Evolife documentation

     summary     

    

******************************************************************************************
Module Evolife.Graphics.Evolife_Graphic:        
=======================================
EVOLIFE: Module Evolife_Graphic:
    Windows that display Genomes, Labyrinth and Social networks for Evolife.

    Useful classes are:
    - Genome_window:  An image area that displays binary genomes
    - Network_window: A drawing area that displays social links
    - Field_window:   A drawing area that displays agent movements
******************************************************************************************


    **************************************************************************************
    Class ViewEvent:        
    ===============
    returned information after click
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method ViewEvent.__init__        
        ----------------------------------------------------------------------------------
        Arguments:
            . EmittingClass
            . EventType
            . Info


    **************************************************************************************
    Class AreaView:        inherits from PyQt5.QtWidgets.QGraphicsView
    ==============
    Standard canvas plus resizing capabilities
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method AreaView.__init__:        
        ========================
        Defining View: a window (QGraphicsView) that contains a plot area (QGraphicsScene)
        ----------------------------------------------------------------------------------
        Arguments:
            . AreaType
            . parent
            . image
            . width
            . height
            . zoom


        ----------------------------------------------------------------------------------
        Method AreaView.paintEvent:        
        ==========================
        calls Qt’s paintEvent
        ----------------------------------------------------------------------------------
        Arguments:
            . e


        ----------------------------------------------------------------------------------
        Method AreaView.resizeEvent:        
        ===========================
        calls Qt’s resizeEvent
        ----------------------------------------------------------------------------------
        Arguments:
            . e


        ----------------------------------------------------------------------------------
        Method AreaView.updateScene:        
        ===========================
        unused
        ----------------------------------------------------------------------------------
        Arguments:
            . L


        ----------------------------------------------------------------------------------
        Method AreaView.photo:        
        =====================
        takes a snapshot and saves it to a new file
        ----------------------------------------------------------------------------------
        Arguments:
            . Name
            . FrameNumber
            . outputDir
            . extension


        ----------------------------------------------------------------------------------
        Method AreaView.EventInterpreter:        
        ================================
        Does nothing here. To be overloaded
        ----------------------------------------------------------------------------------
        Arguments:
            . Event


    **************************************************************************************
    Class Active_Frame:        inherits from Evolife.Graphics.Evolife_Graphic.AreaView
    ==================
    An Active_frame reacts to basic keyboard control
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Active_Frame.__init__:        
        ============================
        Creates a window (AreaView) with the appropriate AreaType (Draw_Area, Ground...)
        ----------------------------------------------------------------------------------
        Arguments:
            . AreaType
            . parent
            . control
            . image
            . width
            . height
            . zoom


        ----------------------------------------------------------------------------------
        Method Active_Frame.keyPressEvent:        
        =================================
        Definition of keyboard shortcuts
        ----------------------------------------------------------------------------------
        Arguments:
            . e


        ----------------------------------------------------------------------------------
        Method Active_Frame.Raise:        
        =========================
        puts the window on top of display
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Active_Frame.EventInterpreter        
        ----------------------------------------------------------------------------------
        Arguments:
            . Event


    **************************************************************************************
    Class Satellite_window:        inherits from Evolife.Graphics.Evolife_Graphic.Active_Frame
    ======================
    Satellite windows are floating windows with zooming abilities
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Satellite_window.__init__:        
        ================================
        calls the parents’ constructor with the appropriate area (QGraphicsScene) type
        ----------------------------------------------------------------------------------
        Arguments:
            . AreaType
            . control
            . Wtitle
            . image
            . width
            . height
            . zoom


        ----------------------------------------------------------------------------------
        Method Satellite_window.dimension:        
        =================================
        sets dimensions
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Satellite_window.keyPressEvent:        
        =====================================
        adds resizing keys (+ and -) to Active_Frame’s shortcuts
        ----------------------------------------------------------------------------------
        Arguments:
            . e


        ----------------------------------------------------------------------------------
        Method Satellite_window.image_display:        
        =====================================
        display an image, with possible resizing of the window
        ----------------------------------------------------------------------------------
        Arguments:
            . Image
            . windowResize


        ----------------------------------------------------------------------------------
        Method Satellite_window.Zoom:        
        ============================
        increase the window’s size
        ----------------------------------------------------------------------------------
        Arguments:
            . ZoomFactor


        ----------------------------------------------------------------------------------
        Method Satellite_window.DeZoom:        
        ==============================
        decrease the window’s size
        ----------------------------------------------------------------------------------
        Arguments:
            . DeZoomFactor


        ----------------------------------------------------------------------------------
        Method Satellite_window.closeEvent:        
        ==================================
        destroys the window
        ----------------------------------------------------------------------------------
        Arguments:
            . event


    **************************************************************************************
    Class Image_window:        inherits from Evolife.Graphics.Evolife_Graphic.Satellite_window
    ==================
    Image_window: Merely contains an image area
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Image_window.__init__:        
        ============================
        calls Satellite_window’s constructor
        ----------------------------------------------------------------------------------
        Arguments:
            . control
            . Wtitle
            . outputDir


    **************************************************************************************
    Class Genome_window:        inherits from Evolife.Graphics.Evolife_Graphic.Satellite_window
    ===================
    Genome_window: An image area that displays binary genomes
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Genome_window.__init__:        
        =============================
        calls Satellite_window’s constructor
            and performs first display
        ----------------------------------------------------------------------------------
        Arguments:
            . control
            . image
            . genome
            . gene_pattern
            . outputDir
            . zoom


        ----------------------------------------------------------------------------------
        Method Genome_window.axes:        
        =========================
        draws separation between genes
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Genome_window.genome_display:        
        ===================================
        genome gives, for each individual, the sequence of binary nucleotides
            gene_pattern is a binary flag to signal gene alternation
        ----------------------------------------------------------------------------------
        Arguments:
            . genome
            . gene_pattern
            . Photo
            . CurrentFrame
            . Prefix


    **************************************************************************************
    Class Network_window:        inherits from Evolife.Graphics.Evolife_Graphic.Satellite_window
    ====================
    Network_window: A drawing area that displays social links
        The population is displayed twice, on two horizontal axes.
        Social links are displayed as ascending vectors from one individual
        on the bottom line to another on the upper line.
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Network_window.__init__:        
        ==============================
        calls Satellite_window’s constructor
        ----------------------------------------------------------------------------------
        Arguments:
            . control
            . image
            . outputDir
            . width
            . height
            . zoom


        ----------------------------------------------------------------------------------
        Method Network_window.axes:        
        ==========================
        Draws two horizontal axes; each axis represents the population;
            social links are shown as vectors going from the lower line
            to the upper one
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Network_window.Network_display:        
        =====================================
        Social links are displayed as ascending vectors from one individual
            on the bottom line to another on the upper line.
        ----------------------------------------------------------------------------------
        Arguments:
            . Layout
            . network
            . Photo
            . CurrentFrame
            . Prefix


        ----------------------------------------------------------------------------------
        Method Network_window.Dump_network:        
        ==================================
        stores social links into a matrix written into a file
        ----------------------------------------------------------------------------------
        Arguments:
            . friends
            . CurrentFrame
            . Prefix


    **************************************************************************************
    Class Field_window:        inherits from Evolife.Graphics.Evolife_Graphic.Satellite_window
    ==================
    Field: A 2D widget that displays agent movements
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Field_window.__init__        
        ----------------------------------------------------------------------------------
        Arguments:
            . control
            . Wtitle
            . image
            . outputDir
            . width
            . height
            . zoom


        ----------------------------------------------------------------------------------
        Method Field_window.Field_display:        
        =================================
        displays agents at indicated positions
            If Ongoing is false, agents that are not given positions are removed
            
             Layout may come with two syntaxes:
                - ((Agent1Id, Coordinates1), (Agent2Id, Coordinates2), ...)
                - (Coordinates1, Coordinates2, ...)
             The first format allows to move and erase agents
             The second format is merely used to draw permanent blobs and lines
             Coordinates have 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)
             If you change the coordinates of an agent in the next call, it will be moved.
             ‘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 (float). 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)
            
             These two forms of vectors can be used to draw in two windows:  ’Trajectories’ and ‘Field’.
             Use the order:    record(vector, Window=<’Field’|’Trajectories’>)
             or:                record([vectors], Window=<’Field’|’Trajectories’>)
             ‘Field’ is default. The latter order is used to send a list of vectors.
            
             The ‘Field’ window comes in two modes, ‘F’ and ‘R’ (see option F and R at Evolife’s start)
                 - In the ‘F’ mode, all agents should be given positions at each call.
                   Missing agents are destroyed from display.
                - In the ‘R’  ('Region') mode, you may indicates positions only for relevant agents
                  To destroy an agent from display, give a negative value to its colour.
        ----------------------------------------------------------------------------------
        Arguments:
            . Layout
            . Photo
            . CurrentFrame
            . Ongoing
            . Prefix


        ----------------------------------------------------------------------------------
        Method Field_window.erase:        
        =========================
        calls Area erase
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Field_window.adaptscale:        
        ==============================
        rescales widget if items land outside (only for max values, not for negative ones)
        ----------------------------------------------------------------------------------
        Arguments:
            . Layout


        ----------------------------------------------------------------------------------
        Method Field_window.Field_scroll        
        ----------------------------------------------------------------------------------


    **************************************************************************************
    Class Trajectory_window:        inherits from Evolife.Graphics.Evolife_Graphic.Field_window
    =======================
    Synonymous for Field_window
    **************************************************************************************

    **************************************************************************************
    Class Help_window:        inherits from PyQt5.QtWidgets.QTextBrowser
    =================
    Displays a text file supposed to provide help
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Help_window.__init__:        
        ===========================
        calls Qt’s QTextBrowser
        ----------------------------------------------------------------------------------
        Arguments:
            . Control
            . Wtitle


        ----------------------------------------------------------------------------------
        Method Help_window.keyPressEvent:        
        ================================
        Definition of keyboard shortcuts
        ----------------------------------------------------------------------------------
        Arguments:
            . e


        ----------------------------------------------------------------------------------
        Method Help_window.display:        
        ==========================
        show help window
        ----------------------------------------------------------------------------------
        Arguments:
            . HelpFilename


        ----------------------------------------------------------------------------------
        Method Help_window.Raise:        
        ========================
        puts help widget in front of display
        ----------------------------------------------------------------------------------


        ----------------------------------------------------------------------------------
        Method Help_window.closeEvent:        
        =============================
        destroys help widget
        ----------------------------------------------------------------------------------
        Arguments:
            . event


    **************************************************************************************
    Class Legend_window:        inherits from Evolife.Graphics.Evolife_Graphic.Help_window
    ===================
    displays legend for curves
    **************************************************************************************

        ----------------------------------------------------------------------------------
        Method Legend_window.__init__:        
        =============================
        legend window is copied from help window
        ----------------------------------------------------------------------------------
        Arguments:
            . Control
            . Wtitle


        ----------------------------------------------------------------------------------
        Method Legend_window.display:        
        ============================
        Legend comes as a list of couples (ColourName, Meaning)
        ----------------------------------------------------------------------------------
        Arguments:
            . Legend
            . Comments


    

    

    Back to Evolife