From 1b91705727d2b9f91345b6d4a462650cb1007618 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 7 Apr 2011 19:38:40 -0400 Subject: [PATCH] Allow visualizaing data with starting offsets. --- gui/mainwindow.cpp | 4 ++ gui/ui/mainwindow.ui | 85 ++++++++++++++++++++--------------- gui/vertexdatainterpreter.cpp | 49 ++++++++++++++------ gui/vertexdatainterpreter.h | 3 ++ 4 files changed, 91 insertions(+), 50 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 380ef8a..f3aed9f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -52,6 +52,8 @@ MainWindow::MainWindow() m_ui.vertexStrideSB->value()); m_vdataInterpreter->setComponents( m_ui.vertexComponentsSB->value()); + m_vdataInterpreter->setStartingOffset( + m_ui.startingOffsetSB->value()); m_vdataInterpreter->setTypeFromString( m_ui.vertexTypeCB->currentText()); @@ -63,6 +65,8 @@ MainWindow::MainWindow() m_vdataInterpreter, SLOT(setStride(int))); connect(m_ui.vertexComponentsSB, SIGNAL(valueChanged(int)), m_vdataInterpreter, SLOT(setComponents(int))); + connect(m_ui.startingOffsetSB, SIGNAL(valueChanged(int)), + m_vdataInterpreter, SLOT(setStartingOffset(int))); m_model = new ApiTraceModel(); m_model->setApiTrace(m_trace); diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index d0d1426..7d39a16 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -176,6 +176,9 @@ + + QFormLayout::ExpandingFieldsGrow + @@ -267,42 +270,52 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Interpret - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + Starting Offset + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Interpret + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + diff --git a/gui/vertexdatainterpreter.cpp b/gui/vertexdatainterpreter.cpp index 7e3616e..c5cdd45 100644 --- a/gui/vertexdatainterpreter.cpp +++ b/gui/vertexdatainterpreter.cpp @@ -39,23 +39,25 @@ static QStringList convertData(const QByteArray &dataArray, int type, int stride, - int numComponents) + int numComponents, + int startingOffset) { QStringList strings; - const char *data = dataArray.constData(); + int dataSize = dataArray.size() - startingOffset; + const char *data = dataArray.constData() + startingOffset; int typeSize = sizeForType(type); int elementSize = numComponents * typeSize; if (!stride) stride = elementSize; - int numElements = dataArray.size() / stride; + int numElements = dataSize / stride; if ((numElements % numComponents) != 0) { - int temp = qFloor(dataArray.size() / (float)stride); + int temp = qFloor(dataSize / (float)stride); int fullElemSize = temp * stride; - if (fullElemSize + numComponents * typeSize <= dataArray.size()){ + if (fullElemSize + numComponents * typeSize <= dataSize) { /* num full elements plus the part of the buffer in which we fit */ numElements = temp + 1; } else { @@ -96,7 +98,8 @@ VertexDataInterpreter::VertexDataInterpreter(QObject *parent) m_listWidget(0), m_type(GL_FLOAT), m_stride(16), - m_components(4) + m_components(4), + m_startingOffset(0) { } @@ -160,28 +163,36 @@ void VertexDataInterpreter::interpretData() QStringList lst; switch(m_type) { case GL_FLOAT: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_UNSIGNED_BYTE: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_BYTE: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_SHORT: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_UNSIGNED_SHORT: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_INT: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_UNSIGNED_INT: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; case GL_DOUBLE: - lst = convertData(m_data, m_type, m_stride, m_components); + lst = convertData(m_data, m_type, m_stride, m_components, + m_startingOffset); break; default: qDebug()<<"unkown gltype = "<