Can gnuplot draw interactive graph items? - c++

I always assumed gnuplot just produced static jpeg (or whatever) images. Recently I downloaded and compiled this package which demonstrated that gnuplot also (at a minimum) is capable of zooming and rotating images.
My question (1) is whether it can also interactively draw lines (sorry if that is not the correct terminology) and such. For instance, if I have generated a sales or stock graph, is gnuplot capable of using the mouse to draw a trend line or similiar? (2) If it is capable of this, is it then possible to save the altered graph? (3) Can gnuplot graphs be easily incorporated into a QT GUI application?
Thanks much for any answers and references or examples.

Gnuplot 4.6 includes Qt support. There is example code in the distribution package that show how to embed the output into a simple Qt application.

It is capable of doing some of the things you described (although it may take some creativity/reliance on external programs, etc...). See the help for mouse and more importantly bind, help mouse variables, etc. And finally, embedding in a QT application is probably the most difficult ... (although I am not completely familiar with the QT framework). I'm not entirely sure that one is possible.
Sorry to get to your question so late, but I though I would answer in case someone else wants to do something similar.

Related

full screen and zoom in Koolplot

I'm trying to graph some things in C++ and Koolplot seems like a very simple and suitable library to do so with. I'm stuck, however, on finding some documentation about it that allows me to fullscreen the application (or resize it like you can do so on lots of applications, chrome, word, discord...). As well as this, I can't find or see how i can allow the user to drag the graph around with the mouse as well as zooming into a point of a scatterplot or function. If anyone has any ideas about these things i'd appreciate it, thanks.
The short reply is: cannot do.
Koolplot uses for drawings of the charts a modernized version of the venerable BGI driver. It was invented once upon a time, when personal computers were still running on some DOS version. Those times the graphics were full screen, hence of fixed size. This particularity was kept in the modernized WinBGIm library.
Zooming or panning properly a chart present on the screen require access from the drawing/painting routines of Koolplot to the data to be shown. This is not the case. If you look once again in the source code, you will note that in the implementation efforts were made to keep separated data to be plot from the actual drawing on the screen.
In conclusion, to do what you want, you will have to modify WinBGIm such that it manages correctly a drawing surface of variable dimensions and modify koolplot such that data to be shown is owned by (or aggregated with) Plotstream class.

draw a line on c++ using qtcreator

