.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.ogl.diagram

.. highlight:: python



.. _wx.lib.ogl.diagram.Diagram:

==========================================================================================================================================
|phoenix_title|  **wx.lib.ogl.diagram.Diagram**
==========================================================================================================================================

The :class:`Diagram` encapsulates an entire diagram, with methods for
drawing. A diagram has an associated :class:`ShapeCanvas`.



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Diagram</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.ogl.diagram.Diagram_inheritance.png" alt="Inheritance diagram of Diagram" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.ogl.diagram.Diagram.html" title="wx.lib.ogl.diagram.Diagram" alt="" coords="5,5,200,35"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.ogl.diagram.Diagram.__init__`                                     Default class constructor.
:meth:`~wx.lib.ogl.diagram.Diagram.AddShape`                                     Add a shape to the diagram. If addAfter is not None, the shape
:meth:`~wx.lib.ogl.diagram.Diagram.Clear`                                        Clear the specified device context.
:meth:`~wx.lib.ogl.diagram.Diagram.DeleteAllShapes`                              Remove and delete all shapes in the diagram.
:meth:`~wx.lib.ogl.diagram.Diagram.DrawOutline`                                  Draw an outline rectangle on the current device context.
:meth:`~wx.lib.ogl.diagram.Diagram.FindShape`                                    Return the shape for the given identifier.
:meth:`~wx.lib.ogl.diagram.Diagram.GetCanvas`                                    Return the shape canvas associated with this diagram.
:meth:`~wx.lib.ogl.diagram.Diagram.GetCount`                                     Return the number of shapes in the diagram.
:meth:`~wx.lib.ogl.diagram.Diagram.GetGridSpacing`                               Return the grid spacing.
:meth:`~wx.lib.ogl.diagram.Diagram.GetMouseTolerance`                            Return the tolerance within which a mouse move is ignored.
:meth:`~wx.lib.ogl.diagram.Diagram.GetQuickEditMode`                             Return quick edit mode.
:meth:`~wx.lib.ogl.diagram.Diagram.GetShapeList`                                 Return the internal shape list.
:meth:`~wx.lib.ogl.diagram.Diagram.GetSnapToGrid`                                Return snap-to-grid mode.
:meth:`~wx.lib.ogl.diagram.Diagram.InsertShape`                                  Insert a shape at the front of the shape list.
:meth:`~wx.lib.ogl.diagram.Diagram.RecentreAll`                                  Recentre all the text that should be centred.
:meth:`~wx.lib.ogl.diagram.Diagram.Redraw`                                       Redraw the shapes in the diagram on the specified device context.
:meth:`~wx.lib.ogl.diagram.Diagram.RemoveAllShapes`                              Remove all shapes from the diagram but do not delete the shapes.
:meth:`~wx.lib.ogl.diagram.Diagram.RemoveShape`                                  Remove the shape from the diagram (non-recursively) but do not
:meth:`~wx.lib.ogl.diagram.Diagram.SetCanvas`                                    Set the canvas associated with this diagram.
:meth:`~wx.lib.ogl.diagram.Diagram.SetGridSpacing`                               Sets grid spacing.
:meth:`~wx.lib.ogl.diagram.Diagram.SetMouseTolerance`                            Set the tolerance within which a mouse move is ignored.
:meth:`~wx.lib.ogl.diagram.Diagram.SetQuickEditMode`                             Set quick-edit-mode on of off.
:meth:`~wx.lib.ogl.diagram.Diagram.SetSnapToGrid`                                Sets snap-to-grid mode.
:meth:`~wx.lib.ogl.diagram.Diagram.ShowAll`                                      Call Show for each shape in the diagram.
:meth:`~wx.lib.ogl.diagram.Diagram.Snap`                                         'Snaps' the coordinate to the nearest grid position, if
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: Diagram(object)

   The :class:`Diagram` encapsulates an entire diagram, with methods for
   drawing. A diagram has an associated :class:`ShapeCanvas`.

   .. method:: __init__(self)

      Default class constructor.


   .. method:: AddShape(self, object, addAfter = None)

      Add a shape to the diagram. If addAfter is not None, the shape
      will be added after addAfter.
      
      :param `object`: an instance of :class:`~lib.ogl.Shape`
      :param `addAfter`: an instance of :class:`~lib.ogl.Shape`


   .. method:: Clear(self, dc)

      Clear the specified device context.


   .. method:: DeleteAllShapes(self)

      Remove and delete all shapes in the diagram.


   .. method:: DrawOutline(self, dc, x1, y1, x2, y2)

      Draw an outline rectangle on the current device context.
      
      :param `dc`: the :class:`wx.MemoryDC` device context
      :param `x1`: the x1 position
      :param `y2`: the y2 position
      :param `x1`: the x1 position
      :param `y2`: the y2 position


   .. method:: FindShape(self, id)

      Return the shape for the given identifier.
      
      :param `id`: the shape id to find


   .. method:: GetCanvas(self)

      Return the shape canvas associated with this diagram.


   .. method:: GetCount(self)

      Return the number of shapes in the diagram.


   .. method:: GetGridSpacing(self)

      Return the grid spacing.


   .. method:: GetMouseTolerance(self)

      Return the tolerance within which a mouse move is ignored.


   .. method:: GetQuickEditMode(self)

      Return quick edit mode.


   .. method:: GetShapeList(self)

      Return the internal shape list.


   .. method:: GetSnapToGrid(self)

      Return snap-to-grid mode.


   .. method:: InsertShape(self, object)

      Insert a shape at the front of the shape list.
      
      :param `object`: an instance of :class:`~lib.ogl.Shape`


   .. method:: RecentreAll(self, dc)

      Recentre all the text that should be centred.
      
      :param `dc`: the :class:`wx.MemoryDC` device context


   .. method:: Redraw(self, dc)

      Redraw the shapes in the diagram on the specified device context.


   .. method:: RemoveAllShapes(self)

      Remove all shapes from the diagram but do not delete the shapes.


   .. method:: RemoveShape(self, object)

      Remove the shape from the diagram (non-recursively) but do not
      delete it.
      
      :param `object`: an instance of :class:`~lib.ogl.Shape`


   .. method:: SetCanvas(self, canvas)

      Set the canvas associated with this diagram.
      
      :param `canvas`: an instance of :class:`~lib.ogl.Canvas`


   .. method:: SetGridSpacing(self, spacing)

      Sets grid spacing.
      
      :param `spacing`: the spacing


   .. method:: SetMouseTolerance(self, tolerance)

      Set the tolerance within which a mouse move is ignored.
      
      The default is 3 pixels.
      
      :param `tolerance`: the tolerance level


   .. method:: SetQuickEditMode(self, mode)

      Set quick-edit-mode on of off.
      
      In this mode, refreshes are minimized, but the diagram may need
      manual refreshing occasionally.
      
      :param `mode`: `True` to quick edit or `False` for normal edit


   .. method:: SetSnapToGrid(self, snap)

      Sets snap-to-grid mode.
      
      :param `snap`: `True` to snap to grid or `False` not to snap


   .. method:: ShowAll(self, show)

      Call Show for each shape in the diagram.
      
      :param `show`: ``True`` or False


   .. method:: Snap(self, x, y)

      'Snaps' the coordinate to the nearest grid position, if
      snap-to-grid is on.
      
      :param `x`: the x position
      :param `y`: the y position


