PDA

View Full Version : Drawing pre-defined shapes interactively - possible?



riggsd
8th March 2007, 09:05
Before I get too deep into learning Qt and purchasing a commercial license, I would appreciate knowing if Qt can do what I want, and perhaps a quick, basic coding example can be provided to show me how it would be done?

I purchased the C++ coding with Qt book (okay, maybe I'm already in too deep :p ) but so far haven't seen that what I need can be done. I do have experience with coding, but not with graphics since I dealt with manipulating data when coding. I've also been looking for documentation on programming 2D paint programs but with very little luck, which is why I'm hoping Qt will give me the push I need.

What I need is for the user to be able to select a pre-defined shape, say, an ellipse, a box, an arrow, a line, or any other predefined shape, then click in the painter window where they want the shape to start, then click where they want the shape to end, and the program draws the object the length and rotation/angle that the user indicated along with increasing the width of the shape proportionately if the shape accommodates the width. And, of course, the user should be able to modify the shape later if needed.

Sort of like how pre-defined shape tools (line, ellipse, circle, box, star, etc.) are used in Photoshop or Paint Shop Pro. Vector-type objects perhaps?

So, how would a shape like a star be predefined and how would a user place that shape on the paint window at the size, location, and angle they want it at?

Thanks in advance.

camel
8th March 2007, 09:51
To give you a start (I am not a graphics person myself, I have to admit):

Have a look at QPainterPath. You might be able to do what you want by defining a QPainterPath in the shape you like, and then (once the user has clicked on the canvas) you calculate how the painterpath has to be transformed to get the result you like. (The transformation can be done by QMatrix/QTransform(in Qt 4.3)

You should also have a look at the Graphics View Framework (http://doc.trolltech.com/4.2/graphicsview.html) which seems to be ideal for the task you plan.

Good luck!

riggsd
9th March 2007, 03:28
Thanks, I'll look into those.

Actually, I am a graphics person ... :rolleyes:

I currently work for DAZ Productions as their QA Manager and have a website for my own work ... some good, some bad, some just for fun .. :p