55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include "heightmap.h"
|
|
|
|
namespace grbl {
|
|
|
|
enum class instruction_type {
|
|
gcode,
|
|
comment,
|
|
user_message
|
|
};
|
|
|
|
struct instruction {
|
|
static instruction new_gcode(size_t line, std::string cmd, std::string comment = "");
|
|
static instruction new_user_message(size_t line, std::string comment = "");
|
|
static instruction new_comment(size_t line, std::string comment = "");
|
|
|
|
size_t line = 0;
|
|
instruction_type type = instruction_type::comment;
|
|
std::string command;
|
|
std::string comment;
|
|
};
|
|
|
|
|
|
|
|
struct program {
|
|
program() = default;
|
|
explicit program(std::string filename);
|
|
|
|
bool load_from_file(std::string filename);
|
|
bool load_from_stream(std::istream& in);
|
|
bool load_from_string(const std::string& content);
|
|
bool load_from_lines(std::vector<std::string> lines);
|
|
|
|
void dump(std::ostream& out);
|
|
|
|
size_t number_of_instructions() const {
|
|
return instructions.size();
|
|
}
|
|
|
|
instruction instruction_at(size_t index) {
|
|
return instructions.at(index);
|
|
}
|
|
bool is_loaded = false;
|
|
std::string filename;
|
|
std::vector<instruction> instructions{};
|
|
grbl::program apply_heightmap(grbl::heightmap& grid);
|
|
void save(std::string path);
|
|
};
|
|
|
|
}
|