PDA

View Full Version : 3D line drawing (CAD program)



PierreA
13th July 2017, 20:52
I'm writing a CAD program and am thinking of using Qt5 for the GUI. Most of the drawing objects are curves, of a kind peculiar to surveying, but I can approximate them arbitrarily closely with chains of cubic Bézier splines. The view will usually be directly from above with parallel rays, but there may be cases where I'll want to tilt the view. I'll need to do hit-testing, including finding the intersection of two lines, finding the foot of perpendicular to a line, etc. Is there a widget designed for this, or should I subclass QWidget and implement it myself?

d_stranz
13th July 2017, 22:18
There is no QWidget that can do this kind of thing out of the box. I would advise you to look at the Qt Graphics / View framework (https://doc.qt.io/qt-5/graphicsview.html) and some of the many examples based on it. Classes derived from QGraphicsItem have support for hit detection and so forth, and the QGraphicsScene supports use of floating point world coordinates and transformations. What is doesn't do is support 3D coordinate systems, so you will have to write your own transformations from your objects' 3D coordinates to screen object 2D coordinates.

Qt3D (https://doc.qt.io/qt-5/qt3d-overview.html) is pretty much useless for any kind of technical graphics. It's primarily designed for real-time scene rendering for animated graphics like games.

Other than that, I don't know of anything that would give you a head start. You could start with QWidget, but you'd be basically starting at zero and would have to write literally everything.

Szyk
14th July 2017, 15:38
You definitely don't want use QWidget as it bases on "old fashioned" 2D Gui interface with out acceleration (WinApi on WinDos and XLib on Linux). Mentioned Graphics View Framework is accelerated when it is possible (read: implemented). I suppose is this true for WinDos, MacOS and most Linux distros (but this should be verified before you start programing).