110 lines
4.2 KiB
C++
110 lines
4.2 KiB
C++
#include <utility>
|
|
#include "../Axis/Abs_Axis_p.h"
|
|
#include "Planisphere_p.h"
|
|
namespace YSG {
|
|
using Planisphere_Binding = Renderable_Binding<Planisphere, Planisphere_Private, Planisphere_Render_State, Planisphere_Input_Data>;
|
|
Planisphere::Planisphere() {
|
|
Planisphere_Binding::init(this, "Planisphere");
|
|
}
|
|
Planisphere_Private* Planisphere::d() {
|
|
return Planisphere_Binding::d(this);
|
|
}
|
|
Render_Data* Planisphere::create_render_data() {
|
|
return Planisphere_Binding::create_render_data();
|
|
}
|
|
Render_State* Planisphere::create_render_state() {
|
|
return Planisphere_Binding::create_render_state();
|
|
}
|
|
Input_Data* Planisphere::create_input_data() {
|
|
return Planisphere_Binding::create_input_data();
|
|
}
|
|
Axis* Planisphere::i_axis(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::i_axis, src);
|
|
}
|
|
void Planisphere::set_i_axis(Axis* value) {
|
|
d()->set_state_value(&Planisphere_Render_State::i_axis, value);
|
|
}
|
|
Axis* Planisphere::q_axis(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::q_axis, src);
|
|
}
|
|
void Planisphere::set_q_axis(Axis* value) {
|
|
d()->set_state_value(&Planisphere_Render_State::q_axis, value);
|
|
}
|
|
Range Planisphere::i_range(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::i_range, src);
|
|
}
|
|
void Planisphere::set_i_range(Range value) {
|
|
d()->set_state_value(&Planisphere_Render_State::i_range, std::move(value));
|
|
}
|
|
Range Planisphere::q_range(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::q_range, src);
|
|
}
|
|
void Planisphere::set_q_range(Range value) {
|
|
d()->set_state_value(&Planisphere_Render_State::q_range, std::move(value));
|
|
}
|
|
QColor Planisphere::point_color(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::point_color, src);
|
|
}
|
|
void Planisphere::set_point_color(QColor value) {
|
|
d()->set_state_value(&Planisphere_Render_State::point_color, std::move(value));
|
|
}
|
|
QColor Planisphere::anchor_color(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::anchor_color, src);
|
|
}
|
|
void Planisphere::set_anchor_color(QColor value) {
|
|
d()->set_state_value(&Planisphere_Render_State::anchor_color, std::move(value));
|
|
}
|
|
int Planisphere::continue_millisecond(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::continue_millisecond, src);
|
|
}
|
|
void Planisphere::set_continue_millisecond(int value) {
|
|
d()->set_state_value(&Planisphere_Render_State::continue_millisecond, value);
|
|
}
|
|
Planisphere_Type Planisphere::type(SRC src) {
|
|
return d()->state_value(&Planisphere_Render_State::type, src);
|
|
}
|
|
void Planisphere::set_type(Planisphere_Type value) {
|
|
d()->set_state_value(&Planisphere_Render_State::type, value);
|
|
}
|
|
void Planisphere::give_data(QPointF pos) {
|
|
if (!ok())
|
|
return;
|
|
if (!mPlot->isVisible())
|
|
return;
|
|
Render_Input_Lease<Planisphere_Private, Planisphere_Input_Data> input(d());
|
|
input->mDataList.push_back({pos});
|
|
}
|
|
Planisphere::Builder::Builder(Axis* i_axis, Axis* q_axis) {
|
|
ASSERT(i_axis->mPlot != nullptr, "Afterglow build error! i_axis->mPlot == nullptr");
|
|
ASSERT(i_axis->mPlot == q_axis->mPlot, "Afterglow build error! i_axis->mPlot != q_axis->mPlot");
|
|
plot = i_axis->mPlot;
|
|
this->i_axis = i_axis;
|
|
this->q_axis = q_axis;
|
|
}
|
|
Planisphere* Planisphere::Builder::build() {
|
|
auto ret = new Planisphere();
|
|
ret->init(plot, layerName);
|
|
Planisphere_Private* pd = ret->d();
|
|
Planisphere_Render_State* sc = reinterpret_cast<Planisphere_Render_State*>(pd->state(State_Edit));
|
|
PROP_R(Axis*, i_axis)
|
|
PROP_R(Axis*, q_axis)
|
|
PROP_R(Range, i_range)
|
|
PROP_R(Range, q_range)
|
|
PROP_R(QColor, point_color)
|
|
PROP_R(QColor, anchor_color)
|
|
PROP_R(int, continue_millisecond)
|
|
PROP_R(Planisphere_Type, type)
|
|
return ret;
|
|
}
|
|
void Planisphere::set_to_axis_center() {
|
|
Planisphere_Render_State* s = reinterpret_cast<Planisphere_Render_State*>(d()->state(State_Edit));
|
|
double w = mPlot->width(), h = mPlot->height();
|
|
double l = w < h ? w : h;
|
|
double iL = s->i_axis->coord_range().size() / w * l / 2;
|
|
double qL = s->q_axis->coord_range().size() / h * l / 2;
|
|
double im = s->i_axis->coord_range().middle(), qm = s->i_axis->coord_range().middle();
|
|
set_i_range({im - iL, im + iL});
|
|
set_q_range({qm - qL, qm + qL});
|
|
}
|
|
} // namespace YSG
|