14 #ifndef GRAPH_PAINTER_H
15 #define GRAPH_PAINTER_H
18 #include "graphwidget.h"
21 #include <QOpenGLFunctions>
26 class XQGraphPainter :
public enable_shared_from_this<XQGraphPainter>,
protected QOpenGLFunctions {
32 enum SelectionMode {SelNone, SelPoint, SelAxis, SelPlane, TiltTracking};
33 enum SelectionState {SelStart, SelFinish, Selecting};
34 void selectObjs(
int x,
int y, SelectionState state,
SelectionMode mode = SelNone);
36 void wheel(
int x,
int y,
double deg);
37 void zoom(
double zoomscale,
int x,
int y);
47 void viewRotate(
double angle,
double x,
double y,
double z,
bool init =
false);
51 void setColor(
float r,
float g,
float b,
float a = 1.0f) {
52 glColor4f(r, g, b, a );
53 m_curTextColor = QColor(lrintf(r * 256.0), lrintf(g * 256.0), lrintf(b * 256.0), a).rgba();
55 void setColor(
unsigned int rgb,
float a = 1.0f) {
56 QColor qc = QRgb(rgb);
57 glColor4f(qc.red() / 256.0, qc.green() / 256.0, qc.blue() / 256.0, a );
58 qc.setAlpha(lrintf(a * 255));
59 m_curTextColor = qc.rgba();
62 glVertex3f(p.x, p.y, p.z);
65 void beginLine(
double size = 1.0);
68 void beginPoint(
double size = 1.0);
71 void beginQuad(
bool fill =
false);
91 void resizeGL (
int width,
int height );
97 int screenToWindow(
const XGraph::ScrPoint &scr,
double *x,
double *y,
double *z);
110 double selectAxis(
int x,
int y,
int dx,
int dy,
112 double selectPoint(
int x,
int y,
int dx,
int dy,
115 shared_ptr<XListener> m_lsnRedraw;
118 void repaintBuffer(
int x1,
int y1,
int x2,
int y2);
125 void drawOffScreenGrids(
const Snapshot &shot);
127 void drawOffScreenPoints(
const Snapshot &shot);
128 void drawOffScreenAxes(
const Snapshot &shot);
134 void drawOnScreenHelp(
const Snapshot &shot, QPainter *qpainter);
136 const shared_ptr<XGraph> m_graph;
139 shared_ptr<XPlot> m_foundPlane;
140 shared_ptr<XAxis> m_foundPlaneAxis1, m_foundPlaneAxis2;
141 shared_ptr<XAxis> m_foundAxis;
145 shared_ptr<XAxis> *axis1, shared_ptr<XAxis> *axis2);
146 SelectionState m_selectionStateNow;
151 int m_selStartPos[2];
152 int m_tiltLastPos[2];
153 int m_pointerLastPos[2];
155 double selectGL(
int x,
int y,
int dx,
int dy, GLint list,
159 GLint m_listpoints, m_listaxes,
160 m_listaxismarkers, m_listgrids, m_listplanemarkers;
162 bool m_bIsRedrawNeeded;
163 bool m_bIsAxisRedrawNeeded;
167 GLdouble m_proj_rot[16];
169 GLdouble m_model[16];
174 XTime m_modifiedTime;
186 std::vector<Text> m_textOverpaint;
188 void drawTextOverpaint(QPainter &qpainter);