2017-01-02 21:07:43 -05:00
|
|
|
// Copyright (c) Charles J. Cliffe
|
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
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) {
|
2015-01-15 20:37:51 -05:00
|
|
|
glDisable (GL_CULL_FACE);
|
|
|
|
glDisable (GL_DEPTH_TEST);
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2015-01-15 20:37:51 -05:00
|
|
|
glMatrixMode (GL_PROJECTION);
|
2014-11-12 21:55:11 -05:00
|
|
|
glLoadIdentity();
|
|
|
|
}
|
|
|
|
|
2015-11-29 13:35:12 -05:00
|
|
|
void ScopeContext::DrawBegin(bool clear) {
|
|
|
|
if (clear) {
|
|
|
|
glClearColor(ThemeMgr::mgr.currentTheme->scopeBackground.r, ThemeMgr::mgr.currentTheme->scopeBackground.g,
|
|
|
|
ThemeMgr::mgr.currentTheme->scopeBackground.b, 1.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2015-01-15 20:37:51 -05:00
|
|
|
glMatrixMode (GL_MODELVIEW);
|
2014-11-12 21:55:11 -05:00
|
|
|
glLoadIdentity();
|
|
|
|
|
2015-01-15 20:37:51 -05:00
|
|
|
glDisable (GL_TEXTURE_2D);
|
2014-12-26 23:28:18 -05:00
|
|
|
}
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2015-08-09 12:51:01 -04:00
|
|
|
void ScopeContext::DrawTunerTitles(bool ppmMode) {
|
|
|
|
glLoadIdentity();
|
2015-03-26 22:45:52 -04:00
|
|
|
|
|
|
|
GLint vp[4];
|
|
|
|
glGetIntegerv(GL_VIEWPORT, vp);
|
|
|
|
float viewHeight = (float) vp[3];
|
|
|
|
float hPos = (float) (13) / viewHeight;
|
|
|
|
|
2016-06-01 19:42:34 -04:00
|
|
|
glColor3f(0.65f, 0.65f, 0.65f);
|
2015-03-26 22:45:52 -04:00
|
|
|
|
2016-06-23 15:17:02 -04:00
|
|
|
GLFont::Drawer refDrawingFont = GLFont::getFont(12, GLFont::getScaleFactor());
|
2016-06-21 13:40:02 -04:00
|
|
|
|
|
|
|
refDrawingFont.drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
|
|
|
refDrawingFont.drawString("Bandwidth", 0.0, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
|
|
|
refDrawingFont.drawString("Center Frequency", 0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
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];
|
2015-01-15 20:37:51 -05:00
|
|
|
glGetIntegerv(GL_VIEWPORT, vp);
|
2014-12-31 21:31:37 -05:00
|
|
|
float viewHeight = (float) vp[3];
|
|
|
|
float hPos = (float) (viewHeight - 20) / viewHeight;
|
|
|
|
|
2016-06-01 19:42:34 -04:00
|
|
|
glColor3f(0.65f, 0.65f, 0.65f);
|
2016-06-23 15:17:02 -04:00
|
|
|
|
|
|
|
GLFont::getFont(12, GLFont::getScaleFactor()).drawString(deviceName.c_str(), 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
2014-12-31 21:31:37 -05:00
|
|
|
}
|
|
|
|
|
2014-12-26 23:28:18 -05:00
|
|
|
void ScopeContext::DrawEnd() {
|
2016-03-31 20:24:38 -04:00
|
|
|
// glFlush();
|
2014-11-12 21:55:11 -05:00
|
|
|
|
2016-03-31 20:24:38 -04:00
|
|
|
// CheckGLError();
|
2014-11-12 21:55:11 -05:00
|
|
|
}
|
2014-12-26 23:28:18 -05:00
|
|
|
|
|
|
|
void ScopeContext::DrawDivider() {
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
2015-01-15 20:37:51 -05:00
|
|
|
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();
|
|
|
|
}
|