From e66cda51bf7bc903a83adad77923dcce55dcf2c8 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Wed, 4 Jul 2018 16:31:55 -0500 Subject: [PATCH] Add get_point3 to interface; add I/O --- src/GUI/OptionsGroup/Field.hpp | 9 +++++---- src/GUI/OptionsGroup/UI_Point.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/GUI/OptionsGroup/Field.hpp b/src/GUI/OptionsGroup/Field.hpp index d2e9715bf..4a220d1e9 100644 --- a/src/GUI/OptionsGroup/Field.hpp +++ b/src/GUI/OptionsGroup/Field.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "ConfigBase.hpp" @@ -49,6 +50,7 @@ public: virtual std::string get_string() { Slic3r::Log::warn(this->LogChannel(), "get_string does not exist"s); return 0; } //< return 0 all the time if this is not implemented. virtual Slic3r::Pointf get_point() { Slic3r::Log::warn(this->LogChannel(), "get_point does not exist"s); return Slic3r::Pointf(); } //< return 0 all the time if this is not implemented. + virtual Slic3r::Pointf3 get_point3() { Slic3r::Log::warn(this->LogChannel(), "get_point3 does not exist"s); return Slic3r::Pointf3(); } //< return 0 all the time if this is not implemented. /// Provide access in a generic fashion to the underlying Window. virtual wxWindow* get_window() { return this->window; } @@ -300,10 +302,8 @@ public: void set_value(boost::any value) override; //< Implements set_value - Pointf get_point() override; /// return a Slic3r::Pointf corresponding to the textctrl contents. - - /// Return the underlying sizer. - wxSizer* get_sizer() { return _sizer; }; + Slic3r::Pointf get_point() override; //< return a Slic3r::Pointf corresponding to the textctrl contents. + Slic3r::Pointf3 get_point3() override; //< return a Slic3r::Pointf3 corresponding to the textctrl contents. /// Function to call when the contents of this change. std::function value)> on_change {nullptr}; @@ -339,6 +339,7 @@ private: wxBoxSizer* _sizer {nullptr}; void _set_value(Slic3r::Pointf value); + void _set_value(Slic3r::Pointf3 value); void _set_value(std::string value); /// Remove extra zeroes generated from std::to_string on doubles diff --git a/src/GUI/OptionsGroup/UI_Point.cpp b/src/GUI/OptionsGroup/UI_Point.cpp index 436ae5d59..a02b0c1d1 100644 --- a/src/GUI/OptionsGroup/UI_Point.cpp +++ b/src/GUI/OptionsGroup/UI_Point.cpp @@ -20,10 +20,19 @@ Slic3r::Pointf UI_Point::get_point() { return Pointf(std::stod(this->_ctrl_x->GetValue().ToStdString()), std::stod(this->_ctrl_y->GetValue().ToStdString())); } +Slic3r::Pointf3 UI_Point::get_point3() { + return Pointf3( + std::stod(this->_ctrl_x->GetValue().ToStdString()), + std::stod(this->_ctrl_y->GetValue().ToStdString()), + 0.0); +} + void UI_Point::set_value(boost::any value) { // type detection and handing off to children if (value.type() == typeid(Slic3r::Pointf)) { this->_set_value(boost::any_cast(value)); + } else if (value.type() == typeid(Slic3r::Pointf3)) { + this->_set_value(boost::any_cast(value)); } else if (value.type() == typeid(std::string)) { this->_set_value(boost::any_cast(value)); } else if (value.type() == typeid(wxString)) { @@ -38,6 +47,9 @@ void UI_Point::_set_value(Slic3r::Pointf value) { this->_ctrl_x->SetValue(trim_zeroes(std::to_string(value.x))); this->_ctrl_y->SetValue(trim_zeroes(std::to_string(value.y))); } +void UI_Point::_set_value(Slic3r::Pointf3 value) { + this->_set_value(Pointf(value.x, value.y)); +} void UI_Point::_set_value(std::string value) { /// parse the string into the two parts.