Skip to content

armagidon-exception/dimagram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dimagram

Generate diagrams from text input.

output eng

Description

Dimagram (the name will change at some point) is a tool to create diagrams from text input. All you have to do is write a text file with markup in a super simple markup language and compile this file to an image.

Features

  • Supports for ER diagrams in Chen notation
  • Generates diagrams with evenly spaces nodes
  • Renders diagrams from markup language

Limitations

  • Graphs induced by diagrams by conform to planarity, i.e. there's gotta be a way to draw it without edges crossing. If you try to compile a graph that does not conform to planarity compiler will give you an error.
  • Diagrams must not be disconnected, i.e. there must be a path from one node to the other by links.
  • Only ER diagrams are supported so far.
  • No labels on the edges or near terminals of nodes.
  • No key attributes out of the box
  • No associative entities out of the box
  • No weak entities out of the box
  • Nodes are rendered in raster mode

Notes

Some node types are not supported out of the box. But you can use your own image of the node.

Building from sources

Prerequisites

  • igraph
  • cairo
  • make
  • gcc
  • libunwind-ptrace (for testing to print out backtraces)
  • Unix like OS

Building

To build in release mode

make build-release

To build in test mode (the compiled program might not output file correctly, idk why)

make build-test

How to use

Dimagram supports ER diagrams in Chen's notation.

You have to mark your diagram up in a text file using a special markup language.

Simple markup language which we shall call elementary graphics language (EGL) has the following notation

  • To define an entity you use this notation
entity <identifier> "<label>"
  • To define a relationship you use this notatation
relationship <identifier> "<label>"
  • To define an attribute you you this notation
attribute <identifier> "<label>"
  • To define any other node with you own image
node <identifier> "<filename>"

Each type of node requires identifier and label to be specified. Identifier can be any alphanumeric sequence of characters. Label is put in quotation marks. Importing images as nodes requires input images to be in raster format e.g. png, jpeg. After marking the diagram up the diagram needs to be compiled.

  • To compile the file you use
<path to dimagram> -i <input> -o <output>

for example

dimagram -i diagram.txt -o diagram.svg
  • Or you could run it like this
<path to dimagram> < <input> > <output>

for example

dimagram < diagram.txt > diagram.svg

Examples

entity student "Student"
entity course "Course"
relationship student_enrolls_course "Student enrolls in course"
link student and student_enrolls_course
link student_enrolls_course and course

entity lector "Lecturer"
relationship lector_makes_course "Lecturer creates course"
link lector and lector_makes_course
link lector_makes_course and course

entity lection "Lecture"
relationship lector_makes_lection "Lecturer creates lecture"
link lection and lector_makes_lection
link lector_makes_lection and lector

entity homework "Homework"
relationship lection_contains_homework "Lecture contains homework"
link lection_contains_homework and lection
link lection_contains_homework and homework

output eng

entity student "student"
entity book "book"
entity car "car"
link book and student
link car and student

output

This code was generated using glazer

Inspirations

Used libraries

  • Log.c - logging library for C
  • igraph - Graph library for C
  • Cairo - Graphics library for C
  • zhash-c - Hashmap implementation for C
  • Boyer-Myrvold Planarity Tester - Original Boyer-Myrvold implementation by the authors of the original paper. (I tried to write my own one, but it was too hard)
  • arena - Arena allocator for C

References

About

Diagram generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors