]> git.cworth.org Git - apitrace/commitdiff
Allow visualizaing data with starting offsets.
authorZack Rusin <zack@kde.org>
Thu, 7 Apr 2011 23:38:40 +0000 (19:38 -0400)
committerZack Rusin <zack@kde.org>
Thu, 7 Apr 2011 23:38:40 +0000 (19:38 -0400)
gui/mainwindow.cpp
gui/ui/mainwindow.ui
gui/vertexdatainterpreter.cpp
gui/vertexdatainterpreter.h

index 380ef8a132a679fc5cdcbc2f4b100dcef7ed2b3f..f3aed9f5e15bf841d5969d6e592b7d385c78ea56 100644 (file)
@@ -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);
index d0d14264c71869ebc495b97f7a861beb736b88c2..7d39a16820bc72ccab7edc733b5d74dc3bce3837 100644 (file)
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
       <layout class="QFormLayout" name="formLayout">
+       <property name="fieldGrowthPolicy">
+        <enum>QFormLayout::ExpandingFieldsGrow</enum>
+       </property>
        <item row="0" column="0">
         <widget class="QLabel" name="label">
          <property name="text">
          </property>
         </widget>
        </item>
-       <item row="3" column="0" colspan="2">
-        <layout class="QHBoxLayout" name="horizontalLayout_3">
-         <item>
-          <spacer name="horizontalSpacer">
-           <property name="orientation">
-            <enum>Qt::Horizontal</enum>
-           </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>40</width>
-             <height>20</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-         <item>
-          <widget class="QPushButton" name="vertexInterpretButton">
-           <property name="text">
-            <string>Interpret</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <spacer name="horizontalSpacer_2">
-           <property name="orientation">
-            <enum>Qt::Horizontal</enum>
-           </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>40</width>
-             <height>20</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-        </layout>
+       <item row="3" column="0">
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string>Starting Offset</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <widget class="QSpinBox" name="startingOffsetSB"/>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_3">
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QPushButton" name="vertexInterpretButton">
+         <property name="text">
+          <string>Interpret</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
        </item>
       </layout>
      </item>
index 7e3616e35b517f079270a9dcc3b33e3ac28151d2..c5cdd45d19b8434338eb9344fb3aa5e91c28e46a 100644 (file)
@@ -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<float>(m_data, m_type, m_stride, m_components);
+        lst = convertData<float>(m_data, m_type, m_stride, m_components,
+                                 m_startingOffset);
         break;
     case GL_UNSIGNED_BYTE:
-        lst = convertData<quint8>(m_data, m_type, m_stride, m_components);
+        lst = convertData<quint8>(m_data, m_type, m_stride, m_components,
+                                  m_startingOffset);
         break;
     case GL_BYTE:
-        lst = convertData<qint8>(m_data, m_type, m_stride, m_components);
+        lst = convertData<qint8>(m_data, m_type, m_stride, m_components,
+                                 m_startingOffset);
         break;
     case GL_SHORT:
-        lst = convertData<qint16>(m_data, m_type, m_stride, m_components);
+        lst = convertData<qint16>(m_data, m_type, m_stride, m_components,
+                                  m_startingOffset);
         break;
     case GL_UNSIGNED_SHORT:
-        lst = convertData<quint16>(m_data, m_type, m_stride, m_components);
+        lst = convertData<quint16>(m_data, m_type, m_stride, m_components,
+                                   m_startingOffset);
         break;
     case GL_INT:
-        lst = convertData<unsigned int>(m_data, m_type, m_stride, m_components);
+        lst = convertData<unsigned int>(m_data, m_type, m_stride, m_components,
+                                        m_startingOffset);
         break;
     case GL_UNSIGNED_INT:
-        lst = convertData<int>(m_data, m_type, m_stride, m_components);
+        lst = convertData<int>(m_data, m_type, m_stride, m_components,
+                               m_startingOffset);
         break;
     case GL_DOUBLE:
-        lst = convertData<double>(m_data, m_type, m_stride, m_components);
+        lst = convertData<double>(m_data, m_type, m_stride, m_components,
+                                  m_startingOffset);
         break;
     default:
         qDebug()<<"unkown gltype = "<<m_type;
@@ -214,4 +225,14 @@ void VertexDataInterpreter::setTypeFromString(const QString &str)
     }
 }
 
+int VertexDataInterpreter::startingOffset() const
+{
+    return m_startingOffset;
+}
+
+void VertexDataInterpreter::setStartingOffset(int offset)
+{
+    m_startingOffset = offset;
+}
+
 #include "vertexdatainterpreter.moc"
index 8492593f8cd0d62aaa5e3517ad289627e308a3ff..7a46e3e5a1683605127cac194026824ab8b0e1a3 100644 (file)
@@ -16,6 +16,7 @@ public:
     int type() const;
     int stride() const;
     int components() const;
+    int startingOffset() const;
 
     void setListWidget(QListWidget *listWidget);
 
@@ -27,6 +28,7 @@ public slots:
     void setStride(int stride);
     void setComponents(int num);
     void setType(int type);
+    void setStartingOffset(int offset);
 
 private:
     QListWidget *m_listWidget;
@@ -34,6 +36,7 @@ private:
     int m_type;
     int m_stride;
     int m_components;
+    int m_startingOffset;
 };
 
 #endif