41 class GLRenderer : public QGLWidget { |
55 class GLRenderer : public QGLWidget { |
42 Q_OBJECT |
56 Q_OBJECT |
43 |
57 |
44 PROPERTY (double, zoom, setZoom) |
58 PROPERTY (double, zoom, setZoom) |
45 READ_PROPERTY (bool, picking) |
59 READ_PROPERTY (bool, picking) |
|
60 CALLBACK_PROPERTY (EditMode, editMode, setEditMode) |
46 |
61 |
47 public: |
62 public: |
48 enum Camera { Top, Front, Left, Bottom, Back, Right, Free }; |
63 enum Camera { Top, Front, Left, Bottom, Back, Right, Free }; |
49 enum EditMode { Select, Draw }; |
|
50 enum ListType { NormalList, PickList, BFCFrontList, BFCBackList }; |
64 enum ListType { NormalList, PickList, BFCFrontList, BFCBackList }; |
51 |
65 |
52 GLRenderer (QWidget* parent = null); |
66 GLRenderer (QWidget* parent = null); |
53 ~GLRenderer (); |
67 ~GLRenderer (); |
54 |
68 |
55 Camera camera () const { return m_camera; } |
69 Camera camera () const { return m_camera; } |
56 Axis cameraAxis (bool y); |
70 Axis cameraAxis (bool y); |
57 const char* cameraName () const; |
71 const char* cameraName () const; |
58 void clearOverlay (); |
72 void clearOverlay (); |
59 void compileObject (LDObject* obj); |
73 void compileObject (LDObject* obj); |
60 void compileAllObjects (); |
74 void compileAllObjects (); |
61 double depthValue () const; |
75 double depthValue () const; |
62 EditMode editMode () const { return m_editMode; } |
76 void endDraw (bool accept); |
63 void endDraw (bool accept); |
77 QColor getMainColor (); |
64 QColor getMainColor (); |
78 overlayMeta& getOverlay (int newcam); |
65 void hardRefresh (); |
79 void hardRefresh (); |
66 void refresh (); |
80 void refresh (); |
67 void resetAngles (); |
81 void resetAngles (); |
68 uchar* screencap (ushort& w, ushort& h); |
82 uchar* screencap (ushort& w, ushort& h); |
69 void setBackground (); |
83 void setBackground (); |
70 void setCamera (const Camera cam); |
84 void setCamera (const Camera cam); |
71 void setDepthValue (double depth); |
85 void setDepthValue (double depth); |
72 void setEditMode (const EditMode mode); |
86 void setupOverlay (); |
73 void setupOverlay (); |
|
74 |
87 |
75 static void deleteLists (LDObject* obj); |
88 static void deleteLists (LDObject* obj); |
76 |
89 |
77 protected: |
90 protected: |
78 void contextMenuEvent (QContextMenuEvent* ev); |
91 void contextMenuEvent (QContextMenuEvent* ev); |
79 void initializeGL (); |
92 void initializeGL (); |
80 void keyPressEvent (QKeyEvent* ev); |
93 void keyPressEvent (QKeyEvent* ev); |
81 void keyReleaseEvent (QKeyEvent* ev); |
94 void keyReleaseEvent (QKeyEvent* ev); |
82 void leaveEvent (QEvent* ev); |
95 void leaveEvent (QEvent* ev); |
83 void mousePressEvent (QMouseEvent* ev); |
96 void mousePressEvent (QMouseEvent* ev); |
84 void mouseMoveEvent (QMouseEvent* ev); |
97 void mouseMoveEvent (QMouseEvent* ev); |
85 void mouseReleaseEvent (QMouseEvent* ev); |
98 void mouseReleaseEvent (QMouseEvent* ev); |
86 void paintEvent (QPaintEvent* ev); |
99 void paintEvent (QPaintEvent* ev); |
87 void resizeGL (int w, int h); |
100 void resizeGL (int w, int h); |
88 void wheelEvent (QWheelEvent* ev); |
101 void wheelEvent (QWheelEvent* ev); |
89 |
102 |
90 private: |
103 private: |
91 QTimer* m_toolTipTimer; |
104 QTimer* m_toolTipTimer; |
92 Qt::MouseButtons m_lastButtons; |
105 Qt::MouseButtons m_lastButtons; |
93 Qt::KeyboardModifiers m_keymods; |
106 Qt::KeyboardModifiers m_keymods; |
98 QPoint m_pos, m_rangeStart; |
111 QPoint m_pos, m_rangeStart; |
99 QPen m_thinBorderPen, m_thickBorderPen; |
112 QPen m_thinBorderPen, m_thickBorderPen; |
100 Camera m_camera, m_toolTipCamera; |
113 Camera m_camera, m_toolTipCamera; |
101 uint m_axeslist; |
114 uint m_axeslist; |
102 ushort m_width, m_height; |
115 ushort m_width, m_height; |
103 std::vector<vertex> m_drawedVerts; |
116 vector<vertex> m_drawedVerts; |
104 EditMode m_editMode; |
|
105 bool m_rectdraw; |
117 bool m_rectdraw; |
106 QColor m_bgcolor; |
118 QColor m_bgcolor; |
|
119 double m_depthValues[6]; |
|
120 overlayMeta m_overlays[6]; |
107 |
121 |
108 void calcCameraIcons (); // Compute geometry for camera icons |
122 void calcCameraIcons (); // Compute geometry for camera icons |
109 void clampAngle (double& angle) const; // Clamps an angle to [0, 360] |
123 void clampAngle (double& angle) const; // Clamps an angle to [0, 360] |
110 void compileList (LDObject* obj, const ListType list); // Compile one of the lists of an object |
124 void compileList (LDObject* obj, const ListType list); // Compile one of the lists of an object |
111 void compileSubObject (LDObject* obj, const GLenum gltype); // Sub-routine for object compiling |
125 void compileSubObject (LDObject* obj, const GLenum gltype); // Sub-routine for object compiling |
112 void compileVertex (const vertex& vrt); // Compile a single vertex to a list |
126 void compileVertex (const vertex& vrt); // Compile a single vertex to a list |
113 vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; // Convert a 2D point to a 3D point |
127 vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; // Convert a 2D point to a 3D point |
114 QPoint coordconv3_2 (const vertex& pos3d) const; // Convert a 3D point to a 2D point |
128 QPoint coordconv3_2 (const vertex& pos3d) const; // Convert a 3D point to a 2D point |
115 void drawGLScene () const; // Paint the GL scene |
129 void drawGLScene () const; // Paint the GL scene |
116 void pick (uint mouseX, uint mouseY); // Perform object selection |
130 void pick (uint mouseX, uint mouseY); // Perform object selection |
117 void setObjectColor (LDObject* obj, const ListType list); // Set the color to an object list |
131 void setObjectColor (LDObject* obj, const ListType list); // Set the color to an object list |
118 |
132 |
119 private slots: |
133 private slots: |
120 void slot_toolTipTimer (); |
134 void slot_toolTipTimer (); |
121 void initGLData(); |
135 void initGLData(); |
122 }; |
136 }; |