1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI
28 #include "SMESHGUI_InitMeshDlg.h"
29 #include "SMESHGUI_AddSubMeshDlg.h"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_HypothesesUtils.h"
43 #include "SMESHGUI_MoveNodesDlg.h"
44 #include "SMESHGUI_AddMeshElementDlg.h"
45 #include "SMESHGUI_EditHypothesesDlg.h"
46 #include "SMESHGUI_CreateHypothesesDlg.h"
47 #include "SMESHGUI_FilterDlg.h"
48 #include "SMESHGUI_FilterLibraryDlg.h"
49 #include "SMESHGUI_SingleEditDlg.h"
50 #include "SMESHGUI_MultiEditDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_DeleteGroupDlg.h"
53 #include "SMESHGUI_SmoothingDlg.h"
54 #include "SMESHGUI_RenumberingDlg.h"
55 #include "SMESHGUI_ExtrusionDlg.h"
56 #include "SMESHGUI_RevolutionDlg.h"
57 #include "SMESHGUI_TranslationDlg.h"
58 #include "SMESHGUI_RotationDlg.h"
59 #include "SMESHGUI_SymmetryDlg.h"
60 #include "SMESHGUI_SewingDlg.h"
61 #include "SMESHGUI_MergeNodesDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_PrecisionDlg.h"
65 #include "VTKViewer_ViewFrame.h"
66 #include "VTKViewer_InteractorStyleSALOME.h"
67 #include "VTKViewer_RenderWindowInteractor.h"
69 #include "SMESH_Actor.h"
70 #include "SMESH_Object.h"
73 #include "QAD_Tools.h"
74 #include "QAD_Config.h"
75 #include "QAD_Settings.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_Resource.h"
79 #include "QAD_FileDlg.h"
80 #include "QAD_Desktop.h"
81 #include "QAD_ResourceMgr.h"
82 #include "QAD_WaitCursor.h"
84 #include "SALOME_NamingService.hxx"
85 #include "SALOME_ListIteratorOfListIO.hxx"
86 #include "SALOME_InteractiveObject.hxx"
88 #include "SALOMEGUI_Desktop.h"
89 #include "SALOMEGUI_NameDlg.h"
90 #include "SALOMEGUI_ImportOperation.h"
91 #include "SALOMEGUI_QtCatchCorbaException.hxx"
93 #include "SMESHGUI_Utils.h"
94 #include "SMESHGUI_SMESHGenUtils.h"
95 #include "SMESHGUI_GEOMGenUtils.h"
96 #include "SMESHGUI_MeshUtils.h"
97 #include "SMESHGUI_GroupUtils.h"
98 #include "SMESHGUI_FilterUtils.h"
99 #include "SMESHGUI_PatternUtils.h"
100 #include "SMESHGUI_VTKUtils.h"
102 #include "SALOMEconfig.h"
103 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
106 #define INCLUDE_MENUITEM_DEF
107 #include <qapplication.h>
108 #include <qlineedit.h>
109 #include <qmenudata.h>
110 #include <qmenubar.h>
111 #include <qpopupmenu.h>
114 #include <qpainter.h>
115 #include <qcheckbox.h>
116 #include <qcolordialog.h>
117 #include <qspinbox.h>
121 #include <qradiobutton.h>
123 #include <boost/shared_ptr.hpp>
125 #include <vtkRenderer.h>
126 #include <vtkRenderWindow.h>
127 #include <vtkActorCollection.h>
128 #include <vtkScalarBarActor.h>
130 #include "utilities.h"
136 //=============================================================
137 void ImportMeshesFromFile(QAD_Desktop * parent,
138 SMESH::SMESH_Gen_ptr theComponentMesh,
141 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
143 void SetDisplayMode(int theCommandID);
145 void SetDisplayEntity(int theCommandID);
147 void Control( int theCommandID );
149 void SetDisplaySettings();
153 //=============================================================
154 void ImportMeshesFromFile(QAD_Desktop * parent,
155 SMESH::SMESH_Gen_ptr theComponentMesh,
161 if(theCommandID == 113){
162 filter = QObject::tr("MED files (*.med)");
163 }else if (theCommandID == 112){
164 filter = QObject::tr("IDEAS files (*.unv)");
165 }else if (theCommandID == 111){
166 filter = QObject::tr("DAT files (*.dat)");
168 QString filename = QAD_FileDlg::getFileName(parent,
171 QObject::tr("Import mesh"),
173 if(!filename.isEmpty()) {
175 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
178 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
179 switch ( theCommandID ) {
182 aMeshes->length( 1 );
183 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
188 SMESH::DriverMED_ReadStatus res;
189 aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
190 if ( res != SMESH::DRS_OK ) {
192 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
193 QObject::tr("SMESH_WRN_WARNING"),
194 QObject::tr(QString("SMESH_DRS_%1").arg(res)),
195 QObject::tr("SMESH_BUT_OK"));
196 aMeshes->length( 0 );
203 bool isEmpty = false;
204 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
205 SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
206 if ( !aMeshSO->_is_nil() ) {
207 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
208 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
209 aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
210 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
211 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
218 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
219 QObject::tr("SMESH_WRN_WARNING"),
220 QObject::tr("SMESH_DRS_EMPTY"),
221 QObject::tr("SMESH_BUT_OK"));
225 catch (const SALOME::SALOME_Exception& S_ex){
227 QtCatchCorbaException(S_ex);
234 void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
236 SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
237 if(aSel->IObjectCount()){
238 Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
239 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
240 if ( !aMesh->_is_nil() ) {
241 QString aFilter, aTitle = QObject::tr("Export mesh");
242 switch ( theCommandID ) {
244 aFilter = QObject::tr("MED files (*.med)");
247 aFilter = QObject::tr("DAT files (*.dat)");
250 if(aMesh->NbPyramids()){
251 int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
252 QObject::tr("SMESH_WRN_WARNING"),
253 QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
254 QObject::tr("SMESH_BUT_YES"),
255 QObject::tr("SMESH_BUT_NO"),
260 aFilter = QObject::tr("IDEAS files (*.unv)");
266 QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
267 if ( !aFilename.isEmpty() ) {
268 // Check whether the file already exists and delete it if yes
269 QFile aFile( aFilename );
270 if ( aFile.exists() )
273 switch ( theCommandID ) {
275 aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
278 aMesh->ExportDAT( aFilename.latin1() );
281 aMesh->ExportUNV( aFilename.latin1() );
291 inline void InverseEntityMode(unsigned int& theOutputMode,
292 unsigned int theMode)
294 bool anIsNotPresent = ~theOutputMode & theMode;
296 theOutputMode |= theMode;
298 theOutputMode &= ~theMode;
301 void SetDisplayEntity(int theCommandID){
302 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
303 if(Sel->IObjectCount() >= 1){
304 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
305 for(; It.More(); It.Next()){
306 Handle(SALOME_InteractiveObject) IObject = It.Value();
307 if(IObject->hasEntry()){
308 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
309 unsigned int aMode = anActor->GetEntityMode();
310 switch(theCommandID){
312 InverseEntityMode(aMode,SMESH_Actor::eEdges);
315 InverseEntityMode(aMode,SMESH_Actor::eFaces);
318 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
321 aMode = SMESH_Actor::eAllEntity;
325 anActor->SetEntityMode(aMode);
332 void SetDisplayMode(int theCommandID){
333 SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
334 if(Sel->IObjectCount() >= 1){
335 switch(theCommandID){
337 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
338 new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
342 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
343 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
346 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
347 for(; It.More(); It.Next()){
348 Handle(SALOME_InteractiveObject) IObject = It.Value();
349 if(IObject->hasEntry()){
350 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
351 switch(theCommandID){
353 anActor->SetRepresentation(SMESH_Actor::eEdge);
356 anActor->SetRepresentation(SMESH_Actor::eSurface);
359 if(anActor->IsShrunk())
362 anActor->SetShrink();
365 anActor->SetRepresentation(SMESH_Actor::ePoint);
369 anActor->GetSufaceColor(color[0], color[1], color[2]);
370 int c0 = int (color[0] * 255);
371 int c1 = int (color[1] * 255);
372 int c2 = int (color[2] * 255);
373 QColor c(c0, c1, c2);
376 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
377 c0 = int (edgecolor[0] * 255);
378 c1 = int (edgecolor[1] * 255);
379 c2 = int (edgecolor[2] * 255);
380 QColor e(c0, c1, c2);
382 float backfacecolor[3];
383 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
384 c0 = int (backfacecolor[0] * 255);
385 c1 = int (backfacecolor[1] * 255);
386 c2 = int (backfacecolor[2] * 255);
387 QColor b(c0, c1, c2);
390 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
391 c0 = int (nodecolor[0] * 255);
392 c1 = int (nodecolor[1] * 255);
393 c2 = int (nodecolor[2] * 255);
394 QColor n(c0, c1, c2);
396 int Edgewidth = (int)anActor->GetLineWidth();
399 int intValue = int(anActor->GetNodeSize());
400 float Shrink = anActor->GetShrinkFactor();
402 SMESHGUI_Preferences_ColorDlg *aDlg =
403 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
404 aDlg->SetColor(1, c);
405 aDlg->SetColor(2, e);
406 aDlg->SetColor(3, n);
407 aDlg->SetColor(4, b);
408 aDlg->SetIntValue(1, Edgewidth);
409 aDlg->SetIntValue(2, intValue);
410 aDlg->SetIntValue(3, int(Shrink*100.));
412 QColor color = aDlg->GetColor(1);
413 QColor edgecolor = aDlg->GetColor(2);
414 QColor nodecolor = aDlg->GetColor(3);
415 QColor backfacecolor = aDlg->GetColor(4);
416 /* actor color and backface color */
417 anActor->SetSufaceColor(float (color.red()) / 255.,
418 float (color.green()) / 255.,
419 float (color.blue()) / 255.);
420 anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
421 float (backfacecolor.green()) / 255.,
422 float (backfacecolor.blue()) / 255.);
425 anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
426 float (edgecolor.green()) / 255.,
427 float (edgecolor.blue()) / 255.);
429 /* Shrink factor and size edges */
430 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
431 anActor->SetLineWidth(aDlg->GetIntValue(1));
433 /* Nodes color and size */
434 anActor->SetNodeColor(float (nodecolor.red()) / 255.,
435 float (nodecolor.green()) / 255.,
436 float (nodecolor.blue()) / 255.);
437 anActor->SetNodeSize(aDlg->GetIntValue(2));
446 SMESH::RepaintCurrentView();
451 void SetDisplaySettings()
453 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
454 SMESHGUI_Preferences_ColorDlg *aDlg =
455 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
458 QString SCr, SCg, SCb;
459 SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
460 SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
461 SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
462 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
463 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
464 else color = QColor(0, 170, 255);
465 aDlg->SetColor(1, color);
467 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
468 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
469 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
470 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
471 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
472 else color = QColor(0, 170, 255);
473 aDlg->SetColor(2, color);
475 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
476 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
477 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
478 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
479 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
480 else color = Qt::red;
481 aDlg->SetColor(3, color);
483 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
484 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
485 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
486 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
487 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
488 else color = Qt::blue;
489 aDlg->SetColor(4, color);
491 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
492 if (intValue.isEmpty()) intValue = "1";
493 aDlg->SetIntValue(1, intValue.toInt());
494 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
495 if (intValue.isEmpty()) intValue = "3";
496 aDlg->SetIntValue(2, intValue.toInt());
497 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
498 if (intValue.isEmpty()) intValue = "75";
499 aDlg->SetIntValue(3, intValue.toInt());
502 QColor colorFill = aDlg->GetColor(1);
503 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
504 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
505 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
507 QColor colorOutline = aDlg->GetColor(2);
508 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
509 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
510 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
512 QColor colorNode = aDlg->GetColor(3);
513 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
514 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
515 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
517 QColor colorBackFace = aDlg->GetColor(4);
518 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
519 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
520 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
522 int width = aDlg->GetIntValue(1);
523 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
525 int nodes_size = aDlg->GetIntValue(2);
526 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
528 int shrink_coeff = aDlg->GetIntValue(3);
529 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
536 void Control( int theCommandID )
538 SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
540 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
543 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
544 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
545 switch ( theCommandID ){
547 aTitle = QObject::tr( "LENGTH_EDGES" );
548 aControl = SMESH_Actor::eLengthEdges;
551 aTitle = QObject::tr( "FREE_EDGES" );
552 aControl = SMESH_Actor::eFreeEdges;
555 aTitle = QObject::tr( "FREE_BORDERS" );
556 aControl = SMESH_Actor::eFreeBorders;
559 aTitle = QObject::tr( "MULTI_BORDERS" );
560 aControl = SMESH_Actor::eMultiConnection;
563 aTitle = QObject::tr( "AREA_ELEMENTS" );
564 aControl = SMESH_Actor::eArea;
567 aTitle = QObject::tr( "TAPER_ELEMENTS" );
568 aControl = SMESH_Actor::eTaper;
571 aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
572 aControl = SMESH_Actor::eAspectRatio;
575 aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
576 aControl = SMESH_Actor::eAspectRatio3D;
579 aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
580 aControl = SMESH_Actor::eMinimumAngle;
583 aTitle = QObject::tr( "WARP_ELEMENTS" );
584 aControl = SMESH_Actor::eWarping;
587 aTitle = QObject::tr( "SKEW_ELEMENTS" );
588 aControl = SMESH_Actor::eSkew;
591 anActor->SetControlMode(aControl);
592 anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
599 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
600 MeshObjectType theType,
601 const QString theInTypeName,
602 QString & theOutTypeName)
604 SMESH_TypeFilter aTypeFilter( theType );
605 if ( aTypeFilter.IsOk( theIO )) {
606 theOutTypeName = theInTypeName;
613 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
615 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
616 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
617 if (!aSObj->_is_nil()) {
618 SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
619 CORBA::String_var anID = aSComp->GetID();
620 if (!strcmp(anID.in(),theIO->getEntry()))
626 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
627 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
628 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
629 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
630 CheckOIType ( theIO, GROUP, "Group", aTypeName )
638 QString CheckHomogeneousSelection()
640 QAD_Study* aStudy = SMESH::GetActiveStudy();
641 SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
644 SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
645 for (; Itinit.More(); Itinit.Next())
647 List.Append(Itinit.Value());
650 QString RefType = CheckTypeObject(aSel->firstIObject());
651 SALOME_ListIteratorOfListIO It(List);
652 for (; It.More(); It.Next())
654 Handle(SALOME_InteractiveObject) IObject = It.Value();
655 QString Type = CheckTypeObject(IObject);
656 if (Type.compare(RefType) != 0)
657 return "Heterogeneous Selection";
660 aSel->ClearIObjects();
661 SALOME_ListIteratorOfListIO It1(List);
662 for (; It1.More(); It1.Next())
664 int res = aSel->AddIObject(It1.Value());
666 aStudy->highlight(It1.Value(), false);
668 aStudy->highlight(It1.Value(), true);
675 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
676 QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
677 if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
678 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
679 QObject::tr("ERR_ERROR"),
680 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
681 QObject::tr("BUT_OK") );
684 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
685 if (QAD_MessageBox::warn2
686 (QAD_Application::getDesktop(),
687 QObject::tr("SMESH_WRN_WARNING"),
688 QObject::tr("SMESH_REALLY_DELETE"),
689 QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
692 QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
693 int nbSf = anActiveStudy->getStudyFramesCount();
695 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
696 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
697 SALOMEDS::GenericAttribute_var anAttr;
698 SALOMEDS::AttributeIOR_var anIOR;
700 SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
701 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
702 for(; It.More(); It.Next()){
703 Handle(SALOME_InteractiveObject) IObject = It.Value();
704 if(IObject->hasEntry()){
705 SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
707 /* Erase child graphical objects */
708 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
709 for(; it->More(); it->Next()){
710 SALOMEDS::SObject_var CSO = it->Value();
711 if(CSO->FindAttribute(anAttr, "AttributeIOR")){
712 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
714 for(int i = 0; i < nbSf; i++){
715 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
716 CORBA::String_var anEntry = CSO->GetID();
717 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
718 SMESH::RemoveActor(sf,anActor);
724 /* Erase main graphical object */
725 for(int i = 0; i < nbSf; i++){
726 QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
727 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
728 SMESH::RemoveActor(sf,anActor);
732 // Remove object(s) from data structures
733 SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
735 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
736 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
738 if ( !aGroup->_is_nil() ) { // DELETE GROUP
739 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
740 aMesh->RemoveGroup( aGroup );
742 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
743 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
744 aMesh->RemoveSubMesh( aSubMesh );
746 else {// default action: remove SObject from the study
747 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
748 //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
750 aStudyBuilder->RemoveObjectWithChildren( obj );
755 } /* IObject->hasEntry() */
758 /* Clear any previous selection */
759 Sel->ClearIObjects();
760 anActiveStudy->updateObjBrowser();
766 //=============================================================================
770 //=============================================================================
771 class CustomItem : public QCustomMenuItem
774 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
777 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
780 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
781 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
782 p->setFont( myFont );
783 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
789 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
792 bool fullSpan() const
802 //=============================================================================
806 //=============================================================================
807 SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
808 SALOMEGUI( theName, theParent )
810 myActiveDialogBox = 0 ;
813 SMESH::GetSMESHGen();
814 SMESH::GetFilterManager();
817 /* load resources for all available meshers */
818 SMESH::InitAvailableHypotheses();
821 //=============================================================================
825 //=============================================================================
826 SMESHGUI::~SMESHGUI()
828 SMESH::GetFilterManager()->Destroy();
831 //=============================================================================
835 //=============================================================================
836 SMESHGUI* SMESHGUI::GetSMESHGUI()
838 static SMESHGUI aSMESHGUI;
839 aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
840 SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
842 /* Automatic Update flag */
843 aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
850 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
851 return SMESHGUI::GetSMESHGUI();
855 //=============================================================================
859 //=============================================================================
860 void SMESHGUI::SetState(int aState)
862 this->myState = aState;
866 //=============================================================================
870 //=============================================================================
871 void SMESHGUI::ResetState()
877 //=============================================================================
881 //=============================================================================
882 void SMESHGUI::EmitSignalDeactivateDialog()
884 emit this->SignalDeactivateActiveDialog();
888 //=============================================================================
892 //=============================================================================
893 void SMESHGUI::EmitSignalStudyFrameChanged()
895 emit this->SignalStudyFrameChanged();
899 //=============================================================================
903 //=============================================================================
904 void SMESHGUI::EmitSignalCloseAllDialogs()
906 emit SignalCloseAllDialogs();
910 //=============================================================================
914 //=============================================================================
915 QDialog *SMESHGUI::GetActiveDialogBox()
917 return this->myActiveDialogBox;
920 //=============================================================================
924 //=============================================================================
925 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
927 this->myActiveDialogBox = (QDialog *) aDlg;
931 //=============================================================================
935 //=============================================================================
936 QAD_Study *SMESHGUI::GetActiveStudy()
938 return this->myActiveStudy;
941 //=============================================================================
945 //=============================================================================
946 QAD_Desktop *SMESHGUI::GetDesktop()
948 return QAD_Application::getDesktop();
951 //=============================================================================
955 //=============================================================================
956 bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
958 MESSAGE("SMESHGUI::activeStudyChanged init.");
959 QAD_Study* prevStudy = myActiveStudy;
960 /* Create or retrieve an object SMESHGUI */
961 MESSAGE("Active study changed : prev study =" << prevStudy);
962 SMESHGUI::GetSMESHGUI();
963 EmitSignalStudyFrameChanged();
964 MESSAGE("Active study changed : active study =" << myActiveStudy);
965 if ( prevStudy != myActiveStudy ) {
966 EmitSignalCloseAllDialogs();
967 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
969 SMESH::UpdateSelectionProp();
971 MESSAGE("SMESHGUI::activeStudyChanged done.");
975 //=============================================================================
979 //=============================================================================
980 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
982 /* Here the position is on the bottom right corner - 10 */
983 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
985 QAD_Desktop *PP = QAD_Application::getDesktop();
986 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
987 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
991 //=============================================================================
995 //=============================================================================
996 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
997 return theStudy->GetProperties()->IsLocked();
1000 static bool checkLock(const SALOMEDS::Study_var& theStudy) {
1001 if (isStudyLocked(theStudy)) {
1002 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
1003 QObject::tr("WRN_WARNING"),
1004 QObject::tr("WRN_STUDY_LOCKED"),
1005 QObject::tr("BUT_OK") );
1011 //=======================================================================
1012 //function : CheckActiveStudyLocked
1014 //=======================================================================
1016 bool SMESHGUI::ActiveStudyLocked()
1018 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1019 return checkLock( aStudy );
1022 //=============================================================================
1026 //=============================================================================
1027 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
1029 SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1031 switch (theCommandID) {
1033 if(checkLock(aStudy)) break;
1041 if(checkLock(aStudy)) break;
1042 ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
1046 case 122: // EXPORT MED
1050 ::ExportMeshToFile(parent, theCommandID);
1054 case 200: // SCALAR BAR
1056 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1057 if( Sel && Sel->IObjectCount() ) {
1058 Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
1059 if( anIO->hasEntry() ) {
1060 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1061 anActor->SetControlMode( SMESH_Actor::eNone );
1069 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1070 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
1074 case 1134: // Clipping
1075 case 1133: // Tranparency
1076 case 1132: // Colors / Size
1083 ::SetDisplayMode(theCommandID);
1089 case 219: // Volumes
1090 case 220: // All Entity
1091 ::SetDisplayEntity(theCommandID);
1096 if(checkLock(aStudy)) break;
1097 SMESH::UpdateView();
1102 case 301: // DISPLAY
1103 case 302: // DISPLAY ONLY
1105 SMESH::EDisplaing anAction;
1106 switch(theCommandID){
1107 case 300: anAction = SMESH::eErase; break;
1108 case 301: anAction = SMESH::eDisplay; break;
1109 case 302: anAction = SMESH::eDisplayOnly; break;
1112 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1113 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1114 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1115 for (; It.More(); It.Next()) {
1116 Handle(SALOME_InteractiveObject) IOS = It.Value();
1117 if (IOS->hasEntry()) {
1118 SMESH::UpdateView(anAction,IOS->getEntry());
1122 Sel->ClearIObjects();
1128 if(checkLock(aStudy)) break;
1129 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1130 EmitSignalDeactivateDialog();
1131 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1132 new SMESHGUI_NodesDlg(parent, "", Sel);
1135 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1136 tr("SMESH_WRN_WARNING"),
1137 tr("SMESH_WRN_VIEWER_VTK"),
1138 tr("SMESH_BUT_OK"));
1143 case 2151: // FILTER
1145 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1147 EmitSignalDeactivateDialog();
1148 new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
1153 case 406: // MOVE NODE
1155 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1157 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1158 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1162 if(checkLock(aStudy)) break;
1163 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1164 new SMESHGUI_MoveNodesDlg( parent, Sel );
1168 case 701: // COMPUTE MESH
1170 if(checkLock(aStudy)) break;
1171 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1172 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1173 int nbSel = Sel->IObjectCount();
1178 SMESH::SMESH_Mesh_var aMesh;
1179 SMESH::SMESH_subMesh_var aSubMesh;
1180 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1181 if (IObject->hasEntry()){
1182 SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1183 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1184 if ( aShapeObject->_is_nil() ) {
1188 if(!aMeshSObj->_is_nil()) {
1189 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1190 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1192 if (!aMesh->_is_nil()){
1193 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1194 if (!refShapeObject->_is_nil()) {
1195 if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
1196 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1197 tr("SMESH_WRN_WARNING"),
1198 tr("SMESH_WRN_MISSING_PARAMETERS"),
1199 tr("SMESH_BUT_OK"));
1203 if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
1204 SMESH::ModifiedMesh(aMeshSObj,true);
1205 // TO Do : change icon of all submeshes
1207 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1208 tr("SMESH_WRN_WARNING"),
1209 tr("SMESH_WRN_COMPUTE_FAILED"),
1210 tr("SMESH_BUT_OK"));
1212 catch(const SALOME::SALOME_Exception & S_ex){
1213 QtCatchCorbaException(S_ex);
1216 }else if(!aSubMesh->_is_nil()){
1217 aMesh = aSubMesh->GetFather();
1218 GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
1219 if(!refShapeObject->_is_nil()){
1220 bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
1222 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1223 tr("SMESH_WRN_WARNING"),
1224 tr("SMESH_WRN_MISSING_PARAMETERS"),
1225 tr("SMESH_BUT_OK"));
1229 if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
1230 SMESH::ModifiedMesh(aMeshSObj,true);
1231 // TO Do : change icon of all submeshes
1233 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1234 tr("SMESH_WRN_WARNING"),
1235 tr("SMESH_WRN_COMPUTE_FAILED"),
1236 tr("SMESH_BUT_OK"));
1237 }catch(const SALOME::SALOME_Exception & S_ex){
1238 QtCatchCorbaException(S_ex);
1244 CORBA::Long anId = aStudy->StudyId();
1245 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1246 if(myAutomaticUpdate && aVisualObj){
1247 aVisualObj->Update();
1248 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1250 anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1252 SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
1258 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1259 tr("SMESH_WRN_WARNING"),
1260 tr("SMESH_WRN_VIEWER_VTK"),
1261 tr("SMESH_BUT_OK"));
1266 case 702: // ADD SUB MESH
1268 if(checkLock(aStudy)) break;
1269 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1270 EmitSignalDeactivateDialog();
1271 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1272 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
1275 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1276 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1277 tr("SMESH_BUT_OK"));
1282 case 703: // INIT MESH
1284 if(checkLock(aStudy)) break;
1285 EmitSignalDeactivateDialog();
1286 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1287 new SMESHGUI_InitMeshDlg(parent, "", Sel);
1291 case 704: // EDIT Hypothesis
1293 if(checkLock(aStudy)) break;
1294 EmitSignalDeactivateDialog();
1295 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1296 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1300 case 705: // EDIT Global Hypothesis
1302 if(checkLock(aStudy)) break;
1303 EmitSignalDeactivateDialog();
1304 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1305 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1309 case 706: // EDIT Local Hypothesis
1311 if(checkLock(aStudy)) break;
1312 EmitSignalDeactivateDialog();
1313 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1314 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
1318 case 407: // DIAGONAL INVERSION
1319 case 408: // Delete diagonal
1321 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
1323 QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1324 tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1328 if ( checkLock( aStudy ) )
1331 SALOME_Selection *aSel =
1332 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1333 /*Standard_Boolean aRes;
1334 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1335 if ( aMesh->_is_nil() )
1337 QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1338 tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1342 EmitSignalDeactivateDialog();
1343 if ( theCommandID == 407 )
1344 new SMESHGUI_TrianglesInversionDlg( parent, aSel );
1346 new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
1349 case 409: // Change orientation
1350 case 410: // Union of triangles
1351 case 411: // Cutting of quadrangles
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() );
1366 EmitSignalDeactivateDialog();
1367 SMESHGUI_MultiEditDlg* aDlg;
1368 if ( theCommandID == 409 )
1369 aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
1370 else if ( theCommandID == 410 )
1371 aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
1373 aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
1376 DefineDlgPosition( aDlg, x, y );
1381 case 412: // Smoothing
1383 if(checkLock(aStudy)) break;
1384 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1385 EmitSignalDeactivateDialog();
1386 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1387 new SMESHGUI_SmoothingDlg(parent, "", Sel);
1390 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1391 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1392 tr("SMESH_BUT_OK"));
1396 case 413: // Extrusion
1398 if(checkLock(aStudy)) break;
1399 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1400 EmitSignalDeactivateDialog();
1401 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1402 new SMESHGUI_ExtrusionDlg(parent, "", Sel);
1405 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1406 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1407 tr("SMESH_BUT_OK"));
1411 case 414: // Revolution
1413 if(checkLock(aStudy)) break;
1414 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1415 EmitSignalDeactivateDialog();
1416 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1417 new SMESHGUI_RevolutionDlg(parent, "", Sel);
1420 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1421 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1422 tr("SMESH_BUT_OK"));
1426 case 415: // Pattern mapping
1428 if ( checkLock( aStudy ) )
1430 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
1432 EmitSignalDeactivateDialog();
1433 SALOME_Selection *Sel = SALOME_Selection::Selection(
1434 myActiveStudy->getSelection() );
1435 new SMESHGUI_MeshPatternDlg( parent, Sel );
1438 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1439 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1440 tr("SMESH_BUT_OK"));
1444 case 801: // CREATE GROUP
1446 if(checkLock(aStudy)) break;
1447 EmitSignalDeactivateDialog();
1448 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1449 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1450 int nbSel = Sel->IObjectCount();
1452 // check if mesh is selected
1453 aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
1455 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
1460 case 802: // CONSTRUCT GROUP
1462 if(checkLock(aStudy)) break;
1463 EmitSignalDeactivateDialog();
1464 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1465 int nbSel = Sel->IObjectCount();
1467 // check if submesh is selected
1468 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1469 if (IObject->hasEntry()) {
1470 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
1471 if(!aSObj->_is_nil()) {
1472 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
1473 if (!aSubMesh->_is_nil()) {
1475 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1476 // get submesh elements list by types
1477 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1478 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1479 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1480 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1481 // create group for each type o elements
1482 QString aName = IObject->getName();
1483 if (aNodes->length() > 0) {
1484 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
1485 aGroup->Add(aNodes.inout());
1487 if (aEdges->length() > 0) {
1488 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
1489 aGroup->Add(aEdges.inout());
1491 if (aFaces->length() > 0) {
1492 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
1493 aGroup->Add(aFaces.inout());
1495 if (aVolumes->length() > 0) {
1496 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
1497 aGroup->Add(aVolumes.inout());
1499 myActiveStudy->updateObjBrowser(true);
1500 }catch(const SALOME::SALOME_Exception & S_ex){
1501 QtCatchCorbaException(S_ex);
1510 case 803: // EDIT GROUP
1512 if(checkLock(aStudy)) break;
1513 EmitSignalDeactivateDialog();
1514 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1515 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1516 SALOME_ListIteratorOfListIO It (IOs);
1517 int nbSelectedGroups = 0;
1518 for ( ; It.More(); It.Next() )
1520 SMESH::SMESH_Group_var aGroup =
1521 SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
1522 if (!aGroup->_is_nil()) {
1524 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
1528 if (nbSelectedGroups == 0)
1530 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
1536 case 804: // Add elements to group
1538 if(checkLock(aStudy)) break;
1539 if (myState == 800) {
1540 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1541 if (aDlg) aDlg->onAdd();
1546 case 805: // Remove elements from group
1548 if(checkLock(aStudy)) break;
1549 if (myState == 800) {
1550 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1551 if (aDlg) aDlg->onRemove();
1556 case 810: // Union Groups
1557 case 811: // Intersect groups
1558 case 812: // Cut groups
1560 if ( checkLock( aStudy ) )
1563 EmitSignalDeactivateDialog();
1564 SALOME_Selection *Sel = SALOME_Selection::Selection(
1565 myActiveStudy->getSelection() );
1568 if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1569 else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1570 else aMode = SMESHGUI_GroupOpDlg::CUT;
1572 ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
1576 case 813: // Delete groups with their contents
1578 if ( checkLock( aStudy ) )
1581 EmitSignalDeactivateDialog();
1582 SALOME_Selection *Sel = SALOME_Selection::Selection(
1583 myActiveStudy->getSelection() );
1585 ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
1589 case 900: // MESH INFOS
1591 EmitSignalDeactivateDialog();
1592 SALOME_Selection *Sel =
1593 SALOME_Selection::Selection(myActiveStudy->getSelection());
1594 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1595 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1596 SALOME_ListIteratorOfListIO It (IOs);
1597 for ( ; It.More(); It.Next() ) {
1598 Sel->ClearIObjects();
1599 Sel->AddIObject( It.Value() );
1600 new SMESHGUI_MeshInfosDlg(parent, "", false);
1602 // restore selection
1603 Sel->ClearIObjects();
1604 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1605 Sel->AddIObject( It.Value() );
1608 new SMESHGUI_MeshInfosDlg(parent, "", false);
1612 case 902: // STANDARD MESH INFOS
1614 EmitSignalDeactivateDialog();
1615 SALOME_Selection *Sel =
1616 SALOME_Selection::Selection(myActiveStudy->getSelection());
1617 if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
1618 SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
1619 SALOME_ListIteratorOfListIO It (IOs);
1620 for ( ; It.More(); It.Next() ) {
1621 Sel->ClearIObjects();
1622 Sel->AddIObject( It.Value() );
1623 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1625 // restore selection
1626 Sel->ClearIObjects();
1627 for (It.Initialize( IOs ) ; It.More(); It.Next() )
1628 Sel->AddIObject( It.Value() );
1631 new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
1635 case 1001: // AUTOMATIC UPDATE PREFERENCES
1637 parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
1638 if (parent->menuBar()->isItemChecked(1001)) {
1639 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
1640 myAutomaticUpdate = true;
1643 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
1644 myAutomaticUpdate = false;
1649 case 1003: // MESH PREFERENCES
1651 ::SetDisplaySettings();
1657 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
1663 ( new SMESHGUI_PrecisionDlg( parent ) )->exec();
1669 SMESHGUI_Preferences_SelectionDlg* aDlg =
1670 new SMESHGUI_Preferences_SelectionDlg(parent);
1673 QString SCr, SCg, SCb;
1674 SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
1675 SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
1676 SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
1677 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1678 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1679 else aColor = Qt::cyan;
1680 aDlg->SetColor(1, aColor);
1682 SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
1683 SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
1684 SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
1685 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1686 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1687 else aColor = Qt::yellow;
1688 aDlg->SetColor(2, aColor);
1690 SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
1691 SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
1692 SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
1693 if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
1694 aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
1695 else aColor = Qt::white;
1696 aDlg->SetColor(3, aColor);
1698 QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
1699 if (SW1.isEmpty()) SW1 = "5";
1700 aDlg->SetWidth(1, SW1.toInt());
1702 QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
1703 if (SW2.isEmpty()) SW2 = "5";
1704 aDlg->SetWidth(2, SW2.toInt());
1706 QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
1707 if (SP1.isEmpty()) SP1 = "0.025";
1708 aDlg->SetPrecision(1, SP1.toDouble());
1710 QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
1711 if (SP2.isEmpty()) SP2 = "0.001";
1712 aDlg->SetPrecision(2, SP2.toDouble());
1715 QColor aPreColor = aDlg->GetColor(1);
1716 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
1717 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
1718 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
1720 QColor aSelColor = aDlg->GetColor(2);
1721 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
1722 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
1723 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
1725 QColor aHiColor = aDlg->GetColor(3);
1726 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
1727 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
1728 QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
1730 int aPreWidth = aDlg->GetWidth(1);
1731 QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
1732 int aSelWidth = aDlg->GetWidth(2);
1733 QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
1735 double aTolNodes = aDlg->GetPrecision(1);
1736 QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
1737 double aTolItems = aDlg->GetPrecision(2);
1738 QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
1740 // update current study settings
1741 SMESH::UpdateSelectionProp();
1743 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
1744 if (studyFrame->getTypeView() == VIEW_VTK) {
1745 VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
1746 // update VTK viewer properties
1747 VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
1749 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
1750 aSelColor.blue()/255., aSelWidth);
1751 anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
1752 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
1754 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
1755 aPreColor.blue()/255., aPreWidth);
1758 vtkRenderer* aRenderer = aViewFrame->getRenderer();
1759 vtkActorCollection *aCollection = aRenderer->GetActors();
1760 aCollection->InitTraversal();
1761 while(vtkActor *anAct = aCollection->GetNextActor()){
1762 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1763 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
1764 aHiColor.blue()/255.);
1765 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
1766 aPreColor.blue()/255.);
1775 case 1100: // EDIT HYPOTHESIS
1777 if(checkLock(aStudy)) break;
1778 SALOME_Selection *Sel =
1779 SALOME_Selection::Selection(myActiveStudy->getSelection());
1780 int nbSel = Sel->IObjectCount();
1783 SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
1785 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1786 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
1787 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
1788 if ( !Hyp->_is_nil() )
1790 char* sName = Hyp->GetName();
1791 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1794 aCreator->EditHypothesis(Hyp);
1805 case 1101: // RENAME
1807 if ( checkLock( aStudy ) )
1810 SALOME_Selection *Sel =
1811 SALOME_Selection::Selection( myActiveStudy->getSelection() );
1813 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1814 for ( ; It.More(); It.Next() )
1816 Handle(SALOME_InteractiveObject) IObject = It.Value();
1817 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
1818 SALOMEDS::GenericAttribute_var anAttr;
1819 SALOMEDS::AttributeName_var aName;
1820 if ( !obj->_is_nil() )
1822 if ( obj->FindAttribute(anAttr, "AttributeName") )
1824 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1825 QString newName = QString(aName->Value());
1826 newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
1827 if ( !newName.isEmpty() )
1829 myActiveStudy->renameIObject( IObject, newName );
1831 // if current object is group update group's name
1832 SMESH::SMESH_GroupBase_var aGroup =
1833 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1834 if (!aGroup->_is_nil() )
1835 aGroup->SetName( newName.latin1() );
1843 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
1845 if(checkLock(aStudy)) break;
1847 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1848 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1849 for (int i = 0; It.More(); It.Next(), i++) {
1850 Handle(SALOME_InteractiveObject) IObject = It.Value();
1851 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1853 Sel->ClearIObjects();
1854 myActiveStudy->updateObjBrowser(true);
1858 case 401: // GEOM::EDGE
1859 case 4021: // TRIANGLE
1864 if(checkLock(aStudy)) break;
1865 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1866 EmitSignalDeactivateDialog();
1867 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1868 SMDSAbs_ElementType type = SMDSAbs_Edge;
1870 switch (theCommandID) {
1871 case 4021: // TRIANGLE
1872 type = SMDSAbs_Face; nbNodes = 3; break;
1874 type = SMDSAbs_Face; nbNodes = 4; break;
1876 type = SMDSAbs_Volume; nbNodes = 4; break;
1878 type = SMDSAbs_Volume; nbNodes = 8; break;
1881 new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
1884 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1885 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1886 tr("SMESH_BUT_OK"));
1891 case 4041: // REMOVES NODES
1893 if(checkLock(aStudy)) break;
1894 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1895 EmitSignalDeactivateDialog();
1896 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1897 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
1900 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1901 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1902 tr("SMESH_BUT_OK"));
1906 case 4042: // REMOVES ELEMENTS
1908 if(checkLock(aStudy)) break;
1909 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1910 EmitSignalDeactivateDialog();
1911 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1912 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
1916 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1917 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1918 tr("SMESH_BUT_OK"));
1922 case 4051: // RENUMBERING NODES
1924 if(checkLock(aStudy)) break;
1925 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1926 EmitSignalDeactivateDialog();
1927 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1928 new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
1932 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1934 tr("SMESH_BUT_OK"));
1938 case 4052: // RENUMBERING ELEMENTS
1940 if(checkLock(aStudy)) break;
1941 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
1942 EmitSignalDeactivateDialog();
1943 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
1944 new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
1948 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1950 tr("SMESH_BUT_OK"));
1954 case 4061: // TRANSLATION
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_TranslationDlg(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 4062: // ROTATION
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_RotationDlg(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 4063: // SYMMETRY
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_SymmetryDlg(parent, "", Sel);
1993 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
1994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1995 tr("SMESH_BUT_OK"));
1999 case 4064: // SEWING
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_SewingDlg(parent, "", Sel);
2008 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2009 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2010 tr("SMESH_BUT_OK"));
2014 case 4065: // MERGE NODES
2016 if(checkLock(aStudy)) break;
2017 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
2018 EmitSignalDeactivateDialog();
2019 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2020 new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2023 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2024 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2025 tr("SMESH_BUT_OK"));
2031 case 5000: // HYPOTHESIS
2033 if(checkLock(aStudy)) break;
2034 EmitSignalDeactivateDialog();
2035 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2040 if(checkLock(aStudy)) break;
2041 EmitSignalDeactivateDialog();
2042 new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2046 case 5105: // Library of selection filters
2048 static QValueList<int> aTypes;
2049 if ( aTypes.isEmpty() )
2051 aTypes.append( SMESH::NODE );
2052 aTypes.append( SMESH::EDGE );
2053 aTypes.append( SMESH::FACE );
2054 aTypes.append( SMESH::VOLUME );
2056 new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2060 case 6017: // CONTROLS
2071 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2072 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2073 if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
2074 SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
2075 if ( !SO->_is_nil() ) {
2076 CORBA::Object_var aObject = SO->GetObject();
2077 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
2078 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2079 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
2080 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2081 ::Control( theCommandID );
2086 QAD_MessageBox::warn1(GetDesktop(),
2087 tr( "SMESH_WRN_WARNING" ),
2088 tr( "SMESH_BAD_SELECTION" ),
2089 tr( "SMESH_BUT_OK" ) );
2093 QAD_MessageBox::warn1(GetDesktop(),
2094 tr( "SMESH_WRN_WARNING" ),
2095 tr( "NOT_A_VTK_VIEWER" ),
2096 tr( "SMESH_BUT_OK" ) );
2101 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2102 if (Sel->IObjectCount() == 1) {
2103 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2104 if(anIObject->hasEntry())
2105 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2106 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2113 SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2114 if (Sel->IObjectCount() == 1) {
2115 Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
2116 if(anIObject->hasEntry())
2117 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2118 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2123 case 10001: // DISPLAY MODE PREFERENCE
2126 parent->menuBar()->setItemChecked(10001, true);
2127 parent->menuBar()->setItemChecked(10002, false);
2128 parent->menuBar()->setItemChecked(10004, false);
2129 parent->menuBar()->setItemEnabled(10003, true);
2130 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
2135 parent->menuBar()->setItemChecked(10002, true);
2136 parent->menuBar()->setItemChecked(10001, false);
2137 parent->menuBar()->setItemChecked(10004, false);
2138 parent->menuBar()->setItemEnabled(10003, true);
2139 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2144 parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
2145 QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
2150 parent->menuBar()->setItemChecked(10001, false);
2151 parent->menuBar()->setItemChecked(10004, true);
2152 parent->menuBar()->setItemChecked(10002, false);
2153 parent->menuBar()->setItemEnabled(10003, false);
2154 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
2160 myActiveStudy->updateObjBrowser(true);
2164 //=============================================================================
2168 //=============================================================================
2169 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
2170 QAD_StudyFrame * studyFrame)
2175 //=============================================================================
2179 //=============================================================================
2180 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
2181 QAD_StudyFrame * studyFrame)
2186 //=============================================================================
2190 //=============================================================================
2191 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
2192 QAD_StudyFrame * studyFrame)
2197 //=============================================================================
2201 //=============================================================================
2202 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2204 MESSAGE("SMESHGUI::SetSettings.");
2205 SMESHGUI::GetSMESHGUI();
2208 QString DisplayMode = "Shading";
2209 if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
2210 DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
2212 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2214 bool Shrink = false;
2215 if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
2216 Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2218 if (DisplayMode == "Wireframe") {
2220 parent->menuBar()->setItemChecked(10004, false);
2221 parent->menuBar()->setItemChecked(10002, false);
2222 parent->menuBar()->setItemChecked(10001, true);
2223 parent->menuBar()->setItemEnabled(10003, true);
2225 else if (DisplayMode == "Nodes") {
2227 parent->menuBar()->setItemChecked(10004, true);
2228 parent->menuBar()->setItemChecked(10002, false);
2229 parent->menuBar()->setItemChecked(10001, false);
2230 parent->menuBar()->setItemEnabled(10003, false);
2233 // default is shading
2234 parent->menuBar()->setItemChecked(10004, false);
2235 parent->menuBar()->setItemChecked(10002, true);
2236 parent->menuBar()->setItemChecked(10001, false);
2237 parent->menuBar()->setItemEnabled(10003, true);
2239 parent->menuBar()->setItemChecked(10003, Shrink);
2241 /* Automatic Update */
2242 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
2243 if (AutoUpdate.compare("true") == 0) {
2244 parent->menuBar()->setItemChecked(1001, true);
2245 myAutomaticUpdate = true;
2248 parent->menuBar()->setItemChecked(1001, false);
2249 myAutomaticUpdate = false;
2253 SMESH::UpdateSelectionProp();
2256 parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
2257 //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2262 //=============================================================================
2266 //=============================================================================
2267 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2269 // NRI : Temporary added
2270 // if ( myStudy->GetProperties()->IsLocked() ) {
2271 // theObject = "NothingSelected";
2272 // theContext = "NothingSelected";
2276 SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2277 int nbSel = Sel->IObjectCount();
2280 theObject = "NothingSelected";
2281 theContext = "NothingSelected";
2284 if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
2285 theObject = "Elements";
2287 theObject = ::CheckTypeObject( Sel->firstIObject() );
2291 theObject = ::CheckHomogeneousSelection();
2296 //=============================================================================
2300 //=============================================================================
2301 bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
2302 const QString& theParent, const QString& theObject)
2304 // get active study frame
2305 QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
2307 // get parent component which selected object(s) belongs to
2308 QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
2311 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2312 int nbSel = Sel->IObjectCount();
2317 else if ( nbSel == 1 ) {
2318 if ( parentComp != parent->getActiveComponent() ) {
2319 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2321 int id = popup->idAt( 0 );
2322 if ( id <= QAD_TopLabel_Popup_ID )
2323 popup->removeItemAt( 0 );
2329 // get selected interactive object
2330 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2331 SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
2332 // find popup menu's TopLabel item
2333 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2334 if ( topItem >= 0 ) {
2335 if ( theParent == "Viewer" ) {
2336 // set bold font for popup menu's TopLabel item (Viewer popup)
2337 QFont fnt = popup->font(); fnt.setBold( TRUE );
2338 popup->removeItem( QAD_TopLabel_Popup_ID );
2339 popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
2341 else if ( theParent == "ObjectBrowser" ) {
2342 // remove popup menu's TopLabel item (Object Browser popup)
2343 popup->removeItem( QAD_TopLabel_Popup_ID );
2347 if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
2348 // remove Display/Erase commands
2349 popup->removeItem( QAD_Display_Popup_ID );
2350 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2351 popup->removeItem( QAD_Erase_Popup_ID );
2352 // remove "Unassign ..." command if hyp/algo is not assigned
2353 if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
2354 popup->removeItem( 1102 );
2356 else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
2358 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
2359 if ( aShapeObject->_is_nil() ) {
2361 popup->removeItem( 701 ); // Compute
2362 popup->removeItem( 705 ); // Edit hypothesis
2363 popup->removeItem( 706 ); // ...
2365 SMESH::SMESH_GroupOnGeom_var aGeomGroup =
2366 SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
2367 if ( !aGeomGroup->_is_nil() ) // group linked on geometry
2368 popup->removeItem( 803 ); // EDIT GROUP
2370 SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2371 // if object has actor
2372 if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2373 VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
2374 if ( myRenderInter->isVisible( IObject ) ) {
2375 popup->removeItem( QAD_Display_Popup_ID );
2376 popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
2377 popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
2378 TVisualObjPtr aVisualObj = anActor->GetObject();
2379 int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
2380 int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
2381 int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
2383 QMenuItem* mi = popup->findItem( 1131 );
2384 if ( mi && mi->popup() ) {
2385 int prType = anActor->GetRepresentation();
2386 // Display Mode / Wireframe
2387 if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2388 mi->popup()->removeItem( 211 );
2390 mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
2392 // Display Mode / Shading
2393 if(aNbFaces == 0 && aNbVolumes == 0){
2394 mi->popup()->removeItem( 212 );
2396 mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
2398 // Display Mode / Points
2399 mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
2400 // Display Mode / Shrink
2401 bool isShrunk = anActor->IsShrunk();
2402 bool isShrunkable = anActor->IsShrunkable();
2403 mi->popup()->setItemChecked( 213, isShrunk );
2404 mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
2408 mi = popup->findItem( 1135 );
2409 if ( mi && mi->popup() ) {
2410 QPopupMenu* aPopup = mi->popup();
2411 unsigned int aMode = anActor->GetEntityMode();
2414 aPopup->removeItem( 219 );
2416 aPopup->setItemChecked( 219, aMode & SMESH_Actor::eVolumes );
2419 aPopup->removeItem( 218 );
2421 aPopup->setItemChecked( 218, aMode & SMESH_Actor::eFaces );
2425 aPopup->removeItem( 217 );
2427 aPopup->setItemChecked( 217, aMode & SMESH_Actor::eEdges );
2430 bool aIsRemove = (aNbVolumes == 0 || aMode & SMESH_Actor::eVolumes);
2431 aIsRemove &= (aNbFaces == 0 || aMode & SMESH_Actor::eFaces);
2432 aIsRemove &= (aNbEdges == 0 || aMode & SMESH_Actor::eEdges);
2435 aPopup->removeItem( 220 );
2439 mi = popup->findItem( 2000 );
2440 if ( mi && mi->popup() ) {
2441 SMESH_Actor::eControl cMode = anActor->GetControlMode();
2443 case SMESH_Actor::eLengthEdges:
2444 mi->popup()->setItemChecked( 6001, true ); break;
2445 case SMESH_Actor::eFreeEdges:
2446 mi->popup()->setItemChecked( 6002, true );
2447 mi->popup()->removeItem( 201 );
2449 case SMESH_Actor::eFreeBorders:
2450 mi->popup()->setItemChecked( 6003, true );
2451 mi->popup()->removeItem( 201 );
2453 case SMESH_Actor::eMultiConnection:
2454 mi->popup()->setItemChecked( 6004, true ); break;
2455 case SMESH_Actor::eArea:
2456 mi->popup()->setItemChecked( 6011, true ); break;
2457 case SMESH_Actor::eTaper:
2458 mi->popup()->setItemChecked( 6012, true ); break;
2459 case SMESH_Actor::eAspectRatio:
2460 mi->popup()->setItemChecked( 6013, true ); break;
2461 case SMESH_Actor::eAspectRatio3D:
2462 mi->popup()->setItemChecked( 6017, true ); break;
2463 case SMESH_Actor::eMinimumAngle:
2464 mi->popup()->setItemChecked( 6014, true ); break;
2465 case SMESH_Actor::eWarping:
2466 mi->popup()->setItemChecked( 6015, true ); break;
2467 case SMESH_Actor::eSkew:
2468 mi->popup()->setItemChecked( 6016, true ); break;
2469 case SMESH_Actor::eNone:
2471 mi->popup()->removeItem( 200 );
2472 mi->popup()->removeItem( 201 );
2475 TVisualObjPtr aVisualObj = anActor->GetObject();
2477 mi->popup()->removeItem( 6001 );
2478 mi->popup()->removeItem( 6003 );
2479 mi->popup()->removeItem( 6004 );
2482 mi->popup()->removeItem( 6002 );
2483 mi->popup()->removeItem( 6011 );
2484 mi->popup()->removeItem( 6012 );
2485 mi->popup()->removeItem( 6013 );
2486 mi->popup()->removeItem( 6014 );
2487 mi->popup()->removeItem( 6015 );
2488 mi->popup()->removeItem( 6016 );
2490 if(aNbVolumes == 0){
2491 mi->popup()->removeItem( 6017 );
2493 if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2494 popup->removeItem( 2000 ); // Scalar Bar
2498 popup->removeItem( QAD_Erase_Popup_ID );
2499 popup->removeItem( 114 ); // Numbering popup menu
2500 popup->removeItem( 1131 ); // Display mode
2501 popup->removeItem( 1132 ); // Color / size
2502 popup->removeItem( 1133 ); // Transparency
2503 popup->removeItem( 1134 ); // Clipping
2504 popup->removeItem( 2000 ); // Scalar Bar
2508 // object doesn't have actor
2509 CORBA::Object_var anObject = SO->GetObject();
2510 bool bDisplay = false;
2511 if ( !CORBA::is_nil( anObject ) ) {
2512 SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
2513 if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
2515 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
2516 if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
2518 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
2519 if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
2523 popup->removeItem( QAD_Display_Popup_ID );
2524 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2526 popup->removeItem( QAD_Erase_Popup_ID );
2527 popup->removeItem( 114 ); // Numbering popup menu
2528 popup->removeItem( 1131 ); // Display mode
2529 popup->removeItem( 1132 ); // Color / size
2530 popup->removeItem( 1133 ); // Transparency
2531 popup->removeItem( 1134 ); // Clipping
2532 popup->removeItem( 2000 ); // Scalar Bar
2535 else if( theObject!="Component" ) {
2536 // another SMESH object
2537 popup->removeItem( QAD_Display_Popup_ID );
2538 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2539 popup->removeItem( QAD_Erase_Popup_ID );
2544 // multiple selection
2545 if ( parentComp != parent->getActiveComponent() ) {
2546 // object not belongs to SMESH module - remove all commands except common Display/Erase...
2548 int id = popup->idAt( 0 );
2549 if ( id <= QAD_TopLabel_Popup_ID )
2550 popup->removeItemAt( 0 );
2554 if ( parentComp.isNull() ) {
2555 // objects from different components are selected
2556 popup->removeItem( QAD_DisplayOnly_Popup_ID );
2557 popup->removeItem( QAD_Display_Popup_ID );
2558 popup->removeItem( QAD_Erase_Popup_ID );
2562 QString type = ::CheckHomogeneousSelection();
2563 if ( type != "Heterogeneous Selection" ) {
2564 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
2565 if ( topItem >= 0 ) {
2566 // set bold font for popup menu's TopLabel item
2567 QFont fnt = popup->font(); fnt.setBold( TRUE );
2568 popup->removeItem( QAD_TopLabel_Popup_ID );
2569 popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2577 //=============================================================================
2578 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2579 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2581 //=============================================================================
2582 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2585 if(theIO->hasEntry()){
2586 QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
2587 QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
2588 SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
2592 void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2594 if (!buffer || !bufferSize)
2596 buffer[0] = (int)VIEW_VTK;
2599 void SMESHGUI::Deactivate()
2601 if ( SMESHGUI::GetSMESHGUI() ) {
2602 SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();