Monday, September 22, 2014

project "Shoot" -- library to visualize your tree structure

    Hi there, it has been a long while since last blog I post. Well, forgive me, it was heat break. But I really did something, I will show them. Just be patient :)

----


    Shoot was a small project I wrote to help me visualize some assignments from my data structure class. It have been stay in my disk for a while. Recently, I think maybe it's a good idea to publish it so other students can easily visualize their works. Cuz I really did a search to find if there a easy way to draw my tree structure when I was in course. Unfortunately, I didn't find one, so I made one.



    Originally this project was developed in pure C language, not C++. But I think object-oriented is much better for this project. Because I can define some virtual function and call them directly.

    This project doesn't really takes much my time, most CSS/Javascript are done when I was in course. Interestingly, my internet breaks during developing. And I can't find any reference for some bugs, Fortunately, At the day after, the internet was fixed. So I can finish it.

----

    Here is the link to "Shoot".

    To use this project, you have to inherit your own node class from shoot::TreeNode. And then you need to implements your own queue/heap/tree structure, and some virtual methods in shoot::TreeNode. Including sibling(), child(), hasSibling(), hasChild(), getData().
    Here is some detail I wrote on github before:
            YourTreeNode *sibling() : no argument, return the pointer of this node's next sibling. If there is no next sibling you can return NULL instead.
            YourTreeNode *child() : no argument, return the pointer of this node's first child. If it don't have any child you can return NULL instead.
            bool hasSibling() : no argument, return a boolean that if this node has next sibling. If it is the last sibling in this generation, return false. Otherwise, return true.
            bool hasChild() : no argument, return a boolean that if this node has any child. If it is the leaf node, return false. Else cases, return true.

    Once you finish these methods, the visualize feature is done. All you have to do is call YourTreeNode->generate(filename) .
    But you gonna notice that "shoot.hd" shall be in the same directory as your .exe is. And it needs the internet to access jquery, if you want to make it works offline,  just download jquery from jquery.com/download to the same directory as "shoot.hd" is. And modify the link source at the first line in "shoot.hd".

----

    If you don't know how to import and compile this project correctly, here are the instructions.
        1. Don't forget to include "shoot.h" in your cpp.
        2. After you finished your code, compile the program with "shoot.o"
            ( g++ -o example.out example.cpp shoot.o)
        3. Check if "shoot.hd" is in the same directory as exe is.

----

    Sincerely hope this project and guidance really help you. :)