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"
65 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
67 #include "VTKViewer_ViewFrame.h"
68 #include "VTKViewer_InteractorStyleSALOME.h"
69 #include "VTKViewer_RenderWindowInteractor.h"
71 #include "SMESH_Actor.h"
72 #include "SMESH_Object.h"
75 #include "QAD_Tools.h"
76 #include "QAD_Config.h"
77 #include "QAD_Settings.h"
78 #include "QAD_RightFrame.h"
79 #include "QAD_MessageBox.h"
80 #include "QAD_Resource.h"
81 #include "QAD_FileDlg.h"
82 #include "QAD_Desktop.h"
83 #include "QAD_ResourceMgr.h"
84 #include "QAD_WaitCursor.h"
86 #include "SALOME_NamingService.hxx"
87 #include "SALOME_ListIteratorOfListIO.hxx"
88 #include "SALOME_InteractiveObject.hxx"
90 #include "SALOMEGUI_Desktop.h"
91 #include "SALOMEGUI_NameDlg.h"
92 #include "SALOMEGUI_ImportOperation.h"
93 #include "SALOMEGUI_QtCatchCorbaException.hxx"
95 #include "SMESHGUI_Utils.h"
96 #include "SMESHGUI_SMESHGenUtils.h"
97 #include "SMESHGUI_GEOMGenUtils.h"
98 #include "SMESHGUI_MeshUtils.h"
99 #include "SMESHGUI_GroupUtils.h"
100 #include "SMESHGUI_FilterUtils.h"
101 #include "SMESHGUI_PatternUtils.h"
102 #include "SMESHGUI_VTKUtils.h"
104 #include "SALOMEconfig.h"
105 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
108 #define INCLUDE_MENUITEM_DEF
109 #include <qapplication.h>
110 #include <qlineedit.h>
111 #include <qmenudata.h>
112 #include <qmenubar.h>
113 #include <qpopupmenu.h>
116 #include <qpainter.h>
117 #include <qcheckbox.h>
118 #include <qcolordialog.h>
119 #include <qspinbox.h>
123 #include <qradiobutton.h>
125 #include <boost/shared_ptr.hpp>
127 #include <vtkRenderer.h>
128 #include <vtkRenderWindow.h>
129 #include <vtkActorCollection.h>
130 #include <vtkScalarBarActor.h>
131 #include <vtkUnstructuredGrid.h>
133 #include "utilities.h"
139 //=============================================================
140 void ImportMeshesFromFile(QAD_Desktop * parent,
141 SMESH::SMESH_Gen_ptr theComponentMesh,
144 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
146 void SetDisplayMode(int theCommandID);
148 void SetDisplayEntity(int theCommandID);
150 void Control( int theCommandID );
152 void SetDisplaySettings();
156 //=============================================================
157 void ImportMeshesFromFile(QAD_Desktop * parent,
158 SMESH::SMESH_Gen_ptr theComponentMesh,
164 if(theCommandID == 113){
165 filter.append(QObject::tr("MED files (*.med)"));
166 filter.append(QObject::tr("All files (*)"));
167 }else if (theCommandID == 112){
168 filter.append(QObject::tr("IDEAS files (*.unv)"));
169 }else if (theCommandID == 111){
170 filter.append(QObject::tr("DAT files (*.dat)"));
172 QString filename = QAD_FileDlg::getFileName(parent,
175 QObject::tr("Import mesh"),
177 if(!filename.isEmpty()) {
179 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
182 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
183 switch ( theCommandID ) {
186 aMeshes->length( 1 );
187 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
192 SMESH::DriverMED_ReadStatus res;
193 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
194 if ( res != SMESH::DRS_OK ) {
196 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
197 QObject::tr("SMESH_WRN_WARNING"),
198 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
199 QObject::tr("SMESH_BUT_OK"));
200 aMeshes->length( 0 );
207 bool isEmpty = false;
208 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
209 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
210 if ( !aMeshSO->_is_nil() ) {
211 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
212 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
213 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
214 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
215 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
222 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
223 QObject::tr("SMESH_WRN_WARNING"),
224 QObject::tr("SMESH_DRS_EMPTY"),
225 QObject::tr("SMESH_BUT_OK"));
229 catch (const SALOME::SALOME_Exception& S_ex){
231 QtCatchCorbaException(S_ex);
238 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
240 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
241 if(aSel->IObjectCount()){
242 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
243 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
244 if ( !aMesh->_is_nil() ) {
245 QString aFilter, aTitle = QObject::tr("Export mesh");
246 QMap<QString, SMESH::MED_VERSION> aFilterMap;
247 switch ( theCommandID ) {
249 aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
250 aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
253 aFilter = QObject::tr("DAT files (*.dat)");
256 if(aMesh->NbPyramids()){
257 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
258 QObject::tr("SMESH_WRN_WARNING"),
259 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
260 QObject::tr("SMESH_BUT_YES"),
261 QObject::tr("SMESH_BUT_NO"),
266 aFilter = QObject::tr("IDEAS files (*.unv)");
273 SMESH::MED_VERSION aFormat;
275 if ( theCommandID != 122)
276 aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
280 for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
281 filters.push_back( it.key() );
283 QAD_FileDlg* fd = new QAD_FileDlg( parent, false, true, true );
284 fd->setCaption( aTitle );
285 fd->setFilters( filters );
287 aFilename = fd->selectedFile();
288 aFormat = aFilterMap[fd->selectedFilter()];
291 if ( !aFilename.isEmpty() ) {
292 // Check whether the file already exists and delete it if yes
293 QFile aFile( aFilename );
294 if ( aFile.exists() )
297 switch ( theCommandID ) {
299 aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
302 aMesh->ExportDAT( aFilename.latin1() );
305 aMesh->ExportUNV( aFilename.latin1() );
315 inline void InverseEntityMode(unsigned int& theOutputMode,
316 unsigned int theMode)
318 bool anIsNotPresent = ~theOutputMode & theMode;
320 theOutputMode |= theMode;
322 theOutputMode &= ~theMode;
325 void SetDisplayEntity(int theCommandID){
326 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
327 if(Sel->IObjectCount() >= 1){
328 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
329 for(; It.More(); It.Next()){
330 Handle(SALOME_InteractiveObject) IObject = It.Value();
331 if(IObject->hasEntry()){
332 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
333 unsigned int aMode = anActor->GetEntityMode();
334 switch(theCommandID){
336 InverseEntityMode(aMode,SMESH_Actor::eEdges);
339 InverseEntityMode(aMode,SMESH_Actor::eFaces);
342 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
345 aMode = SMESH_Actor::eAllEntity;
349 anActor->SetEntityMode(aMode);
356 void SetDisplayMode(int theCommandID){
357 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
358 if(Sel->IObjectCount() >= 1){
359 switch(theCommandID){
361 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
362 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
366 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
367 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
370 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
371 for(; It.More(); It.Next()){
372 Handle(SALOME_InteractiveObject) IObject = It.Value();
373 if(IObject->hasEntry()){
374 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
375 switch(theCommandID){
377 anActor->SetRepresentation(SMESH_Actor::eEdge);
380 anActor->SetRepresentation(SMESH_Actor::eSurface);
383 if(anActor->IsShrunk())
386 anActor->SetShrink();
389 anActor->SetRepresentation(SMESH_Actor::ePoint);
393 anActor->GetSufaceColor(color[0], color[1], color[2]);
394 int c0 = int (color[0] * 255);
395 int c1 = int (color[1] * 255);
396 int c2 = int (color[2] * 255);
397 QColor c(c0, c1, c2);
400 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
401 c0 = int (edgecolor[0] * 255);
402 c1 = int (edgecolor[1] * 255);
403 c2 = int (edgecolor[2] * 255);
404 QColor e(c0, c1, c2);
406 float backfacecolor[3];
407 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
408 c0 = int (backfacecolor[0] * 255);
409 c1 = int (backfacecolor[1] * 255);
410 c2 = int (backfacecolor[2] * 255);
411 QColor b(c0, c1, c2);
414 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
415 c0 = int (nodecolor[0] * 255);
416 c1 = int (nodecolor[1] * 255);
417 c2 = int (nodecolor[2] * 255);
418 QColor n(c0, c1, c2);
420 int Edgewidth = (int)anActor->GetLineWidth();
423 int intValue = int(anActor->GetNodeSize());
424 float Shrink = anActor->GetShrinkFactor();
426 SMESHGUI_Preferences_ColorDlg *aDlg =
427 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
428 aDlg->SetColor(1, c);
429 aDlg->SetColor(2, e);
430 aDlg->SetColor(3, n);
431 aDlg->SetColor(4, b);
432 aDlg->SetIntValue(1, Edgewidth);
433 aDlg->SetIntValue(2, intValue);
434 aDlg->SetIntValue(3, int(Shrink*100.));
436 QColor color = aDlg->GetColor(1);
437 QColor edgecolor = aDlg->GetColor(2);
438 QColor nodecolor = aDlg->GetColor(3);
439 QColor backfacecolor = aDlg->GetColor(4);
440 /* actor color and backface color */
441 anActor->SetSufaceColor(float (color.red()) / 255.,
442 float (color.green()) / 255.,
443 float (color.blue()) / 255.);
444 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
445 float (backfacecolor.green()) / 255.,
446 float (backfacecolor.blue()) / 255.);
449 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
450 float (edgecolor.green()) / 255.,
451 float (edgecolor.blue()) / 255.);
453 /* Shrink factor and size edges */
454 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
455 anActor->SetLineWidth(aDlg->GetIntValue(1));
457 /* Nodes color and size */
458 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
459 float (nodecolor.green()) / 255.,
460 float (nodecolor.blue()) / 255.);
461 anActor->SetNodeSize(aDlg->GetIntValue(2));
470 SMESH::RepaintCurrentView();
475 void SetDisplaySettings()
477 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
478 SMESHGUI_Preferences_ColorDlg *aDlg =
479 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
482 QString SCr, SCg, SCb;
483 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
484 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
485 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
486 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
487 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
488 else color = QColor(0, 170, 255);
489 aDlg->SetColor(1, color);
491 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
492 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
493 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
494 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
495 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
496 else color = QColor(0, 170, 255);
497 aDlg->SetColor(2, color);
499 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
500 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
501 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
502 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
503 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
504 else color = Qt::red;
505 aDlg->SetColor(3, color);
507 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
508 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
509 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
510 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
511 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
512 else color = Qt::blue;
513 aDlg->SetColor(4, color);
515 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
516 if (intValue.isEmpty()) intValue = "1";
517 aDlg->SetIntValue(1, intValue.toInt());
518 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
519 if (intValue.isEmpty()) intValue = "3";
520 aDlg->SetIntValue(2, intValue.toInt());
521 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
522 if (intValue.isEmpty()) intValue = "75";
523 aDlg->SetIntValue(3, intValue.toInt());
526 QColor colorFill = aDlg->GetColor(1);
527 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
528 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
529 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
531 QColor colorOutline = aDlg->GetColor(2);
532 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
533 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
534 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
536 QColor colorNode = aDlg->GetColor(3);
537 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
538 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
539 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
541 QColor colorBackFace = aDlg->GetColor(4);
542 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
543 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
544 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
546 int width = aDlg->GetIntValue(1);
547 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
549 int nodes_size = aDlg->GetIntValue(2);
550 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
552 int shrink_coeff = aDlg->GetIntValue(3);
553 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
560 void Control( int theCommandID )
562 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
564 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
567 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
568 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
569 switch ( theCommandID ){
571 aTitle = QObject::tr( "LENGTH_EDGES" );
572 aControl = SMESH_Actor::eLength;
575 aTitle = QObject::tr( "LENGTH2D_EDGES" );
576 aControl = SMESH_Actor::eLength2D;
579 aTitle = QObject::tr( "FREE_EDGES" );
580 aControl = SMESH_Actor::eFreeEdges;
583 aTitle = QObject::tr( "FREE_BORDERS" );
584 aControl = SMESH_Actor::eFreeBorders;
587 aTitle = QObject::tr( "MULTI_BORDERS" );
588 aControl = SMESH_Actor::eMultiConnection;
591 aTitle = QObject::tr( "MULTI2D_BORDERS" );
592 aControl = SMESH_Actor::eMultiConnection2D;
595 aTitle = QObject::tr( "AREA_ELEMENTS" );
596 aControl = SMESH_Actor::eArea;
599 aTitle = QObject::tr( "TAPER_ELEMENTS" );
600 aControl = SMESH_Actor::eTaper;
603 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
604 aControl = SMESH_Actor::eAspectRatio;
607 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
608 aControl = SMESH_Actor::eAspectRatio3D;
611 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
612 aControl = SMESH_Actor::eMinimumAngle;
615 aTitle = QObject::tr( "WARP_ELEMENTS" );
616 aControl = SMESH_Actor::eWarping;
619 aTitle = QObject::tr( "SKEW_ELEMENTS" );
620 aControl = SMESH_Actor::eSkew;
623 anActor->SetControlMode(aControl);
624 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
631 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
632 MeshObjectType theType,
633 const QString theInTypeName,
634 QString & theOutTypeName)
636 SMESH_TypeFilter aTypeFilter( theType );
637 if ( aTypeFilter.IsOk( theIO )) {
638 theOutTypeName = theInTypeName;
645 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
647 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
648 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
649 if (!aSObj->_is_nil()) {
650 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
651 CORBA::String_var anID = aSComp->GetID();
652 if (!strcmp(anID.in(),theIO->getEntry()))
658 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
659 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
660 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
661 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
662 CheckOIType ( theIO, GROUP, "Group", aTypeName )
670 QString CheckHomogeneousSelection()
672 QAD_Study* aStudy = SMESH::GetActiveStudy();
673 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
676 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
677 for (; Itinit.More(); Itinit.Next())
679 List.Append(Itinit.Value());
682 QString RefType = CheckTypeObject(aSel->firstIObject());
683 SALOME_ListIteratorOfListIO It(List);
684 for (; It.More(); It.Next())
686 Handle(SALOME_InteractiveObject) IObject = It.Value();
687 QString Type = CheckTypeObject(IObject);
688 if (Type.compare(RefType) != 0)
689 return "Heterogeneous Selection";
692 aSel->ClearIObjects();
693 SALOME_ListIteratorOfListIO It1(List);
694 for (; It1.More(); It1.Next())
696 int res = aSel->AddIObject(It1.Value());
698 aStudy->highlight(It1.Value(), false);
700 aStudy->highlight(It1.Value(), true);
707 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
708 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
709 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
710 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
711 QObject::tr("ERR_ERROR"),
712 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
713 QObject::tr("BUT_OK") );
716 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
717 if (QAD_MessageBox::warn2
718 (QAD_Application::getDesktop(),
719 QObject::tr("SMESH_WRN_WARNING"),
720 QObject::tr("SMESH_REALLY_DELETE"),
721 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
724 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
725 int nbSf = anActiveStudy->getStudyFramesCount();
727 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
728 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
729 SALOMEDS::GenericAttribute_var anAttr;
730 SALOMEDS::AttributeIOR_var anIOR;
732 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
733 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
734 for(; It.More(); It.Next()){
735 Handle(SALOME_InteractiveObject) IObject = It.Value();
736 if(IObject->hasEntry()){
737 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
739 /* Erase child graphical objects */
740 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
741 for(; it->More(); it->Next()){
742 SALOMEDS::SObject_var CSO = it->Value();
743 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
744 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
746 for(int i = 0; i < nbSf; i++){
747 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
748 CORBA::String_var anEntry = CSO->GetID();
749 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
750 SMESH::RemoveActor(sf,anActor);
756 /* Erase main graphical object */
757 for(int i = 0; i < nbSf; i++){
758 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
759 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
760 SMESH::RemoveActor(sf,anActor);
764 // Remove object(s) from data structures
765 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
767 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
768 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
770 if ( !aGroup->_is_nil() ) { // DELETE GROUP
771 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
772 aMesh->RemoveGroup( aGroup );
774 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
775 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
776 aMesh->RemoveSubMesh( aSubMesh );
778 else {// default action: remove SObject from the study
779 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
780 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
782 aStudyBuilder->RemoveObjectWithChildren( obj );
787 } /* IObject->hasEntry() */
790 /* Clear any previous selection */
791 Sel->ClearIObjects();
792 anActiveStudy->updateObjBrowser();
798 //=============================================================================
802 //=============================================================================
803 class CustomItem : public QCustomMenuItem
806 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
809 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
812 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
813 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
814 p->setFont( myFont );
815 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
821 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
824 bool fullSpan() const
834 //=============================================================================
838 //=============================================================================
839 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
840 SALOMEGUI( theName, theParent )
842 myActiveDialogBox = 0 ;
845 SMESH::GetSMESHGen();
846 SMESH::GetFilterManager();
849 /* load resources for all available meshers */
850 SMESH::InitAvailableHypotheses();
853 //=============================================================================
857 //=============================================================================
858 SMESHGUI::~SMESHGUI()
860 SMESH::GetFilterManager()->Destroy();
863 //=============================================================================
867 //=============================================================================
868 SMESHGUI* SMESHGUI::GetSMESHGUI()
870 static SMESHGUI aSMESHGUI;
871 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
872 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
874 /* Automatic Update flag */
875 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
882 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
883 return SMESHGUI::GetSMESHGUI();
887 //=============================================================================
891 //=============================================================================
892 void SMESHGUI::SetState(int aState)
894 this->myState = aState;
898 //=============================================================================
902 //=============================================================================
903 void SMESHGUI::ResetState()
909 //=============================================================================
913 //=============================================================================
914 void SMESHGUI::EmitSignalDeactivateDialog()
916 emit this->SignalDeactivateActiveDialog();
920 //=============================================================================
924 //=============================================================================
925 void SMESHGUI::EmitSignalStudyFrameChanged()
927 emit this->SignalStudyFrameChanged();
931 //=============================================================================
935 //=============================================================================
936 void SMESHGUI::EmitSignalCloseAllDialogs()
938 emit SignalCloseAllDialogs();
942 //=============================================================================
946 //=============================================================================
947 QDialog *SMESHGUI::GetActiveDialogBox()
949 return this->myActiveDialogBox;
952 //=============================================================================
956 //=============================================================================
957 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
959 this->myActiveDialogBox = (QDialog *) aDlg;
963 //=============================================================================
967 //=============================================================================
968 QAD_Study *SMESHGUI::GetActiveStudy()
970 return this->myActiveStudy;
973 //=============================================================================
977 //=============================================================================
978 QAD_Desktop *SMESHGUI::GetDesktop()
980 return QAD_Application::getDesktop();
983 //=============================================================================
987 //=============================================================================
988 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
990 MESSAGE("SMESHGUI::activeStudyChanged init.");
991 QAD_Study* prevStudy = myActiveStudy;
992 /* Create or retrieve an object SMESHGUI */
993 MESSAGE("Active study changed : prev study =" << prevStudy);
994 SMESHGUI::GetSMESHGUI();
995 EmitSignalStudyFrameChanged();
996 MESSAGE("Active study changed : active study =" << myActiveStudy);
997 if ( prevStudy != myActiveStudy ) {
998 EmitSignalCloseAllDialogs();
999 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
1001 SMESH::UpdateSelectionProp();
1003 MESSAGE("SMESHGUI::activeStudyChanged done.");
1007 //=============================================================================
1011 //=============================================================================
1012 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1014 /* Here the position is on the bottom right corner - 10 */
1015 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1017 QAD_Desktop *PP = QAD_Application::getDesktop();
1018 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1019 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1023 //=============================================================================
1027 //=============================================================================
1028 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
1029 return theStudy->GetProperties()->IsLocked();
1032 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
1033 if (isStudyLocked(theStudy)) {
1034 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
1035 QObject::tr("WRN_WARNING"),
1036 QObject::tr("WRN_STUDY_LOCKED"),
1037 QObject::tr("BUT_OK") );
1043 //=======================================================================
1044 //function : CheckActiveStudyLocked
1046 //=======================================================================
1048 bool SMESHGUI::ActiveStudyLocked()
1050 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1051 return checkLock( aStudy );
1054 //=============================================================================
1058 //=============================================================================
1059 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
1061 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1063 switch (theCommandID) {
1065 if(checkLock(aStudy)) break;
1073 if(checkLock(aStudy)) break;
1074 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1078 case 122: // EXPORT MED
1082 ::ExportMeshToFile(parent, theCommandID);
1086 case 200: // SCALAR BAR
1088 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1089 if( Sel && Sel->IObjectCount() ) {
1090 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1091 if( anIO->hasEntry() ) {
1092 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1093 anActor->SetControlMode( SMESH_Actor::eNone );
1101 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1102 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1106 case 1134: // Clipping
1107 case 1133: // Tranparency
1108 case 1132: // Colors / Size
1115 ::SetDisplayMode(theCommandID);
1121 case 219: // Volumes
1122 case 220: // All Entity
1123 ::SetDisplayEntity(theCommandID);
1128 if(checkLock(aStudy)) break;
1129 SMESH::UpdateView();
1134 case 301: // DISPLAY
1135 case 302: // DISPLAY ONLY
1137 SMESH::EDisplaing anAction;
1138 switch(theCommandID){
1139 case 300: anAction = SMESH::eErase; break;
1140 case 301: anAction = SMESH::eDisplay; break;
1141 case 302: anAction = SMESH::eDisplayOnly; break;
1144 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1145 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1146 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1147 for (; It.More(); It.Next()) {
1148 Handle(SALOME_InteractiveObject) IOS = It.Value();
1149 if (IOS->hasEntry()) {
1150 SMESH::UpdateView(anAction,IOS->getEntry());
1154 Sel->ClearIObjects();
1160 if(checkLock(aStudy)) break;
1161 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1162 EmitSignalDeactivateDialog();
1163 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1164 new SMESHGUI_NodesDlg(parent, "", Sel);
1167 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1168 tr("SMESH_WRN_WARNING"),
1169 tr("SMESH_WRN_VIEWER_VTK"),
1170 tr("SMESH_BUT_OK"));
1175 case 2151: // FILTER
1177 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1179 EmitSignalDeactivateDialog();
1180 new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1185 case 406: // MOVE NODE
1187 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1189 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1190 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1194 if(checkLock(aStudy)) break;
1195 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1196 new SMESHGUI_MoveNodesDlg( parent, Sel );
1200 case 701: // COMPUTE MESH
1202 if(checkLock(aStudy)) break;
1203 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1204 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1205 int nbSel = Sel->IObjectCount();
1210 SMESH::SMESH_Mesh_var aMesh;
1211 SMESH::SMESH_subMesh_var aSubMesh;
1212 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1213 if (IObject->hasEntry()){
1214 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1215 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1216 if ( aShapeObject->_is_nil() ) {
1220 if(!aMeshSObj->_is_nil()) {
1221 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1222 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1224 if (!aMesh->_is_nil()){
1225 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1226 if (!refShapeObject->_is_nil()) {
1227 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1228 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1229 tr("SMESH_WRN_WARNING"),
1230 tr("SMESH_WRN_MISSING_PARAMETERS"),
1231 tr("SMESH_BUT_OK"));
1235 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1236 SMESH::ModifiedMesh(aMeshSObj,true);
1237 // TO Do : change icon of all submeshes
1239 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1240 tr("SMESH_WRN_WARNING"),
1241 tr("SMESH_WRN_COMPUTE_FAILED"),
1242 tr("SMESH_BUT_OK"));
1244 catch(const SALOME::SALOME_Exception & S_ex){
1245 QtCatchCorbaException(S_ex);
1248 }else if(!aSubMesh->_is_nil()){
1249 aMesh = aSubMesh->GetFather();
1250 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1251 if(!refShapeObject->_is_nil()){
1252 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1254 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1255 tr("SMESH_WRN_WARNING"),
1256 tr("SMESH_WRN_MISSING_PARAMETERS"),
1257 tr("SMESH_BUT_OK"));
1261 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1262 SMESH::ModifiedMesh(aMeshSObj,true);
1263 // TO Do : change icon of all submeshes
1265 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1266 tr("SMESH_WRN_WARNING"),
1267 tr("SMESH_WRN_COMPUTE_FAILED"),
1268 tr("SMESH_BUT_OK"));
1269 }catch(const SALOME::SALOME_Exception & S_ex){
1270 QtCatchCorbaException(S_ex);
1276 CORBA::Long anId = aStudy->StudyId();
1277 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1278 if(myAutomaticUpdate && aVisualObj){
1279 aVisualObj->Update();
1280 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1282 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1284 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1290 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1291 tr("SMESH_WRN_WARNING"),
1292 tr("SMESH_WRN_VIEWER_VTK"),
1293 tr("SMESH_BUT_OK"));
1298 case 702: // ADD SUB MESH
1300 if(checkLock(aStudy)) break;
1301 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1302 EmitSignalDeactivateDialog();
1303 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1304 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1307 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1308 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1309 tr("SMESH_BUT_OK"));
1314 case 703: // INIT MESH
1316 if(checkLock(aStudy)) break;
1317 EmitSignalDeactivateDialog();
1318 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1319 new SMESHGUI_InitMeshDlg(parent, "", Sel);
1323 case 704: // EDIT Hypothesis
1325 if(checkLock(aStudy)) break;
1326 EmitSignalDeactivateDialog();
1327 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1328 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1332 case 705: // EDIT Global Hypothesis
1334 if(checkLock(aStudy)) break;
1335 EmitSignalDeactivateDialog();
1336 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1337 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1341 case 706: // EDIT Local Hypothesis
1343 if(checkLock(aStudy)) break;
1344 EmitSignalDeactivateDialog();
1345 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1346 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1350 case 407: // DIAGONAL INVERSION
1351 case 408: // Delete diagonal
1353 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1355 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1356 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1360 if ( checkLock( aStudy ) )
1363 SALOME_Selection *aSel =
1364 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1365 /*Standard_Boolean aRes;
1366 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1367 if ( aMesh->_is_nil() )
1369 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1370 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1374 EmitSignalDeactivateDialog();
1375 if ( theCommandID == 407 )
1376 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1378 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1381 case 409: // Change orientation
1382 case 410: // Union of triangles
1383 case 411: // Cutting of quadrangles
1385 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1387 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1388 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1392 if ( checkLock( aStudy ) )
1395 SALOME_Selection *aSel =
1396 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1398 EmitSignalDeactivateDialog();
1399 SMESHGUI_MultiEditDlg* aDlg;
1400 if ( theCommandID == 409 )
1401 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1402 else if ( theCommandID == 410 )
1403 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1405 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1408 DefineDlgPosition( aDlg, x, y );
1413 case 412: // Smoothing
1415 if(checkLock(aStudy)) break;
1416 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1417 EmitSignalDeactivateDialog();
1418 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1419 new SMESHGUI_SmoothingDlg(parent, "", Sel);
1422 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1423 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1424 tr("SMESH_BUT_OK"));
1428 case 413: // Extrusion
1430 if(checkLock(aStudy)) break;
1431 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1432 EmitSignalDeactivateDialog();
1433 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1434 new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1437 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1438 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1439 tr("SMESH_BUT_OK"));
1443 case 414: // Revolution
1445 if(checkLock(aStudy)) break;
1446 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1447 EmitSignalDeactivateDialog();
1448 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1449 new SMESHGUI_RevolutionDlg(parent, "", Sel);
1452 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1453 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1454 tr("SMESH_BUT_OK"));
1458 case 415: // Pattern mapping
1460 if ( checkLock( aStudy ) )
1462 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1464 EmitSignalDeactivateDialog();
1465 SALOME_Selection *Sel = SALOME_Selection::Selection(
1466 myActiveStudy->getSelection() );
1467 new SMESHGUI_MeshPatternDlg( parent, Sel );
1470 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1471 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1472 tr("SMESH_BUT_OK"));
1476 case 416: // Extrusion along a path
1478 if(checkLock(aStudy)) break;
1479 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1480 EmitSignalDeactivateDialog();
1481 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1482 new SMESHGUI_ExtrusionAlongPathDlg(parent, Sel);
1485 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1486 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487 tr("SMESH_BUT_OK"));
1491 case 801: // CREATE GROUP
1493 if(checkLock(aStudy)) break;
1494 EmitSignalDeactivateDialog();
1495 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1496 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1497 int nbSel = Sel->IObjectCount();
1499 // check if mesh is selected
1500 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1502 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1507 case 802: // CONSTRUCT GROUP
1509 if(checkLock(aStudy)) break;
1510 EmitSignalDeactivateDialog();
1511 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1512 int nbSel = Sel->IObjectCount();
1514 // check if submesh is selected
1515 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1516 if (IObject->hasEntry()) {
1517 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1518 if(!aSObj->_is_nil()) {
1519 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1520 if (!aSubMesh->_is_nil()) {
1522 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1523 // get submesh elements list by types
1524 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1525 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1526 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1527 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1528 // create group for each type o elements
1529 QString aName = IObject->getName();
1530 if (aNodes->length() > 0) {
1531 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1532 aGroup->Add(aNodes.inout());
1534 if (aEdges->length() > 0) {
1535 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1536 aGroup->Add(aEdges.inout());
1538 if (aFaces->length() > 0) {
1539 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1540 aGroup->Add(aFaces.inout());
1542 if (aVolumes->length() > 0) {
1543 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1544 aGroup->Add(aVolumes.inout());
1546 myActiveStudy->updateObjBrowser(true);
1547 }catch(const SALOME::SALOME_Exception & S_ex){
1548 QtCatchCorbaException(S_ex);
1557 case 803: // EDIT GROUP
1559 if(checkLock(aStudy)) break;
1560 EmitSignalDeactivateDialog();
1561 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1562 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1563 SALOME_ListIteratorOfListIO It (IOs);
1564 int nbSelectedGroups = 0;
1565 for ( ; It.More(); It.Next() )
1567 SMESH::SMESH_Group_var aGroup =
1568 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1569 if (!aGroup->_is_nil()) {
1571 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1575 if (nbSelectedGroups == 0)
1577 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1583 case 804: // Add elements to group
1585 if(checkLock(aStudy)) break;
1586 if (myState == 800) {
1587 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1588 if (aDlg) aDlg->onAdd();
1593 case 805: // Remove elements from group
1595 if(checkLock(aStudy)) break;
1596 if (myState == 800) {
1597 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1598 if (aDlg) aDlg->onRemove();
1603 case 810: // Union Groups
1604 case 811: // Intersect groups
1605 case 812: // Cut groups
1607 if ( checkLock( aStudy ) )
1610 EmitSignalDeactivateDialog();
1611 SALOME_Selection *Sel = SALOME_Selection::Selection(
1612 myActiveStudy->getSelection() );
1615 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1616 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1617 else aMode = SMESHGUI_GroupOpDlg::CUT;
1619 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1623 case 813: // Delete groups with their contents
1625 if ( checkLock( aStudy ) )
1628 EmitSignalDeactivateDialog();
1629 SALOME_Selection *Sel = SALOME_Selection::Selection(
1630 myActiveStudy->getSelection() );
1632 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1636 case 900: // MESH INFOS
1638 EmitSignalDeactivateDialog();
1639 SALOME_Selection *Sel =
1640 SALOME_Selection::Selection(myActiveStudy->getSelection());
1641 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1642 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1643 SALOME_ListIteratorOfListIO It (IOs);
1644 for ( ; It.More(); It.Next() ) {
1645 Sel->ClearIObjects();
1646 Sel->AddIObject( It.Value() );
1647 new SMESHGUI_MeshInfosDlg(parent, "", false);
1649 // restore selection
1650 Sel->ClearIObjects();
1651 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1652 Sel->AddIObject( It.Value() );
1655 new SMESHGUI_MeshInfosDlg(parent, "", false);
1659 case 902: // STANDARD MESH INFOS
1661 EmitSignalDeactivateDialog();
1662 SALOME_Selection *Sel =
1663 SALOME_Selection::Selection(myActiveStudy->getSelection());
1664 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1665 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1666 SALOME_ListIteratorOfListIO It (IOs);
1667 for ( ; It.More(); It.Next() ) {
1668 Sel->ClearIObjects();
1669 Sel->AddIObject( It.Value() );
1670 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1672 // restore selection
1673 Sel->ClearIObjects();
1674 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1675 Sel->AddIObject( It.Value() );
1678 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1682 case 1001: // AUTOMATIC UPDATE PREFERENCES
1684 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1685 if (parent->menuBar()->isItemChecked(1001)) {
1686 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1687 myAutomaticUpdate = true;
1690 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1691 myAutomaticUpdate = false;
1696 case 1003: // MESH PREFERENCES
1698 ::SetDisplaySettings();
1704 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1710 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1716 parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071));
1717 if (parent->menuBar()->isItemChecked(10071)) {
1718 QAD_CONFIG->addSetting("SMESH:DispayEntity","true");
1721 QAD_CONFIG->addSetting("SMESH:DispayEntity","false");
1727 SMESHGUI_Preferences_SelectionDlg* aDlg =
1728 new SMESHGUI_Preferences_SelectionDlg(parent);
1731 QString SCr, SCg, SCb;
1732 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1733 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1734 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1735 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1736 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1737 else aColor = Qt::cyan;
1738 aDlg->SetColor(1, aColor);
1740 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1741 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1742 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1743 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1744 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1745 else aColor = Qt::yellow;
1746 aDlg->SetColor(2, aColor);
1748 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1749 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1750 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1751 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1752 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1753 else aColor = Qt::white;
1754 aDlg->SetColor(3, aColor);
1756 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1757 if (SW1.isEmpty()) SW1 = "5";
1758 aDlg->SetWidth(1, SW1.toInt());
1760 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1761 if (SW2.isEmpty()) SW2 = "5";
1762 aDlg->SetWidth(2, SW2.toInt());
1764 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1765 if (SP1.isEmpty()) SP1 = "0.025";
1766 aDlg->SetPrecision(1, SP1.toDouble());
1768 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1769 if (SP2.isEmpty()) SP2 = "0.001";
1770 aDlg->SetPrecision(2, SP2.toDouble());
1773 QColor aPreColor = aDlg->GetColor(1);
1774 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1775 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1776 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1778 QColor aSelColor = aDlg->GetColor(2);
1779 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1780 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1781 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1783 QColor aHiColor = aDlg->GetColor(3);
1784 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1785 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1786 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1788 int aPreWidth = aDlg->GetWidth(1);
1789 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1790 int aSelWidth = aDlg->GetWidth(2);
1791 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1793 double aTolNodes = aDlg->GetPrecision(1);
1794 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1795 double aTolItems = aDlg->GetPrecision(2);
1796 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1798 // update current study settings
1799 SMESH::UpdateSelectionProp();
1801 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1802 if (studyFrame->getTypeView() == VIEW_VTK) {
1803 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1804 // update VTK viewer properties
1805 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1807 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1808 aSelColor.blue()/255., aSelWidth);
1809 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1810 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1812 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1813 aPreColor.blue()/255., aPreWidth);
1816 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1817 vtkActorCollection *aCollection = aRenderer->GetActors();
1818 aCollection->InitTraversal();
1819 while(vtkActor *anAct = aCollection->GetNextActor()){
1820 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1821 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1822 aHiColor.blue()/255.);
1823 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1824 aPreColor.blue()/255.);
1833 case 1100: // EDIT HYPOTHESIS
1835 if(checkLock(aStudy)) break;
1836 SALOME_Selection *Sel =
1837 SALOME_Selection::Selection(myActiveStudy->getSelection());
1838 int nbSel = Sel->IObjectCount();
1841 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1843 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1844 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1845 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1846 if ( !Hyp->_is_nil() )
1848 char* sName = Hyp->GetName();
1849 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1852 aCreator->EditHypothesis(Hyp);
1863 case 1101: // RENAME
1865 if ( checkLock( aStudy ) )
1868 SALOME_Selection *Sel =
1869 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1871 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1872 for ( ; It.More(); It.Next() )
1874 Handle(SALOME_InteractiveObject) IObject = It.Value();
1875 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1876 SALOMEDS::GenericAttribute_var anAttr;
1877 SALOMEDS::AttributeName_var aName;
1878 if ( !obj->_is_nil() )
1880 if ( obj->FindAttribute(anAttr, "AttributeName") )
1882 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1883 QString newName = QString(aName->Value());
1884 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1885 if ( !newName.isEmpty() )
1887 myActiveStudy->renameIObject( IObject, newName );
1889 // if current object is group update group's name
1890 SMESH::SMESH_GroupBase_var aGroup =
1891 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1892 if (!aGroup->_is_nil() )
1893 aGroup->SetName( newName.latin1() );
1901 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1903 if(checkLock(aStudy)) break;
1905 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1906 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1907 for (int i = 0; It.More(); It.Next(), i++) {
1908 Handle(SALOME_InteractiveObject) IObject = It.Value();
1909 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1911 Sel->ClearIObjects();
1912 myActiveStudy->updateObjBrowser(true);
1916 case 401: // GEOM::EDGE
1917 case 4021: // TRIANGLE
1919 case 4023: // POLYGON
1922 //case 4033: // POLYHEDRON
1924 if(checkLock(aStudy)) break;
1925 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1926 EmitSignalDeactivateDialog();
1927 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1928 SMDSAbs_ElementType type = SMDSAbs_Edge;
1930 switch (theCommandID) {
1931 case 4021: // TRIANGLE
1932 type = SMDSAbs_Face; nbNodes = 3; break;
1934 type = SMDSAbs_Face; nbNodes = 4; break;
1935 case 4023: // POLYGON
1936 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
1938 type = SMDSAbs_Volume; nbNodes = 4; break;
1940 type = SMDSAbs_Volume; nbNodes = 8; break;
1941 case 4033: // POLYHEDRE
1942 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1945 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1948 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4033: // POLYHEDRON
1956 if(checkLock(aStudy)) break;
1957 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1958 EmitSignalDeactivateDialog();
1959 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1960 new SMESHGUI_CreatePolyhedralVolumeDlg(parent, "", Sel);
1963 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1964 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1965 tr("SMESH_BUT_OK"));
1969 case 4041: // REMOVES NODES
1971 if(checkLock(aStudy)) break;
1972 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1973 EmitSignalDeactivateDialog();
1974 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1975 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1978 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1979 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1980 tr("SMESH_BUT_OK"));
1984 case 4042: // REMOVES ELEMENTS
1986 if(checkLock(aStudy)) break;
1987 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1988 EmitSignalDeactivateDialog();
1989 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1990 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1994 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1995 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1996 tr("SMESH_BUT_OK"));
2000 case 4051: // RENUMBERING NODES
2002 if(checkLock(aStudy)) break;
2003 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2004 EmitSignalDeactivateDialog();
2005 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2006 new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
2010 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2011 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2012 tr("SMESH_BUT_OK"));
2016 case 4052: // RENUMBERING ELEMENTS
2018 if(checkLock(aStudy)) break;
2019 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2020 EmitSignalDeactivateDialog();
2021 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2022 new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
2026 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2027 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2028 tr("SMESH_BUT_OK"));
2032 case 4061: // TRANSLATION
2034 if(checkLock(aStudy)) break;
2035 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2036 EmitSignalDeactivateDialog();
2037 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2038 new SMESHGUI_TranslationDlg(parent, "", Sel);
2041 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043 tr("SMESH_BUT_OK"));
2047 case 4062: // ROTATION
2049 if(checkLock(aStudy)) break;
2050 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2051 EmitSignalDeactivateDialog();
2052 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2053 new SMESHGUI_RotationDlg(parent, "", Sel);
2056 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2057 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2058 tr("SMESH_BUT_OK"));
2062 case 4063: // SYMMETRY
2064 if(checkLock(aStudy)) break;
2065 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2066 EmitSignalDeactivateDialog();
2067 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2068 new SMESHGUI_SymmetryDlg(parent, "", Sel);
2071 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073 tr("SMESH_BUT_OK"));
2077 case 4064: // SEWING
2079 if(checkLock(aStudy)) break;
2080 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2081 EmitSignalDeactivateDialog();
2082 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2083 new SMESHGUI_SewingDlg(parent, "", Sel);
2086 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2087 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2088 tr("SMESH_BUT_OK"));
2092 case 4065: // MERGE NODES
2094 if(checkLock(aStudy)) break;
2095 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2096 EmitSignalDeactivateDialog();
2097 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2098 new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2101 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2102 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2103 tr("SMESH_BUT_OK"));
2109 case 5000: // HYPOTHESIS
2111 if(checkLock(aStudy)) break;
2112 EmitSignalDeactivateDialog();
2113 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2118 if(checkLock(aStudy)) break;
2119 EmitSignalDeactivateDialog();
2120 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2124 case 5105: // Library of selection filters
2126 static QValueList<int> aTypes;
2127 if ( aTypes.isEmpty() )
2129 aTypes.append( SMESH::NODE );
2130 aTypes.append( SMESH::EDGE );
2131 aTypes.append( SMESH::FACE );
2132 aTypes.append( SMESH::VOLUME );
2134 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2138 case 6017: // CONTROLS
2151 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2152 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2153 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2154 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2155 if ( !SO->_is_nil() ) {
2156 CORBA::Object_var aObject = SO->GetObject();
2157 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2158 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2159 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2160 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2161 ::Control( theCommandID );
2166 QAD_MessageBox::warn1(GetDesktop(),
2167 tr( "SMESH_WRN_WARNING" ),
2168 tr( "SMESH_BAD_SELECTION" ),
2169 tr( "SMESH_BUT_OK" ) );
2173 QAD_MessageBox::warn1(GetDesktop(),
2174 tr( "SMESH_WRN_WARNING" ),
2175 tr( "NOT_A_VTK_VIEWER" ),
2176 tr( "SMESH_BUT_OK" ) );
2181 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2182 if (Sel->IObjectCount() == 1) {
2183 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2184 if(anIObject->hasEntry())
2185 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2186 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2193 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2194 if (Sel->IObjectCount() == 1) {
2195 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2196 if(anIObject->hasEntry())
2197 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2198 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2203 case 10001: // DISPLAY MODE PREFERENCE
2206 parent->menuBar()->setItemChecked(10001, true);
2207 parent->menuBar()->setItemChecked(10002, false);
2208 parent->menuBar()->setItemChecked(10004, false);
2209 parent->menuBar()->setItemEnabled(10003, true);
2210 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2215 parent->menuBar()->setItemChecked(10002, true);
2216 parent->menuBar()->setItemChecked(10001, false);
2217 parent->menuBar()->setItemChecked(10004, false);
2218 parent->menuBar()->setItemEnabled(10003, true);
2219 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2224 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2225 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2230 parent->menuBar()->setItemChecked(10001, false);
2231 parent->menuBar()->setItemChecked(10004, true);
2232 parent->menuBar()->setItemChecked(10002, false);
2233 parent->menuBar()->setItemEnabled(10003, false);
2234 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2240 myActiveStudy->updateObjBrowser(true);
2244 //=============================================================================
2248 //=============================================================================
2249 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2250 QAD_StudyFrame * studyFrame)
2255 //=============================================================================
2259 //=============================================================================
2260 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2261 QAD_StudyFrame * studyFrame)
2266 //=============================================================================
2270 //=============================================================================
2271 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2272 QAD_StudyFrame * studyFrame)
2277 //=============================================================================
2281 //=============================================================================
2282 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2284 MESSAGE("SMESHGUI::SetSettings.");
2285 SMESHGUI::GetSMESHGUI();
2288 QString DisplayMode = "Shading";
2289 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2290 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2292 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2294 bool Shrink = false;
2295 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2296 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2298 if (DisplayMode == "Wireframe") {
2300 parent->menuBar()->setItemChecked(10004, false);
2301 parent->menuBar()->setItemChecked(10002, false);
2302 parent->menuBar()->setItemChecked(10001, true);
2303 parent->menuBar()->setItemEnabled(10003, true);
2305 else if (DisplayMode == "Nodes") {
2307 parent->menuBar()->setItemChecked(10004, true);
2308 parent->menuBar()->setItemChecked(10002, false);
2309 parent->menuBar()->setItemChecked(10001, false);
2310 parent->menuBar()->setItemEnabled(10003, false);
2313 // default is shading
2314 parent->menuBar()->setItemChecked(10004, false);
2315 parent->menuBar()->setItemChecked(10002, true);
2316 parent->menuBar()->setItemChecked(10001, false);
2317 parent->menuBar()->setItemEnabled(10003, true);
2319 parent->menuBar()->setItemChecked(10003, Shrink);
2321 /* Automatic Update */
2322 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2323 if (AutoUpdate.compare("true") == 0) {
2324 parent->menuBar()->setItemChecked(1001, true);
2325 myAutomaticUpdate = true;
2328 parent->menuBar()->setItemChecked(1001, false);
2329 myAutomaticUpdate = false;
2332 QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity");
2333 if(anIsDisplayEntity.compare("true") == 0)
2334 parent->menuBar()->setItemChecked(10071,true);
2336 parent->menuBar()->setItemChecked(10071,false);
2339 SMESH::UpdateSelectionProp();
2342 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2343 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2348 //=============================================================================
2352 //=============================================================================
2353 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2355 // NRI : Temporary added
2356 // if ( myStudy->GetProperties()->IsLocked() ) {
2357 // theObject = "NothingSelected";
2358 // theContext = "NothingSelected";
2362 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2363 int nbSel = Sel->IObjectCount();
2366 theObject = "NothingSelected";
2367 theContext = "NothingSelected";
2370 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2371 theObject = "Elements";
2373 theObject = ::CheckTypeObject( Sel->firstIObject() );
2377 theObject = ::CheckHomogeneousSelection();
2382 //=============================================================================
2386 //=============================================================================
2387 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2388 const QString& theParent, const QString& theObject)
2390 // get active study frame
2391 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2393 // get parent component which selected object(s) belongs to
2394 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2397 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2398 int nbSel = Sel->IObjectCount();
2403 else if ( nbSel == 1 ) {
2404 if ( parentComp != parent->getActiveComponent() ) {
2405 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2407 int id = popup->idAt( 0 );
2408 if ( id <= QAD_TopLabel_Popup_ID )
2409 popup->removeItemAt( 0 );
2415 // get selected interactive object
2416 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2417 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2418 // find popup menu's TopLabel item
2419 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2420 if ( topItem >= 0 ) {
2421 if ( theParent == "Viewer" ) {
2422 // set bold font for popup menu's TopLabel item (Viewer popup)
2423 QFont fnt = popup->font(); fnt.setBold( TRUE );
2424 popup->removeItem( QAD_TopLabel_Popup_ID );
2425 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2427 else if ( theParent == "ObjectBrowser" ) {
2428 // remove popup menu's TopLabel item (Object Browser popup)
2429 popup->removeItem( QAD_TopLabel_Popup_ID );
2433 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2434 // remove Display/Erase commands
2435 popup->removeItem( QAD_Display_Popup_ID );
2436 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2437 popup->removeItem( QAD_Erase_Popup_ID );
2438 // remove "Unassign ..." command if hyp/algo is not assigned
2439 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2440 popup->removeItem( 1102 );
2442 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2444 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2445 if ( aShapeObject->_is_nil() ) {
2447 popup->removeItem( 701 ); // Compute
2448 popup->removeItem( 705 ); // Edit hypothesis
2449 popup->removeItem( 706 ); // ...
2451 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2452 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2453 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2454 popup->removeItem( 803 ); // EDIT GROUP
2456 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2457 // if object has actor
2458 if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2459 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2460 if ( myRenderInter->isVisible( IObject ) ) {
2461 popup->removeItem( QAD_Display_Popup_ID );
2462 popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
2463 popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
2464 TVisualObjPtr aVisualObj = anActor->GetObject();
2465 int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
2466 int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
2467 int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
2469 QMenuItem* mi = popup->findItem( 1131 );
2470 if ( mi && mi->popup() ) {
2471 int prType = anActor->GetRepresentation();
2472 // Display Mode / Wireframe
2473 if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2474 mi->popup()->removeItem( 211 );
2476 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2478 // Display Mode / Shading
2479 if(aNbFaces == 0 && aNbVolumes == 0){
2480 mi->popup()->removeItem( 212 );
2482 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2484 // Display Mode / Points
2485 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2486 // Display Mode / Shrink
2487 bool isShrunk = anActor->IsShrunk();
2488 bool isShrunkable = anActor->IsShrunkable();
2489 mi->popup()->setItemChecked( 213, isShrunk );
2490 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2494 mi = popup->findItem( 1135 );
2496 if (aNbVolumes>0) aIsSomething++;
2497 if (aNbFaces>0) aIsSomething++;
2498 if (aNbEdges>0) aIsSomething++;
2499 if ( mi && (aIsSomething <= 1)){
2500 popup->removeItem(1135);
2501 }else if ( mi && mi->popup() ) {
2502 QPopupMenu* aPopup = mi->popup();
2503 unsigned int aMode = anActor->GetEntityMode();
2505 bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes;
2506 bool aIsFacesMode = aMode & SMESH_Actor::eFaces;
2507 bool aIsEdgesMode = aMode & SMESH_Actor::eEdges;
2510 aPopup->removeItem( 219 );
2512 aPopup->setItemChecked( 219, aIsVolumesMode );
2515 aPopup->removeItem( 218 );
2517 aPopup->setItemChecked( 218, aIsFacesMode );
2521 aPopup->removeItem( 217 );
2523 aPopup->setItemChecked( 217, aIsEdgesMode );
2526 bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode);
2527 aIsRemove &= (aNbFaces == 0 || aIsFacesMode);
2528 aIsRemove &= (aNbEdges == 0 || aIsEdgesMode);
2531 aPopup->removeItem( 220 );
2535 mi = popup->findItem( 2000 );
2536 if ( mi && mi->popup() ) {
2537 SMESH_Actor::eControl cMode = anActor->GetControlMode();
2539 case SMESH_Actor::eLength:
2540 mi->popup()->setItemChecked( 6001, true ); break;
2541 case SMESH_Actor::eLength2D:
2542 mi->popup()->setItemChecked( 6018, true ); break;
2543 case SMESH_Actor::eFreeEdges:
2544 mi->popup()->setItemChecked( 6002, true );
2545 mi->popup()->removeItem( 201 );
2547 case SMESH_Actor::eFreeBorders:
2548 mi->popup()->setItemChecked( 6003, true );
2549 mi->popup()->removeItem( 201 );
2551 case SMESH_Actor::eMultiConnection:
2552 mi->popup()->setItemChecked( 6004, true ); break;
2553 case SMESH_Actor::eMultiConnection2D:
2554 mi->popup()->setItemChecked( 6019, true ); break;
2555 case SMESH_Actor::eArea:
2556 mi->popup()->setItemChecked( 6011, true ); break;
2557 case SMESH_Actor::eTaper:
2558 mi->popup()->setItemChecked( 6012, true ); break;
2559 case SMESH_Actor::eAspectRatio:
2560 mi->popup()->setItemChecked( 6013, true ); break;
2561 case SMESH_Actor::eAspectRatio3D:
2562 mi->popup()->setItemChecked( 6017, true ); break;
2563 case SMESH_Actor::eMinimumAngle:
2564 mi->popup()->setItemChecked( 6014, true ); break;
2565 case SMESH_Actor::eWarping:
2566 mi->popup()->setItemChecked( 6015, true ); break;
2567 case SMESH_Actor::eSkew:
2568 mi->popup()->setItemChecked( 6016, true ); break;
2569 case SMESH_Actor::eNone:
2571 mi->popup()->removeItem( 200 );
2572 mi->popup()->removeItem( 201 );
2575 TVisualObjPtr aVisualObj = anActor->GetObject();
2577 mi->popup()->removeItem( 6001 );
2578 mi->popup()->removeItem( 6003 );
2579 mi->popup()->removeItem( 6004 );
2582 mi->popup()->removeItem( 6018 );
2583 mi->popup()->removeItem( 6002 );
2584 mi->popup()->removeItem( 6011 );
2585 mi->popup()->removeItem( 6012 );
2586 mi->popup()->removeItem( 6013 );
2587 mi->popup()->removeItem( 6014 );
2588 mi->popup()->removeItem( 6015 );
2589 mi->popup()->removeItem( 6016 );
2590 mi->popup()->removeItem( 6019 );
2592 if(aNbVolumes == 0){
2593 mi->popup()->removeItem( 6017 );
2595 if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2596 popup->removeItem( 2000 ); // Scalar Bar
2600 popup->removeItem( QAD_Erase_Popup_ID );
2601 popup->removeItem( 114 ); // Numbering popup menu
2602 popup->removeItem( 1131 ); // Display mode
2603 popup->removeItem( 1132 ); // Color / size
2604 popup->removeItem( 1133 ); // Transparency
2605 popup->removeItem( 1134 ); // Clipping
2606 popup->removeItem( 2000 ); // Scalar Bar
2608 // VSR 03/02/05 - check if actor is empty ----- start -----
2609 vtkUnstructuredGrid* vtkGrid = anActor->GetUnstructuredGrid();
2610 if ( vtkGrid->GetNumberOfPoints() + vtkGrid->GetNumberOfCells() == 0 ) {
2611 popup->removeItem( QAD_Display_Popup_ID );
2612 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2613 popup->removeItem( QAD_Erase_Popup_ID );
2615 // VSR 03/02/05 - check if actor is empty ----- finish -----
2618 // object doesn't have actor
2619 CORBA::Object_var anObject = SO->GetObject();
2620 bool bDisplay = false;
2621 if ( !CORBA::is_nil( anObject ) ) {
2622 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2623 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2625 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2626 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2628 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2629 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2633 popup->removeItem( QAD_Display_Popup_ID );
2634 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2636 popup->removeItem( QAD_Erase_Popup_ID );
2637 popup->removeItem( 114 ); // Numbering popup menu
2638 popup->removeItem( 1131 ); // Display mode
2639 popup->removeItem( 1132 ); // Color / size
2640 popup->removeItem( 1133 ); // Transparency
2641 popup->removeItem( 1134 ); // Clipping
2642 popup->removeItem( 2000 ); // Scalar Bar
2645 else if( theObject!="Component" ) {
2646 // another SMESH object
2647 popup->removeItem( QAD_Display_Popup_ID );
2648 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2649 popup->removeItem( QAD_Erase_Popup_ID );
2654 // multiple selection
2655 if ( parentComp != parent->getActiveComponent() ) {
2656 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2658 int id = popup->idAt( 0 );
2659 if ( id <= QAD_TopLabel_Popup_ID )
2660 popup->removeItemAt( 0 );
2664 if ( parentComp.isNull() ) {
2665 // objects from different components are selected
2666 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2667 popup->removeItem( QAD_Display_Popup_ID );
2668 popup->removeItem( QAD_Erase_Popup_ID );
2672 QString type = ::CheckHomogeneousSelection();
2673 if ( type != "Heterogeneous Selection" ) {
2674 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2675 if ( topItem >= 0 ) {
2676 // set bold font for popup menu's TopLabel item
2677 QFont fnt = popup->font(); fnt.setBold( TRUE );
2678 popup->removeItem( QAD_TopLabel_Popup_ID );
2679 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2687 //=============================================================================
2688 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2689 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2691 //=============================================================================
2692 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2695 if(theIO->hasEntry()){
2696 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2697 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2698 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2702 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2704 if (!buffer || !bufferSize)
2706 buffer[0] = (int)VIEW_VTK;
2709 void SMESHGUI::Deactivate()
2711 if ( SMESHGUI::GetSMESHGUI() ) {
2712 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();