remove SLAPrint and its integration

This commit is contained in:
tamasmeszaros 2018-11-08 16:18:05 +01:00
parent 3b373a55e6
commit bf1188442a
7 changed files with 2 additions and 331 deletions

View file

@ -121,8 +121,6 @@ add_library(libslic3r_gui STATIC
Utils/Time.hpp
Utils/HexFile.cpp
Utils/HexFile.hpp
GUI/SLAPrint.hpp
GUI/SLAPrint.cpp
AppController.hpp
AppController.cpp
AppControllerWx.cpp

View file

@ -137,7 +137,6 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent)
: m_parent(parent)
, m_group_id(-1)
, m_state(Off)
, m_prev_state(Off)
, m_hover_id(-1)
, m_dragging(false)
{

View file

@ -56,7 +56,7 @@ protected:
GLCanvas3D& m_parent;
int m_group_id;
EState m_state, m_prev_state;
EState m_state;
// textures are assumed to be square and all with the same size in pixels, no internal check is done
GLTexture m_textures[Num_States];
int m_hover_id;
@ -79,17 +79,7 @@ public:
EState get_state() const { return m_state; }
void set_state(EState state) {
bool call_deactivate =
m_prev_state == On && state == Off && m_state == Hover;
if(state == On || state == Off) m_prev_state = state;
m_state = state; on_set_state();
// FIXME: this is my workaround to react on the disabling event (Tamas)
if(call_deactivate) {
on_deactivate();
}
}
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
@ -122,7 +112,6 @@ protected:
virtual bool on_init() = 0;
virtual std::string on_get_name() const = 0;
virtual void on_set_state() {}
virtual void on_deactivate() {} // FIXME: how to react to disabling the Gizmo? (Tamas)
virtual void on_set_hover_id() {}
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
virtual void on_enable_grabber(unsigned int id) {}
@ -434,8 +423,6 @@ protected:
}
}
void on_deactivate() override;
std::string on_get_name() const override;
};

View file

