CubicSDR/src/visual/ScopeContext.cpp

75 lines
2.4 KiB
C++
Raw Normal View History

// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
#include "ScopeContext.h"
#include "ScopeCanvas.h"
#include "ColorTheme.h"
ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext, wxGLContextAttrs *ctxAttrs) :
PrimaryGLContext(canvas, sharedContext, ctxAttrs) {
2015-01-15 20:37:51 -05:00
glDisable (GL_CULL_FACE);
glDisable (GL_DEPTH_TEST);
2015-01-15 20:37:51 -05:00
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
}
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);
}
2015-01-15 20:37:51 -05:00
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
2015-01-15 20:37:51 -05:00
glDisable (GL_TEXTURE_2D);
2014-12-26 23:28:18 -05: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;
glColor3f(0.65f, 0.65f, 0.65f);
2015-03-26 22:45:52 -04:00
GLFont::Drawer refDrawingFont = GLFont::getFont(12, GLFont::getScaleFactor());
//better position frequency/bandwidth labels according to font scale
double shiftFactor = GLFont::getScaleFactor()+0.5;
refDrawingFont.drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
refDrawingFont.drawString("Bandwidth", 0.0, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
refDrawingFont.drawString("Center Frequency", 0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
2014-12-26 23:28:18 -05:00
}
2021-04-04 22:20:33 -04:00
void ScopeContext::DrawDeviceName(const std::string& deviceName) {
GLint vp[4];
2015-01-15 20:37:51 -05:00
glGetIntegerv(GL_VIEWPORT, vp);
float viewHeight = (float) vp[3];
float hPos = (float) (viewHeight - 20) / viewHeight;
glColor3f(0.65f, 0.65f, 0.65f);
2021-04-04 22:20:33 -04:00
GLFont::getFont(12, GLFont::getScaleFactor()).drawString(deviceName, 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
}
2014-12-26 23:28:18 -05:00
void ScopeContext::DrawEnd() {
// glFlush();
// CheckGLError();
}
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);
glVertex2f(0.0, -1.0);
glVertex2f(0.0, 1.0);
2014-12-26 23:28:18 -05:00
glEnd();
}