Merge remote-tracking branch 'origin/dev' into new_main_page_ui

This commit is contained in:
YuSanka 2018-09-13 16:12:07 +02:00
commit a31ac857ef
16 changed files with 102 additions and 37 deletions

View file

@ -438,6 +438,11 @@ void AppController::arrange_model()
{
using Coord = libnest2d::TCoord<libnest2d::PointImpl>;
if(arranging_.load()) return;
// to prevent UI reentrancies
arranging_.store(true);
unsigned count = 0;
for(auto obj : model_->objects) count += obj->instances.size();
@ -451,8 +456,8 @@ void AppController::arrange_model()
// Set the range of the progress to the object count
pind->max(count);
pind->on_cancel([](){
std::cout << "Cannot be cancelled!" << std::endl;
pind->on_cancel([this](){
arranging_.store(false);
});
}
@ -478,10 +483,12 @@ void AppController::arrange_model()
bed,
hint,
false, // create many piles not just one pile
[pind, count](unsigned rem) {
[this, pind, count](unsigned rem) {
if(pind)
pind->update(count - rem, _(L("Arranging objects...")));
});
pind->update(count - rem, L("Arranging objects..."));
process_events();
}, [this] () { return !arranging_.load(); });
} catch(std::exception& e) {
std::cerr << e.what() << std::endl;
report_issue(IssueType::ERR,
@ -493,9 +500,13 @@ void AppController::arrange_model()
// Restore previous max value
if(pind) {
pind->max(pmax);
pind->update(0, _(L("Arranging done.")));
pind->update(0, arranging_.load() ? L("Arranging done.") :
L("Arranging canceled."));
pind->on_cancel(/*remove cancel function*/);
}
arranging_.store(false);
}
}

View file

@ -237,6 +237,7 @@ public:
class AppController: public AppControllerBoilerplate {
Model *model_ = nullptr;
PrintController::Ptr printctl;
std::atomic<bool> arranging_;
public:
/**

View file

@ -28,7 +28,7 @@ bool AppControllerBoilerplate::supports_asynch() const
void AppControllerBoilerplate::process_events()
{
wxSafeYield();
wxYieldIfNeeded();
}
AppControllerBoilerplate::PathList

View file

@ -2164,6 +2164,11 @@ int _3DScene::get_first_volume_id(wxGLCanvas* canvas, int obj_idx)
return s_canvas_mgr.get_first_volume_id(canvas, obj_idx);
}
int _3DScene::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx)
{
return s_canvas_mgr.get_in_object_volume_id(canvas, scene_vol_idx);
}
void _3DScene::reload_scene(wxGLCanvas* canvas, bool force)
{
s_canvas_mgr.reload_scene(canvas, force);

View file

@ -577,6 +577,7 @@ public:
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
static int get_first_volume_id(wxGLCanvas* canvas, int obj_idx);
static int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx);
static void reload_scene(wxGLCanvas* canvas, bool force);

View file

@ -2493,6 +2493,11 @@ int GLCanvas3D::get_first_volume_id(int obj_idx) const
return -1;
}
int GLCanvas3D::get_in_object_volume_id(int scene_vol_idx) const
{
return ((0 <= scene_vol_idx) && (scene_vol_idx < (int)m_volumes.volumes.size())) ? m_volumes.volumes[scene_vol_idx]->volume_idx() : -1;
}
void GLCanvas3D::reload_scene(bool force)
{
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))

View file

@ -105,7 +105,6 @@ class GLCanvas3D
void reset() { first_volumes.clear(); }
};
public:
struct Camera
{
enum EType : unsigned char
@ -441,7 +440,6 @@ public:
void render(const GLCanvas3D& canvas) const;
};
private:
wxGLCanvas* m_canvas;
wxGLContext* m_context;
LegendTexture m_legend_texture;
@ -605,6 +603,7 @@ public:
std::vector<int> load_object(const Model& model, int obj_idx);
int get_first_volume_id(int obj_idx) const;
int get_in_object_volume_id(int scene_vol_idx) const;
void reload_scene(bool force);

View file

@ -548,6 +548,12 @@ int GLCanvas3DManager::get_first_volume_id(wxGLCanvas* canvas, int obj_idx) cons
return (it != m_canvases.end()) ? it->second->get_first_volume_id(obj_idx) : -1;
}
int GLCanvas3DManager::get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx) const
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->get_in_object_volume_id(scene_vol_idx) : -1;
}
void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool force)
{
CanvasesMap::iterator it = _get_canvas(canvas);

View file

@ -138,6 +138,7 @@ public:
std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
int get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const;
int get_in_object_volume_id(wxGLCanvas* canvas, int scene_vol_idx) const;
void reload_scene(wxGLCanvas* canvas, bool force);