#include ".\plot.h" CPlot::CPlot(void) { m_yMin = 0; m_yMax = 127; m_xMin = 0; m_xMax = 1023; m_xPixels = m_yPixels = 1000000; } CPlot::~CPlot(void) { } // Translate position (0 .. MAX_CHANNELS) to pixel inline int CPlot::PositionToPixel(double pos) { return((int)(m_xPixels * double(pos - (m_xMin + 0.5f)) / double(m_xMax - m_xMin) + 0.5f)); } inline double CPlot::PixelToPosition(int pixel) { return(m_xMin + double(pixel) * double(m_xMax - m_xMin) / m_xPixels); } void CPlot::MovePlot(int xmin, int xmax, unsigned long ymin, unsigned long ymax) { int xmi = xmin; int xma = xmax; int dx = xmax - xmin; if (dx < MIN_PLOT_CHANNELS - 1) dx = MIN_PLOT_CHANNELS - 1; else if (dx >= MAX_CHANNELS) dx = MAX_CHANNELS - 1; if (xmi < 0) xmi = 0; xma = xmi + dx; if (xma >= MAX_CHANNELS) { xma = MAX_CHANNELS - 1; xmi = xma - dx; } if (int(m_xMin) != xmi || int(m_xMax) != xma) { m_xMin = xmi; m_xMax = xma; } }