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_ExtrusionAlongPathDlg.h"
57 #include "SMESHGUI_RevolutionDlg.h"
58 #include "SMESHGUI_TranslationDlg.h"
59 #include "SMESHGUI_RotationDlg.h"
60 #include "SMESHGUI_SymmetryDlg.h"
61 #include "SMESHGUI_SewingDlg.h"
62 #include "SMESHGUI_MergeNodesDlg.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_PrecisionDlg.h"
66 #include "VTKViewer_ViewFrame.h"
67 #include "VTKViewer_InteractorStyleSALOME.h"
68 #include "VTKViewer_RenderWindowInteractor.h"
70 #include "SMESH_Actor.h"
71 #include "SMESH_Object.h"
74 #include "QAD_Tools.h"
75 #include "QAD_Config.h"
76 #include "QAD_Settings.h"
77 #include "QAD_RightFrame.h"
78 #include "QAD_MessageBox.h"
79 #include "QAD_Resource.h"
80 #include "QAD_FileDlg.h"
81 #include "QAD_Desktop.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_WaitCursor.h"
85 #include "SALOME_NamingService.hxx"
86 #include "SALOME_ListIteratorOfListIO.hxx"
87 #include "SALOME_InteractiveObject.hxx"
89 #include "SALOMEGUI_Desktop.h"
90 #include "SALOMEGUI_NameDlg.h"
91 #include "SALOMEGUI_ImportOperation.h"
92 #include "SALOMEGUI_QtCatchCorbaException.hxx"
94 #include "SMESHGUI_Utils.h"
95 #include "SMESHGUI_SMESHGenUtils.h"
96 #include "SMESHGUI_GEOMGenUtils.h"
97 #include "SMESHGUI_MeshUtils.h"
98 #include "SMESHGUI_GroupUtils.h"
99 #include "SMESHGUI_FilterUtils.h"
100 #include "SMESHGUI_PatternUtils.h"
101 #include "SMESHGUI_VTKUtils.h"
103 #include "SALOMEconfig.h"
104 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
107 #define INCLUDE_MENUITEM_DEF
108 #include <qapplication.h>
109 #include <qlineedit.h>
110 #include <qmenudata.h>
111 #include <qmenubar.h>
112 #include <qpopupmenu.h>
115 #include <qpainter.h>
116 #include <qcheckbox.h>
117 #include <qcolordialog.h>
118 #include <qspinbox.h>
122 #include <qradiobutton.h>
124 #include <boost/shared_ptr.hpp>
126 #include <vtkRenderer.h>
127 #include <vtkRenderWindow.h>
128 #include <vtkActorCollection.h>
129 #include <vtkScalarBarActor.h>
130 #include <vtkUnstructuredGrid.h>
132 #include "utilities.h"
138 //=============================================================
139 void ImportMeshesFromFile(QAD_Desktop * parent,
140 SMESH::SMESH_Gen_ptr theComponentMesh,
143 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
145 void SetDisplayMode(int theCommandID);
147 void SetDisplayEntity(int theCommandID);
149 void Control( int theCommandID );
151 void SetDisplaySettings();
155 //=============================================================
156 void ImportMeshesFromFile(QAD_Desktop * parent,
157 SMESH::SMESH_Gen_ptr theComponentMesh,
163 if(theCommandID == 113){
164 filter.append(QObject::tr("MED files (*.med)"));
165 filter.append(QObject::tr("All files (*)"));
166 }else if (theCommandID == 112){
167 filter.append(QObject::tr("IDEAS files (*.unv)"));
168 }else if (theCommandID == 111){
169 filter.append(QObject::tr("DAT files (*.dat)"));
171 QString filename = QAD_FileDlg::getFileName(parent,
174 QObject::tr("Import mesh"),
176 if(!filename.isEmpty()) {
178 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
181 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
182 switch ( theCommandID ) {
185 aMeshes->length( 1 );
186 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
191 SMESH::DriverMED_ReadStatus res;
192 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
193 if ( res != SMESH::DRS_OK ) {
195 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
196 QObject::tr("SMESH_WRN_WARNING"),
197 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
198 QObject::tr("SMESH_BUT_OK"));
199 aMeshes->length( 0 );
206 bool isEmpty = false;
207 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
208 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
209 if ( !aMeshSO->_is_nil() ) {
210 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
211 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
212 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
213 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
214 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
221 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
222 QObject::tr("SMESH_WRN_WARNING"),
223 QObject::tr("SMESH_DRS_EMPTY"),
224 QObject::tr("SMESH_BUT_OK"));
228 catch (const SALOME::SALOME_Exception& S_ex){
230 QtCatchCorbaException(S_ex);
237 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
239 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
240 if(aSel->IObjectCount()){
241 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
242 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
243 if ( !aMesh->_is_nil() ) {
244 QString aFilter, aTitle = QObject::tr("Export mesh");
245 QMap<QString, SMESH::MED_VERSION> aFilterMap;
246 switch ( theCommandID ) {
248 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
249 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
252 aFilter = QObject::tr("DAT files (*.dat)");
255 if(aMesh->NbPyramids()){
256 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
257 QObject::tr("SMESH_WRN_WARNING"),
258 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
259 QObject::tr("SMESH_BUT_YES"),
260 QObject::tr("SMESH_BUT_NO"),
265 aFilter = QObject::tr("IDEAS files (*.unv)");
272 SMESH::MED_VERSION aFormat;
274 if ( theCommandID != 122)
275 aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
279 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
280 filters.push_back( it.key() );
282 QAD_FileDlg* fd = new QAD_FileDlg( parent, false, true, true );
283 fd->setCaption( aTitle );
284 fd->setFilters( filters );
286 aFilename = fd->selectedFile();
287 aFormat = aFilterMap[fd->selectedFilter()];
290 if ( !aFilename.isEmpty() ) {
291 // Check whether the file already exists and delete it if yes
292 QFile aFile( aFilename );
293 if ( aFile.exists() )
296 switch ( theCommandID ) {
298 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
301 aMesh->ExportDAT( aFilename.latin1() );
304 aMesh->ExportUNV( aFilename.latin1() );
314 inline void InverseEntityMode(unsigned int& theOutputMode,
315 unsigned int theMode)
317 bool anIsNotPresent = ~theOutputMode & theMode;
319 theOutputMode |= theMode;
321 theOutputMode &= ~theMode;
324 void SetDisplayEntity(int theCommandID){
325 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
326 if(Sel->IObjectCount() >= 1){
327 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
328 for(; It.More(); It.Next()){
329 Handle(SALOME_InteractiveObject) IObject = It.Value();
330 if(IObject->hasEntry()){
331 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
332 unsigned int aMode = anActor->GetEntityMode();
333 switch(theCommandID){
335 InverseEntityMode(aMode,SMESH_Actor::eEdges);
338 InverseEntityMode(aMode,SMESH_Actor::eFaces);
341 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
344 aMode = SMESH_Actor::eAllEntity;
348 anActor->SetEntityMode(aMode);
355 void SetDisplayMode(int theCommandID){
356 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
357 if(Sel->IObjectCount() >= 1){
358 switch(theCommandID){
360 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
361 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
365 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
366 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
369 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
370 for(; It.More(); It.Next()){
371 Handle(SALOME_InteractiveObject) IObject = It.Value();
372 if(IObject->hasEntry()){
373 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
374 switch(theCommandID){
376 anActor->SetRepresentation(SMESH_Actor::eEdge);
379 anActor->SetRepresentation(SMESH_Actor::eSurface);
382 if(anActor->IsShrunk())
385 anActor->SetShrink();
388 anActor->SetRepresentation(SMESH_Actor::ePoint);
392 anActor->GetSufaceColor(color[0], color[1], color[2]);
393 int c0 = int (color[0] * 255);
394 int c1 = int (color[1] * 255);
395 int c2 = int (color[2] * 255);
396 QColor c(c0, c1, c2);
399 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
400 c0 = int (edgecolor[0] * 255);
401 c1 = int (edgecolor[1] * 255);
402 c2 = int (edgecolor[2] * 255);
403 QColor e(c0, c1, c2);
405 float backfacecolor[3];
406 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
407 c0 = int (backfacecolor[0] * 255);
408 c1 = int (backfacecolor[1] * 255);
409 c2 = int (backfacecolor[2] * 255);
410 QColor b(c0, c1, c2);
413 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
414 c0 = int (nodecolor[0] * 255);
415 c1 = int (nodecolor[1] * 255);
416 c2 = int (nodecolor[2] * 255);
417 QColor n(c0, c1, c2);
419 int Edgewidth = (int)anActor->GetLineWidth();
422 int intValue = int(anActor->GetNodeSize());
423 float Shrink = anActor->GetShrinkFactor();
425 SMESHGUI_Preferences_ColorDlg *aDlg =
426 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
427 aDlg->SetColor(1, c);
428 aDlg->SetColor(2, e);
429 aDlg->SetColor(3, n);
430 aDlg->SetColor(4, b);
431 aDlg->SetIntValue(1, Edgewidth);
432 aDlg->SetIntValue(2, intValue);
433 aDlg->SetIntValue(3, int(Shrink*100.));
435 QColor color = aDlg->GetColor(1);
436 QColor edgecolor = aDlg->GetColor(2);
437 QColor nodecolor = aDlg->GetColor(3);
438 QColor backfacecolor = aDlg->GetColor(4);
439 /* actor color and backface color */
440 anActor->SetSufaceColor(float (color.red()) / 255.,
441 float (color.green()) / 255.,
442 float (color.blue()) / 255.);
443 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
444 float (backfacecolor.green()) / 255.,
445 float (backfacecolor.blue()) / 255.);
448 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
449 float (edgecolor.green()) / 255.,
450 float (edgecolor.blue()) / 255.);
452 /* Shrink factor and size edges */
453 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
454 anActor->SetLineWidth(aDlg->GetIntValue(1));
456 /* Nodes color and size */
457 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
458 float (nodecolor.green()) / 255.,
459 float (nodecolor.blue()) / 255.);
460 anActor->SetNodeSize(aDlg->GetIntValue(2));
469 SMESH::RepaintCurrentView();
474 void SetDisplaySettings()
476 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
477 SMESHGUI_Preferences_ColorDlg *aDlg =
478 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
481 QString SCr, SCg, SCb;
482 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
483 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
484 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
485 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
486 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
487 else color = QColor(0, 170, 255);
488 aDlg->SetColor(1, color);
490 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
491 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
492 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
493 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
494 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
495 else color = QColor(0, 170, 255);
496 aDlg->SetColor(2, color);
498 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
499 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
500 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
501 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
502 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
503 else color = Qt::red;
504 aDlg->SetColor(3, color);
506 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
507 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
508 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
509 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
510 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
511 else color = Qt::blue;
512 aDlg->SetColor(4, color);
514 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
515 if (intValue.isEmpty()) intValue = "1";
516 aDlg->SetIntValue(1, intValue.toInt());
517 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
518 if (intValue.isEmpty()) intValue = "3";
519 aDlg->SetIntValue(2, intValue.toInt());
520 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
521 if (intValue.isEmpty()) intValue = "75";
522 aDlg->SetIntValue(3, intValue.toInt());
525 QColor colorFill = aDlg->GetColor(1);
526 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
527 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
528 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
530 QColor colorOutline = aDlg->GetColor(2);
531 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
532 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
533 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
535 QColor colorNode = aDlg->GetColor(3);
536 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
537 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
538 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
540 QColor colorBackFace = aDlg->GetColor(4);
541 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
542 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
543 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
545 int width = aDlg->GetIntValue(1);
546 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
548 int nodes_size = aDlg->GetIntValue(2);
549 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
551 int shrink_coeff = aDlg->GetIntValue(3);
552 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
559 void Control( int theCommandID )
561 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
563 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
566 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
567 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
568 switch ( theCommandID ){
570 aTitle = QObject::tr( "LENGTH_EDGES" );
571 aControl = SMESH_Actor::eLength;
574 aTitle = QObject::tr( "LENGTH2D_EDGES" );
575 aControl = SMESH_Actor::eLength2D;
578 aTitle = QObject::tr( "FREE_EDGES" );
579 aControl = SMESH_Actor::eFreeEdges;
582 aTitle = QObject::tr( "FREE_BORDERS" );
583 aControl = SMESH_Actor::eFreeBorders;
586 aTitle = QObject::tr( "MULTI_BORDERS" );
587 aControl = SMESH_Actor::eMultiConnection;
590 aTitle = QObject::tr( "MULTI2D_BORDERS" );
591 aControl = SMESH_Actor::eMultiConnection2D;
594 aTitle = QObject::tr( "AREA_ELEMENTS" );
595 aControl = SMESH_Actor::eArea;
598 aTitle = QObject::tr( "TAPER_ELEMENTS" );
599 aControl = SMESH_Actor::eTaper;
602 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
603 aControl = SMESH_Actor::eAspectRatio;
606 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
607 aControl = SMESH_Actor::eAspectRatio3D;
610 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
611 aControl = SMESH_Actor::eMinimumAngle;
614 aTitle = QObject::tr( "WARP_ELEMENTS" );
615 aControl = SMESH_Actor::eWarping;
618 aTitle = QObject::tr( "SKEW_ELEMENTS" );
619 aControl = SMESH_Actor::eSkew;
622 anActor->SetControlMode(aControl);
623 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
630 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
631 MeshObjectType theType,
632 const QString theInTypeName,
633 QString & theOutTypeName)
635 SMESH_TypeFilter aTypeFilter( theType );
636 if ( aTypeFilter.IsOk( theIO )) {
637 theOutTypeName = theInTypeName;
644 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
646 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
647 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
648 if (!aSObj->_is_nil()) {
649 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
650 CORBA::String_var anID = aSComp->GetID();
651 if (!strcmp(anID.in(),theIO->getEntry()))
657 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
658 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
659 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
660 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
661 CheckOIType ( theIO, GROUP, "Group", aTypeName )
669 QString CheckHomogeneousSelection()
671 QAD_Study* aStudy = SMESH::GetActiveStudy();
672 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
675 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
676 for (; Itinit.More(); Itinit.Next())
678 List.Append(Itinit.Value());
681 QString RefType = CheckTypeObject(aSel->firstIObject());
682 SALOME_ListIteratorOfListIO It(List);
683 for (; It.More(); It.Next())
685 Handle(SALOME_InteractiveObject) IObject = It.Value();
686 QString Type = CheckTypeObject(IObject);
687 if (Type.compare(RefType) != 0)
688 return "Heterogeneous Selection";
691 aSel->ClearIObjects();
692 SALOME_ListIteratorOfListIO It1(List);
693 for (; It1.More(); It1.Next())
695 int res = aSel->AddIObject(It1.Value());
697 aStudy->highlight(It1.Value(), false);
699 aStudy->highlight(It1.Value(), true);
706 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
707 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
708 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
709 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
710 QObject::tr("ERR_ERROR"),
711 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
712 QObject::tr("BUT_OK") );
715 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
716 if (QAD_MessageBox::warn2
717 (QAD_Application::getDesktop(),
718 QObject::tr("SMESH_WRN_WARNING"),
719 QObject::tr("SMESH_REALLY_DELETE"),
720 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
723 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
724 int nbSf = anActiveStudy->getStudyFramesCount();
726 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
727 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
728 SALOMEDS::GenericAttribute_var anAttr;
729 SALOMEDS::AttributeIOR_var anIOR;
731 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
732 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
734 aStudyBuilder->NewCommand(); // There is a transaction
735 for(; It.More(); It.Next()){
736 Handle(SALOME_InteractiveObject) IObject = It.Value();
737 if(IObject->hasEntry()){
738 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
740 /* Erase child graphical objects */
741 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
742 for(it->InitEx(true); it->More(); it->Next()){
743 SALOMEDS::SObject_var CSO = it->Value();
744 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
745 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
747 for(int i = 0; i < nbSf; i++){
748 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
749 CORBA::String_var anEntry = CSO->GetID();
750 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
751 SMESH::RemoveActor(sf,anActor);
757 /* Erase main graphical object */
758 for(int i = 0; i < nbSf; i++){
759 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
760 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
761 SMESH::RemoveActor(sf,anActor);
765 // Remove object(s) from data structures
766 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
768 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
769 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
771 if ( !aGroup->_is_nil() ) { // DELETE GROUP
772 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
773 aMesh->RemoveGroup( aGroup );
775 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
776 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
777 aMesh->RemoveSubMesh( aSubMesh );
779 else {// default action: remove SObject from the study
780 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
781 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
783 aStudyBuilder->RemoveObjectWithChildren( obj );
788 } /* IObject->hasEntry() */
790 aStudyBuilder->CommitCommand();
792 /* Clear any previous selection */
793 Sel->ClearIObjects();
794 anActiveStudy->updateObjBrowser();
800 //=============================================================================
804 //=============================================================================
805 class CustomItem : public QCustomMenuItem
808 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
811 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
814 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
815 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
816 p->setFont( myFont );
817 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
823 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
826 bool fullSpan() const
836 //=============================================================================
840 //=============================================================================
841 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
842 SALOMEGUI( theName, theParent )
844 myActiveDialogBox = 0 ;
847 SMESH::GetSMESHGen();
848 SMESH::GetFilterManager();
851 /* load resources for all available meshers */
852 SMESH::InitAvailableHypotheses();
855 //=============================================================================
859 //=============================================================================
860 SMESHGUI::~SMESHGUI()
862 SMESH::GetFilterManager()->Destroy();
865 //=============================================================================
869 //=============================================================================
870 SMESHGUI* SMESHGUI::GetSMESHGUI()
872 static SMESHGUI aSMESHGUI;
873 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
874 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
876 /* Automatic Update flag */
877 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
884 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
885 return SMESHGUI::GetSMESHGUI();
889 //=============================================================================
893 //=============================================================================
894 void SMESHGUI::SetState(int aState)
896 this->myState = aState;
900 //=============================================================================
904 //=============================================================================
905 void SMESHGUI::ResetState()
911 //=============================================================================
915 //=============================================================================
916 void SMESHGUI::EmitSignalDeactivateDialog()
918 emit this->SignalDeactivateActiveDialog();
922 //=============================================================================
926 //=============================================================================
927 void SMESHGUI::EmitSignalStudyFrameChanged()
929 emit this->SignalStudyFrameChanged();
933 //=============================================================================
937 //=============================================================================
938 void SMESHGUI::EmitSignalCloseAllDialogs()
940 emit SignalCloseAllDialogs();
944 //=============================================================================
948 //=============================================================================
949 QDialog *SMESHGUI::GetActiveDialogBox()
951 return this->myActiveDialogBox;
954 //=============================================================================
958 //=============================================================================
959 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
961 this->myActiveDialogBox = (QDialog *) aDlg;
965 //=============================================================================
969 //=============================================================================
970 QAD_Study *SMESHGUI::GetActiveStudy()
972 return this->myActiveStudy;
975 //=============================================================================
979 //=============================================================================
980 QAD_Desktop *SMESHGUI::GetDesktop()
982 return QAD_Application::getDesktop();
985 //=============================================================================
989 //=============================================================================
990 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
992 MESSAGE("SMESHGUI::activeStudyChanged init.");
993 QAD_Study* prevStudy = myActiveStudy;
994 /* Create or retrieve an object SMESHGUI */
995 MESSAGE("Active study changed : prev study =" << prevStudy);
996 SMESHGUI::GetSMESHGUI();
997 EmitSignalStudyFrameChanged();
998 MESSAGE("Active study changed : active study =" << myActiveStudy);
999 if ( prevStudy != myActiveStudy ) {
1000 EmitSignalCloseAllDialogs();
1001 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
1003 SMESH::UpdateSelectionProp();
1005 MESSAGE("SMESHGUI::activeStudyChanged done.");
1009 //=============================================================================
1013 //=============================================================================
1014 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1016 /* Here the position is on the bottom right corner - 10 */
1017 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1019 QAD_Desktop *PP = QAD_Application::getDesktop();
1020 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1021 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1025 //=============================================================================
1029 //=============================================================================
1030 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
1031 return theStudy->GetProperties()->IsLocked();
1034 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
1035 if (isStudyLocked(theStudy)) {
1036 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
1037 QObject::tr("WRN_WARNING"),
1038 QObject::tr("WRN_STUDY_LOCKED"),
1039 QObject::tr("BUT_OK") );
1045 //=======================================================================
1046 //function : CheckActiveStudyLocked
1048 //=======================================================================
1050 bool SMESHGUI::ActiveStudyLocked()
1052 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1053 return checkLock( aStudy );
1056 //=============================================================================
1060 //=============================================================================
1061 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
1063 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1065 switch (theCommandID) {
1067 if(checkLock(aStudy)) break;
1075 if(checkLock(aStudy)) break;
1076 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1080 case 122: // EXPORT MED
1084 ::ExportMeshToFile(parent, theCommandID);
1088 case 200: // SCALAR BAR
1090 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1091 if( Sel && Sel->IObjectCount() ) {
1092 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1093 if( anIO->hasEntry() ) {
1094 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1095 anActor->SetControlMode( SMESH_Actor::eNone );
1103 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1104 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1108 case 1134: // Clipping
1109 case 1133: // Tranparency
1110 case 1132: // Colors / Size
1117 ::SetDisplayMode(theCommandID);
1123 case 219: // Volumes
1124 case 220: // All Entity
1125 ::SetDisplayEntity(theCommandID);
1130 if(checkLock(aStudy)) break;
1131 SMESH::UpdateView();
1136 case 301: // DISPLAY
1137 case 302: // DISPLAY ONLY
1139 SMESH::EDisplaing anAction;
1140 switch(theCommandID){
1141 case 300: anAction = SMESH::eErase; break;
1142 case 301: anAction = SMESH::eDisplay; break;
1143 case 302: anAction = SMESH::eDisplayOnly; break;
1146 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1147 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1148 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1149 for (; It.More(); It.Next()) {
1150 Handle(SALOME_InteractiveObject) IOS = It.Value();
1151 if (IOS->hasEntry()) {
1152 SMESH::UpdateView(anAction,IOS->getEntry());
1156 Sel->ClearIObjects();
1162 if(checkLock(aStudy)) break;
1163 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1164 EmitSignalDeactivateDialog();
1165 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1166 new SMESHGUI_NodesDlg(parent, "", Sel);
1169 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1170 tr("SMESH_WRN_WARNING"),
1171 tr("SMESH_WRN_VIEWER_VTK"),
1172 tr("SMESH_BUT_OK"));
1177 case 2151: // FILTER
1179 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1181 EmitSignalDeactivateDialog();
1182 new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1187 case 406: // MOVE NODE
1189 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1191 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1192 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1196 if(checkLock(aStudy)) break;
1197 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1198 new SMESHGUI_MoveNodesDlg( parent, Sel );
1202 case 701: // COMPUTE MESH
1204 if(checkLock(aStudy)) break;
1205 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1206 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1207 int nbSel = Sel->IObjectCount();
1212 SMESH::SMESH_Mesh_var aMesh;
1213 SMESH::SMESH_subMesh_var aSubMesh;
1214 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1215 if (IObject->hasEntry()){
1216 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1217 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1218 if ( aShapeObject->_is_nil() ) {
1222 if(!aMeshSObj->_is_nil()) {
1223 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1224 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1226 if (!aMesh->_is_nil()){
1227 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1228 if (!refShapeObject->_is_nil()) {
1229 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1230 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1231 tr("SMESH_WRN_WARNING"),
1232 tr("SMESH_WRN_MISSING_PARAMETERS"),
1233 tr("SMESH_BUT_OK"));
1237 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1238 SMESH::ModifiedMesh(aMeshSObj,true);
1239 // TO Do : change icon of all submeshes
1241 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1242 tr("SMESH_WRN_WARNING"),
1243 tr("SMESH_WRN_COMPUTE_FAILED"),
1244 tr("SMESH_BUT_OK"));
1246 catch(const SALOME::SALOME_Exception & S_ex){
1247 QtCatchCorbaException(S_ex);
1250 }else if(!aSubMesh->_is_nil()){
1251 aMesh = aSubMesh->GetFather();
1252 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1253 if(!refShapeObject->_is_nil()){
1254 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1256 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1257 tr("SMESH_WRN_WARNING"),
1258 tr("SMESH_WRN_MISSING_PARAMETERS"),
1259 tr("SMESH_BUT_OK"));
1263 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1264 SMESH::ModifiedMesh(aMeshSObj,true);
1265 // TO Do : change icon of all submeshes
1267 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1268 tr("SMESH_WRN_WARNING"),
1269 tr("SMESH_WRN_COMPUTE_FAILED"),
1270 tr("SMESH_BUT_OK"));
1271 }catch(const SALOME::SALOME_Exception & S_ex){
1272 QtCatchCorbaException(S_ex);
1278 CORBA::Long anId = aStudy->StudyId();
1279 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1280 cout<<"myAutomaticUpdate - "<<myAutomaticUpdate<<endl;
1281 if(myAutomaticUpdate && aVisualObj){
1282 aVisualObj->Update();
1283 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1285 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1287 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1293 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1294 tr("SMESH_WRN_WARNING"),
1295 tr("SMESH_WRN_VIEWER_VTK"),
1296 tr("SMESH_BUT_OK"));
1301 case 702: // ADD SUB MESH
1303 if(checkLock(aStudy)) break;
1304 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1305 EmitSignalDeactivateDialog();
1306 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1307 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1310 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1311 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1312 tr("SMESH_BUT_OK"));
1317 case 703: // INIT MESH
1319 if(checkLock(aStudy)) break;
1320 EmitSignalDeactivateDialog();
1321 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1322 new SMESHGUI_InitMeshDlg(parent, "", Sel);
1326 case 704: // EDIT Hypothesis
1328 if(checkLock(aStudy)) break;
1329 EmitSignalDeactivateDialog();
1330 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1331 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1335 case 705: // EDIT Global Hypothesis
1337 if(checkLock(aStudy)) break;
1338 EmitSignalDeactivateDialog();
1339 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1340 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1344 case 706: // EDIT Local Hypothesis
1346 if(checkLock(aStudy)) break;
1347 EmitSignalDeactivateDialog();
1348 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1349 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1353 case 407: // DIAGONAL INVERSION
1354 case 408: // Delete diagonal
1356 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1358 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1359 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1363 if ( checkLock( aStudy ) )
1366 SALOME_Selection *aSel =
1367 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1368 /*Standard_Boolean aRes;
1369 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1370 if ( aMesh->_is_nil() )
1372 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1373 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1377 EmitSignalDeactivateDialog();
1378 if ( theCommandID == 407 )
1379 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1381 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1384 case 409: // Change orientation
1385 case 410: // Union of triangles
1386 case 411: // Cutting of quadrangles
1388 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1390 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1391 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1395 if ( checkLock( aStudy ) )
1398 SALOME_Selection *aSel =
1399 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1401 EmitSignalDeactivateDialog();
1402 SMESHGUI_MultiEditDlg* aDlg;
1403 if ( theCommandID == 409 )
1404 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1405 else if ( theCommandID == 410 )
1406 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1408 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1411 DefineDlgPosition( aDlg, x, y );
1416 case 412: // Smoothing
1418 if(checkLock(aStudy)) break;
1419 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1420 EmitSignalDeactivateDialog();
1421 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1422 new SMESHGUI_SmoothingDlg(parent, "", Sel);
1425 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1426 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1427 tr("SMESH_BUT_OK"));
1431 case 413: // Extrusion
1433 if(checkLock(aStudy)) break;
1434 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1435 EmitSignalDeactivateDialog();
1436 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1437 new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1440 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1441 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1442 tr("SMESH_BUT_OK"));
1446 case 414: // Revolution
1448 if(checkLock(aStudy)) break;
1449 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1450 EmitSignalDeactivateDialog();
1451 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1452 new SMESHGUI_RevolutionDlg(parent, "", Sel);
1455 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1456 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1457 tr("SMESH_BUT_OK"));
1461 case 415: // Pattern mapping
1463 if ( checkLock( aStudy ) )
1465 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1467 EmitSignalDeactivateDialog();
1468 SALOME_Selection *Sel = SALOME_Selection::Selection(
1469 myActiveStudy->getSelection() );
1470 new SMESHGUI_MeshPatternDlg( parent, Sel );
1473 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1474 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1475 tr("SMESH_BUT_OK"));
1479 case 416: // Extrusion along a path
1481 if(checkLock(aStudy)) break;
1482 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1483 EmitSignalDeactivateDialog();
1484 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1485 new SMESHGUI_ExtrusionAlongPathDlg(parent, Sel);
1488 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1489 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1490 tr("SMESH_BUT_OK"));
1494 case 801: // CREATE GROUP
1496 if(checkLock(aStudy)) break;
1497 EmitSignalDeactivateDialog();
1498 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1499 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1500 int nbSel = Sel->IObjectCount();
1502 // check if mesh is selected
1503 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1505 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1510 case 802: // CONSTRUCT GROUP
1512 if(checkLock(aStudy)) break;
1513 EmitSignalDeactivateDialog();
1514 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1515 int nbSel = Sel->IObjectCount();
1517 // check if submesh is selected
1518 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1519 if (IObject->hasEntry()) {
1520 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1521 if(!aSObj->_is_nil()) {
1522 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1523 if (!aSubMesh->_is_nil()) {
1525 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1526 // get submesh elements list by types
1527 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1528 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1529 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1530 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1531 // create group for each type o elements
1532 QString aName = IObject->getName();
1533 if (aNodes->length() > 0) {
1534 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1535 aGroup->Add(aNodes.inout());
1537 if (aEdges->length() > 0) {
1538 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1539 aGroup->Add(aEdges.inout());
1541 if (aFaces->length() > 0) {
1542 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1543 aGroup->Add(aFaces.inout());
1545 if (aVolumes->length() > 0) {
1546 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1547 aGroup->Add(aVolumes.inout());
1549 myActiveStudy->updateObjBrowser(true);
1550 }catch(const SALOME::SALOME_Exception & S_ex){
1551 QtCatchCorbaException(S_ex);
1560 case 803: // EDIT GROUP
1562 if(checkLock(aStudy)) break;
1563 EmitSignalDeactivateDialog();
1564 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1565 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1566 SALOME_ListIteratorOfListIO It (IOs);
1567 int nbSelectedGroups = 0;
1568 for ( ; It.More(); It.Next() )
1570 SMESH::SMESH_Group_var aGroup =
1571 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1572 if (!aGroup->_is_nil()) {
1574 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1578 if (nbSelectedGroups == 0)
1580 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1586 case 804: // Add elements to group
1588 if(checkLock(aStudy)) break;
1589 if (myState == 800) {
1590 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1591 if (aDlg) aDlg->onAdd();
1596 case 805: // Remove elements from group
1598 if(checkLock(aStudy)) break;
1599 if (myState == 800) {
1600 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1601 if (aDlg) aDlg->onRemove();
1606 case 810: // Union Groups
1607 case 811: // Intersect groups
1608 case 812: // Cut groups
1610 if ( checkLock( aStudy ) )
1613 EmitSignalDeactivateDialog();
1614 SALOME_Selection *Sel = SALOME_Selection::Selection(
1615 myActiveStudy->getSelection() );
1618 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1619 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1620 else aMode = SMESHGUI_GroupOpDlg::CUT;
1622 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1626 case 813: // Delete groups with their contents
1628 if ( checkLock( aStudy ) )
1631 EmitSignalDeactivateDialog();
1632 SALOME_Selection *Sel = SALOME_Selection::Selection(
1633 myActiveStudy->getSelection() );
1635 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1639 case 900: // MESH INFOS
1641 EmitSignalDeactivateDialog();
1642 SALOME_Selection *Sel =
1643 SALOME_Selection::Selection(myActiveStudy->getSelection());
1644 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1645 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1646 SALOME_ListIteratorOfListIO It (IOs);
1647 for ( ; It.More(); It.Next() ) {
1648 Sel->ClearIObjects();
1649 Sel->AddIObject( It.Value() );
1650 new SMESHGUI_MeshInfosDlg(parent, "", false);
1652 // restore selection
1653 Sel->ClearIObjects();
1654 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1655 Sel->AddIObject( It.Value() );
1658 new SMESHGUI_MeshInfosDlg(parent, "", false);
1662 case 902: // STANDARD MESH INFOS
1664 EmitSignalDeactivateDialog();
1665 SALOME_Selection *Sel =
1666 SALOME_Selection::Selection(myActiveStudy->getSelection());
1667 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1668 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1669 SALOME_ListIteratorOfListIO It (IOs);
1670 for ( ; It.More(); It.Next() ) {
1671 Sel->ClearIObjects();
1672 Sel->AddIObject( It.Value() );
1673 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1675 // restore selection
1676 Sel->ClearIObjects();
1677 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1678 Sel->AddIObject( It.Value() );
1681 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1685 case 1001: // AUTOMATIC UPDATE PREFERENCES
1687 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1688 if (parent->menuBar()->isItemChecked(1001)) {
1689 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1690 myAutomaticUpdate = true;
1693 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1694 myAutomaticUpdate = false;
1699 case 1003: // MESH PREFERENCES
1701 ::SetDisplaySettings();
1707 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1713 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1719 parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071));
1720 if (parent->menuBar()->isItemChecked(10071)) {
1721 QAD_CONFIG->addSetting("SMESH:DispayEntity","true");
1724 QAD_CONFIG->addSetting("SMESH:DispayEntity","false");
1730 SMESHGUI_Preferences_SelectionDlg* aDlg =
1731 new SMESHGUI_Preferences_SelectionDlg(parent);
1734 QString SCr, SCg, SCb;
1735 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1736 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1737 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1738 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1739 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1740 else aColor = Qt::cyan;
1741 aDlg->SetColor(1, aColor);
1743 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1744 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1745 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1746 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1747 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1748 else aColor = Qt::yellow;
1749 aDlg->SetColor(2, aColor);
1751 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1752 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1753 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1754 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1755 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1756 else aColor = Qt::white;
1757 aDlg->SetColor(3, aColor);
1759 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1760 if (SW1.isEmpty()) SW1 = "5";
1761 aDlg->SetWidth(1, SW1.toInt());
1763 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1764 if (SW2.isEmpty()) SW2 = "5";
1765 aDlg->SetWidth(2, SW2.toInt());
1767 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1768 if (SP1.isEmpty()) SP1 = "0.025";
1769 aDlg->SetPrecision(1, SP1.toDouble());
1771 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1772 if (SP2.isEmpty()) SP2 = "0.001";
1773 aDlg->SetPrecision(2, SP2.toDouble());
1776 QColor aPreColor = aDlg->GetColor(1);
1777 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1778 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1779 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1781 QColor aSelColor = aDlg->GetColor(2);
1782 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1783 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1784 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1786 QColor aHiColor = aDlg->GetColor(3);
1787 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1788 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1789 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1791 int aPreWidth = aDlg->GetWidth(1);
1792 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1793 int aSelWidth = aDlg->GetWidth(2);
1794 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1796 double aTolNodes = aDlg->GetPrecision(1);
1797 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1798 double aTolItems = aDlg->GetPrecision(2);
1799 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1801 // update current study settings
1802 SMESH::UpdateSelectionProp();
1804 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1805 if (studyFrame->getTypeView() == VIEW_VTK) {
1806 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1807 // update VTK viewer properties
1808 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1810 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1811 aSelColor.blue()/255., aSelWidth);
1812 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1813 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1815 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1816 aPreColor.blue()/255., aPreWidth);
1819 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1820 vtkActorCollection *aCollection = aRenderer->GetActors();
1821 aCollection->InitTraversal();
1822 while(vtkActor *anAct = aCollection->GetNextActor()){
1823 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1824 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1825 aHiColor.blue()/255.);
1826 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1827 aPreColor.blue()/255.);
1836 case 1100: // EDIT HYPOTHESIS
1838 if(checkLock(aStudy)) break;
1839 SALOME_Selection *Sel =
1840 SALOME_Selection::Selection(myActiveStudy->getSelection());
1841 int nbSel = Sel->IObjectCount();
1844 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1846 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1847 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1848 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1849 if ( !Hyp->_is_nil() )
1851 char* sName = Hyp->GetName();
1852 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1855 aCreator->EditHypothesis(Hyp);
1866 case 1101: // RENAME
1868 if ( checkLock( aStudy ) )
1871 SALOME_Selection *Sel =
1872 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1874 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1875 for ( ; It.More(); It.Next() )
1877 Handle(SALOME_InteractiveObject) IObject = It.Value();
1878 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1879 SALOMEDS::GenericAttribute_var anAttr;
1880 SALOMEDS::AttributeName_var aName;
1881 if ( !obj->_is_nil() )
1883 if ( obj->FindAttribute(anAttr, "AttributeName") )
1885 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1886 QString newName = QString(aName->Value());
1887 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1888 if ( !newName.isEmpty() )
1890 myActiveStudy->renameIObject( IObject, newName );
1892 // if current object is group update group's name
1893 SMESH::SMESH_GroupBase_var aGroup =
1894 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1895 if (!aGroup->_is_nil() )
1896 aGroup->SetName( newName.latin1() );
1904 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1906 if(checkLock(aStudy)) break;
1908 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1909 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1910 for (int i = 0; It.More(); It.Next(), i++) {
1911 Handle(SALOME_InteractiveObject) IObject = It.Value();
1912 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1914 Sel->ClearIObjects();
1915 myActiveStudy->updateObjBrowser(true);
1919 case 401: // GEOM::EDGE
1920 case 4021: // TRIANGLE
1925 if(checkLock(aStudy)) break;
1926 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1927 EmitSignalDeactivateDialog();
1928 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1929 SMDSAbs_ElementType type = SMDSAbs_Edge;
1931 switch (theCommandID) {
1932 case 4021: // TRIANGLE
1933 type = SMDSAbs_Face; nbNodes = 3; break;
1935 type = SMDSAbs_Face; nbNodes = 4; break;
1937 type = SMDSAbs_Volume; nbNodes = 4; break;
1939 type = SMDSAbs_Volume; nbNodes = 8; break;
1942 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1945 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1946 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1947 tr("SMESH_BUT_OK"));
1952 case 4041: // REMOVES NODES
1954 if(checkLock(aStudy)) break;
1955 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1956 EmitSignalDeactivateDialog();
1957 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1958 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1961 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1962 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963 tr("SMESH_BUT_OK"));
1967 case 4042: // REMOVES ELEMENTS
1969 if(checkLock(aStudy)) break;
1970 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1971 EmitSignalDeactivateDialog();
1972 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1973 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1977 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1978 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1979 tr("SMESH_BUT_OK"));
1983 case 4051: // RENUMBERING NODES
1985 if(checkLock(aStudy)) break;
1986 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1987 EmitSignalDeactivateDialog();
1988 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1989 new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1993 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1995 tr("SMESH_BUT_OK"));
1999 case 4052: // RENUMBERING ELEMENTS
2001 if(checkLock(aStudy)) break;
2002 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2003 EmitSignalDeactivateDialog();
2004 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005 new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
2009 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2010 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2011 tr("SMESH_BUT_OK"));
2015 case 4061: // TRANSLATION
2017 if(checkLock(aStudy)) break;
2018 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2019 EmitSignalDeactivateDialog();
2020 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2021 new SMESHGUI_TranslationDlg(parent, "", Sel);
2024 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2025 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2026 tr("SMESH_BUT_OK"));
2030 case 4062: // ROTATION
2032 if(checkLock(aStudy)) break;
2033 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2034 EmitSignalDeactivateDialog();
2035 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2036 new SMESHGUI_RotationDlg(parent, "", Sel);
2039 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2041 tr("SMESH_BUT_OK"));
2045 case 4063: // SYMMETRY
2047 if(checkLock(aStudy)) break;
2048 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2049 EmitSignalDeactivateDialog();
2050 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2051 new SMESHGUI_SymmetryDlg(parent, "", Sel);
2054 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2056 tr("SMESH_BUT_OK"));
2060 case 4064: // SEWING
2062 if(checkLock(aStudy)) break;
2063 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2064 EmitSignalDeactivateDialog();
2065 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2066 new SMESHGUI_SewingDlg(parent, "", Sel);
2069 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2070 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2071 tr("SMESH_BUT_OK"));
2075 case 4065: // MERGE NODES
2077 if(checkLock(aStudy)) break;
2078 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2079 EmitSignalDeactivateDialog();
2080 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2081 new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2084 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2085 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2086 tr("SMESH_BUT_OK"));
2092 case 5000: // HYPOTHESIS
2094 if(checkLock(aStudy)) break;
2095 EmitSignalDeactivateDialog();
2096 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2101 if(checkLock(aStudy)) break;
2102 EmitSignalDeactivateDialog();
2103 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2107 case 5105: // Library of selection filters
2109 static QValueList<int> aTypes;
2110 if ( aTypes.isEmpty() )
2112 aTypes.append( SMESH::NODE );
2113 aTypes.append( SMESH::EDGE );
2114 aTypes.append( SMESH::FACE );
2115 aTypes.append( SMESH::VOLUME );
2117 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2121 case 6017: // CONTROLS
2134 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2135 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2136 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2137 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2138 if ( !SO->_is_nil() ) {
2139 CORBA::Object_var aObject = SO->GetObject();
2140 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2141 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2142 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2143 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2144 ::Control( theCommandID );
2149 QAD_MessageBox::warn1(GetDesktop(),
2150 tr( "SMESH_WRN_WARNING" ),
2151 tr( "SMESH_BAD_SELECTION" ),
2152 tr( "SMESH_BUT_OK" ) );
2156 QAD_MessageBox::warn1(GetDesktop(),
2157 tr( "SMESH_WRN_WARNING" ),
2158 tr( "NOT_A_VTK_VIEWER" ),
2159 tr( "SMESH_BUT_OK" ) );
2164 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2165 if (Sel->IObjectCount() == 1) {
2166 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2167 if(anIObject->hasEntry())
2168 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2169 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2176 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2177 if (Sel->IObjectCount() == 1) {
2178 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2179 if(anIObject->hasEntry())
2180 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2181 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2186 case 10001: // DISPLAY MODE PREFERENCE
2189 parent->menuBar()->setItemChecked(10001, true);
2190 parent->menuBar()->setItemChecked(10002, false);
2191 parent->menuBar()->setItemChecked(10004, false);
2192 parent->menuBar()->setItemEnabled(10003, true);
2193 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2198 parent->menuBar()->setItemChecked(10002, true);
2199 parent->menuBar()->setItemChecked(10001, false);
2200 parent->menuBar()->setItemChecked(10004, false);
2201 parent->menuBar()->setItemEnabled(10003, true);
2202 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2207 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2208 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2213 parent->menuBar()->setItemChecked(10001, false);
2214 parent->menuBar()->setItemChecked(10004, true);
2215 parent->menuBar()->setItemChecked(10002, false);
2216 parent->menuBar()->setItemEnabled(10003, false);
2217 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2223 myActiveStudy->updateObjBrowser(true);
2227 //=============================================================================
2231 //=============================================================================
2232 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2233 QAD_StudyFrame * studyFrame)
2238 //=============================================================================
2242 //=============================================================================
2243 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2244 QAD_StudyFrame * studyFrame)
2249 //=============================================================================
2253 //=============================================================================
2254 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2255 QAD_StudyFrame * studyFrame)
2260 //=============================================================================
2264 //=============================================================================
2265 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2267 MESSAGE("SMESHGUI::SetSettings.");
2268 SMESHGUI::GetSMESHGUI();
2271 QString DisplayMode = "Shading";
2272 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2273 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2275 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2277 bool Shrink = false;
2278 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2279 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2281 if (DisplayMode == "Wireframe") {
2283 parent->menuBar()->setItemChecked(10004, false);
2284 parent->menuBar()->setItemChecked(10002, false);
2285 parent->menuBar()->setItemChecked(10001, true);
2286 parent->menuBar()->setItemEnabled(10003, true);
2288 else if (DisplayMode == "Nodes") {
2290 parent->menuBar()->setItemChecked(10004, true);
2291 parent->menuBar()->setItemChecked(10002, false);
2292 parent->menuBar()->setItemChecked(10001, false);
2293 parent->menuBar()->setItemEnabled(10003, false);
2296 // default is shading
2297 parent->menuBar()->setItemChecked(10004, false);
2298 parent->menuBar()->setItemChecked(10002, true);
2299 parent->menuBar()->setItemChecked(10001, false);
2300 parent->menuBar()->setItemEnabled(10003, true);
2302 parent->menuBar()->setItemChecked(10003, Shrink);
2304 /* Automatic Update */
2305 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2306 if (AutoUpdate.compare("true") == 0) {
2307 parent->menuBar()->setItemChecked(1001, true);
2308 myAutomaticUpdate = true;
2311 parent->menuBar()->setItemChecked(1001, false);
2312 myAutomaticUpdate = false;
2315 QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity");
2316 if(anIsDisplayEntity.compare("true") == 0)
2317 parent->menuBar()->setItemChecked(10071,true);
2319 parent->menuBar()->setItemChecked(10071,false);
2322 SMESH::UpdateSelectionProp();
2325 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2326 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2331 //=============================================================================
2335 //=============================================================================
2336 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2338 // NRI : Temporary added
2339 // if ( myStudy->GetProperties()->IsLocked() ) {
2340 // theObject = "NothingSelected";
2341 // theContext = "NothingSelected";
2345 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2346 int nbSel = Sel->IObjectCount();
2349 theObject = "NothingSelected";
2350 theContext = "NothingSelected";
2353 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2354 theObject = "Elements";
2356 theObject = ::CheckTypeObject( Sel->firstIObject() );
2360 theObject = ::CheckHomogeneousSelection();
2365 //=============================================================================
2369 //=============================================================================
2370 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2371 const QString& theParent, const QString& theObject)
2373 // get active study frame
2374 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2376 // get parent component which selected object(s) belongs to
2377 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2380 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2381 int nbSel = Sel->IObjectCount();
2386 else if ( nbSel == 1 ) {
2387 if ( parentComp != parent->getActiveComponent() ) {
2388 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2390 int id = popup->idAt( 0 );
2391 if ( id <= QAD_TopLabel_Popup_ID )
2392 popup->removeItemAt( 0 );
2398 // get selected interactive object
2399 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2400 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2401 // find popup menu's TopLabel item
2402 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2403 if ( topItem >= 0 ) {
2404 if ( theParent == "Viewer" ) {
2405 // set bold font for popup menu's TopLabel item (Viewer popup)
2406 QFont fnt = popup->font(); fnt.setBold( TRUE );
2407 popup->removeItem( QAD_TopLabel_Popup_ID );
2408 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2410 else if ( theParent == "ObjectBrowser" ) {
2411 // remove popup menu's TopLabel item (Object Browser popup)
2412 popup->removeItem( QAD_TopLabel_Popup_ID );
2416 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2417 // remove Display/Erase commands
2418 popup->removeItem( QAD_Display_Popup_ID );
2419 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2420 popup->removeItem( QAD_Erase_Popup_ID );
2421 // remove "Unassign ..." command if hyp/algo is not assigned
2422 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2423 popup->removeItem( 1102 );
2425 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2427 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2428 if ( aShapeObject->_is_nil() ) {
2430 popup->removeItem( 701 ); // Compute
2431 popup->removeItem( 705 ); // Edit hypothesis
2432 popup->removeItem( 706 ); // ...
2434 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2435 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2436 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2437 popup->removeItem( 803 ); // EDIT GROUP
2439 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2440 // if object has actor
2441 if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2442 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2443 if ( myRenderInter->isVisible( IObject ) ) {
2444 popup->removeItem( QAD_Display_Popup_ID );
2445 popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
2446 popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
2447 TVisualObjPtr aVisualObj = anActor->GetObject();
2448 int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
2449 int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
2450 int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
2452 QMenuItem* mi = popup->findItem( 1131 );
2453 if ( mi && mi->popup() ) {
2454 int prType = anActor->GetRepresentation();
2455 // Display Mode / Wireframe
2456 if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2457 mi->popup()->removeItem( 211 );
2459 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2461 // Display Mode / Shading
2462 if(aNbFaces == 0 && aNbVolumes == 0){
2463 mi->popup()->removeItem( 212 );
2465 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2467 // Display Mode / Points
2468 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2469 // Display Mode / Shrink
2470 bool isShrunk = anActor->IsShrunk();
2471 bool isShrunkable = anActor->IsShrunkable();
2472 mi->popup()->setItemChecked( 213, isShrunk );
2473 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2477 mi = popup->findItem( 1135 );
2479 if (aNbVolumes>0) aIsSomething++;
2480 if (aNbFaces>0) aIsSomething++;
2481 if (aNbEdges>0) aIsSomething++;
2482 if ( mi && (aIsSomething <= 1)){
2483 popup->removeItem(1135);
2484 }else if ( mi && mi->popup() ) {
2485 QPopupMenu* aPopup = mi->popup();
2486 unsigned int aMode = anActor->GetEntityMode();
2488 bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes;
2489 bool aIsFacesMode = aMode & SMESH_Actor::eFaces;
2490 bool aIsEdgesMode = aMode & SMESH_Actor::eEdges;
2493 aPopup->removeItem( 219 );
2495 aPopup->setItemChecked( 219, aIsVolumesMode );
2498 aPopup->removeItem( 218 );
2500 aPopup->setItemChecked( 218, aIsFacesMode );
2504 aPopup->removeItem( 217 );
2506 aPopup->setItemChecked( 217, aIsEdgesMode );
2509 bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode);
2510 aIsRemove &= (aNbFaces == 0 || aIsFacesMode);
2511 aIsRemove &= (aNbEdges == 0 || aIsEdgesMode);
2514 aPopup->removeItem( 220 );
2518 mi = popup->findItem( 2000 );
2519 if ( mi && mi->popup() ) {
2520 SMESH_Actor::eControl cMode = anActor->GetControlMode();
2522 case SMESH_Actor::eLength:
2523 mi->popup()->setItemChecked( 6001, true ); break;
2524 case SMESH_Actor::eLength2D:
2525 mi->popup()->setItemChecked( 6018, true ); break;
2526 case SMESH_Actor::eFreeEdges:
2527 mi->popup()->setItemChecked( 6002, true );
2528 mi->popup()->removeItem( 201 );
2530 case SMESH_Actor::eFreeBorders:
2531 mi->popup()->setItemChecked( 6003, true );
2532 mi->popup()->removeItem( 201 );
2534 case SMESH_Actor::eMultiConnection:
2535 mi->popup()->setItemChecked( 6004, true ); break;
2536 case SMESH_Actor::eMultiConnection2D:
2537 mi->popup()->setItemChecked( 6019, true ); break;
2538 case SMESH_Actor::eArea:
2539 mi->popup()->setItemChecked( 6011, true ); break;
2540 case SMESH_Actor::eTaper:
2541 mi->popup()->setItemChecked( 6012, true ); break;
2542 case SMESH_Actor::eAspectRatio:
2543 mi->popup()->setItemChecked( 6013, true ); break;
2544 case SMESH_Actor::eAspectRatio3D:
2545 mi->popup()->setItemChecked( 6017, true ); break;
2546 case SMESH_Actor::eMinimumAngle:
2547 mi->popup()->setItemChecked( 6014, true ); break;
2548 case SMESH_Actor::eWarping:
2549 mi->popup()->setItemChecked( 6015, true ); break;
2550 case SMESH_Actor::eSkew:
2551 mi->popup()->setItemChecked( 6016, true ); break;
2552 case SMESH_Actor::eNone:
2554 mi->popup()->removeItem( 200 );
2555 mi->popup()->removeItem( 201 );
2558 TVisualObjPtr aVisualObj = anActor->GetObject();
2560 mi->popup()->removeItem( 6001 );
2561 mi->popup()->removeItem( 6003 );
2562 mi->popup()->removeItem( 6004 );
2565 mi->popup()->removeItem( 6018 );
2566 mi->popup()->removeItem( 6002 );
2567 mi->popup()->removeItem( 6011 );
2568 mi->popup()->removeItem( 6012 );
2569 mi->popup()->removeItem( 6013 );
2570 mi->popup()->removeItem( 6014 );
2571 mi->popup()->removeItem( 6015 );
2572 mi->popup()->removeItem( 6016 );
2573 mi->popup()->removeItem( 6019 );
2575 if(aNbVolumes == 0){
2576 mi->popup()->removeItem( 6017 );
2578 if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2579 popup->removeItem( 2000 ); // Scalar Bar
2583 popup->removeItem( QAD_Erase_Popup_ID );
2584 popup->removeItem( 114 ); // Numbering popup menu
2585 popup->removeItem( 1131 ); // Display mode
2586 popup->removeItem( 1132 ); // Color / size
2587 popup->removeItem( 1133 ); // Transparency
2588 popup->removeItem( 1134 ); // Clipping
2589 popup->removeItem( 2000 ); // Scalar Bar
2591 // VSR 03/02/05 - check if actor is empty ----- start -----
2592 vtkUnstructuredGrid* vtkGrid = anActor->GetUnstructuredGrid();
2593 if ( vtkGrid->GetNumberOfPoints() + vtkGrid->GetNumberOfCells() == 0 ) {
2594 popup->removeItem( QAD_Display_Popup_ID );
2595 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2596 popup->removeItem( QAD_Erase_Popup_ID );
2598 // VSR 03/02/05 - check if actor is empty ----- finish -----
2601 // object doesn't have actor
2602 CORBA::Object_var anObject = SO->GetObject();
2603 bool bDisplay = false;
2604 if ( !CORBA::is_nil( anObject ) ) {
2605 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2606 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2608 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2609 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2611 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2612 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2616 popup->removeItem( QAD_Display_Popup_ID );
2617 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2619 popup->removeItem( QAD_Erase_Popup_ID );
2620 popup->removeItem( 114 ); // Numbering popup menu
2621 popup->removeItem( 1131 ); // Display mode
2622 popup->removeItem( 1132 ); // Color / size
2623 popup->removeItem( 1133 ); // Transparency
2624 popup->removeItem( 1134 ); // Clipping
2625 popup->removeItem( 2000 ); // Scalar Bar
2628 else if( theObject!="Component" ) {
2629 // another SMESH object
2630 popup->removeItem( QAD_Display_Popup_ID );
2631 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2632 popup->removeItem( QAD_Erase_Popup_ID );
2637 // multiple selection
2638 if ( parentComp != parent->getActiveComponent() ) {
2639 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2641 int id = popup->idAt( 0 );
2642 if ( id <= QAD_TopLabel_Popup_ID )
2643 popup->removeItemAt( 0 );
2647 if ( parentComp.isNull() ) {
2648 // objects from different components are selected
2649 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2650 popup->removeItem( QAD_Display_Popup_ID );
2651 popup->removeItem( QAD_Erase_Popup_ID );
2655 QString type = ::CheckHomogeneousSelection();
2656 if ( type != "Heterogeneous Selection" ) {
2657 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2658 if ( topItem >= 0 ) {
2659 // set bold font for popup menu's TopLabel item
2660 QFont fnt = popup->font(); fnt.setBold( TRUE );
2661 popup->removeItem( QAD_TopLabel_Popup_ID );
2662 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2670 //=============================================================================
2671 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2672 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2674 //=============================================================================
2675 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2678 if(theIO->hasEntry()){
2679 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2680 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2681 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2685 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2687 if (!buffer || !bufferSize)
2689 buffer[0] = (int)VIEW_VTK;
2692 void SMESHGUI::Deactivate()
2694 if ( SMESHGUI::GetSMESHGUI() ) {
2695 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();