Skip to content

GSoC 2019 work Product Submission

Deepak Singh Rathore edited this page Aug 22, 2019 · 18 revisions

lua-gl

Table of Contents

Overview

lua-gl is a graphical library using IUP extensible by Lua to allow easy creation of software like a schematic editor/flowchart creator/mind maps/block diagrams in Lua. The library is able to create basic mechanisms and graphic checks to create custom blocks and interconnections and provide an API to use these to create complex interactions like hierarchical schematic editors, etc.

Library link

Commits link

Feature

  • Supports multiple canvases.

Installing the library using Luarocks.

First of all, you should have an IUP and CD library on your local system.

Download IUP from link

Download CD from link

Install lua-gl using luarocks

luarocks install lua-gl

Usage

Some examples of using the library. Full details can be found in the documentation.

To use the module simply do

require("iuplua")
require("iupluaimglib")
require("cdlua")
require("iupluacd")

LGL = require("lua-gl")

Creating a canvas object

cnvobj = LGL.new{ grid_x = 40, grid_y = 40, width = 600, height = 300, gridVisibility = true}  

cnvobj is an object of the IUP canvas. Canvas can be accessed by cnvobj like canvas = cnvobj.cnv and we can perform operations on canvas using cnvobj.

dlg = iup.dialog{
    iup.vbox{
        iup.label{title = "----------------Canvas1---------------"},
        cnvobj.cnv,
    },
    title="lua-gl",
}
dlg:showxy(iup.CENTER, iup.CENTER)

if iup.MainLoopLevel()==0 then
    iup.MainLoop()
    iup.Close()
end

Documentation

Documentation for the library has been provided here

Demo project example

I have built a demo project using Lua-GL to create a very crude schematic editor. Code

Watch the video for more link

Work Status

What is done

Features

  • Provides a canvas of the given window size exposing a canvas area of a given size.
  • Allows saving drawn shapes in text format.
  • Allows placement of another saved drawing on the canvas.
  • Allows enforcing a placement grid so that all drawn objects are snapped to the grid and the desired corner
  • Provides functionality to change the grid size.
  • Allows defining ports on a drawing to which connectors can snap
  • Allow grouping a bunch of objects/shapes in a drawing
  • Allow resizing of objects/shapes/images/groups
  • Provides functionality to handle multiple canvases together.
  • Provides hook functionality.

Functionality

  • Provide functionality to click and drag any shape and group of shape on the canvas an move it around
  • Provide functionality to just draw connector paths anywhere on the canvas
  • Object click event
  • Object drag event

TODO

  • Provide functionality to interconnect different object using connector paths using auto-routing and manual routing options.
  • Allow defining keep-out zones in a drawing where connectors cannot cross over.
  • Allows placement of an image on the canvas with custom scaling
  • Allow adding text and associating or connecting it with a shape or a group of shapes