Installing Jabref

Jabref is an application to manage bibliography. It’s installation is pretty simple. Running the following command in Ubuntu 14.04 installs version 2.8 of Jabref while the latest one is 3.6.

sudo apt-get install jabref

The latest version can be obtained from here. You need Java version 1.6 or newer. On obtaining the jar file, you have to run it using the command:

java -jar JabRef_3.6.jar

Next to add launcher in the Start menu, follow these steps:

  1. cd ~/.local/share/applications/
  2. vim JabRef.desktop
  3. Make your file look like:
[Desktop Entry]
Type=Application
Terminal=false
Icon=/path/to/Jabref/icon/file
Exec=java -jar /path/to/Jabref/jar/file/JabRef_3.6.jar
Name=Jabref

The logo can be obtained from here. Save and exit. You have it in your launcher. Create your database and enjoy!

Android Application Execution Error

Running my application in Android Emulator, I faced this error:

error:execution failed for task ':app:compiledebugjavawithjavac'.

My application got build up and ran in the emulator despite ignoring this issue. However, running it on my USB connected device was not a success.

Here’s how it is fixed. It demanded the environment variable JAVA_HOME to be set up. Open up your .bashrc file in your favorite editor. Add export JAVA_HOME="/path/to/your/jdk/installation" to the end of this file. I set the value to /usr/lib/jvm/java-1.8.0-openjdk-amd64. This set up the JAVA_HOME for me.

Next .gradle directory in the application directory needs to be deleted and then go to Build > Make Project in the Android Studio menu. This builds up the application’s fresh .gradle directory. And Run your application successfully.

Deadlock

Transferring my work from libdxf to libdxfrw has not been easy so far. Considering the functionality of parsing the input file remaining completely same, the functions to write DXF file had to be understood.

A simple line can be written to DXF file as:
DRW_Line line;
line.basePoint.x = 10;
line.basePoint.y = 20;
line.secPoint.x = 30;
line.secPoint.y = 30;
dxfW.writeLine(&line);

The values here are passed statically. The above code is executed successfully in writeEntities() function. This function is called in write() function itself without any need to explicitly call it. However to pass the parsed attributes from an input file follows a little different approach.

DRW_Line line;
line.basePoint.x = ab->at(j).toDouble();
line.basePoint.y = ab->at(j+1).toDouble();
line.secPoint.x = ab->at(j+2).toDouble();
line.secPoint.y = ab->at(j+3).toDouble();
writer.addLine(line);

The arguments of the parsed input are passed to addLine function. Initially, I was trying to call the addLine function in writeEntities function but some arguments had to be passed to the former doing which the parsed values were over-ridden. Doing it reverse made the parsed values to pass to the writeEntities function instead of each value equal to zero in the prior case.

Now I am able to obtain the parsed values outside the function addLine which was not the situation yesterday. Still I continue to confront a segmentation fault whose roots haven’t been determined yet. So far it seems like a deadlock!

The Random Argument Input

In the previous implementation, the ordering of arguments mattered. Putting length as second argument after height as the first parameter altered the drawing which was not desired for the user.

Considering the same entity wall, creating few walls like:

wall(l=100,h=30,bx=10,by=10)
wall(h=50,l=120,bx=10,by=40)
wall(bx=20,h=100,by=100,l=60)
,

does not affect the drawing. A vector was created for storing the values of the arguments. The output file I got after splitting removing the delimiters:

wall
l
100
h
30
bx
10
by
10

and similarly for the other two walls, each line is read and the entity name and variable names are compared and pushed to a vector. After one entity is read completely, it is pushed to another vector which stores the complete data of one entity as a single entry. This data is then extracted to obtain the values of variables, passing them to function that writes to DXF file and create the final drawing.

It can be referred here: https://github.com/kamalpreetgrewal/textToDrawing.

Algorithm Complexity : Recursion Tree

In this post, I aim to explain a method of solving recurrence relations, the result of which will give the complexity of the relation. The performance of the algorithm varies with the input size given to it.

Often counting the number of steps performed by algorithm are used to measure its performance. However, for larger input sizes, this process becomes cumbersome. Also such methods are bound to hardware specifications etc.

The first method we will follow up is Recursion Tree method. A recursion tree for the given recurrence relation is created first. The number of nodes at each level are counted and time taken at the corresponding level is computed. To obtain final result, the time taken at all levels is added up.

The pattern of time computed is observed. Most of the times it is an Arithmetic Progression or a Geometric Progression. The constants are discarded at the end to obtain complexity in terms of input size only. Let us use a simple example deploying the Recursion Tree method.

