2014-11-12 21:55:11 -05:00
|
|
|
#include "ScopeContext.h"
|
|
|
|
|
|
|
|
#include "ScopeCanvas.h"
|
2015-01-14 22:14:57 -05:00
|
|
|
#include "ColorTheme.h"
|
2014-11-12 21:55:11 -05:00
|
|
|
|
|
|
|
ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext) :
|
|
|
|
PrimaryGLContext(canvas, sharedContext) {
|
2014-12-31 21:31:37 -05:00
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2014-12-31 21:31:37 -05:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
2014-11-12 21:55:11 -05:00
|
|
|
glLoadIdentity();
|
|
|
|
}
|
|
|
|
|
2014-12-26 23:28:18 -05:00
|
|
|
void ScopeContext::DrawBegin() {
|
2015-01-15 00:59:33 -05:00
|
|
|
glClearColor(ThemeMgr::mgr.currentTheme->scopeBackground.r, ThemeMgr::mgr.currentTheme->scopeBackground.g, ThemeMgr::mgr.currentTheme->scopeBackground.b, 1.0);
|
2014-11-12 21:55:11 -05:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
2014-12-31 21:31:37 -05:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2014-11-12 21:55:11 -05:00
|
|
|
glLoadIdentity();
|
|
|
|
|
2014-12-31 21:31:37 -05:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
2014-12-26 23:28:18 -05:00
|
|
|
}
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2014-12-29 00:24:10 -05:00
|
|
|
void ScopeContext::Plot(std::vector<float> &points, bool stereo) {
|
2015-01-15 00:59:33 -05:00
|
|
|
glBegin(GL_QUADS);
|
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeBackground.r*2.0, ThemeMgr::mgr.currentTheme->scopeBackground.g*2.0, ThemeMgr::mgr.currentTheme->scopeBackground.b*2.0);
|
|
|
|
glVertex2f(1, 1);
|
|
|
|
glVertex2f(-1, 1);
|
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeBackground.r, ThemeMgr::mgr.currentTheme->scopeBackground.g, ThemeMgr::mgr.currentTheme->scopeBackground.b);
|
|
|
|
glVertex2f(-1, 0);
|
|
|
|
glVertex2f(1, 0);
|
|
|
|
|
|
|
|
glVertex2f(-1, 0);
|
|
|
|
glVertex2f(1, 0);
|
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeBackground.r*2.0, ThemeMgr::mgr.currentTheme->scopeBackground.g*2.0, ThemeMgr::mgr.currentTheme->scopeBackground.b*2.0);
|
|
|
|
glVertex2f(1, -1);
|
|
|
|
glVertex2f(-1, -1);
|
|
|
|
glEnd();
|
|
|
|
|
2014-11-12 21:55:11 -05:00
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
2014-12-29 00:24:10 -05:00
|
|
|
if (stereo) {
|
2015-01-14 22:14:57 -05:00
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r, ThemeMgr::mgr.currentTheme->scopeLine.g, ThemeMgr::mgr.currentTheme->scopeLine.b);
|
2014-12-29 00:24:10 -05:00
|
|
|
glBegin(GL_LINES);
|
2014-12-31 21:31:37 -05:00
|
|
|
glVertex2f(-1.0, 0.0);
|
|
|
|
glVertex2f(1.0, 0.0);
|
2014-12-29 00:24:10 -05:00
|
|
|
glEnd();
|
2015-01-15 00:59:33 -05:00
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r*0.35, ThemeMgr::mgr.currentTheme->scopeLine.g*0.35, ThemeMgr::mgr.currentTheme->scopeLine.b*0.35);
|
2014-12-29 00:24:10 -05:00
|
|
|
glBegin(GL_LINES);
|
2014-12-31 21:31:37 -05:00
|
|
|
glVertex2f(-1.0, 0.5);
|
|
|
|
glVertex2f(1.0, 0.5);
|
|
|
|
glVertex2f(-1.0, -0.5);
|
|
|
|
glVertex2f(1.0, -0.5);
|
2014-12-29 00:24:10 -05:00
|
|
|
glEnd();
|
|
|
|
} else {
|
2015-01-15 00:59:33 -05:00
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r*0.35, ThemeMgr::mgr.currentTheme->scopeLine.g*0.35, ThemeMgr::mgr.currentTheme->scopeLine.b*0.35);
|
2014-12-29 00:24:10 -05:00
|
|
|
glBegin(GL_LINES);
|
2014-12-31 21:31:37 -05:00
|
|
|
glVertex2f(-1.0, 0.0);
|
|
|
|
glVertex2f(1.0, 0.0);
|
2014-12-29 00:24:10 -05:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2015-01-14 22:14:57 -05:00
|
|
|
glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r, ThemeMgr::mgr.currentTheme->scopeLine.g, ThemeMgr::mgr.currentTheme->scopeLine.b);
|
2014-11-12 21:55:11 -05:00
|
|
|
if (points.size()) {
|
2014-12-31 21:31:37 -05:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2014-11-12 21:55:11 -05:00
|
|
|
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
2014-12-29 00:24:10 -05:00
|
|
|
if (stereo) {
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(-1.0f, 0.5f, 0.0f);
|
|
|
|
glScalef(4.0f, 0.92f, 1.0f);
|
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 4);
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(-3.0f, -0.5f, 0.0f);
|
|
|
|
glPushMatrix();
|
|
|
|
glScalef(4.0f, 0.92f, 1.0f);
|
|
|
|
glDrawArrays(GL_LINE_STRIP, points.size() / 4, points.size() / 4);
|
|
|
|
glPopMatrix();
|
|
|
|
glPopMatrix();
|
|
|
|
} else {
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(-1.0f, 0.0f, 0.0f);
|
|
|
|
glScalef(2.0f, 2.0f, 1.0f);
|
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
2014-11-12 21:55:11 -05:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2014-12-29 00:24:10 -05:00
|
|
|
|
2014-11-12 21:55:11 -05:00
|
|
|
}
|
2014-12-26 23:28:18 -05:00
|
|
|
}
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2014-12-31 21:31:37 -05:00
|
|
|
void ScopeContext::DrawDeviceName(std::string deviceName) {
|
|
|
|
GLint vp[4];
|
|
|
|
glGetIntegerv( GL_VIEWPORT, vp);
|
|
|
|
float viewHeight = (float) vp[3];
|
|
|
|
float hPos = (float) (viewHeight - 20) / viewHeight;
|
|
|
|
|
|
|
|
glColor3f(0.65,0.65,0.65);
|
|
|
|
getFont(PrimaryGLContext::GLFONT_SIZE12).drawString(deviceName.c_str(), 1.0, hPos, 12, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
|
|
|
}
|
|
|
|
|
2014-12-26 23:28:18 -05:00
|
|
|
void ScopeContext::DrawEnd() {
|
2014-11-12 21:55:11 -05:00
|
|
|
glFlush();
|
|
|
|
|
|
|
|
CheckGLError();
|
|
|
|
}
|
2014-12-26 23:28:18 -05:00
|
|
|
|
|
|
|
void ScopeContext::DrawDivider() {
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
glBegin(GL_LINES);
|
2014-12-31 21:31:37 -05:00
|
|
|
glVertex2f(0.0, -1.0);
|
|
|
|
glVertex2f(0.0, 1.0);
|
2014-12-26 23:28:18 -05:00
|
|
|
glEnd();
|
|
|
|
}
|