Serialized camera type and fixed Mac build
This commit is contained in:
parent
6af69667a3
commit
b7f67369c9
5 changed files with 39 additions and 10 deletions
|
@ -73,6 +73,9 @@ void AppConfig::set_defaults()
|
||||||
if (get("custom_toolbar_size").empty())
|
if (get("custom_toolbar_size").empty())
|
||||||
set("custom_toolbar_size", "100");
|
set("custom_toolbar_size", "100");
|
||||||
|
|
||||||
|
if (get("camera_type").empty())
|
||||||
|
set("camera_type", "1");
|
||||||
|
|
||||||
// Remove legacy window positions/sizes
|
// Remove legacy window positions/sizes
|
||||||
erase("", "main_frame_maximized");
|
erase("", "main_frame_maximized");
|
||||||
erase("", "main_frame_pos");
|
erase("", "main_frame_pos");
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#if ENABLE_CAMERA_STATISTICS
|
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#endif // ENABLE_CAMERA_STATISTICS
|
#include "AppConfig.hpp"
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
@ -44,23 +43,44 @@ std::string Camera::get_type_as_string() const
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case Unknown:
|
case Unknown:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
case Perspective:
|
case Perspective:
|
||||||
return "perspective";
|
return "perspective";
|
||||||
|
default:
|
||||||
case Ortho:
|
case Ortho:
|
||||||
return "orthographic";
|
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()
|
void Camera::select_next_type()
|
||||||
{
|
{
|
||||||
unsigned char next = (unsigned char)m_type + 1;
|
unsigned char next = (unsigned char)m_type + 1;
|
||||||
if (next == (unsigned char)Num_types)
|
if (next == (unsigned char)Num_types)
|
||||||
next = 1;
|
next = 1;
|
||||||
|
|
||||||
m_type = (EType)next;
|
set_type((EType)next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::set_target(const Vec3d& target)
|
void Camera::set_target(const Vec3d& target)
|
||||||
|
|
|
@ -16,8 +16,8 @@ struct Camera
|
||||||
enum EType : unsigned char
|
enum EType : unsigned char
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
Perspective,
|
|
||||||
Ortho,
|
Ortho,
|
||||||
|
Perspective,
|
||||||
Num_types
|
Num_types
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ public:
|
||||||
|
|
||||||
EType get_type() const { return m_type; }
|
EType get_type() const { return m_type; }
|
||||||
std::string get_type_as_string() const;
|
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();
|
void select_next_type();
|
||||||
|
|
||||||
const Vec3d& get_target() const { return m_target; }
|
const Vec3d& get_target() const { return m_target; }
|
||||||
|
@ -56,6 +57,9 @@ public:
|
||||||
|
|
||||||
double get_zoom() const { return m_zoom; }
|
double get_zoom() const { return m_zoom; }
|
||||||
void set_zoom(double zoom, const BoundingBoxf3& max_box, int canvas_w, int canvas_h);
|
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; }
|
const BoundingBoxf3& get_scene_box() const { return m_scene_box; }
|
||||||
void set_scene_box(const BoundingBoxf3& box) { m_scene_box = box; }
|
void set_scene_box(const BoundingBoxf3& box) { m_scene_box = box; }
|
||||||
|
|
|
@ -1593,8 +1593,8 @@ void GLCanvas3D::render()
|
||||||
if (m_camera.requires_zoom_to_bed)
|
if (m_camera.requires_zoom_to_bed)
|
||||||
{
|
{
|
||||||
zoom_to_bed();
|
zoom_to_bed();
|
||||||
// const Size& cnv_size = get_canvas_size();
|
const Size& cnv_size = get_canvas_size();
|
||||||
// _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
_resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
|
||||||
m_camera.requires_zoom_to_bed = false;
|
m_camera.requires_zoom_to_bed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3304,8 +3304,7 @@ void GLCanvas3D::update_ui_from_settings()
|
||||||
if (new_scaling != orig_scaling) {
|
if (new_scaling != orig_scaling) {
|
||||||
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
||||||
|
|
||||||
m_camera.zoom /= orig_scaling;
|
m_camera.set_zoom(m_camera.get_zoom() * new_scaling / orig_scaling);
|
||||||
m_camera.zoom *= new_scaling;
|
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1772,6 +1772,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||||
q->Layout();
|
q->Layout();
|
||||||
|
|
||||||
set_current_panel(view3D);
|
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)
|
void Plater::priv::update(bool force_full_scene_refresh)
|
||||||
|
|
Loading…
Add table
Reference in a new issue