@ -33,7 +33,6 @@
#include "libslic3r/Format/AMF.hpp"
#include "libslic3r/Format/3mf.hpp"
#include "slic3r/AppController.hpp"
#include "SLAPrint.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
@ -841,43 +840,6 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
}
// Plater / private
// For the SLAPrint: No multi-threading here
class DummyBackgroundProcess: public BackgroundProcess {
public:
/// schedule a task on the background
virtual void schedule(std::function<void()> fn) override {
/*std::asynch*/ fn();
}
/// Report status change, used inside the worker thread
virtual void status(unsigned st, const std::string& msg) {
// TODO would use the statusbar gauge
std::cout << "Processing " << st << "% " << msg << std::endl;
}
/// Check whether the calculation was canceled from the UI. Called by the
/// worker thread
virtual bool is_canceled() {
// this would be connected to the statusbar's cancel button
// and return true if that was pushed during the processing
return false;
}
/// Determine the state of the background process. If something is running
/// returns true. If no job is running, returns false.
virtual bool is_running() { return false; }
virtual void input_changed() override {
/*lock();*/
BackgroundProcess::input_changed();
/*unlock();*/
}
};
struct Plater::priv
{
// PIMPL back pointer ("Q-Pointer")
@ -893,9 +855,6 @@ struct Plater::priv
Slic3r::Model model;
Slic3r::GCodePreviewData gcode_preview_data;
// Will live only in this branch:
Slic3r::SLAPrint slaprint;
// GUI elements
wxNotebook *notebook;
Sidebar *sidebar;
@ -994,10 +953,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
})),
notebook(new wxNotebook(q, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_BOTTOM)),
sidebar(new Sidebar(q)),
canvas3D(GLCanvas3DManager::create_wxglcanvas(notebook)),
slaprint(&model)
canvas3D(GLCanvas3DManager::create_wxglcanvas(notebook))
{
slaprint.set_scheduler(std::make_shared<DummyBackgroundProcess>());
// TODO: background_process.set_print(&slaprint);
background_process.set_print(&print);
background_process.set_gcode_preview_data(&gcode_preview_data);
@ -1567,9 +1524,6 @@ void Plater::priv::async_apply_config()
// Apply new config to the possibly running background task.
Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), std::move(config));
// Thread safe invalidation of the SLAPrint data cache
this->slaprint.synch();
// Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile.
if (Slic3r::_3DScene::is_layers_editing_enabled(this->canvas3D))
this->canvas3D->Refresh();
@ -1980,11 +1934,6 @@ Sidebar& Plater::sidebar() { return *p->sidebar; }
Model& Plater::model() { return p->model; }
Print& Plater::print() { return p->print; }
SLAPrint &Plater::sla_print()
{
return p->slaprint;
}
void Plater::add()
{
wxArrayString input_files;

View file

@ -18,8 +18,6 @@ namespace Slic3r {
class Model;
class Print;
class SLAPrint;
namespace GUI {
class MainFrame;
@ -105,7 +103,6 @@ public:
Sidebar& sidebar();
Model& model();
Print& print();
SLAPrint& sla_print();
void add();

View file

@ -1,76 +0,0 @@
#include "SLAPrint.hpp"
#include "GUI.hpp"
#include "GLGizmo.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
namespace Slic3r {
const std::string SLAPrint::m_stage_labels[] = {
"", // IDLE,
L("Finding best rotation"), // FIND_ROTATION,
L("Scanning model structure"), // SUPPORT_POINTS,
L("Generating support tree"), // SUPPORT_TREE,
L("Generating base pool"), // BASE_POOL,
L("Slicing model"), // SLICE_MODEL,
L("Slicing supports"), // SLICE_SUPPORTS,
L("Exporting layers"), // EXPORT,
L("Prepared for printing"), // DONE,
L("SLA print preparation aborted") // ABORT,
};
void SLAPrint::_start()
{
}
void SLAPrint::_synch() {
m_gcfg = m_config_reader();
// TODO: fill PrintObject cache
m_dirty.store(false);
}
bool SLAPrint::start() {
if(!m_process) return false;
m_process->schedule([this](){ _start(); });
return true;
}
namespace GUI {
void GLGizmoSlaSupports::on_deactivate() {
std::cout << "gizmo deactivated " << std::endl;
if(!m_model_object) return;
SLAPrint& print = wxGetApp().plater()->sla_print();
print.synch();
print.start();
// sla::Controller supportctl;
// std::cout << "Generating supports:" << std::endl;
// // TODO: somehow get the global status indicator
// supportctl.statuscb = [] (unsigned st, const std::string& msg) {
// std::cout << st << "% " << msg << std::endl;
// };
// TriangleMesh&& m = m_model_object->raw_mesh();
// m.transform(m_model_object_matrix);
// auto emesh = sla::to_eigenmesh(m);
// sla::SupportConfig cfg;
// sla::PointSet input = sla::support_points(*m_model_object, 0 /*instance*/);
// sla::SLASupportTree stree(input, emesh, cfg, supportctl);
// TriangleMesh output;
// stree.merged_mesh(output);
// _3DScene::reload_scene(m_parent.get_wxglcanvas(), false);
}
}
}

View file

@ -1,183 +0,0 @@
#include <libslic3r.h>
#include "Point.hpp"
#include "SLA/SLASupportTree.hpp"
#include <string>
#include <memory>
#include <unordered_map>
#include <atomic>
namespace Slic3r {
class Model;
class ModelObject;
class ModelInstance;
class GLCanvas3D;
class DynamicPrintConfig;
// This will be the driver to create background threads. Possibly
// implemented using a BackgroundSlicingProcess or something derived from that
// The methods should be thread safe, obviously...
class BackgroundProcess {
std::function<void()> m_synchfn;
public:
virtual ~BackgroundProcess() {}
/// schedule a task on the background
virtual void schedule(std::function<void()> fn) = 0;
/// Report status change, used inside the worker thread
virtual void status(unsigned st, const std::string& msg) = 0;
/// Check whether the calculation was canceled from the UI. Called by the
/// worker thread
virtual bool is_canceled() = 0;
/// Determine the state of the background process. If something is running
/// returns true. If no job is running, returns false.
virtual bool is_running() = 0;
/// Trigger the synchronization of frontend/backend data
virtual void input_changed() {
m_synchfn(); // will just call the provided synch function itself.
}
/// Setting up a callback that transfers the input parameters to the worker
/// thread. Appropriate synchronization has to be implemented here. A simple
/// condition variable and mutex pair should do the job.
void on_input_changed(std::function<void()> synchfn) {
m_synchfn = synchfn;
}
};
/**
* @brief This class is the high level FSM for the SLA printing process.
*
* It should support the background processing framework and contain the
* metadata for the support geometries and their slicing. It should also
* dispatch the SLA printing configuration values to the appropriate calculation
* steps.
*
* TODO (decide): The last important feature is the support for visualization
* which (at least for now) will be implemented as a method(s) returning the
* triangle meshes or receiving the rendering canvas and drawing on that
* directly.
*
* TODO: This class uses the BackgroundProcess interface to create workers and
* manage input change events. An appropriate implementation can be derived
* from BackgroundSlicingProcess which is now working only with the FDM Print.
*/
class SLAPrint /* : public Print */ {
public:
enum CallType {
BLOCKING, NON_BLOCKING
};
// Global SLA printing configuration
struct GlobalConfig {
double width_mm;
double height_mm;
unsigned long width_px;
unsigned long height_px;
// ...
};
private:
// Caching instance transformations and slices
struct PrintObjectInstance {
Transform3f tr;
SlicedSupports slice_cache;
};
using InstanceMap = std::unordered_map<ModelInstance*, PrintObjectInstance>;
// Every ModelObject will have its PrintObject here. It will contain the
// support tree geometry, the cached index-triangle structure (emesh) and
// the map of the instance cache
struct PrintObject {
sla::EigenMesh3D emesh;
std::unique_ptr<sla::SLASupportTree> support_tree_ptr;
InstanceMap instances;
};
// Map definition for the print objects
using ObjectMap = std::unordered_map<ModelObject*, PrintObject>;
// Input data channels: ***************************************************
const Model *m_model = nullptr; // The model itself
// something to read out the config profiles and return the values we need.
std::function<GlobalConfig()> m_config_reader;
// ************************************************************************
GlobalConfig m_gcfg; // The global SLA print config instance
ObjectMap m_data; // The model data cache (PrintObject's)
std::shared_ptr<BackgroundProcess> m_process; // The scheduler
// For now it will just stop the whole process and invalidate everything
std::atomic<bool> m_dirty;
enum Stages {
IDLE,
FIND_ROTATION,
SUPPORT_POINTS,
SUPPORT_TREE,
BASE_POOL,
SLICE_MODEL,
SLICE_SUPPORTS,
EXPORT,
DONE,
ABORT,
NUM_STAGES
};
static const std::string m_stage_labels[NUM_STAGES];
void _start();
void _synch();
public:
void set_scheduler(std::shared_ptr<BackgroundProcess> scheduler) {
if(scheduler && !scheduler->is_running()) {
m_process = scheduler;
m_process->on_input_changed([this] {
_synch();
});
}
}
SLAPrint(const Model * model,
std::function<SLAPrint::GlobalConfig(void)> cfgreader =
[](){ return SLAPrint::GlobalConfig(); },
std::shared_ptr<BackgroundProcess> scheduler = {}):
m_model(model), m_config_reader(cfgreader)
{
set_scheduler(scheduler);
}
void synch() {
if(m_process) m_process->input_changed();
}
// This will start the calculation using the
bool start();
// Get the full support structure (including the base pool)
// This should block until the supports are not ready?
bool support_mesh(TriangleMesh& output, CallType calltype = BLOCKING);
// Exporting to the final zip file, or possibly other format.
// filepath is reserved to be a zip filename or directory or anything
// that a particular format requires.
// (I know, we will use zipped PNG, but everything changes here so quickly)
bool export_layers(const std::string& filepath,
CallType calltype = BLOCKING);
};
}