2018-06-19 15:43:59 +00:00
|
|
|
#ifndef APPCONTROLLER_HPP
|
|
|
|
#define APPCONTROLLER_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
2018-06-25 15:13:36 +00:00
|
|
|
#include <atomic>
|
2018-06-25 10:40:01 +00:00
|
|
|
#include <iostream>
|
2018-06-25 15:13:36 +00:00
|
|
|
|
2018-06-25 11:24:37 +00:00
|
|
|
#include "IProgressIndicator.hpp"
|
2018-06-19 15:43:59 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class Model;
|
|
|
|
class Print;
|
|
|
|
class PrintObject;
|
|
|
|
|
|
|
|
class AppControllerBoilerplate {
|
2018-06-25 15:13:36 +00:00
|
|
|
class PriMap;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using ProgresIndicatorPtr = std::shared_ptr<IProgressIndicator>;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<PriMap> progressind_;
|
|
|
|
|
2018-06-19 15:43:59 +00:00
|
|
|
public:
|
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
AppControllerBoilerplate();
|
|
|
|
~AppControllerBoilerplate();
|
|
|
|
|
2018-06-19 15:43:59 +00:00
|
|
|
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,
|
2018-06-25 11:24:37 +00:00
|
|
|
const std::string& extensions,
|
|
|
|
const std::string& hint = "") const;
|
2018-06-19 15:43:59 +00:00
|
|
|
|
|
|
|
void report_issue(IssueType issuetype,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& brief = "");
|
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
void progress_indicator(ProgresIndicatorPtr progrind);
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
void progress_indicator(unsigned statenum,
|
2018-06-26 13:51:47 +00:00
|
|
|
const std::string& title,
|
|
|
|
const std::string& firstmsg = "");
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
ProgresIndicatorPtr progress_indicator();
|
2018-06-19 15:43:59 +00:00
|
|
|
|
2018-06-26 13:51:47 +00:00
|
|
|
bool is_main_thread() const;
|
|
|
|
|
2018-06-20 12:50:18 +00:00
|
|
|
protected:
|
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
ProgresIndicatorPtr create_progress_indicator(
|
2018-06-20 12:50:18 +00:00
|
|
|
unsigned statenum,
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& firstmsg = "") const;
|
|
|
|
|
2018-06-25 15:13:36 +00:00
|
|
|
|
|
|
|
ProgresIndicatorPtr global_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
|
|
|
|
2018-06-25 10:40:01 +00:00
|
|
|
void make_perimeters(PrintObject *pobj);
|
|
|
|
void infill(PrintObject *pobj);
|
|
|
|
void gen_support_material(PrintObject *pobj);
|
|
|
|
|
2018-06-26 13:51:47 +00:00
|
|
|
struct PngExportData {
|
|
|
|
std::string zippath;
|
|
|
|
unsigned long width_px = 1440;
|
|
|
|
unsigned long height_px = 2560;
|
|
|
|
double width_mm = 68.0, height_mm = 120.0;
|
|
|
|
double corr = 1.0;
|
|
|
|
} query_png_export_data();
|
|
|
|
|
|
|
|
PngExportData prev_expdata_;
|
|
|
|
|
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 slice();
|
2018-06-19 15:43:59 +00:00
|
|
|
void slice_to_png();
|
2018-06-20 12:50:18 +00:00
|
|
|
};
|
|
|
|
|
2018-06-26 13:51:47 +00:00
|
|
|
class AppController: public AppControllerBoilerplate {
|
2018-06-20 12:50:18 +00:00
|
|
|
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);
|
2018-06-25 15:13:36 +00:00
|
|
|
printctl->progress_indicator(progress_indicator());
|
2018-06-20 12:50:18 +00:00
|
|
|
}
|
2018-06-19 15:43:59 +00:00
|
|
|
|
|
|
|
void set_global_progress_indicator_id(unsigned gauge_id,
|
|
|
|
unsigned statusbar_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // APPCONTROLLER_HPP
|