Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-06-20 11:02:52 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-06-20 11:02:52 +0300
commitb7f67369c99cf204d8071b1d42abc3c2704f1d82 (patch)
tree973b13697b35709ee5eb0d05e6c768b5c1a91686 /src/slic3r/GUI
parent6af69667a33631e894360985feef83053c84cb63 (diff)
Serialized camera type and fixed Mac build
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/AppConfig.cpp3
-rw-r--r--src/slic3r/GUI/Camera.cpp28
-rw-r--r--src/slic3r/GUI/Camera.hpp8
-rw-r--r--src/slic3r/GUI/GLCanvas3D.cpp7
-rw-r--r--src/slic3r/GUI/Plater.cpp3
5 files changed, 39 insertions, 10 deletions
diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp
index d4970880b..edc9845a1 100644
--- a/src/slic3r/GUI/AppConfig.cpp
+++ b/src/slic3r/GUI/AppConfig.cpp
@@ -73,6 +73,9 @@ void AppConfig::set_defaults()
if (get("custom_toolbar_size").empty())
set("custom_toolbar_size", "100");
+ if (get("camera_type").empty())
+ set("camera_type", "1");
+
// Remove legacy window positions/sizes
erase("", "main_frame_maximized");
erase("", "main_frame_pos");
diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp
index a3ecb5e54..b8c182ef4 100644
--- a/src/slic3r/GUI/Camera.cpp
+++ b/src/slic3r/GUI/Camera.cpp
@@ -2,9 +2,8 @@
#include "Camera.hpp"
#include "3DScene.hpp"
-#if ENABLE_CAMERA_STATISTICS
#include "GUI_App.hpp"
-#endif // ENABLE_CAMERA_STATISTICS
+#include "AppConfig.hpp"
#include <GL/glew.h>
@@ -44,23 +43,44 @@ std::string Camera::get_type_as_string() const
{
switch (m_type)
{
- default:
case Unknown:
return "unknown";
case Perspective:
return "perspective";
+ default:
case Ortho:
return "orthographic";
};
}
+void Camera::set_type(EType type)
+{
+ if (m_type != type)
+ {
+ m_type = type;
+
+ wxGetApp().app_config->set("camera_type", std::to_string(m_type));
+ wxGetApp().app_config->save();
+ }
+}
+
+void Camera::set_type(const std::string& type)
+{
+ if (!type.empty() && (type != "1"))
+ {
+ unsigned char type_id = atoi(type.c_str());
+ if (((unsigned char)Ortho < type_id) && (type_id < (unsigned char)Num_types))
+ set_type((Camera::EType)type_id);
+ }
+}
+
void Camera::select_next_type()
{
unsigned char next = (unsigned char)m_type + 1;
if (next == (unsigned char)Num_types)
next = 1;
- m_type = (EType)next;
+ set_type((EType)next);
}
void Camera::set_target(const Vec3d& target)
diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp
index fe6571b05..a64b194f3 100644
--- a/src/slic3r/GUI/Camera.hpp
+++ b/src/slic3r/GUI/Camera.hpp
@@ -16,8 +16,8 @@ struct Camera
enum EType : unsigned char
{
Unknown,
- Perspective,
Ortho,
+ Perspective,
Num_types
};
@@ -45,7 +45,8 @@ public:
EType get_type() const { return m_type; }
std::string get_type_as_string() const;
- void set_type(EType type) { m_type = type; }
+ void set_type(EType type);
+ void set_type(const std::string& type);
void select_next_type();
const Vec3d& get_target() const { return m_target; }
@@ -56,6 +57,9 @@ public:
double get_zoom() const { return m_zoom; }
void set_zoom(double zoom, const BoundingBoxf3& max_box, int canvas_w, int canvas_h);
+#if ENABLE_RETINA_GL
+ void set_zoom(double zoom) { m_zoom = zoom; }
+#endif // ENABLE_RETINA_GL
const BoundingBoxf3& get_scene_box() const { return m_scene_box; }
void set_scene_box(const BoundingBoxf3& box) { m_scene_box = box; }
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 9216eff94..d9a8a870c 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -1593,8 +1593,8 @@ void GLCanvas3D::render()
if (m_camera.requires_zoom_to_bed)
{
zoom_to_bed();
-// const Size& cnv_size = get_canvas_size();
-// _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
+ const Size& cnv_size = get_canvas_size();
+ _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
m_camera.requires_zoom_to_bed = false;
}
@@ -3304,8 +3304,7 @@ void GLCanvas3D::update_ui_from_settings()
if (new_scaling != orig_scaling) {
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
- m_camera.zoom /= orig_scaling;
- m_camera.zoom *= new_scaling;
+ m_camera.set_zoom(m_camera.get_zoom() * new_scaling / orig_scaling);
_refresh_if_shown_on_screen();
}
#endif
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index f8385c0b5..c2456db80 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -1772,6 +1772,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Layout();
set_current_panel(view3D);
+
+ // updates camera type from .ini file
+ camera.set_type(get_config("camera_type"));
}
void Plater::priv::update(bool force_full_scene_refresh)