diff --git a/sdrbase/gui/glscopeng.cpp b/sdrbase/gui/glscopeng.cpp index d6f742cf9..3903d78d0 100644 --- a/sdrbase/gui/glscopeng.cpp +++ b/sdrbase/gui/glscopeng.cpp @@ -188,7 +188,7 @@ void GLScopeNG::paintGL() glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glFunctions->glClear(GL_COLOR_BUFFER_BIT); - if ((m_displayMode == DisplayX) || (m_displayMode == DisplayXYV)) // display trace #0 + if ((m_displayMode == DisplayX) || (m_displayMode == DisplayXYV) || (m_displayMode == DisplayXYH)) // display trace #0 { // draw rect around { @@ -348,7 +348,7 @@ void GLScopeNG::paintGL() } // trace length > 0 } // Display X only - if ((m_displayMode == DisplayY) || (m_displayMode == DisplayXYV)) // display traces #1..n + if ((m_displayMode == DisplayY) || (m_displayMode == DisplayXYV) || (m_displayMode == DisplayXYH)) // display traces #1..n { // draw rect around { @@ -611,7 +611,7 @@ void GLScopeNG::applyConfig() } else if (m_displayMode == DisplayXYH) // both displays horizontally arranged { - + setHorizontalDisplays(); } else if (m_displayMode == DisplayPol) // horizontal arrangement: XY stacked on left and polar on right { @@ -1022,6 +1022,206 @@ void GLScopeNG::setVerticalDisplays() } // Y vertical scale (Y2) } +void GLScopeNG::setHorizontalDisplays() +{ + QFontMetrics fm(font()); + int M = fm.width("-"); + int scopeHeight = height() - m_topMargin - m_botMargin; + int scopeWidth = (width() - m_rightMargin)/2 - m_leftMargin; + + // X display + + m_glScopeRect1 = QRectF( + (float) m_leftMargin / (float) width(), + (float) m_topMargin / (float) height(), + (float) scopeWidth / (float) width(), + (float) scopeHeight / (float) height() + ); + m_glScopeMatrix1.setToIdentity(); + m_glScopeMatrix1.translate ( + -1.0f + ((float) 2*m_leftMargin / (float) width()), + 1.0f - ((float) 2*m_topMargin / (float) height()) + ); + m_glScopeMatrix1.scale ( + (float) 2*scopeWidth / (float) width(), + (float) -2*scopeHeight / (float) height() + ); + + m_glBot1ScaleMatrix.setToIdentity(); + m_glBot1ScaleMatrix.translate ( + -1.0f + ((float) 2*m_leftMargin / (float) width()), + 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) + ); + m_glBot1ScaleMatrix.scale ( + (float) 2*scopeWidth / (float) width(), + (float) -2*(m_botMargin - 1) / (float) height() + ); + + m_glLeft1ScaleMatrix.setToIdentity(); + m_glLeft1ScaleMatrix.translate ( + -1.0f, + 1.0f - ((float) 2*m_topMargin / (float) height()) + ); + m_glLeft1ScaleMatrix.scale ( + (float) 2*(m_leftMargin-1) / (float) width(), + (float) -2*scopeHeight / (float) height() + ); + + // Y display + + m_glScopeRect2 = QRectF( + (float)(m_leftMargin + m_leftMargin + ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2)) / (float)width(), + (float)m_topMargin / (float)height(), + (float)((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2) / (float)width(), + (float)(height() - m_topMargin - m_botMargin) / (float)height() + ); + m_glScopeMatrix2.setToIdentity(); + m_glScopeMatrix2.translate ( + -1.0f + ((float) 2*(m_leftMargin + m_leftMargin + ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2)) / (float) width()), + 1.0f - ((float) 2*m_topMargin / (float) height()) + ); + m_glScopeMatrix2.scale ( + (float) 2*((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2) / (float) width(), + (float) -2*(height() - m_topMargin - m_botMargin) / (float) height() + ); + + m_glBot2ScaleMatrix.setToIdentity(); + m_glBot2ScaleMatrix.translate ( + -1.0f + ((float) 2*(m_leftMargin + m_leftMargin + scopeWidth) / (float) width()), + 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) + ); + m_glBot2ScaleMatrix.scale ( + (float) 2*scopeWidth / (float) width(), + (float) -2*(m_botMargin - 1) / (float) height() + ); + + m_glLeft2ScaleMatrix.setToIdentity(); + m_glLeft2ScaleMatrix.translate ( + -1.0f + (float) 2*(m_leftMargin + scopeWidth) / (float) width(), + 1.0f - ((float) 2*m_topMargin / (float) height()) + ); + m_glLeft2ScaleMatrix.scale ( + (float) 2*(m_leftMargin-1) / (float) width(), + (float) -2*scopeHeight / (float) height() + ); + + { // X horizontal scale (X1) + m_x1Scale.setSize(scopeWidth); + + m_bot1ScalePixmap = QPixmap( + scopeWidth, + m_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); + } + } + } + + m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage()); + + } // X horizontal scale (X1) + + { // Y horizontal scale (X2) + m_x2Scale.setSize(scopeWidth); + m_bot2ScalePixmap = QPixmap( + scopeWidth, + m_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); + } + } + } + + m_glShaderBottom2Scale.initTexture(m_bot2ScalePixmap.toImage()); + } // Y horizontal scale (X2) + + { // X vertical scale (Y1) + m_y1Scale.setSize(scopeHeight); + + m_left1ScalePixmap = QPixmap( + m_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) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); + } + } + } + + m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage()); + } // X vertical scale (Y1) + + { // Y vertical scale (Y2) + m_y2Scale.setSize(scopeHeight); + + m_left2ScalePixmap = QPixmap( + m_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) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); + } + } + } + + m_glShaderLeft2Scale.initTexture(m_left2ScalePixmap.toImage()); + } // Y vertical scale (Y2) +} + void GLScopeNG::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) { ScopeVisNG::TraceData& traceData = (*m_tracesData)[highlightedTraceIndex]; diff --git a/sdrbase/gui/glscopeng.h b/sdrbase/gui/glscopeng.h index b3f5861d6..9d207d051 100644 --- a/sdrbase/gui/glscopeng.h +++ b/sdrbase/gui/glscopeng.h @@ -139,8 +139,9 @@ private: void applyConfig(); void setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex); - void setUniqueDisplays(); //!< Arrange displays when X and Y are unique on screen - void setVerticalDisplays(); //!< Arrange displays when X and Y are stacked vertically + void setUniqueDisplays(); //!< Arrange displays when X and Y are unique on screen + void setVerticalDisplays(); //!< Arrange displays when X and Y are stacked vertically + void setHorizontalDisplays(); //!< Arrange displays when X and Y are stacked horizontally protected slots: void cleanup(); diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index e9ce72326..4dde12de5 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -297,7 +297,7 @@ void GLScopeNGGUI::on_traceAdd_clicked(bool checked) if (ui->trace->value() == 0) { ui->onlyY->setEnabled(true); -// ui->horizontalXY->setEnabled(true); TODO: re-activate when these displays become active + ui->horizontalXY->setEnabled(true); // TODO: re-activate when these displays become active ui->verticalXY->setEnabled(true); // ui->polar->setEnabled(true); }