mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-11 17:08:59 +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() };
|
||||
std::array<wxString, preset_types> preset_ini { };
|
||||
Settings settings { };
|
||||
Settings* settings() { return ui_settings.get(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<Notifier> notifier {nullptr};
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
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, ""),
|
||||
_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:
|
||||
|
||||
/// Build a panel to contain a sizer for dropdowns for preset selection.
|
||||
PresetChooser(wxWindow* parent, Print& print);
|
||||
PresetChooser(wxWindow* parent, Print& print, Settings& external_settings, preset_store& external_presets);
|
||||
PresetChooser(wxWindow* parent, std::weak_ptr<Print> print);
|
||||
PresetChooser(wxWindow* parent, std::weak_ptr<Print> print, Settings* external_settings, preset_store& external_presets);
|
||||
|
||||
std::array<Choosers, preset_types> preset_choosers;
|
||||
|
||||
@ -70,10 +70,10 @@ private:
|
||||
chooser_name_map __chooser_names;
|
||||
|
||||
/// Reference to a Slic3r::Settings object.
|
||||
Settings& _settings;
|
||||
Settings* _settings;
|
||||
|
||||
/// Reference to owning Plater's print
|
||||
Print& _print;
|
||||
/// Weak reference to Plater's print
|
||||
std::weak_ptr<Print> _print;
|
||||
|
||||
/// Reference to owning Application's preset database.
|
||||
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,
|
||||
// update settings, etc.
|
||||
SCENARIO( "PresetChooser changed printer") {
|
||||
Print fake_print;
|
||||
std::shared_ptr<Print> fake_print {std::make_shared<Print>()};
|
||||
Settings default_settings;
|
||||
wxUIActionSimulator sim;
|
||||
wxTestableFrame* old = dynamic_cast<wxTestableFrame*>(wxTheApp->GetTopWindow());
|
||||
@ -73,7 +73,7 @@ SCENARIO( "PresetChooser changed printer") {
|
||||
Settings test_settings;
|
||||
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
||||
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();
|
||||
|
||||
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" ) {
|
||||
Print fake_print;
|
||||
std::shared_ptr<Print> fake_print {std::make_shared<Print>()};
|
||||
Settings default_settings;
|
||||
auto& settings_presets = default_settings.default_presets;
|
||||
wxUIActionSimulator sim;
|
||||
@ -119,7 +119,7 @@ SCENARIO( "PresetChooser Preset loading" ) {
|
||||
GIVEN( "A PresetChooser object." ) {
|
||||
WHEN( "load() is called with only default presets" ) {
|
||||
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();
|
||||
THEN( "Number of preset choosers created is 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" ) {
|
||||
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();
|
||||
THEN( "Number of preset choosers created is 3" ) {
|
||||
REQUIRE(cut.preset_choosers.size() == 3);
|
||||
@ -169,7 +169,7 @@ SCENARIO( "PresetChooser Preset loading" ) {
|
||||
Settings test_settings;
|
||||
test_settings.default_presets.at(get_preset(preset_t::Printer)).push_back(wxString("printer-profile"));
|
||||
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" ) {
|
||||
cut.load();
|
||||
THEN( "Number of preset choosers created is 3" ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user