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
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_EditMeshDlg.h"
61 #include "SMESHGUI_MeshPatternDlg.h"
62 #include "SMESHGUI_Selection.h"
63 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
64 #include "SMESHGUI_ConvToQuadOp.h"
65 #include "SMESHGUI_MeshOp.h"
66 #include "SMESHGUI_Displayer.h"
67 #include "SMESHGUI_MakeNodeAtPointDlg.h"
68 #include "SMESHGUI_BuildCompoundDlg.h"
69 #include "SMESHGUI_ComputeDlg.h"
71 #include "SMESHGUI_Utils.h"
72 #include "SMESHGUI_GEOMGenUtils.h"
73 #include "SMESHGUI_MeshUtils.h"
74 #include "SMESHGUI_GroupUtils.h"
75 #include "SMESHGUI_FilterUtils.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_VTKUtils.h"
78 #include "SMESHGUI_HypothesesUtils.h"
80 #include "SMESH_Actor.h"
81 #include "SMESH_Object.h"
82 #include "SMESH_TypeFilter.hxx"
84 #include "SalomeApp_Tools.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_Application.h"
87 #include "SalomeApp_CheckFileDlg.h"
88 #include "SalomeApp_ImportOperation.h"
90 #include "LightApp_DataOwner.h"
91 #include "LightApp_Preferences.h"
92 #include "LightApp_VTKSelector.h"
93 #include "LightApp_Operation.h"
94 #include "LightApp_UpdateFlags.h"
95 #include "LightApp_NameDlg.h"
97 #include <SVTK_ViewWindow.h>
98 #include <SVTK_ViewModel.h>
99 #include <SVTK_InteractorStyle.h>
100 #include <SVTK_RenderWindowInteractor.h>
101 #include <SVTK_ViewManager.h>
103 #include "OB_Browser.h"
105 #include "SUIT_Tools.h"
106 #include "SUIT_MessageBox.h"
107 #include "SUIT_ResourceMgr.h"
108 #include "SUIT_FileDlg.h"
109 #include "SUIT_Desktop.h"
110 #include "SUIT_OverrideCursor.h"
111 #include "SUIT_Study.h"
112 #include "SUIT_Session.h"
114 #include "QtxPopupMgr.h"
116 #include "SALOME_ListIO.hxx"
117 #include "SALOME_ListIteratorOfListIO.hxx"
118 #include "SALOME_InteractiveObject.hxx"
119 #include "SALOME_NamingService.hxx"
120 #include "SALOME_LifeCycleCORBA.hxx"
122 #include "SALOMEconfig.h"
123 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
124 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
127 #define INCLUDE_MENUITEM_DEF
128 #include <qpopupmenu.h>
134 #include <boost/shared_ptr.hpp>
137 #include <vtkRenderer.h>
138 #include <vtkRenderWindow.h>
139 #include <vtkActorCollection.h>
140 #include <vtkScalarBarActor.h>
141 #include <vtkUnstructuredGrid.h>
143 #include "utilities.h"
145 #include "SALOMEDS_Study.hxx"
146 #include "SALOMEDSClient_StudyBuilder.hxx"
147 #include "SALOMEDSClient_SComponent.hxx"
149 #include <Standard_ErrorHandler.hxx>
155 //=============================================================
156 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
159 void ExportMeshToFile(int theCommandID);
161 void SetDisplayMode(int theCommandID);
163 void SetDisplayEntity(int theCommandID);
165 void Control( int theCommandID );
169 //=============================================================
170 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
176 if(theCommandID == 113){
177 filter.append(QObject::tr("MED files (*.med)"));
178 filter.append(QObject::tr("All files (*)"));
179 }else if (theCommandID == 112){
180 filter.append(QObject::tr("IDEAS files (*.unv)"));
181 }else if (theCommandID == 111){
182 filter.append(QObject::tr("DAT files (*.dat)"));
184 QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
187 QObject::tr("Import mesh"),
189 if(!filename.isEmpty()) {
190 SUIT_OverrideCursor wc;
191 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
194 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
195 switch ( theCommandID ) {
198 aMeshes->length( 1 );
199 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
204 SMESH::DriverMED_ReadStatus res;
205 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
206 if ( res != SMESH::DRS_OK ) {
208 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
209 QObject::tr("SMESH_WRN_WARNING"),
210 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
211 QObject::tr("SMESH_BUT_OK"));
212 aMeshes->length( 0 );
219 bool isEmpty = false;
220 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
221 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
223 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
224 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
225 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
226 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
227 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
234 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
235 QObject::tr("SMESH_WRN_WARNING"),
236 QObject::tr("SMESH_DRS_EMPTY"),
237 QObject::tr("SMESH_BUT_OK"));
241 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
243 catch (const SALOME::SALOME_Exception& S_ex){
245 SalomeApp_Tools::QtCatchCorbaException(S_ex);
252 void ExportMeshToFile( int theCommandID )
254 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
255 SALOME_ListIO selected;
257 aSel->selectedObjects( selected );
259 if(selected.Extent()){
260 Handle(SALOME_InteractiveObject) anIObject = selected.First();
261 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
262 if ( !aMesh->_is_nil() ) {
263 QString aFilter, aTitle = QObject::tr("Export mesh");
264 QMap<QString, SMESH::MED_VERSION> aFilterMap;
265 QMap<QString, int> aFilterMapSTL;
266 switch ( theCommandID ) {
270 if (aMesh->HasDuplicatedGroupNamesMED()) {
271 int aRet = SUIT_MessageBox::warn2
272 (SMESHGUI::desktop(),
273 QObject::tr("SMESH_WRN_WARNING"),
274 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
275 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
281 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
282 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
287 aFilter = QObject::tr("DAT files (*.dat)");
292 if (aMesh->NbPyramids()) {
293 int aRet = SUIT_MessageBox::warn2
294 (SMESHGUI::desktop(),
295 QObject::tr("SMESH_WRN_WARNING"),
296 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
297 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
302 aFilter = QObject::tr("IDEAS files (*.unv)");
310 there must be check on others mesh elements not equal triangles
312 if (aMesh->NbTriangles() < 1) {
313 SUIT_MessageBox::warn1
314 (SMESHGUI::desktop(),
315 QObject::tr("SMESH_WRN_WARNING"),
316 QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
317 QObject::tr("SMESH_BUT_OK"));
320 if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
321 int aRet = SUIT_MessageBox::warn2
322 (SMESHGUI::desktop(),
323 QObject::tr("SMESH_WRN_WARNING"),
324 QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
325 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
331 aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
332 aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
340 SMESH::MED_VERSION aFormat;
341 // Init the parameter with the default value
342 bool aIsASCII_STL = true;
343 bool toCreateGroups = false;
344 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
346 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
348 if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
350 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
352 else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
354 QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
355 for ( ; it != aFilterMapSTL.end(); ++it )
356 filters.push_back( it.key() );
358 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
359 fd->setCaption( aTitle );
360 fd->setFilters( filters );
361 fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
365 aFilename = fd->selectedFile();
366 aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
373 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
374 for ( ; it != aFilterMap.end(); ++it )
375 filters.push_back( it.key() );
377 //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
378 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
379 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
380 fd->setCaption( aTitle );
381 fd->setFilters( filters );
382 fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
383 fd->SetChecked(toCreateGroups);
387 aFilename = fd->selectedFile();
388 aFormat = aFilterMap[fd->selectedFilter()];
390 if ( !aFilename.isEmpty()
391 && (aMesh->NbPolygons()>0 || aMesh->NbPolyhedrons()>0)
392 && aFormat==SMESH::MED_V2_1) {
393 int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
394 QObject::tr("SMESH_WRN_WARNING"),
395 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
396 QObject::tr("SMESH_BUT_YES"),
397 QObject::tr("SMESH_BUT_NO"),
404 toCreateGroups = fd->IsChecked();
407 if ( !aFilename.isEmpty() ) {
408 // Check whether the file already exists and delete it if yes
409 QFile aFile( aFilename );
410 if ( aFile.exists() )
412 SUIT_OverrideCursor wc;
415 bool Renumber = false ;
416 // PAL 14172 : Check of we have to renumber or not from the preferences before export
418 Renumber= resMgr->booleanValue("SMESH","renumbering");
420 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
421 aMeshEditor->RenumberNodes();
422 aMeshEditor->RenumberElements();
423 if ( SMESHGUI::automaticUpdate() )
426 switch ( theCommandID ) {
429 aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
433 aMesh->ExportDAT( aFilename.latin1() );
437 aMesh->ExportUNV( aFilename.latin1() );
441 aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
447 catch (const SALOME::SALOME_Exception& S_ex){
449 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
450 QObject::tr("SMESH_WRN_WARNING"),
451 QObject::tr("SMESH_EXPORT_FAILED"),
452 QObject::tr("SMESH_BUT_OK"));
460 inline void InverseEntityMode(unsigned int& theOutputMode,
461 unsigned int theMode)
463 bool anIsNotPresent = ~theOutputMode & theMode;
465 theOutputMode |= theMode;
467 theOutputMode &= ~theMode;
470 void SetDisplayEntity(int theCommandID){
471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
472 SALOME_ListIO selected;
474 aSel->selectedObjects( selected );
476 if(selected.Extent() >= 1){
477 SALOME_ListIteratorOfListIO It( selected );
478 for(; It.More(); It.Next()){
479 Handle(SALOME_InteractiveObject) IObject = It.Value();
480 if(IObject->hasEntry()){
481 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
482 unsigned int aMode = anActor->GetEntityMode();
483 switch(theCommandID){
485 InverseEntityMode(aMode,SMESH_Actor::eEdges);
488 InverseEntityMode(aMode,SMESH_Actor::eFaces);
491 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
494 aMode = SMESH_Actor::eAllEntity;
498 anActor->SetEntityMode(aMode);
506 SALOME_ListIO selected;
507 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
511 LightApp_SelectionMgr* aSel = app->selectionMgr();
512 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
513 if( !aSel || !appStudy )
516 aSel->selectedObjects( selected );
517 if( selected.IsEmpty() )
520 Handle(SALOME_InteractiveObject) anIObject = selected.First();
522 _PTR(Study) aStudy = appStudy->studyDS();
523 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
524 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
525 if( aMainObject->_is_nil() )
528 aMainObject->SetAutoColor( true );
530 QValueList<SALOMEDS::Color> aReservedColors;
532 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
533 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
535 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
536 SALOMEDS::Color aCurrentColor = aGroupObject->GetColor();
538 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
539 aGroupObject->SetColor( aColor );
540 aReservedColors.append( aColor );
542 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
543 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
544 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
547 SMESH::RepaintCurrentView();
550 void DisableAutoColor(){
551 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
552 SALOME_ListIO selected;
554 aSel->selectedObjects( selected );
556 if(selected.Extent()){
557 Handle(SALOME_InteractiveObject) anIObject = selected.First();
558 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
559 if ( !aMesh->_is_nil() ) {
560 aMesh->SetAutoColor( false );
565 void SetDisplayMode(int theCommandID){
566 SALOME_ListIO selected;
567 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
571 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
572 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
573 if( !aSel || !appStudy )
576 _PTR(Study) aStudy = appStudy->studyDS();
578 aSel->selectedObjects( selected );
580 if(selected.Extent() >= 1){
581 switch(theCommandID){
583 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
584 new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
588 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
589 new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
592 SALOME_ListIteratorOfListIO It( selected );
593 for(; It.More(); It.Next()){
594 Handle(SALOME_InteractiveObject) IObject = It.Value();
595 if(IObject->hasEntry()){
596 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
597 switch(theCommandID){
599 anActor->SetRepresentation(SMESH_Actor::eEdge);
602 anActor->SetRepresentation(SMESH_Actor::eSurface);
605 if(anActor->IsShrunk())
608 anActor->SetShrink();
611 anActor->SetRepresentation(SMESH_Actor::ePoint);
614 vtkFloatingPointType color[3];
615 anActor->GetSufaceColor(color[0], color[1], color[2]);
616 int c0 = int (color[0] * 255);
617 int c1 = int (color[1] * 255);
618 int c2 = int (color[2] * 255);
619 QColor c(c0, c1, c2);
621 vtkFloatingPointType edgecolor[3];
622 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
623 c0 = int (edgecolor[0] * 255);
624 c1 = int (edgecolor[1] * 255);
625 c2 = int (edgecolor[2] * 255);
626 QColor e(c0, c1, c2);
628 vtkFloatingPointType backfacecolor[3];
629 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
630 c0 = int (backfacecolor[0] * 255);
631 c1 = int (backfacecolor[1] * 255);
632 c2 = int (backfacecolor[2] * 255);
633 QColor b(c0, c1, c2);
635 vtkFloatingPointType nodecolor[3];
636 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
637 c0 = int (nodecolor[0] * 255);
638 c1 = int (nodecolor[1] * 255);
639 c2 = int (nodecolor[2] * 255);
640 QColor n(c0, c1, c2);
642 int Edgewidth = (int)anActor->GetLineWidth();
645 int intValue = int(anActor->GetNodeSize());
646 vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
648 SMESHGUI_Preferences_ColorDlg *aDlg =
649 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
650 aDlg->SetColor(1, c);
651 aDlg->SetColor(2, e);
652 aDlg->SetColor(3, n);
653 aDlg->SetColor(4, b);
654 aDlg->SetIntValue(1, Edgewidth);
655 aDlg->SetIntValue(2, intValue);
656 aDlg->SetIntValue(3, int(Shrink*100.));
658 QColor color = aDlg->GetColor(1);
659 QColor edgecolor = aDlg->GetColor(2);
660 QColor nodecolor = aDlg->GetColor(3);
661 QColor backfacecolor = aDlg->GetColor(4);
662 /* actor color and backface color */
663 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
664 vtkFloatingPointType (color.green()) / 255.,
665 vtkFloatingPointType (color.blue()) / 255.);
666 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
667 vtkFloatingPointType (backfacecolor.green()) / 255.,
668 vtkFloatingPointType (backfacecolor.blue()) / 255.);
671 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
672 vtkFloatingPointType (edgecolor.green()) / 255.,
673 vtkFloatingPointType (edgecolor.blue()) / 255.);
675 /* Shrink factor and size edges */
676 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
677 anActor->SetLineWidth(aDlg->GetIntValue(1));
679 /* Nodes color and size */
680 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
681 vtkFloatingPointType (nodecolor.green()) / 255.,
682 vtkFloatingPointType (nodecolor.blue()) / 255.);
683 anActor->SetNodeSize(aDlg->GetIntValue(2));
685 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
686 if( !aGroupObject->_is_nil() )
688 SALOMEDS::Color aColor;
689 aColor.R = (float)color.red() / 255.0;
690 aColor.G = (float)color.green() / 255.0;
691 aColor.B = (float)color.blue() / 255.0;
692 aGroupObject->SetColor( aColor );
702 SMESH::RepaintCurrentView();
706 void Control( int theCommandID )
708 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
709 SALOME_ListIO selected;
711 aSel->selectedObjects( selected );
713 if( !selected.IsEmpty() ){
714 Handle(SALOME_InteractiveObject) anIO = selected.First();
717 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
718 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
719 switch ( theCommandID ){
721 aTitle = QObject::tr( "LENGTH_EDGES" );
722 aControl = SMESH_Actor::eLength;
725 aTitle = QObject::tr( "LENGTH2D_EDGES" );
726 aControl = SMESH_Actor::eLength2D;
729 aTitle = QObject::tr( "FREE_EDGES" );
730 aControl = SMESH_Actor::eFreeEdges;
733 aTitle = QObject::tr( "FREE_BORDERS" );
734 aControl = SMESH_Actor::eFreeBorders;
737 aTitle = QObject::tr( "MULTI_BORDERS" );
738 aControl = SMESH_Actor::eMultiConnection;
741 aTitle = QObject::tr( "MULTI2D_BORDERS" );
742 aControl = SMESH_Actor::eMultiConnection2D;
745 aTitle = QObject::tr( "AREA_ELEMENTS" );
746 aControl = SMESH_Actor::eArea;
749 aTitle = QObject::tr( "TAPER_ELEMENTS" );
750 aControl = SMESH_Actor::eTaper;
753 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
754 aControl = SMESH_Actor::eAspectRatio;
757 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
758 aControl = SMESH_Actor::eAspectRatio3D;
761 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
762 aControl = SMESH_Actor::eMinimumAngle;
765 aTitle = QObject::tr( "WARP_ELEMENTS" );
766 aControl = SMESH_Actor::eWarping;
769 aTitle = QObject::tr( "SKEW_ELEMENTS" );
770 aControl = SMESH_Actor::eSkew;
773 aTitle = QObject::tr( "SMESH_VOLUME" );
774 aControl = SMESH_Actor::eVolume3D;
777 anActor->SetControlMode(aControl);
778 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
779 SMESH::RepaintCurrentView();
786 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
787 MeshObjectType theType,
788 const QString theInTypeName,
789 QString & theOutTypeName)
791 SMESH_TypeFilter aTypeFilter( theType );
793 if( !theIO.IsNull() )
795 entry = theIO->getEntry();
796 LightApp_DataOwner owner( entry );
797 if ( aTypeFilter.isOk( &owner )) {
798 theOutTypeName = theInTypeName;
806 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
808 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
809 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
811 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
812 CORBA::String_var anID = aSComp->GetID().c_str();
813 if (!strcmp(anID.in(),theIO->getEntry()))
819 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
820 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
821 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
822 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
823 CheckOIType ( theIO, GROUP, "Group", aTypeName )
831 QString CheckHomogeneousSelection()
833 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
834 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
835 SALOME_ListIO selected;
837 aSel->selectedObjects( selected );
839 QString RefType = CheckTypeObject(selected.First());
840 SALOME_ListIteratorOfListIO It(selected);
841 for (; It.More(); It.Next())
843 Handle(SALOME_InteractiveObject) IObject = It.Value();
844 QString Type = CheckTypeObject(IObject);
845 if (Type.compare(RefType) != 0)
846 return "Heterogeneous Selection";
853 void SMESHGUI::OnEditDelete()
855 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
856 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
857 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
859 QString aParentComponent = QString::null;
860 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
862 QString cur = anIt.Value()->getComponentDataType();
863 if( aParentComponent.isNull() )
864 aParentComponent = cur;
865 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
866 aParentComponent = "";
869 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
870 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
871 QObject::tr("ERR_ERROR"),
872 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
873 QObject::tr("BUT_OK") );
876 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
877 if (SUIT_MessageBox::warn2
878 (SMESHGUI::desktop(),
879 QObject::tr("SMESH_WRN_WARNING"),
880 QObject::tr("SMESH_REALLY_DELETE"),
881 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
884 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
885 SUIT_ViewManager* vm = anApp->activeViewManager();
886 int nbSf = vm->getViewsCount();
888 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
889 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
890 _PTR(GenericAttribute) anAttr;
891 _PTR(AttributeIOR) anIOR;
893 SALOME_ListIteratorOfListIO It(selected);
895 aStudyBuilder->NewCommand(); // There is a transaction
896 for(; It.More(); It.Next()){ // loop on selected IO's
897 Handle(SALOME_InteractiveObject) IObject = It.Value();
898 if(IObject->hasEntry()) {
899 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
901 // disable removal of "SMESH" component object
902 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
904 if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
908 // put the whole hierarchy of sub-objects of the selected SO into a list and
909 // then treat them all starting from the deepest objects (at list back)
911 list< _PTR(SObject) > listSO;
912 listSO.push_back( aSO );
913 list< _PTR(SObject) >::iterator itSO = listSO.begin();
914 for ( ; itSO != listSO.end(); ++itSO ) {
915 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
916 for (it->InitEx(false); it->More(); it->Next())
917 listSO.push_back( it->Value() );
920 // treat SO's in the list starting from the back
922 list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
923 for ( ; ritSO != listSO.rend(); ++ritSO ) {
924 _PTR(SObject) SO = *ritSO;
926 string anEntry = SO->GetID();
928 /** Erase graphical object **/
929 if(SO->FindAttribute(anAttr, "AttributeIOR")){
930 QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
931 for(int i = 0; i < nbSf; i++){
932 SUIT_ViewWindow *sf = aViews[i];
933 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
934 SMESH::RemoveActor(sf,anActor);
939 /** Remove an object from data structures **/
940 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
941 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
942 if ( !aGroup->_is_nil() ) { // DELETE GROUP
943 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
944 aMesh->RemoveGroup( aGroup );
946 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
947 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
948 aMesh->RemoveSubMesh( aSubMesh );
950 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
952 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
955 IObject = new SALOME_InteractiveObject
956 ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
957 QString objType = CheckTypeObject(IObject);
958 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
959 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
960 aStudyBuilder->RemoveObjectWithChildren( SO );
962 else {// default action: remove SObject from the study
963 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
964 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
966 aStudyBuilder->RemoveObjectWithChildren( SO );
970 } /* listSO back loop */
971 } /* IObject->hasEntry() */
973 aStudyBuilder->CommitCommand();
975 /* Clear any previous selection */
977 aSel->setSelectedObjects( l1 );
979 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
984 SMESHGUI_EXPORT CAM_Module* createModule()
986 return new SMESHGUI();
990 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
992 //=============================================================================
996 //=============================================================================
997 SMESHGUI::SMESHGUI() :
998 SalomeApp_Module( "SMESH" )
1000 if ( CORBA::is_nil( myComponentSMESH ) )
1002 CORBA::Boolean anIsEmbeddedMode;
1003 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1006 myActiveDialogBox = 0;
1007 myFilterLibraryDlg = 0;
1011 SMESH::GetFilterManager();
1012 SMESH::GetPattern();
1014 /* load resources for all available meshers */
1015 SMESH::InitAvailableHypotheses();
1018 //=============================================================================
1022 //=============================================================================
1023 SMESHGUI::~SMESHGUI()
1025 SMESH::GetFilterManager()->Destroy();
1026 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1029 //=============================================================================
1033 //=============================================================================
1034 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1036 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1038 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1043 bool SMESHGUI::automaticUpdate()
1045 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1049 return resMgr->booleanValue( "SMESH", "auto_update", false );
1052 //=============================================================================
1056 //=============================================================================
1057 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1059 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1062 //=============================================================================
1066 //=============================================================================
1067 SMESHGUI* SMESHGUI::GetSMESHGUI()
1069 SMESHGUI* smeshMod = 0;
1070 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1073 CAM_Module* module = app->module( "Mesh" );
1074 smeshMod = dynamic_cast<SMESHGUI*>( module );
1077 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1079 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1082 _PTR(Study) aStudy = study->studyDS();
1084 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1093 Standard_EXPORT SMESHGUI* GetComponentGUI()
1095 return SMESHGUI::GetSMESHGUI();
1099 //=============================================================================
1103 //=============================================================================
1104 void SMESHGUI::SetState(int aState)
1109 //=============================================================================
1113 //=============================================================================
1114 void SMESHGUI::ResetState()
1119 //=============================================================================
1123 //=============================================================================
1124 void SMESHGUI::EmitSignalDeactivateDialog()
1126 emit SignalDeactivateActiveDialog();
1129 //=============================================================================
1133 //=============================================================================
1134 void SMESHGUI::EmitSignalStudyFrameChanged()
1136 emit SignalStudyFrameChanged();
1139 //=============================================================================
1143 //=============================================================================
1144 void SMESHGUI::EmitSignalCloseAllDialogs()
1146 emit SignalCloseAllDialogs();
1149 //=============================================================================
1153 //=============================================================================
1154 QDialog *SMESHGUI::GetActiveDialogBox()
1156 return myActiveDialogBox;
1159 //=============================================================================
1163 //=============================================================================
1164 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1166 myActiveDialogBox = (QDialog *) aDlg;
1170 //=============================================================================
1174 //=============================================================================
1175 SUIT_Desktop* SMESHGUI::desktop()
1177 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1179 return app->desktop();
1184 //=============================================================================
1188 //=============================================================================
1189 SalomeApp_Study* SMESHGUI::activeStudy()
1191 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1193 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1198 //=============================================================================
1202 //=============================================================================
1203 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1205 /* Here the position is on the bottom right corner - 10 */
1206 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1208 SUIT_Desktop *PP = desktop();
1209 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1210 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1214 //=============================================================================
1218 //=============================================================================
1219 static int isStudyLocked(_PTR(Study) theStudy){
1220 return theStudy->GetProperties()->IsLocked();
1223 static bool checkLock(_PTR(Study) theStudy) {
1224 if (isStudyLocked(theStudy)) {
1225 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1226 QObject::tr("WRN_WARNING"),
1227 QObject::tr("WRN_STUDY_LOCKED"),
1228 QObject::tr("BUT_OK") );
1234 //=======================================================================
1235 //function : CheckActiveStudyLocked
1237 //=======================================================================
1239 bool SMESHGUI::isActiveStudyLocked()
1241 _PTR(Study) aStudy = activeStudy()->studyDS();
1242 return checkLock( aStudy );
1245 //=============================================================================
1249 //=============================================================================
1250 bool SMESHGUI::OnGUIEvent( int theCommandID )
1252 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1256 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1257 SUIT_ResourceMgr* mgr = resourceMgr();
1261 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1262 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1265 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1266 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1268 //QAction* act = action( theCommandID );
1270 switch (theCommandID) {
1272 if(checkLock(aStudy)) break;
1280 if(checkLock(aStudy)) break;
1281 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1285 case 122: // EXPORT MED
1294 ::ExportMeshToFile(theCommandID);
1298 case 200: // SCALAR BAR
1300 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1301 SALOME_ListIO selected;
1303 aSel->selectedObjects( selected );
1305 if( selected.Extent() ) {
1306 Handle(SALOME_InteractiveObject) anIO = selected.First();
1307 if( anIO->hasEntry() ) {
1308 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1309 anActor->SetControlMode( SMESH_Actor::eNone );
1317 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1327 ::DisableAutoColor();
1330 case 1134: // Clipping
1331 case 1133: // Tranparency
1332 case 1132: // Colors / Size
1339 ::SetDisplayMode(theCommandID);
1345 case 219: // Volumes
1346 case 220: // All Entity
1347 ::SetDisplayEntity(theCommandID);
1352 if(checkLock(aStudy)) break;
1354 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1357 SMESH::UpdateView();
1359 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
1360 SMESH::OnVisuException();
1362 catch (...) { // PAL16774 (Crash after display of many groups)
1363 SMESH::OnVisuException();
1367 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1368 aSel->selectedObjects( l );
1369 aSel->setSelectedObjects( l );
1374 case 301: // DISPLAY
1375 case 302: // DISPLAY ONLY
1377 SMESH::EDisplaing anAction;
1378 switch (theCommandID) {
1379 case 300: anAction = SMESH::eErase; break;
1380 case 301: anAction = SMESH::eDisplay; break;
1381 case 302: anAction = SMESH::eDisplayOnly; break;
1384 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1385 SALOME_ListIO sel_objects, to_process;
1387 aSel->selectedObjects( sel_objects );
1389 if( theCommandID==302 )
1390 startOperation( myEraseAll );
1392 extractContainers( sel_objects, to_process );
1395 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1399 SALOME_ListIteratorOfListIO It( to_process );
1400 for (; It.More(); It.Next()) {
1401 Handle(SALOME_InteractiveObject) IOS = It.Value();
1402 if (IOS->hasEntry()) {
1403 if (!SMESH::UpdateView(anAction, IOS->getEntry()))
1404 break; // PAL16774 (Crash after display of many groups)
1405 if (anAction == SMESH::eDisplayOnly)
1406 anAction = SMESH::eDisplay;
1411 // PAL13338 + PAL15161 -->
1412 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
1413 SMESH::UpdateView();
1414 // PAL13338 + PAL15161 <--
1416 catch (...) { // PAL16774 (Crash after display of many groups)
1417 SMESH::OnVisuException();
1420 if (anAction == SMESH::eErase) {
1422 aSel->setSelectedObjects( l1 );
1425 aSel->setSelectedObjects( to_process );
1432 if(checkLock(aStudy)) break;
1435 EmitSignalDeactivateDialog();
1437 new SMESHGUI_NodesDlg(this);
1440 SUIT_MessageBox::warn1(desktop(),
1441 tr("SMESH_WRN_WARNING"),
1442 tr("SMESH_WRN_VIEWER_VTK"),
1443 tr("SMESH_BUT_OK"));
1448 case 2151: // FILTER
1452 EmitSignalDeactivateDialog();
1453 new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1458 case 406: // MOVE NODE
1462 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1463 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1467 if(checkLock(aStudy)) break;
1468 new SMESHGUI_MoveNodesDlg(this);
1472 case 701: // COMPUTE MESH
1474 if (checkLock(aStudy)) break;
1476 startOperation( 701 );
1480 case 702: // Create mesh
1481 startOperation( 702 );
1483 case 703: // Create sub-mesh
1484 startOperation( 703 );
1486 case 704: // Edit mesh/sub-mesh
1487 startOperation( 704 );
1489 case 710: // Build compound mesh
1491 if (checkLock(aStudy)) break;
1492 EmitSignalDeactivateDialog();
1493 new SMESHGUI_BuildCompoundDlg( this );
1496 case 407: // DIAGONAL INVERSION
1497 case 408: // Delete diagonal
1501 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1502 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1506 if ( checkLock( aStudy ) )
1509 /*Standard_Boolean aRes;
1510 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1511 if ( aMesh->_is_nil() )
1513 SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1514 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1518 EmitSignalDeactivateDialog();
1519 if ( theCommandID == 407 )
1520 new SMESHGUI_TrianglesInversionDlg(this);
1522 new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1525 case 409: // Change orientation
1526 case 410: // Union of triangles
1527 case 411: // Cutting of quadrangles
1531 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1532 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1536 if ( checkLock( aStudy ) )
1539 EmitSignalDeactivateDialog();
1540 SMESHGUI_MultiEditDlg* aDlg = NULL;
1541 if ( theCommandID == 409 )
1542 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1543 else if ( theCommandID == 410 )
1544 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1546 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1551 case 412: // Smoothing
1553 if(checkLock(aStudy)) break;
1555 EmitSignalDeactivateDialog();
1556 new SMESHGUI_SmoothingDlg( this );
1559 SUIT_MessageBox::warn1(desktop(),
1560 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1561 tr("SMESH_BUT_OK"));
1565 case 413: // Extrusion
1567 if (checkLock(aStudy)) break;
1569 EmitSignalDeactivateDialog();
1570 new SMESHGUI_ExtrusionDlg ( this );
1572 SUIT_MessageBox::warn1(desktop(),
1573 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1574 tr("SMESH_BUT_OK"));
1578 case 414: // Revolution
1580 if(checkLock(aStudy)) break;
1582 EmitSignalDeactivateDialog();
1583 new SMESHGUI_RevolutionDlg( this );
1586 SUIT_MessageBox::warn1(desktop(),
1587 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1588 tr("SMESH_BUT_OK"));
1592 case 415: // Pattern mapping
1594 if ( checkLock( aStudy ) )
1598 EmitSignalDeactivateDialog();
1599 new SMESHGUI_MeshPatternDlg( this );
1602 SUIT_MessageBox::warn1(desktop(),
1603 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1604 tr("SMESH_BUT_OK"));
1608 case 416: // Extrusion along a path
1610 if (checkLock(aStudy)) break;
1612 EmitSignalDeactivateDialog();
1613 new SMESHGUI_ExtrusionAlongPathDlg( this );
1615 SUIT_MessageBox::warn1(desktop(),
1616 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1617 tr("SMESH_BUT_OK"));
1621 case 417: // Convert mesh to quadratic
1623 startOperation( 417 );
1624 /* if (checkLock(aStudy)) break;
1626 EmitSignalDeactivateDialog();
1627 new SMESHGUI_ConvToQuadDlg();
1629 SUIT_MessageBox::warn1(desktop(),
1630 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1631 tr("SMESH_BUT_OK"));
1635 case 801: // CREATE GROUP
1639 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1640 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1644 if(checkLock(aStudy)) break;
1645 EmitSignalDeactivateDialog();
1646 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1648 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1649 SALOME_ListIO selected;
1651 aSel->selectedObjects( selected );
1653 int nbSel = selected.Extent();
1655 // check if mesh is selected
1656 aMesh = SMESH::GetMeshByIO( selected.First() );
1658 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1663 case 802: // CONSTRUCT GROUP
1667 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1668 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1672 if(checkLock(aStudy)) break;
1673 EmitSignalDeactivateDialog();
1675 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1676 SALOME_ListIO selected;
1678 aSel->selectedObjects( selected );
1680 int nbSel = selected.Extent();
1682 // check if submesh is selected
1683 Handle(SALOME_InteractiveObject) IObject = selected.First();
1684 if (IObject->hasEntry()) {
1685 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1687 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1688 if (!aSubMesh->_is_nil()) {
1690 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1691 // get submesh elements list by types
1692 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1693 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1694 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1695 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1696 // create group for each type o elements
1697 QString aName = IObject->getName();
1698 if (aNodes->length() > 0) {
1699 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1700 aGroup->Add(aNodes.inout());
1702 if (aEdges->length() > 0) {
1703 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1704 aGroup->Add(aEdges.inout());
1706 if (aFaces->length() > 0) {
1707 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1708 aGroup->Add(aFaces.inout());
1710 if (aVolumes->length() > 0) {
1711 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1712 aGroup->Add(aVolumes.inout());
1717 catch(const SALOME::SALOME_Exception & S_ex){
1718 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1725 SUIT_MessageBox::warn1(desktop(),
1726 tr("SMESH_WRN_WARNING"),
1727 tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1728 tr("SMESH_BUT_OK"));
1733 case 803: // EDIT GROUP
1737 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1738 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1742 if(checkLock(aStudy)) break;
1743 EmitSignalDeactivateDialog();
1745 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1746 SALOME_ListIO selected;
1748 aSel->selectedObjects( selected );
1750 SALOME_ListIteratorOfListIO It (selected);
1751 int nbSelectedGroups = 0;
1752 for ( ; It.More(); It.Next() )
1754 SMESH::SMESH_GroupBase_var aGroup =
1755 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1756 if (!aGroup->_is_nil()) {
1758 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1762 if (nbSelectedGroups == 0)
1764 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1770 case 804: // Add elements to group
1772 if(checkLock(aStudy)) break;
1773 if (myState == 800) {
1774 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1775 if (aDlg) aDlg->onAdd();
1780 case 805: // Remove elements from group
1782 if(checkLock(aStudy)) break;
1783 if (myState == 800) {
1784 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1785 if (aDlg) aDlg->onRemove();
1790 case 810: // Union Groups
1791 case 811: // Intersect groups
1792 case 812: // Cut groups
1796 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1797 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1801 if ( checkLock( aStudy ) )
1804 EmitSignalDeactivateDialog();
1807 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1808 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1809 else aMode = SMESHGUI_GroupOpDlg::CUT;
1811 ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1815 case 813: // Delete groups with their contents
1819 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1820 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1824 if ( checkLock( aStudy ) )
1827 EmitSignalDeactivateDialog();
1829 new SMESHGUI_DeleteGroupDlg( this );
1833 case 900: // MESH INFOS
1835 EmitSignalDeactivateDialog();
1836 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1837 SALOME_ListIO selected;
1839 aSel->selectedObjects( selected );
1841 if ( selected.Extent() > 1 ) { // a dlg for each IO
1843 SALOME_ListIteratorOfListIO It (selected);
1844 for ( ; It.More(); It.Next() ) {
1845 IOs.Clear(); IOs.Append( It.Value() );
1846 aSel->setSelectedObjects( IOs );
1847 new SMESHGUI_MeshInfosDlg(this, "", false);
1849 // restore selection
1850 aSel->setSelectedObjects( selected );
1853 new SMESHGUI_MeshInfosDlg(this, "", false);
1857 case 902: // STANDARD MESH INFOS
1859 EmitSignalDeactivateDialog();
1860 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1861 SALOME_ListIO selected;
1863 aSel->selectedObjects( selected );
1865 if ( selected.Extent() > 1 ) { // a dlg for each IO
1867 SALOME_ListIteratorOfListIO It (selected);
1868 for ( ; It.More(); It.Next() ) {
1870 IOs.Append( It.Value() );
1871 aSel->setSelectedObjects( IOs );
1872 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1874 // restore selection
1875 aSel->setSelectedObjects( selected );
1878 new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1882 case 1100: // EDIT HYPOTHESIS
1884 if(checkLock(aStudy)) break;
1886 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1887 SALOME_ListIO selected;
1889 aSel->selectedObjects( selected );
1891 int nbSel = selected.Extent();
1894 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1895 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
1897 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1898 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1899 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1900 if ( !aHypothesis->_is_nil() )
1902 CORBA::String_var aHypType = aHypothesis->GetName();
1903 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
1905 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
1912 updateObjBrowser( true );
1916 case 1101: // RENAME
1918 if ( checkLock( aStudy ) )
1921 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1922 SALOME_ListIO selected;
1924 aSel->selectedObjects( selected );
1926 SALOME_ListIteratorOfListIO It( selected );
1927 for ( ; It.More(); It.Next() )
1929 Handle(SALOME_InteractiveObject) IObject = It.Value();
1930 _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1931 _PTR(GenericAttribute) anAttr;
1932 _PTR(AttributeName) aName;
1935 if ( obj->FindAttribute(anAttr, "AttributeName") )
1938 QString newName = QString(aName->Value().c_str());
1939 newName = LightApp_NameDlg::getName(desktop(), newName);
1940 if ( !newName.isEmpty() )
1942 //old source: aStudy->renameIObject( IObject, newName );
1943 aName->SetValue( newName.latin1() );
1945 // if current object is group update group's name
1946 SMESH::SMESH_GroupBase_var aGroup =
1947 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1948 if (!aGroup->_is_nil() )
1949 aGroup->SetName( newName.latin1() );
1959 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1961 if(checkLock(aStudy)) break;
1962 SUIT_OverrideCursor wc;
1964 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1965 SALOME_ListIO selected;
1967 aSel->selectedObjects( selected, QString::null, false );
1969 SALOME_ListIteratorOfListIO It(selected);
1970 for (int i = 0; It.More(); It.Next(), i++) {
1971 Handle(SALOME_InteractiveObject) IObject = It.Value();
1972 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1975 aSel->setSelectedObjects( l1 );
1980 case 401: // GEOM::EDGE
1981 case 4021: // TRIANGLE
1983 case 4023: // POLYGON
1987 if(checkLock(aStudy)) break;
1989 EmitSignalDeactivateDialog();
1990 SMDSAbs_ElementType type = SMDSAbs_Edge;
1992 switch (theCommandID) {
1993 case 4021: // TRIANGLE
1994 type = SMDSAbs_Face; nbNodes = 3; break;
1996 type = SMDSAbs_Face; nbNodes = 4; break;
1998 type = SMDSAbs_Volume; nbNodes = 4; break;
1999 case 4023: // POLYGON
2000 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2002 type = SMDSAbs_Volume; nbNodes = 8; break;
2003 case 4033: // POLYHEDRE
2004 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2007 new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
2010 SUIT_MessageBox::warn1(desktop(),
2011 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2012 tr("SMESH_BUT_OK"));
2016 case 4033: // POLYHEDRON
2018 if(checkLock(aStudy)) break;
2020 EmitSignalDeactivateDialog();
2021 new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
2024 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2025 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2026 tr("SMESH_BUT_OK"));
2030 case 4034: // QUADRATIC EDGE
2031 case 4035: // QUADRATIC TRIANGLE
2032 case 4036: // QUADRATIC QUADRANGLE
2033 case 4037: // QUADRATIC TETRAHEDRON
2034 case 4038: // QUADRATIC PYRAMID
2035 case 4039: // QUADRATIC PENTAHEDRON
2036 case 4040: // QUADRATIC HEXAHEDRON
2038 if(checkLock(aStudy)) break;
2040 EmitSignalDeactivateDialog();
2043 switch (theCommandID) {
2045 type = QUAD_EDGE; break;
2047 type = QUAD_TRIANGLE; break;
2049 type = QUAD_QUADRANGLE; break;
2051 type = QUAD_TETRAHEDRON; break;
2053 type = QUAD_PYRAMID; break;
2055 type = QUAD_PENTAHEDRON; break;
2057 type = QUAD_HEXAHEDRON;
2061 new SMESHGUI_AddQuadraticElementDlg( this, type );
2064 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
2065 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2066 tr("SMESH_BUT_OK"));
2070 case 4041: // REMOVES NODES
2072 if(checkLock(aStudy)) break;
2074 EmitSignalDeactivateDialog();
2075 new SMESHGUI_RemoveNodesDlg(this);
2078 SUIT_MessageBox::warn1(desktop(),
2079 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2080 tr("SMESH_BUT_OK"));
2084 case 4042: // REMOVES ELEMENTS
2086 if(checkLock(aStudy)) break;
2088 EmitSignalDeactivateDialog();
2089 new SMESHGUI_RemoveElementsDlg(this);
2093 SUIT_MessageBox::warn1(desktop(),
2094 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2095 tr("SMESH_BUT_OK"));
2099 case 4051: // RENUMBERING NODES
2101 if(checkLock(aStudy)) break;
2103 EmitSignalDeactivateDialog();
2104 new SMESHGUI_RenumberingDlg( this, "", 0);
2108 SUIT_MessageBox::warn1(desktop(),
2109 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2110 tr("SMESH_BUT_OK"));
2114 case 4052: // RENUMBERING ELEMENTS
2116 if(checkLock(aStudy)) break;
2118 EmitSignalDeactivateDialog();
2119 new SMESHGUI_RenumberingDlg( this, "", 1);
2123 SUIT_MessageBox::warn1(desktop(),
2124 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2125 tr("SMESH_BUT_OK"));
2129 case 4061: // TRANSLATION
2131 if(checkLock(aStudy)) break;
2133 EmitSignalDeactivateDialog();
2134 new SMESHGUI_TranslationDlg( this );
2137 SUIT_MessageBox::warn1(desktop(),
2138 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2139 tr("SMESH_BUT_OK"));
2143 case 4062: // ROTATION
2145 if(checkLock(aStudy)) break;
2147 EmitSignalDeactivateDialog();
2148 new SMESHGUI_RotationDlg( this );
2151 SUIT_MessageBox::warn1(desktop(),
2152 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2153 tr("SMESH_BUT_OK"));
2157 case 4063: // SYMMETRY
2159 if(checkLock(aStudy)) break;
2161 EmitSignalDeactivateDialog();
2162 new SMESHGUI_SymmetryDlg( this );
2165 SUIT_MessageBox::warn1(desktop(),
2166 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2167 tr("SMESH_BUT_OK"));
2171 case 4064: // SEWING
2173 if(checkLock(aStudy)) break;
2175 EmitSignalDeactivateDialog();
2176 new SMESHGUI_SewingDlg( this );
2179 SUIT_MessageBox::warn1(desktop(),
2180 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2181 tr("SMESH_BUT_OK"));
2185 case 4065: // MERGE NODES
2187 if(checkLock(aStudy)) break;
2189 EmitSignalDeactivateDialog();
2190 new SMESHGUI_EditMeshDlg( this, 0 );
2193 SUIT_MessageBox::warn1(desktop(),
2194 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2195 tr("SMESH_BUT_OK"));
2199 case 4066: // MERGE EQUAL ELEMENTS
2201 if (checkLock(aStudy)) break;
2203 EmitSignalDeactivateDialog();
2204 new SMESHGUI_EditMeshDlg( this, 1 );
2206 SUIT_MessageBox::warn1(desktop(),
2207 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2208 tr("SMESH_BUT_OK"));
2213 case 4067: // MAKE MESH PASS THROUGH POINT
2214 startOperation( 4067 );
2217 case 5105: // Library of selection filters
2219 static QValueList<int> aTypes;
2220 if ( aTypes.isEmpty() )
2222 aTypes.append( SMESH::NODE );
2223 aTypes.append( SMESH::EDGE );
2224 aTypes.append( SMESH::FACE );
2225 aTypes.append( SMESH::VOLUME );
2227 if (!myFilterLibraryDlg)
2228 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2229 else if (myFilterLibraryDlg->isHidden())
2230 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2231 myFilterLibraryDlg->raise();
2235 case 6017: // CONTROLS
2251 LightApp_SelectionMgr* mgr = selectionMgr();
2252 SALOME_ListIO selected; mgr->selectedObjects( selected );
2254 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2255 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2257 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2258 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2259 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2260 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2261 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2262 ::Control( theCommandID );
2267 SUIT_MessageBox::warn1(desktop(),
2268 tr( "SMESH_WRN_WARNING" ),
2269 tr( "SMESH_BAD_SELECTION" ),
2270 tr( "SMESH_BUT_OK" ) );
2274 SUIT_MessageBox::warn1(desktop(),
2275 tr( "SMESH_WRN_WARNING" ),
2276 tr( "NOT_A_VTK_VIEWER" ),
2277 tr( "SMESH_BUT_OK" ) );
2282 LightApp_SelectionMgr* mgr = selectionMgr();
2283 SALOME_ListIO selected; mgr->selectedObjects( selected );
2285 SALOME_ListIteratorOfListIO it(selected);
2286 for(; it.More(); it.Next()) {
2287 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2288 if(anIObject->hasEntry()) {
2289 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2290 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2298 LightApp_SelectionMgr* mgr = selectionMgr();
2299 SALOME_ListIO selected; mgr->selectedObjects( selected );
2301 if (selected.Extent() == 1) {
2302 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2303 if(anIObject->hasEntry())
2304 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2305 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2312 anApp->updateActions(); //SRN: To update a Save button in the toolbar
2313 //updateObjBrowser();
2317 //=============================================================================
2321 //=============================================================================
2322 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2327 //=============================================================================
2331 //=============================================================================
2332 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2337 //=============================================================================
2341 //=============================================================================
2342 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2347 //=============================================================================
2348 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2349 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2351 //=============================================================================
2352 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2353 SUIT_ViewWindow* wnd )
2355 if(theIO->hasEntry()){
2356 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2357 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2361 //=======================================================================
2362 // function : createSMESHAction
2364 //=======================================================================
2365 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
2368 QWidget* parent = application()->desktop();
2369 SUIT_ResourceMgr* resMgr = resourceMgr();
2371 if ( icon_id.length() )
2372 pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2374 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2375 if ( !pix.isNull() )
2376 icon = QIconSet( pix );
2378 QString tooltip = tr( QString( "TOP_" )+po_id ),
2379 menu = tr( QString( "MEN_" )+po_id ),
2380 status_bar = tr( QString( "STB_" )+po_id );
2382 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
2385 //=======================================================================
2386 // function : createPopupItem
2388 //=======================================================================
2389 void SMESHGUI::createPopupItem( const int id,
2390 const QString& clients,
2391 const QString& types,
2392 const QString& theRule,
2397 parentId = popupMgr()->actionId( action( pId ) );
2399 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2400 popupMgr()->insert( action( id ), parentId, 0 );
2402 QChar lc = QtxPopupMgr::Selection::defEquality();
2403 QString rule = "(%1) and (%2) and (%3)";
2404 rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2405 if( clients.isEmpty() )
2406 rule = rule.arg( QString( "true" ) );
2408 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2409 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2412 bool cont = myRules.contains( id );
2414 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2416 popupMgr()->setRule( action( id ), rule, true );
2417 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2420 //=======================================================================
2421 // function : initialize
2423 //=======================================================================
2424 void SMESHGUI::initialize( CAM_Application* app )
2426 SalomeApp_Module::initialize( app );
2428 // SUIT_ResourceMgr* mgr = app->resourceMgr();
2430 /* Automatic Update flag */
2431 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2433 // ----- create actions --------------
2435 createSMESHAction( 111, "DAT", "", (CTRL+Key_B) );
2436 createSMESHAction( 112, "UNV", "", (CTRL+Key_U) );
2437 createSMESHAction( 113, "MED", "", (CTRL+Key_M) );
2438 createSMESHAction( 114, "NUM" );
2439 createSMESHAction( 121, "DAT" );
2440 createSMESHAction( 122, "MED" );
2441 createSMESHAction( 123, "UNV" );
2442 createSMESHAction( 140, "STL" );
2443 createSMESHAction( 124, "EXPORT_DAT" );
2444 createSMESHAction( 125, "EXPORT_MED" );
2445 createSMESHAction( 126, "EXPORT_UNV" );
2446 createSMESHAction( 141, "EXPORT_STL" );
2447 createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
2448 createSMESHAction( 5105, "SEL_FILTER_LIB" );
2449 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
2450 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
2451 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
2452 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2453 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
2454 createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" );
2455 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2456 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
2457 createSMESHAction( 804, "ADD" );
2458 createSMESHAction( 805, "REMOVE" );
2459 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
2460 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
2461 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
2462 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
2463 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
2464 createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
2465 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH" , 0, true );
2466 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE" , 0, true );
2467 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D" , 0, true );
2468 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION" , 0, true );
2469 createSMESHAction( 6011, "AREA", "ICON_AREA" , 0, true );
2470 createSMESHAction( 6012, "TAPER", "ICON_TAPER" , 0, true );
2471 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT" , 0, true );
2472 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE" , 0, true );
2473 createSMESHAction( 6015, "WARP", "ICON_WARP" , 0, true );
2474 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
2475 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
2476 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
2477 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
2478 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
2479 createSMESHAction( 400, "NODE", "ICON_DLG_NODE" );
2480 createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" );
2481 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
2482 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
2483 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
2484 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
2485 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
2486 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
2487 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2488 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
2489 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
2490 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
2491 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
2492 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
2493 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
2494 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
2495 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
2496 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2497 createSMESHAction( 406, "MOVE", "ICON_DLG_MOVE_NODE" );
2498 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
2499 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
2500 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
2501 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
2502 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
2503 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
2504 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
2505 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
2506 createSMESHAction( 415, "MAP", "ICON_MAP" );
2507 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2508 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
2509 createSMESHAction( 200, "RESET" );
2510 createSMESHAction( 201, "SCALAR_BAR_PROP" );
2511 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
2512 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
2513 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
2514 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
2515 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
2516 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
2517 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
2518 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
2519 createSMESHAction( 220, "ALL" );
2520 createSMESHAction( 1100, "EDIT_HYPO" );
2521 createSMESHAction( 1101, "RENAME", "", Key_F2 );
2522 createSMESHAction( 1102, "UNASSIGN" );
2523 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2524 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2525 createSMESHAction( 1131, "DISPMODE" );
2526 createSMESHAction( 1132, "COLORS" );
2527 createSMESHAction( 1133, "TRANSP" );
2528 createSMESHAction( 1134, "CLIP" );
2529 createSMESHAction( 1135, "DISP_ENT" );
2530 createSMESHAction( 1136, "AUTO_COLOR" );
2531 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
2532 createSMESHAction( 2000, "CTRL" );
2534 createSMESHAction( 300, "ERASE" );
2535 createSMESHAction( 301, "DISPLAY" );
2536 createSMESHAction( 302, "DISPLAY_ONLY" );
2537 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2538 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2539 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2540 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2541 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2542 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2543 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2544 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2546 // ----- create menu --------------
2547 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
2548 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
2549 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
2550 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
2551 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
2552 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2553 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
2555 createMenu( separator(), fileId );
2557 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2558 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2559 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
2560 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2561 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
2562 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2564 createMenu( 111, importId, -1 );
2565 createMenu( 112, importId, -1 );
2566 createMenu( 113, importId, -1 );
2568 createMenu( 121, exportId, -1 );
2569 createMenu( 122, exportId, -1 );
2570 createMenu( 123, exportId, -1 );
2571 createMenu( 140, exportId, -1 ); // export to stl STL
2573 createMenu( separator(), fileId, 10 );
2575 createMenu( 33, editId, -1 );
2577 createMenu( 5105, toolsId, -1 );
2579 createMenu( 702, meshId, -1 );
2580 createMenu( 703, meshId, -1 );
2581 createMenu( 704, meshId, -1 );
2582 createMenu( 710, meshId, -1 );
2583 createMenu( separator(), meshId, -1 );
2584 createMenu( 701, meshId, -1 );
2585 createMenu( separator(), meshId, -1 );
2586 createMenu( 801, meshId, -1 );
2587 createMenu( 802, meshId, -1 );
2588 createMenu( 803, meshId, -1 );
2589 createMenu( separator(), meshId, -1 );
2590 createMenu( 810, meshId, -1 );
2591 createMenu( 811, meshId, -1 );
2592 createMenu( 812, meshId, -1 );
2593 createMenu( separator(), meshId, -1 );
2594 createMenu( 813, meshId, -1 );
2595 createMenu( separator(), meshId, -1 );
2596 createMenu( 900, meshId, -1 );
2597 createMenu( 902, meshId, -1 );
2598 createMenu( separator(), meshId, -1 );
2600 createMenu( 6003, ctrlId, -1 );
2601 createMenu( 6001, ctrlId, -1 );
2602 createMenu( 6004, ctrlId, -1 );
2603 createMenu( separator(), ctrlId, -1 );
2604 createMenu( 6002, ctrlId, -1 );
2605 createMenu( 6018, ctrlId, -1 );
2606 createMenu( 6019, ctrlId, -1 );
2607 createMenu( 6011, ctrlId, -1 );
2608 createMenu( 6012, ctrlId, -1 );
2609 createMenu( 6013, ctrlId, -1 );
2610 createMenu( 6014, ctrlId, -1 );
2611 createMenu( 6015, ctrlId, -1 );
2612 createMenu( 6016, ctrlId, -1 );
2613 createMenu( separator(), ctrlId, -1 );
2614 createMenu( 6017, ctrlId, -1 );
2615 createMenu( 6009, ctrlId, -1 );
2616 createMenu( separator(), ctrlId, -1 );
2618 createMenu( 400, addId, -1 );
2619 createMenu( 401, addId, -1 );
2620 createMenu( 4021, addId, -1 );
2621 createMenu( 4022, addId, -1 );
2622 createMenu( 4023, addId, -1 );
2623 createMenu( 4031, addId, -1 );
2624 createMenu( 4032, addId, -1 );
2625 createMenu( 4033, addId, -1 );
2626 createMenu( separator(), addId, -1 );
2627 createMenu( 4034, addId, -1 );
2628 createMenu( 4035, addId, -1 );
2629 createMenu( 4036, addId, -1 );
2630 createMenu( 4037, addId, -1 );
2631 createMenu( 4038, addId, -1 );
2632 createMenu( 4039, addId, -1 );
2633 createMenu( 4040, addId, -1 );
2635 createMenu( 4041, removeId, -1 );
2636 createMenu( 4042, removeId, -1 );
2638 createMenu( 4051, renumId, -1 );
2639 createMenu( 4052, renumId, -1 );
2641 createMenu( 4061, transfId, -1 );
2642 createMenu( 4062, transfId, -1 );
2643 createMenu( 4063, transfId, -1 );
2644 createMenu( 4064, transfId, -1 );
2645 createMenu( 4065, transfId, -1 );
2646 createMenu( 4066, transfId, -1 );
2648 createMenu( 406, modifyId, -1 );
2649 createMenu( 4067,modifyId, -1 );
2650 createMenu( 407, modifyId, -1 );
2651 createMenu( 408, modifyId, -1 );
2652 createMenu( 409, modifyId, -1 );
2653 createMenu( 410, modifyId, -1 );
2654 createMenu( 411, modifyId, -1 );
2655 createMenu( 412, modifyId, -1 );
2656 createMenu( 413, modifyId, -1 );
2657 createMenu( 416, modifyId, -1 );
2658 createMenu( 414, modifyId, -1 );
2659 createMenu( 415, modifyId, -1 );
2660 createMenu( 417, modifyId, -1 );
2662 createMenu( 214, viewId, -1 );
2664 // ----- create toolbars --------------
2665 int meshTb = createTool( tr( "TB_MESH" ) ),
2666 ctrlTb = createTool( tr( "TB_CTRL" ) ),
2667 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
2668 modifyTb = createTool( tr( "TB_MODIFY" ) ),
2669 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2671 createTool( 702, meshTb );
2672 createTool( 703, meshTb );
2673 createTool( 704, meshTb );
2674 createTool( 710, meshTb );
2675 createTool( separator(), meshTb );
2676 createTool( 701, meshTb );
2677 createTool( separator(), meshTb );
2678 createTool( 801, meshTb );
2679 createTool( 802, meshTb );
2680 createTool( 803, meshTb );
2681 createTool( separator(), meshTb );
2682 createTool( 900, meshTb );
2683 createTool( 902, meshTb );
2684 createTool( separator(), meshTb );
2686 createTool( 6001, ctrlTb );
2687 createTool( 6003, ctrlTb );
2688 createTool( 6004, ctrlTb );
2689 createTool( separator(), ctrlTb );
2690 createTool( 6002, ctrlTb );
2691 createTool( 6018, ctrlTb );
2692 createTool( 6019, ctrlTb );
2693 createTool( 6011, ctrlTb );
2694 createTool( 6012, ctrlTb );
2695 createTool( 6013, ctrlTb );
2696 createTool( 6014, ctrlTb );
2697 createTool( 6015, ctrlTb );
2698 createTool( 6016, ctrlTb );
2699 createTool( separator(), ctrlTb );
2700 createTool( 6017, ctrlTb );
2701 createTool( 6009, ctrlTb );
2702 createTool( separator(), ctrlTb );
2704 createTool( 400, addRemTb );
2705 createTool( 401, addRemTb );
2706 createTool( 4021, addRemTb );
2707 createTool( 4022, addRemTb );
2708 createTool( 4023, addRemTb );
2709 createTool( 4031, addRemTb );
2710 createTool( 4032, addRemTb );
2711 createTool( 4033, addRemTb );
2712 createTool( separator(), addRemTb );
2713 createTool( 4034, addRemTb );
2714 createTool( 4035, addRemTb );
2715 createTool( 4036, addRemTb );
2716 createTool( 4037, addRemTb );
2717 createTool( 4038, addRemTb );
2718 createTool( 4039, addRemTb );
2719 createTool( 4040, addRemTb );
2720 createTool( separator(), addRemTb );
2721 createTool( 4041, addRemTb );
2722 createTool( 4042, addRemTb );
2723 createTool( separator(), addRemTb );
2724 createTool( 4051, addRemTb );
2725 createTool( 4052, addRemTb );
2726 createTool( separator(), addRemTb );
2727 createTool( 4061, addRemTb );
2728 createTool( 4062, addRemTb );
2729 createTool( 4063, addRemTb );
2730 createTool( 4064, addRemTb );
2731 createTool( 4065, addRemTb );
2732 createTool( 4066, addRemTb );
2733 createTool( separator(), addRemTb );
2735 createTool( 406, modifyTb );
2736 createTool( 4067,modifyTb );
2737 createTool( 407, modifyTb );
2738 createTool( 408, modifyTb );
2739 createTool( 409, modifyTb );
2740 createTool( 410, modifyTb );
2741 createTool( 411, modifyTb );
2742 createTool( 412, modifyTb );
2743 createTool( 413, modifyTb );
2744 createTool( 416, modifyTb );
2745 createTool( 414, modifyTb );
2746 createTool( 415, modifyTb );
2747 createTool( 417, modifyTb );
2749 createTool( 214, dispModeTb );
2753 QString OB = "'ObjectBrowser'",
2754 View = "'" + SVTK_Viewer::Type() + "'",
2756 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2757 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2758 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2759 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2760 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2761 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2762 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2763 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2764 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2765 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2766 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2768 mesh_group = mesh + " " + subMesh + " " + group,
2769 hyp_alg = hypo + " " + algo;
2771 // popup for object browser
2773 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
2774 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
2775 createPopupItem( 803, OB, group ); // EDIT_GROUP
2776 popupMgr()->insert( separator(), -1, 0 );
2777 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
2778 createPopupItem( 214, OB, mesh_group ); // UPDATE
2779 createPopupItem( 900, OB, mesh_group ); // ADV_INFO
2780 createPopupItem( 902, OB, mesh ); // STD_INFO
2781 popupMgr()->insert( separator(), -1, 0 );
2782 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
2783 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
2784 popupMgr()->insert( separator(), -1, 0 );
2785 createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ ); // EDIT HYPOTHESIS
2786 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2787 createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2788 popupMgr()->insert( separator(), -1, 0 );
2790 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2791 createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
2792 createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
2793 createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
2794 //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
2795 createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
2796 popupMgr()->insert( separator(), -1, 0 );
2799 createPopupItem( 803, View, group ); // EDIT_GROUP
2800 createPopupItem( 804, View, elems ); // ADD
2801 createPopupItem( 805, View, elems ); // REMOVE
2802 popupMgr()->insert( separator(), -1, 0 );
2803 createPopupItem( 214, View, mesh_group ); // UPDATE
2804 createPopupItem( 900, View, mesh_group ); // ADV_INFO
2805 createPopupItem( 902, View, mesh ); // STD_INFO
2806 popupMgr()->insert( separator(), -1, 0 );
2808 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
2809 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
2810 popupMgr()->insert( separator(), -1, 0 );
2814 isInvisible("not( isVisible )"),
2815 isEmpty("numberOfNodes = 0"),
2816 isNotEmpty("numberOfNodes <> 0"),
2818 // has nodes, edges, etc in VISIBLE! actor
2819 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2820 hasElems("(count( elemTypes ) > 0)"),
2821 hasDifferentElems("(count( elemTypes ) > 1)"),
2822 hasEdges("({'Edge'} in elemTypes)"),
2823 hasFaces("({'Face'} in elemTypes)"),
2824 hasVolumes("({'Volume'} in elemTypes)");
2826 QString lc = QtxPopupMgr::Selection::defEquality();
2827 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2828 QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2829 aType = aType.arg( mesh_group );
2830 QString aMeshInVTK = aClient + "&&" + aType;
2832 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2833 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2834 QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2836 //-------------------------------------------------
2838 //-------------------------------------------------
2839 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2841 popupMgr()->insert( action( 9010 ), anId, -1 );
2842 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2843 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2845 popupMgr()->insert( action( 9011 ), anId, -1 );
2846 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2847 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2849 popupMgr()->insert( separator(), -1, -1 );
2851 //-------------------------------------------------
2853 //-------------------------------------------------
2854 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2856 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2857 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2858 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2860 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2861 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2862 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2864 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2865 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2866 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2868 popupMgr()->insert( separator(), anId, -1 );
2870 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2871 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2872 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2874 //-------------------------------------------------
2876 //-------------------------------------------------
2877 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2879 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2881 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2882 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2883 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2885 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2886 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2887 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2889 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2890 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2891 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2893 popupMgr()->insert( separator(), anId, -1 );
2895 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2896 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2898 //-------------------------------------------------
2900 //-------------------------------------------------
2901 popupMgr()->insert( action( 1132 ), -1, -1 );
2902 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2904 //-------------------------------------------------
2906 //-------------------------------------------------
2907 popupMgr()->insert( action( 1133 ), -1, -1 );
2908 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2910 //-------------------------------------------------
2912 //-------------------------------------------------
2913 popupMgr()->insert( action( 1134 ), -1, -1 );
2914 popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2916 popupMgr()->insert( separator(), -1, -1 );
2918 //-------------------------------------------------
2920 //-------------------------------------------------
2922 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2923 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2924 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2926 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2928 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2929 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2931 popupMgr()->insert( separator(), anId, -1 );
2933 popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2934 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2935 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2937 popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2938 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2939 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2941 popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2942 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2943 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2945 popupMgr()->insert( separator(), anId, -1 );
2947 popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2948 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2949 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2951 popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2952 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2953 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2955 popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2956 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2957 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2959 popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2960 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2961 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2963 popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2964 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2965 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2967 popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2968 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2969 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2971 popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2972 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2973 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2975 popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2976 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2977 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2979 popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2980 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2981 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2983 popupMgr()->insert( separator(), anId, -1 );
2985 popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2986 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2987 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2989 popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2990 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2991 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2993 popupMgr()->insert( separator(), anId, -1 );
2995 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2996 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2998 popupMgr()->insert( separator(), -1, -1 );
3000 //-------------------------------------------------
3002 //-------------------------------------------------
3003 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
3004 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
3005 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
3006 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
3008 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
3009 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
3011 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
3012 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
3014 popupMgr()->insert( separator(), -1, -1 );
3016 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
3017 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
3020 bool SMESHGUI::activateModule( SUIT_Study* study )
3022 bool res = SalomeApp_Module::activateModule( study );
3024 setMenuShown( true );
3025 setToolShown( true );
3027 // Reset actions accelerator keys
3028 action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
3029 action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
3030 action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
3035 bool SMESHGUI::deactivateModule( SUIT_Study* study )
3037 setMenuShown( false );
3038 setToolShown( false );
3040 EmitSignalCloseAllDialogs();
3042 // Unset actions accelerator keys
3043 action(111)->setAccel(QKeySequence()); // Import DAT
3044 action(112)->setAccel(QKeySequence()); // Import UNV
3045 action(113)->setAccel(QKeySequence()); // Import MED
3047 return SalomeApp_Module::deactivateModule( study );
3050 void SMESHGUI::studyClosed( SUIT_Study* s )
3052 SMESH::RemoveVisuData( s->id() );
3053 SalomeApp_Module::studyClosed( s );
3056 void SMESHGUI::OnGUIEvent()
3058 const QObject* obj = sender();
3059 if ( !obj || !obj->inherits( "QAction" ) )
3061 int id = actionId((QAction*)obj);
3066 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
3068 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
3069 if ( CORBA::is_nil( myComponentSMESH ) )
3071 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
3073 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3074 return aGUI.myComponentSMESH;
3077 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
3078 return myComponentSMESH;
3081 QString SMESHGUI::engineIOR() const
3083 CORBA::ORB_var anORB = getApp()->orb();
3084 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
3085 return QString( anIOR.in() );
3088 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
3090 SMESHGUI_Selection sel;
3091 sel.init( client, selectionMgr() );
3092 popupMgr()->updatePopup( menu, &sel );
3095 void SMESHGUI::windows( QMap<int, int>& aMap ) const
3097 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
3098 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
3101 void SMESHGUI::viewManagers( QStringList& list ) const
3103 list.append( SVTK_Viewer::Type() );
3106 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
3108 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
3109 SMESH::UpdateSelectionProp( this );
3112 void SMESHGUI::createPreferences()
3114 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
3116 int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
3117 addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
3119 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3120 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3121 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3123 int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3124 setPreferenceProperty( precGroup, "columns", 1 );
3126 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3128 setPreferenceProperty( prec, "min", 0 );
3129 setPreferenceProperty( prec, "max", 16 );
3131 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3132 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3134 modes.append( "Wireframe" );
3135 modes.append( "Shading" );
3136 modes.append( "Nodes" );
3137 modes.append( "Shrink" );
3138 QValueList<QVariant> indices;
3139 indices.append( 0 );
3140 indices.append( 1 );
3141 indices.append( 2 );
3142 indices.append( 3 );
3143 setPreferenceProperty( dispmode, "strings", modes );
3144 setPreferenceProperty( dispmode, "indexes", indices );
3146 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3147 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3148 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3150 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3151 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3153 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3154 int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3156 setPreferenceProperty( nodeSz, "min", 1 );
3157 setPreferenceProperty( nodeSz, "max", 5 );
3159 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3161 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3162 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3163 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3164 addPreference( "", elemGroup, LightApp_Preferences::Space );
3166 int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3167 int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3169 setPreferenceProperty( elemW, "min", 1 );
3170 setPreferenceProperty( elemW, "max", 5 );
3172 setPreferenceProperty( shrink, "min", 0 );
3173 setPreferenceProperty( shrink, "max", 100 );
3175 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3177 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3179 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3180 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3181 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3183 setPreferenceProperty( selW, "min", 1 );
3184 setPreferenceProperty( selW, "max", 5 );
3186 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3188 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3189 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3191 setPreferenceProperty( preW, "min", 1 );
3192 setPreferenceProperty( preW, "max", 5 );
3194 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3196 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3197 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3198 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
3200 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3201 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3203 int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3204 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3205 int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3206 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3209 fam.append( tr( "SMESH_FONT_ARIAL" ) );
3210 fam.append( tr( "SMESH_FONT_COURIER" ) );
3211 fam.append( tr( "SMESH_FONT_TIMES" ) );
3212 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3214 setPreferenceProperty( tfont, "families", fam );
3215 setPreferenceProperty( tfont, "system", false );
3216 setPreferenceProperty( tfont, "widget_flags", wflag );
3217 setPreferenceProperty( lfont, "families", fam );
3218 setPreferenceProperty( lfont, "system", false );
3219 setPreferenceProperty( lfont, "widget_flags", wflag );
3221 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3223 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3224 setPreferenceProperty( numcol, "min", 2 );
3225 setPreferenceProperty( numcol, "max", 256 );
3227 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3228 setPreferenceProperty( numlab, "min", 2 );
3229 setPreferenceProperty( numlab, "max", 65 );
3231 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3232 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3233 QStringList orients;
3234 orients.append( tr( "SMESH_VERTICAL" ) );
3235 orients.append( tr( "SMESH_HORIZONTAL" ) );
3236 indices.clear(); indices.append( 0 ); indices.append( 1 );
3237 setPreferenceProperty( orient, "strings", orients );
3238 setPreferenceProperty( orient, "indexes", indices );
3240 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3241 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3242 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3243 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3244 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3245 setPreferenceProperty( xv, "step", 0.1 );
3246 setPreferenceProperty( xv, "min", 0.0 );
3247 setPreferenceProperty( xv, "max", 1.0 );
3248 setPreferenceProperty( yv, "step", 0.1 );
3249 setPreferenceProperty( yv, "min", 0.0 );
3250 setPreferenceProperty( yv, "max", 1.0 );
3251 setPreferenceProperty( wv, "step", 0.1 );
3252 setPreferenceProperty( wv, "min", 0.0 );
3253 setPreferenceProperty( wv, "max", 1.0 );
3254 setPreferenceProperty( hv, "min", 0.0 );
3255 setPreferenceProperty( hv, "max", 1.0 );
3256 setPreferenceProperty( hv, "step", 0.1 );
3258 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3259 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3260 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3261 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3262 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3263 setPreferenceProperty( xv, "min", 0.0 );
3264 setPreferenceProperty( xv, "max", 1.0 );
3265 setPreferenceProperty( xv, "step", 0.1 );
3266 setPreferenceProperty( xh, "min", 0.0 );
3267 setPreferenceProperty( xh, "max", 1.0 );
3268 setPreferenceProperty( xh, "step", 0.1 );
3269 setPreferenceProperty( yh, "min", 0.0 );
3270 setPreferenceProperty( yh, "max", 1.0 );
3271 setPreferenceProperty( yh, "step", 0.1 );
3272 setPreferenceProperty( wh, "min", 0.0 );
3273 setPreferenceProperty( wh, "max", 1.0 );
3274 setPreferenceProperty( wh, "step", 0.1 );
3275 setPreferenceProperty( hh, "min", 0.0 );
3276 setPreferenceProperty( hh, "max", 1.0 );
3277 setPreferenceProperty( hh, "step", 0.1 );
3280 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3282 if( sect=="SMESH" ){
3283 float sbX1,sbY1,sbW,sbH;
3284 float aTol = 1.00000009999999;
3285 std::string aWarning;
3286 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3287 if( name=="selection_object_color" || name=="selection_element_color" ||
3288 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3289 name=="selection_precision_node" || name=="selection_precision_element" ||
3290 name=="selection_precision_object")
3291 SMESH::UpdateSelectionProp( this );
3292 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3293 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3294 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3295 if(sbX1+sbW > aTol){
3296 aWarning = "Origin and Size Vertical: X+Width > 1\n";
3299 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3300 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3303 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3304 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3305 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3306 if(sbY1+sbH > aTol){
3307 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3308 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3309 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3312 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
3313 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3314 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3315 if(sbX1+sbW > aTol){
3316 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3319 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3320 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3323 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
3324 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3325 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3326 if(sbY1+sbH > aTol){
3327 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3330 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3331 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3335 if(aWarning.size() != 0){
3336 aWarning += "The default values are applied instead.";
3337 SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3338 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3339 QObject::tr(aWarning.c_str()),
3340 QObject::tr("SMESH_BUT_OK"));
3345 //================================================================================
3347 * \brief Update something in accordance with update flags
3348 * \param theFlags - update flags
3350 * Update viewer or/and object browser etc. in accordance with update flags ( see
3351 * LightApp_UpdateFlags enumeration ).
3353 //================================================================================
3354 void SMESHGUI::update( const int flags )
3356 if ( flags & UF_Viewer | flags & UF_Forced )
3357 SMESH::UpdateView();
3359 SalomeApp_Module::update( flags );
3362 //================================================================================
3364 * \brief Set default selection mode
3366 * SLOT called when operation commited. Sets default selection mode
3368 //================================================================================
3369 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3371 SVTK_ViewWindow* vtkWnd =
3372 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3374 vtkWnd->SetSelectionMode( ActorSelection );
3377 //================================================================================
3379 * \brief Set default selection mode
3381 * SLOT called when operation aborted. Sets default selection mode
3383 //================================================================================
3384 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3386 SVTK_ViewWindow* vtkWnd =
3387 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3389 vtkWnd->SetSelectionMode( ActorSelection );
3392 //================================================================================
3394 * \brief Creates operation with given identifier
3395 * \param id - identifier of operation to be started
3396 * \return Pointer on created operation or NULL if operation is not created
3398 * Virtual method redefined from the base class creates operation with given id.
3399 * It is called called automatically from startOperation method of base class.
3401 //================================================================================
3402 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3404 LightApp_Operation* op = 0;
3405 // to do : create operation here
3408 case 701: // Compute mesh
3409 op = new SMESHGUI_ComputeOp();
3411 case 702: // Create mesh
3412 op = new SMESHGUI_MeshOp( true, true );
3414 case 703: // Create sub-mesh
3415 op = new SMESHGUI_MeshOp( true, false );
3417 case 704: // Edit mesh/sub-mesh
3418 op = new SMESHGUI_MeshOp( false );
3420 case 417: //convert to quadratic
3421 op = new SMESHGUI_ConvToQuadOp();
3423 case 4067: // make mesh pass through point
3424 op = new SMESHGUI_MakeNodeAtPointOp();
3431 op = SalomeApp_Module::createOperation( id );
3435 //================================================================================
3437 * \brief Stops current operations and starts a given one
3438 * \param id - The id of the operation to start
3440 //================================================================================
3442 void SMESHGUI::switchToOperation(int id)
3444 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3445 activeStudy()->abortAllOperations();
3446 startOperation( id );
3449 LightApp_Displayer* SMESHGUI::displayer()
3452 myDisplayer = new SMESHGUI_Displayer( getApp() );
3456 SALOMEDS::Color SMESHGUI::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
3459 int aTolerance = 64;
3460 int anIterations = 0;
3466 if( anIterations % aPeriod == 0 )
3469 if( aTolerance < 1 )
3472 //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
3474 aHue = (int)( 360.0 * rand() / RAND_MAX );
3475 //cout << "Hue = " << aHue << endl;
3477 //cout << "Auto colors : ";
3479 QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
3480 QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
3481 for( ; it != itEnd; ++it )
3483 SALOMEDS::Color anAutoColor = *it;
3484 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
3487 aQColor.getHsv( &h, &s, &v );
3489 if( abs( h - aHue ) < aTolerance )
3492 //cout << "break (diff = " << abs( h - aHue ) << ")";
3502 //cout << "Hue of the returned color = " << aHue << endl;
3504 aColor.setHsv( aHue, 255, 255 );
3506 SALOMEDS::Color aSColor;
3507 aSColor.R = (double)aColor.red() / 255.0;
3508 aSColor.G = (double)aColor.green() / 255.0;
3509 aSColor.B = (double)aColor.blue() / 255.0;