Commit 6cf55ee7 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

implement plot_add

parent 9178ec79
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ add_library(signaltk STATIC
    graphics/text_shaper.cc
    graphics/rasterize.cc
    graphics/png.cc
    elements/context.cc
    elements/plot/gridlines.cc
    elements/plot/axes.cc
    elements/plot/plot_domain.cc

elements/context.cc

0 → 100644
+25 −0
Original line number Diff line number Diff line
/**
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include "context.h"

namespace signaltk {

Status stack_add(
    Context* ctx,
    std::unique_ptr<ElementConfig> config) {
  ctx->elements.emplace(ElementRef {
    .config = std::move(config)
  });

  return Status::OK;
}

} // namespace signaltk
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ Status stack_head_config(Context* ctx, T** head);
template <typename T>
Status stack_head_config(const Context& ctx, T const** head);

Status stack_add(
    Context* ctx,
    std::unique_ptr<ElementConfig> config);

} // namespace signaltk

#include "context_impl.h"
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ struct AxisDefinition {
  double tick_length_rem;
};

Status plot_add(Context* ctx);
Status plot_axis_add(Context* ctx, AxisPosition pos);
Status plot_axis_addtick(Context* ctx, float offset);
Status plot_axis_addlabel(Context* ctx, float offset, const char* label);
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@

namespace signaltk {

Status plot_add(Context* ctx) {
  stack_add(ctx, std::make_unique<PlotConfig>());
  return OK;
}

Status plot_render(Context* ctx) {
  PlotConfig* elem;
  if (auto rc = stack_head_config(ctx, &elem); rc) {
Loading