Files
Renderive/YSGraphic_Core/plottable/Planisphere.cpp
T
2026-07-23 11:10:17 +08:00

60 lines
2.0 KiB
C++

#include <utility>
#include "Planisphere_p.h"
#include "../Axis/AbsAxis_p.h"
namespace YSG {
Q_Ptr_cpp(Planisphere)
PROP_P(Planisphere, Axis*, IAxis)
PROP_P(Planisphere, Axis*, QAxis)
PROP_P(Planisphere, Range, IRange)
PROP_P(Planisphere, Range, QRange)
PROP_P(Planisphere, QColor, pointColor)
PROP_P(Planisphere, QColor, anchorColor)
PROP_P(Planisphere, int, continueMillisecond)
PROP_P(Planisphere, Planisphere_Type, type)
void Planisphere::giveData(QPointF pos) {
if(!ok()) return;
if(!mPlot->isVisible()) return;
INIT_SET(Planisphere)
td->mDataList.push_back({pos});
}
Planisphere::Builder::Builder(Axis* IAxis, Axis* QAxis) {
ASSERT(IAxis->mPlot != nullptr, "Afterglow build error! IAxis->mPlot == nullptr");
ASSERT(IAxis->mPlot == QAxis->mPlot, "Afterglow build error! IAxis->mPlot != QAxis->mPlot");
plot = IAxis->mPlot;
this->IAxis = IAxis;
this->QAxis = QAxis;
}
Planisphere* Planisphere::Builder::build() {
auto ret = new Planisphere();
ret->init(plot, layerName);
PlanispherePrivate* pd = ret->d();
PlanisphereRenderState* sc = reinterpret_cast<PlanisphereRenderState*>(pd->state(State_Edit));
PROP_R(Axis*, IAxis)
PROP_R(Axis*, QAxis)
PROP_R(Range, IRange)
PROP_R(Range, QRange)
PROP_R(QColor, pointColor)
PROP_R(QColor, anchorColor)
PROP_R(int, continueMillisecond)
PROP_R(Planisphere_Type, type)
return ret;
}
void Planisphere::setToAxisCenter() {
PlanisphereRenderState *s = reinterpret_cast<PlanisphereRenderState*>(d()->state(State_Edit));
double w = mPlot->width(), h = mPlot->height();
double l = w < h ? w : h;
double iL = s->IAxis->coordRange().size()/w * l/2;
double qL = s->QAxis->coordRange().size()/h * l/2;
double im = s->IAxis->coordRange().middle(), qm = s->IAxis->coordRange().middle();
set_IRange({im-iL, im+iL});
set_QRange({qm-qL, qm+qL});
}
}