27 QPen crosshair_pen(Qt::red);
28 crosshair_pen.setWidth(3);
29 vertical_crosshair_->
setPen(crosshair_pen);
30 horizontal_crosshair_->
setPen(crosshair_pen);
42 vertical_crosshair_->
setLayer(
"crosshairs");
43 horizontal_crosshair_->
setLayer(
"crosshairs");
51 rect_position_ = QPair<int, int>(0, 1);
52 color_scale_position_ = QPair<int, int>(0, 0);
55 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
58 color_scale_->
setLayer(
"colorscale");
79 if ((x.n_elem != y.n_elem) || (x.n_elem != z.n_elem) || (y.n_elem != z.n_elem))
80 throw std::invalid_argument(
"Vector sizes do not match!");
84 vec unique_x = sort(unique(x_));
85 vec unique_y = sort(unique(y_));
86 uword x_size = unique_x.n_rows;
87 uword y_size = unique_y.n_rows;
88 x_step_ = unique_x(1) - unique_x(0);
89 y_step_ = unique_y(1) - unique_y(0);
91 QCPRange x_range(x_.min(), x_.max());
92 QCPRange y_range(y_.min(), y_.max());
98 for (uword i = 0; i < x.n_elem; ++i){
104 QCPRange x_axis_range(x_range.lower - (x_step_ / 2.0), x_range.upper + (x_step_ / 2.0));
105 QCPRange y_axis_range(y_range.lower - (y_step_ / 2.0), y_range.upper + (y_step_ / 2.0));
114 color_scale_ = scale;
138 double x_min = x_.min();
139 double x_max = x_.max();
140 double y_min = y_.min();
141 double y_max = y_.max();
142 double x_center = (x_min + x_max) / 2.0;
143 double y_center = (y_min + y_max) / 2.0;
145 vec xdif = arma::abs(x_ - x_center);
146 vec ydif = arma::abs(y_ - y_center);
147 x_center = x_(xdif.index_min());
148 y_center = y_(ydif.index_min());
178 double x_pos = vertical_crosshair_->
point1->
coords().x();
179 double y_pos = horizontal_crosshair_->
point1->
coords().y();
181 if (x_pos > x_.max()) x_pos = x_.max();
182 if (x_pos < x_.min()) x_pos = x_.min();
183 if (y_pos > y_.max()) y_pos = y_.max();
184 if (y_pos < y_.min()) y_pos = y_.min();
186 vec xy = arma::abs(x_ - x_pos) + arma::abs(y_ - y_pos);
187 uword index = xy.index_min();
208 QPointF point1_pos = vertical_crosshair_->
point1->
coords();
209 QPointF point2_pos = vertical_crosshair_->
point2->
coords();
211 double new_x = point1_pos.x() + double(units)*x_step_;
212 new_x = (new_x > x_.max() ? x_.max() : new_x);
213 new_x = (new_x < x_.min() ? x_.min() : new_x);
215 point1_pos.setX(new_x);
216 point2_pos.setX(new_x);
230 QPointF point1_pos = horizontal_crosshair_->
point1->
coords();
231 QPointF point2_pos = horizontal_crosshair_->
point2->
coords();
232 double new_y = point1_pos.y() + double(units)*y_step_;
233 new_y = (new_y > y_.max() ? y_.max() : new_y);
234 new_y = (new_y < y_.min() ? y_.min() : new_y);
236 point1_pos.setY(new_y);
237 point2_pos.setY(new_y);
316 return color_scale_->
label();
327 vec ticks = linspace(min, max, count);
328 qvec tick_qv = qvec::fromStdVector(conv_to<stdvec>::from(ticks));
336 QVector<QString> tick_labels;
337 QVector<double> tick_vector;
338 double tick_step = (z_.max() - z_.min())/count;
344 for (
size_t i = 0; i < count; ++i){
345 tick_vector.push_back(z_.min() + (tick_step / 2.0) + (double(i) * tick_step));
346 tick_labels.push_back(QString::number(i+1));
QCPLayoutGrid * plotLayout() const
A margin group allows synchronization of margin sides if working with multiple layout elements...
void SetGradient(QCPColorGradient gradient)
QString ColorScaleLabel() const
void ColorScaleVisible(bool visible)
void setAutoTickLabels(bool on)
void setKeySize(int keySize)
void setType(QCPAxis::AxisType type)
Q_SLOT bool setLayer(QCPLayer *layer)
void setVisible(bool visible)
bool remove(QCPLayoutElement *element)
Q_SLOT void setDataRange(const QCPRange &dataRange)
const QCPRange range() const
QCPColorMapData * data() const
void SetMapData(const vec &x, const vec &y, const vec &z)
MapPlot::SetMapData.
void SetFonts(const QFont &font)
void setAutoTickStep(bool on)
void setSubTickCount(int count)
void setAutoTicks(bool on)
void rescaleDataRange(bool onlyVisibleMaps)
QCPColorGradient gradient
void setAutoSubTicks(bool on)
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
void setInterpolate(bool interpolate)
void setCoords(double key, double value)
void CrossHairsVisible(bool visible)
bool addElement(int row, int column, QCPLayoutElement *element)
void setValueSize(int valueSize)
void MoveHorizontalCrosshair(int units)
MapPlot::MoveHorizontalCrosshair.
void setColorScale(QCPColorScale *colorScale)
void setAutoTickCount(int approximateCount)
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint)
void SetColorScale(QCPColorScale *scale)
void setTickLabelFont(const QFont &font)
void setData(double key, double value, double z)
Q_SLOT void setGradient(const QCPColorGradient &gradient)
void ShowCrosshairs(bool show)
void CenterCrosshairs()
MapPlot::CenterCrosshairs Positions the crosshairs in the center of the map.
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
void MoveVerticalCrosshair(int units)
MapPlot::MoveVerticalCrosshair.
QCPLayer * layer(const QString &name) const
bool addItem(QCPAbstractItem *item)
void CoordinatesChanged(double x, double y, double z)
bool addPlottable(QCPAbstractPlottable *plottable)
void rescaleDataRange(bool recalculateDataBounds=false)
void setTickVector(const QVector< double > &vec)
void SetClusterTicks(size_t count)
void setFont(const QFont &font)
Q_SLOT void setGradient(const QCPColorGradient &gradient)
QCPAxis * keyAxis() const
void setDataRange(const QCPRange &dataRange)
void SetColorScaleTickCount(int ticks)
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false)
A straight line that spans infinitely in both directions.
void setTightBoundary(bool enabled)
A color scale for use with color coding data such as QCPColorMap.
MapPlot(QWidget *parent=0)
uword GetCrosshairPosition()
void setKeyRange(const QCPRange &keyRange)
void SpectrumRequested(size_t index)
void setTickVectorLabels(const QVector< QString > &vec)
0x01 Axis is vertical and on the left side of the axis rect
void SetColorScaleTicks(double min, double max, size_t count)
QCPAxisRect * axisRect(int index=0) const
void setInterpolate(bool enabled)
The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot...
Q_SLOT void setDataRange(const QCPRange &dataRange)
QCPItemPosition *const point1
void setLabelFont(const QFont &font)
void SaveImage(QString filename)
void rescaleDataRange(bool onlyVisibleMaps=false)
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group)
A plottable representing a two-dimensional color map in a plot.
QCPAxis * valueAxis() const
QCPItemPosition *const point2
void SetGlobalColorGradient(Vespucci::GlobalGradient gradient)
bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove)
void setValueRange(const QCPRange &valueRange)
Defines a color gradient for use with e.g. QCPColorMap.
Represents the range an axis is encompassing.
QCPRange dataRange() const
void SetColorScaleLabel(const QString &label_text)
Holds multiple axes and arranges them in a rectangular shape.
Q_SLOT void setRange(const QCPRange &range)
void setLabel(const QString &str)
void setPen(const QPen &pen)
bool SavePlot(QCustomPlot *plot, QString filename)
Vespucci::SavePlot.