comparison trunk/src/Modules/Output/Graphics/GraphicsViewTime.cc @ 399:7bfed53caacf

- A few changes to get graphics working. In progress.
author tom@acousticscale.org
date Sat, 16 Oct 2010 22:27:03 +0000
parents 3ee03a6b95a0
children 69466da9745e
comparison
equal deleted inserted replaced
398:3ee03a6b95a0 399:7bfed53caacf
29 #include <stdio.h> 29 #include <stdio.h>
30 30
31 #include "Support/SignalBank.h" 31 #include "Support/SignalBank.h"
32 #include "Modules/Output/Graphics/GraphicsView.h" 32 #include "Modules/Output/Graphics/GraphicsView.h"
33 #include "Modules/Output/Graphics/GraphicsViewTime.h" 33 #include "Modules/Output/Graphics/GraphicsViewTime.h"
34
35 namespace aimc {
34 36
35 GraphicsViewTime::GraphicsViewTime(Parameters *pParam) 37 GraphicsViewTime::GraphicsViewTime(Parameters *pParam)
36 : GraphicsView(pParam) { 38 : GraphicsView(pParam) {
37 } 39 }
38 40
70 _S("%s [%.0f..%.0f Hz, %s scale]"), 72 _S("%s [%.0f..%.0f Hz, %s scale]"),
71 m_pAxisFreq->m_sLabel ? m_pAxisFreq->m_sLabel : "", 73 m_pAxisFreq->m_sLabel ? m_pAxisFreq->m_sLabel : "",
72 m_pAxisFreq->m_fMin, m_pAxisFreq->m_fMax, 74 m_pAxisFreq->m_fMin, m_pAxisFreq->m_fMax,
73 m_pAxisFreq->m_pScale->getName()); 75 m_pAxisFreq->m_pScale->getName());
74 m_pDev->gText2f(0.0025f, 0.35f, sTxt, true); 76 m_pDev->gText2f(0.0025f, 0.35f, sTxt, true);
75 if (m_bPlotScaled) { 77 snprintf(sTxt, sizeof(sTxt) / sizeof(sTxt[0]),
76 snprintf(sTxt, sizeof(sTxt) / sizeof(sTxt[0]), 78 _S("%s [%.2f..%.2f ms, %s scale]"),
77 _S("%s [cycles, %s scale]"), 79 m_pAxisX->m_sLabel ? m_pAxisX->m_sLabel : "",
78 m_pAxisX->m_sLabel ? m_pAxisX->m_sLabel : "", 80 m_pAxisX->m_fMin,
79 m_pAxisX->m_pScale->getName()); 81 m_pAxisX->m_fMax,
80 } else { 82 m_pAxisX->m_pScale->getName());
81 snprintf(sTxt, sizeof(sTxt) / sizeof(sTxt[0]), 83
82 _S("%s [%.2f..%.2f ms, %s scale]"),
83 m_pAxisX->m_sLabel ? m_pAxisX->m_sLabel : "",
84 m_pAxisX->m_fMin,
85 m_pAxisX->m_fMax,
86 m_pAxisX->m_pScale->getName());
87 }
88 m_pDev->gText2f(m_fMarginLeft, 0.0025f, sTxt, false); 84 m_pDev->gText2f(m_fMarginLeft, 0.0025f, sTxt, false);
89 85
90 // Frame time 86 // Frame time
91 snprintf(sTxt, sizeof(sTxt)/sizeof(sTxt[0]), _S("t=%.0f ms"), 87 //snprintf(sTxt, sizeof(sTxt)/sizeof(sTxt[0]), _S("t=%.0f ms"),
92 pBank->getSampleTime(0)); 88 // pBank->getSampleTime(0));
93 m_pDev->gText2f(0.8f, 0.0025f, sTxt, false); 89 //m_pDev->gText2f(0.8f, 0.0025f, sTxt, false);
94 } 90 }
95 91
96 void GraphicsViewTime::PlotData(const vector<float> &signal, 92 void GraphicsViewTime::PlotData(const vector<float> &signal,
97 float sample_rate, 93 float sample_rate,
98 float yOffset, 94 float yOffset,
99 float height, 95 float height,
100 float xScale) { 96 float xScale) {
101 AIM_ASSERT(pSig);
102 AIM_ASSERT(xScale >= 0 && xScale <= 1); 97 AIM_ASSERT(xScale >= 0 && xScale <= 1);
103 AIM_ASSERT(height > 0 && height <= 1); 98 AIM_ASSERT(height > 0 && height <= 1);
104 AIM_ASSERT(yOffset >= 0 && yOffset <= 1); 99 AIM_ASSERT(yOffset >= 0 && yOffset <= 1);
105 AIM_ASSERT(m_pAxisX && m_pAxisX->m_pScale); 100 AIM_ASSERT(m_pAxisX && m_pAxisX->m_pScale);
106 AIM_ASSERT(m_pAxisY && m_pAxisY->m_pScale); 101 AIM_ASSERT(m_pAxisY && m_pAxisY->m_pScale);
111 BeginDataStrip(); 106 BeginDataStrip();
112 107
113 // Draw the signal. 108 // Draw the signal.
114 float x = 0; 109 float x = 0;
115 float y = 0; 110 float y = 0;
116 for (int i = 0; i < signal.size(); i++) { 111 for (unsigned int i = 0; i < signal.size(); i++) {
117 // Find out where to draw and do so 112 // Find out where to draw and do so
118 x = xScale * i; 113 x = xScale * i;
119 y = signal[i]; 114 y = signal[i];
120 x = m_pAxisX->m_pScale->FromLinearScaled(x) + 0.5f; 115 x = m_pAxisX->m_pScale->FromLinearScaled(x) + 0.5f;
121 y = m_pAxisY->m_pScale->FromLinearScaled(y); 116 y = m_pAxisY->m_pScale->FromLinearScaled(y);
135 // Redraw the last point in case it's needed 130 // Redraw the last point in case it's needed
136 PlotDataPoint(x, yOffset, y, height, true); 131 PlotDataPoint(x, yOffset, y, height, true);
137 132
138 m_pDev->gEnd(); 133 m_pDev->gEnd();
139 } 134 }
135 } // namespace aimc