00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #include <qvblockprogramming/qvguiblocks/qvcanvas.h>
00026
00027 #ifndef DOXYGEN_IGNORE_THIS
00028
00029 class QV3DArrow: public QV3DModel
00030 {
00031 private:
00032 const double pointLength, pointWidth, trunkLength, trunkWidth;
00033 const int sections;
00034 const QColor color;
00035
00036 void glDrawDisk(const double firstHeight, const double firstWidth,
00037 const double secondHeight, const double secondWidth,
00038 const int sections)
00039 {
00040 glBegin(GL_TRIANGLE_STRIP);
00041
00042 for (double x = 0; x <= 2*PI; x += 2*PI/(double)sections)
00043 {
00044 glVertex3d(firstWidth * sin(x), firstWidth * cos(x), firstHeight);
00045 glVertex3d(secondWidth * sin(x), secondWidth * cos(x), secondHeight);
00046 }
00047 glEnd();
00048 }
00049
00050 public:
00051 QV3DArrow( const double pointLength = 128, const double pointWidth = 24,
00052 const double trunkLength = 256, const double trunkWidth = 10,
00053 const int sections = 10, const QColor & color = Qt::red): QV3DModel(),
00054 pointLength(pointLength), pointWidth(pointWidth), trunkLength(trunkLength), trunkWidth(trunkWidth),
00055 sections(sections), color(color)
00056 {
00057 }
00058
00059 void paint(QGLWidget &glWidget)
00060 {
00061 glWidget.qglColor(color);
00062 glDrawDisk(0, 0, 0, trunkWidth, sections);
00063 glDrawDisk(0, trunkWidth, trunkLength, trunkWidth, sections);
00064 glDrawDisk(trunkLength, 0, trunkLength, pointWidth, sections);
00065 glDrawDisk(trunkLength, pointWidth, trunkLength+pointLength, 0, sections);
00066 };
00067 };
00068
00069 class QV3DCoordinateCenter: public QV3DModel
00070 {
00071 private:
00072 QV3DArrow xAxis, yAxis, zAxis;
00073 public:
00074 QV3DCoordinateCenter(const double axisSizes = 400):QV3DModel(),
00075 xAxis(axisSizes/4, axisSizes/20, axisSizes/2, axisSizes/45, 10, Qt::red),
00076 yAxis(axisSizes/4, axisSizes/20, axisSizes/2, axisSizes/45, 10, Qt::green),
00077 zAxis(axisSizes/4, axisSizes/20, axisSizes/2, axisSizes/45, 10, Qt::blue)
00078 { }
00079
00080 void paint(QGLWidget &glWidget)
00081 {
00082
00083 zAxis.paint(glWidget);
00084
00085
00086 glPushMatrix();
00087 glMultMatrixd(QVMatrix::rotationMatrix3dXAxis(PI/2).transpose().getReadData());
00088 yAxis.paint(glWidget);
00089 glPopMatrix();
00090
00091
00092 glPushMatrix();
00093 glMultMatrixd(QVMatrix::rotationMatrix3dYAxis(-PI/2).transpose().getReadData());
00094 xAxis.paint(glWidget);
00095 glPopMatrix();
00096
00097
00098
00099
00100 };
00101 };
00102 #endif
00103