GSoC: Final Report

After midterm, it was decided that I begin working on a re-write of GNU Dr. Geo to incorporate the newer APIs that have replaced older ones which have been deprecated in recent years.

The most important change was in GTK library as they have dropped GDK Drawing API completely in version 3. They recommend to use Cairo 2D Library directly to make use of Drawing widget provided in the Gtk.

So I started with a basic approach to divide the software in two core parts:

  • GUI
  • Kernel

GUI handles all the graphics, how entities are created, how they are displayed and even how the windows and widgets are created and handled.
Kernel handles the processing of the entities, how they are stored and also how objects are created and used.

My main motive was to provide a general program that can draw some entities and stores them.

Below is the image that shows my current progress.

drgeo-intro
GNU Dr. Geo Window

My modular version of GNU Dr. Geo has following features:

  1. Has Tabbed Document Interface (TDI)
    tab
    TDI interface

    You can create new tabs by clicking New menu item in File menu. You can also close these tabs.

  2. Draw Points
    point
    Single Point

    You can draw points on the canvas by selecting Point entity in Draw menu.

    Multiple Points
    Multiple Points
  3. Draw Line
    Line Entity
    Line Entity

    You can draw line on the canvas by selecting Line entity in Draw menu. But you need two points drawn on the canvas in order to draw line between them.

  4. Draw Circle
    Circle Entity
    Circle Entity

    You can draw circle on the canvas by selecting Circle entity in Draw menu. But you need two points drawn on the canvas in order to draw circle. The first selected point will be the center point of the circle while the second selected point will calculate the radius of the circle.

  5. Draw Arc
    Arc Entity
    Arc Entity

    You can draw arc on the canvas by selecting Arc entity in Draw menu. But you need three points drawn on the canvas in order to draw arc. The first selected point will be the start point of the arc while the second selected point will determine the direction of the arc and the third selected point will be the end point of the arc.

Points are stored in a vector and this vector is iterated to check whether there is already a point drawn under our mouse at any time and at any position.

Kernel, right now, has the container class for point. Similarly all entities will have their own respective containers. Also the drawing areas will have their objects stored and iterated to check which tab is selected and undo/redo operations will be implemented on that.

There are a lot of things that needs improvement and hopefully I will be a part of the development of GNU Dr. Geo for a long time to implement what I have planned for it.

It was great coding and learning experience.

Advertisements

18-August-2014

It’s a last day of coding and I added one last thing before final evaluation.

I have added an about dialog in help menu and inserted a logo in there along with project page link.

I also wrote user manual for using my software.

16-August-2014

Finally implemented ‘arc’ entity in drgeo. Like I wrote in my previous posts that it was really tricky to figure when and how to use negative arc with correct start and end angle.

The code is working pretty nice now.

Now it’s time to write code comments wherever I’ve missed.

14-August-2014

Changed the point color to red to make it look distinct when line or circle is drawn.

Still working on the arc logic to draw it correctly.

The reason behind the delay is that there are lot of cases to consider in respect to the 3 points that I am using.

There are two main things to consider:

  • Correct Starting Angle and the End Angle
  • Correct Direction in which arc must be drawn

Right now arc is sometimes drawn in opposite direction and sometimes the end angle varies.

13-August-2014

I am working on adding arc with 3 points. I got the basic implementation done but still need to add lots of if-else statements.

It is pretty easy to draw an arc using Cairo with the syntax as:

cairo_arc(cairo* surface, double x, double y, double r, double start, double end)

we need only center point(x,y), radius of the arc (r), start angle (start) and the end angle (end) of the arc.

But it is extremely messy trying to get the coordinates and the angles right. The (0,0) coordinate at the upper left corner makes it more confusing with how the angles come into play while calculating radius and placing the arc in between those 3 points.

Hoping to get this done by tomorrow.

12-August-2014

I have implemented another entity, i.e circle which is again drawn with two points.

Initially I thought to use separate class for the calculations. But seeing that these calculations are not really large and can be accommodated easily, I decided to keep the code in the drgeoDrawingArea.cpp itself.

The circle could be drawn in other ways as well which will be implemented at later stage.

Next I have started implemented ‘arc’ which will be drawn with three points. And the order of selection of these points will decide the arc shape and angles.