T(n) = 2 T(n/2) + n2

We start with the non-recurrent value as the root. The expression n2 is non-recurrent here, so it will be the root of our tree.

The next thing is to see the constant value with the recurrent value i.e. T(n/2) here. The constant 2 with it depicts the number of children each node in the tree will have. So the root node will have 2 children here and so on for the subsequent nodes.

drawit-diagram

On adding up time at different levels, we have the expression:
n2 + 2 (n/2)2 + 4 (n/4)2 + ..... + 0
= n2 (1 + 1/2 + 1/4 + ..... + 0)
= n2 (1/(1-1/2))
= n2 (1/(1/2))
= n2 * 2

Now discarding the constant, we have T(n) = O(n2). So the complexity of the recurrence relation is of the order n2 using the recursion tree method.

txt to Drawing in LibreCAD

Recently, I have been working with DXF library. My aim has been to take a text file as input from the user which has details of different elements of a building. Currently I am focusing on the wall entity. On parsing the input file, it yields a DXF file as output which can be opened up in softwares that support the DXF format.

To achieve this, I have gone through things beyond the use of DXF library itself. The correct use of regular expressions has been providing the expected results so far. Not much going into the implementation for this post, I have an input text file with details of two walls written as follows:

wall(l=100,h=30,cx=10,cy=10)
wall(l=10,h=50,cx=0,cy=0)

l depicts the length of the wall. h is height of the wall while cx and cy are coordinates of bottom left corner of the wall.

Following up the format of writing a DXF file including its header, the entities section followed up by the footer, on opening the DXF file, I achieved the drawing similar to the one below:

Screenshot from 2015-09-02 21:33:42

Just setting up in Unity

It’s been quite a while since I wrote here. I have been onto Unity, now Unity5, previously on Unity4.6. Unity5 is free now with so many more features which were in pro in earlier versions. The GDC day showed high ecstasy amongst the developers.

Since last few days, I have been doing those little yet important things. Well figuring them out is not an easy task either. The sprites were ready. The character controller was imported from the asset pack. Whoa! The character was so small compared to the other elements in the scene. What went wrong? The answer was resolution.

While importing the sprites, which initially are in the mode Texture, the Pixels Per Unit is set to 100 by default which should not be altered. I scaled it down to 1 which increased the size of elements in the scene considerably. Obviously, 100 pixels per unit and 1 pixel per unit is quite a noticable change. On exploring, finally today I have reached to the conclusion to use the default values. Also people say with such 1 ppi, handling physics can be a challenging task and natural physics’ implementation may be hindered.

So proceeding with sticking to the default values. Will keep updating you all. 🙂

Snap and dimension

Next I started with snapping to center and snapping to end points, the next two types of snapping after snapping to grid. The centers and end points are added to two different lists which are then iterated to check the distance of position of mouse from these different points added in the lists, with an offset limit added to the mouse position.

A question popped up during discussion:
Would it be efficient to make use of list to store these specific points in case the number of entities in the drawing proliferated? This is really to be explored. The principles of efficient usage of different data structures are not quite clear to us. Experience to be gained.

Also along with these, I made myself involved in dimensioning. Gurjot and I are working on linear specifically horizontal dimensioning under this, vertical will be pursued after this.

In the queue

I pioneered the implementation of change in color of grid and background in the drawing area. The two options are provided in a dialog box with the values contained in a combo-box. It was done but the color did not get update automatically whenever a different color was selected from the combo box. The change came to an effect after some wheel event or any change that updated the drawing area. A similar implementation has been done while enabling and disabling grid which resulted in updating the view/drawing-area just as the action was triggered. But this time it came to no avail.

The next thing was auto zoom which was deployed quite easily. The drawing created in the drawing area got fit in it. But the issue was unless we switched to no mode using Escape key, it did not come into action. Again this has been done by me for Select menu and again the previous implementation did not come to rescue.

For now both of these features are in queue, not at the head/front of the queue though.

Making it amiable

I have just implemented the display of appropriate messages on the status bar while the user creates entities. This has to be done giving suitable messages for other events too.

The messages can be given as a tool tip to the user too. This is to be discussed.

Also the statusbar has been divided into two parts in order to show mouse position and message both together at a time. By default, only one message can be displayed on the statusbar using showMessage().

I have created two labels and added them as widgets to the status bar using addPermanentWidget(*widgetName). This implementation is another step to make eCAD friendly to the user.