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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
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_Preferences_ColorDlg.h"
38 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
39 #include "SMESHGUI_Preferences_SelectionDlg.h"
40 #include "SMESHGUI_Hypotheses.h"
41 #include "SMESHGUI_HypothesesUtils.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_EditHypothesesDlg.h"
45 #include "SMESHGUI_CreateHypothesesDlg.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_SingleEditDlg.h"
49 #include "SMESHGUI_MultiEditDlg.h"
50 #include "SMESHGUI_GroupOpDlg.h"
51 #include "SMESHGUI_DeleteGroupDlg.h"
52 #include "SMESHGUI_SmoothingDlg.h"
53 #include "SMESHGUI_RenumberingDlg.h"
54 #include "SMESHGUI_ExtrusionDlg.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_MergeNodesDlg.h"
61 #include "SMESHGUI_MeshPatternDlg.h"
62 #include "SMESHGUI_PrecisionDlg.h"
64 #include "VTKViewer_ViewFrame.h"
65 #include "VTKViewer_InteractorStyleSALOME.h"
66 #include "VTKViewer_RenderWindowInteractor.h"
68 #include "SMESH_Actor.h"
69 #include "SMESH_Object.h"
72 #include "QAD_Tools.h"
73 #include "QAD_Config.h"
74 #include "QAD_Settings.h"
75 #include "QAD_RightFrame.h"
76 #include "QAD_MessageBox.h"
77 #include "QAD_Resource.h"
78 #include "QAD_FileDlg.h"
79 #include "QAD_Desktop.h"
80 #include "QAD_ResourceMgr.h"
81 #include "QAD_WaitCursor.h"
83 #include "SALOME_NamingService.hxx"
84 #include "SALOME_ListIteratorOfListIO.hxx"
85 #include "SALOME_InteractiveObject.hxx"
87 #include "SALOMEGUI_Desktop.h"
88 #include "SALOMEGUI_NameDlg.h"
89 #include "SALOMEGUI_ImportOperation.h"
90 #include "SALOMEGUI_QtCatchCorbaException.hxx"
92 #include "SMESHGUI_Utils.h"
93 #include "SMESHGUI_SMESHGenUtils.h"
94 #include "SMESHGUI_GEOMGenUtils.h"
95 #include "SMESHGUI_MeshUtils.h"
96 #include "SMESHGUI_GroupUtils.h"
97 #include "SMESHGUI_FilterUtils.h"
98 #include "SMESHGUI_PatternUtils.h"
99 #include "SMESHGUI_VTKUtils.h"
101 #include "SALOMEconfig.h"
102 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
105 #define INCLUDE_MENUITEM_DEF
106 #include <qapplication.h>
107 #include <qlineedit.h>
108 #include <qmenudata.h>
109 #include <qmenubar.h>
110 #include <qpopupmenu.h>
113 #include <qpainter.h>
114 #include <qcheckbox.h>
115 #include <qcolordialog.h>
116 #include <qspinbox.h>
120 #include <qradiobutton.h>
122 #include <boost/shared_ptr.hpp>
124 #include <vtkRenderer.h>
125 #include <vtkRenderWindow.h>
126 #include <vtkActorCollection.h>
127 #include <vtkScalarBarActor.h>
129 #include "utilities.h"
135 //=============================================================
136 void ImportMeshesFromFile(QAD_Desktop * parent,
137 SMESH::SMESH_Gen_ptr theComponentMesh,
140 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
142 void SetViewMode(int theCommandID);
144 void Control( int theCommandID );
146 void SetDisplaySettings();
150 //=============================================================
151 void ImportMeshesFromFile(QAD_Desktop * parent,
152 SMESH::SMESH_Gen_ptr theComponentMesh,
158 if(theCommandID == 113){
159 filter = QObject::tr("MED files (*.med)");
160 }else if (theCommandID == 112){
161 filter = QObject::tr("IDEAS files (*.unv)");
162 }else if (theCommandID == 111){
163 filter = QObject::tr("DAT files (*.dat)");
165 QString filename = QAD_FileDlg::getFileName(parent,
168 QObject::tr("Import mesh"),
170 if(!filename.isEmpty()) {
172 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
175 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
176 switch ( theCommandID ) {
179 aMeshes->length( 1 );
180 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
185 SMESH::DriverMED_ReadStatus res;
186 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
187 if ( res != SMESH::DRS_OK ) {
189 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
190 QObject::tr("SMESH_WRN_WARNING"),
191 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
192 QObject::tr("SMESH_BUT_OK"));
193 aMeshes->length( 0 );
200 bool isEmpty = false;
201 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
202 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
203 if ( !aMeshSO->_is_nil() ) {
204 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
205 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
206 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
207 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
208 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
215 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
216 QObject::tr("SMESH_WRN_WARNING"),
217 QObject::tr("SMESH_DRS_EMPTY"),
218 QObject::tr("SMESH_BUT_OK"));
222 catch (const SALOME::SALOME_Exception& S_ex){
224 QtCatchCorbaException(S_ex);
231 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
233 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
234 if(aSel->IObjectCount()){
235 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
236 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
237 if ( !aMesh->_is_nil() ) {
238 QString aFilter, aTitle = QObject::tr("Export mesh");
239 switch ( theCommandID ) {
241 aFilter = QObject::tr("MED files (*.med)");
244 aFilter = QObject::tr("DAT files (*.dat)");
247 if(aMesh->NbPyramids()){
248 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
249 QObject::tr("SMESH_WRN_WARNING"),
250 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
251 QObject::tr("SMESH_BUT_YES"),
252 QObject::tr("SMESH_BUT_NO"),
257 aFilter = QObject::tr("IDEAS files (*.unv)");
263 QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
264 if ( !aFilename.isEmpty() ) {
265 // Check whether the file already exists and delete it if yes
266 QFile aFile( aFilename );
267 if ( aFile.exists() )
270 switch ( theCommandID ) {
272 aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
275 aMesh->ExportDAT( aFilename.latin1() );
278 aMesh->ExportUNV( aFilename.latin1() );
288 void SetViewMode(int theCommandID){
289 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
290 if(Sel->IObjectCount() >= 1){
291 switch(theCommandID){
293 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
294 SMESHGUI_ClippingDlg *aDlg =
295 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
299 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
300 SMESHGUI_TransparencyDlg *aDlg =
301 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
304 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
305 for(; It.More(); It.Next()){
306 Handle(SALOME_InteractiveObject) IObject = It.Value();
307 if(IObject->hasEntry()){
308 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
309 switch(theCommandID){
311 anActor->SetRepresentation(SMESH_Actor::eEdge);
314 anActor->SetRepresentation(SMESH_Actor::eSurface);
317 if(anActor->IsShrunk())
320 anActor->SetShrink();
323 anActor->SetRepresentation(SMESH_Actor::ePoint);
327 anActor->GetSufaceColor(color[0], color[1], color[2]);
328 int c0 = int (color[0] * 255);
329 int c1 = int (color[1] * 255);
330 int c2 = int (color[2] * 255);
331 QColor c(c0, c1, c2);
334 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
335 c0 = int (edgecolor[0] * 255);
336 c1 = int (edgecolor[1] * 255);
337 c2 = int (edgecolor[2] * 255);
338 QColor e(c0, c1, c2);
340 float backfacecolor[3];
341 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
342 c0 = int (backfacecolor[0] * 255);
343 c1 = int (backfacecolor[1] * 255);
344 c2 = int (backfacecolor[2] * 255);
345 QColor b(c0, c1, c2);
348 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
349 c0 = int (nodecolor[0] * 255);
350 c1 = int (nodecolor[1] * 255);
351 c2 = int (nodecolor[2] * 255);
352 QColor n(c0, c1, c2);
354 int Edgewidth = (int)anActor->GetLineWidth();
357 int intValue = int(anActor->GetNodeSize());
358 float Shrink = anActor->GetShrinkFactor();
360 SMESHGUI_Preferences_ColorDlg *aDlg =
361 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
362 aDlg->SetColor(1, c);
363 aDlg->SetColor(2, e);
364 aDlg->SetColor(3, n);
365 aDlg->SetColor(4, b);
366 aDlg->SetIntValue(1, Edgewidth);
367 aDlg->SetIntValue(2, intValue);
368 aDlg->SetIntValue(3, int(Shrink*100.));
370 QColor color = aDlg->GetColor(1);
371 QColor edgecolor = aDlg->GetColor(2);
372 QColor nodecolor = aDlg->GetColor(3);
373 QColor backfacecolor = aDlg->GetColor(4);
374 /* actor color and backface color */
375 anActor->SetSufaceColor(float (color.red()) / 255.,
376 float (color.green()) / 255.,
377 float (color.blue()) / 255.);
378 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
379 float (backfacecolor.green()) / 255.,
380 float (backfacecolor.blue()) / 255.);
383 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
384 float (edgecolor.green()) / 255.,
385 float (edgecolor.blue()) / 255.);
387 /* Shrink factor and size edges */
388 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
389 anActor->SetLineWidth(aDlg->GetIntValue(1));
391 /* Nodes color and size */
392 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
393 float (nodecolor.green()) / 255.,
394 float (nodecolor.blue()) / 255.);
395 anActor->SetNodeSize(aDlg->GetIntValue(2));
404 SMESH::RepaintCurrentView();
409 void SetDisplaySettings()
411 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
412 SMESHGUI_Preferences_ColorDlg *aDlg =
413 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
416 QString SCr, SCg, SCb;
417 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
418 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
419 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
420 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
421 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
422 else color = QColor(0, 170, 255);
423 aDlg->SetColor(1, color);
425 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
426 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
427 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
428 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
429 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
430 else color = QColor(0, 170, 255);
431 aDlg->SetColor(2, color);
433 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
434 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
435 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
436 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
437 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
438 else color = Qt::red;
439 aDlg->SetColor(3, color);
441 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
442 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
443 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
444 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
445 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
446 else color = Qt::blue;
447 aDlg->SetColor(4, color);
449 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
450 if (intValue.isEmpty()) intValue = "1";
451 aDlg->SetIntValue(1, intValue.toInt());
452 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
453 if (intValue.isEmpty()) intValue = "3";
454 aDlg->SetIntValue(2, intValue.toInt());
455 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
456 if (intValue.isEmpty()) intValue = "75";
457 aDlg->SetIntValue(3, intValue.toInt());
460 QColor colorFill = aDlg->GetColor(1);
461 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
462 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
463 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
465 QColor colorOutline = aDlg->GetColor(2);
466 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
467 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
468 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
470 QColor colorNode = aDlg->GetColor(3);
471 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
472 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
473 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
475 QColor colorBackFace = aDlg->GetColor(4);
476 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
477 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
478 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
480 int width = aDlg->GetIntValue(1);
481 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
483 int nodes_size = aDlg->GetIntValue(2);
484 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
486 int shrink_coeff = aDlg->GetIntValue(3);
487 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
494 void Control( int theCommandID )
496 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
498 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
501 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
502 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
503 switch ( theCommandID ){
505 aTitle = QObject::tr( "LENGTH_EDGES" );
506 aControl = SMESH_Actor::eLengthEdges;
509 aTitle = QObject::tr( "FREE_EDGES" );
510 aControl = SMESH_Actor::eFreeEdges;
513 aTitle = QObject::tr( "FREE_BORDERS" );
514 aControl = SMESH_Actor::eFreeBorders;
517 aTitle = QObject::tr( "MULTI_BORDERS" );
518 aControl = SMESH_Actor::eMultiConnection;
521 aTitle = QObject::tr( "AREA_ELEMENTS" );
522 aControl = SMESH_Actor::eArea;
525 aTitle = QObject::tr( "TAPER_ELEMENTS" );
526 aControl = SMESH_Actor::eTaper;
529 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
530 aControl = SMESH_Actor::eAspectRatio;
533 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
534 aControl = SMESH_Actor::eMinimumAngle;
537 aTitle = QObject::tr( "WARP_ELEMENTS" );
538 aControl = SMESH_Actor::eWarping;
541 aTitle = QObject::tr( "SKEW_ELEMENTS" );
542 aControl = SMESH_Actor::eSkew;
545 anActor->SetControlMode(aControl);
546 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
553 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
554 MeshObjectType theType,
555 const QString theInTypeName,
556 QString & theOutTypeName)
558 SMESH_TypeFilter aTypeFilter( theType );
559 if ( aTypeFilter.IsOk( theIO )) {
560 theOutTypeName = theInTypeName;
567 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
569 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
570 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
571 if (!aSObj->_is_nil()) {
572 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
573 CORBA::String_var anID = aSComp->GetID();
574 if (!strcmp(anID.in(),theIO->getEntry()))
580 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
581 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
582 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
583 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
584 CheckOIType ( theIO, GROUP, "Group", aTypeName )
592 QString CheckHomogeneousSelection()
594 QAD_Study* aStudy = SMESH::GetActiveStudy();
595 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
598 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
599 for (; Itinit.More(); Itinit.Next())
601 List.Append(Itinit.Value());
604 QString RefType = CheckTypeObject(aSel->firstIObject());
605 SALOME_ListIteratorOfListIO It(List);
606 for (; It.More(); It.Next())
608 Handle(SALOME_InteractiveObject) IObject = It.Value();
609 QString Type = CheckTypeObject(IObject);
610 if (Type.compare(RefType) != 0)
611 return "Heterogeneous Selection";
614 aSel->ClearIObjects();
615 SALOME_ListIteratorOfListIO It1(List);
616 for (; It1.More(); It1.Next())
618 int res = aSel->AddIObject(It1.Value());
620 aStudy->highlight(It1.Value(), false);
622 aStudy->highlight(It1.Value(), true);
629 if (QAD_MessageBox::warn2
630 (QAD_Application::getDesktop(),
631 QObject::tr("SMESH_WRN_WARNING"),
632 QObject::tr("SMESH_REALLY_DELETE"),
633 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
636 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
637 int nbSf = anActiveStudy->getStudyFramesCount();
639 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
640 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
641 SALOMEDS::GenericAttribute_var anAttr;
642 SALOMEDS::AttributeIOR_var anIOR;
644 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
645 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
646 for(; It.More(); It.Next()){
647 Handle(SALOME_InteractiveObject) IObject = It.Value();
648 if(IObject->hasEntry()){
649 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
651 /* Erase child graphical objects */
652 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
653 for(; it->More(); it->Next()){
654 SALOMEDS::SObject_var CSO = it->Value();
655 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
656 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
658 for(int i = 0; i < nbSf; i++){
659 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
660 CORBA::String_var anEntry = CSO->GetID();
661 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
662 SMESH::RemoveActor(sf,anActor);
668 /* Erase main graphical object */
669 for(int i = 0; i < nbSf; i++){
670 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
671 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
672 SMESH::RemoveActor(sf,anActor);
676 // Remove object(s) from data structures
677 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
679 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group ::_narrow(obj->GetObject());
680 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
682 if ( !aGroup->_is_nil() ) { // DELETE GROUP
683 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
684 aMesh->RemoveGroup( aGroup );
686 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
687 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
688 aMesh->RemoveSubMesh( aSubMesh );
690 else {// default action: remove SObject from the study
691 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
692 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
694 aStudyBuilder->RemoveObjectWithChildren( obj );
699 } /* IObject->hasEntry() */
702 /* Clear any previous selection */
703 Sel->ClearIObjects();
704 anActiveStudy->updateObjBrowser();
710 //=============================================================================
714 //=============================================================================
715 class CustomItem:public QCustomMenuItem
718 CustomItem(const QString & s, const QFont & f):string(s), font(f)
725 void paint(QPainter * p, const QColorGroup & /*cg */ , bool /*act */ ,
726 bool /*enabled */ , int x, int y, int w, int h)
729 p->drawText(x, y, w, h,
730 AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
735 return QFontMetrics(font).
736 size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
743 //=============================================================================
747 //=============================================================================
748 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
749 SALOMEGUI( theName, theParent )
751 myActiveDialogBox = 0 ;
754 SMESH::GetSMESHGen();
755 SMESH::GetFilterManager();
758 /* load resources for all available meshers */
759 SMESH::InitAvailableHypotheses();
762 //=============================================================================
766 //=============================================================================
767 SMESHGUI::~SMESHGUI()
769 SMESH::GetFilterManager()->Destroy();
772 //=============================================================================
776 //=============================================================================
777 SMESHGUI* SMESHGUI::GetSMESHGUI()
779 static SMESHGUI aSMESHGUI;
780 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
781 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
783 /* Automatic Update flag */
784 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
791 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
792 return SMESHGUI::GetSMESHGUI();
796 //=============================================================================
800 //=============================================================================
801 void SMESHGUI::SetState(int aState)
803 this->myState = aState;
807 //=============================================================================
811 //=============================================================================
812 void SMESHGUI::ResetState()
818 //=============================================================================
822 //=============================================================================
823 void SMESHGUI::EmitSignalDeactivateDialog()
825 emit this->SignalDeactivateActiveDialog();
829 //=============================================================================
833 //=============================================================================
834 void SMESHGUI::EmitSignalStudyFrameChanged()
836 emit this->SignalStudyFrameChanged();
840 //=============================================================================
844 //=============================================================================
845 void SMESHGUI::EmitSignalCloseAllDialogs()
847 emit SignalCloseAllDialogs();
851 //=============================================================================
855 //=============================================================================
856 QDialog *SMESHGUI::GetActiveDialogBox()
858 return this->myActiveDialogBox;
861 //=============================================================================
865 //=============================================================================
866 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
868 this->myActiveDialogBox = (QDialog *) aDlg;
872 //=============================================================================
876 //=============================================================================
877 QAD_Study *SMESHGUI::GetActiveStudy()
879 return this->myActiveStudy;
882 //=============================================================================
886 //=============================================================================
887 QAD_Desktop *SMESHGUI::GetDesktop()
889 return QAD_Application::getDesktop();
892 //=============================================================================
896 //=============================================================================
897 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
899 MESSAGE("SMESHGUI::activeStudyChanged init.");
900 QAD_Study* prevStudy = myActiveStudy;
901 /* Create or retrieve an object SMESHGUI */
902 MESSAGE("Active study changed : prev study =" << prevStudy);
903 SMESHGUI::GetSMESHGUI();
904 EmitSignalStudyFrameChanged();
905 MESSAGE("Active study changed : active study =" << myActiveStudy);
906 if ( prevStudy != myActiveStudy ) {
907 EmitSignalCloseAllDialogs();
908 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
910 SMESH::UpdateSelectionProp();
912 MESSAGE("SMESHGUI::activeStudyChanged done.");
916 //=============================================================================
920 //=============================================================================
921 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
923 /* Here the position is on the bottom right corner - 10 */
924 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
926 QAD_Desktop *PP = QAD_Application::getDesktop();
927 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
928 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
932 //=============================================================================
936 //=============================================================================
937 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
938 return theStudy->GetProperties()->IsLocked();
941 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
942 if (isStudyLocked(theStudy)) {
943 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
944 QObject::tr("WRN_WARNING"),
945 QObject::tr("WRN_STUDY_LOCKED"),
946 QObject::tr("BUT_OK") );
952 //=======================================================================
953 //function : CheckActiveStudyLocked
955 //=======================================================================
957 bool SMESHGUI::ActiveStudyLocked()
959 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
960 return checkLock( aStudy );
963 //=============================================================================
967 //=============================================================================
968 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
970 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
972 switch (theCommandID) {
974 if(checkLock(aStudy)) break;
982 if(checkLock(aStudy)) break;
983 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
987 case 122: // EXPORT MED
991 ::ExportMeshToFile(parent, theCommandID);
995 case 200: // SCALAR BAR
997 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
998 if( Sel && Sel->IObjectCount() ) {
999 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1000 if( anIO->hasEntry() ) {
1001 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1002 anActor->SetControlMode( SMESH_Actor::eNone );
1010 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1011 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1015 case 1134: // Clipping
1016 case 1133: // Tranparency
1017 case 1132: // Colors / Size
1023 ::SetViewMode(theCommandID);
1029 if(checkLock(aStudy)) break;
1030 SMESH::UpdateView();
1035 case 301: // DISPLAY
1036 case 302: // DISPLAY ONLY
1038 SMESH::EDisplaing anAction;
1039 switch(theCommandID){
1040 case 300: anAction = SMESH::eErase; break;
1041 case 301: anAction = SMESH::eDisplay; break;
1042 case 302: anAction = SMESH::eDisplayOnly; break;
1045 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1046 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1047 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1048 for (; It.More(); It.Next()) {
1049 Handle(SALOME_InteractiveObject) IOS = It.Value();
1050 if (IOS->hasEntry()) {
1051 SMESH::UpdateView(anAction,IOS->getEntry());
1055 Sel->ClearIObjects();
1061 if(checkLock(aStudy)) break;
1062 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1063 EmitSignalDeactivateDialog();
1064 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1065 SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
1068 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1069 tr("SMESH_WRN_WARNING"),
1070 tr("SMESH_WRN_VIEWER_VTK"),
1071 tr("SMESH_BUT_OK"));
1076 case 2151: // FILTER
1078 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1080 EmitSignalDeactivateDialog();
1081 SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1086 case 406: // MOVE NODE
1088 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1090 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1091 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1095 if(checkLock(aStudy)) break;
1096 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1097 SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg( parent, Sel );
1101 case 701: // COMPUTE MESH
1103 if(checkLock(aStudy)) break;
1104 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1105 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1106 int nbSel = Sel->IObjectCount();
1111 SMESH::SMESH_Mesh_var aMesh;
1112 SMESH::SMESH_subMesh_var aSubMesh;
1113 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1114 if (IObject->hasEntry()){
1115 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1116 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1117 if ( aShapeObject->_is_nil() ) {
1121 if(!aMeshSObj->_is_nil()) {
1122 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1123 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1125 if (!aMesh->_is_nil()){
1126 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1127 if (!refShapeObject->_is_nil()) {
1128 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1129 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1130 tr("SMESH_WRN_WARNING"),
1131 tr("SMESH_WRN_MISSING_PARAMETERS"),
1132 tr("SMESH_BUT_OK"));
1136 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1137 SMESH::ModifiedMesh(aMeshSObj,true);
1138 // TO Do : change icon of all submeshes
1140 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1141 tr("SMESH_WRN_WARNING"),
1142 tr("SMESH_WRN_COMPUTE_FAILED"),
1143 tr("SMESH_BUT_OK"));
1145 catch(const SALOME::SALOME_Exception & S_ex){
1146 QtCatchCorbaException(S_ex);
1149 }else if(!aSubMesh->_is_nil()){
1150 aMesh = aSubMesh->GetFather();
1151 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1152 if(!refShapeObject->_is_nil()){
1153 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1155 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1156 tr("SMESH_WRN_WARNING"),
1157 tr("SMESH_WRN_MISSING_PARAMETERS"),
1158 tr("SMESH_BUT_OK"));
1162 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1163 SMESH::ModifiedMesh(aMeshSObj,true);
1164 // TO Do : change icon of all submeshes
1166 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1167 tr("SMESH_WRN_WARNING"),
1168 tr("SMESH_WRN_COMPUTE_FAILED"),
1169 tr("SMESH_BUT_OK"));
1170 }catch(const SALOME::SALOME_Exception & S_ex){
1171 QtCatchCorbaException(S_ex);
1177 CORBA::Long anId = aStudy->StudyId();
1178 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1179 if(myAutomaticUpdate && aVisualObj){
1180 aVisualObj->Update();
1181 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1183 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1185 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1191 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1192 tr("SMESH_WRN_WARNING"),
1193 tr("SMESH_WRN_VIEWER_VTK"),
1194 tr("SMESH_BUT_OK"));
1199 case 702: // ADD SUB MESH
1201 if(checkLock(aStudy)) break;
1202 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1203 EmitSignalDeactivateDialog();
1204 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1205 SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1208 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1209 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1210 tr("SMESH_BUT_OK"));
1215 case 703: // INIT MESH
1217 if(checkLock(aStudy)) break;
1218 EmitSignalDeactivateDialog();
1219 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1220 SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
1224 case 704: // EDIT Hypothesis
1226 if(checkLock(aStudy)) break;
1227 EmitSignalDeactivateDialog();
1228 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1229 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1233 case 705: // EDIT Global Hypothesis
1235 if(checkLock(aStudy)) break;
1236 EmitSignalDeactivateDialog();
1237 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1238 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1242 case 706: // EDIT Local Hypothesis
1244 if(checkLock(aStudy)) break;
1245 EmitSignalDeactivateDialog();
1246 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1247 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1251 case 407: // DIAGONAL INVERSION
1252 case 408: // Delete diagonal
1254 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1256 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1257 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1261 if ( checkLock( aStudy ) )
1264 SALOME_Selection *aSel =
1265 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1266 /*Standard_Boolean aRes;
1267 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1268 if ( aMesh->_is_nil() )
1270 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1271 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1275 EmitSignalDeactivateDialog();
1276 if ( theCommandID == 407 )
1277 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1279 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1282 case 409: // Change orientation
1283 case 410: // Union of triangles
1284 case 411: // Cutting of quadrangles
1286 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1288 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1289 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1293 if ( checkLock( aStudy ) )
1296 SALOME_Selection *aSel =
1297 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1299 EmitSignalDeactivateDialog();
1300 SMESHGUI_MultiEditDlg* aDlg;
1301 if ( theCommandID == 409 )
1302 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1303 else if ( theCommandID == 410 )
1304 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1306 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1309 DefineDlgPosition( aDlg, x, y );
1314 case 412: // Smoothing
1316 if(checkLock(aStudy)) break;
1317 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1318 EmitSignalDeactivateDialog();
1319 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1320 SMESHGUI_SmoothingDlg *aDlg = new SMESHGUI_SmoothingDlg(parent, "", Sel);
1323 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1324 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1325 tr("SMESH_BUT_OK"));
1329 case 413: // Extrusion
1331 if(checkLock(aStudy)) break;
1332 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1333 EmitSignalDeactivateDialog();
1334 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1335 SMESHGUI_ExtrusionDlg *aDlg = new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1338 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1339 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1340 tr("SMESH_BUT_OK"));
1344 case 414: // Revolution
1346 if(checkLock(aStudy)) break;
1347 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1348 EmitSignalDeactivateDialog();
1349 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1350 SMESHGUI_RevolutionDlg *aDlg = new SMESHGUI_RevolutionDlg(parent, "", Sel);
1353 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1354 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1355 tr("SMESH_BUT_OK"));
1359 case 415: // Pattern mapping
1361 if ( checkLock( aStudy ) )
1363 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1365 EmitSignalDeactivateDialog();
1366 SALOME_Selection *Sel = SALOME_Selection::Selection(
1367 myActiveStudy->getSelection() );
1368 new SMESHGUI_MeshPatternDlg( parent, Sel );
1371 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1372 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1373 tr("SMESH_BUT_OK"));
1377 case 801: // CREATE GROUP
1379 if(checkLock(aStudy)) break;
1380 EmitSignalDeactivateDialog();
1381 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1382 int nbSel = Sel->IObjectCount();
1384 // check if mesh is selected
1385 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1386 if (!aMesh->_is_nil()) {
1387 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1394 case 802: // CONSTRUCT GROUP
1396 if(checkLock(aStudy)) break;
1397 EmitSignalDeactivateDialog();
1398 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1399 int nbSel = Sel->IObjectCount();
1401 // check if submesh is selected
1402 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1403 if (IObject->hasEntry()) {
1404 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1405 if(!aSObj->_is_nil()) {
1406 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1407 if (!aSubMesh->_is_nil()) {
1409 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1410 // get submesh elements list by types
1411 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1412 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1413 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1414 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1415 // create group for each type o elements
1416 QString aName = IObject->getName();
1417 if (aNodes->length() > 0) {
1418 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
1419 aGroup->Add(aNodes.inout());
1421 if (aEdges->length() > 0) {
1422 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
1423 aGroup->Add(aEdges.inout());
1425 if (aFaces->length() > 0) {
1426 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
1427 aGroup->Add(aFaces.inout());
1429 if (aVolumes->length() > 0) {
1430 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
1431 aGroup->Add(aVolumes.inout());
1433 myActiveStudy->updateObjBrowser(true);
1434 }catch(const SALOME::SALOME_Exception & S_ex){
1435 QtCatchCorbaException(S_ex);
1444 case 803: // EDIT GROUP
1446 if(checkLock(aStudy)) break;
1447 EmitSignalDeactivateDialog();
1448 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1449 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1450 SALOME_ListIteratorOfListIO It (IOs);
1451 for ( ; It.More(); It.Next() )
1453 SMESH::SMESH_Group_var aGroup =
1454 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1455 if (!aGroup->_is_nil()) {
1456 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1463 case 804: // Add elements to group
1465 if(checkLock(aStudy)) break;
1466 if (myState == 800) {
1467 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1468 if (aDlg) aDlg->onAdd();
1473 case 805: // Remove elements from group
1475 if(checkLock(aStudy)) break;
1476 if (myState == 800) {
1477 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1478 if (aDlg) aDlg->onRemove();
1483 case 810: // Union Groups
1484 case 811: // Intersect groups
1485 case 812: // Cut groups
1487 if ( checkLock( aStudy ) )
1490 EmitSignalDeactivateDialog();
1491 SALOME_Selection *Sel = SALOME_Selection::Selection(
1492 myActiveStudy->getSelection() );
1495 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1496 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1497 else aMode = SMESHGUI_GroupOpDlg::CUT;
1499 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1503 case 813: // Delete groups with their contents
1505 if ( checkLock( aStudy ) )
1508 EmitSignalDeactivateDialog();
1509 SALOME_Selection *Sel = SALOME_Selection::Selection(
1510 myActiveStudy->getSelection() );
1512 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1516 case 900: // MESH INFOS
1518 EmitSignalDeactivateDialog();
1519 SALOME_Selection *Sel =
1520 SALOME_Selection::Selection(myActiveStudy->getSelection());
1521 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1522 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1523 SALOME_ListIteratorOfListIO It (IOs);
1524 for ( ; It.More(); It.Next() ) {
1525 Sel->ClearIObjects();
1526 Sel->AddIObject( It.Value() );
1527 SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
1529 // restore selection
1530 Sel->ClearIObjects();
1531 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1532 Sel->AddIObject( It.Value() );
1535 SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
1539 case 1001: // AUTOMATIC UPDATE PREFERENCES
1541 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1542 if (parent->menuBar()->isItemChecked(1001)) {
1543 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1544 myAutomaticUpdate = true;
1547 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1548 myAutomaticUpdate = false;
1553 case 1003: // MESH PREFERENCES
1555 ::SetDisplaySettings();
1561 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1567 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1573 SMESHGUI_Preferences_SelectionDlg* aDlg =
1574 new SMESHGUI_Preferences_SelectionDlg(parent);
1577 QString SCr, SCg, SCb;
1578 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1579 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1580 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1581 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1582 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1583 else aColor = Qt::cyan;
1584 aDlg->SetColor(1, aColor);
1586 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1587 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1588 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1589 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1590 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1591 else aColor = Qt::yellow;
1592 aDlg->SetColor(2, aColor);
1594 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1595 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1596 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1597 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1598 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1599 else aColor = Qt::white;
1600 aDlg->SetColor(3, aColor);
1602 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1603 if (SW1.isEmpty()) SW1 = "5";
1604 aDlg->SetWidth(1, SW1.toInt());
1606 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1607 if (SW2.isEmpty()) SW2 = "5";
1608 aDlg->SetWidth(2, SW2.toInt());
1610 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1611 if (SP1.isEmpty()) SP1 = "0.025";
1612 aDlg->SetPrecision(1, SP1.toDouble());
1614 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1615 if (SP2.isEmpty()) SP2 = "0.001";
1616 aDlg->SetPrecision(2, SP2.toDouble());
1619 QColor aPreColor = aDlg->GetColor(1);
1620 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1621 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1622 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1624 QColor aSelColor = aDlg->GetColor(2);
1625 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1626 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1627 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1629 QColor aHiColor = aDlg->GetColor(3);
1630 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1631 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1632 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1634 int aPreWidth = aDlg->GetWidth(1);
1635 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1636 int aSelWidth = aDlg->GetWidth(2);
1637 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1639 double aTolNodes = aDlg->GetPrecision(1);
1640 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1641 double aTolItems = aDlg->GetPrecision(2);
1642 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1644 // update current study settings
1645 SMESH::UpdateSelectionProp();
1647 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1648 if (studyFrame->getTypeView() == VIEW_VTK) {
1649 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1650 // update VTK viewer properties
1651 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1653 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1654 aSelColor.blue()/255., aSelWidth);
1655 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1656 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1658 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1659 aPreColor.blue()/255., aPreWidth);
1662 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1663 vtkActorCollection *aCollection = aRenderer->GetActors();
1664 aCollection->InitTraversal();
1665 while(vtkActor *anAct = aCollection->GetNextActor()){
1666 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1667 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1668 aHiColor.blue()/255.);
1669 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1670 aPreColor.blue()/255.);
1679 case 1100: // EDIT HYPOTHESIS
1681 if(checkLock(aStudy)) break;
1682 SALOME_Selection *Sel =
1683 SALOME_Selection::Selection(myActiveStudy->getSelection());
1684 int nbSel = Sel->IObjectCount();
1687 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1689 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1690 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1691 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1692 if ( !Hyp->_is_nil() )
1694 char* sName = Hyp->GetName();
1695 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1698 aCreator->EditHypothesis(Hyp);
1709 case 1101: // RENAME
1711 if ( checkLock( aStudy ) )
1714 SALOME_Selection *Sel =
1715 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1717 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1718 for ( ; It.More(); It.Next() )
1720 Handle(SALOME_InteractiveObject) IObject = It.Value();
1721 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1722 SALOMEDS::GenericAttribute_var anAttr;
1723 SALOMEDS::AttributeName_var aName;
1724 if ( !obj->_is_nil() )
1726 if ( obj->FindAttribute(anAttr, "AttributeName") )
1728 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1729 QString newName = QString(aName->Value());
1730 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1731 if ( !newName.isEmpty() )
1733 myActiveStudy->renameIObject( IObject, newName );
1735 // if current object is group update group's name
1736 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IObject);
1737 if (!aGroup->_is_nil() )
1738 aGroup->SetName( newName.latin1() );
1746 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1748 if(checkLock(aStudy)) break;
1750 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1751 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1752 for (int i = 0; It.More(); It.Next(), i++) {
1753 Handle(SALOME_InteractiveObject) IObject = It.Value();
1754 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1756 Sel->ClearIObjects();
1757 myActiveStudy->updateObjBrowser(true);
1761 case 401: // GEOM::EDGE
1762 case 4021: // TRIANGLE
1767 if(checkLock(aStudy)) break;
1768 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1769 EmitSignalDeactivateDialog();
1770 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1771 SMDSAbs_ElementType type = SMDSAbs_Edge;
1773 switch (theCommandID) {
1774 case 4021: // TRIANGLE
1775 type = SMDSAbs_Face; nbNodes = 3; break;
1777 type = SMDSAbs_Face; nbNodes = 4; break;
1779 type = SMDSAbs_Volume; nbNodes = 4; break;
1781 type = SMDSAbs_Volume; nbNodes = 8; break;
1784 SMESHGUI_AddMeshElementDlg *aDlg =
1785 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1788 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1789 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1790 tr("SMESH_BUT_OK"));
1795 case 4041: // REMOVES NODES
1797 if(checkLock(aStudy)) break;
1798 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1799 EmitSignalDeactivateDialog();
1800 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1801 SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1804 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1805 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1806 tr("SMESH_BUT_OK"));
1810 case 4042: // REMOVES ELEMENTS
1812 if(checkLock(aStudy)) break;
1813 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1814 EmitSignalDeactivateDialog();
1815 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1816 SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1820 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1821 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1822 tr("SMESH_BUT_OK"));
1826 case 4051: // RENUMBERING NODES
1828 if(checkLock(aStudy)) break;
1829 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1830 EmitSignalDeactivateDialog();
1831 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1832 SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1836 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1837 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1838 tr("SMESH_BUT_OK"));
1842 case 4052: // RENUMBERING ELEMENTS
1844 if(checkLock(aStudy)) break;
1845 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1846 EmitSignalDeactivateDialog();
1847 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1848 SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
1852 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1853 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1854 tr("SMESH_BUT_OK"));
1858 case 4061: // TRANSLATION
1860 if(checkLock(aStudy)) break;
1861 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1862 EmitSignalDeactivateDialog();
1863 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1864 SMESHGUI_TranslationDlg *aDlg = new SMESHGUI_TranslationDlg(parent, "", Sel);
1867 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1868 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1869 tr("SMESH_BUT_OK"));
1873 case 4062: // ROTATION
1875 if(checkLock(aStudy)) break;
1876 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1877 EmitSignalDeactivateDialog();
1878 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1879 SMESHGUI_RotationDlg *aDlg = new SMESHGUI_RotationDlg(parent, "", Sel);
1882 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1883 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1884 tr("SMESH_BUT_OK"));
1888 case 4063: // SYMMETRY
1890 if(checkLock(aStudy)) break;
1891 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1892 EmitSignalDeactivateDialog();
1893 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1894 SMESHGUI_SymmetryDlg *aDlg = new SMESHGUI_SymmetryDlg(parent, "", Sel);
1897 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1898 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1899 tr("SMESH_BUT_OK"));
1903 case 4064: // SEWING
1905 if(checkLock(aStudy)) break;
1906 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1907 EmitSignalDeactivateDialog();
1908 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1909 SMESHGUI_SewingDlg *aDlg = new SMESHGUI_SewingDlg(parent, "", Sel);
1912 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1913 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1914 tr("SMESH_BUT_OK"));
1918 case 4065: // MERGE NODES
1920 if(checkLock(aStudy)) break;
1921 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1922 EmitSignalDeactivateDialog();
1923 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1924 SMESHGUI_MergeNodesDlg *aDlg = new SMESHGUI_MergeNodesDlg(parent, "", Sel);
1927 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1928 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1929 tr("SMESH_BUT_OK"));
1935 case 5000: // HYPOTHESIS
1937 if(checkLock(aStudy)) break;
1938 EmitSignalDeactivateDialog();
1939 SMESHGUI_CreateHypothesesDlg *aDlg =
1940 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
1945 if(checkLock(aStudy)) break;
1946 EmitSignalDeactivateDialog();
1947 SMESHGUI_CreateHypothesesDlg *aDlg =
1948 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
1952 case 5105: // Library of selection filters
1954 static QValueList<int> aTypes;
1955 if ( aTypes.isEmpty() )
1957 aTypes.append( SMESH::NODE );
1958 aTypes.append( SMESH::EDGE );
1959 aTypes.append( SMESH::FACE );
1960 aTypes.append( SMESH::VOLUME );
1962 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
1966 case 6016: // CONTROLS
1976 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
1977 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1978 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
1979 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
1980 if ( !SO->_is_nil() ) {
1981 CORBA::Object_var aObject = SO->GetObject();
1982 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
1983 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
1984 SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aObject );
1985 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
1986 ::Control( theCommandID );
1991 QAD_MessageBox::warn1(GetDesktop(),
1992 tr( "SMESH_WRN_WARNING" ),
1993 tr( "SMESH_BAD_SELECTION" ),
1994 tr( "SMESH_BUT_OK" ) );
1998 QAD_MessageBox::warn1(GetDesktop(),
1999 tr( "SMESH_WRN_WARNING" ),
2000 tr( "NOT_A_VTK_VIEWER" ),
2001 tr( "SMESH_BUT_OK" ) );
2006 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2007 if (Sel->IObjectCount() == 1) {
2008 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2009 if(anIObject->hasEntry())
2010 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2011 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2018 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2019 if (Sel->IObjectCount() == 1) {
2020 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2021 if(anIObject->hasEntry())
2022 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2023 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2028 case 10001: // DISPLAY MODE PREFERENCE
2031 parent->menuBar()->setItemChecked(10001, true);
2032 parent->menuBar()->setItemChecked(10002, false);
2033 parent->menuBar()->setItemChecked(10004, false);
2034 parent->menuBar()->setItemEnabled(10003, true);
2035 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2040 parent->menuBar()->setItemChecked(10002, true);
2041 parent->menuBar()->setItemChecked(10001, false);
2042 parent->menuBar()->setItemChecked(10004, false);
2043 parent->menuBar()->setItemEnabled(10003, true);
2044 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2049 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2050 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2055 parent->menuBar()->setItemChecked(10001, false);
2056 parent->menuBar()->setItemChecked(10004, true);
2057 parent->menuBar()->setItemChecked(10002, false);
2058 parent->menuBar()->setItemEnabled(10003, false);
2059 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2065 myActiveStudy->updateObjBrowser(true);
2069 //=============================================================================
2073 //=============================================================================
2074 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2075 QAD_StudyFrame * studyFrame)
2080 //=============================================================================
2084 //=============================================================================
2085 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2086 QAD_StudyFrame * studyFrame)
2091 //=============================================================================
2095 //=============================================================================
2096 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2097 QAD_StudyFrame * studyFrame)
2102 //=============================================================================
2106 //=============================================================================
2107 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2109 MESSAGE("SMESHGUI::SetSettings.");
2110 SMESHGUI::GetSMESHGUI();
2113 QString DisplayMode = "Shading";
2114 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2115 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2117 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2119 bool Shrink = false;
2120 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2121 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2123 if (DisplayMode == "Wireframe") {
2125 parent->menuBar()->setItemChecked(10004, false);
2126 parent->menuBar()->setItemChecked(10002, false);
2127 parent->menuBar()->setItemChecked(10001, true);
2128 parent->menuBar()->setItemEnabled(10003, true);
2130 else if (DisplayMode == "Nodes") {
2132 parent->menuBar()->setItemChecked(10004, true);
2133 parent->menuBar()->setItemChecked(10002, false);
2134 parent->menuBar()->setItemChecked(10001, false);
2135 parent->menuBar()->setItemEnabled(10003, false);
2138 // default is shading
2139 parent->menuBar()->setItemChecked(10004, false);
2140 parent->menuBar()->setItemChecked(10002, true);
2141 parent->menuBar()->setItemChecked(10001, false);
2142 parent->menuBar()->setItemEnabled(10003, true);
2144 parent->menuBar()->setItemChecked(10003, Shrink);
2146 /* Automatic Update */
2147 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2148 if (AutoUpdate.compare("true") == 0) {
2149 parent->menuBar()->setItemChecked(1001, true);
2150 myAutomaticUpdate = true;
2153 parent->menuBar()->setItemChecked(1001, false);
2154 myAutomaticUpdate = false;
2158 SMESH::UpdateSelectionProp();
2161 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2162 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2167 //=============================================================================
2171 //=============================================================================
2172 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2174 // NRI : Temporary added
2175 // if ( myStudy->GetProperties()->IsLocked() ) {
2176 // theObject = "NothingSelected";
2177 // theContext = "NothingSelected";
2181 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2182 int nbSel = Sel->IObjectCount();
2185 theObject = "NothingSelected";
2186 theContext = "NothingSelected";
2189 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2190 theObject = "Elements";
2192 theObject = ::CheckTypeObject( Sel->firstIObject() );
2196 theObject = ::CheckHomogeneousSelection();
2201 //=============================================================================
2205 //=============================================================================
2206 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2207 const QString& theParent, const QString& theObject)
2209 // get active study frame
2210 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2212 // get parent component which selected object(s) belongs to
2213 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2216 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2217 int nbSel = Sel->IObjectCount();
2222 else if ( nbSel == 1 ) {
2223 if ( parentComp != parent->getActiveComponent() ) {
2224 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2226 int id = popup->idAt( 0 );
2227 if ( id <= QAD_TopLabel_Popup_ID )
2228 popup->removeItemAt( 0 );
2234 // get selected interactive object
2235 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2236 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2237 // find popup menu's TopLabel item
2238 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2239 if ( topItem >= 0 ) {
2240 if ( theParent == "Viewer" ) {
2241 // set bold font for popup menu's TopLabel item (Viewer popup)
2242 QFont fnt = QApplication::font(); fnt.setBold( TRUE );
2243 popup->removeItem( QAD_TopLabel_Popup_ID );
2244 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2246 else if ( theParent == "ObjectBrowser" ) {
2247 // remove popup menu's TopLabel item (Object Browser popup)
2248 popup->removeItem( QAD_TopLabel_Popup_ID );
2252 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2253 // remove Display/Erase commands
2254 popup->removeItem( QAD_Display_Popup_ID );
2255 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2256 popup->removeItem( QAD_Erase_Popup_ID );
2257 // remove "Unassign ..." command if hyp/algo is not assigned
2258 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2259 popup->removeItem( 1102 );
2261 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2263 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2264 if ( aShapeObject->_is_nil() ) {
2266 popup->removeItem( 701 ); // Compute
2267 popup->removeItem( 705 ); // Edit hypothesis
2268 popup->removeItem( 706 ); // ...
2270 SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry());
2271 // if object has actor
2272 if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
2273 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2274 if ( myRenderInter->isVisible( IObject ) ) {
2275 popup->removeItem( QAD_Display_Popup_ID );
2276 popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
2277 popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements #
2278 TVisualObjPtr aVisualObj = ac->GetObject();
2279 int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
2280 int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
2281 int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
2282 QMenuItem* mi = popup->findItem( 1131 );
2283 if ( mi && mi->popup() ) {
2284 int prType = ac->GetRepresentation();
2285 // Display Mode / Wireframe
2286 if(!aNbFaces && !aNbVolumes && !aNbEdges){
2287 mi->popup()->removeItem( 211 );
2289 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2291 // Display Mode / Shading
2292 if(!aNbFaces && !aNbVolumes){
2293 mi->popup()->removeItem( 212 );
2295 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2297 // Display Mode / Points
2298 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2299 // Display Mode / Shrink
2300 bool isShrunk = ac->IsShrunk();
2301 bool isShrunkable = ac->IsShrunkable();
2302 mi->popup()->setItemChecked( 213, isShrunk );
2303 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2306 mi = popup->findItem( 2000 );
2307 if ( mi && mi->popup() ) {
2308 SMESH_Actor::eControl cMode = ac->GetControlMode();
2310 case SMESH_Actor::eLengthEdges:
2311 mi->popup()->setItemChecked( 6001, true ); break;
2312 case SMESH_Actor::eFreeEdges:
2313 mi->popup()->setItemChecked( 6002, true );
2314 mi->popup()->removeItem( 201 );
2316 case SMESH_Actor::eFreeBorders:
2317 mi->popup()->setItemChecked( 6003, true );
2318 mi->popup()->removeItem( 201 );
2320 case SMESH_Actor::eMultiConnection:
2321 mi->popup()->setItemChecked( 6004, true ); break;
2322 case SMESH_Actor::eArea:
2323 mi->popup()->setItemChecked( 6011, true ); break;
2324 case SMESH_Actor::eTaper:
2325 mi->popup()->setItemChecked( 6012, true ); break;
2326 case SMESH_Actor::eAspectRatio:
2327 mi->popup()->setItemChecked( 6013, true ); break;
2328 case SMESH_Actor::eMinimumAngle:
2329 mi->popup()->setItemChecked( 6014, true ); break;
2330 case SMESH_Actor::eWarping:
2331 mi->popup()->setItemChecked( 6015, true ); break;
2332 case SMESH_Actor::eSkew:
2333 mi->popup()->setItemChecked( 6016, true ); break;
2334 case SMESH_Actor::eNone:
2336 mi->popup()->removeItem( 200 );
2337 mi->popup()->removeItem( 201 );
2340 TVisualObjPtr aVisualObj = ac->GetObject();
2342 mi->popup()->removeItem( 6001 );
2343 mi->popup()->removeItem( 6003 );
2344 mi->popup()->removeItem( 6004 );
2347 mi->popup()->removeItem( 6002 );
2348 mi->popup()->removeItem( 6011 );
2349 mi->popup()->removeItem( 6012 );
2350 mi->popup()->removeItem( 6013 );
2351 mi->popup()->removeItem( 6014 );
2352 mi->popup()->removeItem( 6015 );
2353 mi->popup()->removeItem( 6016 );
2355 if(!aNbFaces && !aNbEdges)
2356 popup->removeItem( 2000 ); // Scalar Bar
2360 popup->removeItem( QAD_Erase_Popup_ID );
2361 popup->removeItem( 114 ); // Numbering popup menu
2362 popup->removeItem( 1131 ); // Display mode
2363 popup->removeItem( 1132 ); // Color / size
2364 popup->removeItem( 1133 ); // Transparency
2365 popup->removeItem( 1134 ); // Clipping
2366 popup->removeItem( 2000 ); // Scalar Bar
2370 // object doesn't have actor
2371 CORBA::Object_var anObject = SO->GetObject();
2372 bool bDisplay = false;
2373 if ( !CORBA::is_nil( anObject ) ) {
2374 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2375 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2377 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2378 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2380 SMESH::SMESH_Group_var aGroupObj = SMESH::SMESH_Group::_narrow( anObject );
2381 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2385 popup->removeItem( QAD_Display_Popup_ID );
2386 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2388 popup->removeItem( QAD_Erase_Popup_ID );
2389 popup->removeItem( 114 ); // Numbering popup menu
2390 popup->removeItem( 1131 ); // Display mode
2391 popup->removeItem( 1132 ); // Color / size
2392 popup->removeItem( 1133 ); // Transparency
2393 popup->removeItem( 1134 ); // Clipping
2394 popup->removeItem( 2000 ); // Scalar Bar
2397 else if( theObject!="Component" ) {
2398 // another SMESH object
2399 popup->removeItem( QAD_Display_Popup_ID );
2400 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2401 popup->removeItem( QAD_Erase_Popup_ID );
2406 // multiple selection
2407 if ( parentComp != parent->getActiveComponent() ) {
2408 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2410 int id = popup->idAt( 0 );
2411 if ( id <= QAD_TopLabel_Popup_ID )
2412 popup->removeItemAt( 0 );
2416 if ( parentComp.isNull() ) {
2417 // objects from different components are selected
2418 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2419 popup->removeItem( QAD_Display_Popup_ID );
2420 popup->removeItem( QAD_Erase_Popup_ID );
2424 QString type = ::CheckHomogeneousSelection();
2425 if ( type != "Heterogeneous Selection" ) {
2426 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2427 if ( topItem >= 0 ) {
2428 // set bold font for popup menu's TopLabel item
2429 QFont fnt = QApplication::font(); fnt.setBold( TRUE );
2430 popup->removeItem( QAD_TopLabel_Popup_ID );
2431 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2439 //=============================================================================
2440 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2441 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2443 //=============================================================================
2444 void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
2446 if(theIO->hasEntry()){
2447 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2448 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2449 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2453 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2455 if (!buffer || !bufferSize)
2457 buffer[0] = (int)VIEW_VTK;
2460 void SMESHGUI::Deactivate()
2462 if ( SMESHGUI::GetSMESHGUI() ) {
2463 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();