16 #include "Base/Axis/IAxis.h"
17 #include "Device/Data/Datafield.h"
24 #include <qcustomplot.h>
26 #include <boost/polymorphic_cast.hpp>
29 using boost::polymorphic_downcast;
33 , m_projectionType(std::move(projectionType))
34 , m_customPlot(new QCustomPlot)
35 , m_block_plot_update(false)
37 auto* vlayout =
new QVBoxLayout(
this);
38 vlayout->setMargin(0);
39 vlayout->setSpacing(0);
41 m_customPlot->setAttribute(Qt::WA_NoMousePropagation,
false);
60 m_customPlot->axisRect()->setMargins(QMargins(left, orig.top(), right, orig.bottom()));
156 pen.setColor(QColor(0, 0, 255, 200));
157 graph->setLineStyle(
intensityItem()->isInterpolated() ? QCPGraph::lsLine
158 : QCPGraph::lsStepCenter);
276 std::unique_ptr<Datafield> field;
280 double value = polymorphic_downcast<HorizontalLineItem*>(item)->posY();
281 field.reset(
m_field->xProjection(value));
283 double value = polymorphic_downcast<VerticalLineItem*>(item)->posX();
284 field.reset(
m_field->yProjection(value));
287 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
288 auto centers = field->axis(0).binCenters();
289 auto values = field->flatVector();
290 graph->setData(QVector<double>(centers.begin(), centers.end()),
291 QVector<double>(values.begin(), values.end()));
293 graph->setData(QVector<double>::fromStdVector(hist->binCenters()),
294 QVector<double>::fromStdVector(hist->binValues()));
301 graph->setLineStyle(isInterpolated ? QCPGraph::lsLine : QCPGraph::lsStepCenter);
Defines various axis items.
Defines class IntensityDataItem.
Defines MaskItems classes.
Defines various constants for plotting.
Defines items related to projections over color map.
Defines class ProjectionsPlot.
Defines RangeUtils namespace.
static bool isLogScalePropertyName(const QString &name)
static constexpr auto M_TYPE
static bool isBoundsPropertiesName(const QString &name)
either lower bound or upper bound property name
static bool isTitlePropertyName(const QString &name)
static constexpr auto M_TYPE
static constexpr auto M_TYPE
static bool isInterpolatedPropertyName(const QString &name)
ProjectionContainerItem * projectionContainerItem()
void unsubscribe(const void *caller)
Cancels all subscriptions of given caller.
void setOnAboutToRemoveChild(std::function< void(SessionItem *)> f, const void *caller=nullptr)
void setOnChildrenChange(std::function< void(SessionItem *)> f, const void *caller=nullptr)
Calls back when number of children has changed, reports newChild. newChild == nullptr denotes the cas...
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
void setOnValueChange(std::function< void(void)> f, const void *caller=nullptr)
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=nullptr)
Calls back on child property change, report childItem and property name.
A container to hold ProjectionItems, intended to store projections of color map on X,...
~ProjectionsPlot() override
QCustomPlot * m_customPlot
void updateProjectionsData()
Creates cached 2D histogram for later projection calculations.
IntensityDataItem * intensityItem()
std::unique_ptr< Datafield > m_field
void onIntensityItemPropertyChanged(const QString &propertyName)
Updates projection appearance (line style, etc)
QVector< SessionItem * > projectionItems()
void clearProjection(SessionItem *item)
Removes plot corresponding to given projection item.
void setGraphFromItem(QCPGraph *graph, SessionItem *item)
Sets the data to graph from given projection iten.
void onMarginsChanged(double left, double right)
void unsubscribeFromItem() override
void unsubscribeFromChildren()
void updateAxesRange()
Updates canva's axes to match current zoom level of IntensityDataItem.
void setLogz(bool isLogz)
QCPGraph * graphForItem(SessionItem *item)
void subscribeToItem() override
QMap< SessionItem *, QCPGraph * > m_item_to_graph
bool isHorizontalType()
Returns true, if widget is intended for horizontal projections.
void updateProjections()
Runs through all projection items and generates missed plots.
ProjectionContainerItem * projectionContainerItem()
void onAxisPropertyChanged(const QString &axisName, const QString &propertyName)
Updates zoom of projections in accordance with IntensityDataItem.
ProjectionsPlot(QString projectionType, QWidget *parent=nullptr)
void setInterpolate(bool isInterpolated)
void clearProjections()
Clears all graphs corresponding to projection items.
void onProjectionPropertyChanged(SessionItem *item, const QString &property)
Base class for a GUI data item.
QString itemName() const
Get item name, return display name if no name is set.
QVector< SessionItem * > childrenOfType(const QString &model_type) const
Returns a vector of all children of the given type.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString modelType() const
Get model type.
int plot_tick_label_size()
QString const & name(EShape k)
QCPRange itemZoomY(const IntensityDataItem *item)
Returns y-axis vizible range (zoom).
void setLogz(QCPColorScale *scale, bool isLogz)
void setDefaultMargins(QCustomPlot *customPlot)
Sets default margins for axes rectangle plot.
QCPRange itemDataZoom(const IntensityDataItem *item)
Returns z-axis visible range (zoom).
QCPRange itemZoomX(const IntensityDataItem *item)
Returns x-axis vizible range (zoom).