Graph editor on Qt [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm writing a graph editor now. The programs must be written on Qt, but the problem is that I don't have enough experience with Qt, but I'm little experienced with C++. Last weeks I read one book about Qt, but I've read about 100 pages, so I know only some basics.
Can somebody give me advices about what classes should I use, please?
What I've already done:
I filled menubar with menus File, Algorithms, About etc.
I suppose that graph vertexes etc I should draw on QGraphicsView, so I added it too, also I add QGraphicsScene and bind them together (ui->setScene(scene)).
Sorry for my mistakes, unfortunately I don't have a complete understanding about all these things.
Also I added QGraphicsRectItem with scene->addRect() and set the flag moveable. But I don't know what classes should I have to use.
So, in general I want to understand how to do next things:
I want to add a panel with 2 buttons (vertex, line). After I chose vertex button (or what it will be) and click on the QGraphicsView - vertex should appear at that point. Also I must be able to change vertex name
After I chose line mode (link, which connected 2 vertexes) I should be able to connect 2 vertexes together depending on graph type (oriented or not).
By clicking on link between vertexes I should be able to change the weight of link.
I think it would be enough for one question.
Sorry if the question is very simple or stupid.
Thanks.

Your question is rather broad so it's nearly impossible to answer it entirely. So instead, I'll offer a really good example you might go look at. This example does much of what you want and might be a good starting set of code to both look at as well as reuse.

Related

Massively struggling with laying out DirectX and windows [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have managed to get this example to work:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370994(v=vs.85).aspx
My problem is that I am trying to structure the code there into something more understandable...
My first step is to remove all the stuff that's not absolutely necessary to lanching a window with a direct x surface... but as soon as I start messing with the code, I get massively confused at which components are core, and which are not...
Do you know of a kind of boilerplate project with literally the utmost basics in it for a directx surface in a window.
D2D is fine unless you suggest I just code straight in D3D... even though i'm only going to be drawing 2d stuff.
I've read so many resources and tutorials for directX but every blooming one has different bits and bobs placed in and it's so difficult to just learn what the "must" bits are!...
Just to help you with the question.
I have started by trying to create a Gfx object that will start and create surfaces and resources for direct X, I also tried to separate my windows code but ofcourse got a bit lost there too... Finally I wrapped up my Game class so that the windows loop just ran begin draw, render and end draw. in the tutorial above you have 2 brushes which as i'm not familiar with directX, I'm unsure if I can just whip them out completely or what?
I guess a step in the right direction is really what i'm looking for.
I very strongly suggest that you get hold of a decent book that can guide you through the steps:
For example - try to get a copy of this

How to move objects in OpenGL independently [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Given I have several cubes drawn on the canvas, how can they be moved independently of each other? How to define distinct onmouseup/onmousedown/onmousemove listeners to each cube?
How to define distinct onmouseup/onmousedown/onmousemove listeners to each cube?
You normally have only one pointer on the screen, except in multitouch environments, or where individual pointers can be requested for each input device.
So having only one set of mouse event handlers is kind of natual. If you want some distinction between the objects, you must get creative and come up with some way to associate event position with the to be changed object. For example clicking on it.
OpenGL is just a drawing API. It doesn't deal with objects, it doesn't know what a mouse is, or what input events are and it doesn't manage a scene, which also means it won't give you free candy in form of per-object-listeners. All of this must be implemented by you (or some 3rd party library).

Drawing lines with boost::gil? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need to draw some lines on an (off-screen) image. I'd like to use boost::gil because the lib is already integrated in my project.
I want to draw a line from start to end point in a 2dim array
Can anybody give me a quick example how to draw a line using gil?
Thank you.
GIL itself is very much concerned with storage of images and pixels in various formats and converting between them... but no more than that. user1929959's answer is using a GIL extension which facilitates interoperability of GIL with OpenCV and then uses OpenCV's line drawing (but OpenCV doesn't come with boost so you'd need to add that into your project too).
For high quality antialiased line drawing AGG and Cairo might also be worth considering (although you'd need to figure out how best adapt GIL images to their own image buffer types). But if you just want basic one pixel wide lines, consult any basic computer graphics text for some Bresenham's line algorithm pseudocode which could be trivially implemented using pixel-setting.
First take a look on boost::gil tutorial. You can find an example in drawing test, from where can easily extract method to drawing line.

How to render ocean wave using opengl in 3D? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How to render ocean waves using opengl in 3D? Any reply will be welcome.
Edit:
Is there any source code that renders ocean waves but not using an other sdk or api? It's difficult to learn how render it by read OSG source code maybe. So any tutorials about it will be ok, it is very good that it attach the source code.
Christian (above) is right. Currently your question is very broad and difficult to answer. You might want to do some research yourself and then ask a more targeted question.
Start looking at shallow water equations for example. (I'm skipping full fluid simulations here for the moment) Or read Tessendorf's "Simulating Ocean Waves". Or have a look at Cem Yuksel's wave particles. Even if you don't end up implementing any of it, the references will be a good resource for you. Another one might be this collection of links.
Not really a clear answer, but give us more to go on and we can point you in a more specific direction.
Rendering realistic looking water is extremely difficult. Luckily there are tools to make it easier, like OSGOcean, which can render some quite impressive waves.

c++ vectors causing break in my game [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
my works like this i shot airplanes and if the shot toughed an airplane it change there positions(airplane and the shot) than it will delete them. if i toughed an airplane the airplane position gets changed. than it gets deleted than my health reduces. well that works well expect that it breaks when i have about 2-4 airplanes left and i toughed one of them and shot one of them my game breaks it pops a box says vector out of range... i have had something like this problem before i fixed it because i new where was the problem but the box doesn't give me any information where it is the problem. here my full code
Thanks in Advance
note: i don't think i can go any lowwer with my code i have put new one
Well I just had a quick look at that monstrosity, and I'm not going to look too far into it but right off the bat I see a problem.
I don't know if this is related to this particular problem you are asking about, but this type of thing isn't going to work the way you think:
for(long index=0; index < (long)RegularShots.vshots.size(); ++index)
{
RegularShots.vshots[index].y-=2;
// Delete Shots
if(RegularShots.vshots[index].y<-16)
{
RegularShots.vshots.erase(RegularShots.vshots.begin()+index);
}
}
When you erase an item from the vector, the next item in the vector is moved down one, so every time you erase an item, you are skipping over the next item and not performing your test on it.
A quick fix here would be to do an index-- after the erase call.
But based on what I've seen, I would seriously recommend that you do some reading on STL containers and iterators in particular. And then read some books on good coding style ;)
Learn to 'refactor': for example, code like line 241 looks like it would be better as a subroutine.
Anyway, to find where this particular problem is, do "Debug/Break All" with the debugger while the error box is being displayed; and then look at the debugger's "Call stack" window, to see what code is being executed which triggers the popping of the box.