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 SetDisplayMode(int theCommandID);
145 void SetDisplayEntity(int theCommandID);
147 void Control( int theCommandID );
149 void SetDisplaySettings();
153 //=============================================================
154 void ImportMeshesFromFile(QAD_Desktop * parent,
155 SMESH::SMESH_Gen_ptr theComponentMesh,
161 if(theCommandID == 113){
162 filter = QObject::tr("MED files (*.med)");
163 }else if (theCommandID == 112){
164 filter = QObject::tr("IDEAS files (*.unv)");
165 }else if (theCommandID == 111){
166 filter = QObject::tr("DAT files (*.dat)");
168 QString filename = QAD_FileDlg::getFileName(parent,
171 QObject::tr("Import mesh"),
173 if(!filename.isEmpty()) {
175 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
178 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
179 switch ( theCommandID ) {
182 aMeshes->length( 1 );
183 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
188 SMESH::DriverMED_ReadStatus res;
189 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
190 if ( res != SMESH::DRS_OK ) {
192 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
193 QObject::tr("SMESH_WRN_WARNING"),
194 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
195 QObject::tr("SMESH_BUT_OK"));
196 aMeshes->length( 0 );
203 bool isEmpty = false;
204 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
205 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
206 if ( !aMeshSO->_is_nil() ) {
207 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
208 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
209 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
210 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
211 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
218 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
219 QObject::tr("SMESH_WRN_WARNING"),
220 QObject::tr("SMESH_DRS_EMPTY"),
221 QObject::tr("SMESH_BUT_OK"));
225 catch (const SALOME::SALOME_Exception& S_ex){
227 QtCatchCorbaException(S_ex);
234 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
236 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
237 if(aSel->IObjectCount()){
238 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
239 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
240 if ( !aMesh->_is_nil() ) {
241 QString aFilter, aTitle = QObject::tr("Export mesh");
242 switch ( theCommandID ) {
244 aFilter = QObject::tr("MED files (*.med)");
247 aFilter = QObject::tr("DAT files (*.dat)");
250 if(aMesh->NbPyramids()){
251 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
252 QObject::tr("SMESH_WRN_WARNING"),
253 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
254 QObject::tr("SMESH_BUT_YES"),
255 QObject::tr("SMESH_BUT_NO"),
260 aFilter = QObject::tr("IDEAS files (*.unv)");
266 QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
267 if ( !aFilename.isEmpty() ) {
268 // Check whether the file already exists and delete it if yes
269 QFile aFile( aFilename );
270 if ( aFile.exists() )
273 switch ( theCommandID ) {
275 aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
278 aMesh->ExportDAT( aFilename.latin1() );
281 aMesh->ExportUNV( aFilename.latin1() );
291 inline void InverseEntityMode(unsigned int& theOutputMode,
292 unsigned int theMode)
294 bool anIsNotPresent = ~theOutputMode & theMode;
296 theOutputMode |= theMode;
298 theOutputMode &= ~theMode;
301 void SetDisplayEntity(int theCommandID){
302 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
303 if(Sel->IObjectCount() >= 1){
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 unsigned int aMode = anActor->GetEntityMode();
310 switch(theCommandID){
312 InverseEntityMode(aMode,SMESH_Actor::eEdges);
315 InverseEntityMode(aMode,SMESH_Actor::eFaces);
318 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
321 aMode = SMESH_Actor::eAllEntity;
325 anActor->SetEntityMode(aMode);
332 void SetDisplayMode(int theCommandID){
333 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
334 if(Sel->IObjectCount() >= 1){
335 switch(theCommandID){
337 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
338 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
342 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
343 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
346 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
347 for(; It.More(); It.Next()){
348 Handle(SALOME_InteractiveObject) IObject = It.Value();
349 if(IObject->hasEntry()){
350 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
351 switch(theCommandID){
353 anActor->SetRepresentation(SMESH_Actor::eEdge);
356 anActor->SetRepresentation(SMESH_Actor::eSurface);
359 if(anActor->IsShrunk())
362 anActor->SetShrink();
365 anActor->SetRepresentation(SMESH_Actor::ePoint);
369 anActor->GetSufaceColor(color[0], color[1], color[2]);
370 int c0 = int (color[0] * 255);
371 int c1 = int (color[1] * 255);
372 int c2 = int (color[2] * 255);
373 QColor c(c0, c1, c2);
376 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
377 c0 = int (edgecolor[0] * 255);
378 c1 = int (edgecolor[1] * 255);
379 c2 = int (edgecolor[2] * 255);
380 QColor e(c0, c1, c2);
382 float backfacecolor[3];
383 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
384 c0 = int (backfacecolor[0] * 255);
385 c1 = int (backfacecolor[1] * 255);
386 c2 = int (backfacecolor[2] * 255);
387 QColor b(c0, c1, c2);
390 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
391 c0 = int (nodecolor[0] * 255);
392 c1 = int (nodecolor[1] * 255);
393 c2 = int (nodecolor[2] * 255);
394 QColor n(c0, c1, c2);
396 int Edgewidth = (int)anActor->GetLineWidth();
399 int intValue = int(anActor->GetNodeSize());
400 float Shrink = anActor->GetShrinkFactor();
402 SMESHGUI_Preferences_ColorDlg *aDlg =
403 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
404 aDlg->SetColor(1, c);
405 aDlg->SetColor(2, e);
406 aDlg->SetColor(3, n);
407 aDlg->SetColor(4, b);
408 aDlg->SetIntValue(1, Edgewidth);
409 aDlg->SetIntValue(2, intValue);
410 aDlg->SetIntValue(3, int(Shrink*100.));
412 QColor color = aDlg->GetColor(1);
413 QColor edgecolor = aDlg->GetColor(2);
414 QColor nodecolor = aDlg->GetColor(3);
415 QColor backfacecolor = aDlg->GetColor(4);
416 /* actor color and backface color */
417 anActor->SetSufaceColor(float (color.red()) / 255.,
418 float (color.green()) / 255.,
419 float (color.blue()) / 255.);
420 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
421 float (backfacecolor.green()) / 255.,
422 float (backfacecolor.blue()) / 255.);
425 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
426 float (edgecolor.green()) / 255.,
427 float (edgecolor.blue()) / 255.);
429 /* Shrink factor and size edges */
430 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
431 anActor->SetLineWidth(aDlg->GetIntValue(1));
433 /* Nodes color and size */
434 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
435 float (nodecolor.green()) / 255.,
436 float (nodecolor.blue()) / 255.);
437 anActor->SetNodeSize(aDlg->GetIntValue(2));
446 SMESH::RepaintCurrentView();
451 void SetDisplaySettings()
453 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
454 SMESHGUI_Preferences_ColorDlg *aDlg =
455 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
458 QString SCr, SCg, SCb;
459 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
460 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
461 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
462 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
463 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
464 else color = QColor(0, 170, 255);
465 aDlg->SetColor(1, color);
467 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
468 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
469 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
470 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
471 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
472 else color = QColor(0, 170, 255);
473 aDlg->SetColor(2, color);
475 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
476 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
477 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
478 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
479 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
480 else color = Qt::red;
481 aDlg->SetColor(3, color);
483 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
484 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
485 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
486 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
487 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
488 else color = Qt::blue;
489 aDlg->SetColor(4, color);
491 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
492 if (intValue.isEmpty()) intValue = "1";
493 aDlg->SetIntValue(1, intValue.toInt());
494 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
495 if (intValue.isEmpty()) intValue = "3";
496 aDlg->SetIntValue(2, intValue.toInt());
497 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
498 if (intValue.isEmpty()) intValue = "75";
499 aDlg->SetIntValue(3, intValue.toInt());
502 QColor colorFill = aDlg->GetColor(1);
503 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
504 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
505 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
507 QColor colorOutline = aDlg->GetColor(2);
508 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
509 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
510 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
512 QColor colorNode = aDlg->GetColor(3);
513 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
514 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
515 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
517 QColor colorBackFace = aDlg->GetColor(4);
518 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
519 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
520 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
522 int width = aDlg->GetIntValue(1);
523 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
525 int nodes_size = aDlg->GetIntValue(2);
526 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
528 int shrink_coeff = aDlg->GetIntValue(3);
529 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
536 void Control( int theCommandID )
538 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
540 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
543 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
544 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
545 switch ( theCommandID ){
547 aTitle = QObject::tr( "LENGTH_EDGES" );
548 aControl = SMESH_Actor::eLength;
551 aTitle = QObject::tr( "LENGTH2D_EDGES" );
552 aControl = SMESH_Actor::eLength2D;
555 aTitle = QObject::tr( "FREE_EDGES" );
556 aControl = SMESH_Actor::eFreeEdges;
559 aTitle = QObject::tr( "FREE_BORDERS" );
560 aControl = SMESH_Actor::eFreeBorders;
563 aTitle = QObject::tr( "MULTI_BORDERS" );
564 aControl = SMESH_Actor::eMultiConnection;
567 aTitle = QObject::tr( "AREA_ELEMENTS" );
568 aControl = SMESH_Actor::eArea;
571 aTitle = QObject::tr( "TAPER_ELEMENTS" );
572 aControl = SMESH_Actor::eTaper;
575 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
576 aControl = SMESH_Actor::eAspectRatio;
579 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
580 aControl = SMESH_Actor::eAspectRatio3D;
583 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
584 aControl = SMESH_Actor::eMinimumAngle;
587 aTitle = QObject::tr( "WARP_ELEMENTS" );
588 aControl = SMESH_Actor::eWarping;
591 aTitle = QObject::tr( "SKEW_ELEMENTS" );
592 aControl = SMESH_Actor::eSkew;
595 anActor->SetControlMode(aControl);
596 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
603 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
604 MeshObjectType theType,
605 const QString theInTypeName,
606 QString & theOutTypeName)
608 SMESH_TypeFilter aTypeFilter( theType );
609 if ( aTypeFilter.IsOk( theIO )) {
610 theOutTypeName = theInTypeName;
617 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
619 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
620 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
621 if (!aSObj->_is_nil()) {
622 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
623 CORBA::String_var anID = aSComp->GetID();
624 if (!strcmp(anID.in(),theIO->getEntry()))
630 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
631 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
632 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
633 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
634 CheckOIType ( theIO, GROUP, "Group", aTypeName )
642 QString CheckHomogeneousSelection()
644 QAD_Study* aStudy = SMESH::GetActiveStudy();
645 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
648 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
649 for (; Itinit.More(); Itinit.Next())
651 List.Append(Itinit.Value());
654 QString RefType = CheckTypeObject(aSel->firstIObject());
655 SALOME_ListIteratorOfListIO It(List);
656 for (; It.More(); It.Next())
658 Handle(SALOME_InteractiveObject) IObject = It.Value();
659 QString Type = CheckTypeObject(IObject);
660 if (Type.compare(RefType) != 0)
661 return "Heterogeneous Selection";
664 aSel->ClearIObjects();
665 SALOME_ListIteratorOfListIO It1(List);
666 for (; It1.More(); It1.Next())
668 int res = aSel->AddIObject(It1.Value());
670 aStudy->highlight(It1.Value(), false);
672 aStudy->highlight(It1.Value(), true);
679 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
680 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
681 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
682 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
683 QObject::tr("ERR_ERROR"),
684 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
685 QObject::tr("BUT_OK") );
688 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
689 if (QAD_MessageBox::warn2
690 (QAD_Application::getDesktop(),
691 QObject::tr("SMESH_WRN_WARNING"),
692 QObject::tr("SMESH_REALLY_DELETE"),
693 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
696 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
697 int nbSf = anActiveStudy->getStudyFramesCount();
699 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
700 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
701 SALOMEDS::GenericAttribute_var anAttr;
702 SALOMEDS::AttributeIOR_var anIOR;
704 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
705 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
706 for(; It.More(); It.Next()){
707 Handle(SALOME_InteractiveObject) IObject = It.Value();
708 if(IObject->hasEntry()){
709 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
711 /* Erase child graphical objects */
712 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
713 for(; it->More(); it->Next()){
714 SALOMEDS::SObject_var CSO = it->Value();
715 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
716 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
718 for(int i = 0; i < nbSf; i++){
719 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
720 CORBA::String_var anEntry = CSO->GetID();
721 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
722 SMESH::RemoveActor(sf,anActor);
728 /* Erase main graphical object */
729 for(int i = 0; i < nbSf; i++){
730 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
731 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
732 SMESH::RemoveActor(sf,anActor);
736 // Remove object(s) from data structures
737 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
739 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
740 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
742 if ( !aGroup->_is_nil() ) { // DELETE GROUP
743 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
744 aMesh->RemoveGroup( aGroup );
746 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
747 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
748 aMesh->RemoveSubMesh( aSubMesh );
750 else {// default action: remove SObject from the study
751 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
752 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
754 aStudyBuilder->RemoveObjectWithChildren( obj );
759 } /* IObject->hasEntry() */
762 /* Clear any previous selection */
763 Sel->ClearIObjects();
764 anActiveStudy->updateObjBrowser();
770 //=============================================================================
774 //=============================================================================
775 class CustomItem : public QCustomMenuItem
778 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
781 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
784 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
785 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
786 p->setFont( myFont );
787 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
793 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
796 bool fullSpan() const
806 //=============================================================================
810 //=============================================================================
811 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
812 SALOMEGUI( theName, theParent )
814 myActiveDialogBox = 0 ;
817 SMESH::GetSMESHGen();
818 SMESH::GetFilterManager();
821 /* load resources for all available meshers */
822 SMESH::InitAvailableHypotheses();
825 //=============================================================================
829 //=============================================================================
830 SMESHGUI::~SMESHGUI()
832 SMESH::GetFilterManager()->Destroy();
835 //=============================================================================
839 //=============================================================================
840 SMESHGUI* SMESHGUI::GetSMESHGUI()
842 static SMESHGUI aSMESHGUI;
843 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
844 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
846 /* Automatic Update flag */
847 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
854 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
855 return SMESHGUI::GetSMESHGUI();
859 //=============================================================================
863 //=============================================================================
864 void SMESHGUI::SetState(int aState)
866 this->myState = aState;
870 //=============================================================================
874 //=============================================================================
875 void SMESHGUI::ResetState()
881 //=============================================================================
885 //=============================================================================
886 void SMESHGUI::EmitSignalDeactivateDialog()
888 emit this->SignalDeactivateActiveDialog();
892 //=============================================================================
896 //=============================================================================
897 void SMESHGUI::EmitSignalStudyFrameChanged()
899 emit this->SignalStudyFrameChanged();
903 //=============================================================================
907 //=============================================================================
908 void SMESHGUI::EmitSignalCloseAllDialogs()
910 emit SignalCloseAllDialogs();
914 //=============================================================================
918 //=============================================================================
919 QDialog *SMESHGUI::GetActiveDialogBox()
921 return this->myActiveDialogBox;
924 //=============================================================================
928 //=============================================================================
929 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
931 this->myActiveDialogBox = (QDialog *) aDlg;
935 //=============================================================================
939 //=============================================================================
940 QAD_Study *SMESHGUI::GetActiveStudy()
942 return this->myActiveStudy;
945 //=============================================================================
949 //=============================================================================
950 QAD_Desktop *SMESHGUI::GetDesktop()
952 return QAD_Application::getDesktop();
955 //=============================================================================
959 //=============================================================================
960 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
962 MESSAGE("SMESHGUI::activeStudyChanged init.");
963 QAD_Study* prevStudy = myActiveStudy;
964 /* Create or retrieve an object SMESHGUI */
965 MESSAGE("Active study changed : prev study =" << prevStudy);
966 SMESHGUI::GetSMESHGUI();
967 EmitSignalStudyFrameChanged();
968 MESSAGE("Active study changed : active study =" << myActiveStudy);
969 if ( prevStudy != myActiveStudy ) {
970 EmitSignalCloseAllDialogs();
971 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
973 SMESH::UpdateSelectionProp();
975 MESSAGE("SMESHGUI::activeStudyChanged done.");
979 //=============================================================================
983 //=============================================================================
984 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
986 /* Here the position is on the bottom right corner - 10 */
987 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
989 QAD_Desktop *PP = QAD_Application::getDesktop();
990 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
991 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
995 //=============================================================================
999 //=============================================================================
1000 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
1001 return theStudy->GetProperties()->IsLocked();
1004 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
1005 if (isStudyLocked(theStudy)) {
1006 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
1007 QObject::tr("WRN_WARNING"),
1008 QObject::tr("WRN_STUDY_LOCKED"),
1009 QObject::tr("BUT_OK") );
1015 //=======================================================================
1016 //function : CheckActiveStudyLocked
1018 //=======================================================================
1020 bool SMESHGUI::ActiveStudyLocked()
1022 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1023 return checkLock( aStudy );
1026 //=============================================================================
1030 //=============================================================================
1031 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
1033 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1035 switch (theCommandID) {
1037 if(checkLock(aStudy)) break;
1045 if(checkLock(aStudy)) break;
1046 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1050 case 122: // EXPORT MED
1054 ::ExportMeshToFile(parent, theCommandID);
1058 case 200: // SCALAR BAR
1060 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1061 if( Sel && Sel->IObjectCount() ) {
1062 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1063 if( anIO->hasEntry() ) {
1064 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1065 anActor->SetControlMode( SMESH_Actor::eNone );
1073 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1074 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1078 case 1134: // Clipping
1079 case 1133: // Tranparency
1080 case 1132: // Colors / Size
1087 ::SetDisplayMode(theCommandID);
1093 case 219: // Volumes
1094 case 220: // All Entity
1095 ::SetDisplayEntity(theCommandID);
1100 if(checkLock(aStudy)) break;
1101 SMESH::UpdateView();
1106 case 301: // DISPLAY
1107 case 302: // DISPLAY ONLY
1109 SMESH::EDisplaing anAction;
1110 switch(theCommandID){
1111 case 300: anAction = SMESH::eErase; break;
1112 case 301: anAction = SMESH::eDisplay; break;
1113 case 302: anAction = SMESH::eDisplayOnly; break;
1116 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1117 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1118 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1119 for (; It.More(); It.Next()) {
1120 Handle(SALOME_InteractiveObject) IOS = It.Value();
1121 if (IOS->hasEntry()) {
1122 SMESH::UpdateView(anAction,IOS->getEntry());
1126 Sel->ClearIObjects();
1132 if(checkLock(aStudy)) break;
1133 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1134 EmitSignalDeactivateDialog();
1135 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1136 new SMESHGUI_NodesDlg(parent, "", Sel);
1139 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1140 tr("SMESH_WRN_WARNING"),
1141 tr("SMESH_WRN_VIEWER_VTK"),
1142 tr("SMESH_BUT_OK"));
1147 case 2151: // FILTER
1149 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1151 EmitSignalDeactivateDialog();
1152 new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1157 case 406: // MOVE NODE
1159 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1161 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1162 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1166 if(checkLock(aStudy)) break;
1167 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1168 new SMESHGUI_MoveNodesDlg( parent, Sel );
1172 case 701: // COMPUTE MESH
1174 if(checkLock(aStudy)) break;
1175 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1176 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1177 int nbSel = Sel->IObjectCount();
1182 SMESH::SMESH_Mesh_var aMesh;
1183 SMESH::SMESH_subMesh_var aSubMesh;
1184 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1185 if (IObject->hasEntry()){
1186 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1187 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1188 if ( aShapeObject->_is_nil() ) {
1192 if(!aMeshSObj->_is_nil()) {
1193 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1194 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1196 if (!aMesh->_is_nil()){
1197 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1198 if (!refShapeObject->_is_nil()) {
1199 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1200 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1201 tr("SMESH_WRN_WARNING"),
1202 tr("SMESH_WRN_MISSING_PARAMETERS"),
1203 tr("SMESH_BUT_OK"));
1207 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1208 SMESH::ModifiedMesh(aMeshSObj,true);
1209 // TO Do : change icon of all submeshes
1211 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1212 tr("SMESH_WRN_WARNING"),
1213 tr("SMESH_WRN_COMPUTE_FAILED"),
1214 tr("SMESH_BUT_OK"));
1216 catch(const SALOME::SALOME_Exception & S_ex){
1217 QtCatchCorbaException(S_ex);
1220 }else if(!aSubMesh->_is_nil()){
1221 aMesh = aSubMesh->GetFather();
1222 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1223 if(!refShapeObject->_is_nil()){
1224 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1226 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1227 tr("SMESH_WRN_WARNING"),
1228 tr("SMESH_WRN_MISSING_PARAMETERS"),
1229 tr("SMESH_BUT_OK"));
1233 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1234 SMESH::ModifiedMesh(aMeshSObj,true);
1235 // TO Do : change icon of all submeshes
1237 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1238 tr("SMESH_WRN_WARNING"),
1239 tr("SMESH_WRN_COMPUTE_FAILED"),
1240 tr("SMESH_BUT_OK"));
1241 }catch(const SALOME::SALOME_Exception & S_ex){
1242 QtCatchCorbaException(S_ex);
1248 CORBA::Long anId = aStudy->StudyId();
1249 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1250 if(myAutomaticUpdate && aVisualObj){
1251 aVisualObj->Update();
1252 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1254 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1256 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1262 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1263 tr("SMESH_WRN_WARNING"),
1264 tr("SMESH_WRN_VIEWER_VTK"),
1265 tr("SMESH_BUT_OK"));
1270 case 702: // ADD SUB MESH
1272 if(checkLock(aStudy)) break;
1273 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1274 EmitSignalDeactivateDialog();
1275 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1276 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1279 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1280 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1281 tr("SMESH_BUT_OK"));
1286 case 703: // INIT MESH
1288 if(checkLock(aStudy)) break;
1289 EmitSignalDeactivateDialog();
1290 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1291 new SMESHGUI_InitMeshDlg(parent, "", Sel);
1295 case 704: // EDIT Hypothesis
1297 if(checkLock(aStudy)) break;
1298 EmitSignalDeactivateDialog();
1299 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1300 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1304 case 705: // EDIT Global Hypothesis
1306 if(checkLock(aStudy)) break;
1307 EmitSignalDeactivateDialog();
1308 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1309 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1313 case 706: // EDIT Local Hypothesis
1315 if(checkLock(aStudy)) break;
1316 EmitSignalDeactivateDialog();
1317 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1318 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1322 case 407: // DIAGONAL INVERSION
1323 case 408: // Delete diagonal
1325 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1327 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1328 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1332 if ( checkLock( aStudy ) )
1335 SALOME_Selection *aSel =
1336 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1337 /*Standard_Boolean aRes;
1338 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1339 if ( aMesh->_is_nil() )
1341 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1342 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1346 EmitSignalDeactivateDialog();
1347 if ( theCommandID == 407 )
1348 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1350 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1353 case 409: // Change orientation
1354 case 410: // Union of triangles
1355 case 411: // Cutting of quadrangles
1357 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1359 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1360 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1364 if ( checkLock( aStudy ) )
1367 SALOME_Selection *aSel =
1368 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1370 EmitSignalDeactivateDialog();
1371 SMESHGUI_MultiEditDlg* aDlg;
1372 if ( theCommandID == 409 )
1373 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1374 else if ( theCommandID == 410 )
1375 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1377 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1380 DefineDlgPosition( aDlg, x, y );
1385 case 412: // Smoothing
1387 if(checkLock(aStudy)) break;
1388 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1389 EmitSignalDeactivateDialog();
1390 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1391 new SMESHGUI_SmoothingDlg(parent, "", Sel);
1394 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1395 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1396 tr("SMESH_BUT_OK"));
1400 case 413: // Extrusion
1402 if(checkLock(aStudy)) break;
1403 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1404 EmitSignalDeactivateDialog();
1405 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1406 new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1409 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1411 tr("SMESH_BUT_OK"));
1415 case 414: // Revolution
1417 if(checkLock(aStudy)) break;
1418 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1419 EmitSignalDeactivateDialog();
1420 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1421 new SMESHGUI_RevolutionDlg(parent, "", Sel);
1424 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1425 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1426 tr("SMESH_BUT_OK"));
1430 case 415: // Pattern mapping
1432 if ( checkLock( aStudy ) )
1434 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1436 EmitSignalDeactivateDialog();
1437 SALOME_Selection *Sel = SALOME_Selection::Selection(
1438 myActiveStudy->getSelection() );
1439 new SMESHGUI_MeshPatternDlg( parent, Sel );
1442 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1443 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1444 tr("SMESH_BUT_OK"));
1448 case 801: // CREATE GROUP
1450 if(checkLock(aStudy)) break;
1451 EmitSignalDeactivateDialog();
1452 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1453 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1454 int nbSel = Sel->IObjectCount();
1456 // check if mesh is selected
1457 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1459 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1464 case 802: // CONSTRUCT GROUP
1466 if(checkLock(aStudy)) break;
1467 EmitSignalDeactivateDialog();
1468 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1469 int nbSel = Sel->IObjectCount();
1471 // check if submesh is selected
1472 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1473 if (IObject->hasEntry()) {
1474 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1475 if(!aSObj->_is_nil()) {
1476 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1477 if (!aSubMesh->_is_nil()) {
1479 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1480 // get submesh elements list by types
1481 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1482 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1483 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1484 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1485 // create group for each type o elements
1486 QString aName = IObject->getName();
1487 if (aNodes->length() > 0) {
1488 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
1489 aGroup->Add(aNodes.inout());
1491 if (aEdges->length() > 0) {
1492 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
1493 aGroup->Add(aEdges.inout());
1495 if (aFaces->length() > 0) {
1496 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
1497 aGroup->Add(aFaces.inout());
1499 if (aVolumes->length() > 0) {
1500 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
1501 aGroup->Add(aVolumes.inout());
1503 myActiveStudy->updateObjBrowser(true);
1504 }catch(const SALOME::SALOME_Exception & S_ex){
1505 QtCatchCorbaException(S_ex);
1514 case 803: // EDIT GROUP
1516 if(checkLock(aStudy)) break;
1517 EmitSignalDeactivateDialog();
1518 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1519 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1520 SALOME_ListIteratorOfListIO It (IOs);
1521 int nbSelectedGroups = 0;
1522 for ( ; It.More(); It.Next() )
1524 SMESH::SMESH_Group_var aGroup =
1525 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1526 if (!aGroup->_is_nil()) {
1528 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1532 if (nbSelectedGroups == 0)
1534 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1540 case 804: // Add elements to group
1542 if(checkLock(aStudy)) break;
1543 if (myState == 800) {
1544 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1545 if (aDlg) aDlg->onAdd();
1550 case 805: // Remove elements from group
1552 if(checkLock(aStudy)) break;
1553 if (myState == 800) {
1554 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1555 if (aDlg) aDlg->onRemove();
1560 case 810: // Union Groups
1561 case 811: // Intersect groups
1562 case 812: // Cut groups
1564 if ( checkLock( aStudy ) )
1567 EmitSignalDeactivateDialog();
1568 SALOME_Selection *Sel = SALOME_Selection::Selection(
1569 myActiveStudy->getSelection() );
1572 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1573 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1574 else aMode = SMESHGUI_GroupOpDlg::CUT;
1576 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1580 case 813: // Delete groups with their contents
1582 if ( checkLock( aStudy ) )
1585 EmitSignalDeactivateDialog();
1586 SALOME_Selection *Sel = SALOME_Selection::Selection(
1587 myActiveStudy->getSelection() );
1589 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1593 case 900: // MESH INFOS
1595 EmitSignalDeactivateDialog();
1596 SALOME_Selection *Sel =
1597 SALOME_Selection::Selection(myActiveStudy->getSelection());
1598 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1599 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1600 SALOME_ListIteratorOfListIO It (IOs);
1601 for ( ; It.More(); It.Next() ) {
1602 Sel->ClearIObjects();
1603 Sel->AddIObject( It.Value() );
1604 new SMESHGUI_MeshInfosDlg(parent, "", false);
1606 // restore selection
1607 Sel->ClearIObjects();
1608 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1609 Sel->AddIObject( It.Value() );
1612 new SMESHGUI_MeshInfosDlg(parent, "", false);
1616 case 902: // STANDARD MESH INFOS
1618 EmitSignalDeactivateDialog();
1619 SALOME_Selection *Sel =
1620 SALOME_Selection::Selection(myActiveStudy->getSelection());
1621 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1622 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1623 SALOME_ListIteratorOfListIO It (IOs);
1624 for ( ; It.More(); It.Next() ) {
1625 Sel->ClearIObjects();
1626 Sel->AddIObject( It.Value() );
1627 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1629 // restore selection
1630 Sel->ClearIObjects();
1631 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1632 Sel->AddIObject( It.Value() );
1635 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1639 case 1001: // AUTOMATIC UPDATE PREFERENCES
1641 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1642 if (parent->menuBar()->isItemChecked(1001)) {
1643 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1644 myAutomaticUpdate = true;
1647 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1648 myAutomaticUpdate = false;
1653 case 1003: // MESH PREFERENCES
1655 ::SetDisplaySettings();
1661 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1667 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1673 SMESHGUI_Preferences_SelectionDlg* aDlg =
1674 new SMESHGUI_Preferences_SelectionDlg(parent);
1677 QString SCr, SCg, SCb;
1678 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1679 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1680 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1681 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1682 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1683 else aColor = Qt::cyan;
1684 aDlg->SetColor(1, aColor);
1686 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1687 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1688 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1689 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1690 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1691 else aColor = Qt::yellow;
1692 aDlg->SetColor(2, aColor);
1694 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1695 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1696 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1697 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1698 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1699 else aColor = Qt::white;
1700 aDlg->SetColor(3, aColor);
1702 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1703 if (SW1.isEmpty()) SW1 = "5";
1704 aDlg->SetWidth(1, SW1.toInt());
1706 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1707 if (SW2.isEmpty()) SW2 = "5";
1708 aDlg->SetWidth(2, SW2.toInt());
1710 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1711 if (SP1.isEmpty()) SP1 = "0.025";
1712 aDlg->SetPrecision(1, SP1.toDouble());
1714 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1715 if (SP2.isEmpty()) SP2 = "0.001";
1716 aDlg->SetPrecision(2, SP2.toDouble());
1719 QColor aPreColor = aDlg->GetColor(1);
1720 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1721 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1722 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1724 QColor aSelColor = aDlg->GetColor(2);
1725 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1726 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1727 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1729 QColor aHiColor = aDlg->GetColor(3);
1730 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1731 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1732 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1734 int aPreWidth = aDlg->GetWidth(1);
1735 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1736 int aSelWidth = aDlg->GetWidth(2);
1737 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1739 double aTolNodes = aDlg->GetPrecision(1);
1740 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1741 double aTolItems = aDlg->GetPrecision(2);
1742 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1744 // update current study settings
1745 SMESH::UpdateSelectionProp();
1747 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1748 if (studyFrame->getTypeView() == VIEW_VTK) {
1749 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1750 // update VTK viewer properties
1751 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1753 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1754 aSelColor.blue()/255., aSelWidth);
1755 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1756 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1758 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1759 aPreColor.blue()/255., aPreWidth);
1762 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1763 vtkActorCollection *aCollection = aRenderer->GetActors();
1764 aCollection->InitTraversal();
1765 while(vtkActor *anAct = aCollection->GetNextActor()){
1766 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1767 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1768 aHiColor.blue()/255.);
1769 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1770 aPreColor.blue()/255.);
1779 case 1100: // EDIT HYPOTHESIS
1781 if(checkLock(aStudy)) break;
1782 SALOME_Selection *Sel =
1783 SALOME_Selection::Selection(myActiveStudy->getSelection());
1784 int nbSel = Sel->IObjectCount();
1787 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1789 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1790 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1791 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1792 if ( !Hyp->_is_nil() )
1794 char* sName = Hyp->GetName();
1795 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1798 aCreator->EditHypothesis(Hyp);
1809 case 1101: // RENAME
1811 if ( checkLock( aStudy ) )
1814 SALOME_Selection *Sel =
1815 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1817 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1818 for ( ; It.More(); It.Next() )
1820 Handle(SALOME_InteractiveObject) IObject = It.Value();
1821 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1822 SALOMEDS::GenericAttribute_var anAttr;
1823 SALOMEDS::AttributeName_var aName;
1824 if ( !obj->_is_nil() )
1826 if ( obj->FindAttribute(anAttr, "AttributeName") )
1828 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1829 QString newName = QString(aName->Value());
1830 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1831 if ( !newName.isEmpty() )
1833 myActiveStudy->renameIObject( IObject, newName );
1835 // if current object is group update group's name
1836 SMESH::SMESH_GroupBase_var aGroup =
1837 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1838 if (!aGroup->_is_nil() )
1839 aGroup->SetName( newName.latin1() );
1847 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1849 if(checkLock(aStudy)) break;
1851 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1852 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1853 for (int i = 0; It.More(); It.Next(), i++) {
1854 Handle(SALOME_InteractiveObject) IObject = It.Value();
1855 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1857 Sel->ClearIObjects();
1858 myActiveStudy->updateObjBrowser(true);
1862 case 401: // GEOM::EDGE
1863 case 4021: // TRIANGLE
1868 if(checkLock(aStudy)) break;
1869 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1870 EmitSignalDeactivateDialog();
1871 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1872 SMDSAbs_ElementType type = SMDSAbs_Edge;
1874 switch (theCommandID) {
1875 case 4021: // TRIANGLE
1876 type = SMDSAbs_Face; nbNodes = 3; break;
1878 type = SMDSAbs_Face; nbNodes = 4; break;
1880 type = SMDSAbs_Volume; nbNodes = 4; break;
1882 type = SMDSAbs_Volume; nbNodes = 8; break;
1885 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1888 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1889 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1890 tr("SMESH_BUT_OK"));
1895 case 4041: // REMOVES NODES
1897 if(checkLock(aStudy)) break;
1898 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1899 EmitSignalDeactivateDialog();
1900 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1901 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1904 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1905 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1906 tr("SMESH_BUT_OK"));
1910 case 4042: // REMOVES ELEMENTS
1912 if(checkLock(aStudy)) break;
1913 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1914 EmitSignalDeactivateDialog();
1915 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1916 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1920 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1921 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1922 tr("SMESH_BUT_OK"));
1926 case 4051: // RENUMBERING NODES
1928 if(checkLock(aStudy)) break;
1929 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1930 EmitSignalDeactivateDialog();
1931 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1932 new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1936 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1937 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1938 tr("SMESH_BUT_OK"));
1942 case 4052: // RENUMBERING ELEMENTS
1944 if(checkLock(aStudy)) break;
1945 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1946 EmitSignalDeactivateDialog();
1947 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1948 new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
1952 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1953 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1954 tr("SMESH_BUT_OK"));
1958 case 4061: // TRANSLATION
1960 if(checkLock(aStudy)) break;
1961 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1962 EmitSignalDeactivateDialog();
1963 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1964 new SMESHGUI_TranslationDlg(parent, "", Sel);
1967 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1968 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1969 tr("SMESH_BUT_OK"));
1973 case 4062: // ROTATION
1975 if(checkLock(aStudy)) break;
1976 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1977 EmitSignalDeactivateDialog();
1978 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1979 new SMESHGUI_RotationDlg(parent, "", Sel);
1982 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1983 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1984 tr("SMESH_BUT_OK"));
1988 case 4063: // SYMMETRY
1990 if(checkLock(aStudy)) break;
1991 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1992 EmitSignalDeactivateDialog();
1993 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1994 new SMESHGUI_SymmetryDlg(parent, "", Sel);
1997 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1998 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1999 tr("SMESH_BUT_OK"));
2003 case 4064: // SEWING
2005 if(checkLock(aStudy)) break;
2006 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2007 EmitSignalDeactivateDialog();
2008 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2009 new SMESHGUI_SewingDlg(parent, "", Sel);
2012 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2013 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2014 tr("SMESH_BUT_OK"));
2018 case 4065: // MERGE NODES
2020 if(checkLock(aStudy)) break;
2021 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2022 EmitSignalDeactivateDialog();
2023 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2024 new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2027 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2028 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029 tr("SMESH_BUT_OK"));
2035 case 5000: // HYPOTHESIS
2037 if(checkLock(aStudy)) break;
2038 EmitSignalDeactivateDialog();
2039 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2044 if(checkLock(aStudy)) break;
2045 EmitSignalDeactivateDialog();
2046 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2050 case 5105: // Library of selection filters
2052 static QValueList<int> aTypes;
2053 if ( aTypes.isEmpty() )
2055 aTypes.append( SMESH::NODE );
2056 aTypes.append( SMESH::EDGE );
2057 aTypes.append( SMESH::FACE );
2058 aTypes.append( SMESH::VOLUME );
2060 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2064 case 6017: // CONTROLS
2076 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2077 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2078 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2079 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2080 if ( !SO->_is_nil() ) {
2081 CORBA::Object_var aObject = SO->GetObject();
2082 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2083 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2084 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2085 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2086 ::Control( theCommandID );
2091 QAD_MessageBox::warn1(GetDesktop(),
2092 tr( "SMESH_WRN_WARNING" ),
2093 tr( "SMESH_BAD_SELECTION" ),
2094 tr( "SMESH_BUT_OK" ) );
2098 QAD_MessageBox::warn1(GetDesktop(),
2099 tr( "SMESH_WRN_WARNING" ),
2100 tr( "NOT_A_VTK_VIEWER" ),
2101 tr( "SMESH_BUT_OK" ) );
2106 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2107 if (Sel->IObjectCount() == 1) {
2108 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2109 if(anIObject->hasEntry())
2110 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2111 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2118 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2119 if (Sel->IObjectCount() == 1) {
2120 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2121 if(anIObject->hasEntry())
2122 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2123 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2128 case 10001: // DISPLAY MODE PREFERENCE
2131 parent->menuBar()->setItemChecked(10001, true);
2132 parent->menuBar()->setItemChecked(10002, false);
2133 parent->menuBar()->setItemChecked(10004, false);
2134 parent->menuBar()->setItemEnabled(10003, true);
2135 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2140 parent->menuBar()->setItemChecked(10002, true);
2141 parent->menuBar()->setItemChecked(10001, false);
2142 parent->menuBar()->setItemChecked(10004, false);
2143 parent->menuBar()->setItemEnabled(10003, true);
2144 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2149 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2150 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2155 parent->menuBar()->setItemChecked(10001, false);
2156 parent->menuBar()->setItemChecked(10004, true);
2157 parent->menuBar()->setItemChecked(10002, false);
2158 parent->menuBar()->setItemEnabled(10003, false);
2159 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2165 myActiveStudy->updateObjBrowser(true);
2169 //=============================================================================
2173 //=============================================================================
2174 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2175 QAD_StudyFrame * studyFrame)
2180 //=============================================================================
2184 //=============================================================================
2185 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2186 QAD_StudyFrame * studyFrame)
2191 //=============================================================================
2195 //=============================================================================
2196 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2197 QAD_StudyFrame * studyFrame)
2202 //=============================================================================
2206 //=============================================================================
2207 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2209 MESSAGE("SMESHGUI::SetSettings.");
2210 SMESHGUI::GetSMESHGUI();
2213 QString DisplayMode = "Shading";
2214 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2215 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2217 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2219 bool Shrink = false;
2220 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2221 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2223 if (DisplayMode == "Wireframe") {
2225 parent->menuBar()->setItemChecked(10004, false);
2226 parent->menuBar()->setItemChecked(10002, false);
2227 parent->menuBar()->setItemChecked(10001, true);
2228 parent->menuBar()->setItemEnabled(10003, true);
2230 else if (DisplayMode == "Nodes") {
2232 parent->menuBar()->setItemChecked(10004, true);
2233 parent->menuBar()->setItemChecked(10002, false);
2234 parent->menuBar()->setItemChecked(10001, false);
2235 parent->menuBar()->setItemEnabled(10003, false);
2238 // default is shading
2239 parent->menuBar()->setItemChecked(10004, false);
2240 parent->menuBar()->setItemChecked(10002, true);
2241 parent->menuBar()->setItemChecked(10001, false);
2242 parent->menuBar()->setItemEnabled(10003, true);
2244 parent->menuBar()->setItemChecked(10003, Shrink);
2246 /* Automatic Update */
2247 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2248 if (AutoUpdate.compare("true") == 0) {
2249 parent->menuBar()->setItemChecked(1001, true);
2250 myAutomaticUpdate = true;
2253 parent->menuBar()->setItemChecked(1001, false);
2254 myAutomaticUpdate = false;
2258 SMESH::UpdateSelectionProp();
2261 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2262 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2267 //=============================================================================
2271 //=============================================================================
2272 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2274 // NRI : Temporary added
2275 // if ( myStudy->GetProperties()->IsLocked() ) {
2276 // theObject = "NothingSelected";
2277 // theContext = "NothingSelected";
2281 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2282 int nbSel = Sel->IObjectCount();
2285 theObject = "NothingSelected";
2286 theContext = "NothingSelected";
2289 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2290 theObject = "Elements";
2292 theObject = ::CheckTypeObject( Sel->firstIObject() );
2296 theObject = ::CheckHomogeneousSelection();
2301 //=============================================================================
2305 //=============================================================================
2306 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2307 const QString& theParent, const QString& theObject)
2309 // get active study frame
2310 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2312 // get parent component which selected object(s) belongs to
2313 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2316 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2317 int nbSel = Sel->IObjectCount();
2322 else if ( nbSel == 1 ) {
2323 if ( parentComp != parent->getActiveComponent() ) {
2324 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2326 int id = popup->idAt( 0 );
2327 if ( id <= QAD_TopLabel_Popup_ID )
2328 popup->removeItemAt( 0 );
2334 // get selected interactive object
2335 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2336 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2337 // find popup menu's TopLabel item
2338 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2339 if ( topItem >= 0 ) {
2340 if ( theParent == "Viewer" ) {
2341 // set bold font for popup menu's TopLabel item (Viewer popup)
2342 QFont fnt = popup->font(); fnt.setBold( TRUE );
2343 popup->removeItem( QAD_TopLabel_Popup_ID );
2344 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2346 else if ( theParent == "ObjectBrowser" ) {
2347 // remove popup menu's TopLabel item (Object Browser popup)
2348 popup->removeItem( QAD_TopLabel_Popup_ID );
2352 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2353 // remove Display/Erase commands
2354 popup->removeItem( QAD_Display_Popup_ID );
2355 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2356 popup->removeItem( QAD_Erase_Popup_ID );
2357 // remove "Unassign ..." command if hyp/algo is not assigned
2358 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2359 popup->removeItem( 1102 );
2361 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2363 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2364 if ( aShapeObject->_is_nil() ) {
2366 popup->removeItem( 701 ); // Compute
2367 popup->removeItem( 705 ); // Edit hypothesis
2368 popup->removeItem( 706 ); // ...
2370 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2371 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2372 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2373 popup->removeItem( 803 ); // EDIT GROUP
2375 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2376 // if object has actor
2377 if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2378 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2379 if ( myRenderInter->isVisible( IObject ) ) {
2380 popup->removeItem( QAD_Display_Popup_ID );
2381 popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
2382 popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
2383 TVisualObjPtr aVisualObj = anActor->GetObject();
2384 int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
2385 int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
2386 int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
2388 QMenuItem* mi = popup->findItem( 1131 );
2389 if ( mi && mi->popup() ) {
2390 int prType = anActor->GetRepresentation();
2391 // Display Mode / Wireframe
2392 if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2393 mi->popup()->removeItem( 211 );
2395 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2397 // Display Mode / Shading
2398 if(aNbFaces == 0 && aNbVolumes == 0){
2399 mi->popup()->removeItem( 212 );
2401 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2403 // Display Mode / Points
2404 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2405 // Display Mode / Shrink
2406 bool isShrunk = anActor->IsShrunk();
2407 bool isShrunkable = anActor->IsShrunkable();
2408 mi->popup()->setItemChecked( 213, isShrunk );
2409 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2413 mi = popup->findItem( 1135 );
2414 if ( mi && mi->popup() ) {
2415 QPopupMenu* aPopup = mi->popup();
2416 unsigned int aMode = anActor->GetEntityMode();
2419 aPopup->removeItem( 219 );
2421 aPopup->setItemChecked( 219, aMode & SMESH_Actor::eVolumes );
2424 aPopup->removeItem( 218 );
2426 aPopup->setItemChecked( 218, aMode & SMESH_Actor::eFaces );
2430 aPopup->removeItem( 217 );
2432 aPopup->setItemChecked( 217, aMode & SMESH_Actor::eEdges );
2435 bool aIsRemove = (aNbVolumes == 0 || aMode & SMESH_Actor::eVolumes);
2436 aIsRemove &= (aNbFaces == 0 || aMode & SMESH_Actor::eFaces);
2437 aIsRemove &= (aNbEdges == 0 || aMode & SMESH_Actor::eEdges);
2440 aPopup->removeItem( 220 );
2444 mi = popup->findItem( 2000 );
2445 if ( mi && mi->popup() ) {
2446 SMESH_Actor::eControl cMode = anActor->GetControlMode();
2448 case SMESH_Actor::eLength:
2449 mi->popup()->setItemChecked( 6001, true ); break;
2450 case SMESH_Actor::eLength2D:
2451 mi->popup()->setItemChecked( 6018, true ); break;
2452 case SMESH_Actor::eFreeEdges:
2453 mi->popup()->setItemChecked( 6002, true );
2454 mi->popup()->removeItem( 201 );
2456 case SMESH_Actor::eFreeBorders:
2457 mi->popup()->setItemChecked( 6003, true );
2458 mi->popup()->removeItem( 201 );
2460 case SMESH_Actor::eMultiConnection:
2461 mi->popup()->setItemChecked( 6004, true ); break;
2462 case SMESH_Actor::eArea:
2463 mi->popup()->setItemChecked( 6011, true ); break;
2464 case SMESH_Actor::eTaper:
2465 mi->popup()->setItemChecked( 6012, true ); break;
2466 case SMESH_Actor::eAspectRatio:
2467 mi->popup()->setItemChecked( 6013, true ); break;
2468 case SMESH_Actor::eAspectRatio3D:
2469 mi->popup()->setItemChecked( 6017, true ); break;
2470 case SMESH_Actor::eMinimumAngle:
2471 mi->popup()->setItemChecked( 6014, true ); break;
2472 case SMESH_Actor::eWarping:
2473 mi->popup()->setItemChecked( 6015, true ); break;
2474 case SMESH_Actor::eSkew:
2475 mi->popup()->setItemChecked( 6016, true ); break;
2476 case SMESH_Actor::eNone:
2478 mi->popup()->removeItem( 200 );
2479 mi->popup()->removeItem( 201 );
2482 TVisualObjPtr aVisualObj = anActor->GetObject();
2484 mi->popup()->removeItem( 6001 );
2485 mi->popup()->removeItem( 6018 );
2486 mi->popup()->removeItem( 6003 );
2487 mi->popup()->removeItem( 6004 );
2490 mi->popup()->removeItem( 6002 );
2491 mi->popup()->removeItem( 6011 );
2492 mi->popup()->removeItem( 6012 );
2493 mi->popup()->removeItem( 6013 );
2494 mi->popup()->removeItem( 6014 );
2495 mi->popup()->removeItem( 6015 );
2496 mi->popup()->removeItem( 6016 );
2498 if(aNbVolumes == 0){
2499 mi->popup()->removeItem( 6017 );
2501 if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2502 popup->removeItem( 2000 ); // Scalar Bar
2506 popup->removeItem( QAD_Erase_Popup_ID );
2507 popup->removeItem( 114 ); // Numbering popup menu
2508 popup->removeItem( 1131 ); // Display mode
2509 popup->removeItem( 1132 ); // Color / size
2510 popup->removeItem( 1133 ); // Transparency
2511 popup->removeItem( 1134 ); // Clipping
2512 popup->removeItem( 2000 ); // Scalar Bar
2516 // object doesn't have actor
2517 CORBA::Object_var anObject = SO->GetObject();
2518 bool bDisplay = false;
2519 if ( !CORBA::is_nil( anObject ) ) {
2520 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2521 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2523 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2524 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2526 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2527 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2531 popup->removeItem( QAD_Display_Popup_ID );
2532 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2534 popup->removeItem( QAD_Erase_Popup_ID );
2535 popup->removeItem( 114 ); // Numbering popup menu
2536 popup->removeItem( 1131 ); // Display mode
2537 popup->removeItem( 1132 ); // Color / size
2538 popup->removeItem( 1133 ); // Transparency
2539 popup->removeItem( 1134 ); // Clipping
2540 popup->removeItem( 2000 ); // Scalar Bar
2543 else if( theObject!="Component" ) {
2544 // another SMESH object
2545 popup->removeItem( QAD_Display_Popup_ID );
2546 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2547 popup->removeItem( QAD_Erase_Popup_ID );
2552 // multiple selection
2553 if ( parentComp != parent->getActiveComponent() ) {
2554 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2556 int id = popup->idAt( 0 );
2557 if ( id <= QAD_TopLabel_Popup_ID )
2558 popup->removeItemAt( 0 );
2562 if ( parentComp.isNull() ) {
2563 // objects from different components are selected
2564 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2565 popup->removeItem( QAD_Display_Popup_ID );
2566 popup->removeItem( QAD_Erase_Popup_ID );
2570 QString type = ::CheckHomogeneousSelection();
2571 if ( type != "Heterogeneous Selection" ) {
2572 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2573 if ( topItem >= 0 ) {
2574 // set bold font for popup menu's TopLabel item
2575 QFont fnt = popup->font(); fnt.setBold( TRUE );
2576 popup->removeItem( QAD_TopLabel_Popup_ID );
2577 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2585 //=============================================================================
2586 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2587 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2589 //=============================================================================
2590 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2593 if(theIO->hasEntry()){
2594 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2595 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2596 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2600 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2602 if (!buffer || !bufferSize)
2604 buffer[0] = (int)VIEW_VTK;
2607 void SMESHGUI::Deactivate()
2609 if ( SMESHGUI::GetSMESHGUI() ) {
2610 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();