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_GroupOnShapeDlg.h"
49 #include "SMESHGUI_DeleteGroupDlg.h"
50 #include "SMESHGUI_SmoothingDlg.h"
51 #include "SMESHGUI_RenumberingDlg.h"
52 #include "SMESHGUI_ExtrusionDlg.h"
53 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
54 #include "SMESHGUI_RevolutionDlg.h"
55 #include "SMESHGUI_TranslationDlg.h"
56 #include "SMESHGUI_RotationDlg.h"
57 #include "SMESHGUI_SymmetryDlg.h"
58 #include "SMESHGUI_SewingDlg.h"
59 #include "SMESHGUI_EditMeshDlg.h"
60 #include "SMESHGUI_MeshPatternDlg.h"
61 #include "SMESHGUI_Selection.h"
62 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
63 #include "SMESHGUI_ConvToQuadOp.h"
64 #include "SMESHGUI_MeshOp.h"
65 #include "SMESHGUI_Displayer.h"
66 #include "SMESHGUI_MakeNodeAtPointDlg.h"
67 #include "SMESHGUI_BuildCompoundDlg.h"
68 #include "SMESHGUI_ComputeDlg.h"
69 #include "SMESHGUI_FileInfoDlg.h"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
79 #include <SMESH_Client.hxx>
80 #include <SMESH_Actor.h>
81 #include <SMESH_TypeFilter.hxx>
83 // SALOME GUI includes
84 #include <SalomeApp_Tools.h>
85 #include <SalomeApp_Study.h>
86 #include <SalomeApp_Application.h>
87 #include <SalomeApp_CheckFileDlg.h>
89 #include <LightApp_DataOwner.h>
90 #include <LightApp_Preferences.h>
91 #include <LightApp_SelectionMgr.h>
92 #include <LightApp_UpdateFlags.h>
93 #include <LightApp_NameDlg.h>
95 #include <SVTK_ViewWindow.h>
96 #include <SVTK_ViewModel.h>
97 #include <SVTK_ViewManager.h>
99 #include <SUIT_MessageBox.h>
100 #include <SUIT_ResourceMgr.h>
101 #include <SUIT_FileDlg.h>
102 #include <SUIT_Desktop.h>
103 #include <SUIT_OverrideCursor.h>
104 #include <SUIT_Session.h>
106 #include <QtxPopupMgr.h>
107 #include <QtxFontEdit.h>
109 #include <SALOME_ListIO.hxx>
110 #include <SALOME_ListIteratorOfListIO.hxx>
113 #include <SALOMEconfig.h>
114 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
115 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
118 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
122 #include <boost/shared_ptr.hpp>
125 #include <vtkScalarBarActor.h>
126 #include <vtkCamera.h>
127 #include <vtkRenderer.h>
128 #include <vtkPlane.h>
130 // SALOME KERNEL includes
131 #include <SALOMEDS_Study.hxx>
132 #include <SALOMEDSClient_StudyBuilder.hxx>
133 #include <SALOMEDSClient_SComponent.hxx>
134 #include <SALOMEDSClient_ClientFactory.hxx>
135 #include <SALOMEDSClient_IParameters.hxx>
138 #include <Standard_ErrorHandler.hxx>
139 #include <NCollection_DataMap.hxx>
143 //=============================================================
144 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
147 void ExportMeshToFile(int theCommandID);
149 void SetDisplayMode(int theCommandID);
151 void SetDisplayEntity(int theCommandID);
153 void Control( int theCommandID );
157 //=============================================================
158 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
162 std::string myExtension;
164 if ( theCommandID == 113 ) {
165 filter.append( QObject::tr( "MED files (*.med)" ) );
166 filter.append( QObject::tr( "All files (*)" ) );
168 else if ( theCommandID == 112 ) {
169 filter.append( QObject::tr( "IDEAS files (*.unv)" ) );
171 else if ( theCommandID == 111 ) {
172 filter.append( QObject::tr( "DAT files (*.dat)" ) );
175 QString anInitialPath = "";
176 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
177 anInitialPath = QDir::currentPath();
179 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
182 QObject::tr( "SMESH_IMPORT_MESH" ) );
183 if ( filenames.count() > 0 ) {
184 SUIT_OverrideCursor wc;
185 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
188 bool isEmpty = false;
189 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
190 QString filename = *it;
191 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
193 switch ( theCommandID ) {
196 // DAT format (currently unsupported)
197 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
198 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
204 aMeshes->length( 1 );
205 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
206 if ( aMeshes[0]->_is_nil() )
207 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
208 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
214 SMESH::DriverMED_ReadStatus res;
215 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
216 if ( res != SMESH::DRS_OK ) {
217 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
218 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
224 catch ( const SALOME::SALOME_Exception& S_ex ) {
225 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
226 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
229 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
230 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
232 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
233 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
234 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
235 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
236 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
244 // update Object browser
245 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
247 // show Error message box if there were errors
248 if ( errors.count() > 0 ) {
249 SUIT_MessageBox::critical( SMESHGUI::desktop(),
250 QObject::tr( "SMESH_ERROR" ),
251 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
254 // show warning message box, if some imported mesh is empty
256 SUIT_MessageBox::warning( SMESHGUI::desktop(),
257 QObject::tr( "SMESH_WRN_WARNING" ),
258 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
263 void ExportMeshToFile( int theCommandID )
265 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
266 SALOME_ListIO selected;
268 aSel->selectedObjects( selected );
270 SMESH::SMESH_Mesh_var aMesh;
271 if(selected.Extent() == 1)
272 aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(selected.First());
273 if ( aMesh->_is_nil() ) {
274 SUIT_MessageBox::warning( SMESHGUI::desktop(),
275 QObject::tr( "SMESH_WRN_WARNING" ),
276 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
280 Handle(SALOME_InteractiveObject) anIObject = selected.First();
281 QString aFilter, aTitle = QObject::tr("Export mesh");
282 QMap<QString, SMESH::MED_VERSION> aFilterMap;
283 QMap<QString, int> aFilterMapSTL;
284 switch ( theCommandID ) {
288 if (aMesh->HasDuplicatedGroupNamesMED()) {
289 int aRet = SUIT_MessageBox::warning
290 (SMESHGUI::desktop(),
291 QObject::tr("SMESH_WRN_WARNING"),
292 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
293 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
294 if (aRet != SUIT_MessageBox::Yes)
298 QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
299 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
300 aFilterMap.insert( QString("MED ") + v21 + " (*.med)", SMESH::MED_V2_1 );
301 aFilterMap.insert( QString("MED ") + v22 + " (*.med)", SMESH::MED_V2_2 );
306 aFilter = QObject::tr("DAT files (*.dat)");
311 if (aMesh->NbPyramids()) {
312 int aRet = SUIT_MessageBox::warning
313 (SMESHGUI::desktop(),
314 QObject::tr("SMESH_WRN_WARNING"),
315 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
316 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
317 if (aRet != SUIT_MessageBox::Yes)
320 aFilter = QObject::tr("IDEAS files (*.unv)");
328 there must be check on others mesh elements not equal triangles
330 if (aMesh->NbTriangles() < 1) {
331 SUIT_MessageBox::warning
332 (SMESHGUI::desktop(),
333 QObject::tr("SMESH_WRN_WARNING"),
334 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()));
337 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
338 int aRet = SUIT_MessageBox::warning
339 (SMESHGUI::desktop(),
340 QObject::tr("SMESH_WRN_WARNING"),
341 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
342 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
343 if (aRet != SUIT_MessageBox::Yes)
347 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
348 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
356 SMESH::MED_VERSION aFormat;
357 // Init the parameter with the default value
358 bool aIsASCII_STL = true;
359 bool toCreateGroups = false;
360 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
362 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
364 QString anInitialPath = "";
365 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
366 anInitialPath = QDir::currentPath();
368 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141) {
369 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
370 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + anIObject->getName(),
371 aFilter, aTitle, false);
373 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
375 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
376 for ( ; it != aFilterMapSTL.end(); ++it )
377 filters.push_back( it.key() );
379 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
380 fd->setWindowTitle( aTitle );
381 fd->setFilters( filters );
382 fd->selectFilter( QObject::tr("STL ASCII (*.stl)") );
383 if ( !anInitialPath.isEmpty() )
384 fd->setDirectory( anInitialPath );
385 fd->selectFile(anIObject->getName());
389 aFilename = fd->selectedFile();
390 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
395 else { // Export to MED
397 QString aDefaultFilter;
398 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
399 for ( ; it != aFilterMap.end(); ++it ) {
400 filters.push_back( it.key() );
401 if (it.value() == SMESH::MED_V2_2)
402 aDefaultFilter = it.key();
405 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
406 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
407 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
408 fd->setWindowTitle( aTitle );
409 fd->setFilters( filters );
410 //fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
411 fd->selectFilter(aDefaultFilter);
412 fd->SetChecked(toCreateGroups);
413 if ( !anInitialPath.isEmpty() )
414 fd->setDirectory( anInitialPath );
415 fd->selectFile(anIObject->getName());
419 aFilename = fd->selectedFile();
420 aFormat = aFilterMap[fd->selectedFilter()];
422 if ( !aFilename.isEmpty()
423 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
424 && aFormat==SMESH::MED_V2_1) {
425 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
426 QObject::tr("SMESH_WRN_WARNING"),
427 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
428 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::Yes);
429 if (aRet != SUIT_MessageBox::Yes) {
434 toCreateGroups = fd->IsChecked();
437 if ( !aFilename.isEmpty() ) {
438 // Check whether the file already exists and delete it if yes
439 QFile aFile( aFilename );
440 if ( aFile.exists() )
442 SUIT_OverrideCursor wc;
445 bool Renumber = false;
446 // PAL 14172 : Check of we have to renumber or not from the preferences before export
448 Renumber= resMgr->booleanValue("SMESH","renumbering");
450 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
451 aMeshEditor->RenumberNodes();
452 aMeshEditor->RenumberElements();
453 if ( SMESHGUI::automaticUpdate() )
456 switch ( theCommandID ) {
459 aMesh->ExportToMED( aFilename.toLatin1().data(), toCreateGroups, aFormat );
463 aMesh->ExportDAT( aFilename.toLatin1().data() );
467 aMesh->ExportUNV( aFilename.toLatin1().data() );
471 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
477 catch (const SALOME::SALOME_Exception& S_ex){
479 SUIT_MessageBox::warning(SMESHGUI::desktop(),
480 QObject::tr("SMESH_WRN_WARNING"),
481 QObject::tr("SMESH_EXPORT_FAILED"));
487 inline void InverseEntityMode(unsigned int& theOutputMode,
488 unsigned int theMode)
490 bool anIsNotPresent = ~theOutputMode & theMode;
492 theOutputMode |= theMode;
494 theOutputMode &= ~theMode;
497 void SetDisplayEntity(int theCommandID){
498 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
499 SALOME_ListIO selected;
501 aSel->selectedObjects( selected );
503 if(selected.Extent() >= 1){
504 SALOME_ListIteratorOfListIO It( selected );
505 for( ; It.More(); It.Next()){
506 Handle(SALOME_InteractiveObject) IObject = It.Value();
507 if(IObject->hasEntry()){
508 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
509 unsigned int aMode = anActor->GetEntityMode();
510 switch(theCommandID){
512 InverseEntityMode(aMode,SMESH_Actor::eEdges);
515 InverseEntityMode(aMode,SMESH_Actor::eFaces);
518 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
521 aMode = SMESH_Actor::eAllEntity;
525 anActor->SetEntityMode(aMode);
533 SALOME_ListIO selected;
534 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
538 LightApp_SelectionMgr* aSel = app->selectionMgr();
539 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
540 if( !aSel || !appStudy )
543 aSel->selectedObjects( selected );
544 if( selected.IsEmpty() )
547 Handle(SALOME_InteractiveObject) anIObject = selected.First();
549 _PTR(Study) aStudy = appStudy->studyDS();
550 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
551 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
552 if( aMainObject->_is_nil() )
555 aMainObject->SetAutoColor( true );
557 QList<SALOMEDS::Color> aReservedColors;
559 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
560 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
562 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
563 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
565 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
566 aGroupObject->SetColor( aColor );
567 aReservedColors.append( aColor );
569 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
570 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
572 if( aGroupObject->GetType() == SMESH::NODE )
573 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
574 else if( aGroupObject->GetType() == SMESH::EDGE )
575 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
577 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
581 SMESH::RepaintCurrentView();
584 void DisableAutoColor(){
585 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
586 SALOME_ListIO selected;
588 aSel->selectedObjects( selected );
590 if(selected.Extent()){
591 Handle(SALOME_InteractiveObject) anIObject = selected.First();
592 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
593 if ( !aMesh->_is_nil() ) {
594 aMesh->SetAutoColor( false );
599 void SetDisplayMode(int theCommandID){
600 SALOME_ListIO selected;
601 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
605 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
606 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
607 if( !aSel || !appStudy )
610 _PTR(Study) aStudy = appStudy->studyDS();
612 aSel->selectedObjects( selected );
614 if(selected.Extent() >= 1){
615 switch(theCommandID){
617 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
618 (new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI() ))->show();
622 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
623 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
626 SALOME_ListIteratorOfListIO It( selected );
627 for( ; It.More(); It.Next()){
628 Handle(SALOME_InteractiveObject) IObject = It.Value();
629 if(IObject->hasEntry()){
630 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
631 switch(theCommandID){
633 anActor->SetRepresentation(SMESH_Actor::eEdge);
636 anActor->SetRepresentation(SMESH_Actor::eSurface);
639 if(anActor->IsShrunk())
642 anActor->SetShrink();
645 anActor->SetRepresentation(SMESH_Actor::ePoint);
648 vtkFloatingPointType color[3];
649 anActor->GetSufaceColor(color[0], color[1], color[2]);
650 int c0 = int (color[0] * 255);
651 int c1 = int (color[1] * 255);
652 int c2 = int (color[2] * 255);
653 QColor c(c0, c1, c2);
655 vtkFloatingPointType edgecolor[3];
656 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
657 c0 = int (edgecolor[0] * 255);
658 c1 = int (edgecolor[1] * 255);
659 c2 = int (edgecolor[2] * 255);
660 QColor e(c0, c1, c2);
662 vtkFloatingPointType backfacecolor[3];
663 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
664 c0 = int (backfacecolor[0] * 255);
665 c1 = int (backfacecolor[1] * 255);
666 c2 = int (backfacecolor[2] * 255);
667 QColor b(c0, c1, c2);
669 vtkFloatingPointType nodecolor[3];
670 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
671 c0 = int (nodecolor[0] * 255);
672 c1 = int (nodecolor[1] * 255);
673 c2 = int (nodecolor[2] * 255);
674 QColor n(c0, c1, c2);
676 int Edgewidth = (int)anActor->GetLineWidth();
679 int intValue = int(anActor->GetNodeSize());
680 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
682 SMESHGUI_Preferences_ColorDlg *aDlg =
683 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
684 aDlg->SetColor(1, c);
685 aDlg->SetColor(2, e);
686 aDlg->SetColor(3, n);
687 aDlg->SetColor(4, b);
688 aDlg->SetIntValue(1, Edgewidth);
689 aDlg->SetIntValue(2, intValue);
690 aDlg->SetIntValue(3, int(Shrink*100.));
692 QColor color = aDlg->GetColor(1);
693 QColor edgecolor = aDlg->GetColor(2);
694 QColor nodecolor = aDlg->GetColor(3);
695 QColor backfacecolor = aDlg->GetColor(4);
696 /* actor color and backface color */
697 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
698 vtkFloatingPointType (color.green()) / 255.,
699 vtkFloatingPointType (color.blue()) / 255.);
700 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
701 vtkFloatingPointType (backfacecolor.green()) / 255.,
702 vtkFloatingPointType (backfacecolor.blue()) / 255.);
705 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
706 vtkFloatingPointType (edgecolor.green()) / 255.,
707 vtkFloatingPointType (edgecolor.blue()) / 255.);
709 /* Shrink factor and size edges */
710 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
711 anActor->SetLineWidth(aDlg->GetIntValue(1));
713 /* Nodes color and size */
714 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
715 vtkFloatingPointType (nodecolor.green()) / 255.,
716 vtkFloatingPointType (nodecolor.blue()) / 255.);
717 anActor->SetNodeSize(aDlg->GetIntValue(2));
719 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
720 if( !aGroupObject->_is_nil() )
722 SALOMEDS::Color aColor;
723 aColor.R = (float)color.red() / 255.0;
724 aColor.G = (float)color.green() / 255.0;
725 aColor.B = (float)color.blue() / 255.0;
726 aGroupObject->SetColor( aColor );
736 SMESH::RepaintCurrentView();
740 void Control( int theCommandID )
742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
743 SALOME_ListIO selected;
745 aSel->selectedObjects( selected );
747 if( !selected.IsEmpty() ){
748 Handle(SALOME_InteractiveObject) anIO = selected.First();
751 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
752 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
753 switch ( theCommandID ){
755 aTitle = QObject::tr( "LENGTH_EDGES" );
756 aControl = SMESH_Actor::eLength;
759 aTitle = QObject::tr( "LENGTH2D_EDGES" );
760 aControl = SMESH_Actor::eLength2D;
763 aTitle = QObject::tr( "FREE_EDGES" );
764 aControl = SMESH_Actor::eFreeEdges;
767 aTitle = QObject::tr( "FREE_BORDERS" );
768 aControl = SMESH_Actor::eFreeBorders;
771 aTitle = QObject::tr( "MULTI_BORDERS" );
772 aControl = SMESH_Actor::eMultiConnection;
775 aTitle = QObject::tr( "MULTI2D_BORDERS" );
776 aControl = SMESH_Actor::eMultiConnection2D;
779 aTitle = QObject::tr( "AREA_ELEMENTS" );
780 aControl = SMESH_Actor::eArea;
783 aTitle = QObject::tr( "TAPER_ELEMENTS" );
784 aControl = SMESH_Actor::eTaper;
787 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
788 aControl = SMESH_Actor::eAspectRatio;
791 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
792 aControl = SMESH_Actor::eAspectRatio3D;
795 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
796 aControl = SMESH_Actor::eMinimumAngle;
799 aTitle = QObject::tr( "WARP_ELEMENTS" );
800 aControl = SMESH_Actor::eWarping;
803 aTitle = QObject::tr( "SKEW_ELEMENTS" );
804 aControl = SMESH_Actor::eSkew;
807 aTitle = QObject::tr( "SMESH_VOLUME" );
808 aControl = SMESH_Actor::eVolume3D;
811 anActor->SetControlMode(aControl);
812 anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
813 SMESH::RepaintCurrentView();
820 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
821 MeshObjectType theType,
822 const QString theInTypeName,
823 QString & theOutTypeName)
825 SMESH_TypeFilter aTypeFilter( theType );
827 if( !theIO.IsNull() )
829 entry = theIO->getEntry();
830 LightApp_DataOwner owner( entry );
831 if ( aTypeFilter.isOk( &owner )) {
832 theOutTypeName = theInTypeName;
840 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
842 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
843 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
845 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
846 CORBA::String_var anID = aSComp->GetID().c_str();
847 if (!strcmp(anID.in(),theIO->getEntry()))
853 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
854 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
855 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
856 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
857 CheckOIType ( theIO, GROUP, "Group", aTypeName )
865 QString CheckHomogeneousSelection()
867 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
868 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
869 SALOME_ListIO selected;
871 aSel->selectedObjects( selected );
873 QString RefType = CheckTypeObject(selected.First());
874 SALOME_ListIteratorOfListIO It(selected);
875 for ( ; It.More(); It.Next())
877 Handle(SALOME_InteractiveObject) IObject = It.Value();
878 QString Type = CheckTypeObject(IObject);
879 if (Type.compare(RefType) != 0)
880 return "Heterogeneous Selection";
887 void SMESHGUI::OnEditDelete()
889 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
890 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
891 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
893 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
894 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
895 _PTR(GenericAttribute) anAttr;
896 _PTR(AttributeIOR) anIOR;
900 QString aParentComponent = QString::null;
901 Handle(SALOME_InteractiveObject) anIO;
902 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
905 QString cur = anIO->getComponentDataType();
906 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
908 // check if object is reference
909 _PTR(SObject) aRefSObj;
910 aNameList.append("\n - ");
911 if ( aSO->ReferencedObject( aRefSObj ) ) {
912 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
913 aNameList.append( aRefName );
914 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
917 aNameList.append(anIO->getName());
921 if( aParentComponent.isNull() )
922 aParentComponent = cur;
923 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
924 aParentComponent = "";
927 if ( objectCount == 0 )
928 return; // No Valid Objects Selected
930 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
931 SUIT_MessageBox::warning( SMESHGUI::desktop(),
932 QObject::tr("ERR_ERROR"),
933 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
936 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
937 if (SUIT_MessageBox::warning
938 (SMESHGUI::desktop(),
939 QObject::tr("SMESH_WRN_WARNING"),
940 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
941 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
942 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
945 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
946 SUIT_ViewManager* vm = anApp->activeViewManager();
947 int nbSf = vm->getViewsCount();
949 SALOME_ListIteratorOfListIO It(selected);
951 aStudyBuilder->NewCommand(); // There is a transaction
952 for( ; It.More(); It.Next()){ // loop on selected IO's
953 Handle(SALOME_InteractiveObject) IObject = It.Value();
954 if(IObject->hasEntry()) {
955 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
957 // disable removal of "SMESH" component object
958 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
960 if ( engineIOR() == anIOR->Value().c_str() )
963 //Check the referenced object
964 _PTR(SObject) aRefSObject;
965 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
966 aSO = aRefSObject; // Delete main Object instead of reference
968 // put the whole hierarchy of sub-objects of the selected SO into a list and
969 // then treat them all starting from the deepest objects (at list back)
971 std::list< _PTR(SObject) > listSO;
972 listSO.push_back( aSO );
973 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
974 for ( ; itSO != listSO.end(); ++itSO ) {
975 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
976 for (it->InitEx(false); it->More(); it->Next())
977 listSO.push_back( it->Value() );
980 // treat SO's in the list starting from the back
982 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
983 for ( ; ritSO != listSO.rend(); ++ritSO ) {
984 _PTR(SObject) SO = *ritSO;
986 std::string anEntry = SO->GetID();
988 /** Erase graphical object **/
989 if(SO->FindAttribute(anAttr, "AttributeIOR")){
990 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
991 for(int i = 0; i < nbSf; i++){
992 SUIT_ViewWindow *sf = aViews[i];
993 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
994 SMESH::RemoveActor(sf,anActor);
999 /** Remove an object from data structures **/
1000 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1001 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1002 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1003 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1004 aMesh->RemoveGroup( aGroup );
1006 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1007 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1008 aMesh->RemoveSubMesh( aSubMesh );
1010 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1012 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1015 IObject = new SALOME_InteractiveObject
1016 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1017 QString objType = CheckTypeObject(IObject);
1018 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1019 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1020 aStudyBuilder->RemoveObjectWithChildren( SO );
1022 else {// default action: remove SObject from the study
1023 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1024 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1026 aStudyBuilder->RemoveObjectWithChildren( SO );
1030 } /* listSO back loop */
1031 } /* IObject->hasEntry() */
1033 aStudyBuilder->CommitCommand();
1035 /* Clear any previous selection */
1037 aSel->setSelectedObjects( l1 );
1039 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1044 SMESHGUI_EXPORT CAM_Module* createModule()
1046 return new SMESHGUI();
1050 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1052 //=============================================================================
1056 //=============================================================================
1057 SMESHGUI::SMESHGUI() :
1058 SalomeApp_Module( "SMESH" )
1060 if ( CORBA::is_nil( myComponentSMESH ) )
1062 CORBA::Boolean anIsEmbeddedMode;
1063 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1066 myActiveDialogBox = 0;
1067 myFilterLibraryDlg = 0;
1071 SMESH::GetFilterManager();
1072 SMESH::GetPattern();
1074 /* load resources for all available meshers */
1075 SMESH::InitAvailableHypotheses();
1078 //=============================================================================
1082 //=============================================================================
1083 SMESHGUI::~SMESHGUI()
1085 SMESH::GetFilterManager()->Destroy();
1086 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1089 //=============================================================================
1093 //=============================================================================
1094 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1096 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1098 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1103 bool SMESHGUI::automaticUpdate()
1105 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1109 return resMgr->booleanValue( "SMESH", "auto_update", false );
1112 //=============================================================================
1116 //=============================================================================
1117 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1119 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1122 //=============================================================================
1126 //=============================================================================
1127 SMESHGUI* SMESHGUI::GetSMESHGUI()
1129 SMESHGUI* smeshMod = 0;
1130 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1133 CAM_Module* module = app->module( "Mesh" );
1134 smeshMod = dynamic_cast<SMESHGUI*>( module );
1137 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1139 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1142 _PTR(Study) aStudy = study->studyDS();
1144 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1153 Standard_EXPORT SMESHGUI* GetComponentGUI()
1155 return SMESHGUI::GetSMESHGUI();
1159 //=============================================================================
1163 //=============================================================================
1164 void SMESHGUI::SetState(int aState)
1169 //=============================================================================
1173 //=============================================================================
1174 void SMESHGUI::ResetState()
1179 //=============================================================================
1183 //=============================================================================
1184 void SMESHGUI::EmitSignalDeactivateDialog()
1186 emit SignalDeactivateActiveDialog();
1189 //=============================================================================
1193 //=============================================================================
1194 void SMESHGUI::EmitSignalStudyFrameChanged()
1196 emit SignalStudyFrameChanged();
1199 //=============================================================================
1203 //=============================================================================
1204 void SMESHGUI::EmitSignalCloseAllDialogs()
1206 emit SignalCloseAllDialogs();
1209 //=============================================================================
1213 //=============================================================================
1214 QDialog *SMESHGUI::GetActiveDialogBox()
1216 return myActiveDialogBox;
1219 //=============================================================================
1223 //=============================================================================
1224 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1226 myActiveDialogBox = (QDialog *) aDlg;
1230 //=============================================================================
1234 //=============================================================================
1235 SUIT_Desktop* SMESHGUI::desktop()
1237 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1239 return app->desktop();
1244 //=============================================================================
1248 //=============================================================================
1249 SalomeApp_Study* SMESHGUI::activeStudy()
1251 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1253 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1258 //=============================================================================
1262 //=============================================================================
1263 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1265 /* Here the position is on the bottom right corner - 10 */
1266 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1268 SUIT_Desktop *PP = desktop();
1269 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1270 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1274 //=============================================================================
1278 //=============================================================================
1279 static int isStudyLocked(_PTR(Study) theStudy){
1280 return theStudy->GetProperties()->IsLocked();
1283 static bool checkLock(_PTR(Study) theStudy) {
1284 if (isStudyLocked(theStudy)) {
1285 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1286 QObject::tr("WRN_WARNING"),
1287 QObject::tr("WRN_STUDY_LOCKED") );
1293 //=======================================================================
1294 //function : CheckActiveStudyLocked
1296 //=======================================================================
1298 bool SMESHGUI::isActiveStudyLocked()
1300 _PTR(Study) aStudy = activeStudy()->studyDS();
1301 return checkLock( aStudy );
1304 //=============================================================================
1308 //=============================================================================
1309 bool SMESHGUI::OnGUIEvent( int theCommandID )
1311 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1315 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1316 SUIT_ResourceMgr* mgr = resourceMgr();
1320 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1321 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1324 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1325 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1327 //QAction* act = action( theCommandID );
1329 switch (theCommandID) {
1331 if(checkLock(aStudy)) break;
1339 if(checkLock(aStudy)) break;
1340 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1344 case 150: //MED FILE INFORMATION
1346 SALOME_ListIO selected;
1347 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1349 aSel->selectedObjects( selected );
1350 if( selected.Extent() )
1352 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1353 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1354 if ( !aMesh->_is_nil() )
1356 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1363 case 122: // EXPORT MED
1372 ::ExportMeshToFile(theCommandID);
1376 case 200: // SCALAR BAR
1378 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1379 SALOME_ListIO selected;
1381 aSel->selectedObjects( selected );
1383 if( selected.Extent() ) {
1384 Handle(SALOME_InteractiveObject) anIO = selected.First();
1385 if( anIO->hasEntry() ) {
1386 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1387 anActor->SetControlMode( SMESH_Actor::eNone );
1395 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1405 ::DisableAutoColor();
1408 case 1134: // Clipping
1409 case 1133: // Tranparency
1410 case 1132: // Colors / Size
1417 ::SetDisplayMode(theCommandID);
1423 case 219: // Volumes
1424 case 220: // All Entity
1425 ::SetDisplayEntity(theCommandID);
1428 case 221: // Orientation of faces
1430 LightApp_SelectionMgr* mgr = selectionMgr();
1431 SALOME_ListIO selected; mgr->selectedObjects( selected );
1433 SALOME_ListIteratorOfListIO it(selected);
1434 for( ; it.More(); it.Next()) {
1435 Handle(SALOME_InteractiveObject) anIObject = it.Value();
1436 if(anIObject->hasEntry()) {
1437 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
1438 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
1447 if(checkLock(aStudy)) break;
1449 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1452 SMESH::UpdateView();
1454 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1455 SMESH::OnVisuException();
1457 catch (...) { // PAL16774 (Crash after display of many groups)
1458 SMESH::OnVisuException();
1462 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1463 aSel->selectedObjects( l );
1464 aSel->setSelectedObjects( l );
1469 case 301: // DISPLAY
1470 case 302: // DISPLAY ONLY
1472 SMESH::EDisplaing anAction;
1473 switch (theCommandID) {
1474 case 300: anAction = SMESH::eErase; break;
1475 case 301: anAction = SMESH::eDisplay; break;
1476 case 302: anAction = SMESH::eDisplayOnly; break;
1479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1480 SALOME_ListIO sel_objects, to_process;
1482 aSel->selectedObjects( sel_objects );
1484 if( theCommandID==302 )
1485 startOperation( myEraseAll );
1487 extractContainers( sel_objects, to_process );
1490 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1494 SALOME_ListIteratorOfListIO It( to_process );
1495 for ( ; It.More(); It.Next()) {
1496 Handle(SALOME_InteractiveObject) IOS = It.Value();
1497 if (IOS->hasEntry()) {
1498 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1499 break; // PAL16774 (Crash after display of many groups)
1500 if (anAction == SMESH::eDisplayOnly)
1501 anAction = SMESH::eDisplay;
1506 // PAL13338 + PAL15161 -->
1507 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1508 SMESH::UpdateView();
1509 // PAL13338 + PAL15161 <--
1511 catch (...) { // PAL16774 (Crash after display of many groups)
1512 SMESH::OnVisuException();
1515 if (anAction == SMESH::eErase) {
1517 aSel->setSelectedObjects( l1 );
1520 aSel->setSelectedObjects( to_process );
1527 if(checkLock(aStudy)) break;
1530 EmitSignalDeactivateDialog();
1532 ( new SMESHGUI_NodesDlg( this ) )->show();
1535 SUIT_MessageBox::warning(desktop(),
1536 tr("SMESH_WRN_WARNING"),
1537 tr("SMESH_WRN_VIEWER_VTK"));
1542 case 2151: // FILTER
1546 EmitSignalDeactivateDialog();
1547 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
1552 case 406: // MOVE NODE
1556 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1557 tr( "NOT_A_VTK_VIEWER" ) );
1561 if(checkLock(aStudy)) break;
1562 ( new SMESHGUI_MoveNodesDlg( this ) )->show();
1566 case 701: // COMPUTE MESH
1567 case 711: // PRECOMPUTE MESH
1569 if (checkLock(aStudy)) break;
1570 startOperation( theCommandID );
1574 case 702: // Create mesh
1575 case 703: // Create sub-mesh
1576 case 704: // Edit mesh/sub-mesh
1577 startOperation( theCommandID );
1579 case 710: // Build compound mesh
1581 if (checkLock(aStudy)) break;
1582 EmitSignalDeactivateDialog();
1583 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
1587 case 407: // DIAGONAL INVERSION
1588 case 408: // Delete diagonal
1592 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1593 tr( "NOT_A_VTK_VIEWER" ) );
1597 if ( checkLock( aStudy ) )
1600 /*Standard_Boolean aRes;
1601 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1602 if ( aMesh->_is_nil() )
1604 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1605 tr( "SMESH_BAD_SELECTION" ) );
1609 EmitSignalDeactivateDialog();
1610 if ( theCommandID == 407 )
1611 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
1613 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
1616 case 409: // Change orientation
1617 case 410: // Union of triangles
1618 case 411: // Cutting of quadrangles
1622 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1623 tr( "NOT_A_VTK_VIEWER" ) );
1627 if ( checkLock( aStudy ) )
1630 EmitSignalDeactivateDialog();
1631 SMESHGUI_MultiEditDlg* aDlg = NULL;
1632 if ( theCommandID == 409 )
1633 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1634 else if ( theCommandID == 410 )
1635 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1637 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1642 case 412: // Smoothing
1644 if(checkLock(aStudy)) break;
1646 EmitSignalDeactivateDialog();
1647 ( new SMESHGUI_SmoothingDlg( this ) )->show();
1650 SUIT_MessageBox::warning(desktop(),
1651 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1655 case 413: // Extrusion
1657 if (checkLock(aStudy)) break;
1659 EmitSignalDeactivateDialog();
1660 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
1662 SUIT_MessageBox::warning(desktop(),
1663 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1667 case 414: // Revolution
1669 if(checkLock(aStudy)) break;
1671 EmitSignalDeactivateDialog();
1672 ( new SMESHGUI_RevolutionDlg( this ) )->show();
1675 SUIT_MessageBox::warning(desktop(),
1676 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1680 case 415: // Pattern mapping
1682 if ( checkLock( aStudy ) )
1686 EmitSignalDeactivateDialog();
1687 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
1690 SUIT_MessageBox::warning(desktop(),
1691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1695 case 416: // Extrusion along a path
1697 if (checkLock(aStudy)) break;
1699 EmitSignalDeactivateDialog();
1700 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
1702 SUIT_MessageBox::warning(desktop(),
1703 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1707 case 417: // Convert mesh to quadratic
1709 startOperation( 417 );
1710 /* if (checkLock(aStudy)) break;
1712 EmitSignalDeactivateDialog();
1713 new SMESHGUI_ConvToQuadDlg();
1715 SUIT_MessageBox::warning(desktop(),
1716 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
1720 case 806: // CREATE GEO GROUP
1722 startOperation( 806 );
1725 case 801: // CREATE GROUP
1729 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1730 tr( "NOT_A_VTK_VIEWER" ) );
1734 if(checkLock(aStudy)) break;
1735 EmitSignalDeactivateDialog();
1736 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1738 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1739 SALOME_ListIO selected;
1741 aSel->selectedObjects( selected );
1743 int nbSel = selected.Extent();
1745 // check if mesh is selected
1746 aMesh = SMESH::GetMeshByIO( selected.First() );
1748 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
1753 case 802: // CONSTRUCT GROUP
1757 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1758 tr( "NOT_A_VTK_VIEWER" ) );
1762 if(checkLock(aStudy)) break;
1763 EmitSignalDeactivateDialog();
1765 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1766 SALOME_ListIO selected;
1768 aSel->selectedObjects( selected );
1770 int nbSel = selected.Extent();
1772 // check if submesh is selected
1773 Handle(SALOME_InteractiveObject) IObject = selected.First();
1774 if (IObject->hasEntry()) {
1775 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1777 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1778 if (!aSubMesh->_is_nil()) {
1780 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1781 // get submesh elements list by types
1782 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1783 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1784 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1785 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1786 // create group for each type o elements
1787 QString aName = IObject->getName();
1788 if (aNodes->length() > 0) {
1789 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1790 aGroup->Add(aNodes.inout());
1792 if (aEdges->length() > 0) {
1793 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1794 aGroup->Add(aEdges.inout());
1796 if (aFaces->length() > 0) {
1797 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1798 aGroup->Add(aFaces.inout());
1800 if (aVolumes->length() > 0) {
1801 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1802 aGroup->Add(aVolumes.inout());
1807 catch(const SALOME::SALOME_Exception & S_ex){
1808 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1815 SUIT_MessageBox::warning(desktop(),
1816 tr("SMESH_WRN_WARNING"),
1817 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
1822 case 803: // EDIT GROUP
1826 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1827 tr( "NOT_A_VTK_VIEWER" ) );
1831 if(checkLock(aStudy)) break;
1832 EmitSignalDeactivateDialog();
1834 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1835 SALOME_ListIO selected;
1837 aSel->selectedObjects( selected );
1839 SALOME_ListIteratorOfListIO It (selected);
1840 int nbSelectedGroups = 0;
1841 for ( ; It.More(); It.Next() )
1843 SMESH::SMESH_GroupBase_var aGroup =
1844 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1845 if (!aGroup->_is_nil()) {
1847 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
1851 if (nbSelectedGroups == 0)
1853 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
1859 case 804: // Add elements to group
1861 if(checkLock(aStudy)) break;
1862 if (myState == 800) {
1863 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1864 if (aDlg) aDlg->onAdd();
1869 case 805: // Remove elements from group
1871 if(checkLock(aStudy)) break;
1872 if (myState == 800) {
1873 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1874 if (aDlg) aDlg->onRemove();
1879 case 810: // Union Groups
1880 case 811: // Intersect groups
1881 case 812: // Cut groups
1883 if ( checkLock( aStudy ) )
1886 EmitSignalDeactivateDialog();
1888 SMESHGUI_GroupOpDlg* aDlg = 0;
1889 if ( theCommandID == 810 )
1890 aDlg = new SMESHGUI_UnionGroupsDlg( this );
1891 else if ( theCommandID == 811 )
1892 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
1894 aDlg = new SMESHGUI_CutGroupsDlg( this );
1901 case 814: // Create groups of entities from existing groups of superior dimensions
1903 if ( checkLock( aStudy ) )
1906 EmitSignalDeactivateDialog();
1907 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
1913 case 813: // Delete groups with their contents
1917 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
1918 tr( "NOT_A_VTK_VIEWER" ) );
1922 if ( checkLock( aStudy ) )
1925 EmitSignalDeactivateDialog();
1927 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
1931 case 900: // MESH INFOS
1933 EmitSignalDeactivateDialog();
1934 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1935 SALOME_ListIO selected;
1937 aSel->selectedObjects( selected );
1939 if ( selected.Extent() > 1 ) { // a dlg for each IO
1941 SALOME_ListIteratorOfListIO It (selected);
1942 for ( ; It.More(); It.Next() ) {
1943 IOs.Clear(); IOs.Append( It.Value() );
1944 aSel->setSelectedObjects( IOs );
1945 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1947 // restore selection
1948 aSel->setSelectedObjects( selected );
1951 ( new SMESHGUI_MeshInfosDlg( this ) )->show();
1955 case 902: // STANDARD MESH INFOS
1957 EmitSignalDeactivateDialog();
1958 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1959 SALOME_ListIO selected;
1961 aSel->selectedObjects( selected );
1963 if ( selected.Extent() > 1 ) { // a dlg for each IO
1965 SALOME_ListIteratorOfListIO It (selected);
1966 for ( ; It.More(); It.Next() ) {
1968 IOs.Append( It.Value() );
1969 aSel->setSelectedObjects( IOs );
1970 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1972 // restore selection
1973 aSel->setSelectedObjects( selected );
1976 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
1980 case 903: // WHAT IS
1982 EmitSignalDeactivateDialog();
1983 ( new SMESHGUI_WhatIsDlg( this ) )->show();
1987 case 1100: // EDIT HYPOTHESIS
1989 if(checkLock(aStudy)) break;
1991 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1992 SALOME_ListIO selected;
1994 aSel->selectedObjects( selected );
1996 int nbSel = selected.Extent();
1999 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2000 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2002 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2003 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2004 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2005 if ( !aHypothesis->_is_nil() )
2007 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2009 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
2016 updateObjBrowser( true );
2020 case 1101: // RENAME
2022 if ( checkLock( aStudy ) )
2025 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2026 SALOME_ListIO selected;
2028 aSel->selectedObjects( selected );
2030 bool isAny = false; // iss there any appropriate object selected
2032 SALOME_ListIteratorOfListIO It( selected );
2033 for ( ; It.More(); It.Next() )
2035 Handle(SALOME_InteractiveObject) IObject = It.Value();
2036 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
2037 _PTR(GenericAttribute) anAttr;
2038 _PTR(AttributeName) aName;
2041 if ( obj->FindAttribute(anAttr, "AttributeName") )
2044 QString newName = QString(aName->Value().c_str());
2046 // check type to prevent renaming of inappropriate objects
2047 int aType = SMESHGUI_Selection::type(IObject->getEntry(), aStudy);
2048 if (aType == MESH || aType == GROUP ||
2049 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
2050 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
2051 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
2052 aType == HYPOTHESIS || aType == ALGORITHM)
2055 newName = LightApp_NameDlg::getName(desktop(), newName);
2056 if ( !newName.isEmpty() )
2058 //old source: aStudy->renameIObject( IObject, newName );
2059 aName->SetValue( newName.toLatin1().constData() );
2061 // if current object is group update group's name
2062 SMESH::SMESH_GroupBase_var aGroup =
2063 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
2064 if (!aGroup->_is_nil() )
2065 aGroup->SetName( newName.toLatin1().constData() );
2075 SUIT_MessageBox::warning(desktop(),
2076 QObject::tr("SMESH_WRN_WARNING"),
2077 QObject::tr("SMESH_WRN_NO_APPROPRIATE_SELECTION"));
2082 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2084 if(checkLock(aStudy)) break;
2085 SUIT_OverrideCursor wc;
2087 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2088 SALOME_ListIO selected;
2090 aSel->selectedObjects( selected, QString::null, false );
2092 SALOME_ListIteratorOfListIO It(selected);
2093 for (int i = 0; It.More(); It.Next(), i++) {
2094 Handle(SALOME_InteractiveObject) IObject = It.Value();
2095 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2098 aSel->setSelectedObjects( l1 );
2103 case 401: // GEOM::EDGE
2104 case 4021: // TRIANGLE
2106 case 4023: // POLYGON
2110 if(checkLock(aStudy)) break;
2112 EmitSignalDeactivateDialog();
2113 SMDSAbs_ElementType type = SMDSAbs_Edge;
2115 switch (theCommandID) {
2116 case 4021: // TRIANGLE
2117 type = SMDSAbs_Face; nbNodes = 3; break;
2119 type = SMDSAbs_Face; nbNodes = 4; break;
2121 type = SMDSAbs_Volume; nbNodes = 4; break;
2122 case 4023: // POLYGON
2123 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2125 type = SMDSAbs_Volume; nbNodes = 8; break;
2126 case 4033: // POLYHEDRE
2127 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2130 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2133 SUIT_MessageBox::warning(desktop(),
2134 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2138 case 4033: // POLYHEDRON
2140 if(checkLock(aStudy)) break;
2142 EmitSignalDeactivateDialog();
2143 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2146 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2147 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2151 case 4034: // QUADRATIC EDGE
2152 case 4035: // QUADRATIC TRIANGLE
2153 case 4036: // QUADRATIC QUADRANGLE
2154 case 4037: // QUADRATIC TETRAHEDRON
2155 case 4038: // QUADRATIC PYRAMID
2156 case 4039: // QUADRATIC PENTAHEDRON
2157 case 4040: // QUADRATIC HEXAHEDRON
2159 if(checkLock(aStudy)) break;
2161 EmitSignalDeactivateDialog();
2164 switch (theCommandID) {
2166 type = QUAD_EDGE; break;
2168 type = QUAD_TRIANGLE; break;
2170 type = QUAD_QUADRANGLE; break;
2172 type = QUAD_TETRAHEDRON; break;
2174 type = QUAD_PYRAMID; break;
2176 type = QUAD_PENTAHEDRON; break;
2178 type = QUAD_HEXAHEDRON;
2182 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2185 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2186 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2190 case 4041: // REMOVES NODES
2192 if(checkLock(aStudy)) break;
2194 EmitSignalDeactivateDialog();
2195 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2198 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2199 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2203 case 4042: // REMOVES ELEMENTS
2205 if(checkLock(aStudy)) break;
2207 EmitSignalDeactivateDialog();
2208 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2212 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2213 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2217 case 4043: { // CLEAR_MESH
2219 if(checkLock(aStudy)) break;
2221 SALOME_ListIO selected;
2222 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2223 aSel->selectedObjects( selected );
2225 SUIT_OverrideCursor wc;
2226 SALOME_ListIteratorOfListIO It (selected);
2227 for ( ; It.More(); It.Next() )
2229 Handle(SALOME_InteractiveObject) IOS = It.Value();
2230 SMESH::SMESH_Mesh_var aMesh =
2231 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2232 if ( aMesh->_is_nil()) continue;
2234 SMESH::UpdateView(SMESH::eErase, IOS->getEntry());
2236 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2237 SMESH::ModifiedMesh( aMeshSObj, false, true);
2238 // hide groups and submeshes
2239 _PTR(ChildIterator) anIter =
2240 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2241 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2243 _PTR(SObject) so = anIter->Value();
2244 SMESH::UpdateView(SMESH::eErase, so->GetID().c_str());
2247 catch (const SALOME::SALOME_Exception& S_ex){
2249 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2253 SMESH::UpdateView();
2257 case 4051: // RENUMBERING NODES
2259 if(checkLock(aStudy)) break;
2261 EmitSignalDeactivateDialog();
2262 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2266 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2267 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2271 case 4052: // RENUMBERING ELEMENTS
2273 if(checkLock(aStudy)) break;
2275 EmitSignalDeactivateDialog();
2276 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2280 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2281 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2285 case 4061: // TRANSLATION
2287 if(checkLock(aStudy)) break;
2289 EmitSignalDeactivateDialog();
2290 ( new SMESHGUI_TranslationDlg( this ) )->show();
2293 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2294 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2298 case 4062: // ROTATION
2300 if(checkLock(aStudy)) break;
2302 EmitSignalDeactivateDialog();
2303 ( new SMESHGUI_RotationDlg( this ) )->show();
2306 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2307 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2311 case 4063: // SYMMETRY
2313 if(checkLock(aStudy)) break;
2315 EmitSignalDeactivateDialog();
2316 ( new SMESHGUI_SymmetryDlg( this ) )->show();
2319 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2320 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2324 case 4064: // SEWING
2326 if(checkLock(aStudy)) break;
2328 EmitSignalDeactivateDialog();
2329 ( new SMESHGUI_SewingDlg( this ) )->show();
2332 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2333 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2337 case 4065: // MERGE NODES
2339 if(checkLock(aStudy)) break;
2341 EmitSignalDeactivateDialog();
2342 ( new SMESHGUI_EditMeshDlg( this, 0 ) )->show();
2345 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2346 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2350 case 4066: // MERGE EQUAL ELEMENTS
2352 if (checkLock(aStudy)) break;
2354 EmitSignalDeactivateDialog();
2355 ( new SMESHGUI_EditMeshDlg( this, 1 ) )->show();
2357 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2358 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2363 case 4067: // MAKE MESH PASS THROUGH POINT
2364 startOperation( 4067 );
2367 case 5105: // Library of selection filters
2369 static QList<int> aTypes;
2370 if ( aTypes.isEmpty() )
2372 aTypes.append( SMESH::NODE );
2373 aTypes.append( SMESH::EDGE );
2374 aTypes.append( SMESH::FACE );
2375 aTypes.append( SMESH::VOLUME );
2377 if (!myFilterLibraryDlg)
2378 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2379 else if (myFilterLibraryDlg->isHidden())
2380 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2381 myFilterLibraryDlg->raise();
2385 case 6017: // CONTROLS
2401 LightApp_SelectionMgr* mgr = selectionMgr();
2402 SALOME_ListIO selected; mgr->selectedObjects( selected );
2404 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2405 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2407 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2408 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2409 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2410 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2411 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2412 ::Control( theCommandID );
2417 SUIT_MessageBox::warning(desktop(),
2418 tr( "SMESH_WRN_WARNING" ),
2419 tr( "SMESH_BAD_SELECTION" ) );
2423 SUIT_MessageBox::warning(desktop(),
2424 tr( "SMESH_WRN_WARNING" ),
2425 tr( "NOT_A_VTK_VIEWER" ) );
2430 LightApp_SelectionMgr* mgr = selectionMgr();
2431 SALOME_ListIO selected; mgr->selectedObjects( selected );
2433 SALOME_ListIteratorOfListIO it(selected);
2434 for( ; it.More(); it.Next()) {
2435 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2436 if(anIObject->hasEntry()) {
2437 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2438 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2446 LightApp_SelectionMgr* mgr = selectionMgr();
2447 SALOME_ListIO selected; mgr->selectedObjects( selected );
2449 if (selected.Extent() == 1) {
2450 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2451 if(anIObject->hasEntry())
2452 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2453 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2460 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2461 //updateObjBrowser();
2465 //=============================================================================
2469 //=============================================================================
2470 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2475 //=============================================================================
2479 //=============================================================================
2480 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2485 //=============================================================================
2489 //=============================================================================
2490 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2495 //=============================================================================
2496 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2497 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2499 //=============================================================================
2500 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2501 SUIT_ViewWindow* wnd )
2503 if(theIO->hasEntry()){
2504 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2505 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2509 //=======================================================================
2510 // function : createSMESHAction
2512 //=======================================================================
2513 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2516 QWidget* parent = application()->desktop();
2517 SUIT_ResourceMgr* resMgr = resourceMgr();
2519 if ( !icon_id.isEmpty() )
2520 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
2522 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
2523 if ( !pix.isNull() )
2524 icon = QIcon( pix );
2526 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
2527 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
2528 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
2530 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2533 //=======================================================================
2534 // function : createPopupItem
2536 //=======================================================================
2537 void SMESHGUI::createPopupItem( const int id,
2538 const QString& clients,
2539 const QString& types,
2540 const QString& theRule,
2545 parentId = popupMgr()->actionId( action( pId ) );
2547 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2548 popupMgr()->insert( action( id ), parentId, 0 );
2550 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2551 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
2552 QString rule = "(%1) and (%2) and (%3)";
2553 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
2554 if( clients.isEmpty() )
2555 rule = rule.arg( QString( "true" ) );
2557 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2558 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2561 bool cont = myRules.contains( id );
2563 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2565 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
2566 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2569 //=======================================================================
2570 // function : initialize
2572 //=======================================================================
2573 void SMESHGUI::initialize( CAM_Application* app )
2575 SalomeApp_Module::initialize( app );
2577 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2579 /* Automatic Update flag */
2580 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2582 // ----- create actions --------------
2584 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
2585 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
2586 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
2587 createSMESHAction( 114, "NUM" );
2588 createSMESHAction( 121, "DAT" );
2589 createSMESHAction( 122, "MED" );
2590 createSMESHAction( 123, "UNV" );
2591 createSMESHAction( 140, "STL" );
2592 createSMESHAction( 124, "EXPORT_DAT" );
2593 createSMESHAction( 125, "EXPORT_MED" );
2594 createSMESHAction( 126, "EXPORT_UNV" );
2595 createSMESHAction( 141, "EXPORT_STL" );
2596 createSMESHAction( 150, "FILE_INFO" );
2597 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
2598 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2599 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2600 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2601 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2602 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2603 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2604 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
2605 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
2606 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
2607 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2608 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2609 createSMESHAction( 804, "ADD" );
2610 createSMESHAction( 805, "REMOVE" );
2611 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2612 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2613 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2614 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
2615 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2616 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2617 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2618 createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
2619 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
2620 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
2621 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
2622 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
2623 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
2624 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
2625 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
2626 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
2627 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
2628 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2629 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2630 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2631 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2632 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2633 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2634 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2635 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2636 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2637 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2638 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2639 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2640 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2641 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2642 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
2643 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2644 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2645 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2646 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2647 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2648 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2649 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2650 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2651 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2652 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2653 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2654 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2655 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2656 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2657 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2658 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2659 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2660 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2661 createSMESHAction( 415, "MAP", "ICON_MAP" );
2662 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2663 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2664 createSMESHAction( 200, "RESET" );
2665 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2666 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2667 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2668 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2669 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2670 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2671 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2672 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2673 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2674 createSMESHAction( 220, "ALL" );
2675 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
2676 createSMESHAction( 1100, "EDIT_HYPO" );
2677 createSMESHAction( 1101, "RENAME", "", Qt::Key_F2 );
2678 createSMESHAction( 1102, "UNASSIGN" );
2679 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2680 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2681 createSMESHAction( 1131, "DISPMODE" );
2682 createSMESHAction( 1132, "COLORS" );
2683 createSMESHAction( 1133, "TRANSP" );
2684 createSMESHAction( 1134, "CLIP" );
2685 createSMESHAction( 1135, "DISP_ENT" );
2686 createSMESHAction( 1136, "AUTO_COLOR" );
2687 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2688 createSMESHAction( 2000, "CTRL" );
2690 createSMESHAction( 300, "ERASE" );
2691 createSMESHAction( 301, "DISPLAY" );
2692 createSMESHAction( 302, "DISPLAY_ONLY" );
2693 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2694 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2695 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2696 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2697 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2698 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2699 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2700 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2702 // ----- create menu --------------
2703 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2704 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2705 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2706 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2707 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2708 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2709 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2711 createMenu( separator(), fileId );
2713 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
2714 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
2715 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2716 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2717 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2718 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2720 createMenu( 111, importId, -1 );
2721 createMenu( 112, importId, -1 );
2722 createMenu( 113, importId, -1 );
2724 createMenu( 121, exportId, -1 );
2725 createMenu( 122, exportId, -1 );
2726 createMenu( 123, exportId, -1 );
2727 createMenu( 140, exportId, -1 ); // export to stl STL
2729 createMenu( separator(), fileId, 10 );
2731 createMenu( 33, editId, -1 );
2733 createMenu( 5105, toolsId, -1 );
2735 createMenu( 702, meshId, -1 ); // "Mesh" menu
2736 createMenu( 703, meshId, -1 );
2737 createMenu( 704, meshId, -1 );
2738 createMenu( 710, meshId, -1 );
2739 createMenu( separator(), meshId, -1 );
2740 createMenu( 701, meshId, -1 );
2741 createMenu( 711, meshId, -1 );
2742 createMenu( separator(), meshId, -1 );
2743 createMenu( 801, meshId, -1 );
2744 createMenu( 806, meshId, -1 );
2745 createMenu( 802, meshId, -1 );
2746 createMenu( 803, meshId, -1 );
2747 createMenu( separator(), meshId, -1 );
2748 createMenu( 810, meshId, -1 );
2749 createMenu( 811, meshId, -1 );
2750 createMenu( 812, meshId, -1 );
2751 createMenu( separator(), meshId, -1 );
2752 createMenu( 814, meshId, -1 );
2753 createMenu( separator(), meshId, -1 );
2754 createMenu( 813, meshId, -1 );
2755 createMenu( separator(), meshId, -1 );
2756 createMenu( 900, meshId, -1 );
2757 createMenu( 902, meshId, -1 );
2758 createMenu( 903, meshId, -1 );
2759 createMenu( separator(), meshId, -1 );
2761 createMenu( 6003, ctrlId, -1 );
2762 createMenu( 6001, ctrlId, -1 );
2763 createMenu( 6004, ctrlId, -1 );
2764 createMenu( separator(), ctrlId, -1 );
2765 createMenu( 6002, ctrlId, -1 );
2766 createMenu( 6018, ctrlId, -1 );
2767 createMenu( 6019, ctrlId, -1 );
2768 createMenu( 6011, ctrlId, -1 );
2769 createMenu( 6012, ctrlId, -1 );
2770 createMenu( 6013, ctrlId, -1 );
2771 createMenu( 6014, ctrlId, -1 );
2772 createMenu( 6015, ctrlId, -1 );
2773 createMenu( 6016, ctrlId, -1 );
2774 createMenu( separator(), ctrlId, -1 );
2775 createMenu( 6017, ctrlId, -1 );
2776 createMenu( 6009, ctrlId, -1 );
2777 createMenu( separator(), ctrlId, -1 );
2779 createMenu( 400, addId, -1 );
2780 createMenu( 401, addId, -1 );
2781 createMenu( 4021, addId, -1 );
2782 createMenu( 4022, addId, -1 );
2783 createMenu( 4023, addId, -1 );
2784 createMenu( 4031, addId, -1 );
2785 createMenu( 4032, addId, -1 );
2786 createMenu( 4033, addId, -1 );
2787 createMenu( separator(), addId, -1 );
2788 createMenu( 4034, addId, -1 );
2789 createMenu( 4035, addId, -1 );
2790 createMenu( 4036, addId, -1 );
2791 createMenu( 4037, addId, -1 );
2792 createMenu( 4038, addId, -1 );
2793 createMenu( 4039, addId, -1 );
2794 createMenu( 4040, addId, -1 );
2796 createMenu( 4041, removeId, -1 );
2797 createMenu( 4042, removeId, -1 );
2798 createMenu( 4043, removeId, -1 );
2800 createMenu( 4051, renumId, -1 );
2801 createMenu( 4052, renumId, -1 );
2803 createMenu( 4061, transfId, -1 );
2804 createMenu( 4062, transfId, -1 );
2805 createMenu( 4063, transfId, -1 );
2806 createMenu( 4064, transfId, -1 );
2807 createMenu( 4065, transfId, -1 );
2808 createMenu( 4066, transfId, -1 );
2810 createMenu( 406, modifyId, -1 );
2811 createMenu( 4067,modifyId, -1 );
2812 createMenu( 407, modifyId, -1 );
2813 createMenu( 408, modifyId, -1 );
2814 createMenu( 409, modifyId, -1 );
2815 createMenu( 410, modifyId, -1 );
2816 createMenu( 411, modifyId, -1 );
2817 createMenu( 412, modifyId, -1 );
2818 createMenu( 413, modifyId, -1 );
2819 createMenu( 416, modifyId, -1 );
2820 createMenu( 414, modifyId, -1 );
2821 createMenu( 415, modifyId, -1 );
2822 createMenu( 417, modifyId, -1 );
2824 createMenu( 214, viewId, -1 );
2826 // ----- create toolbars --------------
2827 int meshTb = createTool( tr( "TB_MESH" ) ),
2828 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2829 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2830 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2831 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2833 createTool( 702, meshTb );
2834 createTool( 703, meshTb );
2835 createTool( 704, meshTb );
2836 createTool( 710, meshTb );
2837 createTool( separator(), meshTb );
2838 createTool( 701, meshTb );
2839 createTool( 711, meshTb );
2840 createTool( separator(), meshTb );
2841 createTool( 801, meshTb );
2842 createTool( 806, meshTb );
2843 createTool( 802, meshTb );
2844 createTool( 803, meshTb );
2845 createTool( separator(), meshTb );
2846 createTool( 900, meshTb );
2847 createTool( 902, meshTb );
2848 createTool( 903, meshTb );
2849 createTool( separator(), meshTb );
2851 createTool( 6001, ctrlTb );
2852 createTool( 6003, ctrlTb );
2853 createTool( 6004, ctrlTb );
2854 createTool( separator(), ctrlTb );
2855 createTool( 6002, ctrlTb );
2856 createTool( 6018, ctrlTb );
2857 createTool( 6019, ctrlTb );
2858 createTool( 6011, ctrlTb );
2859 createTool( 6012, ctrlTb );
2860 createTool( 6013, ctrlTb );
2861 createTool( 6014, ctrlTb );
2862 createTool( 6015, ctrlTb );
2863 createTool( 6016, ctrlTb );
2864 createTool( separator(), ctrlTb );
2865 createTool( 6017, ctrlTb );
2866 createTool( 6009, ctrlTb );
2867 createTool( separator(), ctrlTb );
2869 createTool( 400, addRemTb );
2870 createTool( 401, addRemTb );
2871 createTool( 4021, addRemTb );
2872 createTool( 4022, addRemTb );
2873 createTool( 4023, addRemTb );
2874 createTool( 4031, addRemTb );
2875 createTool( 4032, addRemTb );
2876 createTool( 4033, addRemTb );
2877 createTool( separator(), addRemTb );
2878 createTool( 4034, addRemTb );
2879 createTool( 4035, addRemTb );
2880 createTool( 4036, addRemTb );
2881 createTool( 4037, addRemTb );
2882 createTool( 4038, addRemTb );
2883 createTool( 4039, addRemTb );
2884 createTool( 4040, addRemTb );
2885 createTool( separator(), addRemTb );
2886 createTool( 4041, addRemTb );
2887 createTool( 4042, addRemTb );
2888 createTool( 4043, addRemTb );
2889 createTool( separator(), addRemTb );
2890 createTool( 4051, addRemTb );
2891 createTool( 4052, addRemTb );
2892 createTool( separator(), addRemTb );
2893 createTool( 4061, addRemTb );
2894 createTool( 4062, addRemTb );
2895 createTool( 4063, addRemTb );
2896 createTool( 4064, addRemTb );
2897 createTool( 4065, addRemTb );
2898 createTool( 4066, addRemTb );
2899 createTool( separator(), addRemTb );
2901 createTool( 406, modifyTb );
2902 createTool( 4067,modifyTb );
2903 createTool( 407, modifyTb );
2904 createTool( 408, modifyTb );
2905 createTool( 409, modifyTb );
2906 createTool( 410, modifyTb );
2907 createTool( 411, modifyTb );
2908 createTool( 412, modifyTb );
2909 createTool( 413, modifyTb );
2910 createTool( 416, modifyTb );
2911 createTool( 414, modifyTb );
2912 createTool( 415, modifyTb );
2913 createTool( 417, modifyTb );
2915 createTool( 214, dispModeTb );
2917 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
2918 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
2921 QString OB = "'ObjectBrowser'",
2922 View = "'" + SVTK_Viewer::Type() + "'",
2924 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2925 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2926 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2927 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2928 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2929 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2930 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2931 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2932 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2933 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2934 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2936 mesh_group = mesh + " " + subMesh + " " + group,
2937 hyp_alg = hypo + " " + algo;
2939 // popup for object browser
2941 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
2942 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
2943 createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
2944 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2945 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2946 createPopupItem( 803, OB, group ); // EDIT_GROUP
2947 popupMgr()->insert( separator(), -1, 0 );
2948 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2949 createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE
2950 createPopupItem( 214, OB, mesh_group ); // UPDATE
2951 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2952 createPopupItem( 902, OB, mesh ); // STD_INFO
2953 createPopupItem( 903, OB, mesh_group ); // WHAT_IS
2954 popupMgr()->insert( separator(), -1, 0 );
2955 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2956 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
2957 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2958 popupMgr()->insert( separator(), -1, 0 );
2959 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
2960 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2961 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg ); // RENAME
2962 popupMgr()->insert( separator(), -1, 0 );
2963 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
2964 popupMgr()->insert( separator(), -1, 0 );
2966 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
2968 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2969 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2970 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2971 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2972 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2973 popupMgr()->insert( separator(), -1, 0 );
2976 createPopupItem( 803, View, group ); // EDIT_GROUP
2977 createPopupItem( 804, View, elems ); // ADD
2978 createPopupItem( 805, View, elems ); // REMOVE
2979 popupMgr()->insert( separator(), -1, 0 );
2980 createPopupItem( 214, View, mesh_group ); // UPDATE
2981 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2982 createPopupItem( 902, View, mesh ); // STD_INFO
2983 createPopupItem( 903, View, mesh_group ); // WHAT_IS
2984 popupMgr()->insert( separator(), -1, 0 );
2986 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2987 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2988 popupMgr()->insert( separator(), -1, 0 );
2992 isInvisible("not( isVisible )"),
2993 isEmpty("numberOfNodes = 0"),
2994 isNotEmpty("numberOfNodes <> 0"),
2996 // has nodes, edges, etc in VISIBLE! actor
2997 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2998 hasElems("(count( elemTypes ) > 0)"),
2999 hasDifferentElems("(count( elemTypes ) > 1)"),
3000 hasEdges("({'Edge'} in elemTypes)"),
3001 hasFaces("({'Face'} in elemTypes)"),
3002 hasVolumes("({'Volume'} in elemTypes)");
3004 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3005 QString aType = QString( "%1type in {%2}" ).arg( lc );
3006 aType = aType.arg( mesh_group );
3007 QString aMeshInVTK = aClient + "&&" + aType;
3009 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3010 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3011 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3013 //-------------------------------------------------
3015 //-------------------------------------------------
3016 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3018 popupMgr()->insert( action( 9010 ), anId, -1 );
3019 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3020 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3022 popupMgr()->insert( action( 9011 ), anId, -1 );
3023 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3024 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3026 popupMgr()->insert( separator(), -1, -1 );
3028 //-------------------------------------------------
3030 //-------------------------------------------------
3031 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3033 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3034 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3035 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3037 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3038 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3039 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3041 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3042 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3043 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3045 popupMgr()->insert( separator(), anId, -1 );
3047 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3048 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3049 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3051 //-------------------------------------------------
3053 //-------------------------------------------------
3054 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3056 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3058 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3059 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3060 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3062 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3063 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3064 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3066 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3067 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3068 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3070 popupMgr()->insert( separator(), anId, -1 );
3072 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3073 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3075 //-------------------------------------------------
3076 // Orientation of faces
3077 //-------------------------------------------------
3078 popupMgr()->insert( action( 221 ), -1, -1 );
3079 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3080 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3082 //-------------------------------------------------
3084 //-------------------------------------------------
3085 popupMgr()->insert( action( 1132 ), -1, -1 );
3086 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3088 //-------------------------------------------------
3090 //-------------------------------------------------
3091 popupMgr()->insert( action( 1133 ), -1, -1 );
3092 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3094 //-------------------------------------------------
3096 //-------------------------------------------------
3097 popupMgr()->insert( action( 1134 ), -1, -1 );
3098 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3100 popupMgr()->insert( separator(), -1, -1 );
3102 //-------------------------------------------------
3104 //-------------------------------------------------
3106 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3107 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3108 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3110 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3112 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3113 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3115 popupMgr()->insert( separator(), anId, -1 );
3117 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
3118 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3119 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3121 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
3122 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3123 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3125 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
3126 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3127 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3129 popupMgr()->insert( separator(), anId, -1 );
3131 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
3132 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3133 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3135 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
3136 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3137 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3139 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
3140 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3141 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3143 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
3144 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3145 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3147 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
3148 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3149 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
3151 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
3152 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3153 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
3155 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
3156 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3157 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
3159 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
3160 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3161 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
3163 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
3164 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3165 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
3167 popupMgr()->insert( separator(), anId, -1 );
3169 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
3170 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3171 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
3173 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
3174 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
3175 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
3177 popupMgr()->insert( separator(), anId, -1 );
3179 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
3180 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3182 popupMgr()->insert( separator(), -1, -1 );
3184 //-------------------------------------------------
3186 //-------------------------------------------------
3187 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3188 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3189 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3190 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
3192 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3193 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
3195 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3196 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
3198 popupMgr()->insert( separator(), -1, -1 );
3200 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3201 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3204 //================================================================================
3206 * \brief Return true if SMESH or GEOM objects are selected.
3207 * Is called form LightApp_Module::activateModule() which clear selection if
3208 * not isSelectionCompatible()
3210 //================================================================================
3212 bool SMESHGUI::isSelectionCompatible()
3214 bool isCompatible = true;
3215 SALOME_ListIO selected;
3216 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
3217 Sel->selectedObjects( selected );
3219 SALOME_ListIteratorOfListIO It( selected );
3220 for ( ; isCompatible && It.More(); It.Next())
3222 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
3223 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
3225 return isCompatible;
3228 bool SMESHGUI::activateModule( SUIT_Study* study )
3230 bool res = SalomeApp_Module::activateModule( study );
3232 setMenuShown( true );
3233 setToolShown( true );
3235 // Reset actions accelerator keys
3236 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
3237 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
3238 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
3240 action( 33)->setEnabled(true); // Delete: Key_Delete
3241 action(1101)->setEnabled(true); // Rename: Key_F2
3246 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3248 setMenuShown( false );
3249 setToolShown( false );
3251 EmitSignalCloseAllDialogs();
3253 // Unset actions accelerator keys
3254 action(111)->setShortcut(QKeySequence()); // Import DAT
3255 action(112)->setShortcut(QKeySequence()); // Import UNV
3256 action(113)->setShortcut(QKeySequence()); // Import MED
3258 action( 33)->setEnabled(false); // Delete: Key_Delete
3259 action(1101)->setEnabled(false); // Rename: Key_F2
3261 return SalomeApp_Module::deactivateModule( study );
3264 void SMESHGUI::studyClosed( SUIT_Study* s )
3266 SMESH::RemoveVisuData( s->id() );
3267 SalomeApp_Module::studyClosed( s );
3270 void SMESHGUI::OnGUIEvent()
3272 const QObject* obj = sender();
3273 if ( !obj || !obj->inherits( "QAction" ) )
3275 int id = actionId((QAction*)obj);
3280 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3282 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3283 if ( CORBA::is_nil( myComponentSMESH ) )
3285 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3287 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3288 return aGUI.myComponentSMESH;
3291 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3292 return myComponentSMESH;
3295 QString SMESHGUI::engineIOR() const
3297 CORBA::ORB_var anORB = getApp()->orb();
3298 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3299 return QString( anIOR.in() );
3302 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
3304 SalomeApp_Module::contextMenuPopup( client, menu, title );
3306 selectionMgr()->selectedObjects( lst );
3307 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
3308 Handle(SALOME_InteractiveObject) io = lst.First();
3309 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
3310 _PTR(Study) study = appStudy->studyDS();
3311 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
3313 QString aName = QString( obj->GetName().c_str() );
3314 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
3315 aName.remove( (aName.length() - 1), 1 );
3321 LightApp_Selection* SMESHGUI::createSelection() const
3323 return new SMESHGUI_Selection();
3326 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3328 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3329 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3332 void SMESHGUI::viewManagers( QStringList& list ) const
3334 list.append( SVTK_Viewer::Type() );
3337 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3339 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3340 SMESH::UpdateSelectionProp( this );
3343 void SMESHGUI::createPreferences()
3345 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3347 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3348 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3350 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3351 setPreferenceProperty( qaGroup, "columns", 2 );
3352 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3353 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3355 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3356 setPreferenceProperty( precGroup, "columns", 2 );
3358 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3360 setPreferenceProperty( prec, "min", 0 );
3361 setPreferenceProperty( prec, "max", 16 );
3363 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3364 setPreferenceProperty( dispgroup, "columns", 2 );
3365 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3367 modes.append( "Wireframe" );
3368 modes.append( "Shading" );
3369 modes.append( "Nodes" );
3370 modes.append( "Shrink" );
3371 QList<QVariant> indices;
3372 indices.append( 0 );
3373 indices.append( 1 );
3374 indices.append( 2 );
3375 indices.append( 3 );
3376 setPreferenceProperty( dispmode, "strings", modes );
3377 setPreferenceProperty( dispmode, "indexes", indices );
3379 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3380 setPreferenceProperty( exportgroup, "columns", 2 );
3381 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3382 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3384 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
3385 setPreferenceProperty( computeGroup, "columns", 2 );
3386 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
3388 modes.append( "Never" );
3389 modes.append( "Errors only" );
3390 modes.append( "Always" );
3392 indices.append( 0 );
3393 indices.append( 1 );
3394 indices.append( 2 );
3395 setPreferenceProperty( notifyMode, "strings", modes );
3396 setPreferenceProperty( notifyMode, "indexes", indices );
3398 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3399 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3400 setPreferenceProperty( nodeGroup, "columns", 2 );
3402 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3403 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3405 setPreferenceProperty( nodeSz, "min", 1 );
3406 setPreferenceProperty( nodeSz, "max", 5 );
3408 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3409 setPreferenceProperty( elemGroup, "columns", 2 );
3411 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3412 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3413 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3414 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
3416 setPreferenceProperty( sp, "hstretch", 0 );
3417 setPreferenceProperty( sp, "vstretch", 0 );
3419 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3420 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3422 setPreferenceProperty( elemW, "min", 1 );
3423 setPreferenceProperty( elemW, "max", 5 );
3425 setPreferenceProperty( shrink, "min", 0 );
3426 setPreferenceProperty( shrink, "max", 100 );
3428 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
3429 setPreferenceProperty( orientGroup, "columns", 1 );
3431 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
3432 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
3434 setPreferenceProperty( orientScale, "min", 0.05 );
3435 setPreferenceProperty( orientScale, "max", 0.5 );
3436 setPreferenceProperty( orientScale, "step", 0.05 );
3438 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
3440 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3442 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3443 setPreferenceProperty( selGroup, "columns", 2 );
3445 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3446 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3447 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3449 setPreferenceProperty( selW, "min", 1 );
3450 setPreferenceProperty( selW, "max", 5 );
3452 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3453 setPreferenceProperty( preGroup, "columns", 2 );
3455 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3456 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3458 setPreferenceProperty( preW, "min", 1 );
3459 setPreferenceProperty( preW, "max", 5 );
3461 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3462 setPreferenceProperty( precSelGroup, "columns", 2 );
3464 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3465 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3466 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3468 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3469 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3470 setPreferenceProperty( fontGr, "columns", 2 );
3472 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3473 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3474 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3475 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3478 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3479 fam.append( tr( "SMESH_FONT_COURIER" ) );
3480 fam.append( tr( "SMESH_FONT_TIMES" ) );
3481 int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
3483 setPreferenceProperty( tfont, "families", fam );
3484 setPreferenceProperty( tfont, "system", false );
3485 setPreferenceProperty( tfont, "widget_flags", wflag );
3486 setPreferenceProperty( lfont, "families", fam );
3487 setPreferenceProperty( lfont, "system", false );
3488 setPreferenceProperty( lfont, "widget_flags", wflag );
3490 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3491 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
3493 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3494 setPreferenceProperty( numcol, "min", 2 );
3495 setPreferenceProperty( numcol, "max", 256 );
3497 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3498 setPreferenceProperty( numlab, "min", 2 );
3499 setPreferenceProperty( numlab, "max", 65 );
3501 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3502 setPreferenceProperty( orientGr, "columns", 2 );
3503 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3504 QStringList orients;
3505 orients.append( tr( "SMESH_VERTICAL" ) );
3506 orients.append( tr( "SMESH_HORIZONTAL" ) );
3507 indices.clear(); indices.append( 0 ); indices.append( 1 );
3508 setPreferenceProperty( orient, "strings", orients );
3509 setPreferenceProperty( orient, "indexes", indices );
3511 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3512 setPreferenceProperty( posVSizeGr, "columns", 2 );
3513 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3514 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3515 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3516 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3517 setPreferenceProperty( xv, "step", 0.1 );
3518 setPreferenceProperty( xv, "min", 0.0 );
3519 setPreferenceProperty( xv, "max", 1.0 );
3520 setPreferenceProperty( yv, "step", 0.1 );
3521 setPreferenceProperty( yv, "min", 0.0 );
3522 setPreferenceProperty( yv, "max", 1.0 );
3523 setPreferenceProperty( wv, "step", 0.1 );
3524 setPreferenceProperty( wv, "min", 0.0 );
3525 setPreferenceProperty( wv, "max", 1.0 );
3526 setPreferenceProperty( hv, "min", 0.0 );
3527 setPreferenceProperty( hv, "max", 1.0 );
3528 setPreferenceProperty( hv, "step", 0.1 );
3530 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3531 setPreferenceProperty( posHSizeGr, "columns", 2 );
3532 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3533 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3534 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3535 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3536 setPreferenceProperty( xv, "min", 0.0 );
3537 setPreferenceProperty( xv, "max", 1.0 );
3538 setPreferenceProperty( xv, "step", 0.1 );
3539 setPreferenceProperty( xh, "min", 0.0 );
3540 setPreferenceProperty( xh, "max", 1.0 );
3541 setPreferenceProperty( xh, "step", 0.1 );
3542 setPreferenceProperty( yh, "min", 0.0 );
3543 setPreferenceProperty( yh, "max", 1.0 );
3544 setPreferenceProperty( yh, "step", 0.1 );
3545 setPreferenceProperty( wh, "min", 0.0 );
3546 setPreferenceProperty( wh, "max", 1.0 );
3547 setPreferenceProperty( wh, "step", 0.1 );
3548 setPreferenceProperty( hh, "min", 0.0 );
3549 setPreferenceProperty( hh, "max", 1.0 );
3550 setPreferenceProperty( hh, "step", 0.1 );
3553 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3555 if( sect=="SMESH" ){
3556 float sbX1,sbY1,sbW,sbH;
3557 float aTol = 1.00000009999999;
3558 std::string aWarning;
3559 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3560 if( name=="selection_object_color" || name=="selection_element_color" ||
3561 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3562 name=="selection_precision_node" || name=="selection_precision_element" ||
3563 name=="selection_precision_object")
3564 SMESH::UpdateSelectionProp( this );
3565 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3566 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3567 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3568 if(sbX1+sbW > aTol){
3569 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3572 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3573 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3576 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3577 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3578 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3579 if(sbY1+sbH > aTol){
3580 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3581 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3582 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3585 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3586 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3587 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3588 if(sbX1+sbW > aTol){
3589 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3592 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3593 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3596 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3597 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3598 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3599 if(sbY1+sbH > aTol){
3600 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3603 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3604 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3608 if(aWarning.size() != 0){
3609 aWarning += "The default values are applied instead.";
3610 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3611 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3612 QObject::tr(aWarning.c_str()));
3617 //================================================================================
3619 * \brief Update something in accordance with update flags
3620 * \param theFlags - update flags
3622 * Update viewer or/and object browser etc. in accordance with update flags ( see
3623 * LightApp_UpdateFlags enumeration ).
3625 //================================================================================
3626 void SMESHGUI::update( const int flags )
3628 if ( flags & UF_Viewer | flags & UF_Forced )
3629 SMESH::UpdateView();
3631 SalomeApp_Module::update( flags );
3634 //================================================================================
3636 * \brief Set default selection mode
3638 * SLOT called when operation commited. Sets default selection mode
3640 //================================================================================
3641 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3643 SVTK_ViewWindow* vtkWnd =
3644 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3646 vtkWnd->SetSelectionMode( ActorSelection );
3649 //================================================================================
3651 * \brief Set default selection mode
3653 * SLOT called when operation aborted. Sets default selection mode
3655 //================================================================================
3656 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3658 SVTK_ViewWindow* vtkWnd =
3659 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3661 vtkWnd->SetSelectionMode( ActorSelection );
3664 //================================================================================
3666 * \brief Creates operation with given identifier
3667 * \param id - identifier of operation to be started
3668 * \return Pointer on created operation or NULL if operation is not created
3670 * Virtual method redefined from the base class creates operation with given id.
3671 * It is called called automatically from startOperation method of base class.
3673 //================================================================================
3674 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3676 LightApp_Operation* op = 0;
3677 // to do : create operation here
3680 case 701: // Compute mesh
3681 op = new SMESHGUI_ComputeOp();
3683 case 702: // Create mesh
3684 op = new SMESHGUI_MeshOp( true, true );
3686 case 703: // Create sub-mesh
3687 op = new SMESHGUI_MeshOp( true, false );
3689 case 704: // Edit mesh/sub-mesh
3690 op = new SMESHGUI_MeshOp( false );
3692 case 711: // Precompute mesh
3693 op = new SMESHGUI_PrecomputeOp();
3695 case 806: // Create group on geom
3696 op = new SMESHGUI_GroupOnShapeOp();
3698 case 417: //convert to quadratic
3699 op = new SMESHGUI_ConvToQuadOp();
3701 case 4067: // make mesh pass through point
3702 op = new SMESHGUI_MakeNodeAtPointOp();
3709 op = SalomeApp_Module::createOperation( id );
3713 //================================================================================
3715 * \brief Stops current operations and starts a given one
3716 * \param id - The id of the operation to start
3718 //================================================================================
3720 void SMESHGUI::switchToOperation(int id)
3722 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3723 activeStudy()->abortAllOperations();
3724 startOperation( id );
3727 LightApp_Displayer* SMESHGUI::displayer()
3730 myDisplayer = new SMESHGUI_Displayer( getApp() );
3734 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
3737 int aTolerance = 64;
3738 int anIterations = 0;
3744 if( anIterations % aPeriod == 0 )
3747 if( aTolerance < 1 )
3750 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3752 aHue = (int)( 360.0 * rand() / RAND_MAX );
3753 //cout << "Hue = " << aHue << endl;
3755 //cout << "Auto colors : ";
3757 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3758 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3759 for( ; it != itEnd; ++it )
3761 SALOMEDS::Color anAutoColor = *it;
3762 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3765 aQColor.getHsv( &h, &s, &v );
3767 if( abs( h - aHue ) < aTolerance )
3770 //cout << "break (diff = " << abs( h - aHue ) << ")";
3780 //cout << "Hue of the returned color = " << aHue << endl;
3782 aColor.setHsv( aHue, 255, 255 );
3784 SALOMEDS::Color aSColor;
3785 aSColor.R = (double)aColor.red() / 255.0;
3786 aSColor.G = (double)aColor.green() / 255.0;
3787 aSColor.B = (double)aColor.blue() / 255.0;
3792 const char gSeparator = '_'; // character used to separate parameter names
3793 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
3796 * \brief Store visual parameters
3798 * This method is called just before the study document is saved.
3799 * Store visual parameters in AttributeParameter attribue(s)
3801 void SMESHGUI::storeVisualParameters (int savePoint)
3803 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3804 if (!appStudy || !appStudy->studyDS())
3806 _PTR(Study) studyDS = appStudy->studyDS();
3808 // componentName is used for encoding of entries when storing them in IParameters
3809 std::string componentName = myComponentSMESH->ComponentDataType();
3810 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
3811 //if (!aSComponent) return;
3814 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3815 componentName.c_str(),
3817 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3819 // viewers counters are used for storing view_numbers in IParameters
3822 // main cycle to store parameters of displayed objects
3823 QList<SUIT_ViewManager*> lst;
3824 QList<SUIT_ViewManager*>::Iterator it;
3825 getApp()->viewManagers(lst);
3826 for (it = lst.begin(); it != lst.end(); it++)
3828 SUIT_ViewManager* vman = *it;
3829 QString vType = vman->getType();
3831 // saving VTK actors properties
3832 if (vType == SVTK_Viewer::Type())
3834 QVector<SUIT_ViewWindow*> views = vman->getViews();
3835 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
3837 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
3839 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
3840 allActors->InitTraversal();
3841 while (vtkActor* actor = allActors->GetNextActor())
3843 if (actor->GetVisibility()) // store only visible actors
3845 SMESH_Actor* aSmeshActor = 0;
3846 if (actor->IsA("SMESH_Actor"))
3847 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
3848 if (aSmeshActor && aSmeshActor->hasIO())
3850 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
3853 // entry is "encoded" = it does NOT contain component adress,
3854 // since it is a subject to change on next component loading
3855 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
3857 std::string param, vtkParam = vType.toLatin1().data();
3858 vtkParam += gSeparator;
3859 vtkParam += QString::number(vtkViewers).toLatin1().data();
3860 vtkParam += gSeparator;
3863 param = vtkParam + "Visibility";
3864 ip->setParameter(entry, param, "On");
3867 param = vtkParam + "Representation";
3868 ip->setParameter(entry, param, QString::number
3869 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
3872 param = vtkParam + "IsShrunk";
3873 ip->setParameter(entry, param, QString::number
3874 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
3876 // Displayed entities
3877 unsigned int aMode = aSmeshActor->GetEntityMode();
3878 bool isE = aMode & SMESH_Actor::eEdges;
3879 bool isF = aMode & SMESH_Actor::eFaces;
3880 bool isV = aMode & SMESH_Actor::eVolumes;
3882 QString modeStr ("e");
3883 modeStr += gDigitsSep; modeStr += QString::number(isE);
3884 modeStr += gDigitsSep; modeStr += "f";
3885 modeStr += gDigitsSep; modeStr += QString::number(isF);
3886 modeStr += gDigitsSep; modeStr += "v";
3887 modeStr += gDigitsSep; modeStr += QString::number(isV);
3889 param = vtkParam + "Entities";
3890 ip->setParameter(entry, param, modeStr.toLatin1().data());
3892 // Colors (surface:edge:)
3893 vtkFloatingPointType r, g, b;
3895 aSmeshActor->GetSufaceColor(r, g, b);
3896 QString colorStr ("surface");
3897 colorStr += gDigitsSep; colorStr += QString::number(r);
3898 colorStr += gDigitsSep; colorStr += QString::number(g);
3899 colorStr += gDigitsSep; colorStr += QString::number(b);
3901 aSmeshActor->GetBackSufaceColor(r, g, b);
3902 colorStr += gDigitsSep; colorStr += "backsurface";
3903 colorStr += gDigitsSep; colorStr += QString::number(r);
3904 colorStr += gDigitsSep; colorStr += QString::number(g);
3905 colorStr += gDigitsSep; colorStr += QString::number(b);
3907 aSmeshActor->GetEdgeColor(r, g, b);
3908 colorStr += gDigitsSep; colorStr += "edge";
3909 colorStr += gDigitsSep; colorStr += QString::number(r);
3910 colorStr += gDigitsSep; colorStr += QString::number(g);
3911 colorStr += gDigitsSep; colorStr += QString::number(b);
3913 aSmeshActor->GetNodeColor(r, g, b);
3914 colorStr += gDigitsSep; colorStr += "node";
3915 colorStr += gDigitsSep; colorStr += QString::number(r);
3916 colorStr += gDigitsSep; colorStr += QString::number(g);
3917 colorStr += gDigitsSep; colorStr += QString::number(b);
3919 param = vtkParam + "Colors";
3920 ip->setParameter(entry, param, colorStr.toLatin1().data());
3922 // Sizes of lines and points
3923 QString sizeStr ("line");
3924 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
3925 sizeStr += gDigitsSep; sizeStr += "node";
3926 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetNodeSize());
3927 sizeStr += gDigitsSep; sizeStr += "shrink";
3928 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
3930 param = vtkParam + "Sizes";
3931 ip->setParameter(entry, param, sizeStr.toLatin1().data());
3934 param = vtkParam + "Opacity";
3935 ip->setParameter(entry, param,
3936 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
3939 param = vtkParam + "ClippingPlane";
3940 int nPlanes = aSmeshActor->GetNumberOfClippingPlanes();
3942 ip->setParameter(entry, param, "Off");
3943 for (int ipl = 0; ipl < nPlanes; ipl++) {
3944 //vtkPlane* plane = aSmeshActor->GetClippingPlane(ipl);
3945 SMESH::Orientation anOrientation;
3947 vtkFloatingPointType anAngle[2];
3948 SMESHGUI_ClippingDlg::GetPlaneParam(aSmeshActor, ipl, anOrientation, aDistance, anAngle);
3949 std::string planeValue = QString::number((int)anOrientation).toLatin1().data();
3950 planeValue += gDigitsSep; planeValue += QString::number(aDistance).toLatin1().data();
3951 planeValue += gDigitsSep; planeValue += QString::number(anAngle[0]).toLatin1().data();
3952 planeValue += gDigitsSep; planeValue += QString::number(anAngle[1]).toLatin1().data();
3954 ip->setParameter(entry, param + QString::number(ipl+1).toLatin1().data(), planeValue);
3956 } // if (io->hasEntry())
3957 } // SMESH_Actor && hasIO
3959 } // while.. actors traversal
3963 } // if (SVTK view model)
3964 } // for (viewManagers)
3968 * \brief Restore visual parameters
3970 * This method is called after the study document is opened.
3971 * Restore visual parameters from AttributeParameter attribue(s)
3973 void SMESHGUI::restoreVisualParameters (int savePoint)
3975 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3976 if (!appStudy || !appStudy->studyDS())
3978 _PTR(Study) studyDS = appStudy->studyDS();
3980 // componentName is used for encoding of entries when storing them in IParameters
3981 std::string componentName = myComponentSMESH->ComponentDataType();
3982 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3983 //if (!aSComponent) return;
3986 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3987 componentName.c_str(),
3989 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3991 std::vector<std::string> entries = ip->getEntries();
3993 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3995 // entry is a normal entry - it should be "decoded" (setting base adress of component)
3996 QString entry (ip->decodeEntry(*entIt).c_str());
3998 // Check that the entry corresponds to a real object in the Study
3999 // as the object may be deleted or modified after the visual state is saved.
4000 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
4001 if (!so) continue; //Skip the not existent entry
4003 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
4004 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
4006 std::vector<std::string>::iterator namesIt = paramNames.begin();
4007 std::vector<std::string>::iterator valuesIt = paramValues.begin();
4009 // actors are stored in a map after displaying of them for
4010 // quicker access in the future: map < viewID to actor >
4011 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
4013 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
4015 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
4016 // '_' is used as separator and should not be used in viewer type or parameter names.
4017 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
4018 if (lst.size() != 3)
4021 QString viewerTypStr = lst[0];
4022 QString viewIndexStr = lst[1];
4023 QString paramNameStr = lst[2];
4026 int viewIndex = viewIndexStr.toUInt(&ok);
4027 if (!ok) // bad conversion of view index to integer
4031 if (viewerTypStr == SVTK_Viewer::Type())
4033 SMESH_Actor* aSmeshActor = 0;
4034 if (vtkActors.IsBound(viewIndex))
4035 aSmeshActor = vtkActors.Find(viewIndex);
4037 if (paramNameStr == "Visibility")
4039 if (!aSmeshActor && displayer())
4041 QList<SUIT_ViewManager*> lst;
4042 getApp()->viewManagers(viewerTypStr, lst);
4044 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4045 if (viewIndex >= 0 && viewIndex < lst.count()) {
4046 SUIT_ViewManager* vman = lst.at(viewIndex);
4047 SUIT_ViewModel* vmodel = vman->getViewModel();
4048 // SVTK view model can be casted to SALOME_View
4049 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
4051 // store displayed actor in a temporary map for quicker
4052 // access later when restoring other parameters
4053 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4054 vtkRenderer* Renderer = vtkView->getRenderer();
4055 vtkActorCollection* theActors = Renderer->GetActors();
4056 theActors->InitTraversal();
4057 bool isFound = false;
4058 vtkActor *ac = theActors->GetNextActor();
4059 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
4060 if (ac->IsA("SMESH_Actor")) {
4061 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
4062 if (aGeomAc->hasIO()) {
4063 Handle(SALOME_InteractiveObject) io =
4064 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
4065 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
4067 vtkActors.Bind(viewIndex, aGeomAc);
4074 } // if (paramNameStr == "Visibility")
4077 // the rest properties "work" with SMESH_Actor
4080 QString val ((*valuesIt).c_str());
4083 if (paramNameStr == "Representation") {
4084 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
4087 else if (paramNameStr == "IsShrunk") {
4089 if (!aSmeshActor->IsShrunk())
4090 aSmeshActor->SetShrink();
4093 if (aSmeshActor->IsShrunk())
4094 aSmeshActor->UnShrink();
4097 // Displayed entities
4098 else if (paramNameStr == "Entities") {
4099 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
4100 if (mode.count() == 6) {
4101 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
4102 MESSAGE("Invalid order of data in Entities, must be: "
4103 "e:0/1:f:0/1:v:0/1");
4106 unsigned int aMode = aSmeshActor->GetEntityMode();
4107 unsigned int aNewMode =
4108 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
4109 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
4110 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
4111 if (aNewMode != aMode)
4112 aSmeshActor->SetEntityMode(aNewMode);
4117 else if (paramNameStr == "Colors") {
4118 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
4119 if (colors.count() == 16) {
4120 if (colors[0] != "surface" || colors[4] != "backsurface" ||
4121 colors[8] != "edge" || colors[12] != "node") {
4122 MESSAGE("Invalid order of data in Colors, must be: "
4123 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
4126 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
4127 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
4128 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
4129 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
4133 // Sizes of lines and points
4134 else if (paramNameStr == "Sizes") {
4135 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
4136 if (sizes.count() == 6) {
4137 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
4138 MESSAGE("Invalid order of data in Sizes, must be: "
4139 "line:int:node:int:shrink:float");
4142 aSmeshActor->SetLineWidth(sizes[1].toInt());
4143 aSmeshActor->SetNodeSize(sizes[3].toInt());
4144 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
4149 else if (paramNameStr == "Opacity") {
4150 aSmeshActor->SetOpacity(val.toFloat());
4153 else if (paramNameStr.startsWith("ClippingPlane")) {
4154 cout << "$$$ ClippingPlane 1" << endl;
4155 if (paramNameStr == "ClippingPlane1" || val == "Off")
4156 aSmeshActor->RemoveAllClippingPlanes();
4158 cout << "$$$ ClippingPlane 2" << endl;
4159 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
4160 if (vals.count() == 4) { // format check: 4 values
4161 cout << "$$$ ClippingPlane 3" << endl;
4162 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
4163 double aDistance = vals[1].toFloat();
4164 vtkFloatingPointType anAngle[2];
4165 anAngle[0] = vals[2].toFloat();
4166 anAngle[1] = vals[3].toFloat();
4168 QList<SUIT_ViewManager*> lst;
4169 getApp()->viewManagers(viewerTypStr, lst);
4170 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
4171 if (viewIndex >= 0 && viewIndex < lst.count()) {
4172 SUIT_ViewManager* vman = lst.at(viewIndex);
4173 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
4174 SMESHGUI_ClippingDlg::AddPlane(aSmeshActor, vtkView,
4175 anOrientation, aDistance, anAngle);
4180 } // if (aSmeshActor)
4181 } // other parameters than Visibility
4183 } // for names/parameters iterator
4184 } // for entries iterator
4186 // update all VTK views
4187 QList<SUIT_ViewManager*> lst;
4188 getApp()->viewManagers(lst);
4189 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
4190 SUIT_ViewModel* vmodel = (*it)->getViewModel();
4191 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
4192 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
4193 vtkView->getRenderer()->ResetCameraClippingRange();