Representing an AVL Tree graphically - c++

I implemented and AVL tree using C++, at the moment I print the AVL tree to the console but I need to represent the tree using GUI as part of an application the user can use to interact with the tree. what libraries etc. should I look into in order to achieve this?
Note: I'm using OS X

The point here seems to be that some kind of user interaction is expected.
What kind of operations shall the user be able to invoke? Moving nodes, inserting, deleting?
You can go for the graphviz approach, but if you want to have user interaction, then for graphviz you should go for html output. That way you can e.g. associate nodes with clickable links where you can put some operation logic behind.
If that is not sufficient, then you will need to go for a generic GUI framework, and see what kind of libraries are available.
In case of C++, Qt is one thing to look into. There is something called a treeview that might fit to your problem (see e.g. here: http://doc.qt.digia.com/qt/qtreeview.html).
However, be prepared that it will take you some time to get into Qt.

graphviz is a graph visualization toolkit. Writing graphviz files is really simple and using one of the back-ends to spew out an image, too. You can then display those images with whatever toolkit you like.

graphviz could do the work.
And here is the document.

Related

Good way to maintain Qt labels and text on UI

What is the best way/common practice for maintaining all string resources found on a UI in Qt, especially the textual input/text in combo boxes etc. (since these are the once that are frequently used in the code itself)?
I know that Android has this string resources thing such that resources only have to be modified at one position.
Does Qt have something like that too or do I have to initialize string resources in code instead of in the UI's XML itself...
AFAIK, there is no built-in mechanism for string resources in Qt. If you want to maintain strings at build time you can define them in one .h/.cpp file as global variables and reuse them in your code.
Otherwise you can use Qt's translator files (binary) and load them along with your application. If you need to change a string, you simply will need to edit the translation file (xml) and "recompile" it with lrelease utility without building the application again.
There is a mechanism to dynamically translate texts in application, but it works a bit different than Android string resources, but achieves the same goals.
Qt uses i18n system modelled after standard, well known unix gettext. It works in a very similar way to iOS NSLocalizedString, if that rings a bell.
http://doc.qt.io/qt-5/qobject.html#tr
This is worth reading too:
http://en.wikipedia.org/wiki/Gettext
http://doc.qt.io/qt-5/internationalization.html
Android approach is a bit unique and you should not expect it to be a "standard everywhere". It works, it's ok, but it's not a standard way of doing things on desktop.

how to save and load story-flow nodes in file?

I want to make an interactive fiction game editor, in this type of games a story has many story-lines where each gamer can finish the game with a different story. For each section of a game story we need a node that tells the story and interacts with player.
I will make an editor for drawing story sections (nodes), that every node can link to minimum one node and maybe many, also each node has some properties (like text, photo, sound, ...) and variables (like gold on the ground, HP reducer, ...) that must be used in the game story.
What's the best way for saving this story-line (nodes) in a file for loading with my game player?
If you can write a code example in C++, Pascal or PHP it is better for me.
You want to do a couple of things:
Figure out what you need to reconstruct a saved node completely enough to use it again.
Prepare all that data you need.
Look into file i/o. There are loads of tutorials online, search for "c++ file i/o" or something similar.
Now you implement file saving/loading.
I'd guess you'll end up with something like this for saving.
write number of nodes
for node in node_list:
write node info
And then for loading
read number of nodes
for i in range(0, number_of_nodes)
read node info
If you run into a specific problem ask a new question.
I think you should take a look to xml.
There are a lot of libraries to work with it, personally in c++ I prefer pugi but you can take a look to libxml2, xerces, etc...
Pugi XML
If you don't want user interaction you can always encrypt the xml before save it.

I want to use openStreetMap data to render roads in openGL, where should I start?

What I have in mind is that user will select the part of world he/she wants to generate roads and retrieve openStreetMap data and use it to render roads in openGL.
On searching the web and experimenting, I thought of this approach:
get xml file of selected map
parse the xml and generate roads by openGL.
But I think this is very naive approach.
Also to experiment a bit I used OSM2WorldViewer to convert the xml file to obj file and imported that as a model in openGL, but this method is cumbersome and takes time
and I am unfamiliar with OpenStreetMap api and how it can be used in such a project.
Any suggestions, or helpful links how to start this project ?
EDIT: How it ended: Link to the project wiki
Why do you think your approach is naive? Either you have the user to provide a self-downloaded XML file or you have to use an API to retrieve one yourself. The latter approach allows you to implement an automatic update mechanism whenever the user pans the map.
Instead of the main API you can use the Overpass API for downloading data. It's faster and more flexible to use, allowing to specify which element types to download (e.g. only roads and buildings) and much more.
You already mentioned OSM2World, take a look at its freely available code to see an example implementation of a 3D OpenGL renderer. Or take a look at one of the other 3D renderers for OSM.

A tree like (graphviz) stack trace (Visualize debugging)

I was trying to find if there exists a library or tool that will allow me to visually debug my program. i.e. something that shows a graphviz like tree structure and highlights exactly where I am in the process tree at a breakpoint. This would give a faster understanding of how my process works rather than sequentially debug through and create a tree in my mind.
I found something that partially does what I am looking for, i.e. show a tree structure of my process and the number of calls made per function call
http://www.ibm.com/developerworks/library/l-graphvis/
If it doesn't exist then I might plan on writing something that does the job. Thanks
-CV
The debug visualization plugin for Eclipse sounds like something that might be helpful for you. Furthermore, the venerable Data Display Debugger also has some automatic routines for creating graphs, albeit of the data structures you are currently seeing. I also like the visualization of kcachegrind, but it is not exactly a debugging aid. However, its graphical view shows you the position in the execution tree.
Since there does not seem to be a tool that matches your requirements exactly, maybe these ones will inspire you to write your own ;)

How do I create levels for my puzzle game ? Obj-C & Cocos2d

I want to create levels in my cocos2d game and I do not know how to do that with .plist files ... I searched the Internet but unfortunately I couldn't find significant information on how to implement these property lists. Can you please help out ?
Check out Tiled Map Editor. Tiled's TMX format is supported by Cocos2D.
As with any Apple technologies, the first place you should start searching for is the developer.apple.com website. In this case, here's the Property List (plist) Programming Guide.
However, I find property lists very awkward to work with, specifically if you want to create them manually and whenever they contain more than just a few entries. It certainly can't hurt to evaluate rolling out your own file format, text-based plain and simple. I would always rather work with simple text files like these rather than messing with property lists:
X=10;Y=10;Tile=30;
X=12;Y=11;Tile=28;
X=16;Y=19;Tile=22;
It's a different story if you actually design the data with a tool or within an app, where you'll be able to make use of the various collection convenience methods that save and load property lists, for example to and from a dictionary or array.