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
24 // File : SMESHGUI.cxx
25 // Author : Nicolas REJNERI
31 #include "SMESHGUI_AddHypothesisDlg.h"
32 #include "SMESHGUI_AddAlgorithmDlg.h"
33 #include "SMESHGUI_InitMeshDlg.h"
34 #include "SMESHGUI_LocalLengthDlg.h"
35 #include "SMESHGUI_NbSegmentsDlg.h"
36 #include "SMESHGUI_AddSubMeshDlg.h"
37 #include "SMESHGUI_NodesDlg.h"
38 #include "SMESHGUI_TransparencyDlg.h"
39 #include "SMESHGUI_RemoveNodesDlg.h"
40 #include "SMESHGUI_RemoveElementsDlg.h"
41 #include "SMESHGUI_MeshInfosDlg.h"
42 #include "SMESHGUI_Preferences_ColorDlg.h"
43 #include "SMESHGUI_MaxElementAreaDlg.h"
44 #include "SMESHGUI_MaxElementVolumeDlg.h"
45 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
46 #include "SMESHGUI_EditScalarBarDlg.h"
47 #include "SMESHGUI_aParameterDlg.h"
48 #include "SMESHGUI_ComputeScalarValue.h"
49 #include "SMESHGUI_MoveNodesDlg.h"
50 #include "SMESHGUI_OrientationElementsDlg.h"
51 #include "SMESHGUI_DiagonalInversionDlg.h"
52 #include "SMESHGUI_EdgesConnectivityDlg.h"
53 #include "SMESHGUI_AddFaceDlg.h"
54 #include "SMESHGUI_AddEdgeDlg.h"
55 #include "SMESHGUI_AddVolumeDlg.h"
56 #include "SMESHGUI_EditHypothesesDlg.h"
58 #include "SMESH_Grid.h"
61 #include "Utils_ORB_INIT.hxx"
62 #include "Utils_SINGLETON.hxx"
65 #include "QAD_Tools.h"
66 #include "QAD_Config.h"
67 #include "QAD_Settings.h"
68 #include "QAD_RightFrame.h"
69 #include "QAD_MessageBox.h"
70 #include "QAD_Resource.h"
71 #include "QAD_FileDlg.h"
72 #include "SALOMEGUI_Desktop.h"
73 #include "SALOMEGUI_NameDlg.h"
75 #include "OCCViewer_ViewPort.h"
76 #include "OCCViewer_ViewPort3d.h"
77 #include "OCCViewer_Viewer3d.h"
79 #include "GEOM_Client.hxx"
80 #include "GEOM_InteractiveObject.hxx"
82 #include "SALOME_NamingService.hxx"
83 #include "SALOME_ListIteratorOfListIO.hxx"
84 #include "SALOME_InteractiveObject.hxx"
86 #include "SALOMEGUI_ImportOperation.h"
87 #include "SALOMEGUI_QtCatchCorbaException.hxx"
88 #include "utilities.h"
90 #include "SMDS_Mesh.hxx"
91 #include "SMESHDS_Document.hxx"
92 #include "Document_Reader.h"
93 #include "Document_Writer.h"
94 #include "Mesh_Reader.h"
95 #include "Mesh_Writer.h"
97 #include "DriverDAT_R_SMESHDS_Document.h"
98 #include "DriverMED_R_SMESHDS_Document.h"
99 #include "DriverUNV_R_SMESHDS_Document.h"
100 #include "DriverDAT_W_SMESHDS_Document.h"
101 #include "DriverMED_W_SMESHDS_Document.h"
102 #include "DriverUNV_W_SMESHDS_Document.h"
103 #include "DriverDAT_R_SMESHDS_Mesh.h"
104 #include "DriverMED_R_SMESHDS_Mesh.h"
105 #include "DriverUNV_R_SMESHDS_Mesh.h"
106 #include "DriverDAT_W_SMESHDS_Mesh.h"
107 #include "DriverMED_W_SMESHDS_Mesh.h"
108 #include "DriverUNV_W_SMESHDS_Mesh.h"
111 #define INCLUDE_MENUITEM_DEF
112 #include <qapplication.h>
113 #include <qlineedit.h>
114 #include <qmenudata.h>
115 #include <qmenubar.h>
116 #include <qpopupmenu.h>
119 #include <qcheckbox.h>
120 #include <qcolordialog.h>
121 #include <qmessagebox.h>
122 #include <qspinbox.h>
126 #include <qradiobutton.h>
129 #include "VTKViewer_Common.h"
130 #include "VTKViewer_ViewFrame.h"
131 #include <vtkLegendBoxActor.h>
132 #include <vtkFeatureEdges.h>
133 #include <vtkDoubleArray.h>
135 // Open CASCADE Includes
136 #include <gp_Pnt.hxx>
137 #include <gp_Vec.hxx>
139 static GEOM_Client ShapeReader;
140 static SMESHGUI *smeshGUI = 0;
141 static CORBA::ORB_var _orb;
143 //=============================================================================
147 //=============================================================================
148 class CustomItem:public QCustomMenuItem
151 CustomItem(const QString & s, const QFont & f):string(s), font(f)
158 void paint(QPainter * p, const QColorGroup & /*cg */ , bool /*act */ ,
159 bool /*enabled */ , int x, int y, int w, int h)
162 p->drawText(x, y, w, h,
163 AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
168 return QFontMetrics(font).
169 size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
176 //=============================================================================
180 //=============================================================================
181 SMESHGUI::SMESHGUI():
186 //=============================================================================
190 //=============================================================================
191 SMESHGUI::~SMESHGUI()
195 //=============================================================================
199 //=============================================================================
200 SMESHGUI *SMESHGUI::GetSMESHGUI()
205 //=============================================================================
209 //=============================================================================
210 SMESHGUI *SMESHGUI::GetOrCreateSMESHGUI(QAD_Desktop * desktop)
215 smeshGUI = new SMESHGUI;
216 smeshGUI->myActiveDialogBox = 0;
217 smeshGUI->myState = -1;
218 smeshGUI->myDesktop = desktop;
219 smeshGUI->myActiveStudy = desktop->getActiveStudy();
221 Engines::Component_var comp =
222 desktop->getEngine("FactoryServer", "SMESH");
223 smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp);
225 Engines::Component_var comp1 =
226 desktop->getEngine("FactoryServer", "GEOM");
227 smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1);
229 /* GetCurrentStudy */
230 smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId();
232 smeshGUI->myComponentGeom->GetCurrentStudy(smeshGUI->myStudyId);
233 // smeshGUI->myComponentGeom->NbLabels();
235 smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument();
237 smeshGUI->myStudyAPI =
238 SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh);
240 smeshGUI->myDocument = new SMESHDS_Document(1); //NBU
242 smeshGUI->mySimulationActors = vtkActorCollection::New();
243 smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
247 /* study may have changed */
248 smeshGUI->myActiveStudy = desktop->getActiveStudy();
249 smeshGUI->myStudyAPI.Update(smeshGUI->myComponentMesh);
252 /* Automatic Update */
253 if (desktop->menuBar()->isItemChecked(1001))
254 smeshGUI->myAutomaticUpdate = true;
256 smeshGUI->myAutomaticUpdate = false;
261 //=============================================================================
265 //=============================================================================
266 void SMESHGUI::SetState(int aState)
268 this->myState = aState;
272 //=============================================================================
276 //=============================================================================
277 void SMESHGUI::ResetState()
283 //=============================================================================
287 //=============================================================================
288 void SMESHGUI::EmitSignalDeactivateDialog()
290 emit this->SignalDeactivateActiveDialog();
294 //=============================================================================
298 //=============================================================================
299 void SMESHGUI::EmitSignalCloseAllDialogs()
301 emit this->SignalCloseAllDialogs();
305 //=============================================================================
309 //=============================================================================
310 QDialog *SMESHGUI::GetActiveDialogBox()
312 return this->myActiveDialogBox;
315 //=============================================================================
319 //=============================================================================
320 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
322 this->myActiveDialogBox = (QDialog *) aDlg;
326 //=============================================================================
330 //=============================================================================
331 QAD_Study *SMESHGUI::GetActiveStudy()
333 return this->myActiveStudy;
336 //=============================================================================
340 //=============================================================================
341 SALOMEDS::Study_ptr SMESHGUI::GetStudy()
343 return SALOMEDS::Study::_narrow(myStudy);
346 //=============================================================================
350 //=============================================================================
351 SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI()
356 //=============================================================================
360 //=============================================================================
361 QAD_Desktop *SMESHGUI::GetDesktop()
363 return this->myDesktop;
366 //=============================================================================
370 //=============================================================================
371 vtkScalarBarActor *SMESHGUI::GetScalarBar()
373 vtkRenderer *aRenderer =
374 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
375 getRightFrame()->getViewFrame())->getRenderer();
376 vtkActor2DCollection *actor2DList = aRenderer->GetActors2D();
377 actor2DList->InitTraversal();
378 vtkActor2D *aActor2d = actor2DList->GetNextActor2D();
379 while (aActor2d != NULL)
381 if (aActor2d->IsA("vtkScalarBarActor"))
382 return vtkScalarBarActor::SafeDownCast(aActor2d);
383 actor2DList->GetNextActor2D();
388 //=============================================================================
392 //=============================================================================
393 void SMESHGUI::activeStudyChanged(QAD_Desktop * parent)
395 MESSAGE("SMESHGUI::activeStudyChanged init.")
396 /* Create or retrieve an object SMESHGUI */
397 SMESHGUI::GetOrCreateSMESHGUI(parent);
400 smeshGUI->EmitSignalCloseAllDialogs();
401 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
405 //smeshGUI->SetSettings( parent ); //DCQ : Pb. Multi-Etudes
406 MESSAGE("SMESHGUI::activeStudyChanged done.") return;
409 //=============================================================================
413 //=============================================================================
414 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
416 /* Here the position is on the bottom right corner - 10 */
417 aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
418 QAD_Desktop *PP = QAD_Application::getDesktop();
419 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
420 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
424 //=============================================================================
428 //=============================================================================
429 void SMESHGUI::EraseSimulationActors()
431 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
433 vtkRenderer *theRenderer =
434 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
435 getRightFrame()->getViewFrame())->getRenderer();
436 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
438 if (mySimulationActors != NULL)
441 mySimulationActors->InitTraversal();
442 vtkActor *ac = mySimulationActors->GetNextActor();
443 while (!(ac == NULL))
445 theRenderer->RemoveActor(ac);
446 ac = mySimulationActors->GetNextActor();
448 mySimulationActors->RemoveAllItems();
450 if (mySimulationActors2D != NULL)
452 mySimulationActors2D->InitTraversal();
453 vtkActor2D *ac = mySimulationActors2D->GetNextActor2D();
454 while (!(ac == NULL))
456 theRenderer->RemoveActor2D(ac);
457 ac = mySimulationActors2D->GetNextActor2D();
459 mySimulationActors2D->RemoveAllItems();
465 //=============================================================================
469 //=============================================================================
470 SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh(GEOM::GEOM_Shape_ptr aShape,
475 if (!myComponentMesh->_is_nil() && !aShape->_is_nil())
477 SMESH::SMESH_Mesh_var aMesh =
478 myComponentMesh->Init(myComponentGeom, myStudyId, aShape);
480 if (!aMesh->_is_nil())
482 SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
483 myStudyAPI.SetName(SM, NameMesh);
485 // GEOM::GEOM_Shape has non-empty StudyShapeId only after AddInStudy operation,
486 // not after loading from file, so let's use more reliable way to retrieve SObject
487 Standard_CString ShapeIOR = _orb->object_to_string(aShape);
488 SALOMEDS::SObject_var SObject =
489 myStudy->FindObjectIOR(ShapeIOR);
490 if (!SObject->_is_nil() && !SM->_is_nil())
492 myStudyAPI.SetShape(SM, SObject);
494 return SMESH::SMESH_Mesh::_narrow(aMesh);
498 catch(const SALOME::SALOME_Exception & S_ex)
500 QtCatchCorbaException(S_ex);
502 myActiveStudy->updateObjBrowser(true);
503 return SMESH::SMESH_Mesh::_nil();
506 //=============================================================================
510 //=============================================================================
511 SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh(SMESH::SMESH_Mesh_ptr aMesh,
512 GEOM::GEOM_Shape_ptr aShape, QString NameMesh)
516 SMESH::SMESH_subMesh_var aSubMesh = aMesh->GetElementsOnShape(aShape);
517 SALOMEDS::SObject_var SO_Mesh = myStudyAPI.FindMesh(aMesh);
518 Standard_CString ShapeIOR = _orb->object_to_string(aShape);
519 SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectIOR(ShapeIOR);
521 if (!SO_GeomShape->_is_nil() && !SO_Mesh->_is_nil() &&
522 !aSubMesh->_is_nil() && !aMesh->_is_nil())
524 SALOMEDS::SObject_var SO =
525 myStudyAPI.AddSubMeshOnShape(SO_Mesh, SO_GeomShape, aSubMesh,
526 aShape->ShapeType());
527 myStudyAPI.SetName(SO, NameMesh);
529 SMESH_Actor *amesh = SMESH_Actor::New();
530 Handle(SALOME_InteractiveObject) IO =
531 new SALOME_InteractiveObject(SO->GetID(), "MESH",
534 amesh->setName(strdup(NameMesh));
535 DisplayActor(amesh, false);
536 return SMESH::SMESH_subMesh::_narrow(aSubMesh);
539 catch(const SALOME::SALOME_Exception & S_ex)
541 QtCatchCorbaException(S_ex);
543 myActiveStudy->updateObjBrowser(true);
544 return SMESH::SMESH_subMesh::_nil();
547 //=============================================================================
551 //=============================================================================
552 SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis(QString TypeHypothesis,
553 QString NameHypothesis)
555 SMESH::SMESH_Hypothesis_var Hyp;
558 Hyp = myComponentMesh->CreateHypothesis(TypeHypothesis, myStudyId);
561 SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewHypothesis(Hyp);
562 myStudyAPI.SetName(SHyp, NameHypothesis);
565 catch(const SALOME::SALOME_Exception & S_ex)
567 QtCatchCorbaException(S_ex);
570 return SMESH::SMESH_Hypothesis::_narrow(Hyp);
573 //=============================================================================
577 //=============================================================================
578 void SMESHGUI::AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
579 SMESH::SMESH_Hypothesis_ptr aHyp)
581 if (!aMesh->_is_nil())
583 QApplication::setOverrideCursor(Qt::waitCursor);
584 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
585 GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
588 bool res = aMesh->AddHypothesis(aShape, aHyp);
591 SALOMEDS::SObject_var SH =
592 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
593 if (!SM->_is_nil() && !SH->_is_nil())
595 myStudyAPI.SetHypothesis(SM, SH);
596 myStudyAPI.ModifiedMesh(SM, false);
598 QApplication::restoreOverrideCursor();
602 QApplication::restoreOverrideCursor();
603 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
604 tr("SMESH_WRN_WARNING"),
605 tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
606 tr("SMESH_BUT_YES"));
609 catch(const SALOME::SALOME_Exception & S_ex)
611 QtCatchCorbaException(S_ex);
614 myActiveStudy->updateObjBrowser(true);
615 QApplication::restoreOverrideCursor();
618 //=============================================================================
622 //=============================================================================
624 RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject) &
627 if (IObject->hasReference())
629 SMESH::SMESH_Hypothesis_var anHyp;
630 SALOMEDS::SObject_var SO_Hypothesis =
631 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
632 SALOMEDS::GenericAttribute_var anAttr;
633 SALOMEDS::AttributeIOR_var anIOR;
635 if (!SO_Hypothesis->_is_nil())
637 QApplication::setOverrideCursor(Qt::waitCursor);
638 if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR"))
640 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
642 SMESH::SMESH_Hypothesis::_narrow(_orb->
643 string_to_object(anIOR->Value()));
646 SALOMEDS::SObject_var SO_Applied_Hypothesis =
647 smeshGUI->myStudy->FindObjectID(IObject->getReference());
648 if (!SO_Applied_Hypothesis->_is_nil())
650 SALOMEDS::SObject_var MorSM =
651 smeshGUI->myStudyAPI.
652 GetMeshOrSubmesh(SO_Applied_Hypothesis);
653 if (!MorSM->_is_nil())
655 smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
657 GEOM::GEOM_Shape_var aShape =
658 smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
659 if (!aShape->_is_nil())
661 if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
663 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
664 SMESH::SMESH_Mesh_var aMesh =
665 SMESH::SMESH_Mesh::_narrow(_orb->
666 string_to_object(anIOR->Value()));
667 SMESH::SMESH_subMesh_var aSubMesh =
668 SMESH::SMESH_subMesh::_narrow(_orb->
669 string_to_object(anIOR->Value()));
670 if (!aMesh->_is_nil())
673 aMesh->RemoveHypothesis(aShape, anHyp);
676 QApplication::restoreOverrideCursor();
677 QAD_MessageBox::warn1(QAD_Application::
678 getDesktop(), tr("SMESH_WRN_WARNING"),
679 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
680 tr("SMESH_BUT_YES"));
683 else if (!aSubMesh->_is_nil())
685 aMesh = aSubMesh->GetFather();
686 if (!aMesh->_is_nil())
689 aMesh->RemoveHypothesis(aShape, anHyp);
692 QApplication::restoreOverrideCursor();
693 QAD_MessageBox::warn1(QAD_Application::
695 tr("SMESH_WRN_WARNING"),
696 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
697 tr("SMESH_BUT_YES"));
701 if (myAutomaticUpdate)
703 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
711 smeshGUI->ChangeRepresentation(Mesh,
712 Mesh->getDisplayMode());
718 smeshGUI->myStudyAPI.UnSetHypothesis(SO_Applied_Hypothesis);
722 else if (IObject->hasEntry())
724 MESSAGE("IObject entry " << IObject->getEntry())}
725 QApplication::restoreOverrideCursor();
728 //=============================================================================
732 //=============================================================================
733 void SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM,
734 SMESH::SMESH_Hypothesis_ptr anHyp)
736 SALOMEDS::SObject_var AHR, aRef;
737 SALOMEDS::GenericAttribute_var anAttr;
738 SALOMEDS::AttributeIOR_var anIOR;
740 if (!MorSM->_is_nil())
742 GEOM::GEOM_Shape_var aShape =
743 smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
744 if (!aShape->_is_nil())
746 if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
748 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
749 SMESH::SMESH_Mesh_var aMesh =
750 SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
752 SMESH::SMESH_subMesh_var aSubMesh =
753 SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
755 if (!aMesh->_is_nil())
757 bool res = aMesh->RemoveHypothesis(aShape, anHyp);
760 QApplication::restoreOverrideCursor();
761 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
762 tr("SMESH_WRN_WARNING"),
763 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
764 tr("SMESH_BUT_YES"));
767 else if (!aSubMesh->_is_nil())
769 aMesh = aSubMesh->GetFather();
770 if (!aMesh->_is_nil())
772 bool res = aMesh->RemoveHypothesis(aShape, anHyp);
775 QApplication::restoreOverrideCursor();
776 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
777 tr("SMESH_WRN_WARNING"),
778 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
779 tr("SMESH_BUT_YES"));
783 if (myAutomaticUpdate)
785 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
793 // smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() );
799 if (MorSM->FindSubObject(2, AHR))
801 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
802 for (; it->More(); it->Next())
804 SALOMEDS::SObject_var Obj = it->Value();
805 if (Obj->ReferencedObject(aRef))
807 if (aRef->FindAttribute(anAttr, "AttributeIOR"))
809 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
810 if (strcmp(anIOR->Value(),
811 _orb->object_to_string(anHyp)) == 0)
813 smeshGUI->myStudyAPI.UnSetHypothesis(Obj);
820 if (MorSM->FindSubObject(3, AHR))
822 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
823 for (; it->More(); it->Next())
825 SALOMEDS::SObject_var Obj = it->Value();
826 if (Obj->ReferencedObject(aRef))
828 if (aRef->FindAttribute(anAttr, "AttributeIOR"))
830 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
831 if (strcmp(anIOR->Value(),
832 _orb->object_to_string(anHyp)) == 0)
834 smeshGUI->myStudyAPI.UnSetAlgorithm(Obj);
841 smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
843 QApplication::restoreOverrideCursor();
846 //=============================================================================
850 //=============================================================================
851 void SMESHGUI::AddAlgorithmOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
852 SMESH::SMESH_Hypothesis_ptr aHyp)
854 if (!aMesh->_is_nil())
856 QApplication::setOverrideCursor(Qt::waitCursor);
857 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
858 GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
861 bool res = aMesh->AddHypothesis(aShape, aHyp);
864 SALOMEDS::SObject_var SH =
865 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
866 if (!SM->_is_nil() && !SH->_is_nil())
868 myStudyAPI.SetAlgorithms(SM, SH);
869 myStudyAPI.ModifiedMesh(SM, false);
874 QApplication::restoreOverrideCursor();
875 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
876 tr("SMESH_WRN_WARNING"),
877 tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
878 tr("SMESH_BUT_YES"));
881 catch(const SALOME::SALOME_Exception & S_ex)
883 QtCatchCorbaException(S_ex);
886 myActiveStudy->updateObjBrowser(true);
887 QApplication::restoreOverrideCursor();
890 //=============================================================================
894 //=============================================================================
895 void SMESHGUI::AddHypothesisOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
896 SMESH::SMESH_Hypothesis_ptr aHyp)
898 if (!aSubMesh->_is_nil())
900 QApplication::setOverrideCursor(Qt::waitCursor);
903 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
904 SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
905 GEOM::GEOM_Shape_var aShape =
906 myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
907 if (!aMesh->_is_nil())
909 bool res = aMesh->AddHypothesis(aShape, aHyp);
912 SALOMEDS::SObject_var SH =
913 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
914 if (!SsubM->_is_nil() && !SH->_is_nil())
916 myStudyAPI.SetHypothesis(SsubM, SH);
917 myStudyAPI.ModifiedMesh(SsubM, false);
922 QApplication::restoreOverrideCursor();
923 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
924 tr("SMESH_WRN_WARNING"),
925 tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
926 tr("SMESH_BUT_YES"));
930 catch(const SALOME::SALOME_Exception & S_ex)
932 QtCatchCorbaException(S_ex);
935 myActiveStudy->updateObjBrowser(true);
936 QApplication::restoreOverrideCursor();
939 //=============================================================================
943 //=============================================================================
944 void SMESHGUI::AddAlgorithmOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
945 SMESH::SMESH_Hypothesis_ptr aHyp)
947 if (!aSubMesh->_is_nil())
949 QApplication::setOverrideCursor(Qt::waitCursor);
952 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
953 SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
954 GEOM::GEOM_Shape_var aShape =
955 myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
956 if (!aMesh->_is_nil())
958 bool res = aMesh->AddHypothesis(aShape, aHyp);
961 SALOMEDS::SObject_var SH =
962 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
963 if (!SsubM->_is_nil() && !SH->_is_nil())
965 myStudyAPI.SetAlgorithms(SsubM, SH);
966 myStudyAPI.ModifiedMesh(SsubM, false);
971 QApplication::restoreOverrideCursor();
972 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
973 tr("SMESH_WRN_WARNING"),
974 tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
975 tr("SMESH_BUT_YES"));
979 catch(const SALOME::SALOME_Exception & S_ex)
981 QtCatchCorbaException(S_ex);
984 myActiveStudy->updateObjBrowser(true);
985 QApplication::restoreOverrideCursor();
988 //=============================================================================
992 //=============================================================================
993 void SMESHGUI::CreateAlgorithm(QString TypeAlgo, QString NameAlgo)
995 SMESH::SMESH_Hypothesis_var Hyp;
998 if (TypeAlgo.compare("Regular_1D") == 0)
999 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
1000 else if (TypeAlgo.compare("MEFISTO_2D") == 0)
1001 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
1002 else if (TypeAlgo.compare("Quadrangle_2D") == 0)
1003 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
1004 else if (TypeAlgo.compare("Hexa_3D") == 0)
1005 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
1006 else if (TypeAlgo.compare("NETGEN_3D") == 0)
1007 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
1009 if (!Hyp->_is_nil())
1011 SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms(Hyp);
1012 myStudyAPI.SetName(SHyp, NameAlgo);
1015 catch(const SALOME::SALOME_Exception & S_ex)
1017 QtCatchCorbaException(S_ex);
1019 myActiveStudy->updateObjBrowser(true);
1022 //=============================================================================
1026 //=============================================================================
1027 void SMESHGUI::CreateLocalLength(QString TypeHypothesis, QString NameHypothesis,
1030 QApplication::setOverrideCursor(Qt::waitCursor);
1033 SMESH::SMESH_Hypothesis_var Hyp =
1034 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1036 SMESH::SMESH_LocalLength_var LL =
1037 SMESH::SMESH_LocalLength::_narrow(Hyp);
1039 LL->SetLength(Length);
1041 catch(const SALOME::SALOME_Exception & S_ex)
1043 QtCatchCorbaException(S_ex);
1045 myActiveStudy->updateObjBrowser(true);
1046 QApplication::restoreOverrideCursor();
1049 //=============================================================================
1053 //=============================================================================
1054 void SMESHGUI::CreateMaxElementArea(QString TypeHypothesis,
1055 QString NameHypothesis, double MaxArea)
1057 QApplication::setOverrideCursor(Qt::waitCursor);
1060 SMESH::SMESH_Hypothesis_var Hyp =
1061 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1063 SMESH::SMESH_MaxElementArea_var MaxElArea =
1064 SMESH::SMESH_MaxElementArea::_narrow(Hyp);
1065 if (!MaxElArea->_is_nil())
1066 MaxElArea->SetMaxElementArea(MaxArea);
1068 catch(SALOME::SALOME_Exception & S_ex)
1070 QtCatchCorbaException(S_ex);
1073 myActiveStudy->updateObjBrowser(true);
1074 QApplication::restoreOverrideCursor();
1077 //=============================================================================
1081 //=============================================================================
1082 void SMESHGUI::CreateMaxElementVolume(QString TypeHypothesis,
1083 QString NameHypothesis, double MaxVolume)
1085 QApplication::setOverrideCursor(Qt::waitCursor);
1088 SMESH::SMESH_Hypothesis_var Hyp =
1089 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1091 SMESH::SMESH_MaxElementVolume_var MaxElVolume =
1092 SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
1093 if (!MaxElVolume->_is_nil())
1094 MaxElVolume->SetMaxElementVolume(MaxVolume);
1096 catch(const SALOME::SALOME_Exception & S_ex)
1098 QtCatchCorbaException(S_ex);
1100 myActiveStudy->updateObjBrowser(true);
1101 QApplication::restoreOverrideCursor();
1104 //=============================================================================
1108 //=============================================================================
1109 void SMESHGUI::CreateNbSegments(QString TypeHypothesis, QString NameHypothesis,
1112 QApplication::setOverrideCursor(Qt::waitCursor);
1115 SMESH::SMESH_Hypothesis_var Hyp =
1116 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1118 SMESH::SMESH_NumberOfSegments_var NbS =
1119 SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
1120 if (!NbS->_is_nil())
1121 NbS->SetNumberOfSegments(nbSegments);
1123 catch(const SALOME::SALOME_Exception & S_ex)
1125 QtCatchCorbaException(S_ex);
1127 myActiveStudy->updateObjBrowser(true);
1128 QApplication::restoreOverrideCursor();
1131 //=============================================================================
1135 //=============================================================================
1136 int SMESHGUI::GetNameOfSelectedIObjects(SALOME_Selection * Sel, QString & aName)
1138 int nbSel = Sel->IObjectCount();
1141 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1142 aName = IObject->getName();
1146 aName = tr("SMESH_OBJECTS_SELECTED").arg(nbSel);
1151 //=============================================================================
1155 //=============================================================================
1156 int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName)
1159 int nbSel = Sel->IObjectCount();
1162 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1163 if (!IObject->hasEntry())
1166 Standard_Boolean res;
1167 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1171 TColStd_MapOfInteger MapIndex;
1172 Sel->GetIndex(IObject, MapIndex);
1173 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1175 nbNodes = MapIndex.Extent();
1176 for (; ite.More(); ite.Next())
1179 aName + QString("%1").arg(ac->GetIdSMESHDSNode(ite.Key())) +
1190 //=============================================================================
1194 //=============================================================================
1195 int SMESHGUI::GetNameOfSelectedElements(SALOME_Selection * Sel, QString & aName)
1198 int nbSel = Sel->IObjectCount();
1201 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1202 if (!IObject->hasEntry())
1205 Standard_Boolean res;
1206 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1210 TColStd_MapOfInteger MapIndex;
1211 Sel->GetIndex(IObject, MapIndex);
1212 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1214 nbElements = MapIndex.Extent();
1215 MESSAGE("GetNameOfSelectedElements(): number = " << nbElements);
1216 for (; ite.More(); ite.Next())
1218 int idVTK = ite.Key();
1219 MESSAGE("GetNameOfSelectedElements(): VTK Id = " << idVTK);
1221 aName + QString("%1").arg(ac->GetIdSMESHDSElement(idVTK)) + " ";
1231 //=============================================================================
1235 //=============================================================================
1236 int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName)
1239 int nbSel = Sel->IObjectCount();
1242 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1243 if (!IObject->hasEntry())
1246 Standard_Boolean res;
1247 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1251 TColStd_MapOfInteger MapIndex;
1252 Sel->GetIndex(IObject, MapIndex);
1253 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1255 nbElements = MapIndex.Extent();
1256 for (; ite.More(); ite.Next())
1258 aName = aName + QString("%1").arg(ite.Key()) + " ";
1268 //=============================================================================
1272 //=============================================================================
1273 SMESH_Actor *SMESHGUI::FindActorByEntry(QString entry,
1274 Standard_Boolean & testResult, bool onlyInActiveView)
1276 int nbSf = myActiveStudy->getStudyFramesCount();
1277 for (int i = 0; i < nbSf; i++)
1279 QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
1280 if (sf->getTypeView() == VIEW_VTK)
1282 vtkRenderer *Renderer =
1283 ((VTKViewer_ViewFrame *) sf->getRightFrame()->getViewFrame())->
1285 vtkActorCollection *theActors = Renderer->GetActors();
1286 theActors->InitTraversal();
1287 vtkActor *ac = theActors->GetNextActor();
1288 while (!(ac == NULL))
1290 if (ac->IsA("SMESH_Actor"))
1292 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
1293 if (anActor->hasIO())
1295 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
1296 if (strcmp(IO->getEntry(), entry) == 0)
1298 if (onlyInActiveView)
1300 if (sf == myActiveStudy->getActiveStudyFrame())
1314 ac = theActors->GetNextActor();
1319 MESSAGE(" Actor Not Found ") testResult = false;
1320 return SMESH_Actor::New();
1323 //=============================================================================
1327 //=============================================================================
1328 SMESH_Actor *SMESHGUI::FindActor(SMESH::SMESH_Mesh_ptr aMesh,
1329 Standard_Boolean & testResult, bool onlyInActiveView)
1331 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
1334 MESSAGE(" Actor Not Found ") testResult = false;
1335 return SMESH_Actor::New();
1338 return FindActorByEntry(SM->GetID(), testResult, onlyInActiveView);
1341 //=============================================================================
1345 //=============================================================================
1346 SMESH::SMESH_Mesh_ptr SMESHGUI::
1347 ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO,
1348 Standard_Boolean & testResult)
1350 SMESH::SMESH_Mesh_var aMesh;
1356 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1357 SALOMEDS::GenericAttribute_var anAttr;
1358 SALOMEDS::AttributeIOR_var anIOR;
1359 if (!obj->_is_nil())
1361 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1363 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1365 SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
1367 if (!aMesh->_is_nil())
1370 return SMESH::SMESH_Mesh::_duplicate(aMesh);
1375 return SMESH::SMESH_Mesh::_nil();
1378 //=============================================================================
1382 //=============================================================================
1383 SMESH::SMESH_subMesh_ptr SMESHGUI::
1384 ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO,
1385 Standard_Boolean & testResult)
1387 SMESH::SMESH_subMesh_var aSubMesh;
1393 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1394 SALOMEDS::GenericAttribute_var anAttr;
1395 SALOMEDS::AttributeIOR_var anIOR;
1396 if (!obj->_is_nil())
1398 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1400 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1402 SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
1404 if (!aSubMesh->_is_nil())
1407 return SMESH::SMESH_subMesh::_duplicate(aSubMesh);
1412 return SMESH::SMESH_subMesh::_nil();
1415 //=============================================================================
1419 //=============================================================================
1420 SMESH::SMESH_Hypothesis_ptr SMESHGUI::
1421 ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO,
1422 Standard_Boolean & testResult)
1424 SMESH::SMESH_Hypothesis_var aHyp;
1430 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1431 SALOMEDS::GenericAttribute_var anAttr;
1432 SALOMEDS::AttributeIOR_var anIOR;
1433 if (!obj->_is_nil())
1435 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1437 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1439 SMESH::SMESH_Hypothesis::_narrow(_orb->
1440 string_to_object(anIOR->Value()));
1441 if (!aHyp->_is_nil())
1444 return SMESH::SMESH_Hypothesis::_duplicate(aHyp);
1449 return SMESH::SMESH_Hypothesis::_nil();
1452 //=============================================================================
1456 //=============================================================================
1457 GEOM::GEOM_Shape_ptr SMESHGUI::
1458 ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO,
1459 Standard_Boolean & testResult)
1461 GEOM::GEOM_Shape_var aShape;
1467 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1468 SALOMEDS::GenericAttribute_var anAttr;
1469 SALOMEDS::AttributeIOR_var anIOR;
1470 if (!obj->_is_nil())
1472 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1474 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1475 aShape = myComponentGeom->GetIORFromString(anIOR->Value());
1476 if (!aShape->_is_nil())
1479 return GEOM::GEOM_Shape::_duplicate(aShape);
1484 return GEOM::GEOM_Shape::_nil();
1487 //=============================================================================
1491 //=============================================================================
1492 void SMESHGUI::SetViewMode(int commandId)
1494 SALOME_Selection *Sel =
1495 SALOME_Selection::Selection(myActiveStudy->getSelection());
1496 int nbSel = Sel->IObjectCount();
1499 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1500 for (; It.More(); It.Next())
1502 Handle(SALOME_InteractiveObject) IObject = It.Value();
1503 if (IObject->hasEntry())
1505 Standard_Boolean res;
1507 FindActorByEntry(IObject->getEntry(), res, true);
1514 ChangeRepresentation(ac, 0);
1519 ChangeRepresentation(ac, 1);
1524 ChangeRepresentation(ac, 2);
1529 ChangeRepresentation(ac, 3);
1536 if (commandId == 1133)
1538 ChangeRepresentation(SMESH_Actor::New(), 4);
1543 //=============================================================================
1547 //=============================================================================
1548 void SMESHGUI::ChangeRepresentation(SMESH_Actor * ac, int type)
1550 if (ac->DataSource == NULL && type != 4)
1555 if (ac->getMapper() == NULL)
1564 QApplication::setOverrideCursor(Qt::waitCursor);
1565 if (ac->getDisplayMode() == 2)
1567 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1568 vtkDataSetMapper *meshMapper =
1569 (vtkDataSetMapper *) (ac->getMapper());
1570 meshMapper->SetInput(ac->DataSource);
1571 meshMapper->SetScalarVisibility(isColored); //SAL3899
1573 ac->setDisplayMode(0);
1574 ac->GetProperty()->SetRepresentationToWireframe();
1575 // ac->SetActorProperty( ac->GetProperty() );
1576 QApplication::restoreOverrideCursor();
1581 QApplication::setOverrideCursor(Qt::waitCursor);
1582 if (ac->getDisplayMode() == 2)
1584 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1585 vtkDataSetMapper *meshMapper =
1586 (vtkDataSetMapper *) (ac->getMapper());
1587 meshMapper->SetInput(ac->DataSource);
1588 meshMapper->SetScalarVisibility(isColored); //SAL3899
1590 ac->setDisplayMode(1);
1591 ac->GetProperty()->SetRepresentationToSurface();
1592 QApplication::restoreOverrideCursor();
1593 // ac->SetActorProperty( ac->GetProperty() );
1598 // if (!(ac->getDisplayMode()==2)) {
1599 // ChangeRepresentation(ac, 1);
1600 QApplication::setOverrideCursor(Qt::waitCursor);
1601 ac->setDisplayMode(2);
1602 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1603 vtkDataSetMapper *meshMapper = (vtkDataSetMapper *) (ac->getMapper());
1604 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
1605 shrink->SetInput(ac->DataSource);
1606 shrink->SetShrinkFactor(ac->GetShrinkFactor());
1608 meshMapper->SetInput(shrink->GetOutput());
1609 meshMapper->SetScalarVisibility(isColored); //SAL3899
1610 ac->SetMapper(meshMapper);
1611 QApplication::restoreOverrideCursor();
1619 float backfacecolor[3];
1621 ac->GetColor(color[0], color[1], color[2]);
1622 // QColor c(color[0]*255,color[1]*255,color[2]*255);
1623 int c0 = int (color[0] * 255);
1624 int c1 = int (color[1] * 255);
1625 int c2 = int (color[2] * 255);
1626 QColor c(c0, c1, c2);
1627 ac->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1628 // QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255);
1629 c0 = int (edgecolor[0] * 255);
1630 c1 = int (edgecolor[1] * 255);
1631 c2 = int (edgecolor[2] * 255);
1632 QColor e(c0, c1, c2);
1633 ac->GetBackfaceProperty()->GetColor(backfacecolor);
1634 // QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255);
1635 c0 = int (backfacecolor[0] * 255);
1636 c1 = int (backfacecolor[1] * 255);
1637 c2 = int (backfacecolor[2] * 255);
1638 QColor b(c0, c1, c2);
1639 ac->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1640 // QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ;
1641 c0 = int (nodecolor[0] * 255);
1642 c1 = int (nodecolor[1] * 255);
1643 c2 = int (nodecolor[2] * 255);
1644 QColor n(c0, c1, c2);
1646 int Edgewidth = (int)ac->EdgeDevice->GetProperty()->GetLineWidth();
1649 int intValue = ac->GetNodeSize();
1650 float Shrink = ac->GetShrinkFactor();
1652 SMESHGUI_Preferences_ColorDlg *aDlg =
1653 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),
1655 aDlg->SetColor(1, c);
1656 aDlg->SetColor(2, e);
1657 aDlg->SetColor(3, n);
1658 aDlg->SetColor(4, b);
1659 aDlg->SetIntValue(1, Edgewidth);
1660 aDlg->SetIntValue(2, intValue);
1661 aDlg->SetIntValue(3, int (Shrink * 100.));
1665 QApplication::setOverrideCursor(Qt::waitCursor);
1666 QColor color = aDlg->GetColor(1);
1667 QColor edgecolor = aDlg->GetColor(2);
1668 QColor nodecolor = aDlg->GetColor(3);
1669 QColor backfacecolor = aDlg->GetColor(4);
1670 /* actor color and backface color */
1671 ac->GetProperty()->SetColor(float (color.red()) / 255.,
1672 float (color.green()) / 255., float (color.blue()) / 255.);
1673 ac->SetColor(float (color.red()) / 255.,
1674 float (color.green()) / 255., float (color.blue()) / 255.);
1675 ac->GetBackfaceProperty()->SetColor(float (backfacecolor.red()) /
1676 255., float (backfacecolor.green()) / 255.,
1677 float (backfacecolor.blue()) / 255.);
1680 ac->EdgeDevice->GetProperty()->SetColor(float (edgecolor.red()) /
1681 255., float (edgecolor.green()) / 255.,
1682 float (edgecolor.blue()) / 255.);
1683 ac->EdgeShrinkDevice->GetProperty()->SetColor(float (edgecolor.
1684 red()) / 255., float (edgecolor.green()) / 255.,
1685 float (edgecolor.blue()) / 255.);
1686 ac->SetEdgeColor(float (edgecolor.red()) / 255.,
1687 float (edgecolor.green()) / 255.,
1688 float (edgecolor.blue()) / 255.);
1690 /* Shrink factor and size edges */
1691 ac->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
1692 ac->EdgeDevice->GetProperty()->SetLineWidth(aDlg->GetIntValue(1));
1693 ac->EdgeShrinkDevice->GetProperty()->SetLineWidth(aDlg->
1696 /* Nodes color and size */
1697 ac->SetNodeColor(float (nodecolor.red()) / 255.,
1698 float (nodecolor.green()) / 255.,
1699 float (nodecolor.blue()) / 255.);
1700 ac->SetNodeSize(aDlg->GetIntValue(2));
1702 if (ac->getDisplayMode() == 2)
1704 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1705 vtkDataSetMapper *meshMapper =
1706 (vtkDataSetMapper *) (ac->getMapper());
1707 meshMapper->SetInput(ac->DataSource);
1708 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
1709 shrink->SetInput(meshMapper->GetInput());
1710 shrink->SetShrinkFactor(ac->GetShrinkFactor());
1712 meshMapper->SetInput(shrink->GetOutput());
1713 meshMapper->SetScalarVisibility(isColored); //SAL3899
1714 ac->SetMapper(meshMapper);
1718 QApplication::restoreOverrideCursor();
1723 EmitSignalDeactivateDialog();
1724 SALOME_Selection *Sel =
1725 SALOME_Selection::Selection(myActiveStudy->getSelection());
1726 SMESHGUI_TransparencyDlg *aDlg =
1727 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(), "",
1733 QApplication::setOverrideCursor(Qt::waitCursor);
1734 ac->GetProperty()->SetRepresentationToPoints();
1735 QApplication::restoreOverrideCursor();
1740 QApplication::setOverrideCursor(Qt::waitCursor);
1741 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
1743 vtkRenderer *theRenderer =
1744 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1745 getRightFrame()->getViewFrame())->getRenderer();
1746 theRenderer->Render();
1748 QApplication::restoreOverrideCursor();
1751 //=============================================================================
1755 //=============================================================================
1756 void SMESHGUI::UpdateView()
1758 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1761 vtkRenderer *theRenderer =
1762 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1763 getRightFrame()->getViewFrame())->getRenderer();
1764 theRenderer->Render();
1767 //=============================================================================
1771 //=============================================================================
1772 void SMESHGUI::DisplayActor(SMESH_Actor * ac, bool visibility)
1774 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1777 MESSAGE("DisplayActor(): DataSource = " << ac->DataSource);
1779 vtkRenderer *theRenderer =
1780 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1781 getRightFrame()->getViewFrame())->getRenderer();
1782 vtkActorCollection *theActors = theRenderer->GetActors();
1783 theActors->InitTraversal();
1784 if (theActors->IsItemPresent(ac) == 0)
1786 vtkProperty *prop = vtkProperty::New();
1787 prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
1789 QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
1791 QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
1794 prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
1796 prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
1798 ac->SetProperty(prop);
1799 ac->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
1801 QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
1803 QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
1806 // prop->BackfaceCullingOn();
1807 vtkProperty *backprop = vtkProperty::New();
1808 backprop->SetColor(QAD_CONFIG->
1809 getSetting("SMESH:SettingsBackFaceColorRed").toFloat() / 255.,
1810 QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen").
1812 QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue").
1814 ac->SetBackfaceProperty(backprop);
1817 QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff").toInt();
1820 ac->SetShrinkFactor(intValue / 100.);
1822 ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer();
1823 ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02);
1825 QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
1826 if (DisplayMode.compare("Wireframe") == 0)
1828 ac->setDisplayMode(0);
1829 ChangeRepresentation(ac, 0);
1831 else if (DisplayMode.compare("Shading") == 0)
1833 ac->setDisplayMode(1);
1834 ChangeRepresentation(ac, 1);
1836 else if (DisplayMode.compare("Shrink") == 0)
1838 ac->setDisplayMode(2);
1839 ChangeRepresentation(ac, 2);
1841 theRenderer->AddActor(ac);
1845 if (ac->GetMapper())
1846 ac->GetMapper()->Update();
1849 // if ( visibility )
1850 ac->SetVisibility(visibility);
1851 // ac->VisibilityOn();
1853 // ac->VisibilityOff();
1855 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
1859 //=============================================================================
1863 //=============================================================================
1864 void SMESHGUI::EraseActor(SMESH_Actor * ac)
1866 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1869 vtkRenderer *theRenderer =
1870 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1871 getRightFrame()->getViewFrame())->getRenderer();
1873 //NRI- : 02/12/2002 : Fixed bugId 882
1874 // ac->EdgeDevice->VisibilityOff();
1875 // ac->EdgeShrinkDevice->VisibilityOff();
1876 // ac->VisibilityOff();
1877 ac->SetVisibility(false);
1879 theRenderer->Render();
1882 //=============================================================================
1886 //=============================================================================
1887 bool SMESHGUI::AddActorInSelection(SMESH_Actor * ac)
1889 SALOME_Selection *Sel =
1890 SALOME_Selection::Selection(myActiveStudy->getSelection());
1891 Sel->ClearIObjects();
1893 return Sel->AddIObject(ac->getIO());
1898 //=============================================================================
1902 //=============================================================================
1903 QString SMESHGUI::CheckHomogeneousSelection()
1905 SALOME_Selection *Sel =
1906 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
1909 SALOME_ListIteratorOfListIO Itinit(Sel->StoredIObjects());
1910 for (; Itinit.More(); Itinit.Next())
1912 List.Append(Itinit.Value());
1915 QString RefType = CheckTypeObject(Sel->firstIObject());
1916 SALOME_ListIteratorOfListIO It(List);
1917 for (; It.More(); It.Next())
1919 Handle(SALOME_InteractiveObject) IObject = It.Value();
1920 QString Type = CheckTypeObject(IObject);
1921 if (Type.compare(RefType) != 0)
1922 return "Heterogeneous Selection";
1925 Sel->ClearIObjects();
1926 SALOME_ListIteratorOfListIO It1(List);
1927 for (; It1.More(); It1.Next())
1929 int res = Sel->AddIObject(It1.Value());
1931 myActiveStudy->highlight(It1.Value(), false);
1933 myActiveStudy->highlight(It1.Value(), true);
1938 //=============================================================================
1942 //=============================================================================
1943 QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject) & IO)
1945 SALOMEDS::SObject_var sobj =
1946 smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->
1948 if (!sobj->_is_nil())
1950 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
1951 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
1952 { // component is selected
1957 SALOME_Selection *Sel =
1958 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
1959 Sel->ClearIObjects();
1961 Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS);
1962 Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM);
1963 Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH);
1964 Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH);
1965 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter =
1966 new SMESH_TypeFilter(MESHorSUBMESH);
1967 Handle(SMESH_TypeFilter) aSubMeshVextexFilter =
1968 new SMESH_TypeFilter(SUBMESH_VERTEX);
1969 Handle(SMESH_TypeFilter) aSubMeshEdgeFilter =
1970 new SMESH_TypeFilter(SUBMESH_EDGE);
1971 Handle(SMESH_TypeFilter) aSubMeshFaceFilter =
1972 new SMESH_TypeFilter(SUBMESH_FACE);
1973 Handle(SMESH_TypeFilter) aSubMeshSolidFilter =
1974 new SMESH_TypeFilter(SUBMESH_SOLID);
1975 Handle(SMESH_TypeFilter) aSubMeshCompoundFilter =
1976 new SMESH_TypeFilter(SUBMESH_COMPOUND);
1978 Sel->AddFilter(aHypFilter);
1979 if (Sel->AddIObject(IO) != -1)
1981 Sel->ClearFilters();
1982 return "Hypothesis";
1985 Sel->ClearFilters();
1986 Sel->AddFilter(anAlgoFilter);
1987 if (Sel->AddIObject(IO) != -1)
1989 Sel->ClearFilters();
1993 Sel->ClearFilters();
1994 Sel->AddFilter(aMeshFilter);
1995 if (Sel->AddIObject(IO) != -1)
1997 Sel->ClearFilters();
2001 Sel->ClearFilters();
2002 Sel->AddFilter(aSubMeshFilter);
2003 if (Sel->AddIObject(IO) != -1)
2005 Sel->ClearFilters();
2009 Sel->ClearFilters();
2010 Sel->AddFilter(aSubMeshVextexFilter);
2011 if (Sel->AddIObject(IO) != -1)
2013 Sel->ClearFilters();
2014 return "SubMeshVertex";
2017 Sel->ClearFilters();
2018 Sel->AddFilter(aSubMeshEdgeFilter);
2019 if (Sel->AddIObject(IO) != -1)
2021 Sel->ClearFilters();
2022 return "SubMeshEdge";
2025 Sel->ClearFilters();
2026 Sel->AddFilter(aSubMeshFaceFilter);
2027 if (Sel->AddIObject(IO) != -1)
2029 Sel->ClearFilters();
2030 return "SubMeshFace";
2033 Sel->ClearFilters();
2034 Sel->AddFilter(aSubMeshSolidFilter);
2035 if (Sel->AddIObject(IO) != -1)
2037 Sel->ClearFilters();
2038 return "SubMeshSolid";
2041 Sel->ClearFilters();
2042 Sel->AddFilter(aSubMeshCompoundFilter);
2043 if (Sel->AddIObject(IO) != -1)
2045 Sel->ClearFilters();
2046 return "SubMeshCompound";
2049 Sel->ClearFilters();
2050 Sel->AddIObject(IO);
2054 //=============================================================================
2058 //=============================================================================
2059 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
2061 /* Create or retrieve an object SMESHGUI */
2062 SMESHGUI::GetOrCreateSMESHGUI(parent);
2064 // NRI : Temporary added
2065 if (smeshGUI->myStudy->GetProperties()->IsLocked())
2071 // QAD_Viewer3d* v3d;
2072 OCCViewer_Viewer3d *v3d;
2074 Handle(AIS_InteractiveContext) ic;
2075 vtkRenderer *Renderer;
2076 vtkRenderWindow *RenWin;
2078 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2082 ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy->
2083 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2085 ic = v3d->getAISContext();
2087 else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2091 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2092 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2094 RenWin = Renderer->GetRenderWindow();
2097 switch (theCommandID)
2100 smeshGUI->OnEditDelete();
2107 Import_Document(parent, theCommandID); //NBU
2108 //Import_Mesh(parent,theCommandID);
2112 case 122: // EXPORT MED
2116 Export_Mesh(parent, theCommandID);
2120 case 200: // SCALAR BAR
2122 smeshGUI->DisplayScalarBar(false);
2127 SMESHGUI_EditScalarBarDlg *aDlg =
2128 new SMESHGUI_EditScalarBarDlg(parent, "", false);
2134 smeshGUI->DisplayScalarBar(true);
2138 case 1133: // DISPLAY MODE : WireFrame, Surface, Shrink
2144 smeshGUI->SetViewMode(theCommandID);
2156 SALOME_Selection *Sel =
2157 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2159 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2163 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2164 for (; It.More(); It.Next())
2166 Handle(SALOME_InteractiveObject) IOS = It.Value();
2167 if (IOS->hasEntry())
2169 Standard_Boolean res;
2171 smeshGUI->FindActorByEntry(IOS->getEntry(), res, true);
2173 smeshGUI->EraseActor(ac);
2177 Sel->ClearIObjects();
2178 smeshGUI->myActiveStudy->updateObjBrowser(true);
2181 case 301: // DISPLAY
2183 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2187 QApplication::setOverrideCursor(Qt::waitCursor);
2188 SALOMEDS::SObject_var fatherSF =
2189 smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
2190 getActiveStudyFrame()->entry());
2192 SALOME_Selection *Sel =
2193 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2195 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2197 for (; It.More(); It.Next())
2199 Handle(SALOME_InteractiveObject) IObject = It.Value();
2200 if (IObject->hasEntry())
2202 Standard_Boolean res;
2204 smeshGUI->FindActorByEntry(IObject->getEntry(), res,
2208 smeshGUI->DisplayActor(ac, true);
2209 smeshGUI->DisplayEdges(ac);
2210 smeshGUI->ChangeRepresentation(ac,
2211 ac->getDisplayMode());
2215 QApplication::restoreOverrideCursor();
2220 case 302: // DISPLAY ONLY
2222 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2225 QApplication::setOverrideCursor(Qt::waitCursor);
2226 vtkActorCollection *theActors = Renderer->GetActors();
2227 theActors->InitTraversal();
2228 vtkActor *ac = theActors->GetNextActor();
2229 while (!(ac == NULL))
2231 if (ac->IsA("SMESH_Actor"))
2233 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
2234 if (!anActor->isHighlighted())
2236 //anActor->VisibilityOff();
2237 //NRI- : 02/12/2002 : Fixed bugId 882
2238 // anActor->EdgeDevice->VisibilityOff();
2239 // anActor->EdgeShrinkDevice->VisibilityOff();
2240 anActor->SetVisibility(false);
2243 ac = theActors->GetNextActor();
2246 // Display selection
2247 SALOMEDS::SObject_var fatherSF =
2248 smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
2249 getActiveStudyFrame()->entry());
2251 SALOME_Selection *Sel =
2252 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2254 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2256 for (; It.More(); It.Next())
2258 Handle(SALOME_InteractiveObject) IObject = It.Value();
2259 SALOMEDS::SObject_var obj =
2260 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
2262 VTKViewer_RenderWindowInteractor *myRenderInter =
2263 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2264 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2266 // vtkQGLRenderWindowInteractor* myRenderInter= smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
2268 if (myRenderInter->isInViewer(IObject))
2270 if (IObject->hasEntry())
2272 Standard_Boolean res;
2274 smeshGUI->FindActorByEntry(IObject->getEntry(), res,
2278 smeshGUI->DisplayActor(ac, true);
2279 smeshGUI->DisplayEdges(ac);
2280 smeshGUI->ChangeRepresentation(ac,
2281 ac->getDisplayMode());
2286 smeshGUI->myActiveStudy->updateObjBrowser(true);
2287 QApplication::restoreOverrideCursor();
2294 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2297 smeshGUI->EmitSignalDeactivateDialog();
2298 SALOME_Selection *Sel =
2299 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2301 Sel->ClearIObjects();
2302 smeshGUI->myDesktop->SetSelectionMode(1, true);
2303 parent->menuBar()->setItemChecked(9010, false);
2304 parent->menuBar()->setItemChecked(9011, false);
2305 smeshGUI->ViewNodes();
2306 SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
2310 QApplication::restoreOverrideCursor();
2311 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2313 tr("SMESH_BUT_YES"));
2318 case 405: // MOVE NODE
2320 smeshGUI->myDesktop->SetSelectionMode(1, true);
2321 SALOME_Selection *Sel =
2322 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2324 SMESHGUI_MoveNodesDlg *aDlg =
2325 new SMESHGUI_MoveNodesDlg(parent, "", Sel);
2329 case 701: // COMPUTE MESH
2331 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2334 SALOME_Selection *Sel =
2335 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2337 int nbSel = Sel->IObjectCount();
2340 QApplication::restoreOverrideCursor();
2344 SMESH::SMESH_Mesh_var aM;
2345 SMESH::SMESH_subMesh_var aSubM;
2346 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2347 if (IObject->hasEntry())
2349 SALOMEDS::SObject_var aMorSM =
2350 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
2351 SALOMEDS::GenericAttribute_var anAttr;
2352 SALOMEDS::AttributeIOR_var anIOR;
2353 if (!aMorSM->_is_nil())
2355 if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
2357 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2358 MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "
2359 << anIOR->Value())CORBA::Object_var cobj;
2362 cobj = _orb->string_to_object(anIOR->Value());
2363 if (CORBA::is_nil(cobj))
2366 ("SMESHGUI::OnGUIEvent - Compute mesh : nil object")}
2368 catch(CORBA::COMM_FAILURE & ex)
2371 ("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)")}
2372 aM = SMESH::SMESH_Mesh::_narrow(cobj);
2373 //aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
2375 SMESH::SMESH_subMesh::_narrow(_orb->
2376 string_to_object(anIOR->Value()));
2379 GEOM::GEOM_Shape_var refShape =
2380 smeshGUI->myStudyAPI.
2381 GetShapeOnMeshOrSubMesh(aMorSM);
2382 if (!refShape->_is_nil())
2385 smeshGUI->myComponentMesh->
2386 IsReadyToCompute(aM, refShape);
2389 QApplication::restoreOverrideCursor();
2390 QAD_MessageBox::warn1(QAD_Application::
2391 getDesktop(), tr("SMESH_WRN_WARNING"),
2392 tr("SMESH_WRN_MISSING_PARAMETERS"),
2393 tr("SMESH_BUT_YES"));
2398 smeshGUI->myComponentMesh->Compute(aM,
2400 smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
2402 // TO Do : change icon of all submeshes
2404 catch(const SALOME::SALOME_Exception & S_ex)
2406 QtCatchCorbaException(S_ex);
2410 else if (!aSubM->_is_nil())
2412 aM = aSubM->GetFather();
2413 GEOM::GEOM_Shape_var refShape =
2414 smeshGUI->myStudyAPI.
2415 GetShapeOnMeshOrSubMesh(aMorSM);
2416 if (!refShape->_is_nil())
2419 smeshGUI->myComponentMesh->
2420 IsReadyToCompute(aM, refShape);
2423 QApplication::restoreOverrideCursor();
2424 QAD_MessageBox::warn1(QAD_Application::
2425 getDesktop(), tr("SMESH_WRN_WARNING"),
2426 tr("SMESH_WRN_MISSING_PARAMETERS"),
2427 tr("SMESH_BUT_YES"));
2432 smeshGUI->myComponentMesh->Compute(aM,
2434 smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
2436 // TO Do : change icon of all submeshes
2438 catch(const SALOME::SALOME_Exception & S_ex)
2440 QtCatchCorbaException(S_ex);
2448 // Check whether the actor for the mesh exists at least in one view
2449 Standard_Boolean res;
2451 smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
2453 smeshGUI->InitActor(aM);
2456 // Check whether the actor belongs to the active view
2457 VTKViewer_RenderWindowInteractor *rwInter =
2458 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2459 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2462 // The actor belongs to inactive view -> create a copy and add it in the active view
2463 if (!rwInter->isInViewer(IObject))
2465 SMESH_Actor *acCopy = SMESH_Actor::New();
2466 acCopy->ShallowCopy(ac);
2468 smeshGUI->DisplayActor(acCopy, false);
2472 if (smeshGUI->myAutomaticUpdate)
2474 SMESH_Actor *Mesh = smeshGUI->ReadScript(aM);
2480 smeshGUI->DisplayActor(Mesh, true);
2481 smeshGUI->DisplayEdges(Mesh, true);
2482 smeshGUI->ChangeRepresentation(Mesh,
2483 Mesh->getDisplayMode());
2489 QApplication::restoreOverrideCursor();
2490 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2491 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2492 tr("SMESH_BUT_YES"));
2494 QApplication::restoreOverrideCursor();
2498 case 702: // ADD SUB MESH
2500 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2503 smeshGUI->EmitSignalDeactivateDialog();
2504 SALOME_Selection *Sel =
2505 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2507 SMESHGUI_AddSubMeshDlg *aDlg =
2508 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
2512 QApplication::restoreOverrideCursor();
2513 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2514 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2515 tr("SMESH_BUT_YES"));
2520 case 703: // INIT MESH
2522 smeshGUI->EmitSignalDeactivateDialog();
2523 SALOME_Selection *Sel =
2524 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2526 SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
2530 case 704: // EDIT Hypothesis
2532 smeshGUI->EmitSignalDeactivateDialog();
2533 SALOME_Selection *Sel =
2534 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2536 SMESHGUI_EditHypothesesDlg *aDlg =
2537 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2541 case 705: // EDIT Global Hypothesis
2543 smeshGUI->EmitSignalDeactivateDialog();
2544 SALOME_Selection *Sel =
2545 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2547 SMESHGUI_EditHypothesesDlg *aDlg =
2548 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2552 case 706: // EDIT Local Hypothesis
2554 smeshGUI->EmitSignalDeactivateDialog();
2555 SALOME_Selection *Sel =
2556 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2558 SMESHGUI_EditHypothesesDlg *aDlg =
2559 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2563 case 806: // ORIENTATION ELEMENTS
2565 smeshGUI->EmitSignalDeactivateDialog();
2566 SALOME_Selection *Sel =
2567 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2569 smeshGUI->myDesktop->SetSelectionMode(3, true);
2570 SMESHGUI_OrientationElementsDlg *aDlg =
2571 new SMESHGUI_OrientationElementsDlg(parent, "", Sel);
2575 case 807: // DIAGONAL INVERSION
2577 smeshGUI->EmitSignalDeactivateDialog();
2578 SALOME_Selection *Sel =
2579 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2581 Sel->ClearIObjects();
2582 smeshGUI->myDesktop->SetSelectionMode(2, true);
2583 SMESHGUI_DiagonalInversionDlg *aDlg =
2584 new SMESHGUI_DiagonalInversionDlg(parent, "", Sel);
2588 case 900: // MESH INFOS
2590 smeshGUI->EmitSignalDeactivateDialog();
2591 SALOME_Selection *Sel =
2592 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2594 SMESHGUI_MeshInfosDlg *aDlg =
2595 new SMESHGUI_MeshInfosDlg(parent, "", Sel);
2599 case 1001: // AUTOMATIC UPDATE PREFERENCES
2601 parent->menuBar()->setItemChecked(1001,
2602 !parent->menuBar()->isItemChecked(1001));
2603 if (parent->menuBar()->isItemChecked(1001))
2605 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
2606 smeshGUI->myAutomaticUpdate = true;
2610 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
2611 smeshGUI->myAutomaticUpdate = false;
2616 case 1003: // MESH PREFERENCES
2618 smeshGUI->SetDisplaySettings();
2624 QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
2625 QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
2626 QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
2627 QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
2628 QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation");
2629 float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
2630 float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
2631 int NumberOfLabels =
2632 QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
2633 int NumberOfColors =
2634 QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
2640 if (NumberOfLabels == 0)
2642 if (NumberOfColors == 0)
2643 NumberOfColors = 64;
2645 SMESHGUI_Preferences_ScalarBarDlg *aDlg =
2646 new SMESHGUI_Preferences_ScalarBarDlg(parent, "", true);
2648 if (Bold.compare("true") == 0)
2649 aDlg->Bold->setChecked(true);
2651 aDlg->Bold->setChecked(false);
2652 if (Italic.compare("true") == 0)
2653 aDlg->Italic->setChecked(true);