Skip to content

Commit 04d0b42

Browse files
3d preview: only update when needed
1 parent e44d858 commit 04d0b42

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

src/imp/3d/3d_view.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ View3DWindow::View3DWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Buil
266266
canvas->signal_layers_loading().connect([this](unsigned int i, unsigned int n) {
267267
layer_loading_i = i;
268268
layer_loading_n = n;
269-
if (i >= n)
270-
update_button->set_sensitive(true);
271-
272269
update_loading();
273270
});
274271

@@ -381,12 +378,21 @@ void View3DWindow::add_widget(Gtk::Widget *w)
381378

382379
void View3DWindow::update(bool clear)
383380
{
381+
if (!needs_update)
382+
return;
384383
s_signal_request_update.emit();
385384
canvas->update(board);
386385
if (clear)
387386
canvas->clear_3d_models();
388387
canvas->load_models_async(pool);
389388
update_button->set_sensitive(false);
389+
needs_update = false;
390+
}
391+
392+
void View3DWindow::set_needs_update()
393+
{
394+
needs_update = true;
395+
update_button->set_sensitive(true);
390396
}
391397

392398
void View3DWindow::set_highlights(const std::set<UUID> &pkgs)

src/imp/3d/3d_view.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class View3DWindow : public Gtk::Window, public Changeable {
1515
Mode mode, class Canvas3D *ca_custom);
1616
static View3DWindow *create(const class Board &b, class IPool &p, Mode mode, class Canvas3D *ca_custom = nullptr);
1717
void update(bool clear = false);
18+
void set_needs_update();
1819
void set_highlights(const std::set<UUID> &pkgs);
1920
void add_widget(Gtk::Widget *w);
2021

@@ -51,6 +52,7 @@ class View3DWindow : public Gtk::Window, public Changeable {
5152
class Canvas3D *canvas = nullptr;
5253
const class Board &board;
5354
class IPool &pool;
55+
bool needs_update = true;
5456
const Mode mode;
5557
Gtk::Box *main_box = nullptr;
5658

src/imp/3d/imp_package_3d.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ void ImpPackage::construct_3d()
136136
view_3d_window = View3DWindow::create(fake_board, *pool.get(), View3DWindow::Mode::PACKAGE, canvas_3d);
137137
view_3d_window->signal_request_update().connect(sigc::mem_fun(*this, &ImpPackage::update_fake_board));
138138
view_3d_window->signal_present_imp().connect([this] { main_window->present(); });
139+
core_package.signal_rebuilt().connect([this] { view_3d_window->set_needs_update(); });
139140

140141
auto models_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
141142
{

src/imp/imp_board.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ void ImpBoard::construct()
614614
canvas->set_selection({});
615615
}
616616
});
617+
core_board.signal_rebuilt().connect([this] { view_3d_window->set_needs_update(); });
617618

618619
step_export_window = StepExportWindow::create(main_window, core_board, project_dir);
619620
step_export_window->signal_changed().connect([this] { core_board.set_needs_save(); });

0 commit comments

Comments
 (0)