2018-06-19 15:43:59 +00:00
|
|
|
#ifndef APPCONTROLLER_HPP
|
|
|
|
#define APPCONTROLLER_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class Model;
|
|
|
|
class Print;
|
|
|
|
class PrintObject;
|
|
|
|
|
|
|
|
class AppControllerBoilerplate {
|
|
|
|
public:
|
|
|
|
|
|
|
|
using Path = std::string;
|
|
|
|
using PathList = std::vector<Path>;
|
|
|
|
|
|
|
|
enum class IssueType {
|
|
|
|
INFO,
|
|
|
|
WARN,
|
|
|
|
ERR,
|
|
|
|
FATAL
|
|
|
|
};
|
|
|
|
|
|
|
|
PathList query_destination_paths(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& extensions) const;
|
|
|
|
|
|
|
|
PathList query_destination_dirs(
|
|
|
|
const std::string& title) const;
|
|
|
|
|
|
|
|
Path query_destination_path(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& extensions) const;
|
|
|
|
|
|
|
|
void report_issue(IssueType issuetype,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& brief = "");
|
|
|
|
|
|
|
|
class ProgressIndicator {
|
|
|
|
float state_ = .0f, max_ = 1.f, step_;
|
|
|
|
public:
|
|
|
|
|
|
|
|
inline virtual ~ProgressIndicator() {}
|
|
|
|
|
|
|
|
float max() const { return max_; }
|
|
|
|
float state() const { return state_; }
|
|
|
|
|
|
|
|
virtual void max(float maxval) { max_ = maxval; }
|
|
|
|
virtual void state(float val) { state_ = val; }
|
|
|
|
virtual void state(unsigned st) { state_ = st * step_; }
|
|
|
|
virtual void states(unsigned statenum) {
|
|
|
|
step_ = max_ / statenum;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void message(const std::string&) = 0;
|
|
|
|
virtual void title(const std::string&) = 0;
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
virtual void messageFmt(const std::string& fmt, ...);
|
|
|
|
|
2018-06-19 15:43:59 +00:00
|
|
|
template<class T>
|
|
|
|
void update(T st, const std::string& msg) {
|
|
|
|
message(msg); state(st);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using ProgresIndicatorPtr = std::shared_ptr<ProgressIndicator>;
|
|
|
|
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
inline void progressIndicator(ProgresIndicatorPtr progrind) {
|
|
|
|
progressind_ = progrind;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void progressIndicator(unsigned statenum,
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& firstmsg = "") {
|
|
|
|
progressind_ = createProgressIndicator(statenum, title, firstmsg);
|
2018-06-19 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
inline ProgresIndicatorPtr progressIndicator() {
|
|
|
|
if(!progressind_)
|
|
|
|
progressind_ = createProgressIndicator(100, "Progress");
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
return progressind_;
|
2018-06-19 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
ProgresIndicatorPtr createProgressIndicator(
|
|
|
|
unsigned statenum,
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& firstmsg = "") const;
|
|
|
|
|
2018-06-19 15:43:59 +00:00
|
|
|
private:
|
2018-06-20 12:50:18 +00:00
|
|
|
ProgresIndicatorPtr progressind_;
|
2018-06-19 15:43:59 +00:00
|
|
|
};
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
class PrintController: public AppControllerBoilerplate {
|
|
|
|
Print *print_ = nullptr;
|
|
|
|
protected:
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
void make_skirt();
|
|
|
|
void make_brim();
|
|
|
|
void make_wipe_tower();
|
2018-06-19 15:43:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
using Ptr = std::unique_ptr<PrintController>;
|
|
|
|
|
|
|
|
explicit inline PrintController(Print *print): print_(print) {}
|
|
|
|
|
|
|
|
inline static Ptr create(Print *print) {
|
|
|
|
return std::make_unique<PrintController>(print);
|
|
|
|
}
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
void slice(PrintObject *pobj);
|
|
|
|
void make_perimeters(PrintObject *pobj);
|
|
|
|
void infill(PrintObject *pobj);
|
|
|
|
void gen_support_material(PrintObject *pobj);
|
|
|
|
|
|
|
|
void slice();
|
2018-06-19 15:43:59 +00:00
|
|
|
void slice_to_png();
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AppController: protected AppControllerBoilerplate {
|
|
|
|
Model *model_ = nullptr;
|
|
|
|
PrintController::Ptr printctl;
|
|
|
|
public:
|
|
|
|
|
|
|
|
PrintController * print_ctl() { return printctl.get(); }
|
|
|
|
|
2018-06-19 15:43:59 +00:00
|
|
|
void set_model(Model *model) { model_ = model; }
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
void set_print(Print *print) {
|
|
|
|
printctl = PrintController::create(print);
|
|
|
|
printctl->progressIndicator(progressIndicator());
|
|
|
|
}
|
2018-06-19 15:43:59 +00:00
|
|
|
|
|
|
|
void set_global_progress_indicator_id(unsigned gauge_id,
|
|
|
|
unsigned statusbar_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // APPCONTROLLER_HPP
|