mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-11 22:29:00 +08:00
Convert Print& to weak_ptr; Settings& to Settings*.
This commit is contained in:
parent
eb69998832
commit
7a048c3f70
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
preset_store presets { Presets() };
|
preset_store presets { Presets() };
|
||||||
std::array<wxString, preset_types> preset_ini { };
|
std::array<wxString, preset_types> preset_ini { };
|
||||||
Settings settings { };
|
Settings* settings() { return ui_settings.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Notifier> notifier {nullptr};
|
std::unique_ptr<Notifier> notifier {nullptr};
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
PresetChooser::PresetChooser(wxWindow* parent, Print& print) : PresetChooser(parent, print, SLIC3RAPP->settings, SLIC3RAPP->presets) {}
|
PresetChooser::PresetChooser(wxWindow* parent, std::weak_ptr<Print> print) : PresetChooser(parent, print, SLIC3RAPP->settings(), SLIC3RAPP->presets) {}
|
||||||
|
|
||||||
PresetChooser::PresetChooser(wxWindow* parent, Print& print, Settings& external_settings, preset_store& external_presets) :
|
PresetChooser::PresetChooser(wxWindow* parent, std::weak_ptr<Print> print, Settings* external_settings, preset_store& external_presets) :
|
||||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ""),
|
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ""),
|
||||||
_local_sizer(new wxFlexGridSizer(3,3,1,2)), _parent(parent), _settings(external_settings), _print(print), _presets(external_presets)
|
_local_sizer(new wxFlexGridSizer(3,3,1,2)), _parent(parent), _settings(external_settings), _print(print), _presets(external_presets)
|
||||||
{
|
{
|
||||||
|
@ -25,8 +25,8 @@ class PresetChooser : public wxPanel {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/// Build a panel to contain a sizer for dropdowns for preset selection.
|
/// Build a panel to contain a sizer for dropdowns for preset selection.
|
||||||
PresetChooser(wxWindow* parent, Print& print);
|
PresetChooser(wxWindow* parent, std::weak_ptr<Print> print);
|
||||||
PresetChooser(wxWindow* parent, Print& print, Settings& external_settings, preset_store& external_presets);
|
PresetChooser(wxWindow* parent, std::weak_ptr<Print> print, Settings* external_settings, preset_store& external_presets);
|
||||||
|
|
||||||
std::array<Choosers, preset_types> preset_choosers;
|
std::array<Choosers, preset_types> preset_choosers;
|
||||||
|
|
||||||
@ -70,10 +70,10 @@ private:
|
|||||||
chooser_name_map __chooser_names;
|
chooser_name_map __chooser_names;
|
||||||
|
|
||||||
/// Reference to a Slic3r::Settings object.
|
/// Reference to a Slic3r::Settings object.
|
||||||
Settings& _settings;
|
Settings* _settings;
|
||||||
|
|
||||||
/// Reference to owning Plater's print
|
/// Weak reference to Plater's print
|
||||||
Print& _print;
|
std::weak_ptr<Print> _print;
|
||||||
|
|
||||||
/// Reference to owning Application's preset database.
|
/// Reference to owning Application's preset database.
|
||||||
preset_store& _presets;
|
preset_store& _presets;
|
||||||
|
@ -62,7 +62,7 @@ std::array<Presets, preset_types> sample_compatible() {
|
|||||||
// System should update its selected choosers based on changed print profile,
|
// System should update its selected choosers based on changed print profile,
|
||||||
// update settings, etc.
|
// update settings, etc.
|
||||||
SCENARIO( "PresetChooser changed printer") {
|
SCENARIO( "PresetChooser changed printer") {
|
||||||
Print fake_print;
|
std::shared_ptr<Print> fake_print {std::make_shared<Print>()};
|
||||||
Settings default_settings;
|
Settings default_settings;
|
||||||
wxUIActionSimulator sim;
|
wxUIActionSimulator sim;
|
||||||
wxTestableFrame* old = dynamic_cast<wxTestableFrame*>(wxTheApp->GetTopWindow());
|
wxTestableFrame* old = dynamic_cast<wxTestableFrame*>(wxTheApp->GetTopWindow());
|
||||||
@ -73,7 +73,7 @@ SCENARIO( "PresetChooser changed printer") {
|
|||||||
Settings test_settings;
|
Settings test_settings;
|
||||||
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
||||||
auto preset_list {sample_compatible()};
|
auto preset_list {sample_compatible()};
|
||||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, test_settings, preset_list);
|
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, &test_settings, preset_list);
|
||||||
cut.load();
|
cut.load();
|
||||||
|
|
||||||
WHEN( "Printer profile is changed to printer-profile-2 via select_preset_by_name" ) {
|
WHEN( "Printer profile is changed to printer-profile-2 via select_preset_by_name" ) {
|
||||||
@ -108,7 +108,7 @@ SCENARIO( "PresetChooser changed printer") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SCENARIO( "PresetChooser Preset loading" ) {
|
SCENARIO( "PresetChooser Preset loading" ) {
|
||||||
Print fake_print;
|
std::shared_ptr<Print> fake_print {std::make_shared<Print>()};
|
||||||
Settings default_settings;
|
Settings default_settings;
|
||||||
auto& settings_presets = default_settings.default_presets;
|
auto& settings_presets = default_settings.default_presets;
|
||||||
wxUIActionSimulator sim;
|
wxUIActionSimulator sim;
|
||||||
@ -119,7 +119,7 @@ SCENARIO( "PresetChooser Preset loading" ) {
|
|||||||
GIVEN( "A PresetChooser object." ) {
|
GIVEN( "A PresetChooser object." ) {
|
||||||
WHEN( "load() is called with only default presets" ) {
|
WHEN( "load() is called with only default presets" ) {
|
||||||
auto preset_list {defaults()};
|
auto preset_list {defaults()};
|
||||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, default_settings, preset_list);
|
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, &default_settings, preset_list);
|
||||||
cut.load();
|
cut.load();
|
||||||
THEN( "Number of preset choosers created is 3" ) {
|
THEN( "Number of preset choosers created is 3" ) {
|
||||||
REQUIRE(cut.preset_choosers.size() == 3);
|
REQUIRE(cut.preset_choosers.size() == 3);
|
||||||
@ -140,7 +140,7 @@ SCENARIO( "PresetChooser Preset loading" ) {
|
|||||||
}
|
}
|
||||||
WHEN( "load is called with non-default presets and default presets" ) {
|
WHEN( "load is called with non-default presets and default presets" ) {
|
||||||
auto preset_list {sample()};
|
auto preset_list {sample()};
|
||||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, default_settings, preset_list);
|
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, &default_settings, preset_list);
|
||||||
cut.load();
|
cut.load();
|
||||||
THEN( "Number of preset choosers created is 3" ) {
|
THEN( "Number of preset choosers created is 3" ) {
|
||||||
REQUIRE(cut.preset_choosers.size() == 3);
|
REQUIRE(cut.preset_choosers.size() == 3);
|
||||||
@ -169,7 +169,7 @@ SCENARIO( "PresetChooser Preset loading" ) {
|
|||||||
Settings test_settings;
|
Settings test_settings;
|
||||||
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
||||||
auto preset_list {sample_compatible()};
|
auto preset_list {sample_compatible()};
|
||||||
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, test_settings, preset_list);
|
PresetChooser cut(wxTheApp->GetTopWindow(), fake_print, &test_settings, preset_list);
|
||||||
WHEN( "load is called with non-default presets and default presets and the material is listed with an incompatible printer" ) {
|
WHEN( "load is called with non-default presets and default presets and the material is listed with an incompatible printer" ) {
|
||||||
cut.load();
|
cut.load();
|
||||||
THEN( "Number of preset choosers created is 3" ) {
|
THEN( "Number of preset choosers created is 3" ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user