1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Added options to display scope primary or secondary displays exclusively

This commit is contained in:
f4exb 2015-07-12 22:22:04 +02:00
parent b10cab79ae
commit 3d75f2f899
8 changed files with 760 additions and 450 deletions

View File

@ -42,6 +42,12 @@ public:
ModeCyclostationary
};
enum Displays {
DisplayBoth,
DisplayFirstOnly,
DisplaySecondOnly
};
GLScope(QWidget* parent = NULL);
~GLScope();
@ -51,6 +57,7 @@ public:
void setTimeBase(int timeBase);
void setTimeOfsProMill(int timeOfsProMill);
void setMode(Mode mode);
void setDisplays(Displays displays);
void setOrientation(Qt::Orientation orientation);
void setDisplayGridIntensity(int intensity);
@ -72,6 +79,7 @@ private:
bool m_dataChanged;
bool m_configChanged;
Mode m_mode;
Displays m_displays;
Qt::Orientation m_orientation;
// traces

View File

@ -67,6 +67,8 @@ private slots:
void on_horizView_clicked();
void on_vertView_clicked();
void on_onlyPrimeView_clicked();
void on_onlySecondView_clicked();
};
#endif // INCLUDE_GLSCOPEGUI_H

View File

@ -17,6 +17,7 @@ GLScope::GLScope(QWidget* parent) :
m_dataChanged(false),
m_configChanged(true),
m_mode(ModeIQ),
m_displays(DisplayBoth),
m_orientation(Qt::Horizontal),
m_displayTrace(&m_rawTrace),
m_oldTraceSize(-1),
@ -103,6 +104,14 @@ void GLScope::setMode(Mode mode)
update();
}
void GLScope::setDisplays(Displays displays)
{
m_displays = displays;
m_dataChanged = true;
m_configChanged = true;
update();
}
void GLScope::setOrientation(Qt::Orientation orientation)
{
m_orientation = orientation;
@ -169,8 +178,10 @@ void GLScope::paintGL()
glScalef(2.0, -2.0, 1.0);
glTranslatef(-0.50, -0.5, 0);
// I
// I - primary display
if ((m_displays == DisplayBoth) || (m_displays == DisplayFirstOnly))
{
// draw rect around
glPushMatrix();
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
@ -252,52 +263,6 @@ void GLScope::paintGL()
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// paint left #2 scale
glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glLeft2ScaleRect.x(), m_glLeft2ScaleRect.y(), 0);
glScalef(m_glLeft2ScaleRect.width(), m_glLeft2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// paint bottom #2 scale
glBindTexture(GL_TEXTURE_2D, m_bot2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glBot2ScaleRect.x(), m_glBot2ScaleRect.y(), 0);
glScalef(m_glBot2ScaleRect.width(), m_glBot2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
if(m_triggerChannel == ScopeVis::TriggerChannelI) {
glPushMatrix();
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0, 0);
@ -348,9 +313,12 @@ void GLScope::paintGL()
glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
} // Both displays or primary only
// Q
// Q - secondary display
if ((m_displays == DisplayBoth) || (m_displays == DisplaySecondOnly))
{
// draw rect around
glPushMatrix();
glTranslatef(m_glScopeRect2.x(), m_glScopeRect2.y(), 0);
@ -366,6 +334,7 @@ void GLScope::paintGL()
glVertex2f(1, 0);
glEnd();
glDisable(GL_BLEND);
// paint grid
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -385,6 +354,52 @@ void GLScope::paintGL()
}
glPopMatrix();
// paint left #2 scale
glBindTexture(GL_TEXTURE_2D, m_left2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glLeft2ScaleRect.x(), m_glLeft2ScaleRect.y(), 0);
glScalef(m_glLeft2ScaleRect.width(), m_glLeft2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// paint bottom #2 scale
glBindTexture(GL_TEXTURE_2D, m_bot2ScaleTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(m_glBot2ScaleRect.x(), m_glBot2ScaleRect.y(), 0);
glScalef(m_glBot2ScaleRect.width(), m_glBot2ScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
if(m_triggerChannel == ScopeVis::TriggerChannelQ) {
glPushMatrix();
glTranslatef(m_glScopeRect2.x(), m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0, 0);
@ -435,6 +450,7 @@ void GLScope::paintGL()
glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
} // Both displays or secondary display only
glPopMatrix();
m_dataChanged = false;
@ -643,6 +659,8 @@ void GLScope::applyConfig()
// QRectF(x, y, w, h); (x, y) = top left corner
if (m_displays == DisplayBoth)
{
if(m_orientation == Qt::Vertical) {
int scopeHeight = (height() - topMargin) / 2 - botMargin;
int scopeWidth = width() - leftMargin - rightMargin;
@ -1017,6 +1035,201 @@ void GLScope::applyConfig()
m_bot2ScaleTextureAllocated = true;
} // X2 scale
}
} // Both displays
else if (m_displays == DisplayFirstOnly)
{
int scopeHeight = height() - topMargin - botMargin;
int scopeWidth = width() - leftMargin - rightMargin;
m_glScopeRect1 = QRectF(
(float) leftMargin / (float) width(),
(float) topMargin / (float) height(),
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft1ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glBot1ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
{ // Y1 scale
//std::cerr << "Horizontal: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl;
m_y1Scale.setSize(scopeHeight);
m_left1ScalePixmap = QPixmap(
leftMargin - 1,
scopeHeight
);
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
m_left1ScalePixmap.fill(Qt::black);
QPainter painter(&m_left1ScalePixmap);
painter.setPen(QColor(0xf0, 0xf0, 0xff));
painter.setFont(font());
tickList = &m_y1Scale.getTickList();
for(int i = 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
if(tick->major) {
if(tick->textSize > 0) {
//std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl;
painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text);
}
}
}
if (m_left1ScaleTextureAllocated)
deleteTexture(m_left1ScaleTextureAllocated);
m_left1ScaleTexture = bindTexture(m_left1ScalePixmap,
GL_TEXTURE_2D,
GL_RGBA,
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_left1ScaleTextureAllocated = true;
} // Y1 scale
{ // X1 scale
m_x1Scale.setSize(scopeWidth);
m_bot1ScalePixmap = QPixmap(
scopeWidth,
botMargin - 1
);
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
m_bot1ScalePixmap.fill(Qt::black);
QPainter painter(&m_bot1ScalePixmap);
painter.setPen(QColor(0xf0, 0xf0, 0xff));
painter.setFont(font());
tickList = &m_x1Scale.getTickList();
for(int i = 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
if(tick->major) {
if(tick->textSize > 0) {
painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text);
}
}
}
if (m_bot1ScaleTextureAllocated)
deleteTexture(m_bot1ScaleTexture);
m_bot1ScaleTexture = bindTexture(m_bot1ScalePixmap,
GL_TEXTURE_2D,
GL_RGBA,
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_bot1ScaleTextureAllocated = true;
} // X1 scale
} // Primary display only
else if (m_displays == DisplaySecondOnly)
{
int scopeHeight = height() - topMargin - botMargin;
int scopeWidth = width() - leftMargin - rightMargin;
m_glScopeRect2 = QRectF(
(float) leftMargin / (float) width(),
(float) topMargin / (float) height(),
(float) scopeWidth / (float) width(),
(float) scopeHeight / (float) height()
);
m_glLeft2ScaleRect = QRectF(
0,
(float) topMargin / (float) height(),
(float) (leftMargin-1) / (float) width(),
(float) scopeHeight / (float) height()
);
m_glBot2ScaleRect = QRectF(
(float) leftMargin / (float) width(),
(float) (scopeHeight + topMargin + 1) / (float) height(),
(float) scopeWidth / (float) width(),
(float) (botMargin - 1) / (float) height()
);
{ // Y2 scale
//std::cerr << "Horizontal: " << width() << "x" << scopeHeight << " amp:" << m_amp << std::endl;
m_y2Scale.setSize(scopeHeight);
m_left2ScalePixmap = QPixmap(
leftMargin - 1,
scopeHeight
);
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
m_left2ScalePixmap.fill(Qt::black);
QPainter painter(&m_left2ScalePixmap);
painter.setPen(QColor(0xf0, 0xf0, 0xff));
painter.setFont(font());
tickList = &m_y2Scale.getTickList();
for(int i = 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
if(tick->major) {
if(tick->textSize > 0) {
//std::cerr << (tick->text).toStdString() << " @ " << tick->textPos << std::endl;
painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text);
}
}
}
if (m_left2ScaleTextureAllocated)
deleteTexture(m_left2ScaleTextureAllocated);
m_left2ScaleTexture = bindTexture(m_left2ScalePixmap,
GL_TEXTURE_2D,
GL_RGBA,
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_left2ScaleTextureAllocated = true;
} // Y2 scale
{ // X2 scale
m_x2Scale.setSize(scopeWidth);
m_bot2ScalePixmap = QPixmap(
scopeWidth,
botMargin - 1
);
const ScaleEngine::TickList* tickList;
const ScaleEngine::Tick* tick;
m_bot2ScalePixmap.fill(Qt::black);
QPainter painter(&m_bot2ScalePixmap);
painter.setPen(QColor(0xf0, 0xf0, 0xff));
painter.setFont(font());
tickList = &m_x2Scale.getTickList();
for(int i = 0; i < tickList->count(); i++) {
tick = &(*tickList)[i];
if(tick->major) {
if(tick->textSize > 0) {
painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text);
}
}
}
if (m_bot2ScaleTextureAllocated)
deleteTexture(m_bot2ScaleTexture);
m_bot2ScaleTexture = bindTexture(m_bot2ScalePixmap,
GL_TEXTURE_2D,
GL_RGBA,
QGLContext::LinearFilteringBindOption |
QGLContext::MipmapBindOption);
m_bot2ScaleTextureAllocated = true;
} // X2 scale
} // Secondary display only
}
void GLScope::tick()

View File

@ -248,24 +248,63 @@ void GLScopeGUI::on_dataMode_currentIndexChanged(int index)
void GLScopeGUI::on_horizView_clicked()
{
std::cerr << "GLScopeGUI::on_horizView_clicked" << std::endl;
m_displayOrientation = Qt::Horizontal;
if(ui->horizView->isChecked()) {
ui->vertView->setChecked(false);
ui->onlyPrimeView->setChecked(false);
ui->onlySecondView->setChecked(false);
m_glScope->setOrientation(Qt::Horizontal);
m_glScope->setDisplays(GLScope::DisplayBoth);
} else {
ui->horizView->setChecked(true);
m_glScope->setOrientation(Qt::Horizontal);
m_glScope->setDisplays(GLScope::DisplayBoth);
}
}
void GLScopeGUI::on_vertView_clicked()
{
std::cerr << "GLScopeGUI::on_vertView_clicked" << std::endl;
m_displayOrientation = Qt::Vertical;
if(ui->vertView->isChecked()) {
ui->horizView->setChecked(false);
ui->onlyPrimeView->setChecked(false);
ui->onlySecondView->setChecked(false);
m_glScope->setOrientation(Qt::Vertical);
m_glScope->setDisplays(GLScope::DisplayBoth);
} else {
ui->vertView->setChecked(true);
m_glScope->setOrientation(Qt::Vertical);
m_glScope->setDisplays(GLScope::DisplayBoth);
}
}
void GLScopeGUI::on_onlyPrimeView_clicked()
{
std::cerr << "GLScopeGUI::on_onlyPrimeView_clicked" << std::endl;
if(ui->onlyPrimeView->isChecked()) {
ui->horizView->setChecked(false);
ui->vertView->setChecked(false);
ui->onlySecondView->setChecked(false);
m_glScope->setDisplays(GLScope::DisplayFirstOnly);
} else {
ui->onlyPrimeView->setChecked(true);
m_glScope->setDisplays(GLScope::DisplayFirstOnly);
}
}
void GLScopeGUI::on_onlySecondView_clicked()
{
std::cerr << "GLScopeGUI::on_onlySecondView_clicked" << std::endl;
if(ui->onlySecondView->isChecked()) {
ui->horizView->setChecked(false);
ui->vertView->setChecked(false);
ui->onlyPrimeView->setChecked(false);
m_glScope->setDisplays(GLScope::DisplaySecondOnly);
} else {
ui->onlySecondView->setChecked(true);
m_glScope->setDisplays(GLScope::DisplaySecondOnly);
}
}

View File

@ -79,27 +79,27 @@
</property>
<item>
<property name="text">
<string>I+Q (linear)</string>
<string>1:I 2:Q (linear)</string>
</property>
</item>
<item>
<property name="text">
<string>Mag (linear) + Phi</string>
<string>1:Mag (linear) 2:Phi</string>
</property>
</item>
<item>
<property name="text">
<string>Mag (dB) + Phi</string>
<string>1:Mag (dB) 2: Phi</string>
</property>
</item>
<item>
<property name="text">
<string>Derived 1+2nd </string>
<string>1:Derived 1 2:2nd </string>
</property>
</item>
<item>
<property name="text">
<string>Cyclostationary</string>
<string>1,2:Cyclostationary</string>
</property>
</item>
</widget>
@ -116,10 +116,56 @@
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="onlyPrimeView">
<property name="toolTip">
<string>Only primary display</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/display1.png</normaloff>:/display1.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="onlySecondView">
<property name="toolTip">
<string>Only secondary display</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/display2.png</normaloff>:/display2.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="horizView">
<property name="toolTip">
<string>Horizontal display arrangement</string>
<string>Both displays horizontally arranged</string>
</property>
<property name="text">
<string/>
@ -145,7 +191,7 @@
<item>
<widget class="QToolButton" name="vertView">
<property name="toolTip">
<string>Vertical display arrangement</string>
<string>Both displays vertically arranged</string>
</property>
<property name="text">
<string/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

View File

@ -14,5 +14,7 @@
<file>grid.png</file>
<file>invertspectrum.png</file>
<file>preset-last.png</file>
<file>display1.png</file>
<file>display2.png</file>
</qresource>
</RCC>