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"
91 #define INCLUDE_MENUITEM_DEF
92 #include <qapplication.h>
93 #include <qlineedit.h>
94 #include <qmenudata.h>
96 #include <qpopupmenu.h>
99 #include <qcheckbox.h>
100 #include <qcolordialog.h>
101 #include <qmessagebox.h>
102 #include <qspinbox.h>
106 #include <qradiobutton.h>
109 #include "VTKViewer_Common.h"
110 #include "VTKViewer_ViewFrame.h"
111 #include <vtkLegendBoxActor.h>
112 #include <vtkFeatureEdges.h>
113 #include <vtkDoubleArray.h>
115 // Open CASCADE Includes
116 #include <gp_Pnt.hxx>
117 #include <gp_Vec.hxx>
119 static GEOM_Client ShapeReader;
120 static SMESHGUI *smeshGUI = 0;
121 static CORBA::ORB_var _orb;
123 //=============================================================================
127 //=============================================================================
128 class CustomItem:public QCustomMenuItem
131 CustomItem(const QString & s, const QFont & f):string(s), font(f)
138 void paint(QPainter * p, const QColorGroup & /*cg */ , bool /*act */ ,
139 bool /*enabled */ , int x, int y, int w, int h)
142 p->drawText(x, y, w, h,
143 AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
148 return QFontMetrics(font).
149 size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
156 //=============================================================================
160 //=============================================================================
161 SMESHGUI::SMESHGUI():
166 //=============================================================================
170 //=============================================================================
171 SMESHGUI::~SMESHGUI()
175 //=============================================================================
179 //=============================================================================
180 SMESHGUI *SMESHGUI::GetSMESHGUI()
185 //=============================================================================
189 //=============================================================================
190 SMESHGUI *SMESHGUI::GetOrCreateSMESHGUI(QAD_Desktop * desktop)
195 smeshGUI = new SMESHGUI;
196 smeshGUI->myActiveDialogBox = 0;
197 smeshGUI->myState = -1;
198 smeshGUI->myDesktop = desktop;
199 smeshGUI->myActiveStudy = desktop->getActiveStudy();
201 Engines::Component_var comp =
202 desktop->getEngine("FactoryServer", "SMESH");
203 smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp);
205 Engines::Component_var comp1 =
206 desktop->getEngine("FactoryServer", "GEOM");
207 smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1);
209 /* GetCurrentStudy */
210 smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId();
212 smeshGUI->myComponentGeom->GetCurrentStudy(smeshGUI->myStudyId);
213 // smeshGUI->myComponentGeom->NbLabels();
215 smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument();
217 smeshGUI->myStudyAPI =
218 SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh);
220 smeshGUI->mySimulationActors = vtkActorCollection::New();
221 smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
225 /* study may have changed */
226 smeshGUI->myActiveStudy = desktop->getActiveStudy();
227 smeshGUI->myStudyAPI.Update(smeshGUI->myComponentMesh);
230 /* Automatic Update */
231 if (desktop->menuBar()->isItemChecked(1001))
232 smeshGUI->myAutomaticUpdate = true;
234 smeshGUI->myAutomaticUpdate = false;
239 //=============================================================================
243 //=============================================================================
244 void SMESHGUI::SetState(int aState)
246 this->myState = aState;
250 //=============================================================================
254 //=============================================================================
255 void SMESHGUI::ResetState()
261 //=============================================================================
265 //=============================================================================
266 void SMESHGUI::EmitSignalDeactivateDialog()
268 emit this->SignalDeactivateActiveDialog();
272 //=============================================================================
276 //=============================================================================
277 void SMESHGUI::EmitSignalCloseAllDialogs()
279 emit this->SignalCloseAllDialogs();
283 //=============================================================================
287 //=============================================================================
288 QDialog *SMESHGUI::GetActiveDialogBox()
290 return this->myActiveDialogBox;
293 //=============================================================================
297 //=============================================================================
298 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
300 this->myActiveDialogBox = (QDialog *) aDlg;
304 //=============================================================================
308 //=============================================================================
309 QAD_Study *SMESHGUI::GetActiveStudy()
311 return this->myActiveStudy;
314 //=============================================================================
318 //=============================================================================
319 SALOMEDS::Study_ptr SMESHGUI::GetStudy()
321 return SALOMEDS::Study::_narrow(myStudy);
324 //=============================================================================
328 //=============================================================================
329 SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI()
334 //=============================================================================
338 //=============================================================================
339 QAD_Desktop *SMESHGUI::GetDesktop()
341 return this->myDesktop;
344 //=============================================================================
348 //=============================================================================
349 vtkScalarBarActor *SMESHGUI::GetScalarBar()
351 vtkRenderer *aRenderer =
352 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
353 getRightFrame()->getViewFrame())->getRenderer();
354 vtkActor2DCollection *actor2DList = aRenderer->GetActors2D();
355 actor2DList->InitTraversal();
356 vtkActor2D *aActor2d = actor2DList->GetNextActor2D();
357 while (aActor2d != NULL)
359 if (aActor2d->IsA("vtkScalarBarActor"))
360 return vtkScalarBarActor::SafeDownCast(aActor2d);
361 actor2DList->GetNextActor2D();
366 //=============================================================================
370 //=============================================================================
371 void SMESHGUI::activeStudyChanged(QAD_Desktop * parent)
373 MESSAGE("SMESHGUI::activeStudyChanged init.")
374 /* Create or retrieve an object SMESHGUI */
375 SMESHGUI::GetOrCreateSMESHGUI(parent);
378 smeshGUI->EmitSignalCloseAllDialogs();
379 MESSAGE("Active study changed : SMESHGUI nullified" << endl);
383 //smeshGUI->SetSettings( parent ); //DCQ : Pb. Multi-Etudes
384 MESSAGE("SMESHGUI::activeStudyChanged done.") return;
387 //=============================================================================
391 //=============================================================================
392 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
394 /* Here the position is on the bottom right corner - 10 */
395 aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
396 QAD_Desktop *PP = QAD_Application::getDesktop();
397 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
398 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
402 //=============================================================================
406 //=============================================================================
407 void SMESHGUI::EraseSimulationActors()
409 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
411 vtkRenderer *theRenderer =
412 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
413 getRightFrame()->getViewFrame())->getRenderer();
414 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
416 if (mySimulationActors != NULL)
419 mySimulationActors->InitTraversal();
420 vtkActor *ac = mySimulationActors->GetNextActor();
421 while (!(ac == NULL))
423 theRenderer->RemoveActor(ac);
424 ac = mySimulationActors->GetNextActor();
426 mySimulationActors->RemoveAllItems();
428 if (mySimulationActors2D != NULL)
430 mySimulationActors2D->InitTraversal();
431 vtkActor2D *ac = mySimulationActors2D->GetNextActor2D();
432 while (!(ac == NULL))
434 theRenderer->RemoveActor2D(ac);
435 ac = mySimulationActors2D->GetNextActor2D();
437 mySimulationActors2D->RemoveAllItems();
443 //=============================================================================
447 //=============================================================================
448 SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh(GEOM::GEOM_Shape_ptr aShape,
453 if (!myComponentMesh->_is_nil() && !aShape->_is_nil())
455 SMESH::SMESH_Mesh_var aMesh =
456 myComponentMesh->Init(myComponentGeom, myStudyId, aShape);
458 if (!aMesh->_is_nil())
460 SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
461 myStudyAPI.SetName(SM, NameMesh);
463 // GEOM::GEOM_Shape has non-empty StudyShapeId only after AddInStudy operation,
464 // not after loading from file, so let's use more reliable way to retrieve SObject
465 Standard_CString ShapeIOR = _orb->object_to_string(aShape);
466 SALOMEDS::SObject_var SObject =
467 myStudy->FindObjectIOR(ShapeIOR);
468 if (!SObject->_is_nil() && !SM->_is_nil())
470 myStudyAPI.SetShape(SM, SObject);
472 return SMESH::SMESH_Mesh::_narrow(aMesh);
476 catch(const SALOME::SALOME_Exception & S_ex)
478 QtCatchCorbaException(S_ex);
480 myActiveStudy->updateObjBrowser(true);
481 return SMESH::SMESH_Mesh::_nil();
484 //=============================================================================
488 //=============================================================================
489 SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh(SMESH::SMESH_Mesh_ptr aMesh,
490 GEOM::GEOM_Shape_ptr aShape, QString NameMesh)
494 SMESH::SMESH_subMesh_var aSubMesh = aMesh->GetElementsOnShape(aShape);
495 SALOMEDS::SObject_var SO_Mesh = myStudyAPI.FindMesh(aMesh);
496 Standard_CString ShapeIOR = _orb->object_to_string(aShape);
497 SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectIOR(ShapeIOR);
499 if (!SO_GeomShape->_is_nil() && !SO_Mesh->_is_nil() &&
500 !aSubMesh->_is_nil() && !aMesh->_is_nil())
502 SALOMEDS::SObject_var SO =
503 myStudyAPI.AddSubMeshOnShape(SO_Mesh, SO_GeomShape, aSubMesh,
504 aShape->ShapeType());
505 myStudyAPI.SetName(SO, NameMesh);
507 SMESH_Actor *amesh = SMESH_Actor::New();
508 Handle(SALOME_InteractiveObject) IO =
509 new SALOME_InteractiveObject(SO->GetID(), "MESH",
512 amesh->setName(strdup(NameMesh));
513 DisplayActor(amesh, false);
514 return SMESH::SMESH_subMesh::_narrow(aSubMesh);
517 catch(const SALOME::SALOME_Exception & S_ex)
519 QtCatchCorbaException(S_ex);
521 myActiveStudy->updateObjBrowser(true);
522 return SMESH::SMESH_subMesh::_nil();
525 //=============================================================================
529 //=============================================================================
530 SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis(QString TypeHypothesis,
531 QString NameHypothesis)
533 SMESH::SMESH_Hypothesis_var Hyp;
536 Hyp = myComponentMesh->CreateHypothesis(TypeHypothesis, myStudyId);
539 SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewHypothesis(Hyp);
540 myStudyAPI.SetName(SHyp, NameHypothesis);
543 catch(const SALOME::SALOME_Exception & S_ex)
545 QtCatchCorbaException(S_ex);
548 return SMESH::SMESH_Hypothesis::_narrow(Hyp);
551 //=============================================================================
555 //=============================================================================
556 void SMESHGUI::AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
557 SMESH::SMESH_Hypothesis_ptr aHyp)
559 if (!aMesh->_is_nil())
561 QApplication::setOverrideCursor(Qt::waitCursor);
562 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
563 GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
566 bool res = aMesh->AddHypothesis(aShape, aHyp);
569 SALOMEDS::SObject_var SH =
570 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
571 if (!SM->_is_nil() && !SH->_is_nil())
573 myStudyAPI.SetHypothesis(SM, SH);
574 myStudyAPI.ModifiedMesh(SM, false);
576 QApplication::restoreOverrideCursor();
580 QApplication::restoreOverrideCursor();
581 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
582 tr("SMESH_WRN_WARNING"),
583 tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
584 tr("SMESH_BUT_YES"));
587 catch(const SALOME::SALOME_Exception & S_ex)
589 QtCatchCorbaException(S_ex);
592 myActiveStudy->updateObjBrowser(true);
593 QApplication::restoreOverrideCursor();
596 //=============================================================================
600 //=============================================================================
602 RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject) &
605 if (IObject->hasReference())
607 SMESH::SMESH_Hypothesis_var anHyp;
608 SALOMEDS::SObject_var SO_Hypothesis =
609 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
610 SALOMEDS::GenericAttribute_var anAttr;
611 SALOMEDS::AttributeIOR_var anIOR;
613 if (!SO_Hypothesis->_is_nil())
615 QApplication::setOverrideCursor(Qt::waitCursor);
616 if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR"))
618 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
620 SMESH::SMESH_Hypothesis::_narrow(_orb->
621 string_to_object(anIOR->Value()));
624 SALOMEDS::SObject_var SO_Applied_Hypothesis =
625 smeshGUI->myStudy->FindObjectID(IObject->getReference());
626 if (!SO_Applied_Hypothesis->_is_nil())
628 SALOMEDS::SObject_var MorSM =
629 smeshGUI->myStudyAPI.
630 GetMeshOrSubmesh(SO_Applied_Hypothesis);
631 if (!MorSM->_is_nil())
633 smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
635 GEOM::GEOM_Shape_var aShape =
636 smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
637 if (!aShape->_is_nil())
639 if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
641 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
642 SMESH::SMESH_Mesh_var aMesh =
643 SMESH::SMESH_Mesh::_narrow(_orb->
644 string_to_object(anIOR->Value()));
645 SMESH::SMESH_subMesh_var aSubMesh =
646 SMESH::SMESH_subMesh::_narrow(_orb->
647 string_to_object(anIOR->Value()));
648 if (!aMesh->_is_nil())
651 aMesh->RemoveHypothesis(aShape, anHyp);
654 QApplication::restoreOverrideCursor();
655 QAD_MessageBox::warn1(QAD_Application::
656 getDesktop(), tr("SMESH_WRN_WARNING"),
657 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
658 tr("SMESH_BUT_YES"));
661 else if (!aSubMesh->_is_nil())
663 aMesh = aSubMesh->GetFather();
664 if (!aMesh->_is_nil())
667 aMesh->RemoveHypothesis(aShape, anHyp);
670 QApplication::restoreOverrideCursor();
671 QAD_MessageBox::warn1(QAD_Application::
673 tr("SMESH_WRN_WARNING"),
674 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
675 tr("SMESH_BUT_YES"));
679 if (myAutomaticUpdate)
681 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
689 smeshGUI->ChangeRepresentation(Mesh,
690 Mesh->getDisplayMode());
696 smeshGUI->myStudyAPI.UnSetHypothesis(SO_Applied_Hypothesis);
700 else if (IObject->hasEntry())
702 MESSAGE("IObject entry " << IObject->getEntry())}
703 QApplication::restoreOverrideCursor();
706 //=============================================================================
710 //=============================================================================
711 void SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM,
712 SMESH::SMESH_Hypothesis_ptr anHyp)
714 SALOMEDS::SObject_var AHR, aRef;
715 SALOMEDS::GenericAttribute_var anAttr;
716 SALOMEDS::AttributeIOR_var anIOR;
718 if (!MorSM->_is_nil())
720 GEOM::GEOM_Shape_var aShape =
721 smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
722 if (!aShape->_is_nil())
724 if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
726 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
727 SMESH::SMESH_Mesh_var aMesh =
728 SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
730 SMESH::SMESH_subMesh_var aSubMesh =
731 SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
733 if (!aMesh->_is_nil())
735 bool res = aMesh->RemoveHypothesis(aShape, anHyp);
738 QApplication::restoreOverrideCursor();
739 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
740 tr("SMESH_WRN_WARNING"),
741 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
742 tr("SMESH_BUT_YES"));
745 else if (!aSubMesh->_is_nil())
747 aMesh = aSubMesh->GetFather();
748 if (!aMesh->_is_nil())
750 bool res = aMesh->RemoveHypothesis(aShape, anHyp);
753 QApplication::restoreOverrideCursor();
754 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
755 tr("SMESH_WRN_WARNING"),
756 tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
757 tr("SMESH_BUT_YES"));
761 if (myAutomaticUpdate)
763 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
771 // smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() );
777 if (MorSM->FindSubObject(2, AHR))
779 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
780 for (; it->More(); it->Next())
782 SALOMEDS::SObject_var Obj = it->Value();
783 if (Obj->ReferencedObject(aRef))
785 if (aRef->FindAttribute(anAttr, "AttributeIOR"))
787 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
788 if (strcmp(anIOR->Value(),
789 _orb->object_to_string(anHyp)) == 0)
791 smeshGUI->myStudyAPI.UnSetHypothesis(Obj);
798 if (MorSM->FindSubObject(3, AHR))
800 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
801 for (; it->More(); it->Next())
803 SALOMEDS::SObject_var Obj = it->Value();
804 if (Obj->ReferencedObject(aRef))
806 if (aRef->FindAttribute(anAttr, "AttributeIOR"))
808 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
809 if (strcmp(anIOR->Value(),
810 _orb->object_to_string(anHyp)) == 0)
812 smeshGUI->myStudyAPI.UnSetAlgorithm(Obj);
819 smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
821 QApplication::restoreOverrideCursor();
824 //=============================================================================
828 //=============================================================================
829 void SMESHGUI::AddAlgorithmOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
830 SMESH::SMESH_Hypothesis_ptr aHyp)
832 if (!aMesh->_is_nil())
834 QApplication::setOverrideCursor(Qt::waitCursor);
835 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
836 GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
839 bool res = aMesh->AddHypothesis(aShape, aHyp);
842 SALOMEDS::SObject_var SH =
843 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
844 if (!SM->_is_nil() && !SH->_is_nil())
846 myStudyAPI.SetAlgorithms(SM, SH);
847 myStudyAPI.ModifiedMesh(SM, false);
852 QApplication::restoreOverrideCursor();
853 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
854 tr("SMESH_WRN_WARNING"),
855 tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
856 tr("SMESH_BUT_YES"));
859 catch(const SALOME::SALOME_Exception & S_ex)
861 QtCatchCorbaException(S_ex);
864 myActiveStudy->updateObjBrowser(true);
865 QApplication::restoreOverrideCursor();
868 //=============================================================================
872 //=============================================================================
873 void SMESHGUI::AddHypothesisOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
874 SMESH::SMESH_Hypothesis_ptr aHyp)
876 if (!aSubMesh->_is_nil())
878 QApplication::setOverrideCursor(Qt::waitCursor);
881 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
882 SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
883 GEOM::GEOM_Shape_var aShape =
884 myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
885 if (!aMesh->_is_nil())
887 bool res = aMesh->AddHypothesis(aShape, aHyp);
890 SALOMEDS::SObject_var SH =
891 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
892 if (!SsubM->_is_nil() && !SH->_is_nil())
894 myStudyAPI.SetHypothesis(SsubM, SH);
895 myStudyAPI.ModifiedMesh(SsubM, false);
900 QApplication::restoreOverrideCursor();
901 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
902 tr("SMESH_WRN_WARNING"),
903 tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
904 tr("SMESH_BUT_YES"));
908 catch(const SALOME::SALOME_Exception & S_ex)
910 QtCatchCorbaException(S_ex);
913 myActiveStudy->updateObjBrowser(true);
914 QApplication::restoreOverrideCursor();
917 //=============================================================================
921 //=============================================================================
922 void SMESHGUI::AddAlgorithmOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
923 SMESH::SMESH_Hypothesis_ptr aHyp)
925 if (!aSubMesh->_is_nil())
927 QApplication::setOverrideCursor(Qt::waitCursor);
930 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
931 SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
932 GEOM::GEOM_Shape_var aShape =
933 myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
934 if (!aMesh->_is_nil())
936 bool res = aMesh->AddHypothesis(aShape, aHyp);
939 SALOMEDS::SObject_var SH =
940 myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
941 if (!SsubM->_is_nil() && !SH->_is_nil())
943 myStudyAPI.SetAlgorithms(SsubM, SH);
944 myStudyAPI.ModifiedMesh(SsubM, false);
949 QApplication::restoreOverrideCursor();
950 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
951 tr("SMESH_WRN_WARNING"),
952 tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
953 tr("SMESH_BUT_YES"));
957 catch(const SALOME::SALOME_Exception & S_ex)
959 QtCatchCorbaException(S_ex);
962 myActiveStudy->updateObjBrowser(true);
963 QApplication::restoreOverrideCursor();
966 //=============================================================================
970 //=============================================================================
971 void SMESHGUI::CreateAlgorithm(QString TypeAlgo, QString NameAlgo)
973 SMESH::SMESH_Hypothesis_var Hyp;
976 if (TypeAlgo.compare("Regular_1D") == 0)
977 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
978 else if (TypeAlgo.compare("MEFISTO_2D") == 0)
979 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
980 else if (TypeAlgo.compare("Quadrangle_2D") == 0)
981 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
982 else if (TypeAlgo.compare("Hexa_3D") == 0)
983 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
984 else if (TypeAlgo.compare("NETGEN_3D") == 0)
985 Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
989 SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms(Hyp);
990 myStudyAPI.SetName(SHyp, NameAlgo);
993 catch(const SALOME::SALOME_Exception & S_ex)
995 QtCatchCorbaException(S_ex);
997 myActiveStudy->updateObjBrowser(true);
1000 //=============================================================================
1004 //=============================================================================
1005 void SMESHGUI::CreateLocalLength(QString TypeHypothesis, QString NameHypothesis,
1008 QApplication::setOverrideCursor(Qt::waitCursor);
1011 SMESH::SMESH_Hypothesis_var Hyp =
1012 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1014 SMESH::SMESH_LocalLength_var LL =
1015 SMESH::SMESH_LocalLength::_narrow(Hyp);
1017 LL->SetLength(Length);
1019 catch(const SALOME::SALOME_Exception & S_ex)
1021 QtCatchCorbaException(S_ex);
1023 myActiveStudy->updateObjBrowser(true);
1024 QApplication::restoreOverrideCursor();
1027 //=============================================================================
1031 //=============================================================================
1032 void SMESHGUI::CreateMaxElementArea(QString TypeHypothesis,
1033 QString NameHypothesis, double MaxArea)
1035 QApplication::setOverrideCursor(Qt::waitCursor);
1038 SMESH::SMESH_Hypothesis_var Hyp =
1039 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1041 SMESH::SMESH_MaxElementArea_var MaxElArea =
1042 SMESH::SMESH_MaxElementArea::_narrow(Hyp);
1043 if (!MaxElArea->_is_nil())
1044 MaxElArea->SetMaxElementArea(MaxArea);
1046 catch(SALOME::SALOME_Exception & S_ex)
1048 QtCatchCorbaException(S_ex);
1051 myActiveStudy->updateObjBrowser(true);
1052 QApplication::restoreOverrideCursor();
1055 //=============================================================================
1059 //=============================================================================
1060 void SMESHGUI::CreateMaxElementVolume(QString TypeHypothesis,
1061 QString NameHypothesis, double MaxVolume)
1063 QApplication::setOverrideCursor(Qt::waitCursor);
1066 SMESH::SMESH_Hypothesis_var Hyp =
1067 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1069 SMESH::SMESH_MaxElementVolume_var MaxElVolume =
1070 SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
1071 if (!MaxElVolume->_is_nil())
1072 MaxElVolume->SetMaxElementVolume(MaxVolume);
1074 catch(const SALOME::SALOME_Exception & S_ex)
1076 QtCatchCorbaException(S_ex);
1078 myActiveStudy->updateObjBrowser(true);
1079 QApplication::restoreOverrideCursor();
1082 //=============================================================================
1086 //=============================================================================
1087 void SMESHGUI::CreateNbSegments(QString TypeHypothesis, QString NameHypothesis,
1090 QApplication::setOverrideCursor(Qt::waitCursor);
1093 SMESH::SMESH_Hypothesis_var Hyp =
1094 SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
1096 SMESH::SMESH_NumberOfSegments_var NbS =
1097 SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
1098 if (!NbS->_is_nil())
1099 NbS->SetNumberOfSegments(nbSegments);
1101 catch(const SALOME::SALOME_Exception & S_ex)
1103 QtCatchCorbaException(S_ex);
1105 myActiveStudy->updateObjBrowser(true);
1106 QApplication::restoreOverrideCursor();
1109 //=============================================================================
1113 //=============================================================================
1114 int SMESHGUI::GetNameOfSelectedIObjects(SALOME_Selection * Sel, QString & aName)
1116 int nbSel = Sel->IObjectCount();
1119 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1120 aName = IObject->getName();
1124 aName = tr("SMESH_OBJECTS_SELECTED").arg(nbSel);
1129 //=============================================================================
1133 //=============================================================================
1134 int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName)
1137 int nbSel = Sel->IObjectCount();
1140 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1141 if (!IObject->hasEntry())
1144 Standard_Boolean res;
1145 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1149 TColStd_MapOfInteger MapIndex;
1150 Sel->GetIndex(IObject, MapIndex);
1151 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1153 nbNodes = MapIndex.Extent();
1154 for (; ite.More(); ite.Next())
1157 aName + QString("%1").arg(ac->GetIdSMESHDSNode(ite.Key())) +
1168 //=============================================================================
1172 //=============================================================================
1173 int SMESHGUI::GetNameOfSelectedElements(SALOME_Selection * Sel, QString & aName)
1176 int nbSel = Sel->IObjectCount();
1179 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1180 if (!IObject->hasEntry())
1183 Standard_Boolean res;
1184 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1188 TColStd_MapOfInteger MapIndex;
1189 Sel->GetIndex(IObject, MapIndex);
1190 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1192 nbElements = MapIndex.Extent();
1193 MESSAGE("GetNameOfSelectedElements(): number = " << nbElements);
1194 for (; ite.More(); ite.Next())
1196 int idVTK = ite.Key();
1197 MESSAGE("GetNameOfSelectedElements(): VTK Id = " << idVTK);
1199 aName + QString("%1").arg(ac->GetIdSMESHDSElement(idVTK)) + " ";
1209 //=============================================================================
1213 //=============================================================================
1214 int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName)
1217 int nbSel = Sel->IObjectCount();
1220 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1221 if (!IObject->hasEntry())
1224 Standard_Boolean res;
1225 SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
1229 TColStd_MapOfInteger MapIndex;
1230 Sel->GetIndex(IObject, MapIndex);
1231 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
1233 nbElements = MapIndex.Extent();
1234 for (; ite.More(); ite.Next())
1236 aName = aName + QString("%1").arg(ite.Key()) + " ";
1246 //=============================================================================
1250 //=============================================================================
1251 SMESH_Actor *SMESHGUI::FindActorByEntry(QString entry,
1252 Standard_Boolean & testResult, bool onlyInActiveView)
1254 int nbSf = myActiveStudy->getStudyFramesCount();
1255 for (int i = 0; i < nbSf; i++)
1257 QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
1258 if (sf->getTypeView() == VIEW_VTK)
1260 vtkRenderer *Renderer =
1261 ((VTKViewer_ViewFrame *) sf->getRightFrame()->getViewFrame())->
1263 vtkActorCollection *theActors = Renderer->GetActors();
1264 theActors->InitTraversal();
1265 vtkActor *ac = theActors->GetNextActor();
1266 while (!(ac == NULL))
1268 if (ac->IsA("SMESH_Actor"))
1270 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
1271 if (anActor->hasIO())
1273 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
1274 if (strcmp(IO->getEntry(), entry) == 0)
1276 if (onlyInActiveView)
1278 if (sf == myActiveStudy->getActiveStudyFrame())
1292 ac = theActors->GetNextActor();
1297 MESSAGE(" Actor Not Found ") testResult = false;
1298 return SMESH_Actor::New();
1301 //=============================================================================
1305 //=============================================================================
1306 SMESH_Actor *SMESHGUI::FindActor(SMESH::SMESH_Mesh_ptr aMesh,
1307 Standard_Boolean & testResult, bool onlyInActiveView)
1309 SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
1312 MESSAGE(" Actor Not Found ") testResult = false;
1313 return SMESH_Actor::New();
1316 return FindActorByEntry(SM->GetID(), testResult, onlyInActiveView);
1319 //=============================================================================
1323 //=============================================================================
1324 SMESH::SMESH_Mesh_ptr SMESHGUI::
1325 ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO,
1326 Standard_Boolean & testResult)
1328 SMESH::SMESH_Mesh_var aMesh;
1334 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1335 SALOMEDS::GenericAttribute_var anAttr;
1336 SALOMEDS::AttributeIOR_var anIOR;
1337 if (!obj->_is_nil())
1339 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1341 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1343 SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
1345 if (!aMesh->_is_nil())
1348 return SMESH::SMESH_Mesh::_duplicate(aMesh);
1353 return SMESH::SMESH_Mesh::_nil();
1356 //=============================================================================
1360 //=============================================================================
1361 SMESH::SMESH_subMesh_ptr SMESHGUI::
1362 ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO,
1363 Standard_Boolean & testResult)
1365 SMESH::SMESH_subMesh_var aSubMesh;
1371 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1372 SALOMEDS::GenericAttribute_var anAttr;
1373 SALOMEDS::AttributeIOR_var anIOR;
1374 if (!obj->_is_nil())
1376 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1378 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1380 SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
1382 if (!aSubMesh->_is_nil())
1385 return SMESH::SMESH_subMesh::_duplicate(aSubMesh);
1390 return SMESH::SMESH_subMesh::_nil();
1393 //=============================================================================
1397 //=============================================================================
1398 SMESH::SMESH_Hypothesis_ptr SMESHGUI::
1399 ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO,
1400 Standard_Boolean & testResult)
1402 SMESH::SMESH_Hypothesis_var aHyp;
1408 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1409 SALOMEDS::GenericAttribute_var anAttr;
1410 SALOMEDS::AttributeIOR_var anIOR;
1411 if (!obj->_is_nil())
1413 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1415 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1417 SMESH::SMESH_Hypothesis::_narrow(_orb->
1418 string_to_object(anIOR->Value()));
1419 if (!aHyp->_is_nil())
1422 return SMESH::SMESH_Hypothesis::_duplicate(aHyp);
1427 return SMESH::SMESH_Hypothesis::_nil();
1430 //=============================================================================
1434 //=============================================================================
1435 GEOM::GEOM_Shape_ptr SMESHGUI::
1436 ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO,
1437 Standard_Boolean & testResult)
1439 GEOM::GEOM_Shape_var aShape;
1445 SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
1446 SALOMEDS::GenericAttribute_var anAttr;
1447 SALOMEDS::AttributeIOR_var anIOR;
1448 if (!obj->_is_nil())
1450 if (obj->FindAttribute(anAttr, "AttributeIOR"))
1452 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1453 aShape = myComponentGeom->GetIORFromString(anIOR->Value());
1454 if (!aShape->_is_nil())
1457 return GEOM::GEOM_Shape::_duplicate(aShape);
1462 return GEOM::GEOM_Shape::_nil();
1465 //=============================================================================
1469 //=============================================================================
1470 void SMESHGUI::SetViewMode(int commandId)
1472 SALOME_Selection *Sel =
1473 SALOME_Selection::Selection(myActiveStudy->getSelection());
1474 int nbSel = Sel->IObjectCount();
1477 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1478 for (; It.More(); It.Next())
1480 Handle(SALOME_InteractiveObject) IObject = It.Value();
1481 if (IObject->hasEntry())
1483 Standard_Boolean res;
1485 FindActorByEntry(IObject->getEntry(), res, true);
1492 ChangeRepresentation(ac, 0);
1497 ChangeRepresentation(ac, 1);
1502 ChangeRepresentation(ac, 2);
1507 ChangeRepresentation(ac, 3);
1514 if (commandId == 1133)
1516 ChangeRepresentation(SMESH_Actor::New(), 4);
1521 //=============================================================================
1525 //=============================================================================
1526 void SMESHGUI::ChangeRepresentation(SMESH_Actor * ac, int type)
1528 if (ac->DataSource == NULL && type != 4)
1533 if (ac->getMapper() == NULL)
1542 QApplication::setOverrideCursor(Qt::waitCursor);
1543 if (ac->getDisplayMode() == 2)
1545 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1546 vtkDataSetMapper *meshMapper =
1547 (vtkDataSetMapper *) (ac->getMapper());
1548 meshMapper->SetInput(ac->DataSource);
1549 meshMapper->SetScalarVisibility(isColored); //SAL3899
1551 ac->setDisplayMode(0);
1552 ac->GetProperty()->SetRepresentationToWireframe();
1553 // ac->SetActorProperty( ac->GetProperty() );
1554 QApplication::restoreOverrideCursor();
1559 QApplication::setOverrideCursor(Qt::waitCursor);
1560 if (ac->getDisplayMode() == 2)
1562 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1563 vtkDataSetMapper *meshMapper =
1564 (vtkDataSetMapper *) (ac->getMapper());
1565 meshMapper->SetInput(ac->DataSource);
1566 meshMapper->SetScalarVisibility(isColored); //SAL3899
1568 ac->setDisplayMode(1);
1569 ac->GetProperty()->SetRepresentationToSurface();
1570 QApplication::restoreOverrideCursor();
1571 // ac->SetActorProperty( ac->GetProperty() );
1576 // if (!(ac->getDisplayMode()==2)) {
1577 // ChangeRepresentation(ac, 1);
1578 QApplication::setOverrideCursor(Qt::waitCursor);
1579 ac->setDisplayMode(2);
1580 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1581 vtkDataSetMapper *meshMapper = (vtkDataSetMapper *) (ac->getMapper());
1582 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
1583 shrink->SetInput(ac->DataSource);
1584 shrink->SetShrinkFactor(ac->GetShrinkFactor());
1586 meshMapper->SetInput(shrink->GetOutput());
1587 meshMapper->SetScalarVisibility(isColored); //SAL3899
1588 ac->SetMapper(meshMapper);
1589 QApplication::restoreOverrideCursor();
1597 float backfacecolor[3];
1599 ac->GetColor(color[0], color[1], color[2]);
1600 // QColor c(color[0]*255,color[1]*255,color[2]*255);
1601 int c0 = int (color[0] * 255);
1602 int c1 = int (color[1] * 255);
1603 int c2 = int (color[2] * 255);
1604 QColor c(c0, c1, c2);
1605 ac->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1606 // QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255);
1607 c0 = int (edgecolor[0] * 255);
1608 c1 = int (edgecolor[1] * 255);
1609 c2 = int (edgecolor[2] * 255);
1610 QColor e(c0, c1, c2);
1611 ac->GetBackfaceProperty()->GetColor(backfacecolor);
1612 // QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255);
1613 c0 = int (backfacecolor[0] * 255);
1614 c1 = int (backfacecolor[1] * 255);
1615 c2 = int (backfacecolor[2] * 255);
1616 QColor b(c0, c1, c2);
1617 ac->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1618 // QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ;
1619 c0 = int (nodecolor[0] * 255);
1620 c1 = int (nodecolor[1] * 255);
1621 c2 = int (nodecolor[2] * 255);
1622 QColor n(c0, c1, c2);
1624 int Edgewidth = (int)ac->EdgeDevice->GetProperty()->GetLineWidth();
1627 int intValue = ac->GetNodeSize();
1628 float Shrink = ac->GetShrinkFactor();
1630 SMESHGUI_Preferences_ColorDlg *aDlg =
1631 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),
1633 aDlg->SetColor(1, c);
1634 aDlg->SetColor(2, e);
1635 aDlg->SetColor(3, n);
1636 aDlg->SetColor(4, b);
1637 aDlg->SetIntValue(1, Edgewidth);
1638 aDlg->SetIntValue(2, intValue);
1639 aDlg->SetIntValue(3, int (Shrink * 100.));
1643 QApplication::setOverrideCursor(Qt::waitCursor);
1644 QColor color = aDlg->GetColor(1);
1645 QColor edgecolor = aDlg->GetColor(2);
1646 QColor nodecolor = aDlg->GetColor(3);
1647 QColor backfacecolor = aDlg->GetColor(4);
1648 /* actor color and backface color */
1649 ac->GetProperty()->SetColor(float (color.red()) / 255.,
1650 float (color.green()) / 255., float (color.blue()) / 255.);
1651 ac->SetColor(float (color.red()) / 255.,
1652 float (color.green()) / 255., float (color.blue()) / 255.);
1653 ac->GetBackfaceProperty()->SetColor(float (backfacecolor.red()) /
1654 255., float (backfacecolor.green()) / 255.,
1655 float (backfacecolor.blue()) / 255.);
1658 ac->EdgeDevice->GetProperty()->SetColor(float (edgecolor.red()) /
1659 255., float (edgecolor.green()) / 255.,
1660 float (edgecolor.blue()) / 255.);
1661 ac->EdgeShrinkDevice->GetProperty()->SetColor(float (edgecolor.
1662 red()) / 255., float (edgecolor.green()) / 255.,
1663 float (edgecolor.blue()) / 255.);
1664 ac->SetEdgeColor(float (edgecolor.red()) / 255.,
1665 float (edgecolor.green()) / 255.,
1666 float (edgecolor.blue()) / 255.);
1668 /* Shrink factor and size edges */
1669 ac->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
1670 ac->EdgeDevice->GetProperty()->SetLineWidth(aDlg->GetIntValue(1));
1671 ac->EdgeShrinkDevice->GetProperty()->SetLineWidth(aDlg->
1674 /* Nodes color and size */
1675 ac->SetNodeColor(float (nodecolor.red()) / 255.,
1676 float (nodecolor.green()) / 255.,
1677 float (nodecolor.blue()) / 255.);
1678 ac->SetNodeSize(aDlg->GetIntValue(2));
1680 if (ac->getDisplayMode() == 2)
1682 bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
1683 vtkDataSetMapper *meshMapper =
1684 (vtkDataSetMapper *) (ac->getMapper());
1685 meshMapper->SetInput(ac->DataSource);
1686 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
1687 shrink->SetInput(meshMapper->GetInput());
1688 shrink->SetShrinkFactor(ac->GetShrinkFactor());
1690 meshMapper->SetInput(shrink->GetOutput());
1691 meshMapper->SetScalarVisibility(isColored); //SAL3899
1692 ac->SetMapper(meshMapper);
1696 QApplication::restoreOverrideCursor();
1701 EmitSignalDeactivateDialog();
1702 SALOME_Selection *Sel =
1703 SALOME_Selection::Selection(myActiveStudy->getSelection());
1704 SMESHGUI_TransparencyDlg *aDlg =
1705 new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(), "",
1711 QApplication::setOverrideCursor(Qt::waitCursor);
1712 ac->GetProperty()->SetRepresentationToPoints();
1713 QApplication::restoreOverrideCursor();
1718 QApplication::setOverrideCursor(Qt::waitCursor);
1719 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
1721 vtkRenderer *theRenderer =
1722 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1723 getRightFrame()->getViewFrame())->getRenderer();
1724 theRenderer->Render();
1726 QApplication::restoreOverrideCursor();
1729 //=============================================================================
1733 //=============================================================================
1734 void SMESHGUI::UpdateView()
1736 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1739 vtkRenderer *theRenderer =
1740 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1741 getRightFrame()->getViewFrame())->getRenderer();
1742 theRenderer->Render();
1745 //=============================================================================
1749 //=============================================================================
1750 void SMESHGUI::DisplayActor(SMESH_Actor * ac, bool visibility)
1752 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1755 MESSAGE("DisplayActor(): DataSource = " << ac->DataSource);
1757 vtkRenderer *theRenderer =
1758 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1759 getRightFrame()->getViewFrame())->getRenderer();
1760 vtkActorCollection *theActors = theRenderer->GetActors();
1761 theActors->InitTraversal();
1762 if (theActors->IsItemPresent(ac) == 0)
1764 vtkProperty *prop = vtkProperty::New();
1765 prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
1767 QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
1769 QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
1772 prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
1774 prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
1776 ac->SetProperty(prop);
1777 ac->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
1779 QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
1781 QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
1784 // prop->BackfaceCullingOn();
1785 vtkProperty *backprop = vtkProperty::New();
1786 backprop->SetColor(QAD_CONFIG->
1787 getSetting("SMESH:SettingsBackFaceColorRed").toFloat() / 255.,
1788 QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen").
1790 QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue").
1792 ac->SetBackfaceProperty(backprop);
1795 QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff").toInt();
1798 ac->SetShrinkFactor(intValue / 100.);
1800 ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer();
1801 ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02);
1803 QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
1804 if (DisplayMode.compare("Wireframe") == 0)
1806 ac->setDisplayMode(0);
1807 ChangeRepresentation(ac, 0);
1809 else if (DisplayMode.compare("Shading") == 0)
1811 ac->setDisplayMode(1);
1812 ChangeRepresentation(ac, 1);
1814 else if (DisplayMode.compare("Shrink") == 0)
1816 ac->setDisplayMode(2);
1817 ChangeRepresentation(ac, 2);
1819 theRenderer->AddActor(ac);
1823 if (ac->GetMapper())
1824 ac->GetMapper()->Update();
1827 // if ( visibility )
1828 ac->SetVisibility(visibility);
1829 // ac->VisibilityOn();
1831 // ac->VisibilityOff();
1833 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
1837 //=============================================================================
1841 //=============================================================================
1842 void SMESHGUI::EraseActor(SMESH_Actor * ac)
1844 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
1847 vtkRenderer *theRenderer =
1848 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
1849 getRightFrame()->getViewFrame())->getRenderer();
1851 //NRI- : 02/12/2002 : Fixed bugId 882
1852 // ac->EdgeDevice->VisibilityOff();
1853 // ac->EdgeShrinkDevice->VisibilityOff();
1854 // ac->VisibilityOff();
1855 ac->SetVisibility(false);
1857 theRenderer->Render();
1860 //=============================================================================
1864 //=============================================================================
1865 bool SMESHGUI::AddActorInSelection(SMESH_Actor * ac)
1867 SALOME_Selection *Sel =
1868 SALOME_Selection::Selection(myActiveStudy->getSelection());
1869 Sel->ClearIObjects();
1871 return Sel->AddIObject(ac->getIO());
1876 //=============================================================================
1880 //=============================================================================
1881 QString SMESHGUI::CheckHomogeneousSelection()
1883 SALOME_Selection *Sel =
1884 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
1887 SALOME_ListIteratorOfListIO Itinit(Sel->StoredIObjects());
1888 for (; Itinit.More(); Itinit.Next())
1890 List.Append(Itinit.Value());
1893 QString RefType = CheckTypeObject(Sel->firstIObject());
1894 SALOME_ListIteratorOfListIO It(List);
1895 for (; It.More(); It.Next())
1897 Handle(SALOME_InteractiveObject) IObject = It.Value();
1898 QString Type = CheckTypeObject(IObject);
1899 if (Type.compare(RefType) != 0)
1900 return "Heterogeneous Selection";
1903 Sel->ClearIObjects();
1904 SALOME_ListIteratorOfListIO It1(List);
1905 for (; It1.More(); It1.Next())
1907 int res = Sel->AddIObject(It1.Value());
1909 myActiveStudy->highlight(It1.Value(), false);
1911 myActiveStudy->highlight(It1.Value(), true);
1916 //=============================================================================
1920 //=============================================================================
1921 QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject) & IO)
1923 SALOMEDS::SObject_var sobj =
1924 smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->
1926 if (!sobj->_is_nil())
1928 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
1929 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
1930 { // component is selected
1935 SALOME_Selection *Sel =
1936 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
1937 Sel->ClearIObjects();
1939 Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS);
1940 Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM);
1941 Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH);
1942 Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH);
1943 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter =
1944 new SMESH_TypeFilter(MESHorSUBMESH);
1945 Handle(SMESH_TypeFilter) aSubMeshVextexFilter =
1946 new SMESH_TypeFilter(SUBMESH_VERTEX);
1947 Handle(SMESH_TypeFilter) aSubMeshEdgeFilter =
1948 new SMESH_TypeFilter(SUBMESH_EDGE);
1949 Handle(SMESH_TypeFilter) aSubMeshFaceFilter =
1950 new SMESH_TypeFilter(SUBMESH_FACE);
1951 Handle(SMESH_TypeFilter) aSubMeshSolidFilter =
1952 new SMESH_TypeFilter(SUBMESH_SOLID);
1953 Handle(SMESH_TypeFilter) aSubMeshCompoundFilter =
1954 new SMESH_TypeFilter(SUBMESH_COMPOUND);
1956 Sel->AddFilter(aHypFilter);
1957 if (Sel->AddIObject(IO) != -1)
1959 Sel->ClearFilters();
1960 return "Hypothesis";
1963 Sel->ClearFilters();
1964 Sel->AddFilter(anAlgoFilter);
1965 if (Sel->AddIObject(IO) != -1)
1967 Sel->ClearFilters();
1971 Sel->ClearFilters();
1972 Sel->AddFilter(aMeshFilter);
1973 if (Sel->AddIObject(IO) != -1)
1975 Sel->ClearFilters();
1979 Sel->ClearFilters();
1980 Sel->AddFilter(aSubMeshFilter);
1981 if (Sel->AddIObject(IO) != -1)
1983 Sel->ClearFilters();
1987 Sel->ClearFilters();
1988 Sel->AddFilter(aSubMeshVextexFilter);
1989 if (Sel->AddIObject(IO) != -1)
1991 Sel->ClearFilters();
1992 return "SubMeshVertex";
1995 Sel->ClearFilters();
1996 Sel->AddFilter(aSubMeshEdgeFilter);
1997 if (Sel->AddIObject(IO) != -1)
1999 Sel->ClearFilters();
2000 return "SubMeshEdge";
2003 Sel->ClearFilters();
2004 Sel->AddFilter(aSubMeshFaceFilter);
2005 if (Sel->AddIObject(IO) != -1)
2007 Sel->ClearFilters();
2008 return "SubMeshFace";
2011 Sel->ClearFilters();
2012 Sel->AddFilter(aSubMeshSolidFilter);
2013 if (Sel->AddIObject(IO) != -1)
2015 Sel->ClearFilters();
2016 return "SubMeshSolid";
2019 Sel->ClearFilters();
2020 Sel->AddFilter(aSubMeshCompoundFilter);
2021 if (Sel->AddIObject(IO) != -1)
2023 Sel->ClearFilters();
2024 return "SubMeshCompound";
2027 Sel->ClearFilters();
2028 Sel->AddIObject(IO);
2032 //=============================================================================
2036 //=============================================================================
2037 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
2039 /* Create or retrieve an object SMESHGUI */
2040 SMESHGUI::GetOrCreateSMESHGUI(parent);
2042 // NRI : Temporary added
2043 if (smeshGUI->myStudy->GetProperties()->IsLocked())
2049 // QAD_Viewer3d* v3d;
2050 OCCViewer_Viewer3d *v3d;
2052 Handle(AIS_InteractiveContext) ic;
2053 vtkRenderer *Renderer;
2054 vtkRenderWindow *RenWin;
2056 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2060 ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy->
2061 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2063 ic = v3d->getAISContext();
2065 else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2069 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2070 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2072 RenWin = Renderer->GetRenderWindow();
2075 switch (theCommandID)
2078 smeshGUI->OnEditDelete();
2085 smeshGUI->Import_Document(parent, theCommandID);
2089 case 122: // EXPORT MED
2093 Export_Mesh(parent, theCommandID);
2097 case 200: // SCALAR BAR
2099 smeshGUI->DisplayScalarBar(false);
2104 SMESHGUI_EditScalarBarDlg *aDlg =
2105 new SMESHGUI_EditScalarBarDlg(parent, "", false);
2111 smeshGUI->DisplayScalarBar(true);
2115 case 1133: // DISPLAY MODE : WireFrame, Surface, Shrink
2121 smeshGUI->SetViewMode(theCommandID);
2133 SALOME_Selection *Sel =
2134 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2136 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2140 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2141 for (; It.More(); It.Next())
2143 Handle(SALOME_InteractiveObject) IOS = It.Value();
2144 if (IOS->hasEntry())
2146 Standard_Boolean res;
2148 smeshGUI->FindActorByEntry(IOS->getEntry(), res, true);
2150 smeshGUI->EraseActor(ac);
2154 Sel->ClearIObjects();
2155 smeshGUI->myActiveStudy->updateObjBrowser(true);
2158 case 301: // DISPLAY
2160 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2164 QApplication::setOverrideCursor(Qt::waitCursor);
2165 SALOMEDS::SObject_var fatherSF =
2166 smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
2167 getActiveStudyFrame()->entry());
2169 SALOME_Selection *Sel =
2170 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2172 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2174 for (; It.More(); It.Next())
2176 Handle(SALOME_InteractiveObject) IObject = It.Value();
2177 if (IObject->hasEntry())
2179 Standard_Boolean res;
2181 smeshGUI->FindActorByEntry(IObject->getEntry(), res,
2185 smeshGUI->DisplayActor(ac, true);
2186 smeshGUI->DisplayEdges(ac);
2187 smeshGUI->ChangeRepresentation(ac,
2188 ac->getDisplayMode());
2192 QApplication::restoreOverrideCursor();
2197 case 302: // DISPLAY ONLY
2199 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2202 QApplication::setOverrideCursor(Qt::waitCursor);
2203 vtkActorCollection *theActors = Renderer->GetActors();
2204 theActors->InitTraversal();
2205 vtkActor *ac = theActors->GetNextActor();
2206 while (!(ac == NULL))
2208 if (ac->IsA("SMESH_Actor"))
2210 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
2211 if (!anActor->isHighlighted())
2213 //anActor->VisibilityOff();
2214 //NRI- : 02/12/2002 : Fixed bugId 882
2215 // anActor->EdgeDevice->VisibilityOff();
2216 // anActor->EdgeShrinkDevice->VisibilityOff();
2217 anActor->SetVisibility(false);
2220 ac = theActors->GetNextActor();
2223 // Display selection
2224 SALOMEDS::SObject_var fatherSF =
2225 smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
2226 getActiveStudyFrame()->entry());
2228 SALOME_Selection *Sel =
2229 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2231 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2233 for (; It.More(); It.Next())
2235 Handle(SALOME_InteractiveObject) IObject = It.Value();
2236 SALOMEDS::SObject_var obj =
2237 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
2239 VTKViewer_RenderWindowInteractor *myRenderInter =
2240 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2241 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2243 // vtkQGLRenderWindowInteractor* myRenderInter= smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
2245 if (myRenderInter->isInViewer(IObject))
2247 if (IObject->hasEntry())
2249 Standard_Boolean res;
2251 smeshGUI->FindActorByEntry(IObject->getEntry(), res,
2255 smeshGUI->DisplayActor(ac, true);
2256 smeshGUI->DisplayEdges(ac);
2257 smeshGUI->ChangeRepresentation(ac,
2258 ac->getDisplayMode());
2263 smeshGUI->myActiveStudy->updateObjBrowser(true);
2264 QApplication::restoreOverrideCursor();
2271 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2274 smeshGUI->EmitSignalDeactivateDialog();
2275 SALOME_Selection *Sel =
2276 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2278 Sel->ClearIObjects();
2279 smeshGUI->myDesktop->SetSelectionMode(1, true);
2280 parent->menuBar()->setItemChecked(9010, false);
2281 parent->menuBar()->setItemChecked(9011, false);
2282 smeshGUI->ViewNodes();
2283 SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
2287 QApplication::restoreOverrideCursor();
2288 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2289 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2290 tr("SMESH_BUT_YES"));
2295 case 405: // MOVE NODE
2297 smeshGUI->myDesktop->SetSelectionMode(1, true);
2298 SALOME_Selection *Sel =
2299 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2301 SMESHGUI_MoveNodesDlg *aDlg =
2302 new SMESHGUI_MoveNodesDlg(parent, "", Sel);
2306 case 701: // COMPUTE MESH
2308 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2311 SALOME_Selection *Sel =
2312 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2314 int nbSel = Sel->IObjectCount();
2317 QApplication::restoreOverrideCursor();
2321 SMESH::SMESH_Mesh_var aM;
2322 SMESH::SMESH_subMesh_var aSubM;
2323 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
2324 if (IObject->hasEntry())
2326 SALOMEDS::SObject_var aMorSM =
2327 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
2328 SALOMEDS::GenericAttribute_var anAttr;
2329 SALOMEDS::AttributeIOR_var anIOR;
2330 if (!aMorSM->_is_nil())
2332 if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
2334 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2335 MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "
2336 << anIOR->Value())CORBA::Object_var cobj;
2339 cobj = _orb->string_to_object(anIOR->Value());
2340 if (CORBA::is_nil(cobj))
2343 ("SMESHGUI::OnGUIEvent - Compute mesh : nil object")}
2345 catch(CORBA::COMM_FAILURE & ex)
2348 ("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)")}
2349 aM = SMESH::SMESH_Mesh::_narrow(cobj);
2350 //aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
2352 SMESH::SMESH_subMesh::_narrow(_orb->
2353 string_to_object(anIOR->Value()));
2356 GEOM::GEOM_Shape_var refShape =
2357 smeshGUI->myStudyAPI.
2358 GetShapeOnMeshOrSubMesh(aMorSM);
2359 if (!refShape->_is_nil())
2362 smeshGUI->myComponentMesh->
2363 IsReadyToCompute(aM, refShape);
2366 QApplication::restoreOverrideCursor();
2367 QAD_MessageBox::warn1(QAD_Application::
2368 getDesktop(), tr("SMESH_WRN_WARNING"),
2369 tr("SMESH_WRN_MISSING_PARAMETERS"),
2370 tr("SMESH_BUT_YES"));
2375 smeshGUI->myComponentMesh->Compute(aM,
2377 smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
2379 // TO Do : change icon of all submeshes
2381 catch(const SALOME::SALOME_Exception & S_ex)
2383 QtCatchCorbaException(S_ex);
2387 else if (!aSubM->_is_nil())
2389 aM = aSubM->GetFather();
2390 GEOM::GEOM_Shape_var refShape =
2391 smeshGUI->myStudyAPI.
2392 GetShapeOnMeshOrSubMesh(aMorSM);
2393 if (!refShape->_is_nil())
2396 smeshGUI->myComponentMesh->
2397 IsReadyToCompute(aM, refShape);
2400 QApplication::restoreOverrideCursor();
2401 QAD_MessageBox::warn1(QAD_Application::
2402 getDesktop(), tr("SMESH_WRN_WARNING"),
2403 tr("SMESH_WRN_MISSING_PARAMETERS"),
2404 tr("SMESH_BUT_YES"));
2409 smeshGUI->myComponentMesh->Compute(aM,
2411 smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
2413 // TO Do : change icon of all submeshes
2415 catch(const SALOME::SALOME_Exception & S_ex)
2417 QtCatchCorbaException(S_ex);
2425 // Check whether the actor for the mesh exists at least in one view
2426 Standard_Boolean res;
2428 smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
2430 smeshGUI->InitActor(aM);
2433 // Check whether the actor belongs to the active view
2434 VTKViewer_RenderWindowInteractor *rwInter =
2435 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
2436 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
2439 // The actor belongs to inactive view -> create a copy and add it in the active view
2440 if (!rwInter->isInViewer(IObject))
2442 SMESH_Actor *acCopy = SMESH_Actor::New();
2443 acCopy->ShallowCopy(ac);
2445 smeshGUI->DisplayActor(acCopy, false);
2449 if (smeshGUI->myAutomaticUpdate)
2451 SMESH_Actor *Mesh = smeshGUI->ReadScript(aM);
2457 smeshGUI->DisplayActor(Mesh, true);
2458 smeshGUI->DisplayEdges(Mesh, true);
2459 smeshGUI->ChangeRepresentation(Mesh,
2460 Mesh->getDisplayMode());
2466 QApplication::restoreOverrideCursor();
2467 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2468 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2469 tr("SMESH_BUT_YES"));
2471 QApplication::restoreOverrideCursor();
2475 case 702: // ADD SUB MESH
2477 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2480 smeshGUI->EmitSignalDeactivateDialog();
2481 SALOME_Selection *Sel =
2482 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2484 SMESHGUI_AddSubMeshDlg *aDlg =
2485 new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
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"));
2497 case 703: // INIT MESH
2499 smeshGUI->EmitSignalDeactivateDialog();
2500 SALOME_Selection *Sel =
2501 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2503 SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
2507 case 704: // EDIT Hypothesis
2509 smeshGUI->EmitSignalDeactivateDialog();
2510 SALOME_Selection *Sel =
2511 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2513 SMESHGUI_EditHypothesesDlg *aDlg =
2514 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2518 case 705: // EDIT Global Hypothesis
2520 smeshGUI->EmitSignalDeactivateDialog();
2521 SALOME_Selection *Sel =
2522 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2524 SMESHGUI_EditHypothesesDlg *aDlg =
2525 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2529 case 706: // EDIT Local Hypothesis
2531 smeshGUI->EmitSignalDeactivateDialog();
2532 SALOME_Selection *Sel =
2533 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2535 SMESHGUI_EditHypothesesDlg *aDlg =
2536 new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2540 case 806: // ORIENTATION ELEMENTS
2542 smeshGUI->EmitSignalDeactivateDialog();
2543 SALOME_Selection *Sel =
2544 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2546 smeshGUI->myDesktop->SetSelectionMode(3, true);
2547 SMESHGUI_OrientationElementsDlg *aDlg =
2548 new SMESHGUI_OrientationElementsDlg(parent, "", Sel);
2552 case 807: // DIAGONAL INVERSION
2554 smeshGUI->EmitSignalDeactivateDialog();
2555 SALOME_Selection *Sel =
2556 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2558 Sel->ClearIObjects();
2559 smeshGUI->myDesktop->SetSelectionMode(2, true);
2560 SMESHGUI_DiagonalInversionDlg *aDlg =
2561 new SMESHGUI_DiagonalInversionDlg(parent, "", Sel);
2565 case 900: // MESH INFOS
2567 smeshGUI->EmitSignalDeactivateDialog();
2568 SALOME_Selection *Sel =
2569 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2571 SMESHGUI_MeshInfosDlg *aDlg =
2572 new SMESHGUI_MeshInfosDlg(parent, "", Sel);
2576 case 1001: // AUTOMATIC UPDATE PREFERENCES
2578 parent->menuBar()->setItemChecked(1001,
2579 !parent->menuBar()->isItemChecked(1001));
2580 if (parent->menuBar()->isItemChecked(1001))
2582 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
2583 smeshGUI->myAutomaticUpdate = true;
2587 QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
2588 smeshGUI->myAutomaticUpdate = false;
2593 case 1003: // MESH PREFERENCES
2595 smeshGUI->SetDisplaySettings();
2601 QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
2602 QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
2603 QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
2604 QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
2605 QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation");
2606 float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
2607 float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
2608 int NumberOfLabels =
2609 QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
2610 int NumberOfColors =
2611 QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
2617 if (NumberOfLabels == 0)
2619 if (NumberOfColors == 0)
2620 NumberOfColors = 64;
2622 SMESHGUI_Preferences_ScalarBarDlg *aDlg =
2623 new SMESHGUI_Preferences_ScalarBarDlg(parent, "", true);
2625 if (Bold.compare("true") == 0)
2626 aDlg->Bold->setChecked(true);
2628 aDlg->Bold->setChecked(false);
2629 if (Italic.compare("true") == 0)
2630 aDlg->Italic->setChecked(true);
2632 aDlg->Italic->setChecked(false);
2633 if (Shadow.compare("true") == 0)
2634 aDlg->Shadow->setChecked(true);
2636 aDlg->Shadow->setChecked(false);
2638 if (Orientation.compare("Horizontal") == 0)
2639 aDlg->RadioHoriz->setChecked(true);
2641 aDlg->RadioVert->setChecked(true);
2643 int NbItems = aDlg->ComboBox1->count();
2645 aDlg->ComboBox1->setCurrentItem(i);
2648 if (FontFamily.compare(aDlg->ComboBox1->text(i)) == 0)
2649 aDlg->ComboBox1->setCurrentItem(i);
2653 aDlg->LineEditWidth->setText(QString("%1").arg(Width));
2654 aDlg->LineEditHeight->setText(QString("%1").arg(Height));
2656 aDlg->SpinBoxLabels->setValue(NumberOfLabels);
2657 aDlg->SpinBoxColors->setValue(NumberOfColors);
2662 if (aDlg->RadioHoriz->isChecked())
2663 Orientation = "Horizontal";
2665 Orientation = "Vertical";
2666 if (aDlg->Bold->isChecked())
2670 if (aDlg->Italic->isChecked())
2674 if (aDlg->Shadow->isChecked())
2679 FontFamily = aDlg->ComboBox1->currentText();
2680 Width = aDlg->LineEditWidth->text().toFloat();
2681 Height = aDlg->LineEditHeight->text().toFloat();
2682 NumberOfColors = aDlg->SpinBoxColors->text().toInt();
2683 NumberOfLabels = aDlg->SpinBoxLabels->text().toInt();
2685 vtkScalarBarActor *aScalarBar = smeshGUI->GetScalarBar();
2686 if (aScalarBar != NULL)
2688 smeshGUI->SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow,
2689 FontFamily, Orientation,
2690 Width, Height, NumberOfColors, NumberOfLabels);
2693 QAD_CONFIG->addSetting("ScalarBar:Bold", Bold);
2694 QAD_CONFIG->addSetting("ScalarBar:Italic", Italic);
2695 QAD_CONFIG->addSetting("ScalarBar:Shadow", Shadow);
2696 QAD_CONFIG->addSetting("ScalarBar:FontFamily", FontFamily);
2697 QAD_CONFIG->addSetting("ScalarBar:Orientation", Orientation);
2698 QAD_CONFIG->addSetting("ScalarBar:Width", Width);
2699 QAD_CONFIG->addSetting("ScalarBar:Height", Height);
2700 QAD_CONFIG->addSetting("ScalarBar:NumberOfLabels", NumberOfLabels);
2701 QAD_CONFIG->addSetting("ScalarBar:NumberOfColors", NumberOfColors);
2706 case 1100: // EDIT HYPOTHESIS
2708 SALOME_Selection *Sel =
2709 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2711 int nbSel = Sel->IObjectCount();
2715 Standard_Boolean res;
2716 SMESH::SMESH_Hypothesis_var Hyp =
2717 smeshGUI->ConvertIOinSMESHHypothesis(Sel->firstIObject(), res);
2719 /* Look for all mesh objects that have this hupothesis affected in order to flag as ModifiedMesh */
2720 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2721 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2722 SALOMEDS::Study::ListOfSObject_var listSOmesh =
2723 smeshGUI->GetMeshesUsingAlgoOrHypothesis(Hyp);
2727 QString Name = Hyp->GetName();
2729 if (Name.compare("LocalLength") == 0)
2731 SMESH::SMESH_LocalLength_var LL =
2732 SMESH::SMESH_LocalLength::_narrow(Hyp);
2733 double beforeLength = LL->GetLength();
2734 double Length = smeshGUI->Parameter(res,
2736 tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"),
2739 if (res && Length != beforeLength)
2741 LL->SetLength(Length);
2742 for (int i = 0; i < listSOmesh->length(); i++)
2744 smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
2751 else if (Name.compare("NumberOfSegments") == 0)
2753 SMESH::SMESH_NumberOfSegments_var NOS =
2754 SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
2755 int beforeNbSeg = NOS->GetNumberOfSegments();
2756 int NbSeg = smeshGUI->Parameter(res,
2758 tr("SMESH_NB_SEGMENTS_HYPOTHESIS"),
2762 if (res && NbSeg != beforeNbSeg)
2764 NOS->SetNumberOfSegments(NbSeg);
2765 for (int i = 0; i < listSOmesh->length(); i++)
2767 SALOMEDS::SObject_var SO = listSOmesh[i];
2768 smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
2775 else if (Name.compare("MaxElementArea") == 0)
2777 SMESH::SMESH_MaxElementArea_var MEA =
2778 SMESH::SMESH_MaxElementArea::_narrow(Hyp);
2779 double beforeMaxArea = MEA->GetMaxElementArea();
2780 double MaxArea = smeshGUI->Parameter(res,
2782 tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
2785 if (res && MaxArea != beforeMaxArea)
2787 MEA->SetMaxElementArea(MaxArea);
2788 for (int i = 0; i < listSOmesh->length(); i++)
2790 smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
2797 else if (Name.compare("MaxElementVolume") == 0)
2799 SMESH::SMESH_MaxElementVolume_var MEV =
2800 SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
2801 double beforeMaxVolume = MEV->GetMaxElementVolume();
2802 double MaxVolume = smeshGUI->Parameter(res,
2804 tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
2807 if (res && MaxVolume != beforeMaxVolume)
2809 MEV->SetMaxElementVolume(MaxVolume);
2810 for (int i = 0; i < listSOmesh->length(); i++)
2812 smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
2819 else if (Name.compare("Regular_1D") == 0)
2822 else if (Name.compare("MEFISTO_2D") == 0)
2834 case 1101: // RENAME
2836 SALOME_Selection *Sel =
2837 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2839 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2840 for (; It.More(); It.Next())
2842 Handle(SALOME_InteractiveObject) IObject = It.Value();
2844 SALOMEDS::SObject_var obj =
2845 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
2846 SALOMEDS::GenericAttribute_var anAttr;
2847 SALOMEDS::AttributeName_var aName;
2848 if (!obj->_is_nil())
2850 if (obj->FindAttribute(anAttr, "AttributeName"))
2852 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2853 QString newName = QString(aName->Value());
2855 SALOMEGUI_NameDlg::getName(QAD_Application::
2856 getDesktop(), newName);
2857 if (!newName.isEmpty())
2859 QApplication::setOverrideCursor(Qt::waitCursor);
2860 smeshGUI->myActiveStudy->renameIObject(IObject,
2863 QApplication::restoreOverrideCursor();
2870 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2872 QApplication::setOverrideCursor(Qt::waitCursor);
2873 SALOME_Selection *Sel =
2874 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2876 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2877 for (int i = 0; It.More(); It.Next(), i++)
2879 Handle(SALOME_InteractiveObject) IObject = It.Value();
2880 smeshGUI->RemoveHypothesisOrAlgorithmOnMesh(IObject);
2882 Sel->ClearIObjects();
2883 smeshGUI->myActiveStudy->updateObjBrowser(true);
2884 QApplication::restoreOverrideCursor();
2888 case 401: // GEOM::EDGE
2890 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2893 smeshGUI->EmitSignalDeactivateDialog();
2894 SALOME_Selection *Sel =
2895 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2897 Sel->ClearIObjects();
2898 smeshGUI->myDesktop->SetSelectionMode(1, true);
2899 parent->menuBar()->setItemChecked(9010, false);
2900 parent->menuBar()->setItemChecked(9011, false);
2901 smeshGUI->ViewNodes();
2902 SMESHGUI_AddEdgeDlg *aDlg =
2903 new SMESHGUI_AddEdgeDlg(parent, "", Sel);
2907 QApplication::restoreOverrideCursor();
2908 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2909 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2910 tr("SMESH_BUT_YES"));
2914 case 4021: // TRIANGLE
2916 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2919 smeshGUI->EmitSignalDeactivateDialog();
2920 SALOME_Selection *Sel =
2921 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2923 Sel->ClearIObjects();
2924 smeshGUI->myDesktop->SetSelectionMode(1, true);
2925 parent->menuBar()->setItemChecked(9010, false);
2926 parent->menuBar()->setItemChecked(9011, false);
2927 smeshGUI->ViewNodes();
2928 SMESHGUI_AddFaceDlg *aDlg =
2929 new SMESHGUI_AddFaceDlg(parent, "", Sel, 3);
2933 QApplication::restoreOverrideCursor();
2934 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2936 tr("SMESH_BUT_YES"));
2942 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2945 smeshGUI->EmitSignalDeactivateDialog();
2946 SALOME_Selection *Sel =
2947 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2949 Sel->ClearIObjects();
2950 smeshGUI->myDesktop->SetSelectionMode(1, true);
2951 parent->menuBar()->setItemChecked(9010, false);
2952 parent->menuBar()->setItemChecked(9011, false);
2953 smeshGUI->ViewNodes();
2954 SMESHGUI_AddFaceDlg *aDlg =
2955 new SMESHGUI_AddFaceDlg(parent, "", Sel, 4);
2959 QApplication::restoreOverrideCursor();
2960 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2961 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2962 tr("SMESH_BUT_YES"));
2968 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2971 smeshGUI->EmitSignalDeactivateDialog();
2972 SALOME_Selection *Sel =
2973 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
2975 Sel->ClearIObjects();
2976 smeshGUI->myDesktop->SetSelectionMode(1, true);
2977 parent->menuBar()->setItemChecked(9010, false);
2978 parent->menuBar()->setItemChecked(9011, false);
2979 smeshGUI->ViewNodes();
2980 SMESHGUI_AddVolumeDlg *aDlg =
2981 new SMESHGUI_AddVolumeDlg(parent, "", Sel, 4);
2985 QApplication::restoreOverrideCursor();
2986 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2987 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2988 tr("SMESH_BUT_YES"));
2994 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
2997 smeshGUI->EmitSignalDeactivateDialog();
2998 SALOME_Selection *Sel =
2999 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3001 Sel->ClearIObjects();
3002 smeshGUI->myDesktop->SetSelectionMode(1, true);
3003 parent->menuBar()->setItemChecked(9010, false);
3004 parent->menuBar()->setItemChecked(9011, false);
3005 smeshGUI->ViewNodes();
3006 SMESHGUI_AddVolumeDlg *aDlg =
3007 new SMESHGUI_AddVolumeDlg(parent, "", Sel, 8);
3011 QApplication::restoreOverrideCursor();
3012 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
3013 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
3014 tr("SMESH_BUT_YES"));
3019 case 4041: // REMOVES NODES
3021 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
3024 smeshGUI->EmitSignalDeactivateDialog();
3025 SALOME_Selection *Sel =
3026 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3028 Sel->ClearIObjects();
3029 smeshGUI->myDesktop->SetSelectionMode(1, true);
3030 parent->menuBar()->setItemChecked(9010, false);
3031 parent->menuBar()->setItemChecked(9011, false);
3032 smeshGUI->ViewNodes();
3033 SMESHGUI_RemoveNodesDlg *aDlg =
3034 new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
3038 QApplication::restoreOverrideCursor();
3039 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
3040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
3041 tr("SMESH_BUT_YES"));
3045 case 4042: // REMOVES ELEMENTS
3047 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
3050 smeshGUI->EmitSignalDeactivateDialog();
3051 SALOME_Selection *Sel =
3052 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3054 Sel->ClearIObjects();
3055 smeshGUI->myDesktop->SetSelectionMode(3, true);
3056 SMESHGUI_RemoveElementsDlg *aDlg =
3057 new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
3061 QApplication::restoreOverrideCursor();
3062 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
3063 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
3064 tr("SMESH_BUT_YES"));
3069 case 5000: // HYPOTHESIS - ALGO
3071 smeshGUI->CreateAlgorithm("Regular_1D", "Wire Discretisation");
3076 smeshGUI->CreateAlgorithm("MEFISTO_2D", "Triangle (Mefisto)");
3081 smeshGUI->CreateAlgorithm("Quadrangle_2D", "Quadrangle (Mapping)");
3086 smeshGUI->CreateAlgorithm("Hexa_3D", "Hexahedron (i,j,k)");
3091 smeshGUI->CreateAlgorithm("NETGEN_3D", "Tetrahedron (Netgen)");
3095 case 5030: // HYPOTHESIS - LOCAL LENGTH
3097 smeshGUI->EmitSignalDeactivateDialog();
3098 SALOME_Selection *Sel =
3099 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3101 SMESHGUI_LocalLengthDlg *aDlg = new SMESHGUI_LocalLengthDlg(parent, "");
3104 case 5031: // HYPOTHESIS - NB SEGMENTS
3106 smeshGUI->EmitSignalDeactivateDialog();
3107 SALOME_Selection *Sel =
3108 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3110 SMESHGUI_NbSegmentsDlg *aDlg = new SMESHGUI_NbSegmentsDlg(parent, "");
3114 case 5032: // HYPOTHESIS - MAX ELEMENT AREA
3116 smeshGUI->EmitSignalDeactivateDialog();
3117 SALOME_Selection *Sel =
3118 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3120 SMESHGUI_MaxElementAreaDlg *aDlg =
3121 new SMESHGUI_MaxElementAreaDlg(parent, "");
3125 case 5033: // HYPOTHESIS - MAX ELEMENT VOLUME
3127 smeshGUI->EmitSignalDeactivateDialog();
3128 SALOME_Selection *Sel =
3129 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3131 SMESHGUI_MaxElementVolumeDlg *aDlg =
3132 new SMESHGUI_MaxElementVolumeDlg(parent, "");
3136 case 5034: // HYPOTHESIS - LENGTH FROM EDGES
3138 SMESH::SMESH_Hypothesis_var Hyp;
3141 Hyp = smeshGUI->myComponentMesh->CreateHypothesis("LengthFromEdges", smeshGUI->myStudyId);
3143 if (!Hyp->_is_nil())
3145 SALOMEDS::SObject_var SHyp = smeshGUI->myStudyAPI.AddNewHypothesis(Hyp);
3146 smeshGUI->myStudyAPI.SetName(SHyp, "LengthFromEdges");
3149 catch(const SALOME::SALOME_Exception & S_ex)
3151 QtCatchCorbaException(S_ex);
3153 smeshGUI->myActiveStudy->updateObjBrowser(true);
3158 case 6016: // CONTROLS
3166 SALOME_Selection *Sel =
3167 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3169 int nbSel = Sel->IObjectCount();
3172 smeshGUI->Control(theCommandID);
3178 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
3181 SALOME_Selection *Sel =
3182 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3184 SMESHGUI_EdgesConnectivityDlg *Dlg =
3185 new SMESHGUI_EdgesConnectivityDlg(parent, "", Sel);
3189 QApplication::restoreOverrideCursor();
3190 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
3191 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
3192 tr("SMESH_BUT_YES"));
3199 if (!parent->menuBar()->isItemChecked(9010))
3201 QApplication::setOverrideCursor(Qt::waitCursor);
3202 parent->menuBar()->setItemChecked(9011, false);
3204 smeshGUI->EraseSimulationActors();
3205 smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
3207 SALOME_Selection *Sel =
3208 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3210 int nbSel = Sel->IObjectCount();
3213 Standard_Boolean res;
3214 SMESH_Actor *MeshActor =
3215 smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
3219 parent->menuBar()->setItemChecked(9010,
3220 !parent->menuBar()->isItemChecked(9010));
3222 // It's necessary to display SMDS IDs instead of VTK ones, so
3223 // vtkIdFilter is unacceptable here. We have to do it manually :(
3224 vtkUnstructuredGrid *ptGrid = vtkUnstructuredGrid::New();
3225 ptGrid->CopyStructure(MeshActor->DataSource);
3227 int numPts = MeshActor->DataSource->GetNumberOfPoints();
3229 // Loop over points and generate ids
3230 vtkIntArray *ptIds = vtkIntArray::New();
3231 ptIds->SetNumberOfValues(numPts);
3233 for (int id = 0; id < numPts; id++)
3235 int idSMDS = MeshActor->GetIdSMESHDSNode(id);
3236 ptIds->SetValue(id, idSMDS);
3239 // mpv porting vtk4.2.2
3240 // vtkScalars* newScalars = vtkScalars::New();
3241 // newScalars->SetData(ptIds);
3242 // ptGrid->GetPointData()->SetScalars(newScalars);
3243 ptGrid->GetPointData()->SetScalars(ptIds);
3244 // newScalars->Delete();
3248 vtkMaskPoints *mask = vtkMaskPoints::New();
3249 mask->SetInput(ptGrid);
3250 mask->SetOnRatio(1);
3251 // mask->SetMaximumNumberOfPoints( 50 );
3252 // mask->RandomModeOn();
3254 vtkSelectVisiblePoints *visPts =
3255 vtkSelectVisiblePoints::New();
3256 visPts->SetInput(mask->GetOutput());
3257 visPts->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
3258 myActiveStudy->getActiveStudyFrame()->
3259 getRightFrame()->getViewFrame())->getRenderer());
3260 //visPts->SetSelectInvisible(1);
3261 visPts->SelectInvisibleOff();
3262 visPts->SetTolerance(0.1);
3264 vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
3265 ldm->SetInput(visPts->GetOutput());
3266 ldm->SetLabelFormat("%g");
3267 ldm->SetLabelModeToLabelScalars();
3268 //ldm->SetLabelModeToLabelFieldData();
3270 ldm->SetFontFamilyToTimes();
3271 ldm->SetFontSize(6 * parent->font().pointSize() / 5);
3276 vtkActor2D *pointLabels = vtkActor2D::New();
3277 pointLabels->SetMapper(ldm);
3278 pointLabels->GetProperty()->SetColor(0, 1, 0);
3282 smeshGUI->mySimulationActors2D->AddItem(pointLabels);
3283 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
3284 getActiveStudyFrame()->getRightFrame()->
3285 getViewFrame())->getRenderer()->AddActor2D(pointLabels);
3291 QApplication::setOverrideCursor(Qt::waitCursor);
3292 parent->menuBar()->setItemChecked(9010,
3293 !parent->menuBar()->isItemChecked(9010));
3294 smeshGUI->EraseSimulationActors();
3295 smeshGUI->ScalarVisibilityOff();
3297 QApplication::restoreOverrideCursor();
3302 if (!parent->menuBar()->isItemChecked(9011))
3304 QApplication::setOverrideCursor(Qt::waitCursor);
3305 parent->menuBar()->setItemChecked(9010, false);
3307 smeshGUI->EraseSimulationActors();
3308 smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
3310 SALOME_Selection *Sel =
3311 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
3313 int nbSel = Sel->IObjectCount();
3316 Standard_Boolean res;
3317 SMESH_Actor *MeshActor =
3318 smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
3322 parent->menuBar()->setItemChecked(9011,
3323 !parent->menuBar()->isItemChecked(9011));
3325 // It's necessary to display SMDS IDs instead of VTK ones, so
3326 // vtkIdFilter is unacceptable here. We have to do it manually :(
3327 vtkUnstructuredGrid *elGrid = vtkUnstructuredGrid::New();
3328 elGrid->CopyStructure(MeshActor->DataSource);
3330 int numCells = MeshActor->DataSource->GetNumberOfCells();
3332 // Loop over points and generate ids
3333 vtkIntArray *cellIds = vtkIntArray::New();
3334 cellIds->SetNumberOfValues(numCells);
3336 for (int id = 0; id < numCells; id++)
3338 int idSMDS = MeshActor->GetIdSMESHDSElement(id);
3339 cellIds->SetValue(id, idSMDS);
3342 // mpv porting vk4.2.2
3343 // vtkScalars* newScalars = vtkScalars::New();
3344 // newScalars->SetData(cellIds);
3345 elGrid->GetCellData()->SetScalars(cellIds);
3346 // elGrid->GetCellData()->SetScalars(newScalars);
3347 // newScalars->Delete();
3352 vtkCellCenters *cc = vtkCellCenters::New();
3353 cc->SetInput(elGrid);
3355 vtkSelectVisiblePoints *visCells =
3356 vtkSelectVisiblePoints::New();
3357 visCells->SetInput(cc->GetOutput());
3358 visCells->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
3359 myActiveStudy->getActiveStudyFrame()->
3360 getRightFrame()->getViewFrame())->getRenderer());
3361 visCells->SelectInvisibleOff();
3362 visCells->SetTolerance(0.1);
3363 // visCells->SetSelectInvisible(1);
3365 vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
3366 ldm->SetInput(visCells->GetOutput());
3367 ldm->SetLabelFormat("%g");
3368 ldm->SetLabelModeToLabelScalars();
3370 ldm->SetFontFamilyToTimes();
3371 ldm->SetFontSize(6 * parent->font().pointSize() / 5);
3376 vtkActor2D *cellLabels = vtkActor2D::New();
3377 cellLabels->SetMapper(ldm);
3378 cellLabels->GetProperty()->SetColor(1, 0, 0);
3383 smeshGUI->mySimulationActors2D->AddItem(cellLabels);
3384 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
3385 getActiveStudyFrame()->getRightFrame()->
3386 getViewFrame())->getRenderer()->AddActor2D(cellLabels);
3392 QApplication::setOverrideCursor(Qt::waitCursor);
3393 parent->menuBar()->setItemChecked(9011,
3394 !parent->menuBar()->isItemChecked(9011));
3395 smeshGUI->EraseSimulationActors();
3396 smeshGUI->ScalarVisibilityOff();
3398 QApplication::restoreOverrideCursor();
3402 case 10001: // DISPLAY MODE PREFERENCE
3404 parent->menuBar()->setItemChecked(10001,
3405 !parent->menuBar()->isItemChecked(10001));
3406 parent->menuBar()->setItemChecked(10002, false);
3407 parent->menuBar()->setItemChecked(10003, false);
3408 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
3413 parent->menuBar()->setItemChecked(10002,
3414 !parent->menuBar()->isItemChecked(10002));
3415 parent->menuBar()->setItemChecked(10001, false);
3416 parent->menuBar()->setItemChecked(10003, false);
3417 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
3422 parent->menuBar()->setItemChecked(10003,
3423 !parent->menuBar()->isItemChecked(10003));
3424 parent->menuBar()->setItemChecked(10002, false);
3425 parent->menuBar()->setItemChecked(10001, false);
3426 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shrink");
3432 smeshGUI->myActiveStudy->updateObjBrowser(true);
3436 //=============================================================================
3437 /*! function : GetMeshesUsingAlgoOrHypothesis()
3438 * purpose : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected.
3439 * : However is supposed here that father of father of an hypothesis is a Mesh Object.
3441 //=============================================================================
3442 SALOMEDS::Study::ListOfSObject *
3443 SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH::
3444 SMESH_Hypothesis_ptr AlgoOrHyp)
3446 SALOMEDS::Study::ListOfSObject_var listSOmesh =
3447 new SALOMEDS::Study::ListOfSObject;
3448 listSOmesh->length(0);
3449 unsigned int index = 0;
3450 if (!AlgoOrHyp->_is_nil())
3452 SALOMEDS::SObject_var SO_Hypothesis =
3453 smeshGUI->GetStudyAPI().FindHypothesisOrAlgorithms(AlgoOrHyp);
3454 if (!SO_Hypothesis->_is_nil())
3456 SALOMEDS::Study::ListOfSObject_var listSO =
3457 smeshGUI->myStudy->FindDependances(SO_Hypothesis);
3458 for (unsigned int i = 0; i < listSO->length(); i++)
3460 SALOMEDS::SObject_var SO = listSO[i];
3463 SALOMEDS::SObject_var SOfatherFather =
3464 SO->GetFather()->GetFather();
3465 if (!SOfatherFather->_is_nil())
3468 listSOmesh->length(index);
3469 listSOmesh[index - 1] = SOfatherFather;
3475 return listSOmesh._retn();
3478 //=============================================================================
3482 //=============================================================================
3483 void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID)
3485 SALOME_Selection *Sel =
3486 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
3487 int nbSel = Sel->IObjectCount();
3490 Standard_Boolean res;
3491 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
3492 SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res);
3495 if (theCommandID == 122)
3497 QString filename = QAD_FileDlg::getFileName(parent,
3499 tr("MED files (*.med)"),
3502 if (!filename.isEmpty())
3504 QApplication::setOverrideCursor(Qt::waitCursor);
3505 aMesh->Export(filename.latin1(), "MED");
3506 QApplication::restoreOverrideCursor();
3509 else if (theCommandID == 121)
3511 QString filename = QAD_FileDlg::getFileName(parent,
3513 tr("DAT files (*.dat)"),
3516 if (!filename.isEmpty())
3518 QApplication::setOverrideCursor(Qt::waitCursor);
3519 aMesh->Export(filename.latin1(), "DAT");
3520 QApplication::restoreOverrideCursor();
3523 else if (theCommandID == 123)
3525 QString filename = QAD_FileDlg::getFileName(parent,
3527 tr("IDEAS files (*.unv)"),
3530 if (!filename.isEmpty())
3532 QApplication::setOverrideCursor(Qt::waitCursor);
3533 aMesh->Export(filename.latin1(), "UNV");
3534 QApplication::restoreOverrideCursor();
3537 aMesh->Export(filename.latin1(), "DAT");
3539 QApplication::restoreOverrideCursor();
3541 if (IObject->hasEntry())
3544 SALOMEDS::SObject_var SO =
3545 smeshGUI->myStudy->FindObjectID(IObject->getEntry());
3546 SALOMEDS::GenericAttribute_var anAttr;
3547 SALOMEDS::AttributeComment_var aFileName;
3548 SALOMEDS::StudyBuilder_var aStudyBuilder =
3549 smeshGUI->myStudy->NewBuilder();
3551 aStudyBuilder->FindOrCreateAttribute(SO,
3552 "AttributeComment");
3553 aFileName = SALOMEDS::AttributeComment::_narrow(anAttr);
3554 aFileName->SetValue(filename.latin1());
3561 //=============================================================================
3565 //=============================================================================
3566 void SMESHGUI::Import_Document(QAD_Desktop * parent, int theCommandID)
3571 if (theCommandID == 113)
3573 filter = tr("MED files (*.med)");
3574 myExtension = string("MED");
3576 else if (theCommandID == 112)
3578 filter = tr("IDEAS files (*.unv)");
3579 myExtension = string("UNV");
3581 else if (theCommandID == 111)
3583 filter = tr("DAT files (*.dat)");
3584 myExtension = string("DAT");
3587 QString filename = QAD_FileDlg::getFileName(parent, "", filter,
3588 tr("Import document"), true);
3590 if (!filename.isEmpty())
3592 QApplication::setOverrideCursor(Qt::waitCursor);
3595 if (!myComponentMesh->_is_nil())
3597 SMESH::SMESH_Mesh_var aMesh =
3598 myComponentMesh->Import(myStudyId, filename.latin1(),
3599 myExtension.c_str());
3601 if (!aMesh->_is_nil())
3603 SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
3604 myStudyAPI.SetName(SM, filename);
3608 catch(const SALOME::SALOME_Exception & S_ex)
3610 QtCatchCorbaException(S_ex);
3612 myActiveStudy->updateObjBrowser(true);
3613 QApplication::restoreOverrideCursor();
3617 //=============================================================================
3621 //=============================================================================
3622 bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
3623 QAD_StudyFrame * studyFrame)
3625 SMESHGUI::GetOrCreateSMESHGUI(parent);
3629 //=============================================================================
3633 //=============================================================================
3634 bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
3635 QAD_StudyFrame * studyFrame)
3637 SMESHGUI::GetOrCreateSMESHGUI(parent);
3642 //=============================================================================
3646 //=============================================================================
3647 bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
3648 QAD_StudyFrame * studyFrame)
3650 SMESHGUI::GetOrCreateSMESHGUI(parent);
3655 //=============================================================================
3659 //=============================================================================
3660 bool SMESHGUI::SetSettings(QAD_Desktop * parent)
3662 SMESHGUI::GetOrCreateSMESHGUI(parent);
3665 QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
3666 if (DisplayMode.compare("") == 0)
3668 DisplayMode = "Shading";
3669 QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
3672 if (DisplayMode.compare("Wireframe") == 0)
3674 parent->menuBar()->setItemChecked(10003, false);
3675 parent->menuBar()->setItemChecked(10002, false);
3676 parent->menuBar()->setItemChecked(10001, true);
3678 else if (DisplayMode.compare("Shading") == 0)
3680 parent->menuBar()->setItemChecked(10003, false);
3681 parent->menuBar()->setItemChecked(10002, true);
3682 parent->menuBar()->setItemChecked(10001, false);
3684 else if (DisplayMode.compare("Shrink") == 0)
3686 parent->menuBar()->setItemChecked(10003, true);
3687 parent->menuBar()->setItemChecked(10002, false);
3688 parent->menuBar()->setItemChecked(10001, false);
3691 /* Automatic Update */
3692 QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
3693 if (AutoUpdate.compare("true") == 0)
3695 parent->menuBar()->setItemChecked(1001, true);
3696 smeshGUI->myAutomaticUpdate = true;
3700 parent->menuBar()->setItemChecked(1001, false);
3701 smeshGUI->myAutomaticUpdate = false;
3707 //=============================================================================
3711 //=============================================================================
3712 void SMESHGUI::DefinePopup(QString & theContext, QString & theParent,
3713 QString & theObject)
3715 /* Create or retrieve an object SMESHGUI */
3716 SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
3718 // NRI : Temporary added
3719 // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
3720 // theObject = "NothingSelected";
3721 // theContext = "NothingSelected";
3725 SALOME_Selection *Sel =
3726 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
3727 int nbSel = Sel->IObjectCount();
3730 if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
3733 vtkScalarBarActor *aScalarBar = smeshGUI->GetScalarBar();
3734 if ((aScalarBar != NULL) && (aScalarBar->GetVisibility() == 1))
3736 theObject = "ScalarBar";
3741 theObject = "NothingSelected";
3742 theContext = "NothingSelected";
3747 theObject = "NothingSelected";
3748 theContext = "NothingSelected";
3751 else if (nbSel == 1)
3753 theObject = smeshGUI->CheckTypeObject(Sel->firstIObject());
3758 theObject = smeshGUI->CheckHomogeneousSelection();
3763 //=============================================================================
3767 //=============================================================================
3768 bool SMESHGUI::CustomPopup(QAD_Desktop * parent,
3770 const QString & theContext,
3771 const QString & theParent, const QString & theObject)
3773 // Popup should be customized for any viewer since some meaningless commands may be present in the popup
3774 //if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) //Test du type de viewer true=OCC false=VTK
3776 /* Create or retrieve an object SMESHGUI */
3777 SMESHGUI::GetOrCreateSMESHGUI(parent);
3779 // NRI : Temporary added
3780 // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
3785 SALOME_Selection *Sel =
3786 SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
3787 QAD_StudyFrame *studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame();
3788 int nbSel = Sel->IObjectCount();
3792 if (studyFrame->getTypeView() != VIEW_VTK)
3796 else if (nbSel == 1)
3798 QString parentComp =
3799 ((SALOMEGUI_Desktop *) parent)->getComponentFromSelection();
3800 // First check type of active viewer (VTK required)
3801 if ( /*studyFrame->getTypeView() != VIEW_VTK || */ parentComp !=
3802 parent->getActiveComponent())
3804 //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items")
3807 int id = popup->idAt(0);
3808 if (id <= QAD_TopLabel_Popup_ID)
3809 popup->removeItemAt(0);
3813 if (theObject.compare("Component") == 0)
3815 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3820 // Remove common popup items for Submesh, Hypothesis and Algorithm
3821 if (theObject.compare("SubMesh") == 0 ||
3822 theObject.compare("Hypothesis") == 0 ||
3823 theObject.compare("Algorithm") == 0)
3825 popup->removeItem(QAD_Display_Popup_ID);
3826 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3827 popup->removeItem(QAD_Erase_Popup_ID);
3828 int id = popup->idAt(popup->count() - 1); // last item
3829 if (id < 0 && id != -1)
3830 popup->removeItem(id); // separator
3833 if (theObject.compare("Component") == 0)
3835 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3839 int id = QAD_TopLabel_Popup_ID; //popup->idAt(0);
3840 QFont f = QApplication::font();
3843 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
3845 if (theParent.compare("Viewer") == 0)
3847 if (popup->idAt(0) == id)
3849 popup->removeItem(id);
3850 popup->insertItem(new CustomItem(QString(IObject->getName()),
3854 Standard_Boolean res;
3856 smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
3857 if (res && studyFrame->getTypeView() == VIEW_VTK)
3859 VTKViewer_RenderWindowInteractor *myRenderInter =
3860 ((VTKViewer_ViewFrame *) studyFrame->getRightFrame()->
3861 getViewFrame())->getRWInteractor();
3862 if (myRenderInter->isVisible(IObject))
3864 popup->removeItem(QAD_Display_Popup_ID);
3868 popup->removeItem(QAD_Erase_Popup_ID);
3873 popup->removeItem(QAD_Erase_Popup_ID);
3875 { // mesh not computed -> can't display it
3876 popup->removeItem(QAD_Display_Popup_ID);
3877 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3878 popup->removeItemAt(popup->count() - 1); //separator
3882 else if (theParent.compare("ObjectBrowser") == 0)
3884 if (theObject.compare("Mesh") == 0 ||
3885 theObject.compare("SubMesh") == 0 ||
3886 theObject.compare("Hypothesis") == 0 ||
3887 theObject.compare("Algorithm") == 0)
3889 popup->removeItemAt(0);
3893 if (popup->idAt(0) == id)
3895 popup->removeItem(id);
3896 popup->removeItemAt(0); //separator
3900 Standard_Boolean res;
3902 smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
3903 if (res && studyFrame->getTypeView() == VIEW_VTK)
3905 VTKViewer_RenderWindowInteractor *myRenderInter =
3906 ((VTKViewer_ViewFrame *) studyFrame->getRightFrame()->
3907 getViewFrame())->getRWInteractor();
3908 if (myRenderInter->isVisible(IObject))
3910 popup->removeItem(QAD_Display_Popup_ID);
3914 popup->removeItem(QAD_Erase_Popup_ID);
3919 if (theObject.compare("Mesh") == 0 ||
3920 theObject.compare("SubMesh") == 0 ||
3921 theObject.compare("Hypothesis") == 0 ||
3922 theObject.compare("Algorithm") == 0)
3927 popup->removeItem(QAD_Erase_Popup_ID);
3929 { // mesh not computed -> can't display it
3930 popup->removeItem(QAD_Display_Popup_ID);
3931 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3932 popup->removeItemAt(popup->count() - 1); //separator
3940 QString parentComp =
3941 ((SALOMEGUI_Desktop *) parent)->getComponentFromSelection();
3942 QAD_StudyFrame *studyFrame =
3943 smeshGUI->myActiveStudy->getActiveStudyFrame();
3944 if ( /*studyFrame->getTypeView() != VIEW_VTK || */ parentComp !=
3945 parent->getActiveComponent())
3947 //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items")
3950 int id = popup->idAt(0);
3951 if (id <= QAD_TopLabel_Popup_ID && id != -1)
3952 popup->removeItemAt(0);
3956 if (parentComp.isNull())
3957 { // objects from several components are selected
3958 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3959 popup->removeItem(QAD_Display_Popup_ID);
3960 popup->removeItem(QAD_Erase_Popup_ID);
3961 int id = popup->idAt(popup->count() - 1); // last item
3962 if (id < 0 && id != -1)
3963 popup->removeItem(id); // separator
3968 QString type = smeshGUI->CheckHomogeneousSelection();
3969 if (type.compare("Heterogeneous Selection") != 0)
3971 int id = QAD_TopLabel_Popup_ID; //popup->idAt(0);
3972 QFont f = QApplication::font();
3974 popup->removeItem(id);
3975 popup->insertItem(new CustomItem(QString("%1 ").arg(nbSel) + type +
3976 " (s) ", f), id, 0);
3983 * Ensures that the actor for the given <theIO> exists in the active VTK view
3984 * @TODO Handle multiple selection.
3986 void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
3988 MESSAGE("SMESHGUI::BuildPresentation("<<theIO->getEntry()<<")");
3989 /* Create or retrieve an object SMESHGUI */
3990 SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
3992 QAD_StudyFrame *activeFrame =
3993 smeshGUI->myActiveStudy->getActiveStudyFrame();
3994 if (activeFrame->getTypeView() == VIEW_VTK)
3997 // Some ideas to handle multiple selection...
3998 /*SALOMEDS::SObject_var fatherSF =
3999 smeshGUI->myStudy->FindObjectID(activeFrame->entry());
4001 SALOME_Selection *Sel =
4002 SALOME_Selection::Selection(smeshGUI->myActiveStudy->
4004 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4006 for(;It.More();It.Next()) {
4007 Handle(SALOME_InteractiveObject) IObject = It.Value();*/
4008 Handle(SALOME_InteractiveObject) IObject = theIO;
4009 if (IObject->hasEntry())
4011 // Look for the actor in all views
4012 Standard_Boolean res;
4014 smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
4018 SALOMEDS::SObject_var aMorSM=smeshGUI->myStudy->FindObjectID( IObject->getEntry());
4019 SALOMEDS::GenericAttribute_var anAttr;
4020 SALOMEDS::AttributeIOR_var anIOR;
4021 if(aMorSM->FindAttribute(anAttr, "AttributeIOR"))
4023 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4024 SMESH::SMESH_Mesh_var aM =
4025 SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()));
4028 smeshGUI->InitActor(aM);
4029 ac = smeshGUI->ReadScript(aM);
4030 smeshGUI->DisplayActor( ac, true );
4031 smeshGUI->DisplayEdges( ac );
4032 smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
4036 MESSAGE("Do not know how to display something which is not a SMESH_Mesh");
4041 MESSAGE("The object "<<theIO->getEntry()<<
4042 " do not have \"AttributeIOR\" attribute");
4047 // The actor exists in some view
4048 // Check whether the actor belongs to the active view
4049 VTKViewer_RenderWindowInteractor *rwInter =
4050 ((VTKViewer_ViewFrame *) activeFrame->getRightFrame()->
4051 getViewFrame())->getRWInteractor();
4053 // The actor belongs to inactive view -> create a copy and display it in the active view
4054 if (!rwInter->isInViewer(IObject))
4056 if(ac->GetMapper()==NULL)
4058 SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(theIO, res);
4059 ac=smeshGUI->ReadScript(aMesh);
4061 SMESH_Actor *acCopy = SMESH_Actor::New();
4062 acCopy->ShallowCopy(ac);
4065 smeshGUI->DisplayActor(ac, false);
4066 smeshGUI->DisplayEdges(ac);
4067 smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
4073 MESSAGE("BuildPresentation() must not be called while non-VTK view is active");
4077 //=============================================================================
4081 //=============================================================================
4082 void SMESHGUI::setOrb()
4086 ORB_INIT & init = *SINGLETON_ < ORB_INIT >::Instance();
4087 ASSERT(SINGLETON_ < ORB_INIT >::IsAlreadyExisting());
4091 INFOS("internal error : orb not found");
4094 ASSERT(!CORBA::is_nil(_orb));
4098 * Get the history of all commands made in the SMESH server. This list of command
4099 * is used to display the mesh in the VTK view
4100 * @TODO Handle the REMOVE_ALL command.
4102 SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr aMesh)
4104 MESSAGE("SMESHGUI::ReadScript");
4105 SMESH_Actor *MeshActor;
4106 if (!aMesh->_is_nil())
4108 Standard_Boolean result;
4109 MeshActor = FindActor(aMesh, result, false);
4112 SMESH::log_array_var aSeq = aMesh->GetLog(true);
4113 MESSAGE("SMESHGUI::ReadScript: The log contains "<<aSeq->length()
4116 for (unsigned int ind = 0; ind < aSeq->length(); ind++)
4118 switch (aSeq[ind].commandType)
4120 case SMESH::ADD_NODE:
4122 AddNodes(MeshActor, aSeq[ind].number, aSeq[ind].coords,
4126 case SMESH::ADD_EDGE:
4128 // AddEdges( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes );
4131 case SMESH::ADD_TRIANGLE:
4133 AddTriangles(MeshActor, aSeq[ind].number, aSeq[ind].coords,
4137 case SMESH::ADD_QUADRANGLE:
4139 AddQuadrangles(MeshActor, aSeq[ind].number,
4140 aSeq[ind].coords, aSeq[ind].indexes);
4143 case SMESH::ADD_TETRAHEDRON:
4145 AddTetras(MeshActor, aSeq[ind].number, aSeq[ind].coords,
4149 case SMESH::ADD_PYRAMID:
4153 case SMESH::ADD_PRISM:
4157 case SMESH::ADD_HEXAHEDRON:
4159 AddHexaedres(MeshActor, aSeq[ind].number, aSeq[ind].coords,
4163 case SMESH::REMOVE_NODE:
4165 RemoveNodes(MeshActor, aSeq[ind].number, aSeq[ind].coords,
4169 case SMESH::REMOVE_ELEMENT:
4171 RemoveElements(MeshActor, aSeq[ind].number,
4172 aSeq[ind].coords, aSeq[ind].indexes);
4175 case SMESH::REMOVE_ALL:
4176 MESSAGE("REMOVE_ALL command not yet implemented");
4178 default: MESSAGE("Warning: Unknown script command.");
4187 //=============================================================================
4191 //=============================================================================
4192 void SMESHGUI::Dump(SMESH_Actor * Mactor)
4194 vtkUnstructuredGrid *ugrid =
4195 vtkUnstructuredGrid::SafeDownCast(Mactor->DataSource);
4196 vtkPoints *Pts = ugrid->GetPoints();
4197 int nbPts = Pts->GetNumberOfPoints();
4198 int nbCells = ugrid->GetNumberOfCells();
4202 In = fopen("/tmp/dumpMesh", "w+");
4203 fprintf(In, "%d %d\n", nbPts, nbCells);
4204 for (int i = 0; i < nbPts; i++)
4206 float *p = ugrid->GetPoint(i);
4207 fprintf(In, "%d %e %e %e\n", i, p[0], p[1], p[2]);
4210 for (int i = 0; i < nbCells; i++)
4212 fprintf(In, "%d %d", i, ugrid->GetCell(i)->GetCellType());
4213 vtkIdList *Id = ugrid->GetCell(i)->GetPointIds();
4214 for (j = 0; j < Id->GetNumberOfIds(); j++)
4216 fprintf(In, " %d", Id->GetId(j));
4223 //=============================================================================
4227 //=============================================================================
4228 void SMESHGUI::AddNodes(SMESH_Actor * Mactor, int number,
4229 const SMESH::double_array & coords, const SMESH::long_array & indexes)
4231 MESSAGE("SMESHGUI::AddNodes(number="<<number<<", indexes.length()="<<indexes.length()<<")");
4232 QApplication::setOverrideCursor(Qt::waitCursor);
4233 if (Mactor->GetMapper() == NULL)
4235 vtkPoints *Pts = vtkPoints::New();
4236 SMESH_Grid *ugrid = SMESH_Grid::New();
4244 Pts->InsertNextPoint(coords[j - 1], coords[j], coords[j + 1]);
4245 //Mactor->AddNode( indexes[i-1], idVTK );
4246 ugrid->AddNode(indexes[i - 1], idVTK);
4250 //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
4251 ugrid->SetPoints(Pts);
4252 vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
4253 PtsMapper->SetInput(ugrid);
4254 Mactor->DataSource = PtsMapper->GetInput();
4255 Mactor->SetMapper(PtsMapper);
4259 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4260 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4266 ugrid->GetPoints()->InsertNextPoint(coords[j - 1], coords[j],
4268 ugrid->AddNode(indexes[i - 1], idVTK);
4272 vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
4273 PtsMapper->SetInput(ugrid);
4274 Mactor->DataSource = PtsMapper->GetInput();
4275 Mactor->SetMapper(PtsMapper);
4277 QApplication::restoreOverrideCursor();
4280 //=============================================================================
4284 //=============================================================================
4285 void SMESHGUI::AddNode(SMESH_Actor * Mactor, int idnode, float x, float y,
4288 QApplication::setOverrideCursor(Qt::waitCursor);
4289 MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" << z);
4291 if (Mactor->GetMapper() == NULL)
4293 vtkPoints *Pts = vtkPoints::New();
4294 int idVTK = Pts->InsertNextPoint(x, y, z);
4295 //Mactor->AddNode( idnode, idVTK );
4296 //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
4297 SMESH_Grid *ugrid = SMESH_Grid::New();
4299 ugrid->AddNode(idnode, idVTK);
4300 ugrid->SetPoints(Pts);
4301 vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
4302 PtsMapper->SetInput(ugrid);
4303 Mactor->DataSource = PtsMapper->GetInput();
4304 Mactor->SetMapper(PtsMapper);
4308 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4309 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4310 int idVTK = ugrid->GetPoints()->InsertNextPoint(x, y, z);
4311 //Mactor->AddNode( idnode, idVTK );
4312 ugrid->AddNode(idnode, idVTK);
4313 vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
4314 PtsMapper->SetInput(ugrid);
4315 Mactor->DataSource = PtsMapper->GetInput();
4316 Mactor->SetMapper(PtsMapper);
4318 QApplication::restoreOverrideCursor();
4321 //=============================================================================
4325 //=============================================================================
4326 void SMESHGUI::RemoveNode(SMESH_Actor * Mactor, int idnode)
4328 MESSAGE(" OLD RemoveNode method ")
4329 // int id = Mactor->GetIdVTKNode( idnode );
4330 // MESSAGE ( " RemoveNode id VTK " << id )
4331 // if ( Mactor->GetMapper() != NULL ) {
4332 // vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4333 // vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New();
4334 // vtkPoints *Pts = ugrid->GetPoints();
4335 // vtkPoints *newPts = vtkPoints::New();
4336 // int nbPts = Pts->GetNumberOfPoints();
4337 // bool findPt = false;
4338 // for ( int i = 0; i < nbPts; i++ ) {
4341 // newPts->InsertPoint(i, Pts->GetPoint(i) );
4343 // newPts->InsertPoint(i-1, Pts->GetPoint(i) );
4346 // Mactor->RemoveNode( idnode );
4349 // newUgrid->SetPoints(newPts);
4350 // int nbCells = ugrid->GetNumberOfCells();
4351 // for ( int i = 0; i < nbCells; i++ ) {
4352 // vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds();
4353 // vtkIdList *newIds = vtkIdList::New();
4354 // int nbIds = Ids->GetNumberOfIds();
4355 // newIds->SetNumberOfIds(nbIds);
4356 // for ( int j = 0; j < nbIds; j++ ) {
4357 // int theid = Ids->GetId(j);
4358 // if ( theid > id ) {
4359 // newIds->SetId( j, theid-1 );
4361 // newIds->SetId( j, theid );
4363 // int idSMDSel = Mactor->GetIdSMESHDSElement( i );
4364 // Mactor->RemoveElement( idSMDSel, false );
4365 // int idVTKel = newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), newIds );
4366 // Mactor->AddElement( idSMDSel, idVTKel );
4368 // vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
4369 // Mapper->SetInput( newUgrid );
4370 // Mactor->DataSource = Mapper->GetInput();
4371 // Mactor->SetMapper(Mapper);
4376 //=============================================================================
4380 //=============================================================================
4381 void SMESHGUI::RemoveNodes(SMESH_Actor * Mactor, int number,
4382 const SMESH::double_array & coords, const SMESH::long_array & indexes)
4384 QApplication::setOverrideCursor(Qt::waitCursor);
4388 Mactor->RemoveNode(indexes[i - 1]);
4392 TColStd_DataMapOfIntegerInteger newMapVTKNodes;
4393 TColStd_DataMapOfIntegerInteger newMapSMESHDSNodes;
4394 TColStd_DataMapOfIntegerInteger MapOldNodesToNewNodes;
4396 if (Mactor->GetMapper() != NULL)
4398 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4399 SMESH_Grid *newUgrid = SMESH_Grid::New();
4400 newUgrid->CopyMaps(ugrid);
4402 vtkPoints *Pts = ugrid->GetPoints();
4403 vtkPoints *newPts = vtkPoints::New();
4404 int nbPts = Pts->GetNumberOfPoints();
4406 for (int i = 0; i < nbPts; i++)
4408 int idSMESHDSNode = Mactor->GetIdSMESHDSNode(i);
4409 if (idSMESHDSNode != -1)
4411 newPts->InsertPoint(j, Pts->GetPoint(i));
4413 newMapVTKNodes.Bind(j, idSMESHDSNode);
4414 newMapSMESHDSNodes.Bind(idSMESHDSNode, j);
4416 MapOldNodesToNewNodes.Bind(i, j);
4421 newUgrid->SetIdsVTKNode(newMapVTKNodes);
4422 newUgrid->SetIdsSMESHDSNode(newMapSMESHDSNodes);
4423 newUgrid->SetPoints(newPts);
4425 TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK;
4426 TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS;
4428 int nbCells = ugrid->GetNumberOfCells();
4429 for (int i = 0; i < nbCells; i++)
4431 vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds();
4432 vtkIdList *newIds = vtkIdList::New();
4433 int nbIds = Ids->GetNumberOfIds();
4434 newIds->SetNumberOfIds(nbIds);
4436 for (int j = 0; j < nbIds; j++)
4438 int theid = Ids->GetId(j);
4439 if (MapOldNodesToNewNodes.IsBound(theid))
4441 newIds->SetId(j, MapOldNodesToNewNodes.Find(theid));
4450 // Filtering out cells based on non-existing nodes
4453 int idSMDSel = Mactor->GetIdSMESHDSElement(i);
4455 newUgrid->InsertNextCell(ugrid->GetCell(i)->GetCellType(),
4458 newMapElementSMDStoVTK.Bind(idSMDSel, idVTKel);
4459 newMapElementVTKtoSMDS.Bind(idVTKel, idSMDSel);
4463 newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS);
4464 newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK);
4466 // Copy new data to the old DatSource: keep the single DataSource for all actors
4467 ugrid->DeepCopy(newUgrid);
4469 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
4470 Mapper->SetInput(ugrid);
4471 Mactor->SetMapper(Mapper);
4473 // Commented to avoid multiple viewer updates when called by ReadScript()
4477 QApplication::restoreOverrideCursor();
4480 //=============================================================================
4484 //=============================================================================
4485 void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh,
4486 const TColStd_MapOfInteger & MapIndex)
4488 QApplication::setOverrideCursor(Qt::waitCursor);
4489 Standard_Boolean result;
4490 SMESH_Actor *ac = FindActor(aMesh, result, true);
4493 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
4494 anArrayOfIdeces->length(MapIndex.Extent());
4495 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
4497 for (; ite.More(); ite.Next())
4499 // MESSAGE ( " RemoveNode : id " << ac->GetIdSMESHDSNode(ite.Key()) )
4500 anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
4503 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
4504 aMeshEditor->RemoveNodes(anArrayOfIdeces);
4507 if (myAutomaticUpdate)
4509 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
4512 smeshGUI->DisplayActor(Mesh);
4513 smeshGUI->DisplayEdges(Mesh);
4514 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
4515 AddActorInSelection(Mesh);
4518 QApplication::restoreOverrideCursor();
4521 //=============================================================================
4525 //=============================================================================
4526 void SMESHGUI::RemoveElement(SMESH_Actor * Mactor, int idelement)
4528 MESSAGE(" OLD RemoveElement method ")
4529 // int id = Mactor->GetIdVTKElement( idelement );
4530 // MESSAGE ( " RemoveElement id VTK : " << id )
4531 // if ( Mactor->GetMapper() != NULL ) {
4532 // vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4533 // vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New();
4534 // int nbCells = ugrid->GetNumberOfCells();
4535 // for ( int i = 0; i < nbCells; i++ ) {
4537 // newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(),
4538 // ugrid->GetCell(i)->GetPointIds() );
4540 // Mactor->RemoveElement( idelement );
4542 // newUgrid->SetPoints(ugrid->GetPoints());
4543 // vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
4544 // Mapper->SetInput( newUgrid );
4545 // Mactor->DataSource = Mapper->GetInput();
4546 // Mactor->SetMapper(Mapper);
4551 //=============================================================================
4555 //=============================================================================
4556 void SMESHGUI::RemoveElements(SMESH_Actor * Mactor, int number,
4557 const SMESH::double_array & coords, const SMESH::long_array & indexes)
4559 QApplication::setOverrideCursor(Qt::waitCursor);
4563 Mactor->RemoveElement(indexes[i - 1]);
4566 TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK;
4567 TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS;
4569 if (Mactor->GetMapper() != NULL)
4571 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4572 SMESH_Grid *newUgrid = SMESH_Grid::New();
4573 newUgrid->CopyMaps(ugrid);
4575 int nbCells = ugrid->GetNumberOfCells();
4576 for (int i = 0; i < nbCells; i++)
4578 int idSMESHDSElement = Mactor->GetIdSMESHDSElement(i);
4579 if (idSMESHDSElement != -1)
4582 newUgrid->InsertNextCell(ugrid->GetCell(i)->GetCellType(),
4583 ugrid->GetCell(i)->GetPointIds());
4584 newMapElementSMDStoVTK.Bind(idSMESHDSElement, newId);
4585 newMapElementVTKtoSMDS.Bind(newId, idSMESHDSElement);
4589 newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS);
4590 newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK);
4592 newUgrid->SetPoints(ugrid->GetPoints());
4594 // Copy new data to the old DatSource: keep the single DataSource for all actors
4595 ugrid->DeepCopy(newUgrid);
4597 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
4598 Mapper->SetInput(ugrid);
4599 Mactor->SetMapper(Mapper);
4601 // Commented to avoid multiple viewer updates when called by ReadScript()
4604 QApplication::restoreOverrideCursor();
4607 //=============================================================================
4611 //=============================================================================
4612 void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr aMesh,
4613 const TColStd_MapOfInteger & MapIndex)
4615 QApplication::setOverrideCursor(Qt::waitCursor);
4616 Standard_Boolean result;
4617 SMESH_Actor *ac = FindActor(aMesh, result, true);
4620 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
4621 anArrayOfIdeces->length(MapIndex.Extent());
4622 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
4624 for (; ite.More(); ite.Next())
4626 // MESSAGE ( " RemoveElement : id " << ite.Key() << "," << ac->GetIdSMESHDSElement(ite.Key()) )
4627 anArrayOfIdeces[i] = ac->GetIdSMESHDSElement(ite.Key());
4631 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
4632 aMeshEditor->RemoveElements(anArrayOfIdeces);
4635 if (myAutomaticUpdate)
4637 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
4640 smeshGUI->DisplayActor(Mesh);
4641 smeshGUI->DisplayEdges(Mesh);
4642 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
4643 AddActorInSelection(Mesh);
4649 QApplication::restoreOverrideCursor();
4652 //=============================================================================
4656 //=============================================================================
4657 void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh,
4658 const TColStd_MapOfInteger & MapIndex)
4660 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
4663 vtkRenderer *theRenderer =
4664 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
4665 getRightFrame()->getViewFrame())->getRenderer();
4666 Standard_Boolean result;
4667 SMESH_Actor *ac = FindActor(aMesh, result, true);
4670 //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New();
4671 SMESH_Grid *UGrid = SMESH_Grid::New();
4672 SMESH_Grid *oldGrid = SMESH_Grid::SafeDownCast(ac->DataSource);
4673 UGrid->CopyMaps(oldGrid);
4675 vtkGeometryFilter *gf = vtkGeometryFilter::New();
4676 gf->SetInput(ac->DataSource);
4678 vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
4679 Mapper->SetInput(gf->GetOutput());
4682 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
4683 for (; ite.More(); ite.Next())
4685 Mapper->GetInput()->ReverseCell(ite.Key());
4688 UGrid->SetPoints(Mapper->GetInput()->GetPoints());
4689 int nbCells = Mapper->GetInput()->GetNumberOfCells();
4690 for (int i = 0; i < nbCells; i++)
4692 UGrid->InsertNextCell(Mapper->GetInput()->GetCellType(i),
4693 Mapper->GetInput()->GetCell(i)->GetPointIds());
4696 // Copy new data to the old DatSource: keep the single DataSource for all actors
4697 oldGrid->DeepCopy(UGrid);
4699 vtkDataSetMapper *NewMapper = vtkDataSetMapper::New();
4700 //NewMapper->SetInput( UGrid );
4701 NewMapper->SetInput(oldGrid);
4702 NewMapper->Update();
4704 //ac->DataSource = NewMapper->GetInput();
4705 ac->SetMapper(NewMapper);
4707 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
4709 QApplication::restoreOverrideCursor();
4712 //=============================================================================
4716 //=============================================================================
4717 void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh,
4718 const TColStd_MapOfInteger & MapIndex)
4720 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
4723 QApplication::setOverrideCursor(Qt::waitCursor);
4724 vtkRenderer *theRenderer =
4725 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
4726 getRightFrame()->getViewFrame())->getRenderer();
4727 Standard_Boolean result;
4729 SMESH_Actor *ac = FindActor(aMesh, result, true);
4732 //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New();
4733 SMESH_Grid *UGrid = SMESH_Grid::New();
4734 vtkGeometryFilter *gf = vtkGeometryFilter::New();
4735 gf->SetInput(ac->DataSource);
4737 vtkExtractEdges *edges = vtkExtractEdges::New();
4738 edges->SetInput(ac->DataSource);
4740 vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
4741 Mapper->SetInput(edges->GetOutput());
4744 int nb = Mapper->GetInput()->GetNumberOfCells();
4745 //MESSAGE ( "nb : " << nb )
4747 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
4748 for (; ite.More(); ite.Next())
4750 vtkCell *StartEdge = Mapper->GetInput()->GetCell(ite.Key());
4751 //MESSAGE( "DCQ : Edge Id = " << ite.Key())
4752 int CellType = StartEdge->GetCellType();
4753 //MESSAGE( "DCQ : Cell Type = " << CellType)
4754 int nbPoints = StartEdge->GetNumberOfPoints();
4756 //MESSAGE( "DCQ : Nb Point = " << nbPoints)
4759 vtkUnstructuredGrid *StartUGrid =
4760 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
4762 vtkIdList *IdCells = vtkIdList::New();
4763 vtkIdList *IdPoints = StartEdge->GetPointIds();
4767 Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(0),
4769 Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(1),
4772 int idp1 = StartUGrid->FindPoint(p1);
4773 int idp2 = StartUGrid->FindPoint(p2);
4775 StartUGrid->GetPointCells(idp1, IdCells);
4777 //MESSAGE ( " pt 0 : " << IdPoints->GetId(0) )
4778 //MESSAGE ( " pt 1 : " << IdPoints->GetId(1) )
4780 //MESSAGE ( " pt 0 : " << idp1 )
4781 //MESSAGE ( " pt 1 : " << idp2 )
4783 vtkIdList *IdPts = vtkIdList::New();
4784 if (IdCells->GetNumberOfIds() >= 2)
4786 int nbCells = IdCells->GetNumberOfIds();
4787 //MESSAGE ( " nbCells : " << nbCells )
4788 for (int j = 0; j < nbCells; j++)
4790 StartUGrid->GetCellPoints(IdCells->GetId(j), IdPts);
4791 if (IdPts->IsId(idp2) == -1)
4793 IdCells->DeleteId(IdCells->GetId(j));
4797 //MESSAGE ( " IdCells " << IdCells->GetNumberOfIds() )
4799 vtkIdList *IdPts0 = vtkIdList::New();
4800 vtkIdList *IdPts1 = vtkIdList::New();
4802 if (IdCells->GetNumberOfIds() == 2)
4804 StartUGrid->GetCellPoints(IdCells->GetId(0), IdPts0);
4805 StartUGrid->GetCellPoints(IdCells->GetId(1), IdPts1);
4808 TColStd_MapOfInteger EndMapIndex;
4809 for (int j = 0; j < 3; j++)
4811 if (IdPts0->GetId(j) != idp1 &&
4812 IdPts0->GetId(j) != idp2)
4814 EndMapIndex.Add(IdPts0->GetId(j));
4816 if (IdPts1->GetId(j) != idp1 &&
4817 IdPts1->GetId(j) != idp2)
4819 EndMapIndex.Add(IdPts1->GetId(j));
4823 bool MyAU = myAutomaticUpdate;
4824 myAutomaticUpdate = false;
4826 EndMapIndex.Add(idp1);
4827 TColStd_MapIteratorOfMapOfInteger ite1(EndMapIndex);
4831 if (ite1.Key() == idp1)
4836 bool reverse1 = (i == 2);
4837 this->AddFace(aMesh, EndMapIndex, reverse1);
4839 EndMapIndex.Remove(idp1);
4840 EndMapIndex.Add(idp2);
4841 TColStd_MapIteratorOfMapOfInteger ite2(EndMapIndex);
4845 if (ite2.Key() == idp2)
4850 bool reverse2 = (i == 2);
4851 this->AddFace(aMesh, EndMapIndex,
4852 !(reverse1 == reverse2));
4854 myAutomaticUpdate = MyAU;
4855 //MESSAGE ( " myAutomaticUpdate = " << MyAU )
4858 TColStd_MapOfInteger StartMapIndex;
4859 StartMapIndex.Add(IdCells->GetId(0));
4860 StartMapIndex.Add(IdCells->GetId(1));
4861 this->RemoveElements(aMesh, StartMapIndex);
4869 // UGrid->SetPoints( Mapper->GetInput()->GetPoints() );
4870 // int nbCells = Mapper->GetInput()->GetNumberOfCells();
4871 // for ( int i = 0; i < nbCells; i++ ) {
4872 // UGrid->InsertNextCell( Mapper->GetInput()->GetCellType(i), Mapper->GetInput()->GetCell(i)->GetPointIds() );
4875 // vtkDataSetMapper *NewMapper = vtkDataSetMapper::New();
4876 // NewMapper->SetInput( UGrid );
4877 // NewMapper->Update();
4879 // ac->DataSource = NewMapper->GetInput();
4880 // ac->SetMapper( NewMapper );
4882 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
4884 QApplication::restoreOverrideCursor();
4887 //=============================================================================
4891 //=============================================================================
4892 void SMESHGUI::AddEdges(SMESH_Actor * Mactor, int number,
4893 const SMESH::double_array & coords, const SMESH::long_array & indexes)
4895 QApplication::setOverrideCursor(Qt::waitCursor);
4896 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4897 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4902 vtkIdList *Ids = vtkIdList::New();
4903 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
4904 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
4905 int id = ugrid->InsertNextCell(VTK_LINE, Ids);
4906 Mactor->AddElement(indexes[j - 1], id);
4910 vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New();
4911 EdgeMapper->SetInput(ugrid);
4912 Mactor->DataSource = EdgeMapper->GetInput();
4913 Mactor->SetMapper(EdgeMapper);
4914 QApplication::restoreOverrideCursor();
4917 //=============================================================================
4921 //=============================================================================
4922 void SMESHGUI::AddEdge(SMESH_Actor * Mactor, int idedge, int idnode1,
4925 QApplication::setOverrideCursor(Qt::waitCursor);
4926 MESSAGE("SMESHGUI::AddEdge " << idedge << " : " << idnode1 << ";" <<
4927 idnode2) vtkIdList *Ids = vtkIdList::New();
4928 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
4929 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
4931 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4932 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4933 int id = ugrid->InsertNextCell(VTK_LINE, Ids);
4934 Mactor->AddElement(idedge, id);
4936 MESSAGE(" Edge VTK id " << id)
4937 vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New();
4938 EdgeMapper->SetInput(ugrid);
4939 Mactor->DataSource = EdgeMapper->GetInput();
4940 Mactor->SetMapper(EdgeMapper);
4941 QApplication::restoreOverrideCursor();
4944 //=============================================================================
4948 //=============================================================================
4949 void SMESHGUI::AddTriangles(SMESH_Actor * Mactor, int number,
4950 const SMESH::double_array & coords, const SMESH::long_array & indexes)
4952 MESSAGE("SMESHGUI::AddTriangles(number="<<number<<", indexes.length="
4953 <<indexes.length()<<")");
4955 QApplication::setOverrideCursor(Qt::waitCursor);
4956 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4957 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4962 vtkIdList *Ids = vtkIdList::New();
4963 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
4964 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
4965 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
4966 int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids);
4967 Mactor->AddElement(indexes[j - 1], id);
4971 vtkDataSetMapper *TriMapper = vtkDataSetMapper::New();
4972 TriMapper->SetInput(ugrid);
4973 Mactor->DataSource = TriMapper->GetInput();
4974 Mactor->SetMapper(TriMapper);
4975 QApplication::restoreOverrideCursor();
4977 void SMESHGUI::AddTriangle(SMESH_Actor * Mactor, int idtri, int idnode1,
4978 int idnode2, int idnode3)
4980 QApplication::setOverrideCursor(Qt::waitCursor);
4981 vtkIdList *Ids = vtkIdList::New();
4982 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
4983 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
4984 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
4986 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
4987 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
4988 int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids);
4989 Mactor->AddElement(idtri, id);
4991 vtkDataSetMapper *TriMapper = vtkDataSetMapper::New();
4992 TriMapper->SetInput(ugrid);
4993 Mactor->DataSource = TriMapper->GetInput();
4994 Mactor->SetMapper(TriMapper);
4995 QApplication::restoreOverrideCursor();
4998 //=============================================================================
5002 //=============================================================================
5003 void SMESHGUI::AddQuadrangles(SMESH_Actor * Mactor, int number,
5004 const SMESH::double_array & coords, const SMESH::long_array & indexes)
5006 QApplication::setOverrideCursor(Qt::waitCursor);
5007 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5008 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5013 vtkIdList *Ids = vtkIdList::New();
5014 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
5015 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
5016 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
5017 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
5018 int id = ugrid->InsertNextCell(VTK_QUAD, Ids);
5019 Mactor->AddElement(indexes[j - 1], id);
5023 vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New();
5024 QuadMapper->SetInput(ugrid);
5025 Mactor->DataSource = QuadMapper->GetInput();
5026 Mactor->SetMapper(QuadMapper);
5027 QApplication::restoreOverrideCursor();
5030 //=============================================================================
5034 //=============================================================================
5035 void SMESHGUI::AddQuadrangle(SMESH_Actor * Mactor, int idquad, int idnode1,
5036 int idnode2, int idnode3, int idnode4)
5038 QApplication::setOverrideCursor(Qt::waitCursor);
5039 vtkIdList *Ids = vtkIdList::New();
5040 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
5041 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
5042 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
5043 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
5045 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5046 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5047 int id = ugrid->InsertNextCell(VTK_QUAD, Ids);
5048 Mactor->AddElement(idquad, id);
5050 vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New();
5051 QuadMapper->SetInput(ugrid);
5052 Mactor->DataSource = QuadMapper->GetInput();
5053 Mactor->SetMapper(QuadMapper);
5054 QApplication::restoreOverrideCursor();
5057 //=============================================================================
5061 //=============================================================================
5062 void SMESHGUI::AddTetras(SMESH_Actor * Mactor, int number,
5063 const SMESH::double_array & coords, const SMESH::long_array & indexes)
5065 QApplication::setOverrideCursor(Qt::waitCursor);
5066 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5067 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5072 vtkIdList *Ids = vtkIdList::New();
5073 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
5074 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
5075 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
5076 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
5077 int id = ugrid->InsertNextCell(VTK_TETRA, Ids);
5078 Mactor->AddElement(indexes[j - 1], id);
5082 vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New();
5083 TetraMapper->SetInput(ugrid);
5084 Mactor->DataSource = TetraMapper->GetInput();
5085 Mactor->SetMapper(TetraMapper);
5086 QApplication::restoreOverrideCursor();
5089 //=============================================================================
5093 //=============================================================================
5094 void SMESHGUI::AddTetra(SMESH_Actor * Mactor, int idtetra, int idnode1,
5095 int idnode2, int idnode3, int idnode4)
5097 QApplication::setOverrideCursor(Qt::waitCursor);
5098 MESSAGE("SMESHGUI::AddTetra " << idtetra << " : " << idnode1 << ";" <<
5099 idnode2 << ";" << idnode3 << ";" << idnode4) vtkIdList *Ids =
5101 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
5102 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
5103 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
5104 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
5106 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5107 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5108 int id = ugrid->InsertNextCell(VTK_TETRA, Ids);
5109 Mactor->AddElement(idtetra, id);
5111 MESSAGE(" Tetra VTK id " << id)
5112 vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New();
5113 TetraMapper->SetInput(ugrid);
5114 Mactor->DataSource = TetraMapper->GetInput();
5115 Mactor->SetMapper(TetraMapper);
5116 QApplication::restoreOverrideCursor();
5119 //=============================================================================
5123 //=============================================================================
5124 void SMESHGUI::AddHexaedres(SMESH_Actor * Mactor, int number,
5125 const SMESH::double_array & coords, const SMESH::long_array & indexes)
5127 QApplication::setOverrideCursor(Qt::waitCursor);
5128 //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5129 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5134 vtkIdList *Ids = vtkIdList::New();
5135 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
5136 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
5137 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
5138 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
5139 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 4]));
5140 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 5]));
5141 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 6]));
5142 Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 7]));
5143 int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
5144 Mactor->AddElement(indexes[j - 1], id);
5148 vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New();
5149 HexaMapper->SetInput(ugrid);
5150 Mactor->DataSource = HexaMapper->GetInput();
5151 Mactor->SetMapper(HexaMapper);
5152 QApplication::restoreOverrideCursor();
5155 //=============================================================================
5159 //=============================================================================
5160 void SMESHGUI::AddHexaedre(SMESH_Actor * Mactor, int idhexa, int idnode1,
5161 int idnode2, int idnode3, int idnode4, int idnode5, int idnode6,
5162 int idnode7, int idnode8)
5164 QApplication::setOverrideCursor(Qt::waitCursor);
5165 MESSAGE("SMESHGUI::AddHexaedre " << idhexa << " : " << idnode1 << ";" <<
5166 idnode2 << ";" << idnode3 << ";" << idnode4 << ";" << idnode5 << ";" <<
5167 idnode6 << ";" << idnode7 << ";" << idnode8) vtkIdList *Ids =
5169 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
5170 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
5171 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
5172 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
5173 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode5));
5174 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode6));
5175 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode7));
5176 Ids->InsertNextId(Mactor->GetIdVTKNode(idnode8));
5178 //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
5179 SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
5180 int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
5181 Mactor->AddElement(idhexa, id);
5183 MESSAGE(" Hexa VTK id " << id)
5184 vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New();
5185 HexaMapper->SetInput(ugrid);
5186 Mactor->DataSource = HexaMapper->GetInput();
5187 Mactor->SetMapper(HexaMapper);
5188 QApplication::restoreOverrideCursor();
5191 //=====================================================================================
5193 //=====================================================================================
5196 bool OnGUIEvent(int theCommandID, QAD_Desktop * parent)
5198 return SMESHGUI::OnGUIEvent(theCommandID, parent);
5201 bool OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
5202 QAD_StudyFrame * studyFrame)
5204 return SMESHGUI::OnKeyPress(pe, parent, studyFrame);
5207 bool OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
5208 QAD_StudyFrame * studyFrame)
5210 return SMESHGUI::OnMousePress(pe, parent, studyFrame);
5213 bool OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
5214 QAD_StudyFrame * studyFrame)
5216 return SMESHGUI::OnMouseMove(pe, parent, studyFrame);
5219 bool SetSettings(QAD_Desktop * parent)
5221 return SMESHGUI::SetSettings(parent);
5224 bool customPopup(QAD_Desktop * parent, QPopupMenu * popup,
5225 const QString & theContext, const QString & theParent,
5226 const QString & theObject)
5228 return SMESHGUI::CustomPopup(parent, popup, theContext, theParent,
5232 void definePopup(QString & theContext, QString & theParent,
5233 QString & theObject)
5235 SMESHGUI::DefinePopup(theContext, theParent, theObject);
5238 bool activeStudyChanged(QAD_Desktop * parent)
5240 SMESHGUI::activeStudyChanged(parent);
5243 void buildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
5245 SMESHGUI::BuildPresentation(theIO);
5248 void supportedViewType(int *buffer, int bufferSize)
5250 if (!buffer || !bufferSize)
5252 buffer[0] = (int)VIEW_VTK;
5257 //=============================================================================
5261 //=============================================================================
5262 void SMESHGUI::ViewNodes()
5264 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
5267 EraseSimulationActors();
5268 mySimulationActors = vtkActorCollection::New();
5269 vtkRenderer *theRenderer =
5270 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5271 getRightFrame()->getViewFrame())->getRenderer();
5272 vtkActorCollection *theActors = theRenderer->GetActors();
5273 theActors->InitTraversal();
5274 vtkActor *ac = theActors->GetNextActor();
5275 while (!(ac == NULL))
5277 if (ac->IsA("SMESH_Actor"))
5279 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
5280 if (anActor->GetVisibility() == 1)
5282 vtkGeometryFilter *gf = vtkGeometryFilter::New();
5283 gf->SetInput(anActor->DataSource);
5284 vtkMaskPoints *verts = vtkMaskPoints::New();
5285 verts->SetInput(gf->GetOutput());
5286 verts->GenerateVerticesOn();
5287 verts->SetOnRatio(1);
5289 vtkPolyDataMapper *vertMapper = vtkPolyDataMapper::New();
5290 vertMapper->SetInput(verts->GetOutput());
5291 vertMapper->ScalarVisibilityOff();
5293 vtkActor *vertActor = vtkActor::New();
5294 vertActor->SetMapper(vertMapper);
5297 anActor->GetNodeColor(r, g, b);
5298 vertActor->GetProperty()->SetColor(r, g, b);
5300 vertActor->GetProperty()->SetPointSize(anActor->GetNodeSize());
5302 vertActor->PickableOff();
5304 mySimulationActors->AddItem(vertActor);
5305 theRenderer->AddActor(vertActor);
5308 ac = theActors->GetNextActor();
5311 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
5315 //=============================================================================
5319 //=============================================================================
5320 void SMESHGUI::Control(int theCommandID)
5322 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
5325 QApplication::setOverrideCursor(Qt::waitCursor);
5326 DisplayScalarBar(false);
5328 vtkDoubleArray *scalars = vtkDoubleArray::New();
5329 scalars->SetNumberOfComponents(1);
5331 vtkDataSetMapper *meshMapper = 0;
5332 SALOME_Selection *Sel =
5333 SALOME_Selection::Selection(myActiveStudy->getSelection());
5334 int nbSel = Sel->IObjectCount();
5335 Standard_Boolean result;
5336 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5337 SMESH_Actor *MeshActor =
5338 FindActorByEntry(IObject->getEntry(), result, true);
5340 // Mesh may be not updated after Compute
5341 if (!MeshActor->DataSource || !MeshActor->GetMapper())
5343 QApplication::restoreOverrideCursor();
5347 vtkDataSet *aDataSet = MeshActor->DataSource;
5348 typedef double (*TScalarFun) (vtkCell * theCell);
5349 TScalarFun aScalarFun;
5353 switch (theCommandID)
5357 type = tr("SMESH_CONTROL_LENGTH_EDGES");
5358 aDataSet = MeshActor->EdgeDevice->GetMapper()->GetInput();
5359 aScalarFun = &(SMESHGUI_ComputeScalarValue::LengthEdges);
5360 MESSAGE(" init minimum length " << aDataSet->GetNumberOfCells());
5361 if (MeshActor->getDisplayMode() != 0)
5362 ChangeRepresentation(MeshActor, 1); // limitation; in Wireframe, colored edges are not visible
5367 type = tr("SMESH_CONTROL_AREA_ELEMENTS");
5368 aScalarFun = &(SMESHGUI_ComputeScalarValue::AreaElements);
5369 if (MeshActor->getDisplayMode() != 1)
5370 ChangeRepresentation(MeshActor, 1);
5375 type = tr("SMESH_CONTROL_TAPER_ELEMENTS");
5376 aScalarFun = &(SMESHGUI_ComputeScalarValue::Taper);
5381 type = tr("SMESH_CONTROL_ASPECTRATIO_ELEMENTS");
5382 aScalarFun = &(SMESHGUI_ComputeScalarValue::AspectRatio);
5383 if (MeshActor->getDisplayMode() != 1)
5384 ChangeRepresentation(MeshActor, 1);
5389 type = tr("SMESH_CONTROL_MINIMUMANGLE_ELEMENTS");
5390 aScalarFun = &(SMESHGUI_ComputeScalarValue::MinimumAngle);
5391 if (MeshActor->getDisplayMode() != 1)
5392 ChangeRepresentation(MeshActor, 1);
5397 type = tr("SMESH_CONTROL_WARP_ELEMENTS");
5398 aScalarFun = &(SMESHGUI_ComputeScalarValue::Warp);
5403 type = tr("SMESH_CONTROL_SKEW_ELEMENTS");
5404 aScalarFun = &(SMESHGUI_ComputeScalarValue::Skew);
5409 for (int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++)
5410 scalars->InsertTuple1(i, aScalarFun(aDataSet->GetCell(i)));
5413 scalars->GetRange(range);
5415 vtkLookupTable *wat = vtkLookupTable::New();
5416 wat->SetRange(range);
5419 scalars->SetLookupTable(wat);
5422 meshMapper = (vtkDataSetMapper *) (MeshActor->getMapper());
5423 meshMapper->SetScalarModeToUseCellData();
5424 MeshActor->DataSource->GetCellData()->SetScalars(scalars);
5425 meshMapper->SetScalarRange(range);
5426 meshMapper->ScalarVisibilityOn();
5428 vtkScalarBarActor *aScalarBar = GetScalarBar();
5429 if (aScalarBar == NULL)
5431 aScalarBar = vtkScalarBarActor::New();
5432 QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
5433 QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
5434 QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
5435 QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
5436 QString Orientation =
5437 QAD_CONFIG->getSetting("ScalarBar:Orientation");
5438 float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
5439 float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
5440 int NumberOfLabels =
5441 QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
5442 int NumberOfColors =
5443 QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
5445 SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow, FontFamily,
5446 Orientation, Width, Height, NumberOfColors, NumberOfLabels);
5447 vtkRenderer *theRenderer =
5448 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5449 getRightFrame()->getViewFrame())->getRenderer();
5450 theRenderer->AddActor2D(aScalarBar);
5452 aScalarBar->SetLookupTable(wat);
5453 aScalarBar->SetTitle(type.latin1());
5457 DisplayScalarBar(true);
5459 QApplication::restoreOverrideCursor();
5462 //=============================================================================
5466 //=============================================================================
5467 void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar,
5468 QString Bold, QString Italic,
5469 QString Shadow, QString FontFamily,
5470 QString Orientation, float Width, float Height, int NbColors, int NbLabels)
5472 if (Bold.isNull() || Bold.isEmpty() || (Bold.compare("true") == 0))
5473 theScalarBar->BoldOn();
5475 theScalarBar->BoldOff();
5477 if (Italic.isNull() || Italic.isEmpty() || (Italic.compare("true") == 0))
5478 theScalarBar->ItalicOn();
5480 theScalarBar->ItalicOff();
5482 if (Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare("true") == 0))
5483 theScalarBar->ShadowOn();
5485 theScalarBar->ShadowOff();
5487 if (FontFamily.compare("Arial") == 0)
5488 theScalarBar->SetFontFamilyToArial();
5489 else if (FontFamily.compare("Courier") == 0)
5490 theScalarBar->SetFontFamilyToCourier();
5491 else if (FontFamily.compare("Times") == 0)
5492 theScalarBar->SetFontFamilyToTimes();
5494 theScalarBar->SetFontFamilyToArial();
5496 if (Orientation.isNull() || Orientation.isEmpty() ||
5497 (Orientation.compare("Vertical") == 0))
5498 theScalarBar->SetOrientationToVertical();
5500 theScalarBar->SetOrientationToHorizontal();
5502 theScalarBar->SetWidth((Width == 0) ? 0.17 : Width);
5503 theScalarBar->SetHeight((Height == 0) ? 0.8 : Height);
5505 theScalarBar->SetNumberOfLabels((NbLabels == 0) ? 5 : NbLabels);
5506 theScalarBar->SetMaximumNumberOfColors((NbColors == 0) ? 64 : NbColors);
5509 //=============================================================================
5513 //=============================================================================
5514 void SMESHGUI::DisplayScalarBar(bool visibility)
5516 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
5519 vtkRenderer *theRenderer =
5520 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5521 getRightFrame()->getViewFrame())->getRenderer();
5522 vtkScalarBarActor *aScalarBar = GetScalarBar();
5524 if (aScalarBar == NULL)
5526 MESSAGE("myScalarBar is NULL");
5531 aScalarBar->VisibilityOn();
5534 aScalarBar->VisibilityOff();
5535 //Turn off mesh coloring (influences on all views)
5536 vtkActorCollection *actorList = theRenderer->GetActors();
5537 actorList->InitTraversal();
5538 vtkActor *ac = actorList->GetNextActor();
5541 if (ac->GetMapper() != NULL)
5543 ac->GetMapper()->ScalarVisibilityOff();
5545 ac = actorList->GetNextActor();
5547 // Turn off ScalarBar in all views
5548 /*QList<QAD_StudyFrame> aFrames = myActiveStudy->getStudyFrames();
5549 * for ( QAD_StudyFrame* aFrame = aFrames.first(); aFrame; aFrame = aFrames.next() ) {
5550 * if (aFrame->getTypeView() == VIEW_VTK) {
5551 * vtkRenderer *aRenderer = ((VTKViewer_ViewFrame*) aFrame->getRightFrame()->getViewFrame())->getRenderer();
5552 * vtkActor2DCollection* actor2DList = aRenderer->GetActors2D();
5553 * actor2DList->InitTraversal();
5554 * vtkActor2D* aActor2d = actor2DList->GetNextActor2D();
5555 * while (aActor2d != NULL) {
5556 * if (aActor2d->IsA("vtkScalarBarActor")) {
5557 * aActor2d->VisibilityOff();
5560 * actor2DList->GetNextActor2D();
5565 myActiveStudy->update3dViewers();
5568 //=============================================================================
5572 //=============================================================================
5573 void SMESHGUI::UpdateScalarBar(float MinRange, float MaxRange)
5575 vtkScalarBarActor *aScalarBar = GetScalarBar();
5576 if (aScalarBar == NULL)
5578 MESSAGE("myScalarBar is NULL");
5581 DisplayScalarBar(false);
5583 aScalarBar->GetLookupTable()->SetRange(MinRange, MaxRange);
5584 vtkRenderer *aRenderer =
5585 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5586 getRightFrame()->getViewFrame())->getRenderer();
5587 vtkActorCollection *aActorList = aRenderer->GetActors();
5588 aActorList->InitTraversal();
5589 vtkActor *aActor = aActorList->GetNextActor();
5590 while (aActor != NULL)
5592 if (aActor->IsA("SMESH_Actor"))
5594 SMESH_Actor *aMeshActor = SMESH_Actor::SafeDownCast(aActor);
5595 vtkDataSetMapper *aMeshMapper =
5596 (vtkDataSetMapper *) (aMeshActor->getMapper());
5597 if ((aMeshMapper != NULL))
5599 aMeshMapper->SetScalarRange(MinRange, MaxRange);
5600 aMeshMapper->ScalarVisibilityOn();
5603 aActor = aActorList->GetNextActor();
5605 DisplayScalarBar(true);
5608 //=============================================================================
5612 //=============================================================================
5613 void SMESHGUI::SetDisplaySettings()
5615 EmitSignalDeactivateDialog();
5616 SMESHGUI_Preferences_ColorDlg *aDlg =
5617 new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
5619 QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
5620 QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
5621 QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
5622 QColor color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
5623 aDlg->SetColor(1, color);
5625 SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
5626 SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
5627 SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
5628 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
5629 aDlg->SetColor(2, color);
5631 SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
5632 SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
5633 SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
5634 color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
5635 aDlg->SetColor(3, color);
5637 QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
5638 QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
5639 QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
5640 color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
5641 aDlg->SetColor(4, color);
5643 QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
5644 aDlg->SetIntValue(1, intValue.toInt());
5645 intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
5646 aDlg->SetIntValue(2, intValue.toInt());
5647 intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
5648 aDlg->SetIntValue(3, intValue.toInt());
5652 QColor colorFill = aDlg->GetColor(1);
5653 QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
5654 QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen",
5656 QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
5658 QColor colorOutline = aDlg->GetColor(2);
5659 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed",
5660 colorOutline.red());
5661 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen",
5662 colorOutline.green());
5663 QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue",
5664 colorOutline.blue());
5666 QColor colorNode = aDlg->GetColor(3);
5667 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
5668 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen",
5670 QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
5672 QColor colorBackFace = aDlg->GetColor(4);
5673 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed",
5674 colorBackFace.red());
5675 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen",
5676 colorBackFace.green());
5677 QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue",
5678 colorBackFace.blue());
5680 int width = aDlg->GetIntValue(1);
5681 QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
5683 int nodes_size = aDlg->GetIntValue(2);
5684 QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
5686 int shrink_coeff = aDlg->GetIntValue(3);
5687 QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
5693 //=======================================================================
5694 // function : Parameter()
5695 // purpose : return a parameter (double) from a dialog box
5697 // aValue : is a double used as a default value displayed
5698 // aLabel : is the title for aValue1
5699 // aTitle : is the main title
5700 // bottom : maximum value to be entered
5701 // top : minimum value to be entered
5702 // decimals : number of decimals
5703 //=======================================================================
5704 double SMESHGUI::Parameter(Standard_Boolean & res,
5705 const double aValue,
5708 const double bottom, const double top, const int decimals)
5710 SMESHGUI_aParameterDlg *Dialog =
5711 new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(),
5714 bottom, top, decimals,
5716 Dialog->setValue(aValue);
5718 res = (Dialog->exec() == QDialog::Accepted);
5720 X = Dialog->getDblValue();
5724 //=======================================================================
5725 // function : Parameter()
5726 // purpose : return a parameter (int) from a dialog box
5728 // aValue : is a int used as a default value displayed
5729 // aLabel : is the title for aValue1
5730 // aTitle : is the main title
5731 // bottom : maximum value to be entered
5732 // top : minimum value to be entered
5733 //=======================================================================
5734 int SMESHGUI::Parameter(Standard_Boolean & res,
5736 const char *aLabel, const char *aTitle, const int bottom, const int top)
5738 SMESHGUI_aParameterDlg *Dialog =
5739 new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(),
5744 Dialog->setValue(aValue);
5746 res = (Dialog->exec() == QDialog::Accepted);
5748 X = Dialog->getIntValue();
5752 //=============================================================================
5756 //=============================================================================
5757 void SMESHGUI::DisplayEdges(SMESH_Actor * ac, bool visibility)
5759 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
5761 if (ac->DataSource == NULL || ac->GetMapper() == NULL)
5764 vtkGeometryFilter *gf = vtkGeometryFilter::New();
5765 gf->SetInput(ac->DataSource);
5766 vtkFeatureEdges *edges = vtkFeatureEdges::New();
5767 edges->SetInput(gf->GetOutput());
5768 edges->BoundaryEdgesOn();
5769 edges->ManifoldEdgesOn();
5771 vtkPolyDataMapper *edgeMapper = vtkPolyDataMapper::New();
5772 edgeMapper->SetInput(edges->GetOutput());
5773 edgeMapper->ScalarVisibilityOff();
5775 vtkRenderer *theRenderer =
5776 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5777 getRightFrame()->getViewFrame())->getRenderer();
5778 vtkActorCollection *actorList = theRenderer->GetActors();
5780 int test = actorList->IsItemPresent(ac->EdgeDevice);
5783 vtkProperty *prop = vtkProperty::New();
5784 prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").
5786 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
5788 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
5790 prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
5792 prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
5794 ac->EdgeDevice->SetProperty(prop);
5795 ac->SetEdgeColor(QAD_CONFIG->
5796 getSetting("SMESH:SettingsOutlineColorRed").toFloat() / 255.,
5797 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
5799 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
5801 ac->EdgeDevice->SetMapper(edgeMapper);
5803 theRenderer->AddActor(ac->EdgeDevice);
5807 ac->EdgeDevice->SetMapper(edgeMapper);
5808 edgeMapper->Update();
5811 vtkShrinkFilter *shrink = vtkShrinkFilter::New();
5812 shrink->SetInput(ac->DataSource);
5813 shrink->SetShrinkFactor(ac->GetShrinkFactor());
5814 vtkGeometryFilter *Shrinkgf = vtkGeometryFilter::New();
5815 Shrinkgf->SetInput(shrink->GetOutput());
5816 vtkFeatureEdges *ShrinkEdges = vtkFeatureEdges::New();
5817 ShrinkEdges->SetInput(Shrinkgf->GetOutput());
5818 ShrinkEdges->BoundaryEdgesOn();
5819 ShrinkEdges->ManifoldEdgesOn();
5821 vtkPolyDataMapper *ShrinkEdgeMapper = vtkPolyDataMapper::New();
5822 ShrinkEdgeMapper->SetInput(ShrinkEdges->GetOutput());
5823 ShrinkEdgeMapper->ScalarVisibilityOff();
5825 test = actorList->IsItemPresent(ac->EdgeShrinkDevice);
5828 vtkProperty *prop = vtkProperty::New();
5829 prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").
5831 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
5833 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
5835 prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
5837 prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
5839 ac->EdgeShrinkDevice->SetProperty(prop);
5840 ac->SetEdgeColor(QAD_CONFIG->
5841 getSetting("SMESH:SettingsOutlineColorRed").toFloat() / 255.,
5842 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
5844 QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
5846 ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper);
5848 theRenderer->AddActor(ac->EdgeShrinkDevice);
5852 ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper);
5853 ShrinkEdgeMapper->Update();
5856 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
5860 //=============================================================================
5864 //=============================================================================
5865 void SMESHGUI::InitActor(SMESH::SMESH_Mesh_ptr aMesh)
5867 SALOMEDS::SObject_var aSO_M = myStudyAPI.FindMesh(aMesh);
5868 SALOMEDS::GenericAttribute_var anAttr;
5869 SALOMEDS::AttributeName_var aName;
5870 if (!aSO_M->_is_nil())
5872 if (aSO_M->FindAttribute(anAttr, "AttributeName"))
5874 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5875 Standard_Boolean result;
5876 SMESH_Actor *MeshActor =
5877 smeshGUI->FindActorByEntry(aSO_M->GetID(), result, true);
5880 SMESH_Actor *amesh = SMESH_Actor::New();
5881 Handle(SALOME_InteractiveObject) IO =
5882 new SALOME_InteractiveObject(aSO_M->GetID(), "MESH",
5885 amesh->setName(aName->Value());
5886 DisplayActor(amesh, false);
5892 //=============================================================================
5896 //=============================================================================
5897 void SMESHGUI::Update()
5899 MESSAGE("SMESHGUI::Update");
5900 if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
5902 vtkRenderer *theRenderer =
5903 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
5904 getRightFrame()->getViewFrame())->getRenderer();
5906 SALOME_Selection *Sel =
5907 SALOME_Selection::Selection(myActiveStudy->getSelection());
5908 int nbSel = Sel->IObjectCount();
5911 vtkActorCollection *actorList = theRenderer->GetActors();
5912 actorList->InitTraversal();
5913 vtkActor *ac = actorList->GetNextActor();
5914 while (!(ac == NULL))
5916 if (ac->IsA("SMESH_Actor"))
5918 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
5919 if (anActor->hasIO())
5921 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
5925 ac = actorList->GetNextActor();
5930 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
5931 for (; It.More(); It.Next())
5933 Handle(SALOME_InteractiveObject) IO = It.Value();
5937 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
5940 QApplication::restoreOverrideCursor();
5943 //=============================================================================
5947 //=============================================================================
5948 void SMESHGUI::Update(const Handle(SALOME_InteractiveObject) & IO)
5950 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
5955 Standard_Boolean res;
5956 SMESH::SMESH_Mesh_var aMesh = ConvertIOinMesh(IO, res);
5959 SMESH_Actor *ac = FindActorByEntry(IO->getEntry(), res, false);
5962 // Check whether the actor belongs to the active view
5963 VTKViewer_RenderWindowInteractor *rwInter =
5964 ((VTKViewer_ViewFrame *) myActiveStudy->
5965 getActiveStudyFrame()->getRightFrame()->getViewFrame())->
5968 ac = ReadScript(aMesh);
5969 // The actor belongs to inactive view -> create a copy and display it in the active view
5970 if (!rwInter->isInViewer(IO))
5972 SMESH_Actor *acCopy = SMESH_Actor::New();
5973 acCopy->ShallowCopy(ac);
5984 smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
5991 //=============================================================================
5995 //=============================================================================
5996 vtkActor *SMESHGUI::SimulationMoveNode(SMESH_Actor * Mactor, int idnode)
5998 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6001 mySimulationActors = vtkActorCollection::New();
6002 vtkRenderer *theRenderer =
6003 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6004 getRightFrame()->getViewFrame())->getRenderer();
6006 vtkUnstructuredGrid *ugrid =
6007 vtkUnstructuredGrid::SafeDownCast(Mactor->DataSource);
6008 vtkIdList *IdCells = vtkIdList::New();
6009 ugrid->GetPointCells(idnode, IdCells);
6011 vtkPoints *Pts = vtkPoints::New();
6012 Pts = ugrid->GetPoints();
6014 vtkUnstructuredGrid *ugridSimulation = vtkUnstructuredGrid::New();
6015 ugridSimulation->SetPoints(Pts);
6016 vtkIdList *IdPts = vtkIdList::New();
6017 for (int j = 0; j < IdCells->GetNumberOfIds(); j++)
6019 ugrid->GetCellPoints(IdCells->GetId(j), IdPts);
6020 ugridSimulation->InsertNextCell(ugrid->GetCellType(IdCells->GetId(j)),
6024 vtkProperty *prop = vtkProperty::New();
6025 prop->SetColor(1., 0., 0.);
6026 prop->SetRepresentationToWireframe();
6028 int Edgewidth = (int)Mactor->EdgeDevice->GetProperty()->GetLineWidth();
6031 prop->SetLineWidth(Edgewidth + 1);
6033 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6034 Mapper->SetInput(ugridSimulation);
6035 vtkActor *ac = vtkActor::New();
6036 ac->SetMapper(Mapper);
6037 ac->SetProperty(prop);
6039 ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer();
6040 ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02);
6042 mySimulationActors->AddItem(ac);
6043 theRenderer->AddActor(ac);
6045 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6051 //=============================================================================
6055 //=============================================================================
6056 void SMESHGUI::DisplaySimulationNode(SMESH::SMESH_Mesh_ptr aMesh, float x,
6059 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6062 EraseSimulationActors();
6063 mySimulationActors = vtkActorCollection::New();
6064 vtkRenderer *theRenderer =
6065 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6066 getRightFrame()->getViewFrame())->getRenderer();
6067 Standard_Boolean result;
6068 SMESH_Actor *ac = FindActor(aMesh, result, true);
6072 vtkUnstructuredGrid *ugrid =
6073 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6074 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6076 vtkPoints *Pts = ugrid->GetPoints();
6077 vtkPoints *newPts = vtkPoints::New();
6078 int nbPts = Pts->GetNumberOfPoints();
6079 for (int i = 0; i < nbPts; i++)
6081 newPts->InsertPoint(i, Pts->GetPoint(i));
6084 newugrid->SetPoints(newPts);
6085 newugrid->GetPoints()->InsertNextPoint(x, y, z);
6087 vtkMaskPoints *verts = vtkMaskPoints::New();
6088 verts->SetInput(newugrid);
6089 verts->SetGenerateVertices(1);
6090 verts->SetOnRatio(1);
6092 vtkPolyDataMapper *vertMapper = vtkPolyDataMapper::New();
6093 vertMapper->SetInput(verts->GetOutput());
6094 vertMapper->ScalarVisibilityOff();
6096 vtkActor *node = vtkActor::New();
6097 node->SetMapper(vertMapper);
6099 QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
6100 QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
6101 QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
6102 QColor nodecolor(SCr.toInt(), SCg.toInt(), SCb.toInt());
6103 if (!nodecolor.isValid())
6104 // nodecolor = QColor(0.,1.,0.);
6105 nodecolor = QColor(0, 1, 0);
6107 node->GetProperty()->SetColor(float (nodecolor.red()) / 255.,
6108 float (nodecolor.green()) / 255., float (nodecolor.blue()) / 255.);
6111 QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt();
6115 node->GetProperty()->SetPointSize(intValue);
6117 node->VisibilityOn();
6119 mySimulationActors->AddItem(node);
6120 theRenderer->AddActor(node);
6123 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6127 //=============================================================================
6131 //=============================================================================
6132 void SMESHGUI::DisplaySimulationMoveNode(vtkActor * ac, int idnode, float x,
6135 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6138 vtkRenderer *theRenderer =
6139 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6140 getRightFrame()->getViewFrame())->getRenderer();
6141 float *pt = ac->GetMapper()->GetInput()->GetPoint(idnode);
6146 ac->GetMapper()->ImmediateModeRenderingOn();
6147 ac->GetProperty()->SetRepresentationToWireframe();
6149 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6154 //=============================================================================
6158 //=============================================================================
6159 void SMESHGUI::MoveNode(SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x,
6162 Standard_Boolean result;
6164 SMESH_Actor *MeshActor = FindActor(aMesh, result, true);
6170 //=============================================================================
6174 //=============================================================================
6175 void SMESHGUI::ScalarVisibilityOff()
6177 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6180 vtkRenderer *theRenderer =
6181 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6182 getRightFrame()->getViewFrame())->getRenderer();
6183 vtkActorCollection *actorList = theRenderer->GetActors();
6185 actorList->InitTraversal();
6186 vtkActor *ac = actorList->GetNextActor();
6187 while (!(ac == NULL))
6189 if (ac->IsA("SMESH_Actor"))
6191 SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
6192 if (anActor->GetVisibility() == 1)
6194 vtkDataSetMapper *meshMapper =
6195 (vtkDataSetMapper *) (anActor->getMapper());
6196 meshMapper->ScalarVisibilityOff();
6197 meshMapper->SetInput(anActor->DataSource);
6198 ChangeRepresentation(anActor, anActor->getDisplayMode());
6201 ac = actorList->GetNextActor();
6204 theRenderer->Render();
6207 //=============================================================================
6211 //=============================================================================
6212 void SMESHGUI::DisplaySimulationEdge(SMESH::SMESH_Mesh_ptr aMesh,
6213 const TColStd_MapOfInteger & MapIndex)
6215 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6218 EraseSimulationActors();
6219 mySimulationActors = vtkActorCollection::New();
6220 vtkRenderer *theRenderer =
6221 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6222 getRightFrame()->getViewFrame())->getRenderer();
6223 Standard_Boolean result;
6224 SMESH_Actor *ac = FindActor(aMesh, result, true);
6227 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6231 vtkIdList *Ids = vtkIdList::New();
6232 for (; ite.More(); ite.Next())
6234 idNodes[i] = ite.Key();
6238 Ids->InsertId(0, idNodes[0]);
6239 pts[0] = idNodes[0];
6240 Ids->InsertId(1, idNodes[1]);
6241 pts[1] = idNodes[1];
6243 vtkUnstructuredGrid *ugrid =
6244 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6245 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6246 newugrid->SetPoints(ugrid->GetPoints());
6247 newugrid->InsertNextCell(VTK_LINE, 2, pts);
6249 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6250 Mapper->SetInput(newugrid);
6253 vtkActor *edge = vtkActor::New();
6254 edge->SetMapper(Mapper);
6255 edge->SetProperty(ac->GetProperty());
6256 edge->SetBackfaceProperty(ac->GetBackfaceProperty());
6257 edge->VisibilityOn();
6258 mySimulationActors->AddItem(edge);
6259 theRenderer->AddActor(edge);
6262 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6266 //=============================================================================
6270 //=============================================================================
6271 void SMESHGUI::DisplaySimulationTriangle(SMESH::SMESH_Mesh_ptr aMesh,
6272 const TColStd_MapOfInteger & MapIndex, bool reverse)
6274 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6277 EraseSimulationActors();
6278 mySimulationActors = vtkActorCollection::New();
6279 vtkRenderer *theRenderer =
6280 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6281 getRightFrame()->getViewFrame())->getRenderer();
6282 Standard_Boolean result;
6283 SMESH_Actor *ac = FindActor(aMesh, result, true);
6286 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6290 vtkIdList *Ids = vtkIdList::New();
6291 for (; ite.More(); ite.Next())
6293 idNodes[i] = ite.Key();
6299 Ids->InsertId(0, idNodes[2]);
6300 pts[0] = idNodes[2];
6301 Ids->InsertId(1, idNodes[1]);
6302 pts[1] = idNodes[1];
6303 Ids->InsertId(2, idNodes[0]);
6304 pts[2] = idNodes[0];
6308 Ids->InsertId(0, idNodes[0]);
6309 pts[0] = idNodes[0];
6310 Ids->InsertId(1, idNodes[1]);
6311 pts[1] = idNodes[1];
6312 Ids->InsertId(2, idNodes[2]);
6313 pts[2] = idNodes[2];
6315 vtkUnstructuredGrid *ugrid =
6316 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6317 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6318 newugrid->SetPoints(ugrid->GetPoints());
6319 newugrid->InsertNextCell(VTK_TRIANGLE, 3, pts);
6321 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6322 Mapper->SetInput(newugrid);
6325 vtkActor *tri = vtkActor::New();
6326 tri->SetMapper(Mapper);
6327 tri->SetProperty(ac->GetProperty());
6328 tri->SetBackfaceProperty(ac->GetBackfaceProperty());
6329 tri->VisibilityOn();
6330 mySimulationActors->AddItem(tri);
6331 theRenderer->AddActor(tri);
6334 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6338 //=============================================================================
6342 //=============================================================================
6343 void SMESHGUI::DisplaySimulationQuadrangle(SMESH::SMESH_Mesh_ptr aMesh,
6344 const TColStd_MapOfInteger & MapIndex, bool reverse)
6346 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6349 EraseSimulationActors();
6350 mySimulationActors = vtkActorCollection::New();
6351 vtkRenderer *theRenderer =
6352 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6353 getRightFrame()->getViewFrame())->getRenderer();
6354 Standard_Boolean result;
6355 SMESH_Actor *ac = FindActor(aMesh, result, true);
6357 vtkUnstructuredGrid *ugrid =
6358 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6362 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6365 vtkIdList *Ids = vtkIdList::New();
6366 for (; ite.More(); ite.Next())
6368 idNodes[i] = ite.Key();
6372 float *p0 = ugrid->GetPoint(idNodes[0]);
6373 float *p1 = ugrid->GetPoint(idNodes[1]);
6374 float *p2 = ugrid->GetPoint(idNodes[2]);
6375 float *p3 = ugrid->GetPoint(idNodes[3]);
6377 gp_Pnt P0(p0[0], p0[1], p0[2]);
6379 gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2]));
6380 gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2]));
6381 gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2]));
6383 gp_Vec Cross1 = V1 ^ V2;
6384 gp_Vec Cross2 = V2 ^ V3;
6387 if (Cross1.Dot(Cross2) < 0)
6389 V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2]));
6390 V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2]));
6394 if (Cross1.Dot(Cross2) < 0)
6397 idNodes[2] = idNodes[3];
6403 idNodes[1] = idNodes[2];
6410 Ids->InsertId(0, idNodes[3]);
6411 Ids->InsertId(1, idNodes[2]);
6412 Ids->InsertId(2, idNodes[1]);
6413 Ids->InsertId(3, idNodes[0]);
6417 Ids->InsertId(0, idNodes[0]);
6418 Ids->InsertId(1, idNodes[1]);
6419 Ids->InsertId(2, idNodes[2]);
6420 Ids->InsertId(3, idNodes[3]);
6423 // vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource );
6424 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6425 newugrid->SetPoints(ugrid->GetPoints());
6426 newugrid->InsertNextCell(VTK_QUAD, Ids);
6428 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6429 Mapper->SetInput(newugrid);
6432 vtkActor *quad = vtkActor::New();
6433 quad->SetMapper(Mapper);
6434 quad->SetProperty(ac->GetProperty());
6435 quad->SetBackfaceProperty(ac->GetBackfaceProperty());
6436 quad->VisibilityOn();
6437 mySimulationActors->AddItem(quad);
6438 theRenderer->AddActor(quad);
6440 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6444 //=============================================================================
6448 //=============================================================================
6449 void SMESHGUI::DisplaySimulationTetra(SMESH::SMESH_Mesh_ptr aMesh,
6450 const TColStd_MapOfInteger & MapIndex)
6452 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6455 EraseSimulationActors();
6456 mySimulationActors = vtkActorCollection::New();
6457 vtkRenderer *theRenderer =
6458 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6459 getRightFrame()->getViewFrame())->getRenderer();
6460 Standard_Boolean result;
6461 SMESH_Actor *ac = FindActor(aMesh, result, true);
6464 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6467 vtkIdList *Ids = vtkIdList::New();
6468 for (; ite.More(); ite.Next())
6470 idNodes[i] = ite.Key();
6474 Ids->InsertId(0, idNodes[0]);
6475 Ids->InsertId(1, idNodes[1]);
6476 Ids->InsertId(2, idNodes[2]);
6477 Ids->InsertId(3, idNodes[3]);
6479 vtkUnstructuredGrid *ugrid =
6480 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6481 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6482 newugrid->SetPoints(ugrid->GetPoints());
6483 newugrid->InsertNextCell(VTK_TETRA, Ids);
6485 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6486 Mapper->SetInput(newugrid);
6489 vtkActor *tetra = vtkActor::New();
6490 tetra->SetMapper(Mapper);
6491 tetra->SetProperty(ac->GetProperty());
6492 tetra->SetBackfaceProperty(ac->GetBackfaceProperty());
6493 tetra->VisibilityOn();
6494 mySimulationActors->AddItem(tetra);
6495 theRenderer->AddActor(tetra);
6497 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6501 //=============================================================================
6505 //=============================================================================
6506 void SMESHGUI::DisplaySimulationHexa(SMESH::SMESH_Mesh_ptr aMesh,
6507 const TColStd_MapOfInteger & MapIndex)
6509 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6512 EraseSimulationActors();
6513 mySimulationActors = vtkActorCollection::New();
6514 vtkRenderer *theRenderer =
6515 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6516 getRightFrame()->getViewFrame())->getRenderer();
6517 Standard_Boolean result;
6518 SMESH_Actor *ac = FindActor(aMesh, result, true);
6521 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6524 vtkIdList *Ids = vtkIdList::New();
6525 for (; ite.More(); ite.Next())
6527 idNodes[i] = ite.Key();
6531 Ids->InsertId(0, idNodes[0]);
6532 Ids->InsertId(1, idNodes[1]);
6533 Ids->InsertId(2, idNodes[2]);
6534 Ids->InsertId(3, idNodes[3]);
6535 Ids->InsertId(4, idNodes[4]);
6536 Ids->InsertId(5, idNodes[5]);
6537 Ids->InsertId(6, idNodes[6]);
6538 Ids->InsertId(7, idNodes[7]);
6540 vtkUnstructuredGrid *ugrid =
6541 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6542 vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
6543 newugrid->SetPoints(ugrid->GetPoints());
6544 newugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
6546 vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
6547 Mapper->SetInput(newugrid);
6550 vtkActor *hexa = vtkActor::New();
6551 hexa->SetMapper(Mapper);
6552 hexa->SetProperty(ac->GetProperty());
6553 hexa->SetBackfaceProperty(ac->GetBackfaceProperty());
6554 hexa->VisibilityOn();
6555 mySimulationActors->AddItem(hexa);
6556 theRenderer->AddActor(hexa);
6558 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6562 //=============================================================================
6566 //=============================================================================
6567 void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr aMesh,
6568 const TColStd_MapOfInteger & MapIndex, bool reverse)
6570 QApplication::setOverrideCursor(Qt::waitCursor);
6571 Standard_Boolean result;
6572 SMESH_Actor *ac = FindActor(aMesh, result, true);
6575 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6576 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
6577 anArrayOfIdeces->length(MapIndex.Extent());
6580 for (; ite.More(); ite.Next())
6582 anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
6587 if (MapIndex.Extent() == 4)
6591 TColStd_MapIteratorOfMapOfInteger ite1(MapIndex);
6592 for (; ite1.More(); ite1.Next())
6594 idNodes[i] = ite1.Key();
6598 vtkUnstructuredGrid *ugrid =
6599 vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
6600 float *p0 = ugrid->GetPoint(idNodes[0]);
6601 float *p1 = ugrid->GetPoint(idNodes[1]);
6602 float *p2 = ugrid->GetPoint(idNodes[2]);
6603 float *p3 = ugrid->GetPoint(idNodes[3]);
6605 gp_Pnt P0(p0[0], p0[1], p0[2]);
6607 gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2]));
6608 gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2]));
6609 gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2]));
6611 gp_Vec Cross1 = V1 ^ V2;
6612 gp_Vec Cross2 = V2 ^ V3;
6614 if (Cross1.Dot(Cross2) < 0)
6617 V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2]));
6618 V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2]));
6622 if (Cross1.Dot(Cross2) < 0)
6624 tmp = anArrayOfIdeces[2];
6625 anArrayOfIdeces[2] = anArrayOfIdeces[3];
6626 anArrayOfIdeces[3] = tmp;
6630 tmp = anArrayOfIdeces[1];
6631 anArrayOfIdeces[1] = anArrayOfIdeces[2];
6632 anArrayOfIdeces[2] = tmp;
6640 for (i = 0; i < (MapIndex.Extent() / 2); i++)
6642 tmp = anArrayOfIdeces[i];
6643 anArrayOfIdeces[i] = anArrayOfIdeces[MapIndex.Extent() - i - 1];
6644 anArrayOfIdeces[MapIndex.Extent() - i - 1] = tmp;
6647 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
6648 aMeshEditor->AddFace(anArrayOfIdeces);
6650 if (myAutomaticUpdate)
6652 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
6655 smeshGUI->DisplayActor(Mesh);
6656 smeshGUI->DisplayEdges(Mesh);
6657 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
6658 AddActorInSelection(Mesh);
6661 QApplication::restoreOverrideCursor();
6664 //=============================================================================
6668 //=============================================================================
6669 void SMESHGUI::AddVolume(SMESH::SMESH_Mesh_ptr aMesh,
6670 const TColStd_MapOfInteger & MapIndex)
6672 QApplication::setOverrideCursor(Qt::waitCursor);
6673 Standard_Boolean result;
6674 SMESH_Actor *ac = FindActor(aMesh, result, true);
6677 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6678 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
6679 anArrayOfIdeces->length(MapIndex.Extent());
6682 for (; ite.More(); ite.Next())
6684 anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
6688 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
6689 aMeshEditor->AddVolume(anArrayOfIdeces);
6691 if (myAutomaticUpdate)
6693 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
6696 smeshGUI->DisplayActor(Mesh);
6697 smeshGUI->DisplayEdges(Mesh);
6698 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
6699 AddActorInSelection(Mesh);
6702 QApplication::restoreOverrideCursor();
6705 //=============================================================================
6709 //=============================================================================
6710 void SMESHGUI::AddEdge(SMESH::SMESH_Mesh_ptr aMesh,
6711 const TColStd_MapOfInteger & MapIndex)
6713 QApplication::setOverrideCursor(Qt::waitCursor);
6714 Standard_Boolean result;
6715 SMESH_Actor *ac = FindActor(aMesh, result, true);
6718 TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
6719 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
6720 anArrayOfIdeces->length(MapIndex.Extent());
6723 for (; ite.More(); ite.Next())
6725 anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
6729 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
6730 aMeshEditor->AddEdge(anArrayOfIdeces);
6732 if (myAutomaticUpdate)
6734 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
6737 smeshGUI->DisplayActor(Mesh);
6738 smeshGUI->DisplayEdges(Mesh);
6739 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
6740 AddActorInSelection(Mesh);
6743 QApplication::restoreOverrideCursor();
6746 //=============================================================================
6750 //=============================================================================
6751 void SMESHGUI::AddNode(SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z)
6753 QApplication::setOverrideCursor(Qt::waitCursor);
6754 Standard_Boolean result;
6755 SMESH_Actor *ac = FindActor(aMesh, result, true);
6758 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
6759 aMeshEditor->AddNode(x, y, z);
6761 if (myAutomaticUpdate)
6763 SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
6766 smeshGUI->DisplayActor(Mesh);
6767 smeshGUI->DisplayEdges(Mesh);
6768 smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
6769 AddActorInSelection(Mesh);
6773 QApplication::restoreOverrideCursor();
6776 //=============================================================================
6780 //=============================================================================
6781 void SMESHGUI::DisplayEdgesConnectivityLegendBox(vtkActor * ac)
6783 if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
6786 EraseSimulationActors();
6787 mySimulationActors2D = vtkActor2DCollection::New();
6789 vtkRenderer *theRenderer =
6790 ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
6791 getRightFrame()->getViewFrame())->getRenderer();
6793 vtkGlyphSource2D *gs2 = vtkGlyphSource2D::New();
6794 gs2->SetGlyphTypeToTriangle();
6797 vtkLegendBoxActor *legend = vtkLegendBoxActor::New();
6798 legend->GetPositionCoordinate()->SetValue(0.025, 0.025, 0.);
6799 legend->GetPosition2Coordinate()->SetValue(0.3, 0.3, 0.); //relative to Position
6801 legend->SetNumberOfEntries(4);
6802 legend->SetEntryString(0, tr("SMESH_BOUNDARYEDGES"));
6803 legend->SetEntrySymbol(0, gs2->GetOutput());
6804 legend->SetEntryColor(0, ac->GetMapper()->GetLookupTable()->GetColor(0.));
6805 legend->SetEntryString(1, tr("SMESH_MANIFOLDEDGES"));
6806 legend->SetEntrySymbol(1, gs2->GetOutput());
6807 legend->SetEntryColor(1,
6808 ac->GetMapper()->GetLookupTable()->GetColor(0.666667));
6809 legend->SetEntryString(2, tr("SMESH_NONMANIFOLDEDGES"));
6810 legend->SetEntrySymbol(2, gs2->GetOutput());
6811 legend->SetEntryColor(2,
6812 ac->GetMapper()->GetLookupTable()->GetColor(0.222222));
6813 legend->SetEntryString(3, tr("SMESH_FEATUREEDGES"));
6814 legend->SetEntrySymbol(3, gs2->GetOutput());
6815 legend->SetEntryColor(3,
6816 ac->GetMapper()->GetLookupTable()->GetColor(0.444444));
6817 legend->SetPadding(5);
6818 // legend->GetProperty()->SetColor();
6820 mySimulationActors2D->AddItem(legend);
6821 theRenderer->AddActor2D(legend);
6824 myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->
6828 //===============================================================================
6829 // function : OnEditDelete()
6831 //===============================================================================
6832 void SMESHGUI::OnEditDelete()
6834 if (QAD_MessageBox::warn2
6835 (QAD_Application::getDesktop(),
6836 tr("SMESH_WRN_WARNING"),
6837 tr("SMESH_REALLY_DELETE"),
6838 tr("SMESH_BUT_YES"), tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
6841 int nbSf = myActiveStudy->getStudyFramesCount();
6843 Standard_Boolean found;
6844 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6845 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
6846 SALOMEDS::GenericAttribute_var anAttr;
6847 SALOMEDS::AttributeIOR_var anIOR;
6849 SALOME_Selection *Sel =
6850 SALOME_Selection::Selection(myActiveStudy->getSelection());
6851 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
6852 for (; It.More(); It.Next())
6854 Handle(SALOME_InteractiveObject) IObject = It.Value();
6855 if (IObject->hasEntry())
6857 SALOMEDS::SObject_var SO =
6858 myStudy->FindObjectID(IObject->getEntry());
6860 /* Erase child graphical objects */
6861 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
6862 for (; it->More(); it->Next())
6864 SALOMEDS::SObject_var CSO = it->Value();
6865 if (CSO->FindAttribute(anAttr, "AttributeIOR"))
6867 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6869 for (int i = 0; i < nbSf; i++)
6871 QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
6872 if (sf->getTypeView() == VIEW_VTK)
6874 vtkRenderer *Renderer =
6875 ((VTKViewer_ViewFrame *) smeshGUI->
6876 myActiveStudy->getActiveStudyFrame()->
6877 getRightFrame()->getViewFrame())->getRenderer();
6879 smeshGUI->FindActorByEntry(CSO->GetID(), found,
6883 Renderer->RemoveActor(ac->EdgeDevice);
6884 Renderer->RemoveActor(ac->EdgeShrinkDevice);
6885 Renderer->RemoveActor(ac);
6892 /* Erase main graphical object */
6893 for (int i = 0; i < nbSf; i++)
6895 QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
6896 if (sf->getTypeView() == VIEW_VTK)
6898 vtkRenderer *Renderer =
6899 ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
6900 getActiveStudyFrame()->getRightFrame()->
6901 getViewFrame())->getRenderer();
6902 VTKViewer_RenderWindowInteractor *myRenderInter =
6903 ((VTKViewer_ViewFrame *) sf->getRightFrame()->
6904 getViewFrame())->getRWInteractor();
6906 smeshGUI->FindActorByEntry(IObject->getEntry(), found,
6910 Renderer->RemoveActor(ac->EdgeDevice);
6911 Renderer->RemoveActor(ac->EdgeShrinkDevice);
6913 myRenderInter->Remove(IObject);
6917 /* Erase objects in Study */
6918 SALOMEDS::SObject_var obj =
6919 myStudy->FindObjectID(IObject->getEntry());
6920 if (!obj->_is_nil())
6923 new SALOMEGUI_ImportOperation(myActiveStudy);
6925 aStudyBuilder->RemoveObject(obj);
6929 } /* IObject->hasEntry() */
6932 /* Clear any previous selection */
6933 Sel->ClearIObjects();
6934 myActiveStudy->updateObjBrowser();