Skip to content
Snippets Groups Projects
Commit 0a452a50 authored by Wuttke, Joachim's avatar Wuttke, Joachim Committed by Wuttke, Joachim
Browse files

inline fcts itemXrange etc

parent af811c76
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,14 @@ const int replot_update_interval = 10;
const int colorbar_width_logz = 50;
const int colorbar_width = 80;
// Converts xmin (low edge of first bin) and xmax (upper edge of last bin) to the
// range expected by QCPColorMapData::setRange.
QCPRange qcpRange(double xmin, double xmax, int nbins)
{
double dx = (xmax - xmin) / nbins;
return QCPRange(xmin + dx / 2., xmax - dx / 2.);
}
} // namespace
ColorMap::ColorMap(QWidget* parent)
......@@ -328,8 +336,8 @@ void ColorMap::setAxesRangeFromItem()
m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
m_customPlot->axisRect()->setupFullAxesBox(true);
m_colorMap->data()->setSize(ii->xSize(), ii->ySize());
m_colorMap->data()->setRange(GUI::View::RangeUtil::itemXrange(ii),
GUI::View::RangeUtil::itemYrange(ii));
m_colorMap->data()->setRange(qcpRange(ii->xMin(), ii->xMax(), ii->xSize()),
qcpRange(ii->yMin(), ii->yMax(), ii->ySize()));
replot();
}
......
......@@ -19,34 +19,11 @@
#include "GUI/Support/Util/StyleUtil.h"
#include <qcustomplot.h>
namespace {
// Converts xmin (low edge of first bin) and xmax (upper edge of last bin) to the
// range expected by QCPColorMapData::setRange.
QCPRange qcpRange(double xmin, double xmax, int nbins)
{
double dx = (xmax - xmin) / nbins;
return QCPRange(xmin + dx / 2., xmax - dx / 2.);
}
} // namespace
QCPRange GUI::View::RangeUtil::itemXrange(const IntensityDataItem* item)
{
return qcpRange(item->xMin(), item->xMax(), item->xSize());
}
QCPRange GUI::View::RangeUtil::itemZoomX(const IntensityDataItem* item)
{
return QCPRange(item->lowerX(), item->upperX());
}
QCPRange GUI::View::RangeUtil::itemYrange(const IntensityDataItem* item)
{
return qcpRange(item->yMin(), item->yMax(), item->ySize());
}
QCPRange GUI::View::RangeUtil::itemZoomY(const IntensityDataItem* item)
{
return QCPRange(item->lowerY(), item->upperY());
......
......@@ -26,15 +26,9 @@ class QCPRange;
namespace GUI::View::RangeUtil {
//! Returns x-axis range.
QCPRange itemXrange(const IntensityDataItem* item);
//! Returns x-axis vizible range (zoom).
QCPRange itemZoomX(const IntensityDataItem* item);
//! Returns y-axis range.
QCPRange itemYrange(const IntensityDataItem* item);
//! Returns y-axis vizible range (zoom).
QCPRange itemZoomY(const IntensityDataItem* item);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment