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_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_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_MergeNodesDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_PrecisionDlg.h"
65 #include "VTKViewer_ViewFrame.h"
66 #include "VTKViewer_InteractorStyleSALOME.h"
67 #include "VTKViewer_RenderWindowInteractor.h"
69 #include "SMESH_Actor.h"
70 #include "SMESH_Object.h"
73 #include "QAD_Tools.h"
74 #include "QAD_Config.h"
75 #include "QAD_Settings.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_Resource.h"
79 #include "QAD_FileDlg.h"
80 #include "QAD_Desktop.h"
81 #include "QAD_ResourceMgr.h"
82 #include "QAD_WaitCursor.h"
84 #include "SALOME_NamingService.hxx"
85 #include "SALOME_ListIteratorOfListIO.hxx"
86 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOMEGUI_Desktop.h"
89 #include "SALOMEGUI_NameDlg.h"
90 #include "SALOMEGUI_ImportOperation.h"
91 #include "SALOMEGUI_QtCatchCorbaException.hxx"
93 #include "SMESHGUI_Utils.h"
94 #include "SMESHGUI_SMESHGenUtils.h"
95 #include "SMESHGUI_GEOMGenUtils.h"
96 #include "SMESHGUI_MeshUtils.h"
97 #include "SMESHGUI_GroupUtils.h"
98 #include "SMESHGUI_FilterUtils.h"
99 #include "SMESHGUI_PatternUtils.h"
100 #include "SMESHGUI_VTKUtils.h"
102 #include "SALOMEconfig.h"
103 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
106 #define INCLUDE_MENUITEM_DEF
107 #include <qapplication.h>
108 #include <qlineedit.h>
109 #include <qmenudata.h>
110 #include <qmenubar.h>
111 #include <qpopupmenu.h>
114 #include <qpainter.h>
115 #include <qcheckbox.h>
116 #include <qcolordialog.h>
117 #include <qspinbox.h>
121 #include <qradiobutton.h>
123 #include <boost/shared_ptr.hpp>
125 #include <vtkRenderer.h>
126 #include <vtkRenderWindow.h>
127 #include <vtkActorCollection.h>
128 #include <vtkScalarBarActor.h>
130 #include "utilities.h"
136 //=============================================================
137 void ImportMeshesFromFile(QAD_Desktop * parent,
138 SMESH::SMESH_Gen_ptr theComponentMesh,
141 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
143 void SetViewMode(int theCommandID);
145 void Control( int theCommandID );
147 void SetDisplaySettings();
151 //=============================================================
152 void ImportMeshesFromFile(QAD_Desktop * parent,
153 SMESH::SMESH_Gen_ptr theComponentMesh,
159 if(theCommandID == 113){
160 filter = QObject::tr("MED files (*.med)");
161 }else if (theCommandID == 112){
162 filter = QObject::tr("IDEAS files (*.unv)");
163 }else if (theCommandID == 111){
164 filter = QObject::tr("DAT files (*.dat)");
166 QString filename = QAD_FileDlg::getFileName(parent,
169 QObject::tr("Import mesh"),
171 if(!filename.isEmpty()) {
173 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
176 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
177 switch ( theCommandID ) {
180 aMeshes->length( 1 );
181 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
186 SMESH::DriverMED_ReadStatus res;
187 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
188 if ( res != SMESH::DRS_OK ) {
190 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
191 QObject::tr("SMESH_WRN_WARNING"),
192 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
193 QObject::tr("SMESH_BUT_OK"));
194 aMeshes->length( 0 );
201 bool isEmpty = false;
202 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
203 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
204 if ( !aMeshSO->_is_nil() ) {
205 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
206 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
207 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
208 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
209 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
216 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
217 QObject::tr("SMESH_WRN_WARNING"),
218 QObject::tr("SMESH_DRS_EMPTY"),
219 QObject::tr("SMESH_BUT_OK"));
223 catch (const SALOME::SALOME_Exception& S_ex){
225 QtCatchCorbaException(S_ex);
232 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
234 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
235 if(aSel->IObjectCount()){
236 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
237 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
238 if ( !aMesh->_is_nil() ) {
239 QString aFilter, aTitle = QObject::tr("Export mesh");
240 switch ( theCommandID ) {
242 aFilter = QObject::tr("MED files (*.med)");
245 aFilter = QObject::tr("DAT files (*.dat)");
248 if(aMesh->NbPyramids()){
249 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
250 QObject::tr("SMESH_WRN_WARNING"),
251 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
252 QObject::tr("SMESH_BUT_YES"),
253 QObject::tr("SMESH_BUT_NO"),
258 aFilter = QObject::tr("IDEAS files (*.unv)");
264 QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
265 if ( !aFilename.isEmpty() ) {
266 // Check whether the file already exists and delete it if yes
267 QFile aFile( aFilename );
268 if ( aFile.exists() )
271 switch ( theCommandID ) {
273 aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
276 aMesh->ExportDAT( aFilename.latin1() );
279 aMesh->ExportUNV( aFilename.latin1() );
289 void SetViewMode(int theCommandID){
290 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
291 if(Sel->IObjectCount() >= 1){
292 switch(theCommandID){
294 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
295 SMESHGUI_ClippingDlg *aDlg =
296 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
300 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
301 SMESHGUI_TransparencyDlg *aDlg =
302 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
305 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
306 for(; It.More(); It.Next()){
307 Handle(SALOME_InteractiveObject) IObject = It.Value();
308 if(IObject->hasEntry()){
309 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
310 switch(theCommandID){
312 anActor->SetRepresentation(SMESH_Actor::eEdge);
315 anActor->SetRepresentation(SMESH_Actor::eSurface);
318 if(anActor->IsShrunk())
321 anActor->SetShrink();
324 anActor->SetRepresentation(SMESH_Actor::ePoint);
328 anActor->GetSufaceColor(color[0], color[1], color[2]);
329 int c0 = int (color[0] * 255);
330 int c1 = int (color[1] * 255);
331 int c2 = int (color[2] * 255);
332 QColor c(c0, c1, c2);
335 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
336 c0 = int (edgecolor[0] * 255);
337 c1 = int (edgecolor[1] * 255);
338 c2 = int (edgecolor[2] * 255);
339 QColor e(c0, c1, c2);
341 float backfacecolor[3];
342 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
343 c0 = int (backfacecolor[0] * 255);
344 c1 = int (backfacecolor[1] * 255);
345 c2 = int (backfacecolor[2] * 255);
346 QColor b(c0, c1, c2);
349 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
350 c0 = int (nodecolor[0] * 255);
351 c1 = int (nodecolor[1] * 255);
352 c2 = int (nodecolor[2] * 255);
353 QColor n(c0, c1, c2);
355 int Edgewidth = (int)anActor->GetLineWidth();
358 int intValue = int(anActor->GetNodeSize());
359 float Shrink = anActor->GetShrinkFactor();
361 SMESHGUI_Preferences_ColorDlg *aDlg =
362 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
363 aDlg->SetColor(1, c);
364 aDlg->SetColor(2, e);
365 aDlg->SetColor(3, n);
366 aDlg->SetColor(4, b);
367 aDlg->SetIntValue(1, Edgewidth);
368 aDlg->SetIntValue(2, intValue);
369 aDlg->SetIntValue(3, int(Shrink*100.));
371 QColor color = aDlg->GetColor(1);
372 QColor edgecolor = aDlg->GetColor(2);
373 QColor nodecolor = aDlg->GetColor(3);
374 QColor backfacecolor = aDlg->GetColor(4);
375 /* actor color and backface color */
376 anActor->SetSufaceColor(float (color.red()) / 255.,
377 float (color.green()) / 255.,
378 float (color.blue()) / 255.);
379 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
380 float (backfacecolor.green()) / 255.,
381 float (backfacecolor.blue()) / 255.);
384 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
385 float (edgecolor.green()) / 255.,
386 float (edgecolor.blue()) / 255.);
388 /* Shrink factor and size edges */
389 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
390 anActor->SetLineWidth(aDlg->GetIntValue(1));
392 /* Nodes color and size */
393 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
394 float (nodecolor.green()) / 255.,
395 float (nodecolor.blue()) / 255.);
396 anActor->SetNodeSize(aDlg->GetIntValue(2));
405 SMESH::RepaintCurrentView();
410 void SetDisplaySettings()
412 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
413 SMESHGUI_Preferences_ColorDlg *aDlg =
414 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
417 QString SCr, SCg, SCb;
418 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
419 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
420 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
421 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
422 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
423 else color = QColor(0, 170, 255);
424 aDlg->SetColor(1, color);
426 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
427 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
428 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
429 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
430 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
431 else color = QColor(0, 170, 255);
432 aDlg->SetColor(2, color);
434 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
435 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
436 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
437 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
438 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
439 else color = Qt::red;
440 aDlg->SetColor(3, color);
442 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
443 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
444 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
445 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
446 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
447 else color = Qt::blue;
448 aDlg->SetColor(4, color);
450 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
451 if (intValue.isEmpty()) intValue = "1";
452 aDlg->SetIntValue(1, intValue.toInt());
453 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
454 if (intValue.isEmpty()) intValue = "3";
455 aDlg->SetIntValue(2, intValue.toInt());
456 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
457 if (intValue.isEmpty()) intValue = "75";
458 aDlg->SetIntValue(3, intValue.toInt());
461 QColor colorFill = aDlg->GetColor(1);
462 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
463 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
464 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
466 QColor colorOutline = aDlg->GetColor(2);
467 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
468 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
469 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
471 QColor colorNode = aDlg->GetColor(3);
472 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
473 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
474 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
476 QColor colorBackFace = aDlg->GetColor(4);
477 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
478 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
479 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
481 int width = aDlg->GetIntValue(1);
482 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
484 int nodes_size = aDlg->GetIntValue(2);
485 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
487 int shrink_coeff = aDlg->GetIntValue(3);
488 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
495 void Control( int theCommandID )
497 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
499 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
502 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
503 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
504 switch ( theCommandID ){
506 aTitle = QObject::tr( "LENGTH_EDGES" );
507 aControl = SMESH_Actor::eLengthEdges;
510 aTitle = QObject::tr( "FREE_EDGES" );
511 aControl = SMESH_Actor::eFreeEdges;
514 aTitle = QObject::tr( "FREE_BORDERS" );
515 aControl = SMESH_Actor::eFreeBorders;
518 aTitle = QObject::tr( "MULTI_BORDERS" );
519 aControl = SMESH_Actor::eMultiConnection;
522 aTitle = QObject::tr( "AREA_ELEMENTS" );
523 aControl = SMESH_Actor::eArea;
526 aTitle = QObject::tr( "TAPER_ELEMENTS" );
527 aControl = SMESH_Actor::eTaper;
530 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
531 aControl = SMESH_Actor::eAspectRatio;
534 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
535 aControl = SMESH_Actor::eMinimumAngle;
538 aTitle = QObject::tr( "WARP_ELEMENTS" );
539 aControl = SMESH_Actor::eWarping;
542 aTitle = QObject::tr( "SKEW_ELEMENTS" );
543 aControl = SMESH_Actor::eSkew;
546 anActor->SetControlMode(aControl);
547 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
554 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
555 MeshObjectType theType,
556 const QString theInTypeName,
557 QString & theOutTypeName)
559 SMESH_TypeFilter aTypeFilter( theType );
560 if ( aTypeFilter.IsOk( theIO )) {
561 theOutTypeName = theInTypeName;
568 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
570 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
571 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
572 if (!aSObj->_is_nil()) {
573 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
574 CORBA::String_var anID = aSComp->GetID();
575 if (!strcmp(anID.in(),theIO->getEntry()))
581 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
582 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
583 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
584 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
585 CheckOIType ( theIO, GROUP, "Group", aTypeName )
593 QString CheckHomogeneousSelection()
595 QAD_Study* aStudy = SMESH::GetActiveStudy();
596 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
599 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
600 for (; Itinit.More(); Itinit.Next())
602 List.Append(Itinit.Value());
605 QString RefType = CheckTypeObject(aSel->firstIObject());
606 SALOME_ListIteratorOfListIO It(List);
607 for (; It.More(); It.Next())
609 Handle(SALOME_InteractiveObject) IObject = It.Value();
610 QString Type = CheckTypeObject(IObject);
611 if (Type.compare(RefType) != 0)
612 return "Heterogeneous Selection";
615 aSel->ClearIObjects();
616 SALOME_ListIteratorOfListIO It1(List);
617 for (; It1.More(); It1.Next())
619 int res = aSel->AddIObject(It1.Value());
621 aStudy->highlight(It1.Value(), false);
623 aStudy->highlight(It1.Value(), true);
630 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
631 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
632 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
633 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
634 QObject::tr("ERR_ERROR"),
635 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
636 QObject::tr("BUT_OK") );
639 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
640 if (QAD_MessageBox::warn2
641 (QAD_Application::getDesktop(),
642 QObject::tr("SMESH_WRN_WARNING"),
643 QObject::tr("SMESH_REALLY_DELETE"),
644 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
647 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
648 int nbSf = anActiveStudy->getStudyFramesCount();
650 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
651 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
652 SALOMEDS::GenericAttribute_var anAttr;
653 SALOMEDS::AttributeIOR_var anIOR;
655 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
656 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
657 for(; It.More(); It.Next()){
658 Handle(SALOME_InteractiveObject) IObject = It.Value();
659 if(IObject->hasEntry()){
660 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
662 /* Erase child graphical objects */
663 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
664 for(; it->More(); it->Next()){
665 SALOMEDS::SObject_var CSO = it->Value();
666 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
667 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
669 for(int i = 0; i < nbSf; i++){
670 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
671 CORBA::String_var anEntry = CSO->GetID();
672 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
673 SMESH::RemoveActor(sf,anActor);
679 /* Erase main graphical object */
680 for(int i = 0; i < nbSf; i++){
681 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
682 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
683 SMESH::RemoveActor(sf,anActor);
687 // Remove object(s) from data structures
688 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
690 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
691 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
693 if ( !aGroup->_is_nil() ) { // DELETE GROUP
694 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
695 aMesh->RemoveGroup( aGroup );
697 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
698 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
699 aMesh->RemoveSubMesh( aSubMesh );
701 else {// default action: remove SObject from the study
702 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
703 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
705 aStudyBuilder->RemoveObjectWithChildren( obj );
710 } /* IObject->hasEntry() */
713 /* Clear any previous selection */
714 Sel->ClearIObjects();
715 anActiveStudy->updateObjBrowser();
721 //=============================================================================
725 //=============================================================================
726 class CustomItem : public QCustomMenuItem
729 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
732 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
735 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
736 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
737 p->setFont( myFont );
738 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
744 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
747 bool fullSpan() const
757 //=============================================================================
761 //=============================================================================
762 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
763 SALOMEGUI( theName, theParent )
765 myActiveDialogBox = 0 ;
768 SMESH::GetSMESHGen();
769 SMESH::GetFilterManager();
772 /* load resources for all available meshers */
773 SMESH::InitAvailableHypotheses();
776 //=============================================================================
780 //=============================================================================
781 SMESHGUI::~SMESHGUI()
783 SMESH::GetFilterManager()->Destroy();
786 //=============================================================================
790 //=============================================================================
791 SMESHGUI* SMESHGUI::GetSMESHGUI()
793 static SMESHGUI aSMESHGUI;
794 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
795 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
797 /* Automatic Update flag */
798 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
805 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
806 return SMESHGUI::GetSMESHGUI();
810 //=============================================================================
814 //=============================================================================
815 void SMESHGUI::SetState(int aState)
817 this->myState = aState;
821 //=============================================================================
825 //=============================================================================
826 void SMESHGUI::ResetState()
832 //=============================================================================
836 //=============================================================================
837 void SMESHGUI::EmitSignalDeactivateDialog()
839 emit this->SignalDeactivateActiveDialog();
843 //=============================================================================
847 //=============================================================================
848 void SMESHGUI::EmitSignalStudyFrameChanged()
850 emit this->SignalStudyFrameChanged();
854 //=============================================================================
858 //=============================================================================
859 void SMESHGUI::EmitSignalCloseAllDialogs()
861 emit SignalCloseAllDialogs();
865 //=============================================================================
869 //=============================================================================
870 QDialog *SMESHGUI::GetActiveDialogBox()
872 return this->myActiveDialogBox;
875 //=============================================================================
879 //=============================================================================
880 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
882 this->myActiveDialogBox = (QDialog *) aDlg;
886 //=============================================================================
890 //=============================================================================
891 QAD_Study *SMESHGUI::GetActiveStudy()
893 return this->myActiveStudy;
896 //=============================================================================
900 //=============================================================================
901 QAD_Desktop *SMESHGUI::GetDesktop()
903 return QAD_Application::getDesktop();
906 //=============================================================================
910 //=============================================================================
911 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
913 MESSAGE("SMESHGUI::activeStudyChanged init.");
914 QAD_Study* prevStudy = myActiveStudy;
915 /* Create or retrieve an object SMESHGUI */
916 MESSAGE("Active study changed : prev study =" << prevStudy);
917 SMESHGUI::GetSMESHGUI();
918 EmitSignalStudyFrameChanged();
919 MESSAGE("Active study changed : active study =" << myActiveStudy);
920 if ( prevStudy != myActiveStudy ) {
921 EmitSignalCloseAllDialogs();
922 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
924 SMESH::UpdateSelectionProp();
926 MESSAGE("SMESHGUI::activeStudyChanged done.");
930 //=============================================================================
934 //=============================================================================
935 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
937 /* Here the position is on the bottom right corner - 10 */
938 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
940 QAD_Desktop *PP = QAD_Application::getDesktop();
941 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
942 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
946 //=============================================================================
950 //=============================================================================
951 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
952 return theStudy->GetProperties()->IsLocked();
955 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
956 if (isStudyLocked(theStudy)) {
957 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
958 QObject::tr("WRN_WARNING"),
959 QObject::tr("WRN_STUDY_LOCKED"),
960 QObject::tr("BUT_OK") );
966 //=======================================================================
967 //function : CheckActiveStudyLocked
969 //=======================================================================
971 bool SMESHGUI::ActiveStudyLocked()
973 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
974 return checkLock( aStudy );
977 //=============================================================================
981 //=============================================================================
982 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
984 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
986 switch (theCommandID) {
988 if(checkLock(aStudy)) break;
996 if(checkLock(aStudy)) break;
997 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1001 case 122: // EXPORT MED
1005 ::ExportMeshToFile(parent, theCommandID);
1009 case 200: // SCALAR BAR
1011 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1012 if( Sel && Sel->IObjectCount() ) {
1013 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1014 if( anIO->hasEntry() ) {
1015 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1016 anActor->SetControlMode( SMESH_Actor::eNone );
1024 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1025 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1029 case 1134: // Clipping
1030 case 1133: // Tranparency
1031 case 1132: // Colors / Size
1037 ::SetViewMode(theCommandID);
1043 if(checkLock(aStudy)) break;
1044 SMESH::UpdateView();
1049 case 301: // DISPLAY
1050 case 302: // DISPLAY ONLY
1052 SMESH::EDisplaing anAction;
1053 switch(theCommandID){
1054 case 300: anAction = SMESH::eErase; break;
1055 case 301: anAction = SMESH::eDisplay; break;
1056 case 302: anAction = SMESH::eDisplayOnly; break;
1059 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1060 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1061 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1062 for (; It.More(); It.Next()) {
1063 Handle(SALOME_InteractiveObject) IOS = It.Value();
1064 if (IOS->hasEntry()) {
1065 SMESH::UpdateView(anAction,IOS->getEntry());
1069 Sel->ClearIObjects();
1075 if(checkLock(aStudy)) break;
1076 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1077 EmitSignalDeactivateDialog();
1078 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1079 SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
1082 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1083 tr("SMESH_WRN_WARNING"),
1084 tr("SMESH_WRN_VIEWER_VTK"),
1085 tr("SMESH_BUT_OK"));
1090 case 2151: // FILTER
1092 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1094 EmitSignalDeactivateDialog();
1095 SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1100 case 406: // MOVE NODE
1102 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1104 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1105 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1109 if(checkLock(aStudy)) break;
1110 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1111 SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg( parent, Sel );
1115 case 701: // COMPUTE MESH
1117 if(checkLock(aStudy)) break;
1118 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1119 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1120 int nbSel = Sel->IObjectCount();
1125 SMESH::SMESH_Mesh_var aMesh;
1126 SMESH::SMESH_subMesh_var aSubMesh;
1127 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1128 if (IObject->hasEntry()){
1129 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1130 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1131 if ( aShapeObject->_is_nil() ) {
1135 if(!aMeshSObj->_is_nil()) {
1136 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1137 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1139 if (!aMesh->_is_nil()){
1140 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1141 if (!refShapeObject->_is_nil()) {
1142 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1143 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1144 tr("SMESH_WRN_WARNING"),
1145 tr("SMESH_WRN_MISSING_PARAMETERS"),
1146 tr("SMESH_BUT_OK"));
1150 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1151 SMESH::ModifiedMesh(aMeshSObj,true);
1152 // TO Do : change icon of all submeshes
1154 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1155 tr("SMESH_WRN_WARNING"),
1156 tr("SMESH_WRN_COMPUTE_FAILED"),
1157 tr("SMESH_BUT_OK"));
1159 catch(const SALOME::SALOME_Exception & S_ex){
1160 QtCatchCorbaException(S_ex);
1163 }else if(!aSubMesh->_is_nil()){
1164 aMesh = aSubMesh->GetFather();
1165 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1166 if(!refShapeObject->_is_nil()){
1167 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1169 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1170 tr("SMESH_WRN_WARNING"),
1171 tr("SMESH_WRN_MISSING_PARAMETERS"),
1172 tr("SMESH_BUT_OK"));
1176 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1177 SMESH::ModifiedMesh(aMeshSObj,true);
1178 // TO Do : change icon of all submeshes
1180 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1181 tr("SMESH_WRN_WARNING"),
1182 tr("SMESH_WRN_COMPUTE_FAILED"),
1183 tr("SMESH_BUT_OK"));
1184 }catch(const SALOME::SALOME_Exception & S_ex){
1185 QtCatchCorbaException(S_ex);
1191 CORBA::Long anId = aStudy->StudyId();
1192 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1193 if(myAutomaticUpdate && aVisualObj){
1194 aVisualObj->Update();
1195 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1197 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1199 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1205 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1206 tr("SMESH_WRN_WARNING"),
1207 tr("SMESH_WRN_VIEWER_VTK"),
1208 tr("SMESH_BUT_OK"));
1213 case 702: // ADD SUB MESH
1215 if(checkLock(aStudy)) break;
1216 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1217 EmitSignalDeactivateDialog();
1218 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1219 SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1222 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1223 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1224 tr("SMESH_BUT_OK"));
1229 case 703: // INIT MESH
1231 if(checkLock(aStudy)) break;
1232 EmitSignalDeactivateDialog();
1233 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1234 SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
1238 case 704: // EDIT Hypothesis
1240 if(checkLock(aStudy)) break;
1241 EmitSignalDeactivateDialog();
1242 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1243 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1247 case 705: // EDIT Global Hypothesis
1249 if(checkLock(aStudy)) break;
1250 EmitSignalDeactivateDialog();
1251 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1252 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1256 case 706: // EDIT Local Hypothesis
1258 if(checkLock(aStudy)) break;
1259 EmitSignalDeactivateDialog();
1260 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1261 SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1265 case 407: // DIAGONAL INVERSION
1266 case 408: // Delete diagonal
1268 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1270 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1271 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1275 if ( checkLock( aStudy ) )
1278 SALOME_Selection *aSel =
1279 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1280 /*Standard_Boolean aRes;
1281 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1282 if ( aMesh->_is_nil() )
1284 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1285 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1289 EmitSignalDeactivateDialog();
1290 if ( theCommandID == 407 )
1291 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1293 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1296 case 409: // Change orientation
1297 case 410: // Union of triangles
1298 case 411: // Cutting of quadrangles
1300 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1302 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1303 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1307 if ( checkLock( aStudy ) )
1310 SALOME_Selection *aSel =
1311 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1313 EmitSignalDeactivateDialog();
1314 SMESHGUI_MultiEditDlg* aDlg;
1315 if ( theCommandID == 409 )
1316 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1317 else if ( theCommandID == 410 )
1318 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1320 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1323 DefineDlgPosition( aDlg, x, y );
1328 case 412: // Smoothing
1330 if(checkLock(aStudy)) break;
1331 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1332 EmitSignalDeactivateDialog();
1333 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1334 SMESHGUI_SmoothingDlg *aDlg = new SMESHGUI_SmoothingDlg(parent, "", Sel);
1337 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1338 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1339 tr("SMESH_BUT_OK"));
1343 case 413: // Extrusion
1345 if(checkLock(aStudy)) break;
1346 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1347 EmitSignalDeactivateDialog();
1348 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1349 SMESHGUI_ExtrusionDlg *aDlg = new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1352 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1353 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1354 tr("SMESH_BUT_OK"));
1358 case 414: // Revolution
1360 if(checkLock(aStudy)) break;
1361 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1362 EmitSignalDeactivateDialog();
1363 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1364 SMESHGUI_RevolutionDlg *aDlg = new SMESHGUI_RevolutionDlg(parent, "", Sel);
1367 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1368 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1369 tr("SMESH_BUT_OK"));
1373 case 415: // Pattern mapping
1375 if ( checkLock( aStudy ) )
1377 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1379 EmitSignalDeactivateDialog();
1380 SALOME_Selection *Sel = SALOME_Selection::Selection(
1381 myActiveStudy->getSelection() );
1382 new SMESHGUI_MeshPatternDlg( parent, Sel );
1385 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1386 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1387 tr("SMESH_BUT_OK"));
1391 case 801: // CREATE GROUP
1393 if(checkLock(aStudy)) break;
1394 EmitSignalDeactivateDialog();
1395 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1396 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1397 int nbSel = Sel->IObjectCount();
1399 // check if mesh is selected
1400 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1402 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1407 case 802: // CONSTRUCT GROUP
1409 if(checkLock(aStudy)) break;
1410 EmitSignalDeactivateDialog();
1411 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1412 int nbSel = Sel->IObjectCount();
1414 // check if submesh is selected
1415 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1416 if (IObject->hasEntry()) {
1417 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1418 if(!aSObj->_is_nil()) {
1419 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1420 if (!aSubMesh->_is_nil()) {
1422 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1423 // get submesh elements list by types
1424 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1425 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1426 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1427 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1428 // create group for each type o elements
1429 QString aName = IObject->getName();
1430 if (aNodes->length() > 0) {
1431 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
1432 aGroup->Add(aNodes.inout());
1434 if (aEdges->length() > 0) {
1435 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
1436 aGroup->Add(aEdges.inout());
1438 if (aFaces->length() > 0) {
1439 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
1440 aGroup->Add(aFaces.inout());
1442 if (aVolumes->length() > 0) {
1443 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
1444 aGroup->Add(aVolumes.inout());
1446 myActiveStudy->updateObjBrowser(true);
1447 }catch(const SALOME::SALOME_Exception & S_ex){
1448 QtCatchCorbaException(S_ex);
1457 case 803: // EDIT GROUP
1459 if(checkLock(aStudy)) break;
1460 EmitSignalDeactivateDialog();
1461 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1462 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1463 SALOME_ListIteratorOfListIO It (IOs);
1464 int nbSelectedGroups = 0;
1465 for ( ; It.More(); It.Next() )
1467 SMESH::SMESH_Group_var aGroup =
1468 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1469 if (!aGroup->_is_nil()) {
1471 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1475 if (nbSelectedGroups == 0)
1477 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1483 case 804: // Add elements to group
1485 if(checkLock(aStudy)) break;
1486 if (myState == 800) {
1487 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1488 if (aDlg) aDlg->onAdd();
1493 case 805: // Remove elements from group
1495 if(checkLock(aStudy)) break;
1496 if (myState == 800) {
1497 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1498 if (aDlg) aDlg->onRemove();
1503 case 810: // Union Groups
1504 case 811: // Intersect groups
1505 case 812: // Cut groups
1507 if ( checkLock( aStudy ) )
1510 EmitSignalDeactivateDialog();
1511 SALOME_Selection *Sel = SALOME_Selection::Selection(
1512 myActiveStudy->getSelection() );
1515 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1516 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1517 else aMode = SMESHGUI_GroupOpDlg::CUT;
1519 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1523 case 813: // Delete groups with their contents
1525 if ( checkLock( aStudy ) )
1528 EmitSignalDeactivateDialog();
1529 SALOME_Selection *Sel = SALOME_Selection::Selection(
1530 myActiveStudy->getSelection() );
1532 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1536 case 900: // MESH INFOS
1538 EmitSignalDeactivateDialog();
1539 SALOME_Selection *Sel =
1540 SALOME_Selection::Selection(myActiveStudy->getSelection());
1541 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1542 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1543 SALOME_ListIteratorOfListIO It (IOs);
1544 for ( ; It.More(); It.Next() ) {
1545 Sel->ClearIObjects();
1546 Sel->AddIObject( It.Value() );
1547 SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
1549 // restore selection
1550 Sel->ClearIObjects();
1551 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1552 Sel->AddIObject( It.Value() );
1555 SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
1559 case 902: // STANDARD MESH INFOS
1561 EmitSignalDeactivateDialog();
1562 SALOME_Selection *Sel =
1563 SALOME_Selection::Selection(myActiveStudy->getSelection());
1564 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1565 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1566 SALOME_ListIteratorOfListIO It (IOs);
1567 for ( ; It.More(); It.Next() ) {
1568 Sel->ClearIObjects();
1569 Sel->AddIObject( It.Value() );
1570 SMESHGUI_StandardMeshInfosDlg *aDlg = new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1572 // restore selection
1573 Sel->ClearIObjects();
1574 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1575 Sel->AddIObject( It.Value() );
1578 SMESHGUI_StandardMeshInfosDlg *aDlg = new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1582 case 1001: // AUTOMATIC UPDATE PREFERENCES
1584 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1585 if (parent->menuBar()->isItemChecked(1001)) {
1586 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1587 myAutomaticUpdate = true;
1590 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1591 myAutomaticUpdate = false;
1596 case 1003: // MESH PREFERENCES
1598 ::SetDisplaySettings();
1604 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1610 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1616 SMESHGUI_Preferences_SelectionDlg* aDlg =
1617 new SMESHGUI_Preferences_SelectionDlg(parent);
1620 QString SCr, SCg, SCb;
1621 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1622 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1623 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1624 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1625 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1626 else aColor = Qt::cyan;
1627 aDlg->SetColor(1, aColor);
1629 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1630 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1631 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1632 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1633 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1634 else aColor = Qt::yellow;
1635 aDlg->SetColor(2, aColor);
1637 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1638 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1639 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1640 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1641 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1642 else aColor = Qt::white;
1643 aDlg->SetColor(3, aColor);
1645 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1646 if (SW1.isEmpty()) SW1 = "5";
1647 aDlg->SetWidth(1, SW1.toInt());
1649 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1650 if (SW2.isEmpty()) SW2 = "5";
1651 aDlg->SetWidth(2, SW2.toInt());
1653 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1654 if (SP1.isEmpty()) SP1 = "0.025";
1655 aDlg->SetPrecision(1, SP1.toDouble());
1657 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1658 if (SP2.isEmpty()) SP2 = "0.001";
1659 aDlg->SetPrecision(2, SP2.toDouble());
1662 QColor aPreColor = aDlg->GetColor(1);
1663 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1664 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1665 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1667 QColor aSelColor = aDlg->GetColor(2);
1668 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1669 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1670 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1672 QColor aHiColor = aDlg->GetColor(3);
1673 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1674 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1675 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1677 int aPreWidth = aDlg->GetWidth(1);
1678 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1679 int aSelWidth = aDlg->GetWidth(2);
1680 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1682 double aTolNodes = aDlg->GetPrecision(1);
1683 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1684 double aTolItems = aDlg->GetPrecision(2);
1685 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1687 // update current study settings
1688 SMESH::UpdateSelectionProp();
1690 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1691 if (studyFrame->getTypeView() == VIEW_VTK) {
1692 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1693 // update VTK viewer properties
1694 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1696 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1697 aSelColor.blue()/255., aSelWidth);
1698 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1699 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1701 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1702 aPreColor.blue()/255., aPreWidth);
1705 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1706 vtkActorCollection *aCollection = aRenderer->GetActors();
1707 aCollection->InitTraversal();
1708 while(vtkActor *anAct = aCollection->GetNextActor()){
1709 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1710 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1711 aHiColor.blue()/255.);
1712 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1713 aPreColor.blue()/255.);
1722 case 1100: // EDIT HYPOTHESIS
1724 if(checkLock(aStudy)) break;
1725 SALOME_Selection *Sel =
1726 SALOME_Selection::Selection(myActiveStudy->getSelection());
1727 int nbSel = Sel->IObjectCount();
1730 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1732 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1733 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1734 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1735 if ( !Hyp->_is_nil() )
1737 char* sName = Hyp->GetName();
1738 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1741 aCreator->EditHypothesis(Hyp);
1752 case 1101: // RENAME
1754 if ( checkLock( aStudy ) )
1757 SALOME_Selection *Sel =
1758 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1760 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1761 for ( ; It.More(); It.Next() )
1763 Handle(SALOME_InteractiveObject) IObject = It.Value();
1764 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1765 SALOMEDS::GenericAttribute_var anAttr;
1766 SALOMEDS::AttributeName_var aName;
1767 if ( !obj->_is_nil() )
1769 if ( obj->FindAttribute(anAttr, "AttributeName") )
1771 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1772 QString newName = QString(aName->Value());
1773 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1774 if ( !newName.isEmpty() )
1776 myActiveStudy->renameIObject( IObject, newName );
1778 // if current object is group update group's name
1779 SMESH::SMESH_GroupBase_var aGroup =
1780 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1781 if (!aGroup->_is_nil() )
1782 aGroup->SetName( newName.latin1() );
1790 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1792 if(checkLock(aStudy)) break;
1794 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1795 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1796 for (int i = 0; It.More(); It.Next(), i++) {
1797 Handle(SALOME_InteractiveObject) IObject = It.Value();
1798 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1800 Sel->ClearIObjects();
1801 myActiveStudy->updateObjBrowser(true);
1805 case 401: // GEOM::EDGE
1806 case 4021: // TRIANGLE
1811 if(checkLock(aStudy)) break;
1812 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1813 EmitSignalDeactivateDialog();
1814 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1815 SMDSAbs_ElementType type = SMDSAbs_Edge;
1817 switch (theCommandID) {
1818 case 4021: // TRIANGLE
1819 type = SMDSAbs_Face; nbNodes = 3; break;
1821 type = SMDSAbs_Face; nbNodes = 4; break;
1823 type = SMDSAbs_Volume; nbNodes = 4; break;
1825 type = SMDSAbs_Volume; nbNodes = 8; break;
1828 SMESHGUI_AddMeshElementDlg *aDlg =
1829 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1832 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1833 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1834 tr("SMESH_BUT_OK"));
1839 case 4041: // REMOVES NODES
1841 if(checkLock(aStudy)) break;
1842 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1843 EmitSignalDeactivateDialog();
1844 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1845 SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1848 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1849 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1850 tr("SMESH_BUT_OK"));
1854 case 4042: // REMOVES ELEMENTS
1856 if(checkLock(aStudy)) break;
1857 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1858 EmitSignalDeactivateDialog();
1859 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1860 SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1864 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1865 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1866 tr("SMESH_BUT_OK"));
1870 case 4051: // RENUMBERING NODES
1872 if(checkLock(aStudy)) break;
1873 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1874 EmitSignalDeactivateDialog();
1875 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1876 SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1880 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1881 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1882 tr("SMESH_BUT_OK"));
1886 case 4052: // RENUMBERING ELEMENTS
1888 if(checkLock(aStudy)) break;
1889 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1890 EmitSignalDeactivateDialog();
1891 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1892 SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
1896 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1897 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1898 tr("SMESH_BUT_OK"));
1902 case 4061: // TRANSLATION
1904 if(checkLock(aStudy)) break;
1905 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1906 EmitSignalDeactivateDialog();
1907 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1908 SMESHGUI_TranslationDlg *aDlg = new SMESHGUI_TranslationDlg(parent, "", Sel);
1911 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1912 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1913 tr("SMESH_BUT_OK"));
1917 case 4062: // ROTATION
1919 if(checkLock(aStudy)) break;
1920 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1921 EmitSignalDeactivateDialog();
1922 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1923 SMESHGUI_RotationDlg *aDlg = new SMESHGUI_RotationDlg(parent, "", Sel);
1926 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1927 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1928 tr("SMESH_BUT_OK"));
1932 case 4063: // SYMMETRY
1934 if(checkLock(aStudy)) break;
1935 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1936 EmitSignalDeactivateDialog();
1937 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1938 SMESHGUI_SymmetryDlg *aDlg = new SMESHGUI_SymmetryDlg(parent, "", Sel);
1941 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1942 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1943 tr("SMESH_BUT_OK"));
1947 case 4064: // SEWING
1949 if(checkLock(aStudy)) break;
1950 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1951 EmitSignalDeactivateDialog();
1952 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1953 SMESHGUI_SewingDlg *aDlg = new SMESHGUI_SewingDlg(parent, "", Sel);
1956 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1957 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1958 tr("SMESH_BUT_OK"));
1962 case 4065: // MERGE NODES
1964 if(checkLock(aStudy)) break;
1965 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1966 EmitSignalDeactivateDialog();
1967 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1968 SMESHGUI_MergeNodesDlg *aDlg = new SMESHGUI_MergeNodesDlg(parent, "", Sel);
1971 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1972 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1973 tr("SMESH_BUT_OK"));
1979 case 5000: // HYPOTHESIS
1981 if(checkLock(aStudy)) break;
1982 EmitSignalDeactivateDialog();
1983 SMESHGUI_CreateHypothesesDlg *aDlg =
1984 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
1989 if(checkLock(aStudy)) break;
1990 EmitSignalDeactivateDialog();
1991 SMESHGUI_CreateHypothesesDlg *aDlg =
1992 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
1996 case 5105: // Library of selection filters
1998 static QValueList<int> aTypes;
1999 if ( aTypes.isEmpty() )
2001 aTypes.append( SMESH::NODE );
2002 aTypes.append( SMESH::EDGE );
2003 aTypes.append( SMESH::FACE );
2004 aTypes.append( SMESH::VOLUME );
2006 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2010 case 6016: // CONTROLS
2020 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2021 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2022 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2023 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2024 if ( !SO->_is_nil() ) {
2025 CORBA::Object_var aObject = SO->GetObject();
2026 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2027 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2028 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2029 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2030 ::Control( theCommandID );
2035 QAD_MessageBox::warn1(GetDesktop(),
2036 tr( "SMESH_WRN_WARNING" ),
2037 tr( "SMESH_BAD_SELECTION" ),
2038 tr( "SMESH_BUT_OK" ) );
2042 QAD_MessageBox::warn1(GetDesktop(),
2043 tr( "SMESH_WRN_WARNING" ),
2044 tr( "NOT_A_VTK_VIEWER" ),
2045 tr( "SMESH_BUT_OK" ) );
2050 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2051 if (Sel->IObjectCount() == 1) {
2052 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2053 if(anIObject->hasEntry())
2054 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2055 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2062 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2063 if (Sel->IObjectCount() == 1) {
2064 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2065 if(anIObject->hasEntry())
2066 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2067 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2072 case 10001: // DISPLAY MODE PREFERENCE
2075 parent->menuBar()->setItemChecked(10001, true);
2076 parent->menuBar()->setItemChecked(10002, false);
2077 parent->menuBar()->setItemChecked(10004, false);
2078 parent->menuBar()->setItemEnabled(10003, true);
2079 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2084 parent->menuBar()->setItemChecked(10002, true);
2085 parent->menuBar()->setItemChecked(10001, false);
2086 parent->menuBar()->setItemChecked(10004, false);
2087 parent->menuBar()->setItemEnabled(10003, true);
2088 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2093 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2094 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2099 parent->menuBar()->setItemChecked(10001, false);
2100 parent->menuBar()->setItemChecked(10004, true);
2101 parent->menuBar()->setItemChecked(10002, false);
2102 parent->menuBar()->setItemEnabled(10003, false);
2103 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2109 myActiveStudy->updateObjBrowser(true);
2113 //=============================================================================
2117 //=============================================================================
2118 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2119 QAD_StudyFrame * studyFrame)
2124 //=============================================================================
2128 //=============================================================================
2129 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2130 QAD_StudyFrame * studyFrame)
2135 //=============================================================================
2139 //=============================================================================
2140 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2141 QAD_StudyFrame * studyFrame)
2146 //=============================================================================
2150 //=============================================================================
2151 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2153 MESSAGE("SMESHGUI::SetSettings.");
2154 SMESHGUI::GetSMESHGUI();
2157 QString DisplayMode = "Shading";
2158 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2159 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2161 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2163 bool Shrink = false;
2164 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2165 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2167 if (DisplayMode == "Wireframe") {
2169 parent->menuBar()->setItemChecked(10004, false);
2170 parent->menuBar()->setItemChecked(10002, false);
2171 parent->menuBar()->setItemChecked(10001, true);
2172 parent->menuBar()->setItemEnabled(10003, true);
2174 else if (DisplayMode == "Nodes") {
2176 parent->menuBar()->setItemChecked(10004, true);
2177 parent->menuBar()->setItemChecked(10002, false);
2178 parent->menuBar()->setItemChecked(10001, false);
2179 parent->menuBar()->setItemEnabled(10003, false);
2182 // default is shading
2183 parent->menuBar()->setItemChecked(10004, false);
2184 parent->menuBar()->setItemChecked(10002, true);
2185 parent->menuBar()->setItemChecked(10001, false);
2186 parent->menuBar()->setItemEnabled(10003, true);
2188 parent->menuBar()->setItemChecked(10003, Shrink);
2190 /* Automatic Update */
2191 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2192 if (AutoUpdate.compare("true") == 0) {
2193 parent->menuBar()->setItemChecked(1001, true);
2194 myAutomaticUpdate = true;
2197 parent->menuBar()->setItemChecked(1001, false);
2198 myAutomaticUpdate = false;
2202 SMESH::UpdateSelectionProp();
2205 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2206 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2211 //=============================================================================
2215 //=============================================================================
2216 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2218 // NRI : Temporary added
2219 // if ( myStudy->GetProperties()->IsLocked() ) {
2220 // theObject = "NothingSelected";
2221 // theContext = "NothingSelected";
2225 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2226 int nbSel = Sel->IObjectCount();
2229 theObject = "NothingSelected";
2230 theContext = "NothingSelected";
2233 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2234 theObject = "Elements";
2236 theObject = ::CheckTypeObject( Sel->firstIObject() );
2240 theObject = ::CheckHomogeneousSelection();
2245 //=============================================================================
2249 //=============================================================================
2250 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2251 const QString& theParent, const QString& theObject)
2253 // get active study frame
2254 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2256 // get parent component which selected object(s) belongs to
2257 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2260 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2261 int nbSel = Sel->IObjectCount();
2266 else if ( nbSel == 1 ) {
2267 if ( parentComp != parent->getActiveComponent() ) {
2268 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2270 int id = popup->idAt( 0 );
2271 if ( id <= QAD_TopLabel_Popup_ID )
2272 popup->removeItemAt( 0 );
2278 // get selected interactive object
2279 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2280 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2281 // find popup menu's TopLabel item
2282 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2283 if ( topItem >= 0 ) {
2284 if ( theParent == "Viewer" ) {
2285 // set bold font for popup menu's TopLabel item (Viewer popup)
2286 QFont fnt = popup->font(); fnt.setBold( TRUE );
2287 popup->removeItem( QAD_TopLabel_Popup_ID );
2288 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2290 else if ( theParent == "ObjectBrowser" ) {
2291 // remove popup menu's TopLabel item (Object Browser popup)
2292 popup->removeItem( QAD_TopLabel_Popup_ID );
2296 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2297 // remove Display/Erase commands
2298 popup->removeItem( QAD_Display_Popup_ID );
2299 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2300 popup->removeItem( QAD_Erase_Popup_ID );
2301 // remove "Unassign ..." command if hyp/algo is not assigned
2302 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2303 popup->removeItem( 1102 );
2305 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2307 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2308 if ( aShapeObject->_is_nil() ) {
2310 popup->removeItem( 701 ); // Compute
2311 popup->removeItem( 705 ); // Edit hypothesis
2312 popup->removeItem( 706 ); // ...
2314 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2315 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2316 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2317 popup->removeItem( 803 ); // EDIT GROUP
2319 SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry());
2320 // if object has actor
2321 if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
2322 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2323 if ( myRenderInter->isVisible( IObject ) ) {
2324 popup->removeItem( QAD_Display_Popup_ID );
2325 popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
2326 popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements #
2327 TVisualObjPtr aVisualObj = ac->GetObject();
2328 int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
2329 int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
2330 int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
2331 QMenuItem* mi = popup->findItem( 1131 );
2332 if ( mi && mi->popup() ) {
2333 int prType = ac->GetRepresentation();
2334 // Display Mode / Wireframe
2335 if(!aNbFaces && !aNbVolumes && !aNbEdges){
2336 mi->popup()->removeItem( 211 );
2338 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2340 // Display Mode / Shading
2341 if(!aNbFaces && !aNbVolumes){
2342 mi->popup()->removeItem( 212 );
2344 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2346 // Display Mode / Points
2347 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2348 // Display Mode / Shrink
2349 bool isShrunk = ac->IsShrunk();
2350 bool isShrunkable = ac->IsShrunkable();
2351 mi->popup()->setItemChecked( 213, isShrunk );
2352 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2355 mi = popup->findItem( 2000 );
2356 if ( mi && mi->popup() ) {
2357 SMESH_Actor::eControl cMode = ac->GetControlMode();
2359 case SMESH_Actor::eLengthEdges:
2360 mi->popup()->setItemChecked( 6001, true ); break;
2361 case SMESH_Actor::eFreeEdges:
2362 mi->popup()->setItemChecked( 6002, true );
2363 mi->popup()->removeItem( 201 );
2365 case SMESH_Actor::eFreeBorders:
2366 mi->popup()->setItemChecked( 6003, true );
2367 mi->popup()->removeItem( 201 );
2369 case SMESH_Actor::eMultiConnection:
2370 mi->popup()->setItemChecked( 6004, true ); break;
2371 case SMESH_Actor::eArea:
2372 mi->popup()->setItemChecked( 6011, true ); break;
2373 case SMESH_Actor::eTaper:
2374 mi->popup()->setItemChecked( 6012, true ); break;
2375 case SMESH_Actor::eAspectRatio:
2376 mi->popup()->setItemChecked( 6013, true ); break;
2377 case SMESH_Actor::eMinimumAngle:
2378 mi->popup()->setItemChecked( 6014, true ); break;
2379 case SMESH_Actor::eWarping:
2380 mi->popup()->setItemChecked( 6015, true ); break;
2381 case SMESH_Actor::eSkew:
2382 mi->popup()->setItemChecked( 6016, true ); break;
2383 case SMESH_Actor::eNone:
2385 mi->popup()->removeItem( 200 );
2386 mi->popup()->removeItem( 201 );
2389 TVisualObjPtr aVisualObj = ac->GetObject();
2391 mi->popup()->removeItem( 6001 );
2392 mi->popup()->removeItem( 6003 );
2393 mi->popup()->removeItem( 6004 );
2396 mi->popup()->removeItem( 6002 );
2397 mi->popup()->removeItem( 6011 );
2398 mi->popup()->removeItem( 6012 );
2399 mi->popup()->removeItem( 6013 );
2400 mi->popup()->removeItem( 6014 );
2401 mi->popup()->removeItem( 6015 );
2402 mi->popup()->removeItem( 6016 );
2404 if(!aNbFaces && !aNbEdges)
2405 popup->removeItem( 2000 ); // Scalar Bar
2409 popup->removeItem( QAD_Erase_Popup_ID );
2410 popup->removeItem( 114 ); // Numbering popup menu
2411 popup->removeItem( 1131 ); // Display mode
2412 popup->removeItem( 1132 ); // Color / size
2413 popup->removeItem( 1133 ); // Transparency
2414 popup->removeItem( 1134 ); // Clipping
2415 popup->removeItem( 2000 ); // Scalar Bar
2419 // object doesn't have actor
2420 CORBA::Object_var anObject = SO->GetObject();
2421 bool bDisplay = false;
2422 if ( !CORBA::is_nil( anObject ) ) {
2423 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2424 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2426 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2427 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2429 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2430 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2434 popup->removeItem( QAD_Display_Popup_ID );
2435 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2437 popup->removeItem( QAD_Erase_Popup_ID );
2438 popup->removeItem( 114 ); // Numbering popup menu
2439 popup->removeItem( 1131 ); // Display mode
2440 popup->removeItem( 1132 ); // Color / size
2441 popup->removeItem( 1133 ); // Transparency
2442 popup->removeItem( 1134 ); // Clipping
2443 popup->removeItem( 2000 ); // Scalar Bar
2446 else if( theObject!="Component" ) {
2447 // another SMESH object
2448 popup->removeItem( QAD_Display_Popup_ID );
2449 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2450 popup->removeItem( QAD_Erase_Popup_ID );
2455 // multiple selection
2456 if ( parentComp != parent->getActiveComponent() ) {
2457 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2459 int id = popup->idAt( 0 );
2460 if ( id <= QAD_TopLabel_Popup_ID )
2461 popup->removeItemAt( 0 );
2465 if ( parentComp.isNull() ) {
2466 // objects from different components are selected
2467 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2468 popup->removeItem( QAD_Display_Popup_ID );
2469 popup->removeItem( QAD_Erase_Popup_ID );
2473 QString type = ::CheckHomogeneousSelection();
2474 if ( type != "Heterogeneous Selection" ) {
2475 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2476 if ( topItem >= 0 ) {
2477 // set bold font for popup menu's TopLabel item
2478 QFont fnt = popup->font(); fnt.setBold( TRUE );
2479 popup->removeItem( QAD_TopLabel_Popup_ID );
2480 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2488 //=============================================================================
2489 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2490 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2492 //=============================================================================
2493 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2496 if(theIO->hasEntry()){
2497 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2498 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2499 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2503 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2505 if (!buffer || !bufferSize)
2507 buffer[0] = (int)VIEW_VTK;
2510 void SMESHGUI::Deactivate()
2512 if ( SMESHGUI::GetSMESHGUI() ) {
2513 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();