mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python] matplotlib: make pyplot a submodule of matplotlib
This commit is contained in:
73
python/port/mod/matplotlib/pyplot/plot_view.cpp
Normal file
73
python/port/mod/matplotlib/pyplot/plot_view.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "plot_view.h"
|
||||
|
||||
namespace Matplotlib {
|
||||
|
||||
void PlotView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, KDColorWhite);
|
||||
|
||||
if (m_store->gridRequested()) {
|
||||
drawGrid(ctx, rect);
|
||||
}
|
||||
|
||||
if (m_store->axesRequested()) {
|
||||
drawAxes(ctx, rect);
|
||||
drawLabelsAndGraduations(ctx, rect, Axis::Vertical, true);
|
||||
drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, true);
|
||||
}
|
||||
|
||||
for (PlotStore::Dot dot : m_store->dots()) {
|
||||
traceDot(ctx, rect, dot);
|
||||
}
|
||||
|
||||
for (PlotStore::Label label : m_store->labels()) {
|
||||
traceLabel(ctx, rect, label);
|
||||
}
|
||||
|
||||
for (PlotStore::Segment segment : m_store->segments()) {
|
||||
traceSegment(ctx, rect, segment);
|
||||
}
|
||||
|
||||
for (PlotStore::Rect rectangle : m_store->rects()) {
|
||||
traceRect(ctx, rect, rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
void PlotView::traceDot(KDContext * ctx, KDRect r, PlotStore::Dot dot) const {
|
||||
drawDot(ctx, r, dot.x(), dot.y(), dot.color());
|
||||
}
|
||||
|
||||
void PlotView::traceSegment(KDContext * ctx, KDRect r, PlotStore::Segment segment) const {
|
||||
drawSegment(
|
||||
ctx, r,
|
||||
segment.xStart(), segment.yStart(),
|
||||
segment.xEnd(), segment.yEnd(),
|
||||
segment.color()
|
||||
);
|
||||
if (segment.isArrow()) {
|
||||
float dx = segment.xEnd() - segment.xStart();
|
||||
float dy = segment.yEnd() - segment.yStart();
|
||||
drawArrow(ctx, r, segment.xEnd(), segment.yEnd(), dx, dy, segment.color());
|
||||
}
|
||||
}
|
||||
|
||||
void PlotView::traceRect(KDContext * ctx, KDRect r, PlotStore::Rect rect) const {
|
||||
KDRect pixelRect(
|
||||
floatToPixel(Axis::Horizontal, rect.x()),
|
||||
floatToPixel(Axis::Vertical, rect.y()),
|
||||
rect.width() / pixelWidth(),
|
||||
rect.height() / pixelHeight()
|
||||
);
|
||||
ctx->fillRect(pixelRect, rect.color());
|
||||
}
|
||||
|
||||
void PlotView::traceLabel(KDContext * ctx, KDRect r, PlotStore::Label label) const {
|
||||
drawLabel(ctx, r,
|
||||
label.x(), label.y(), label.string(),
|
||||
KDColorBlack,
|
||||
RelativePosition::None,
|
||||
RelativePosition::None
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user