Example #1
0
def create_ogl_group(display):
    """
    create a group that will store an OpenGL buffer
    """
    aStructure = Graphic3d_Structure(display._struc_mgr)
    group = Prs3d_Root_CurrentGroup(aStructure)
    return aStructure, group
Example #2
0
    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
        """
        aStructure = Graphic3d_Structure(self._struc_mgr)
        text_aspect = Prs3d_TextAspect()

        if message_color is not None:
            text_aspect.SetColor(rgb_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(aStructure, text_aspect, to_string(text_to_write),
                        point)
        aStructure.Display()
        # @TODO: it would be more coherent if a AIS_InteractiveObject
        # is be returned
        if update:
            self.Repaint()
        return aStructure
Example #3
0
    def DisplayVector(self, vec, pnt, update=False):
        """displays a vector as an arrow"""
        if self._inited:
            aStructure = Graphic3d_Structure(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(aStructure, pnt_start, gp_Dir(vec),
                             math.radians(20), vec.Magnitude())
            aStructure.Display()
            # it would be more coherent if a AIS_InteractiveObject
            # would be returned
            if update:
                self.Repaint()
            return aStructure