How to create graphs in gtk+ - c++

I have implemented a max flow algorithm, now i want to show it using gui in gtk+.
I want to display the residual graph.How can i do this in gtk+? I am coding in c++.

You need a widget that can display graphs. There isn't one in plain vanilla GTK, so you'll have to find an external one. There are a few, I believe. If you happen to be using Python and PyGTK, you can use a Matplotlib graph in GTK.

Related

Tkinter style GUI with raylib application?

I am developing a sorting algorithm simulator in C++ using RayLib for the visual simulation and was wondering if there was a way I could implement a tkinter style GUI to make a sidebar for the window and allow the user to control the simulation
I have tried using RayGUI however currently some of the files use C only functions and syntax which do not work with C++
Is there any way I can achieve this? I don't mind changing libraries but I would prefer to stay with RayLib. I have also considered using pure tkinter and using tkinter canvas to draw the simulation but that is a last resort option.
Here is a rough diagram of what I would like to achieve (the right section would be a tkinter style sidebar)
https://github.com/Spacerulerwill/Algorithm-Visualiser/blob/master/img/sortUI.png

Can I create a histogram using Gtk in native way (no external libraries)?

I'm struggling with Google to find a native way to draw histogram (or other kind of graphs) using Gtk in C++.
Maybe I'm wrong, maybe I'm not good with research on Google... anyway it seems that there is no native way to do this. This sounds strange since there are applications built for Gnome in Gtk such as Baobab (aka Disk Usage Analyzer), where there is some (circular) histogram.
I'd like standard histogram (bar plot or bar chart if you prefer).

How to get started on custom GUI widgets

I would like to exercise programming software with non-standard graphical interfaces such as the ones in the following images. I know how to create a GUI using basic widgets, but I have no idea on how to create my own custom widgets. I am familiar with GTK 3.0 and Qt. The GTK tutorial, for instance, has a link on how to do custom drawing. I just don't know if this is the usual and correct way to create custom widgets. There's also things such as: selections, mouse handling, zoom, scrolling, animations and so on that tutorials do not teach.
So here is my question: what kind of documentation, keywords, tutorials and algorithms should I look for? For my first project, I would like to start with something similar to the first and second images below. My current knowledge is C/C++ and Qt and GTK, but I can learn new languages and tools if necessary.
http://hobby-electrons.sourceforge.net/tutorials/gEDA/simple-schematic-in-gschem.png
http://www.cburch.com/logisim/docs/2.7/pt/html/images/screen-shot.png
http://eeweb.poly.edu/labs/nanovlsi/tutorials/soctutorials/figures/ENCFinalDesign.gif
http://www.ccm.ece.vt.edu:8088/etextiles/projects/arch_images/simulation.jpg
http://j-algo.binaervarianz.de/images/avl_avltest.png
The Qt Graphics view Framework is what you should use if you go with Qt. There are several examples covering the basics of creating components.
To be able to mimic those samples, most of the work is going to be on implementing custom graphic view items. Like widgets it means providing a paint method, specialized event handlers and properties.

Creating a simple window with simple controls in c++ and OpenGL

How do i just create a window with just some controls like menus , check button , radio button , scroll bar ..just with c++ and OpenGL?
It depends.
1) You can't use any external libraries.
In this case you would need to create whole framework for creating controls, handling events, hit tests, state changes... Shortly speaking, you would need to write a GUI library like Qt or wxWidgets, but with all controls drawing implemented in OpenGL.
2) You can use 3rd party libs.
Well, simply read the spec and use them. Examples:
GiGi
GLUI
Also, you may want to read this: OpenGL Forum
However, if you don't have to use OpenGL-based solution, I would suggest you use wxWidgets. I've been using it for years. It's my favourite cross-platform GUI library with solid support, quite big community and reliable, up-to-date online/offline documentation.

Can I change glui panel background colour?

I am using glui to add a control panel to my OpenGl code. This is a visualisation interface for a large scale simulation platform written in C++.
I was wondering if it is possible to make changes to the background colours of the panels?
If this is not possible, can anyone comment on how slower my display will become if I switch to using pyQt with OpenGL? And would it be possible to access information on my C++ classes and display them with a pyQt approach? (I am happy to make this a second thread if you think it is better that way.)
For background color change of glui-based panel, its not clear what you are asking but I don't see why it would not support such a basic op. Update: I would try using glClearColor like on that link.
For speed it really depends on what and how you're going to use opengl: see pyopengl: Could it replace c++? for a good discussion.
For using your c++ from python this is usually relatively easy by using SWIG (swig.org). You tell SWIG what parts of your c++ api you want to access from python and SWIG generates the code to make your c++ available as a python module.