I am extremely new on both c++ and qtcreator. At school I asked for draw a line between 2 crossed corner of an image. I am planning to use the Bresenhams Algorithm to calculate the line however I don`t know anything about the graphics library.
Can you tell me how to put a dot to a point which calculated by the algorithm?
Your question is too vague. qtcreator is just a GUI for QT development, there is graphic library in QT that should be used for your purposes, but anyway, you should gain some level in c++/qt (i.e. not to be an "extremely new") to successfully utilize it.

What type of a tool should I use to make a simple simulator in C or C++

I'm a Rails/web developer with little experience with C++, so I'm not totally sure what direction to head in: I'm looking to build a simple simulator that I can use to test an algorithm I'm building that converts standard images to radial coordinates, and all I really need to be able to do is to plot points (which will represent LEDs) on a blank window and continuously refresh them (the LEDs blink). I don't want to build a gui; command line is fine, as I'll be the only person using the tool.
I'm not sure whether this is even possible or not... I did some Java programming years ago and I remember being able to pretty easily open a window and render images in it. Is there a C++ equivalent?
Thanks in advance!
What you are describing is a perfect fit for a GUI application, rather than command line, as far as I understand.
But if you want something really simple, and not spend some time learning a GUI development framework (MFC, Qt, WxWidgets, etc), you should check the following resources:
character based basic console graphics
some more advanced console graphics with blinking, box drawing, etc.
using full GDI graphics on console
It's not that easy in C++, because there is no standard way in doing this. It's not part of the language. There are a lot of frameworks though, some lightweight and some bloating. It also depends your platform. Anyhow, I think I would use OpenGL and do that calculation thing in a shader. That way you don't have to recompile and rerun all the C++ code. You can even do it in way that updates the GPU shader whenever you save your shader file giving you immediate results.

What library to choose to build a user interface for a C++ software that uses SDL

I have a simulation software (C++) that runs on the command line. It is platform independent (currently compiling and running on Windows, MacOS X and Linux). When the simulation ends, I visualize the result with SDL; it is a very basic 2d view, mainly color squares next to each other.
I would like to have a user interface on top of the simulation so that I can start and pause the simulation, and change the parameters on the fly. Something pretty simple I guess. Well, ideally I will also add a grapher somewhere to see the evolution over time of some parameters.
Now, I am wondering what direction I should go.
Should I try to use one of the UI libraries for SDL ?
Or maybe wxwidget in conjunction with SDL ?
Or simply wxwidget and get rid of SDL ?
Do you have any experience with this ?
Thanks in advance
Barth
PS: I tried to use AGAR, a SDL UI library. It seemed very promising but I couldn't get it working. Not even the helloworld.
It may be worth you time to look into Qt. It is generally the most mature free Gui framework available. It is cross platform. And it has hardware accelerated rendering if your drawing needs some speed.
Here is a comparison posted on WxWidgets site.
In the end if your windowing needs are minimal you should choose the framework you are most comfortable with.
Probably using wxWidgets without SDL would be the easiest way to go. SDL is a media layer -- it's supposed to allow cross-platform media application development. As you only need graphical display, you only need wxWidgets -- and it will be a lot easier too!
You would benefit from SDL if:
you'd need very fast blitting of very large amount of surfaces (we're talking the 60fps range here)
you'd use RLE, color keying or other graphics operations
you'd use other media (sound, advanced real-time input, etc)
you'd need to run the software on embedded systems (handheld consoles, etc)
If the answer to all 4 is "no", then you won't benefit from SDL, and using wx alone will be much easier.

Writing OpenGL enabled GUI

I am exploring a possibility to write a kind of a notebook analogue that would reproduce the look and feel of using a traditional notebook, but with the added benefit of customizing the page in ways you can't do on paper - ask the program to lay ruled paper here, grid paper there, paste an image, insert a recording from the built-in camera, try to do handwriting recognition on the tablet input, insert some latex for neat formulas and so on. I'm pretty interested in developing it just to see if writing notes on computer can come anywhere close to the comfort plain paper + pencil offer (hard to do IMO) and can always turn it in as a university C++ project, so double gain there.
Coming from the type of project there are certain requirements for the user interface:
the user will be able to zoom, move and rotate the notebook as he wishes and I think it's pretty sensible delegate it to OpenGL, so the prospective GUI needs to work well with OGL (preferably being rendered in it)
the interface should be navigable with as little of keyboard input as user wishes (incorporating some sort of gestures maybe) up to limiting the keyboard keys as modifiers to the pen movements and taps; this includes tablet and possible multitouch support
the interface should keep out of the way where not needed and come up where needed and be easily layerable
the notebook sheet itself will be a container for objects representing the notebook blurbs, so it would be nice if the GUI would be able to overlay some frames over the exact parts of the OpenGL-drawn sheet to signify what can be done with given part (like moving, rotating, deleting, copying, editing etc.) and it's extents
In terms of interface it's probably going to end up similar to Alias' Sketch Book Pro:
picture.
As far as toolkits go I'm considering Qt and nui, but I'm not really aware how well would they match up the requirements and how well would they handle such an application.
As far as I know you can somehow coerce Qt into doing widget drawing with OpenGL, but on the other hand I heard voices it's slot-signal framework isn't exactly optimal and requires it's own preprocessor and I don't know how hard would be to do all the custom widgets I would need (say color-wheel, ruler, blurb frames, blurb selection, tablet-targeted pop-up menu etc.) in the constraints of Qt. Also quite a few Qt programs I've had on my machine seemed really sluggish, but it may be attributed to me having old PC or programmers using Qt suboptimally rather to the framework itself.
As for nui (http://www.libnui.net/) I know it's also cross-platform and all of the basic things you would require of a GUI toolkit and what is the biggest plus it is OpenGL-enabled from the start, but I don't know how it is with custom widgets and other facets and it certainly has smaller userbase and less elaborate documentation than Qt.
The question goes as this:
Does any of these toolkits fulfill (preferably all of) the requirements or there is a well fitting toolkit I haven't come across or maybe I should just roll up my sleeves, get SFML (or maybe Clutter would be more suited to this?) and something like FastDelegates or libsigc++ and program the GUI framework from the ground up myself?
I would be very glad if anyone had experience with a similar GUI project and can offer some comments on how well these toolkits hold up or is it worthwhile to pursue own GUI toolkit in this case.
Sorry for longwindedness, duh.
Have you tried FLTK? It is made with 3D graphics programming in mind and has interfaces to OpenGL. I wrote some FLTK->Scheme bindings and found the API to be real fun to work with.
OpenGL font support is terrible, in my experience. It sounds like you're going to have to develop all your own custom widgets anyway so don't even bother with a toolkit. You'll spend more time learning the toolkit, trying to figure out how to get that toolkit to work with OpenGL, and and trying to figure out how to make your special widgets in that toolkit than you will just rolling your own. I wouldn't give this advice in just any situation but it sounds like your application and your widget set is going to be very unique. Make a superclass for all widgets, define a draw method, even handler methods, etc., for override, and you've already done most of what those frameworks would do for you.
Also I'm sure you know this but this is an enormous project so you should initially narrow it down to a few simple objectives for a first iteration.