def create_ogl_group(display): """ create a group that will store an OpenGL buffer """ aPresentation = Prs3d_Presentation(display._struc_mgr) group = Prs3d_Root_CurrentGroup(aPresentation.GetHandle()).GetObject() return aPresentation, group
def DisplayMessage(self, point, text_to_write, height=None, message_color=None, update=False): """ :point: a gp_Pnt or gp_Pnt2d instance :text_to_write: a string :message_color: triple with the range 0-1 """ aPresentation = Prs3d_Presentation(self._struc_mgr) text_aspect = Prs3d_TextAspect() if message_color is not None: text_aspect.SetColor(color(*message_color)) if height is not None: text_aspect.SetHeight(height) if isinstance(point, gp_Pnt2d): point = gp_Pnt(point.X(), point.Y(), 0) Prs3d_Text.Draw(aPresentation.GetHandle(), text_aspect.GetHandle(), to_string(text_to_write), point) aPresentation.Display() # @TODO: it would be more coherent if a AIS_InteractiveObject # is be returned if update: self.Repaint() return aPresentation
def display_vector(self, origin, direction): r"""Display a vector starting at origin and going in direction Parameters ---------- origin : tuple(float) The origin coordinates (x, y, z) of the vector to display direction : tuple(float) The direction coordinates (x, y, z) of the vector to display """ xo, yo, zo = origin xd, yd, zd = direction end = (xo + xd, yo + xd, zo + zd) xe, ye, ze = end # self.glarea.d3d.DisplayVector(gp_Vec(xd, yd, zd), gp_Pnt(xo, yo, zo)) presentation = Prs3d_Presentation(self.glarea.occ_context.MainPrsMgr(). GetObject().StructureManager()) arrow = Prs3d_Arrow() arrow.Draw(presentation.GetHandle(), gp_Pnt(xe, ye, ze), gp_Dir(gp_Vec(xd, yd, zd)), _math.radians(20), gp_Vec(xd, yd, zd).Magnitude() / 4.) presentation.Display() e1 = BRepBuilderAPI_MakeEdge(gp_Pnt(xo, yo, zo), gp_Pnt(xe, ye, ze)).\ Edge() self.display(e1, line_width=4)
def DisplayVector(self, vec, pnt, update=False): if self._inited: aPresentation = Prs3d_Presentation(self._struc_mgr) arrow = Prs3d_Arrow() arrow.Draw(aPresentation.GetHandle(), (pnt.as_vec() + vec).as_pnt(), gp_Dir(vec), math.radians(20), vec.Magnitude()) aPresentation.Display() # it would be more coherent if a AIS_InteractiveObject # would be returned if update: self.Repaint() return aPresentation
def DisplayVector(self, vec, pnt, update=False): if self._inited: aPresentation = Prs3d_Presentation(self._struc_mgr) pnt_as_vec = gp_Vec(pnt.X(), pnt.Y(), pnt.Z()) start = pnt_as_vec + vec pnt_start = gp_Pnt(start.X(), start.Y(), start.Z()) Prs3d_Arrow.Draw(aPresentation.GetHandle(), pnt_start, gp_Dir(vec), math.radians(20), vec.Magnitude()) aPresentation.Display() # it would be more coherent if a AIS_InteractiveObject # would be returned if update: self.Repaint() return aPresentation