gui for mpi program - c++

I have a problem about a simple mpi program.This program have some 3D points and these points are moving during the program. I created an simple code by implemented c++ and then I tried to add an simple gui. I used gnuplot library and I have a problem. When I call the gui function the gui is created and it is disappeared at the same time. I mean, point object have x,y,z coordinate and I have an array that includes point objects. I want to create them as gui. Can you help me about this problem?
Thanks for any help..

what about Qt? You could use the Qt Graphics View Framework to simulate the 3D-environment - it even supports coordinate transformation (ok, it was originally designed for 2d scope). It supports OpenGL and maybe you are able to simulate the 3D points by drawing dots and setting their positions using simple cosinus and tangens mathematics.
Don't get afraid of the many functions and classes Qt offers - it's very easy and fast to learn - just check out the simple tutorials and after that you right can start your gui!
...and if you are used to Qt, you'll never want to miss it :)

Could it be that the plot is up correctly but that then your program ends? Ie everything's correct, the window goes up, but the next thing that happens is that the program is done, and the window gets destroyed? Try putting in a couple lines that wait for a keypress right after you throw up the window. Then, the window will stay until you press a key (and then the program will end).

Related

Mouse events on a cairo context

I'm developing an application with C++ and GTK3 but I'm stucked. I've created a visual application with glade which has three columns and one of them, the middle one, is a DrawingArea. In that DrawingArea I want to draw some circles at the point I want to after pressing a button and have different mouse events on that circles (like drag and drop, double click, right click...). I've made the first thing (draw a circle after pressing a button) following the official documentation, but the problem is that I don't know how to do the mouse events, but I thought about it and I have some different solutions (I don't know if they are the bests solutions or maybe there are better):
I think the best way is to create a signal to the cairomm context, but I didn't see anything to do that. Maybe the way would be to create a cairo surface or something like that.
Every time I click to create a circle, I would have to create a gtk widget in which I can handle mouse events. The problem here is that the widget needs to have circular shape and need to be drawable. Is it possible to create a circular DrawingArea? It could be the best. I saw the way to create custom widgets here.
Use goocanvasmm. The problem here is that goocanvasmm has a little documentation (I'm sorry I can not post more than two links because of my reputation) and I think this is not the best solution, I prefer to use cairomm.
This application was written in C using GTK2, and the circles were drawn using gnomecanvas, adding signals in an easy way to each circle; and now I'm moving this application to C++ and GTK3 to renew it.
I'm very new to GTK (and graphical interfaces in general), but I looked for solutions for hours and I don't know what is the best way in order to continue my work.
Thank you for your help :)
It's best to use a canvas library for this such as GooCanvas. Doing it with cairo alone would require you to listen to mouse events on the whole drawing area, and keep track of where the circles were in order to decide which circle the mouse event belongs to - exactly the problem which the canvas library has already solved for you.
If you are having trouble with goocanvasmm documentation, a look at the documentation for GooCanvas' C API combined with knowledge of how the C API translates into C++ will usually suffice. Although the GooCanvasmm documentation seems fairly extensive to me.

How can i get the absolute mouse position in Linux in C

As far as i know the two ways to get mouse position are using libgpm or reading /dev/input/mice file. But the latter just returns a relative position from the last position. So my question is how can i get the absolute mouse position though reading /dev/input/mice or other way.
And i want to implement this function by C or C++. Any information will be appreciate.
First, a mouse device is probably sending only relative movements, so there is no way to get the absolute position (just try to raise the mouse with your hand and put it elsewhere), except by integrating the movement.
And almost all Linux GUI environments are above X11, so it is the X11 server (usually the Xorg process) which deals with the mouse (it is the only process actually reading /dev/input/mice)
You'll then need to make an X11 client application. See this & that question. But you'll be much better in using some existing toolkit library, like Qt or GTK; see e.g. QMouseEvent & QWidget::mouseMoveEvent in Qt, and GtkWidget "motion-notify-event" signal in Gtk (and many other functions).
See also this question

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.

QTopengl c++ simple 2d app

Im trying to make a simple 2D application, and our image processing professor has told us to use opengl. Im working with c++ and QT.
I want to open a simple window that holds a place where I can draw points of different colors. All by code, there is no user interaction. I cant use any other library, can anyone tell me how to do this?
check out :
http://www.digitalfanatics.org/projects/qt_tutorial/chapter14.html
2D Painting Example using QGLWidget.
OpenGL is a library to render. You need at least one or two more (at least to create a window).
Since that is a homework, take a look at this example on how to do your assignment.
Qt comes with numerous examples of using QGLWidget.

How does get object from point work?

I'm new to programming. I want to make a card game with C++ / Allegro. The graphics api is irrelevant though. I want it to have many buttons you can click. I'm wondering the proper way this is done. For instance, how does windows know which control you click on from your cursor. I would use an array of rectangles and check each rectangle to ee if my mouse is is 1 of their bounds, but this doesn't seem very good. What about if I draw a line from 2 points and want to be able to drag any part of the line? I doubt i'm doing this right either. Any insight on this would be very helpful. Thanks
Basically, you want to make a mouse-driven user interface.
This is very difficult to do from scratch, that's why Allegro has a built-in GUI system. If you don't like it, you'd better use a GUI library than doing it yourself.
I'd recommand MasKing, it's an add-on for Allegro, to write graphical interfaces in C++.