Evolife documentation

     summary     

    

******************************************************************************************
Module Evolife.Graphics.Plot_Area:        
=================================
EVOLIFE: Module Plot_Area:
    Windows that display Curves or images.
    This module can be used independently.

    Useful classes are:
    - Image_Area:   An area that displays an image
        function:   display()
    - Draw_Area:    Basic drawing Area
        function:   plot(, (, ) )
    - Plot_Area:    Draw_Area + grid + automatic resizing
        function:   plot(, (, ) )
    - Ground:       Defines a 2-D region where agents are located and may move
        functions:  create_agent(, , (, ) )
                    move_agent(, (, ) )

    Usage:
        #self.W = QPlot_Area.AreaView(QPlot_Area.Image_Area)
        self.W = QPlot_Area.AreaView(QPlot_Area.Draw_Area)
        #self.W = QPlot_Area.AreaView(QPlot_Area.Plot_Area)
        self.W.Area.plot(3,(10,10))
        self.W.Area.plot(3,(20,40))
        self.W.Area.plot(3,(10,22))
******************************************************************************************


    **************************************************************************************
    Class Image_Area:        inherits from PyQt5.QtWidgets.QGraphicsScene
    ================
    Defines a logical Area on which objects are drawn (hidden from screen)
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Image_Area.__init__:        
        ==========================
        Inherits from QGraphicsScene
        ----------------------------------------------------------------------------------
        Arguments:
            . image
            . width
            . height
            . EventInterpreter
            . zoom


        ----------------------------------------------------------------------------------
        Method Image_Area.resize:        
        ========================
        Stores new dimensions and redraws
        ----------------------------------------------------------------------------------
        Arguments:
            . w
            . h


        ----------------------------------------------------------------------------------
        Method Image_Area.dimension:        
        ===========================
        returns dimensions
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Image_Area.redraw:        
        ========================
        the whole scene is redrawn when the scale changes
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Image_Area.drawPoints:        
        ============================
        Unused ------ just for test
        ----------------------------------------------------------------------------------


    **************************************************************************************
    Class Draw_Area:        inherits from Evolife.Graphics.Plot_Area.Image_Area, Evolife.Graphics.Curves.Curves
    ===============
    Draw_Area: Basic drawing Area
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Draw_Area.__init__:        
        =========================
        Calls Image_Area constructor
            Initializes Curves
        ----------------------------------------------------------------------------------
        Arguments:
            . image
            . width
            . height
            . EventInterpreter
            . zoom


        ----------------------------------------------------------------------------------
        Method Draw_Area.set_margins:        
        ============================
        surrounding margins (in Image_Area pixels)
        ----------------------------------------------------------------------------------
        Arguments:
            . Left
            . Right
            . Bottom
            . Top


        ----------------------------------------------------------------------------------
        Method Draw_Area.init_Pens:        
        ==========================
        Defining one pen and one QPainterPath per curve
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Draw_Area.grid:        
        =====================
        Initial display - to be overloaded
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Draw_Area.pixel2xy:        
        =========================
        converts physical coordinates into logical pixel(between 0 and scaleX)
        ----------------------------------------------------------------------------------
        Arguments:
            . Point


        ----------------------------------------------------------------------------------
        Method Draw_Area.xy2pixel:        
        =========================
        converts logical pixel (between 0 and scaleX) into physical coordinates through rescaling
        ----------------------------------------------------------------------------------
        Arguments:
            . Point


        ----------------------------------------------------------------------------------
        Method Draw_Area.convert:        
        ========================
        Conversion of logical coordinates into physical coordinates through scaling and margin translation
        ----------------------------------------------------------------------------------
        Arguments:
            . Point


        ----------------------------------------------------------------------------------
        Method Draw_Area.Q_Convert:        
        ==========================
        Conversion of Point into Qt point
        ----------------------------------------------------------------------------------
        Arguments:
            . Point


        ----------------------------------------------------------------------------------
        Method Draw_Area.draw:        
        =====================
        adds a segment on a given curve
        ----------------------------------------------------------------------------------
        Arguments:
            . oldpoint
            . newpoint
            . Width
            . ColorID
            . Tag


        ----------------------------------------------------------------------------------
        Method Draw_Area.drawTo:        
        =======================
        draws an additional segment on a given curve (from the end of the previous one)
        ----------------------------------------------------------------------------------
        Arguments:
            . newpoint
            . Width
            . ColorID
            . Drawing
            . Tag


        ----------------------------------------------------------------------------------
        Method Draw_Area.erase:        
        ======================
        erase curves, items and restore grid
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Draw_Area.redraw:        
        =======================
        the whole picture is redrawn when the scale changes
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Draw_Area.reframe:        
        ========================
        performs a change of scale when necessary
        ----------------------------------------------------------------------------------
        Arguments:
            . Point
            . Anticipation


        ----------------------------------------------------------------------------------
        Method Draw_Area.plot:        
        =====================
        draws an additional segment on a curve
        ----------------------------------------------------------------------------------
        Arguments:
            . Curve_designation
            . newpoint
            . Width


        ----------------------------------------------------------------------------------
        Method Draw_Area.move:        
        =====================
        introduces a discontinuity in a curve
        ----------------------------------------------------------------------------------
        Arguments:
            . Curve_designation
            . newpoint


        ----------------------------------------------------------------------------------
        Method Draw_Area.speck:        
        ======================
        draws a spot
        ----------------------------------------------------------------------------------
        Arguments:
            . Curve_id
            . newpoint
            . Size


        ----------------------------------------------------------------------------------
        Method Draw_Area.mouseLocate:        
        ============================
        convert mouse position into window coordinates
        ----------------------------------------------------------------------------------
        Arguments:
            . MouseEvent


        ----------------------------------------------------------------------------------
        Method Draw_Area.mousePressEvent:        
        ================================
        retrieves mouse clicks - added by Gauthier Tallec
        ----------------------------------------------------------------------------------
        Arguments:
            . MouseEvent


        ----------------------------------------------------------------------------------
        Method Draw_Area.mouseReleaseEvent:        
        ==================================
        retrieves mouse clicks
        ----------------------------------------------------------------------------------
        Arguments:
            . MouseEvent


        ----------------------------------------------------------------------------------
        Method Draw_Area.mouseDoubleClickEvent:        
        ======================================
        retrieves mouse clicks
        ----------------------------------------------------------------------------------
        Arguments:
            . MouseEvent


        ----------------------------------------------------------------------------------
        Method Draw_Area.mouseMoveEvent:        
        ===============================
        retrieves mouse movements when button is pressed
        ----------------------------------------------------------------------------------
        Arguments:
            . MouseEvent


    **************************************************************************************
    Class Plot_Area:        inherits from Evolife.Graphics.Plot_Area.Draw_Area
    ===============
    Definition of the drawing area, with grid, legend and curves
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Plot_Area.__init__:        
        =========================
        Calls Draw_Area constructor and sets margins
        ----------------------------------------------------------------------------------
        Arguments:
            . image
            . width
            . height
            . EventInterpreter
            . zoom


        ----------------------------------------------------------------------------------
        Method Plot_Area.grid:        
        =====================
        Drawing a grid with axes and legend
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Plot_Area.plot:        
        =====================
        A version of PLOT that checks whether the new segment
            remains within the frame. If not, the scale is changed
            and all curves are replotted
        ----------------------------------------------------------------------------------
        Arguments:
            . Curve_id
            . newpoint
            . Width


    **************************************************************************************
    Class Ground:        inherits from Evolife.Graphics.Plot_Area.Draw_Area
    ============
    Defines a 2-D region where agents are located and may move
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Ground.__init__:        
        ======================
        Creates a Draw_Area and initializes agents
        ----------------------------------------------------------------------------------
        Arguments:
            . image
            . width
            . height
            . legend
            . EventInterpreter
            . zoom


        ----------------------------------------------------------------------------------
        Method Ground.setToric:        
        ======================
        if toric, edges ‘touch’ each other
        ----------------------------------------------------------------------------------
        Arguments:
            . Toric


        ----------------------------------------------------------------------------------
        Method Ground.grid:        
        ==================
        Writing maximal values for both axes
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Ground.coordinates:        
        =========================
        Coord is a tuple.
            It has the following form:
            (x, y, colour, size, ToX, ToY, segmentColour, segmentThickness, ‘shape=
')
            (shorter tuples are automatically continued with default values - ‘shape=...’ can be inserted anywhere)
            The effect is that an object of size ‘size’ is drawn at location (x,y) (your coordinates, not pixels)
            and a segment starting from that blob is drawn to (ToX, ToY) (if these values are given)
            # ‘size’ is in pixels and is not resized in case of zoom. However, if negative, it is interpreted in your coordinates and it will be resized/
            # ‘size’ may be a fractional number. It is then understood as a fraction of the window size.
            # The value assigned to ‘shape’ in the string ‘shape=...’ can be ‘ellipse’ (=default) or ‘rectangle’ or
            # any image. If it is an image, ‘colour’ is interpreted as an angle. The image is scaled to fit ‘size’ (but aspect ratio is preserved)
        ----------------------------------------------------------------------------------
        Arguments:
            . Coord


        ----------------------------------------------------------------------------------
        Method Ground.convert:        
        =====================
        process modulo if toric and calls Draw_Area’s convert
        ----------------------------------------------------------------------------------
        Arguments:
            . Coord


        ----------------------------------------------------------------------------------
        Method Ground.create_agent:        
        ==========================
        creates a dot at some location that represents an agent
        ----------------------------------------------------------------------------------
        Arguments:
            . Name
            . Coord


        ----------------------------------------------------------------------------------
        Method Ground.move_agent:        
        ========================
        moves an agent’s representative dot to some new location
        ----------------------------------------------------------------------------------
        Arguments:
            . Name
            . Coord
            . Position
            . Segment
            . Shape


        ----------------------------------------------------------------------------------
        Method Ground.create_graphic_agent:        
        ==================================
        creates a graphic agent and returns the Q-reference
        ----------------------------------------------------------------------------------
        Arguments:
            . Position
            . Shape


        ----------------------------------------------------------------------------------
        Method Ground.create_graphic_segment:        
        ====================================
        creates a graphic segment and returns the Q-reference
        ----------------------------------------------------------------------------------
        Arguments:
            . Position
            . Segment


        ----------------------------------------------------------------------------------
        Method Ground.remove_agent:        
        ==========================
        removes an agent from the ground
        ----------------------------------------------------------------------------------
        Arguments:
            . Name


        ----------------------------------------------------------------------------------
        Method Ground.remove_segment:        
        ============================
        removes a segment from the ground
        ----------------------------------------------------------------------------------
        Arguments:
            . Name


        ----------------------------------------------------------------------------------
        Method Ground.on_ground:        
        =======================
        Returns the identificiation of all agents on the ground
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Ground.remove_absent:        
        ===========================
        removes agents that are not in Present
        ----------------------------------------------------------------------------------
        Arguments:
            . Present


        ----------------------------------------------------------------------------------
        Method Ground.scroll:        
        ====================
        move agents vertically (not yet used)
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Ground.draw_tailed_blob:        
        ==============================
        draws a blob and a segment, as for an agent,
            but without agent name and without moving and removing options
        ----------------------------------------------------------------------------------
        Arguments:
            . Coord


        ----------------------------------------------------------------------------------
        Method Ground.erase:        
        ===================
        removes agents and erases Draw_Area
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Ground.redraw:        
        ====================
        the whole picture is redrawn when the scale changes
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Ground.restore_agent:        
        ===========================
        display an agent that is still present in ‘positions’ and in ‘segments’, but is graphically dead
        ----------------------------------------------------------------------------------
        Arguments:
            . Name


    

    

    Back to Evolife