Program Listing for File AxisEqualizer.hpp

Return to documentation for file (sinspekto/AxisEqualizer.hpp)

#pragma once

#include <map>
#include <utility>
#include <QObject>
#include <QPointF>
#include <QRectF>

class AxisEqualizer : public QObject
{
  Q_OBJECT
  Q_PROPERTY(QPointF bboxX READ bboxX NOTIFY boundingBoxChanged)
  Q_PROPERTY(QPointF bboxY READ bboxY NOTIFY boundingBoxChanged)
  Q_PROPERTY(QPointF equalAxisX READ equalAxisX NOTIFY equalAxisChanged)
  Q_PROPERTY(QPointF equalAxisY READ equalAxisY NOTIFY equalAxisChanged)
  Q_PROPERTY(QRectF plotArea READ plotArea WRITE setPlotArea NOTIFY plotAreaChanged)
//  Q_PROPERTY(double marginPercent MEMBER m_marginPercent NOTIFY marginPercentChanged)

public:
  explicit AxisEqualizer(QObject *parent = nullptr);
  virtual ~AxisEqualizer();

  QPointF bboxX() const;
  QPointF bboxY() const;
  QPointF equalAxisX() const;
  QPointF equalAxisY() const;
  QRectF plotArea() const;

signals:
  void boundingBoxChanged(QPointF bboxX, QPointF bboxY);
  void equalAxisChanged(QPointF axisX, QPointF axisY);
  void plotAreaChanged(QRectF plotArea);
  //void marginPercentChanged(double margin);

public slots:
  void registerBox(const QString& seriesName, const QPointF& xR, const QPointF& yR);
  void calculateEqualAxes();
  void evaluateBoundingBox();
  void setPlotArea(QRectF plotArea);

protected:
  std::map<QString, std::pair<QPointF, QPointF>> m_ranges;
  std::pair<QPointF, QPointF> m_bbox;
  std::pair<QPointF, QPointF> m_equalAxes;
  QRectF m_plotArea;
  //double m_marginPercent;
};