mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 01:01:15 -06:00
Merge remote-tracking branch 'origin/dev' into new_main_page_ui
This commit is contained in:
commit
73ee3f77c3
86 changed files with 4884 additions and 2922 deletions
|
|
@ -401,7 +401,7 @@ void PrintController::slice_to_png()
|
|||
// });
|
||||
}
|
||||
|
||||
void IProgressIndicator::message_fmt(
|
||||
void ProgressIndicator::message_fmt(
|
||||
const string &fmtstr, ...) {
|
||||
std::stringstream ss;
|
||||
va_list args;
|
||||
|
|
@ -433,69 +433,68 @@ const PrintConfig &PrintController::config() const
|
|||
return print_->config;
|
||||
}
|
||||
|
||||
|
||||
void AppController::arrange_model()
|
||||
{
|
||||
auto ftr = std::async(
|
||||
supports_asynch()? std::launch::async : std::launch::deferred,
|
||||
[this]()
|
||||
{
|
||||
using Coord = libnest2d::TCoord<libnest2d::PointImpl>;
|
||||
using Coord = libnest2d::TCoord<libnest2d::PointImpl>;
|
||||
|
||||
unsigned count = 0;
|
||||
for(auto obj : model_->objects) count += obj->instances.size();
|
||||
unsigned count = 0;
|
||||
for(auto obj : model_->objects) count += obj->instances.size();
|
||||
|
||||
auto pind = global_progress_indicator();
|
||||
auto pind = global_progress_indicator();
|
||||
|
||||
float pmax = 1.0;
|
||||
float pmax = 1.0;
|
||||
|
||||
if(pind) {
|
||||
pmax = pind->max();
|
||||
if(pind) {
|
||||
pmax = pind->max();
|
||||
|
||||
// Set the range of the progress to the object count
|
||||
pind->max(count);
|
||||
// Set the range of the progress to the object count
|
||||
pind->max(count);
|
||||
|
||||
}
|
||||
pind->on_cancel([](){
|
||||
std::cout << "Cannot be cancelled!" << std::endl;
|
||||
});
|
||||
}
|
||||
|
||||
auto dist = print_ctl()->config().min_object_distance();
|
||||
auto dist = print_ctl()->config().min_object_distance();
|
||||
|
||||
// Create the arranger config
|
||||
auto min_obj_distance = static_cast<Coord>(dist/SCALING_FACTOR);
|
||||
// Create the arranger config
|
||||
auto min_obj_distance = static_cast<Coord>(dist/SCALING_FACTOR);
|
||||
|
||||
auto& bedpoints = print_ctl()->config().bed_shape.values;
|
||||
Polyline bed; bed.points.reserve(bedpoints.size());
|
||||
for(auto& v : bedpoints)
|
||||
bed.append(Point::new_scale(v(0), v(1)));
|
||||
auto& bedpoints = print_ctl()->config().bed_shape.values;
|
||||
Polyline bed; bed.points.reserve(bedpoints.size());
|
||||
for(auto& v : bedpoints)
|
||||
bed.append(Point::new_scale(v(0), v(1)));
|
||||
|
||||
if(pind) pind->update(0, _(L("Arranging objects...")));
|
||||
if(pind) pind->update(0, _(L("Arranging objects...")));
|
||||
|
||||
try {
|
||||
arr::arrange(*model_,
|
||||
min_obj_distance,
|
||||
bed,
|
||||
arr::BOX,
|
||||
false, // create many piles not just one pile
|
||||
[pind, count](unsigned rem) {
|
||||
if(pind)
|
||||
pind->update(count - rem, _(L("Arranging objects...")));
|
||||
});
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
report_issue(IssueType::ERR,
|
||||
_(L("Could not arrange model objects! "
|
||||
"Some geometries may be invalid.")),
|
||||
_(L("Exception occurred")));
|
||||
}
|
||||
try {
|
||||
arr::BedShapeHint hint;
|
||||
// TODO: from Sasha from GUI
|
||||
hint.type = arr::BedShapeType::WHO_KNOWS;
|
||||
|
||||
// Restore previous max value
|
||||
if(pind) {
|
||||
pind->max(pmax);
|
||||
pind->update(0, _(L("Arranging done.")));
|
||||
}
|
||||
});
|
||||
arr::arrange(*model_,
|
||||
min_obj_distance,
|
||||
bed,
|
||||
hint,
|
||||
false, // create many piles not just one pile
|
||||
[pind, count](unsigned rem) {
|
||||
if(pind)
|
||||
pind->update(count - rem, _(L("Arranging objects...")));
|
||||
});
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
report_issue(IssueType::ERR,
|
||||
_(L("Could not arrange model objects! "
|
||||
"Some geometries may be invalid.")),
|
||||
_(L("Exception occurred")));
|
||||
}
|
||||
|
||||
while( ftr.wait_for(std::chrono::milliseconds(10))
|
||||
!= std::future_status::ready) {
|
||||
process_events();
|
||||
// Restore previous max value
|
||||
if(pind) {
|
||||
pind->max(pmax);
|
||||
pind->update(0, _(L("Arranging done.")));
|
||||
pind->on_cancel(/*remove cancel function*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <atomic>
|
||||
#include <iostream>
|
||||
|
||||
#include "IProgressIndicator.hpp"
|
||||
#include "ProgressIndicator.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
|
@ -15,6 +15,7 @@ class Model;
|
|||
class Print;
|
||||
class PrintObject;
|
||||
class PrintConfig;
|
||||
class ProgressStatusBar;
|
||||
|
||||
/**
|
||||
* @brief A boilerplate class for creating application logic. It should provide
|
||||
|
|
@ -32,7 +33,7 @@ class AppControllerBoilerplate {
|
|||
public:
|
||||
|
||||
/// A Progress indicator object smart pointer
|
||||
using ProgresIndicatorPtr = std::shared_ptr<IProgressIndicator>;
|
||||
using ProgresIndicatorPtr = std::shared_ptr<ProgressIndicator>;
|
||||
|
||||
private:
|
||||
class PriData; // Some structure to store progress indication data
|
||||
|
|
@ -278,8 +279,7 @@ public:
|
|||
* @param gauge_id The ID of the gague widget of the status bar.
|
||||
* @param statusbar_id The ID of the status bar.
|
||||
*/
|
||||
void set_global_progress_indicator(unsigned gauge_id,
|
||||
unsigned statusbar_id);
|
||||
void set_global_progress_indicator(ProgressStatusBar *prs);
|
||||
|
||||
void arrange_model();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <future>
|
||||
|
||||
#include <slic3r/GUI/GUI.hpp>
|
||||
#include <slic3r/GUI/PngExportDialog.hpp>
|
||||
#include <slic3r/GUI/ProgressStatusBar.hpp>
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/filedlg.h>
|
||||
|
|
@ -105,10 +105,10 @@ namespace {
|
|||
* the main thread as well.
|
||||
*/
|
||||
class GuiProgressIndicator:
|
||||
public IProgressIndicator, public wxEvtHandler {
|
||||
public ProgressIndicator, public wxEvtHandler {
|
||||
|
||||
wxProgressDialog gauge_;
|
||||
using Base = IProgressIndicator;
|
||||
using Base = ProgressIndicator;
|
||||
wxString message_;
|
||||
int range_; wxString title_;
|
||||
bool is_asynch_ = false;
|
||||
|
|
@ -154,7 +154,7 @@ public:
|
|||
|
||||
virtual void cancel() override {
|
||||
update(max(), "Abort");
|
||||
IProgressIndicator::cancel();
|
||||
ProgressIndicator::cancel();
|
||||
}
|
||||
|
||||
virtual void state(float val) override {
|
||||
|
|
@ -211,31 +211,21 @@ AppControllerBoilerplate::create_progress_indicator(unsigned statenum,
|
|||
|
||||
namespace {
|
||||
|
||||
// A wrapper progress indicator class around the statusbar created in perl.
|
||||
class Wrapper: public IProgressIndicator, public wxEvtHandler {
|
||||
wxGauge *gauge_;
|
||||
wxStatusBar *stbar_;
|
||||
using Base = IProgressIndicator;
|
||||
class Wrapper: public ProgressIndicator, public wxEvtHandler {
|
||||
ProgressStatusBar *sbar_;
|
||||
using Base = ProgressIndicator;
|
||||
std::string message_;
|
||||
AppControllerBoilerplate& ctl_;
|
||||
|
||||
void showProgress(bool show = true) {
|
||||
gauge_->Show(show);
|
||||
sbar_->show_progress(show);
|
||||
}
|
||||
|
||||
void _state(unsigned st) {
|
||||
if( st <= IProgressIndicator::max() ) {
|
||||
if( st <= ProgressIndicator::max() ) {
|
||||
Base::state(st);
|
||||
|
||||
if(!gauge_->IsShown()) showProgress(true);
|
||||
|
||||
stbar_->SetStatusText(message_);
|
||||
if(static_cast<long>(st) == gauge_->GetRange()) {
|
||||
gauge_->SetValue(0);
|
||||
showProgress(false);
|
||||
} else {
|
||||
gauge_->SetValue(static_cast<int>(st));
|
||||
}
|
||||
sbar_->set_status_text(message_);
|
||||
sbar_->set_progress(st);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,12 +238,12 @@ class Wrapper: public IProgressIndicator, public wxEvtHandler {
|
|||
|
||||
public:
|
||||
|
||||
inline Wrapper(wxGauge *gauge, wxStatusBar *stbar,
|
||||
inline Wrapper(ProgressStatusBar *sbar,
|
||||
AppControllerBoilerplate& ctl):
|
||||
gauge_(gauge), stbar_(stbar), ctl_(ctl)
|
||||
sbar_(sbar), ctl_(ctl)
|
||||
{
|
||||
Base::max(static_cast<float>(gauge->GetRange()));
|
||||
Base::states(static_cast<unsigned>(gauge->GetRange()));
|
||||
Base::max(static_cast<float>(sbar_->get_range()));
|
||||
Base::states(static_cast<unsigned>(sbar_->get_range()));
|
||||
|
||||
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
||||
&Wrapper::_state,
|
||||
|
|
@ -266,8 +256,8 @@ public:
|
|||
|
||||
virtual void max(float val) override {
|
||||
if(val > 1.0) {
|
||||
gauge_->SetRange(static_cast<int>(val));
|
||||
IProgressIndicator::max(val);
|
||||
sbar_->set_range(static_cast<int>(val));
|
||||
ProgressIndicator::max(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,135 +284,19 @@ public:
|
|||
|
||||
virtual void title(const string & /*title*/) override {}
|
||||
|
||||
virtual void on_cancel(CancelFn fn) override {
|
||||
sbar_->set_cancel_callback(fn);
|
||||
Base::on_cancel(fn);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
void AppController::set_global_progress_indicator(
|
||||
unsigned gid,
|
||||
unsigned sid)
|
||||
void AppController::set_global_progress_indicator(ProgressStatusBar *prsb)
|
||||
{
|
||||
wxGauge* gauge = dynamic_cast<wxGauge*>(wxWindow::FindWindowById(gid));
|
||||
wxStatusBar* sb = dynamic_cast<wxStatusBar*>(wxWindow::FindWindowById(sid));
|
||||
|
||||
if(gauge && sb) {
|
||||
global_progress_indicator(std::make_shared<Wrapper>(gauge, sb, *this));
|
||||
if(prsb) {
|
||||
global_progress_indicator(std::make_shared<Wrapper>(prsb, *this));
|
||||
}
|
||||
}
|
||||
|
||||
//PrintController::PngExportData PrintController::collect_png_export_data()
|
||||
//{
|
||||
|
||||
// // Implement the logic of the PngExportDialog
|
||||
// class PngExportView: public PngExportDialog {
|
||||
// double ratio_, bs_ratio_;
|
||||
// PrintController& ctl_;
|
||||
// public:
|
||||
|
||||
// PngExportView(PrintController& ctl):
|
||||
// PngExportDialog(wxTheApp->GetTopWindow()), ctl_(ctl)
|
||||
// {
|
||||
// ratio_ = double(spin_reso_width_->GetValue()) /
|
||||
// spin_reso_height_->GetValue();
|
||||
|
||||
// bs_ratio_ = bed_width_spin_->GetValue() /
|
||||
// bed_height_spin_->GetValue();
|
||||
// }
|
||||
|
||||
// PngExportData export_data() const {
|
||||
// PrintController::PngExportData ret;
|
||||
// ret.zippath = filepick_ctl_->GetPath();
|
||||
// ret.width_px = spin_reso_width_->GetValue();
|
||||
// ret.height_px = spin_reso_height_->GetValue();
|
||||
// ret.width_mm = bed_width_spin_->GetValue();
|
||||
// ret.height_mm = bed_height_spin_->GetValue();
|
||||
// ret.exp_time_s = exptime_spin_->GetValue();
|
||||
// ret.exp_time_first_s = exptime_first_spin_->GetValue();
|
||||
// ret.corr_x = corr_spin_x_->GetValue();
|
||||
// ret.corr_y = corr_spin_y_->GetValue();
|
||||
// ret.corr_z = corr_spin_z_->GetValue();
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
// void prefill(const PngExportData& data) {
|
||||
// filepick_ctl_->SetPath(data.zippath);
|
||||
// spin_reso_width_->SetValue(data.width_px);
|
||||
// spin_reso_height_->SetValue(data.height_px);
|
||||
// bed_width_spin_->SetValue(data.width_mm);
|
||||
// bed_height_spin_->SetValue(data.height_mm);
|
||||
// exptime_spin_->SetValue(data.exp_time_s);
|
||||
// exptime_first_spin_->SetValue(data.exp_time_first_s);
|
||||
// corr_spin_x_->SetValue(data.corr_x);
|
||||
// corr_spin_y_->SetValue(data.corr_y);
|
||||
// corr_spin_z_->SetValue(data.corr_z);
|
||||
// if(data.zippath.empty()) export_btn_->Disable();
|
||||
// else export_btn_->Enable();
|
||||
// }
|
||||
|
||||
// virtual void ResoLock( wxCommandEvent& /*event*/ ) override {
|
||||
// ratio_ = double(spin_reso_width_->GetValue()) /
|
||||
// double(spin_reso_height_->GetValue());
|
||||
// }
|
||||
|
||||
// virtual void BedsizeLock( wxCommandEvent& /*event*/ ) override {
|
||||
// bs_ratio_ = bed_width_spin_->GetValue() /
|
||||
// bed_height_spin_->GetValue();
|
||||
// }
|
||||
|
||||
// virtual void EvalResoSpin( wxCommandEvent& event ) override {
|
||||
// if(reso_lock_btn_->GetValue()) {
|
||||
// if(event.GetId() == spin_reso_width_->GetId()) {
|
||||
// spin_reso_height_->SetValue(
|
||||
// std::round(spin_reso_width_->GetValue()/ratio_));
|
||||
// spin_reso_height_->Update();
|
||||
// } else {
|
||||
// spin_reso_width_->SetValue(
|
||||
// std::round(spin_reso_height_->GetValue()*ratio_));
|
||||
// spin_reso_width_->Update();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// virtual void EvalBedSpin( wxCommandEvent& event ) override {
|
||||
// if(bedsize_lock_btn_->GetValue()) {
|
||||
// if(event.GetId() == bed_width_spin_->GetId()) {
|
||||
// bed_height_spin_->SetValue(
|
||||
// std::round(bed_width_spin_->GetValue()/bs_ratio_));
|
||||
// bed_height_spin_->Update();
|
||||
// } else {
|
||||
// bed_width_spin_->SetValue(
|
||||
// std::round(bed_height_spin_->GetValue()*bs_ratio_));
|
||||
// bed_width_spin_->Update();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// virtual void onFileChanged( wxFileDirPickerEvent& event ) {
|
||||
// if(filepick_ctl_->GetPath().IsEmpty()) export_btn_->Disable();
|
||||
// else export_btn_->Enable();
|
||||
// }
|
||||
|
||||
// virtual void Close( wxCommandEvent& /*event*/ ) {
|
||||
// auto ret = wxID_OK;
|
||||
|
||||
// if(wxFileName(filepick_ctl_->GetPath()).Exists())
|
||||
// if(!ctl_.report_issue(PrintController::IssueType::WARN_Q,
|
||||
// _(L("File already exists. Overwrite?")),
|
||||
// _(L("Warning")))) ret = wxID_CANCEL;
|
||||
// EndModal(ret);
|
||||
// }
|
||||
// };
|
||||
|
||||
// PngExportView exdlg(*this);
|
||||
|
||||
// exdlg.prefill(prev_expdata_);
|
||||
|
||||
// auto r = exdlg.ShowModal();
|
||||
|
||||
// auto ret = exdlg.export_data();
|
||||
// prev_expdata_ = ret;
|
||||
|
||||
// if(r != wxID_OK) ret.zippath.clear();
|
||||
|
||||
// return ret;
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,9 +195,9 @@ const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f };
|
|||
const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f };
|
||||
|
||||
GLVolume::GLVolume(float r, float g, float b, float a)
|
||||
: m_origin(0, 0, 0)
|
||||
, m_angle_z(0.0f)
|
||||
, m_scale_factor(1.0f)
|
||||
: m_offset(Vec3d::Zero())
|
||||
, m_rotation(0.0)
|
||||
, m_scaling_factor(1.0)
|
||||
, m_world_matrix(Transform3f::Identity())
|
||||
, m_world_matrix_dirty(true)
|
||||
, m_transformed_bounding_box_dirty(true)
|
||||
|
|
@ -255,43 +255,43 @@ void GLVolume::set_render_color()
|
|||
set_render_color(color, 4);
|
||||
}
|
||||
|
||||
const Vec3d& GLVolume::get_origin() const
|
||||
double GLVolume::get_rotation()
|
||||
{
|
||||
return m_origin;
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
float GLVolume::get_angle_z()
|
||||
void GLVolume::set_rotation(double rotation)
|
||||
{
|
||||
return m_angle_z;
|
||||
}
|
||||
|
||||
void GLVolume::set_origin(const Vec3d& origin)
|
||||
{
|
||||
if (m_origin != origin)
|
||||
if (m_rotation != rotation)
|
||||
{
|
||||
m_origin = origin;
|
||||
m_rotation = rotation;
|
||||
m_world_matrix_dirty = true;
|
||||
m_transformed_bounding_box_dirty = true;
|
||||
m_transformed_convex_hull_bounding_box_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GLVolume::set_angle_z(float angle_z)
|
||||
const Vec3d& GLVolume::get_offset() const
|
||||
{
|
||||
if (m_angle_z != angle_z)
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
void GLVolume::set_offset(const Vec3d& offset)
|
||||
{
|
||||
if (m_offset != offset)
|
||||
{
|
||||
m_angle_z = angle_z;
|
||||
m_offset = offset;
|
||||
m_world_matrix_dirty = true;
|
||||
m_transformed_bounding_box_dirty = true;
|
||||
m_transformed_convex_hull_bounding_box_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GLVolume::set_scale_factor(float scale_factor)
|
||||
void GLVolume::set_scaling_factor(double factor)
|
||||
{
|
||||
if (m_scale_factor != scale_factor)
|
||||
if (m_scaling_factor != factor)
|
||||
{
|
||||
m_scale_factor = scale_factor;
|
||||
m_scaling_factor = factor;
|
||||
m_world_matrix_dirty = true;
|
||||
m_transformed_bounding_box_dirty = true;
|
||||
m_transformed_convex_hull_bounding_box_dirty = true;
|
||||
|
|
@ -303,14 +303,32 @@ void GLVolume::set_convex_hull(const TriangleMesh& convex_hull)
|
|||
m_convex_hull = &convex_hull;
|
||||
}
|
||||
|
||||
void GLVolume::set_select_group_id(const std::string& select_by)
|
||||
{
|
||||
if (select_by == "object")
|
||||
select_group_id = object_idx() * 1000000;
|
||||
else if (select_by == "volume")
|
||||
select_group_id = object_idx() * 1000000 + volume_idx() * 1000;
|
||||
else if (select_by == "instance")
|
||||
select_group_id = composite_id;
|
||||
}
|
||||
|
||||
void GLVolume::set_drag_group_id(const std::string& drag_by)
|
||||
{
|
||||
if (drag_by == "object")
|
||||
drag_group_id = object_idx() * 1000;
|
||||
else if (drag_by == "instance")
|
||||
drag_group_id = object_idx() * 1000 + instance_idx();
|
||||
}
|
||||
|
||||
const Transform3f& GLVolume::world_matrix() const
|
||||
{
|
||||
if (m_world_matrix_dirty)
|
||||
{
|
||||
m_world_matrix = Transform3f::Identity();
|
||||
m_world_matrix.translate(Vec3f((float)m_origin(0), (float)m_origin(1), (float)m_origin(2)));
|
||||
m_world_matrix.rotate(Eigen::AngleAxisf(m_angle_z, Vec3f::UnitZ()));
|
||||
m_world_matrix.scale(m_scale_factor);
|
||||
m_world_matrix.translate(m_offset.cast<float>());
|
||||
m_world_matrix.rotate(Eigen::AngleAxisf((float)m_rotation, Vec3f::UnitZ()));
|
||||
m_world_matrix.scale((float)m_scaling_factor);
|
||||
m_world_matrix_dirty = false;
|
||||
}
|
||||
return m_world_matrix;
|
||||
|
|
@ -384,9 +402,9 @@ void GLVolume::render() const
|
|||
|
||||
::glCullFace(GL_BACK);
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_origin(0), m_origin(1), m_origin(2));
|
||||
::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f);
|
||||
::glScalef(m_scale_factor, m_scale_factor, m_scale_factor);
|
||||
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
|
||||
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
|
||||
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
|
||||
if (this->indexed_vertex_array.indexed())
|
||||
this->indexed_vertex_array.render(this->tverts_range, this->qverts_range);
|
||||
else
|
||||
|
|
@ -510,9 +528,9 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c
|
|||
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), nullptr);
|
||||
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_origin(0), m_origin(1), m_origin(2));
|
||||
::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f);
|
||||
::glScalef(m_scale_factor, m_scale_factor, m_scale_factor);
|
||||
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
|
||||
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
|
||||
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
|
||||
|
||||
if (n_triangles > 0)
|
||||
{
|
||||
|
|
@ -555,9 +573,9 @@ void GLVolume::render_legacy() const
|
|||
::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data());
|
||||
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_origin(0), m_origin(1), m_origin(2));
|
||||
::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f);
|
||||
::glScalef(m_scale_factor, m_scale_factor, m_scale_factor);
|
||||
::glTranslated(m_offset(0), m_offset(1), m_offset(2));
|
||||
::glRotated(m_rotation * 180.0 / (double)PI, 0.0, 0.0, 1.0);
|
||||
::glScaled(m_scaling_factor, m_scaling_factor, m_scaling_factor);
|
||||
|
||||
if (n_triangles > 0)
|
||||
::glDrawElements(GL_TRIANGLES, n_triangles, GL_UNSIGNED_INT, indexed_vertex_array.triangle_indices.data() + tverts_range.first);
|
||||
|
|
@ -655,17 +673,8 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||
v.indexed_vertex_array.finalize_geometry(use_VBOs);
|
||||
v.composite_id = obj_idx * 1000000 + volume_idx * 1000 + instance_idx;
|
||||
if (select_by == "object")
|
||||
v.select_group_id = obj_idx * 1000000;
|
||||
else if (select_by == "volume")
|
||||
v.select_group_id = obj_idx * 1000000 + volume_idx * 1000;
|
||||
else if (select_by == "instance")
|
||||
v.select_group_id = v.composite_id;
|
||||
if (drag_by == "object")
|
||||
v.drag_group_id = obj_idx * 1000;
|
||||
else if (drag_by == "instance")
|
||||
v.drag_group_id = obj_idx * 1000 + instance_idx;
|
||||
|
||||
v.set_select_group_id(select_by);
|
||||
v.set_drag_group_id(drag_by);
|
||||
if (!model_volume->modifier)
|
||||
{
|
||||
v.set_convex_hull(model_volume->get_convex_hull());
|
||||
|
|
@ -675,9 +684,9 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
}
|
||||
v.is_modifier = model_volume->modifier;
|
||||
v.shader_outside_printer_detection_enabled = !model_volume->modifier;
|
||||
v.set_origin(Vec3d(instance->offset(0), instance->offset(1), 0.0));
|
||||
v.set_angle_z(instance->rotation);
|
||||
v.set_scale_factor(instance->scaling_factor);
|
||||
v.set_offset(Vec3d(instance->offset(0), instance->offset(1), 0.0));
|
||||
v.set_rotation(instance->rotation);
|
||||
v.set_scaling_factor(instance->scaling_factor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -746,7 +755,7 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||
else
|
||||
v.indexed_vertex_array.load_mesh_flat_shading(mesh);
|
||||
|
||||
v.set_origin(Vec3d(pos_x, pos_y, 0.));
|
||||
v.set_offset(Vec3d(pos_x, pos_y, 0.0));
|
||||
|
||||
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
|
||||
v.bounding_box = v.indexed_vertex_array.bounding_box();
|
||||
|
|
@ -949,6 +958,24 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con
|
|||
}
|
||||
}
|
||||
|
||||
void GLVolumeCollection::set_select_by(const std::string& select_by)
|
||||
{
|
||||
for (GLVolume *vol : this->volumes)
|
||||
{
|
||||
if (vol != nullptr)
|
||||
vol->set_select_group_id(select_by);
|
||||
}
|
||||
}
|
||||
|
||||
void GLVolumeCollection::set_drag_by(const std::string& drag_by)
|
||||
{
|
||||
for (GLVolume *vol : this->volumes)
|
||||
{
|
||||
if (vol != nullptr)
|
||||
vol->set_drag_group_id(drag_by);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> GLVolumeCollection::get_current_print_zs(bool active_only) const
|
||||
{
|
||||
// Collect layer top positions of all volumes.
|
||||
|
|
@ -1190,7 +1217,7 @@ static void thick_lines_to_indexed_vertex_array(
|
|||
b1_prev = b1;
|
||||
v_prev = v;
|
||||
|
||||
if (bottom_z_different)
|
||||
if (bottom_z_different && (closed || (!is_first && !is_last)))
|
||||
{
|
||||
// Found a change of the layer thickness -> Add a cap at the beginning of this segment.
|
||||
volume.push_quad(idx_a[BOTTOM], idx_a[RIGHT], idx_a[TOP], idx_a[LEFT]);
|
||||
|
|
@ -1198,10 +1225,10 @@ static void thick_lines_to_indexed_vertex_array(
|
|||
|
||||
if (! closed) {
|
||||
// Terminate open paths with caps.
|
||||
if (is_first && !bottom_z_different)
|
||||
if (is_first)
|
||||
volume.push_quad(idx_a[BOTTOM], idx_a[RIGHT], idx_a[TOP], idx_a[LEFT]);
|
||||
// We don't use 'else' because both cases are true if we have only one line.
|
||||
if (is_last && !bottom_z_different)
|
||||
if (is_last)
|
||||
volume.push_quad(idx_b[BOTTOM], idx_b[LEFT], idx_b[TOP], idx_b[RIGHT]);
|
||||
}
|
||||
|
||||
|
|
@ -1772,12 +1799,12 @@ void _3DScene::set_model(wxGLCanvas* canvas, Model* model)
|
|||
|
||||
void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||
{
|
||||
return s_canvas_mgr.set_bed_shape(canvas, shape);
|
||||
s_canvas_mgr.set_bed_shape(canvas, shape);
|
||||
}
|
||||
|
||||
void _3DScene::set_auto_bed_shape(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.set_auto_bed_shape(canvas);
|
||||
s_canvas_mgr.set_auto_bed_shape(canvas);
|
||||
}
|
||||
|
||||
BoundingBoxf3 _3DScene::get_volumes_bounding_box(wxGLCanvas* canvas)
|
||||
|
|
@ -1792,22 +1819,27 @@ void _3DScene::set_axes_length(wxGLCanvas* canvas, float length)
|
|||
|
||||
void _3DScene::set_cutting_plane(wxGLCanvas* canvas, float z, const ExPolygons& polygons)
|
||||
{
|
||||
return s_canvas_mgr.set_cutting_plane(canvas, z, polygons);
|
||||
s_canvas_mgr.set_cutting_plane(canvas, z, polygons);
|
||||
}
|
||||
|
||||
void _3DScene::set_color_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
return s_canvas_mgr.set_color_by(canvas, value);
|
||||
s_canvas_mgr.set_color_by(canvas, value);
|
||||
}
|
||||
|
||||
void _3DScene::set_select_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
return s_canvas_mgr.set_select_by(canvas, value);
|
||||
s_canvas_mgr.set_select_by(canvas, value);
|
||||
}
|
||||
|
||||
void _3DScene::set_drag_by(wxGLCanvas* canvas, const std::string& value)
|
||||
{
|
||||
return s_canvas_mgr.set_drag_by(canvas, value);
|
||||
s_canvas_mgr.set_drag_by(canvas, value);
|
||||
}
|
||||
|
||||
std::string _3DScene::get_select_by(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_select_by(canvas);
|
||||
}
|
||||
|
||||
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||
|
|
@ -2025,6 +2057,11 @@ void _3DScene::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callb
|
|||
s_canvas_mgr.register_on_gizmo_rotate_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_gizmo_flatten_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_update_geometry_info_callback(canvas, callback);
|
||||
|
|
@ -2080,6 +2117,11 @@ void _3DScene::register_action_layersediting_callback(wxGLCanvas* canvas, void*
|
|||
s_canvas_mgr.register_action_layersediting_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_action_selectbyparts_callback(canvas, callback);
|
||||
}
|
||||
|
||||
static inline int hex_digit_to_int(const char c)
|
||||
{
|
||||
return
|
||||
|
|
@ -2117,6 +2159,11 @@ std::vector<int> _3DScene::load_object(wxGLCanvas* canvas, const Model* model, i
|
|||
return s_canvas_mgr.load_object(canvas, model, obj_idx);
|
||||
}
|
||||
|
||||
int _3DScene::get_first_volume_id(wxGLCanvas* canvas, int obj_idx)
|
||||
{
|
||||
return s_canvas_mgr.get_first_volume_id(canvas, obj_idx);
|
||||
}
|
||||
|
||||
void _3DScene::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
s_canvas_mgr.reload_scene(canvas, force);
|
||||
|
|
|
|||
|
|
@ -255,11 +255,11 @@ public:
|
|||
|
||||
private:
|
||||
// Offset of the volume to be rendered.
|
||||
Vec3d m_origin;
|
||||
Vec3d m_offset;
|
||||
// Rotation around Z axis of the volume to be rendered.
|
||||
float m_angle_z;
|
||||
double m_rotation;
|
||||
// Scale factor of the volume to be rendered.
|
||||
float m_scale_factor;
|
||||
double m_scaling_factor;
|
||||
// World matrix of the volume to be rendered.
|
||||
mutable Transform3f m_world_matrix;
|
||||
// Whether or not is needed to recalculate the world matrix.
|
||||
|
|
@ -327,13 +327,19 @@ public:
|
|||
// Sets render color in dependence of current state
|
||||
void set_render_color();
|
||||
|
||||
float get_angle_z();
|
||||
const Vec3d& get_origin() const;
|
||||
void set_origin(const Vec3d& origin);
|
||||
void set_angle_z(float angle_z);
|
||||
void set_scale_factor(float scale_factor);
|
||||
double get_rotation();
|
||||
void set_rotation(double rotation);
|
||||
|
||||
const Vec3d& get_offset() const;
|
||||
void set_offset(const Vec3d& offset);
|
||||
|
||||
void set_scaling_factor(double factor);
|
||||
|
||||
void set_convex_hull(const TriangleMesh& convex_hull);
|
||||
|
||||
void set_select_group_id(const std::string& select_by);
|
||||
void set_drag_group_id(const std::string& drag_by);
|
||||
|
||||
int object_idx() const { return this->composite_id / 1000000; }
|
||||
int volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
||||
int instance_idx() const { return this->composite_id % 1000; }
|
||||
|
|
@ -443,6 +449,9 @@ public:
|
|||
|
||||
void update_colors_by_extruder(const DynamicPrintConfig* config);
|
||||
|
||||
void set_select_by(const std::string& select_by);
|
||||
void set_drag_by(const std::string& drag_by);
|
||||
|
||||
// Returns a vector containing the sorted list of all the print_zs of the volumes contained in this collection
|
||||
std::vector<double> get_current_print_zs(bool active_only) const;
|
||||
|
||||
|
|
@ -496,6 +505,8 @@ public:
|
|||
static void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
||||
static void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||
|
||||
static std::string get_select_by(wxGLCanvas* canvas);
|
||||
|
||||
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
||||
static bool is_layers_editing_allowed(wxGLCanvas* canvas);
|
||||
static bool is_shader_enabled(wxGLCanvas* canvas);
|
||||
|
|
@ -547,6 +558,7 @@ public:
|
|||
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
static void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
|
@ -559,10 +571,13 @@ public:
|
|||
static void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
||||
|
||||
static int get_first_volume_id(wxGLCanvas* canvas, int obj_idx);
|
||||
|
||||
static void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
static void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
||||
|
|
|
|||
|
|
@ -228,24 +228,20 @@ namespace Slic3r { namespace GUI {
|
|||
}), temp->GetId());
|
||||
#endif // __WXGTK__
|
||||
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent)
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent& evt)
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
bChangedValueEvent = true;
|
||||
#else
|
||||
on_change_field();
|
||||
if (bChangedValueEvent)
|
||||
#endif //__WXGTK__
|
||||
on_change_field();
|
||||
}), temp->GetId());
|
||||
|
||||
#ifdef __WXGTK__
|
||||
temp->Bind(wxEVT_KEY_UP, [this](wxKeyEvent& event)
|
||||
{
|
||||
if (bChangedValueEvent) {
|
||||
on_change_field();
|
||||
bChangedValueEvent = false;
|
||||
}
|
||||
event.Skip();
|
||||
});
|
||||
// to correct value updating on GTK we should:
|
||||
// call on_change_field() on wxEVT_KEY_UP instead of wxEVT_TEXT
|
||||
// and prevent value updating on wxEVT_KEY_DOWN
|
||||
temp->Bind(wxEVT_KEY_DOWN, &TextCtrl::change_field_value, this);
|
||||
temp->Bind(wxEVT_KEY_UP, &TextCtrl::change_field_value, this);
|
||||
#endif //__WXGTK__
|
||||
|
||||
// select all text using Ctrl+A
|
||||
|
|
@ -271,6 +267,15 @@ namespace Slic3r { namespace GUI {
|
|||
void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }
|
||||
void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(false); }
|
||||
|
||||
#ifdef __WXGTK__
|
||||
void TextCtrl::change_field_value(wxEvent& event)
|
||||
{
|
||||
if (bChangedValueEvent = event.GetEventType()==wxEVT_KEY_UP)
|
||||
on_change_field();
|
||||
event.Skip();
|
||||
};
|
||||
#endif //__WXGTK__
|
||||
|
||||
void CheckBox::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
||||
|
|
|
|||
|
|
@ -235,7 +235,8 @@ inline bool is_sizer_field(const t_field& obj) { return !is_bad_field(obj) && ob
|
|||
class TextCtrl : public Field {
|
||||
using Field::Field;
|
||||
#ifdef __WXGTK__
|
||||
bool bChangedValueEvent = false;
|
||||
bool bChangedValueEvent = true;
|
||||
void change_field_value(wxEvent& event);
|
||||
#endif //__WXGTK__
|
||||
public:
|
||||
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||
|
|
|
|||
|
|
@ -1123,7 +1123,6 @@ const float GLCanvas3D::Gizmos::OverlayGapY = 5.0f * OverlayTexturesScale;
|
|||
GLCanvas3D::Gizmos::Gizmos()
|
||||
: m_enabled(false)
|
||||
, m_current(Undefined)
|
||||
, m_dragging(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1134,7 +1133,16 @@ GLCanvas3D::Gizmos::~Gizmos()
|
|||
|
||||
bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
|
||||
{
|
||||
GLGizmoBase* gizmo = new GLGizmoScale3D(parent);
|
||||
GLGizmoBase* gizmo = new GLGizmoMove3D(parent);
|
||||
if (gizmo == nullptr)
|
||||
return false;
|
||||
|
||||
if (!gizmo->init())
|
||||
return false;
|
||||
|
||||
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
|
||||
|
||||
gizmo = new GLGizmoScale3D(parent);
|
||||
if (gizmo == nullptr)
|
||||
return false;
|
||||
|
||||
|
|
@ -1320,16 +1328,6 @@ void GLCanvas3D::Gizmos::update(const Linef3& mouse_ray)
|
|||
curr->update(mouse_ray);
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::refresh()
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
GLGizmoBase* curr = _get_current();
|
||||
if (curr != nullptr)
|
||||
curr->refresh();
|
||||
}
|
||||
|
||||
GLCanvas3D::Gizmos::EType GLCanvas3D::Gizmos::get_current_type() const
|
||||
{
|
||||
return m_current;
|
||||
|
|
@ -1346,25 +1344,43 @@ bool GLCanvas3D::Gizmos::is_running() const
|
|||
|
||||
bool GLCanvas3D::Gizmos::is_dragging() const
|
||||
{
|
||||
return m_dragging;
|
||||
GLGizmoBase* curr = _get_current();
|
||||
return (curr != nullptr) ? curr->is_dragging() : false;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::start_dragging()
|
||||
void GLCanvas3D::Gizmos::start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
m_dragging = true;
|
||||
GLGizmoBase* curr = _get_current();
|
||||
if (curr != nullptr)
|
||||
curr->start_dragging();
|
||||
curr->start_dragging(box);
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::stop_dragging()
|
||||
{
|
||||
m_dragging = false;
|
||||
GLGizmoBase* curr = _get_current();
|
||||
if (curr != nullptr)
|
||||
curr->stop_dragging();
|
||||
}
|
||||
|
||||
Vec3d GLCanvas3D::Gizmos::get_position() const
|
||||
{
|
||||
if (!m_enabled)
|
||||
return Vec3d::Zero();
|
||||
|
||||
GizmosMap::const_iterator it = m_gizmos.find(Move);
|
||||
return (it != m_gizmos.end()) ? reinterpret_cast<GLGizmoMove3D*>(it->second)->get_position() : Vec3d::Zero();
|
||||
}
|
||||
|
||||
void GLCanvas3D::Gizmos::set_position(const Vec3d& position)
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
GizmosMap::const_iterator it = m_gizmos.find(Move);
|
||||
if (it != m_gizmos.end())
|
||||
reinterpret_cast<GLGizmoMove3D*>(it->second)->set_position(position);
|
||||
}
|
||||
|
||||
float GLCanvas3D::Gizmos::get_scale() const
|
||||
{
|
||||
if (!m_enabled)
|
||||
|
|
@ -2018,6 +2034,9 @@ void GLCanvas3D::update_volumes_selection(const std::vector<int>& selections)
|
|||
if (m_model == nullptr)
|
||||
return;
|
||||
|
||||
if (selections.empty())
|
||||
return;
|
||||
|
||||
for (unsigned int obj_idx = 0; obj_idx < (unsigned int)m_model->objects.size(); ++obj_idx)
|
||||
{
|
||||
if ((selections[obj_idx] == 1) && (obj_idx < (unsigned int)m_objects_volumes_idxs.size()))
|
||||
|
|
@ -2144,11 +2163,23 @@ void GLCanvas3D::set_color_by(const std::string& value)
|
|||
void GLCanvas3D::set_select_by(const std::string& value)
|
||||
{
|
||||
m_select_by = value;
|
||||
m_volumes.set_select_by(value);
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_drag_by(const std::string& value)
|
||||
{
|
||||
m_drag_by = value;
|
||||
m_volumes.set_drag_by(value);
|
||||
}
|
||||
|
||||
const std::string& GLCanvas3D::get_select_by() const
|
||||
{
|
||||
return m_select_by;
|
||||
}
|
||||
|
||||
const std::string& GLCanvas3D::get_drag_by() const
|
||||
{
|
||||
return m_drag_by;
|
||||
}
|
||||
|
||||
float GLCanvas3D::get_camera_zoom() const
|
||||
|
|
@ -2327,6 +2358,7 @@ void GLCanvas3D::update_gizmos_data()
|
|||
ModelInstance* model_instance = model_object->instances[0];
|
||||
if (model_instance != nullptr)
|
||||
{
|
||||
m_gizmos.set_position(Vec3d(model_instance->offset(0), model_instance->offset(1), 0.0));
|
||||
m_gizmos.set_scale(model_instance->scaling_factor);
|
||||
m_gizmos.set_angle_z(model_instance->rotation);
|
||||
m_gizmos.set_flattening_data(model_object);
|
||||
|
|
@ -2335,6 +2367,7 @@ void GLCanvas3D::update_gizmos_data()
|
|||
}
|
||||
else
|
||||
{
|
||||
m_gizmos.set_position(Vec3d::Zero());
|
||||
m_gizmos.set_scale(1.0f);
|
||||
m_gizmos.set_angle_z(0.0f);
|
||||
m_gizmos.set_flattening_data(nullptr);
|
||||
|
|
@ -2432,6 +2465,17 @@ std::vector<int> GLCanvas3D::load_object(const Model& model, int obj_idx)
|
|||
return std::vector<int>();
|
||||
}
|
||||
|
||||
int GLCanvas3D::get_first_volume_id(int obj_idx) const
|
||||
{
|
||||
for (int i = 0; i < (int)m_volumes.volumes.size(); ++i)
|
||||
{
|
||||
if ((m_volumes.volumes[i] != nullptr) && (m_volumes.volumes[i]->object_idx() == obj_idx))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void GLCanvas3D::reload_scene(bool force)
|
||||
{
|
||||
if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr))
|
||||
|
|
@ -2467,8 +2511,6 @@ void GLCanvas3D::reload_scene(bool force)
|
|||
if (!m_objects_selections.empty())
|
||||
update_gizmos_data();
|
||||
|
||||
m_gizmos.refresh();
|
||||
|
||||
if (m_config->has("nozzle_diameter"))
|
||||
{
|
||||
// Should the wipe tower be visualized ?
|
||||
|
|
@ -2691,6 +2733,12 @@ void GLCanvas3D::register_on_gizmo_rotate_callback(void* callback)
|
|||
m_on_gizmo_rotate_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_on_gizmo_flatten_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
m_on_gizmo_flatten_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_on_update_geometry_info_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
|
|
@ -2757,6 +2805,12 @@ void GLCanvas3D::register_action_layersediting_callback(void* callback)
|
|||
m_action_layersediting_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_action_selectbyparts_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
m_action_selectbyparts_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::bind_event_handlers()
|
||||
{
|
||||
if (m_canvas != nullptr)
|
||||
|
|
@ -2952,7 +3006,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.position = Vec2d(-1.0, -1.0);
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1))
|
||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1) && !gizmos_overlay_contains_mouse && (toolbar_contains_mouse == -1))
|
||||
m_on_double_click_callback.call();
|
||||
else if (evt.LeftDClick() && (toolbar_contains_mouse != -1))
|
||||
{
|
||||
|
|
@ -2993,16 +3047,16 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else if ((selected_object_idx != -1) && m_gizmos.grabber_contains_mouse())
|
||||
{
|
||||
update_gizmos_data();
|
||||
m_gizmos.start_dragging();
|
||||
m_gizmos.start_dragging(_selected_volumes_bounding_box());
|
||||
m_mouse.drag.gizmo_volume_idx = _get_first_selected_volume_id(selected_object_idx);
|
||||
|
||||
if (m_gizmos.get_current_type() == Gizmos::Flatten) {
|
||||
// Rotate the object so the normal points downward:
|
||||
Vec3d normal = m_gizmos.get_flattening_normal();
|
||||
if (normal != Vec3d::Zero()) {
|
||||
Vec3d axis = normal(2) > 0.999f ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ());
|
||||
float angle = -acos(-normal(2));
|
||||
m_on_gizmo_rotate_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
|
||||
if (normal(0) != 0.0 || normal(1) != 0.0 || normal(2) != 0.0) {
|
||||
Vec3d axis = normal(2) > 0.999 ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()).normalized();
|
||||
float angle = acos(clamp(-1.0, 1.0, -normal(2)));
|
||||
m_on_gizmo_flatten_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3036,14 +3090,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
|
||||
update_gizmos_data();
|
||||
m_gizmos.refresh();
|
||||
m_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// propagate event through callback
|
||||
if (m_picking_enabled && (volume_idx != -1))
|
||||
_on_select(volume_idx);
|
||||
_on_select(volume_idx, selected_object_idx);
|
||||
|
||||
if (volume_idx != -1)
|
||||
{
|
||||
|
|
@ -3126,10 +3179,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
// Apply new temporary volume origin and ignore Z.
|
||||
for (GLVolume* v : volumes)
|
||||
v->set_origin(v->get_origin() + Vec3d(vector(0), vector(1), 0.0));
|
||||
{
|
||||
v->set_offset(v->get_offset() + Vec3d(vector(0), vector(1), 0.0));
|
||||
}
|
||||
|
||||
update_position_values(volume->get_offset());
|
||||
m_mouse.drag.start_position_3D = cur_pos;
|
||||
m_gizmos.refresh();
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -3160,14 +3215,27 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
switch (m_gizmos.get_current_type())
|
||||
{
|
||||
case Gizmos::Move:
|
||||
{
|
||||
// Apply new temporary offset
|
||||
GLVolume* volume = m_volumes.volumes[m_mouse.drag.gizmo_volume_idx];
|
||||
Vec3d offset = m_gizmos.get_position() - volume->get_offset();
|
||||
for (GLVolume* v : volumes)
|
||||
{
|
||||
v->set_offset(v->get_offset() + offset);
|
||||
}
|
||||
update_position_values(volume->get_offset());
|
||||
break;
|
||||
}
|
||||
case Gizmos::Scale:
|
||||
{
|
||||
// Apply new temporary scale factor
|
||||
float scale_factor = m_gizmos.get_scale();
|
||||
for (GLVolume* v : volumes)
|
||||
{
|
||||
v->set_scale_factor(scale_factor);
|
||||
v->set_scaling_factor((double)scale_factor);
|
||||
}
|
||||
update_scale_values((double)scale_factor);
|
||||
break;
|
||||
}
|
||||
case Gizmos::Rotate:
|
||||
|
|
@ -3176,8 +3244,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
float angle_z = m_gizmos.get_angle_z();
|
||||
for (GLVolume* v : volumes)
|
||||
{
|
||||
v->set_angle_z(angle_z);
|
||||
v->set_rotation((double)angle_z);
|
||||
}
|
||||
update_rotation_value((double)angle_z, Z);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -3193,13 +3262,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
const Vec3d& size = bb.size();
|
||||
m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale());
|
||||
update_scale_values(size, m_gizmos.get_scale());
|
||||
update_rotation_value(volumes[0]->get_angle_z(), "z");
|
||||
}
|
||||
|
||||
if ((m_gizmos.get_current_type() != Gizmos::Rotate) && (volumes.size() > 1))
|
||||
m_gizmos.refresh();
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.Dragging() && !gizmos_overlay_contains_mouse)
|
||||
|
|
@ -3284,7 +3348,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (m_picking_enabled && !m_toolbar_action_running)
|
||||
{
|
||||
deselect_volumes();
|
||||
_on_select(-1);
|
||||
_on_select(-1, -1);
|
||||
update_gizmos_data();
|
||||
}
|
||||
}
|
||||
|
|
@ -3292,10 +3356,30 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
{
|
||||
switch (m_gizmos.get_current_type())
|
||||
{
|
||||
case Gizmos::Move:
|
||||
{
|
||||
// get all volumes belonging to the same group, if any
|
||||
std::vector<int> volume_idxs;
|
||||
int vol_id = m_mouse.drag.gizmo_volume_idx;
|
||||
int group_id = m_volumes.volumes[vol_id]->select_group_id;
|
||||
if (group_id == -1)
|
||||
volume_idxs.push_back(vol_id);
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < (int)m_volumes.volumes.size(); ++i)
|
||||
{
|
||||
if (m_volumes.volumes[i]->select_group_id == group_id)
|
||||
volume_idxs.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
_on_move(volume_idxs);
|
||||
|
||||
break;
|
||||
}
|
||||
case Gizmos::Scale:
|
||||
{
|
||||
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
||||
Slic3r::GUI::update_settings_value();
|
||||
break;
|
||||
}
|
||||
case Gizmos::Rotate:
|
||||
|
|
@ -3307,6 +3391,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
break;
|
||||
}
|
||||
m_gizmos.stop_dragging();
|
||||
Slic3r::GUI::update_settings_value();
|
||||
}
|
||||
|
||||
m_mouse.drag.move_volume_idx = -1;
|
||||
|
|
@ -3509,6 +3594,17 @@ bool GLCanvas3D::_init_toolbar()
|
|||
if (!m_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "selectbyparts";
|
||||
item.tooltip = GUI::L_str("Select by parts");
|
||||
item.sprite_id = 10;
|
||||
item.is_toggable = true;
|
||||
item.action_callback = &m_action_selectbyparts_callback;
|
||||
if (!m_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
enable_toolbar_item("add", true);
|
||||
|
||||
return true;
|
||||
|
|
@ -3736,6 +3832,7 @@ void GLCanvas3D::_deregister_callbacks()
|
|||
m_on_enable_action_buttons_callback.deregister_callback();
|
||||
m_on_gizmo_scale_uniformly_callback.deregister_callback();
|
||||
m_on_gizmo_rotate_callback.deregister_callback();
|
||||
m_on_gizmo_flatten_callback.deregister_callback();
|
||||
m_on_update_geometry_info_callback.deregister_callback();
|
||||
|
||||
m_action_add_callback.deregister_callback();
|
||||
|
|
@ -3748,6 +3845,7 @@ void GLCanvas3D::_deregister_callbacks()
|
|||
m_action_cut_callback.deregister_callback();
|
||||
m_action_settings_callback.deregister_callback();
|
||||
m_action_layersediting_callback.deregister_callback();
|
||||
m_action_selectbyparts_callback.deregister_callback();
|
||||
}
|
||||
|
||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||
|
|
@ -5219,7 +5317,7 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||
|
||||
std::set<std::string> done; // prevent moving instances twice
|
||||
bool object_moved = false;
|
||||
Vec3d wipe_tower_origin(0.0, 0.0, 0.0);
|
||||
Vec3d wipe_tower_origin = Vec3d::Zero();
|
||||
for (int volume_idx : volume_idxs)
|
||||
{
|
||||
GLVolume* volume = m_volumes.volumes[volume_idx];
|
||||
|
|
@ -5238,34 +5336,56 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||
{
|
||||
// Move a regular object.
|
||||
ModelObject* model_object = m_model->objects[obj_idx];
|
||||
const Vec3d& origin = volume->get_origin();
|
||||
model_object->instances[instance_idx]->offset = Vec2d(origin(0), origin(1));
|
||||
model_object->invalidate_bounding_box();
|
||||
object_moved = true;
|
||||
if (model_object != nullptr)
|
||||
{
|
||||
const Vec3d& offset = volume->get_offset();
|
||||
model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1));
|
||||
model_object->invalidate_bounding_box();
|
||||
update_position_values();
|
||||
object_moved = true;
|
||||
}
|
||||
}
|
||||
else if (obj_idx == 1000)
|
||||
// Move a wipe tower proxy.
|
||||
wipe_tower_origin = volume->get_origin();
|
||||
wipe_tower_origin = volume->get_offset();
|
||||
}
|
||||
|
||||
if (object_moved)
|
||||
m_on_instance_moved_callback.call();
|
||||
|
||||
if (wipe_tower_origin != Vec3d(0.0, 0.0, 0.0))
|
||||
if (wipe_tower_origin != Vec3d::Zero())
|
||||
m_on_wipe_tower_moved_callback.call(wipe_tower_origin(0), wipe_tower_origin(1));
|
||||
}
|
||||
|
||||
void GLCanvas3D::_on_select(int volume_idx)
|
||||
void GLCanvas3D::_on_select(int volume_idx, int object_idx)
|
||||
{
|
||||
int id = -1;
|
||||
int vol_id = -1;
|
||||
int obj_id = -1;
|
||||
|
||||
if ((volume_idx != -1) && (volume_idx < (int)m_volumes.volumes.size()))
|
||||
{
|
||||
if (m_select_by == "volume")
|
||||
id = m_volumes.volumes[volume_idx]->volume_idx();
|
||||
{
|
||||
if (m_volumes.volumes[volume_idx]->object_idx() != object_idx)
|
||||
{
|
||||
set_select_by("object");
|
||||
obj_id = m_volumes.volumes[volume_idx]->object_idx();
|
||||
vol_id = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj_id = object_idx;
|
||||
vol_id = m_volumes.volumes[volume_idx]->volume_idx();
|
||||
}
|
||||
}
|
||||
else if (m_select_by == "object")
|
||||
id = m_volumes.volumes[volume_idx]->object_idx();
|
||||
{
|
||||
obj_id = m_volumes.volumes[volume_idx]->object_idx();
|
||||
vol_id = -1;
|
||||
}
|
||||
}
|
||||
m_on_select_object_callback.call(id);
|
||||
|
||||
m_on_select_object_callback.call(obj_id, vol_id);
|
||||
}
|
||||
|
||||
std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ public:
|
|||
enum EType : unsigned char
|
||||
{
|
||||
Undefined,
|
||||
Move,
|
||||
Scale,
|
||||
Rotate,
|
||||
Flatten,
|
||||
|
|
@ -347,7 +348,6 @@ public:
|
|||
typedef std::map<EType, GLGizmoBase*> GizmosMap;
|
||||
GizmosMap m_gizmos;
|
||||
EType m_current;
|
||||
bool m_dragging;
|
||||
|
||||
public:
|
||||
Gizmos();
|
||||
|
|
@ -367,16 +367,18 @@ public:
|
|||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
||||
bool grabber_contains_mouse() const;
|
||||
void update(const Linef3& mouse_ray);
|
||||
void refresh();
|
||||
|
||||
EType get_current_type() const;
|
||||
|
||||
bool is_running() const;
|
||||
|
||||
bool is_dragging() const;
|
||||
void start_dragging();
|
||||
void start_dragging(const BoundingBoxf3& box);
|
||||
void stop_dragging();
|
||||
|
||||
Vec3d get_position() const;
|
||||
void set_position(const Vec3d& position);
|
||||
|
||||
float get_scale() const;
|
||||
void set_scale(float scale);
|
||||
|
||||
|
|
@ -502,6 +504,7 @@ private:
|
|||
PerlCallback m_on_enable_action_buttons_callback;
|
||||
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
||||
PerlCallback m_on_gizmo_rotate_callback;
|
||||
PerlCallback m_on_gizmo_flatten_callback;
|
||||
PerlCallback m_on_update_geometry_info_callback;
|
||||
|
||||
PerlCallback m_action_add_callback;
|
||||
|
|
@ -514,6 +517,7 @@ private:
|
|||
PerlCallback m_action_cut_callback;
|
||||
PerlCallback m_action_settings_callback;
|
||||
PerlCallback m_action_layersediting_callback;
|
||||
PerlCallback m_action_selectbyparts_callback;
|
||||
|
||||
public:
|
||||
GLCanvas3D(wxGLCanvas* canvas);
|
||||
|
|
@ -556,6 +560,9 @@ public:
|
|||
void set_select_by(const std::string& value);
|
||||
void set_drag_by(const std::string& value);
|
||||
|
||||
const std::string& get_select_by() const;
|
||||
const std::string& get_drag_by() const;
|
||||
|
||||
float get_camera_zoom() const;
|
||||
|
||||
BoundingBoxf3 volumes_bounding_box() const;
|
||||
|
|
@ -597,6 +604,8 @@ public:
|
|||
std::vector<int> load_object(const ModelObject& model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||
std::vector<int> load_object(const Model& model, int obj_idx);
|
||||
|
||||
int get_first_volume_id(int obj_idx) const;
|
||||
|
||||
void reload_scene(bool force);
|
||||
|
||||
void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector<std::string>& str_tool_colors);
|
||||
|
|
@ -619,6 +628,7 @@ public:
|
|||
void register_on_enable_action_buttons_callback(void* callback);
|
||||
void register_on_gizmo_scale_uniformly_callback(void* callback);
|
||||
void register_on_gizmo_rotate_callback(void* callback);
|
||||
void register_on_gizmo_flatten_callback(void* callback);
|
||||
void register_on_update_geometry_info_callback(void* callback);
|
||||
|
||||
void register_action_add_callback(void* callback);
|
||||
|
|
@ -631,6 +641,7 @@ public:
|
|||
void register_action_cut_callback(void* callback);
|
||||
void register_action_settings_callback(void* callback);
|
||||
void register_action_layersediting_callback(void* callback);
|
||||
void register_action_selectbyparts_callback(void* callback);
|
||||
|
||||
void bind_event_handlers();
|
||||
void unbind_event_handlers();
|
||||
|
|
@ -733,7 +744,7 @@ private:
|
|||
void _show_warning_texture_if_needed();
|
||||
|
||||
void _on_move(const std::vector<int>& volume_idxs);
|
||||
void _on_select(int volume_idx);
|
||||
void _on_select(int volume_idx, int object_idx);
|
||||
|
||||
// generates the legend texture in dependence of the current shown view type
|
||||
void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||
|
|
|
|||
|
|
@ -338,6 +338,12 @@ void GLCanvas3DManager::set_drag_by(wxGLCanvas* canvas, const std::string& value
|
|||
it->second->set_drag_by(value);
|
||||
}
|
||||
|
||||
std::string GLCanvas3DManager::get_select_by(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_select_by() : "";
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
|
|
@ -536,6 +542,12 @@ std::vector<int> GLCanvas3DManager::load_object(wxGLCanvas* canvas, const Model*
|
|||
return (it != m_canvases.end()) ? it->second->load_object(*model, obj_idx) : std::vector<int>();
|
||||
}
|
||||
|
||||
int GLCanvas3DManager::get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_first_volume_id(obj_idx) : -1;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
@ -688,6 +700,13 @@ void GLCanvas3DManager::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, vo
|
|||
it->second->register_on_gizmo_rotate_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->register_on_gizmo_flatten_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
@ -765,6 +784,13 @@ void GLCanvas3DManager::register_action_layersediting_callback(wxGLCanvas* canva
|
|||
it->second->register_action_layersediting_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->register_action_selectbyparts_callback(callback);
|
||||
}
|
||||
|
||||
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas)
|
||||
{
|
||||
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ public:
|
|||
void set_select_by(wxGLCanvas* canvas, const std::string& value);
|
||||
void set_drag_by(wxGLCanvas* canvas, const std::string& value);
|
||||
|
||||
std::string get_select_by(wxGLCanvas* canvas) const;
|
||||
|
||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||
bool is_layers_editing_allowed(wxGLCanvas* canvas) const;
|
||||
bool is_shader_enabled(wxGLCanvas* canvas) const;
|
||||
|
|
@ -135,6 +137,8 @@ public:
|
|||
std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||
std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
||||
|
||||
int get_first_volume_id(wxGLCanvas* canvas, int obj_idx) const;
|
||||
|
||||
void reload_scene(wxGLCanvas* canvas, bool force);
|
||||
|
||||
void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector<std::string>& str_tool_colors);
|
||||
|
|
@ -159,6 +163,7 @@ public:
|
|||
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
|
@ -171,6 +176,7 @@ public:
|
|||
void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_selectbyparts_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
private:
|
||||
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
||||
|
|
|
|||
|
|
@ -15,14 +15,95 @@ static const float DEFAULT_BASE_COLOR[3] = { 0.625f, 0.625f, 0.625f };
|
|||
static const float DEFAULT_DRAG_COLOR[3] = { 1.0f, 1.0f, 1.0f };
|
||||
static const float DEFAULT_HIGHLIGHT_COLOR[3] = { 1.0f, 0.38f, 0.0f };
|
||||
|
||||
static const float RED[3] = { 1.0f, 0.0f, 0.0f };
|
||||
static const float GREEN[3] = { 0.0f, 1.0f, 0.0f };
|
||||
static const float BLUE[3] = { 0.0f, 0.0f, 1.0f };
|
||||
static const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } };
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
const float GLGizmoBase::Grabber::HalfSize = 2.0f;
|
||||
// returns the intersection of the given ray with the plane parallel to plane XY and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_xy(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
return Vec3d(mouse_pos_2d(0), mouse_pos_2d(1), 0.0);
|
||||
}
|
||||
|
||||
// returns the intersection of the given ray with the plane parallel to plane XZ and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_xz(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5 * (double)PI, Vec3d::UnitX()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
return Vec3d(mouse_pos_2d(0), 0.0, mouse_pos_2d(1));
|
||||
}
|
||||
|
||||
// returns the intersection of the given ray with the plane parallel to plane YZ and passing through the given center
|
||||
// coordinates are local to the plane
|
||||
Vec3d intersection_on_plane_yz(const Linef3& ray, const Vec3d& center)
|
||||
{
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5f * (double)PI, Vec3d::UnitY()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(ray, m).intersect_plane(0.0));
|
||||
|
||||
return Vec3d(0.0, mouse_pos_2d(1), -mouse_pos_2d(0));
|
||||
}
|
||||
|
||||
// return an index:
|
||||
// 0 for plane XY
|
||||
// 1 for plane XZ
|
||||
// 2 for plane YZ
|
||||
// which indicates which plane is best suited for intersecting the given unit vector
|
||||
// giving precedence to the plane with the given index
|
||||
unsigned int select_best_plane(const Vec3d& unit_vector, unsigned int preferred_plane)
|
||||
{
|
||||
unsigned int ret = preferred_plane;
|
||||
|
||||
// 1st checks if the given vector is not parallel to the given preferred plane
|
||||
double dot_to_normal = 0.0;
|
||||
switch (ret)
|
||||
{
|
||||
case 0: // plane xy
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(Vec3d::UnitZ()));
|
||||
break;
|
||||
}
|
||||
case 1: // plane xz
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(-Vec3d::UnitY()));
|
||||
break;
|
||||
}
|
||||
case 2: // plane yz
|
||||
{
|
||||
dot_to_normal = std::abs(unit_vector.dot(Vec3d::UnitX()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if almost parallel, select the plane whose normal direction is closest to the given vector direction,
|
||||
// otherwise return the given preferred plane index
|
||||
if (dot_to_normal < 0.1)
|
||||
{
|
||||
typedef std::map<double, unsigned int> ProjsMap;
|
||||
ProjsMap projs_map;
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(Vec3d::UnitZ())), 0)); // plane xy
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(-Vec3d::UnitY())), 1)); // plane xz
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(unit_vector.dot(Vec3d::UnitX())), 2)); // plane yz
|
||||
ret = projs_map.rbegin()->second;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const float GLGizmoBase::Grabber::HalfSize = 2.0f;
|
||||
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
|
||||
|
||||
GLGizmoBase::Grabber::Grabber()
|
||||
|
|
@ -131,6 +212,7 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent)
|
|||
, m_group_id(-1)
|
||||
, m_state(Off)
|
||||
, m_hover_id(-1)
|
||||
, m_dragging(false)
|
||||
{
|
||||
::memcpy((void*)m_base_color, (const void*)DEFAULT_BASE_COLOR, 3 * sizeof(float));
|
||||
::memcpy((void*)m_drag_color, (const void*)DEFAULT_DRAG_COLOR, 3 * sizeof(float));
|
||||
|
|
@ -152,18 +234,21 @@ void GLGizmoBase::set_highlight_color(const float* color)
|
|||
::memcpy((void*)m_highlight_color, (const void*)color, 3 * sizeof(float));
|
||||
}
|
||||
|
||||
void GLGizmoBase::start_dragging()
|
||||
void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
m_dragging = true;
|
||||
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
{
|
||||
m_grabbers[i].dragging = (m_hover_id == i);
|
||||
}
|
||||
|
||||
on_start_dragging();
|
||||
on_start_dragging(box);
|
||||
}
|
||||
|
||||
void GLGizmoBase::stop_dragging()
|
||||
{
|
||||
m_dragging = false;
|
||||
set_tooltip("");
|
||||
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
|
|
@ -199,8 +284,11 @@ void GLGizmoBase::render_grabbers() const
|
|||
|
||||
void GLGizmoBase::render_grabbers_for_picking() const
|
||||
{
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||
{
|
||||
m_grabbers[i].color[0] = 1.0f;
|
||||
m_grabbers[i].color[1] = 1.0f;
|
||||
m_grabbers[i].color[2] = picking_color_component(i);
|
||||
m_grabbers[i].render_for_picking();
|
||||
}
|
||||
}
|
||||
|
|
@ -234,7 +322,6 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
|
|||
, m_angle(0.0)
|
||||
, m_center(0.0, 0.0, 0.0)
|
||||
, m_radius(0.0f)
|
||||
, m_keep_initial_values(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -252,6 +339,12 @@ bool GLGizmoRotate::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
m_center = box.center();
|
||||
m_radius = Offset + box.radius();
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_update(const Linef3& mouse_ray)
|
||||
{
|
||||
Vec2d mouse_pos = to_2d(mouse_position_in_local_plane(mouse_ray));
|
||||
|
|
@ -293,18 +386,16 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if (m_grabbers[0].dragging)
|
||||
if (m_dragging)
|
||||
set_tooltip(format(m_angle * 180.0f / (float)PI, 4));
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if (!m_keep_initial_values)
|
||||
else
|
||||
{
|
||||
m_center = box.center();
|
||||
m_radius = Offset + box.radius();
|
||||
m_keep_initial_values = true;
|
||||
}
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
::glPushMatrix();
|
||||
transform_to_local();
|
||||
|
||||
|
|
@ -335,12 +426,8 @@ void GLGizmoRotate::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
::glPushMatrix();
|
||||
|
||||
transform_to_local();
|
||||
|
||||
m_grabbers[0].color[0] = 1.0f;
|
||||
m_grabbers[0].color[1] = 1.0f;
|
||||
m_grabbers[0].color[2] = picking_color_component(0);
|
||||
|
||||
render_grabbers_for_picking();
|
||||
|
||||
::glPopMatrix();
|
||||
|
|
@ -512,23 +599,29 @@ Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray) cons
|
|||
|
||||
GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
, m_x(parent, GLGizmoRotate::X)
|
||||
, m_y(parent, GLGizmoRotate::Y)
|
||||
, m_z(parent, GLGizmoRotate::Z)
|
||||
{
|
||||
m_x.set_group_id(0);
|
||||
m_y.set_group_id(1);
|
||||
m_z.set_group_id(2);
|
||||
m_gizmos.emplace_back(parent, GLGizmoRotate::X);
|
||||
m_gizmos.emplace_back(parent, GLGizmoRotate::Y);
|
||||
m_gizmos.emplace_back(parent, GLGizmoRotate::Z);
|
||||
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
m_gizmos[i].set_group_id(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool GLGizmoRotate3D::on_init()
|
||||
{
|
||||
if (!m_x.init() || !m_y.init() || !m_z.init())
|
||||
return false;
|
||||
for (GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
if (!g.init())
|
||||
return false;
|
||||
}
|
||||
|
||||
m_x.set_highlight_color(RED);
|
||||
m_y.set_highlight_color(GREEN);
|
||||
m_z.set_highlight_color(BLUE);
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
m_gizmos[i].set_highlight_color(AXES_COLOR[i]);
|
||||
}
|
||||
|
||||
std::string path = resources_dir() + "/icons/overlay/";
|
||||
|
||||
|
|
@ -547,68 +640,28 @@ bool GLGizmoRotate3D::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_start_dragging()
|
||||
void GLGizmoRotate3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
switch (m_hover_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_x.start_dragging();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_y.start_dragging();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_z.start_dragging();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((0 <= m_hover_id) && (m_hover_id < 3))
|
||||
m_gizmos[m_hover_id].start_dragging(box);
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_stop_dragging()
|
||||
{
|
||||
switch (m_hover_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_x.stop_dragging();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_y.stop_dragging();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_z.stop_dragging();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((0 <= m_hover_id) && (m_hover_id < 3))
|
||||
m_gizmos[m_hover_id].stop_dragging();
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if ((m_hover_id == -1) || (m_hover_id == 0))
|
||||
m_x.render(box);
|
||||
m_gizmos[X].render(box);
|
||||
|
||||
if ((m_hover_id == -1) || (m_hover_id == 1))
|
||||
m_y.render(box);
|
||||
m_gizmos[Y].render(box);
|
||||
|
||||
if ((m_hover_id == -1) || (m_hover_id == 2))
|
||||
m_z.render(box);
|
||||
m_gizmos[Z].render(box);
|
||||
}
|
||||
|
||||
const float GLGizmoScale3D::Offset = 5.0f;
|
||||
|
|
@ -617,7 +670,7 @@ GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent)
|
|||
: GLGizmoBase(parent)
|
||||
, m_scale(Vec3d::Ones())
|
||||
, m_starting_scale(Vec3d::Ones())
|
||||
, m_starting_center(Vec3d::Zero())
|
||||
, m_show_starting_box(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -655,12 +708,13 @@ bool GLGizmoScale3D::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_start_dragging()
|
||||
void GLGizmoScale3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||
m_starting_center = m_box.center();
|
||||
m_show_starting_box = true;
|
||||
m_starting_box = box;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -702,20 +756,20 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
// x axis
|
||||
m_grabbers[0].center = Vec3d(m_box.min(0), center(1), center(2));
|
||||
m_grabbers[1].center = Vec3d(m_box.max(0), center(1), center(2));
|
||||
::memcpy((void*)m_grabbers[0].color, (const void*)RED, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[1].color, (const void*)RED, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[0].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[1].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
|
||||
|
||||
// y axis
|
||||
m_grabbers[2].center = Vec3d(center(0), m_box.min(1), center(2));
|
||||
m_grabbers[3].center = Vec3d(center(0), m_box.max(1), center(2));
|
||||
::memcpy((void*)m_grabbers[2].color, (const void*)GREEN, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[3].color, (const void*)GREEN, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[2].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[3].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
|
||||
|
||||
// z axis
|
||||
m_grabbers[4].center = Vec3d(center(0), center(1), m_box.min(2));
|
||||
m_grabbers[5].center = Vec3d(center(0), center(1), m_box.max(2));
|
||||
::memcpy((void*)m_grabbers[4].color, (const void*)BLUE, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[5].color, (const void*)BLUE, 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[4].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
::memcpy((void*)m_grabbers[5].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
|
||||
// uniform
|
||||
m_grabbers[6].center = Vec3d(m_box.min(0), m_box.min(1), m_box.min(2));
|
||||
|
|
@ -731,16 +785,32 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
|
||||
if (m_hover_id == -1)
|
||||
{
|
||||
::glColor3fv(m_base_color);
|
||||
// draw box
|
||||
render_box();
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_box);
|
||||
// draw connections
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
render_grabbers_connection(0, 1);
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
render_grabbers_connection(2, 3);
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
render_grabbers_connection(4, 5);
|
||||
// draw grabbers
|
||||
render_grabbers();
|
||||
}
|
||||
else if ((m_hover_id == 0) || (m_hover_id == 1))
|
||||
{
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
// draw starting box
|
||||
if (m_show_starting_box)
|
||||
{
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_starting_box);
|
||||
}
|
||||
// draw current box
|
||||
::glColor3fv(m_drag_color);
|
||||
render_box(m_box);
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
render_grabbers_connection(0, 1);
|
||||
// draw grabbers
|
||||
m_grabbers[0].render(true);
|
||||
|
|
@ -748,8 +818,17 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
else if ((m_hover_id == 2) || (m_hover_id == 3))
|
||||
{
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
// draw starting box
|
||||
if (m_show_starting_box)
|
||||
{
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_starting_box);
|
||||
}
|
||||
// draw current box
|
||||
::glColor3fv(m_drag_color);
|
||||
render_box(m_box);
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
render_grabbers_connection(2, 3);
|
||||
// draw grabbers
|
||||
m_grabbers[2].render(true);
|
||||
|
|
@ -757,8 +836,17 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
else if ((m_hover_id == 4) || (m_hover_id == 5))
|
||||
{
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
// draw starting box
|
||||
if (m_show_starting_box)
|
||||
{
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_starting_box);
|
||||
}
|
||||
// draw current box
|
||||
::glColor3fv(m_drag_color);
|
||||
render_box(m_box);
|
||||
// draw connection
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
render_grabbers_connection(4, 5);
|
||||
// draw grabbers
|
||||
m_grabbers[4].render(true);
|
||||
|
|
@ -766,9 +854,15 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
else if (m_hover_id >= 6)
|
||||
{
|
||||
// draw starting box
|
||||
if (m_show_starting_box)
|
||||
{
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_starting_box);
|
||||
}
|
||||
// draw current box
|
||||
::glColor3fv(m_drag_color);
|
||||
// draw box
|
||||
render_box();
|
||||
render_box(m_box);
|
||||
// draw grabbers
|
||||
for (int i = 6; i < 10; ++i)
|
||||
{
|
||||
|
|
@ -781,40 +875,33 @@ void GLGizmoScale3D::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||
{
|
||||
m_grabbers[i].color[0] = 1.0f;
|
||||
m_grabbers[i].color[1] = 1.0f;
|
||||
m_grabbers[i].color[2] = picking_color_component(i);
|
||||
}
|
||||
|
||||
render_grabbers_for_picking();
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::render_box() const
|
||||
void GLGizmoScale3D::render_box(const BoundingBoxf3& box) const
|
||||
{
|
||||
// bottom face
|
||||
::glBegin(GL_LINE_LOOP);
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.min(1), (GLfloat)m_box.min(2));
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.max(1), (GLfloat)m_box.min(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.max(1), (GLfloat)m_box.min(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.min(1), (GLfloat)m_box.min(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.min(1), (GLfloat)box.min(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.max(1), (GLfloat)box.min(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.max(1), (GLfloat)box.min(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.min(1), (GLfloat)box.min(2));
|
||||
::glEnd();
|
||||
|
||||
// top face
|
||||
::glBegin(GL_LINE_LOOP);
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.min(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.max(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.max(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.min(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.min(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.max(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.max(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.min(1), (GLfloat)box.max(2));
|
||||
::glEnd();
|
||||
|
||||
// vertical edges
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.min(1), (GLfloat)m_box.min(2)); ::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.min(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.max(1), (GLfloat)m_box.min(2)); ::glVertex3f((GLfloat)m_box.min(0), (GLfloat)m_box.max(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.max(1), (GLfloat)m_box.min(2)); ::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.max(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.min(1), (GLfloat)m_box.min(2)); ::glVertex3f((GLfloat)m_box.max(0), (GLfloat)m_box.min(1), (GLfloat)m_box.max(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.min(1), (GLfloat)box.min(2)); ::glVertex3f((GLfloat)box.min(0), (GLfloat)box.min(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.min(0), (GLfloat)box.max(1), (GLfloat)box.min(2)); ::glVertex3f((GLfloat)box.min(0), (GLfloat)box.max(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.max(1), (GLfloat)box.min(2)); ::glVertex3f((GLfloat)box.max(0), (GLfloat)box.max(1), (GLfloat)box.max(2));
|
||||
::glVertex3f((GLfloat)box.max(0), (GLfloat)box.min(1), (GLfloat)box.min(2)); ::glVertex3f((GLfloat)box.max(0), (GLfloat)box.min(1), (GLfloat)box.max(2));
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
|
|
@ -832,7 +919,7 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
|
|||
|
||||
void GLGizmoScale3D::do_scale_x(const Linef3& mouse_ray)
|
||||
{
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_center);
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_box.center());
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(0) = m_starting_scale(0) * ratio;
|
||||
|
|
@ -840,7 +927,7 @@ void GLGizmoScale3D::do_scale_x(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_y(const Linef3& mouse_ray)
|
||||
{
|
||||
double ratio = calc_ratio(2, mouse_ray, m_starting_center);
|
||||
double ratio = calc_ratio(2, mouse_ray, m_starting_box.center());
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(0) = m_starting_scale(1) * ratio; // << this is temporary
|
||||
|
|
@ -849,7 +936,7 @@ void GLGizmoScale3D::do_scale_y(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
|
||||
{
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_center);
|
||||
double ratio = calc_ratio(1, mouse_ray, m_starting_box.center());
|
||||
|
||||
if (ratio > 0.0)
|
||||
m_scale(0) = m_starting_scale(2) * ratio; // << this is temporary
|
||||
|
|
@ -858,7 +945,7 @@ void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
|
|||
|
||||
void GLGizmoScale3D::do_scale_uniform(const Linef3& mouse_ray)
|
||||
{
|
||||
Vec3d center = m_starting_center;
|
||||
Vec3d center = m_starting_box.center();
|
||||
center(2) = m_box.min(2);
|
||||
double ratio = calc_ratio(0, mouse_ray, center);
|
||||
|
||||
|
|
@ -877,77 +964,24 @@ double GLGizmoScale3D::calc_ratio(unsigned int preferred_plane_id, const Linef3&
|
|||
|
||||
Vec3d starting_vec_dir = starting_vec.normalized();
|
||||
Vec3d mouse_dir = mouse_ray.unit_vector();
|
||||
unsigned int plane_id = preferred_plane_id;
|
||||
|
||||
// 1st try to see if the mouse direction is close enough to the preferred plane normal
|
||||
double dot_to_normal = 0.0;
|
||||
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
||||
// ratio is given by the projection of the calculated intersection on the starting vector divided by the starting vector length
|
||||
switch (plane_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
dot_to_normal = std::abs(mouse_dir.dot(Vec3d::UnitZ()));
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
dot_to_normal = std::abs(mouse_dir.dot(-Vec3d::UnitY()));
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
dot_to_normal = std::abs(mouse_dir.dot(Vec3d::UnitX()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dot_to_normal < 0.1)
|
||||
{
|
||||
// if not, select the plane who's normal is closest to the mouse direction
|
||||
|
||||
typedef std::map<double, unsigned int> ProjsMap;
|
||||
ProjsMap projs_map;
|
||||
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(mouse_dir.dot(Vec3d::UnitZ())), 0)); // plane xy
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(mouse_dir.dot(-Vec3d::UnitY())), 1)); // plane xz
|
||||
projs_map.insert(ProjsMap::value_type(std::abs(mouse_dir.dot(Vec3d::UnitX())), 2)); // plane yz
|
||||
plane_id = projs_map.rbegin()->second;
|
||||
}
|
||||
|
||||
switch (plane_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// calculates the intersection of the mouse ray with the plane parallel to plane XY and passing through the given center
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(mouse_ray, m).intersect_plane(0.0));
|
||||
|
||||
// ratio is given by the projection of the calculated intersection on the starting vector divided by the starting vector length
|
||||
ratio = starting_vec_dir.dot(Vec3d(mouse_pos_2d(0), mouse_pos_2d(1), 0.0)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// calculates the intersection of the mouse ray with the plane parallel to plane XZ and passing through the given center
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5 * (double)PI, Vec3d::UnitX()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(mouse_ray, m).intersect_plane(0.0));
|
||||
|
||||
// ratio is given by the projection of the calculated intersection on the starting vector divided by the starting vector length
|
||||
ratio = starting_vec_dir.dot(Vec3d(mouse_pos_2d(0), 0.0, mouse_pos_2d(1))) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// calculates the intersection of the mouse ray with the plane parallel to plane YZ and passing through the given center
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-0.5f * (double)PI, Vec3d::UnitY()));
|
||||
m.translate(-center);
|
||||
Vec2d mouse_pos_2d = to_2d(transform(mouse_ray, m).intersect_plane(0.0));
|
||||
|
||||
// ratio is given by the projection of the calculated intersection on the starting vector divided by the starting vector length
|
||||
ratio = starting_vec_dir.dot(Vec3d(0.0, mouse_pos_2d(1), -mouse_pos_2d(0))) / len_starting_vec;
|
||||
ratio = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, center)) / len_starting_vec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -955,10 +989,162 @@ double GLGizmoScale3D::calc_ratio(unsigned int preferred_plane_id, const Linef3&
|
|||
return ratio;
|
||||
}
|
||||
|
||||
const double GLGizmoMove3D::Offset = 10.0;
|
||||
|
||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
, m_position(Vec3d::Zero())
|
||||
, m_starting_drag_position(Vec3d::Zero())
|
||||
, m_starting_box_center(Vec3d::Zero())
|
||||
{
|
||||
}
|
||||
|
||||
bool GLGizmoMove3D::on_init()
|
||||
{
|
||||
std::string path = resources_dir() + "/icons/overlay/";
|
||||
|
||||
std::string filename = path + "move_off.png";
|
||||
if (!m_textures[Off].load_from_file(filename, false))
|
||||
return false;
|
||||
|
||||
filename = path + "move_hover.png";
|
||||
if (!m_textures[Hover].load_from_file(filename, false))
|
||||
return false;
|
||||
|
||||
filename = path + "move_on.png";
|
||||
if (!m_textures[On].load_from_file(filename, false))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
m_grabbers.push_back(Grabber());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||
m_starting_box_center = box.center();
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_update(const Linef3& mouse_ray)
|
||||
{
|
||||
if (m_hover_id == 0)
|
||||
m_position(0) = 2.0 * m_starting_box_center(0) + calc_displacement(1, mouse_ray) - m_starting_drag_position(0);
|
||||
else if (m_hover_id == 1)
|
||||
m_position(1) = 2.0 * m_starting_box_center(1) + calc_displacement(2, mouse_ray) - m_starting_drag_position(1);
|
||||
else if (m_hover_id == 2)
|
||||
m_position(2) = 2.0 * m_starting_box_center(2) + calc_displacement(1, mouse_ray) - m_starting_drag_position(2);
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if (m_grabbers[0].dragging)
|
||||
set_tooltip("X: " + format(m_position(0), 2));
|
||||
else if (m_grabbers[1].dragging)
|
||||
set_tooltip("Y: " + format(m_position(1), 2));
|
||||
else if (m_grabbers[2].dragging)
|
||||
set_tooltip("Z: " + format(m_position(2), 2));
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
const Vec3d& center = box.center();
|
||||
|
||||
// x axis
|
||||
m_grabbers[0].center = Vec3d(box.max(0) + Offset, center(1), center(2));
|
||||
::memcpy((void*)m_grabbers[0].color, (const void*)&AXES_COLOR[0], 3 * sizeof(float));
|
||||
|
||||
// y axis
|
||||
m_grabbers[1].center = Vec3d(center(0), box.max(1) + Offset, center(2));
|
||||
::memcpy((void*)m_grabbers[1].color, (const void*)&AXES_COLOR[1], 3 * sizeof(float));
|
||||
|
||||
// z axis
|
||||
m_grabbers[2].center = Vec3d(center(0), center(1), box.max(2) + Offset);
|
||||
::memcpy((void*)m_grabbers[2].color, (const void*)&AXES_COLOR[2], 3 * sizeof(float));
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
|
||||
if (m_hover_id == -1)
|
||||
{
|
||||
// draw axes
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
::glColor3fv(AXES_COLOR[i]);
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f(center(0), center(1), center(2));
|
||||
::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), (GLfloat)m_grabbers[i].center(2));
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
// draw grabbers
|
||||
render_grabbers();
|
||||
}
|
||||
else
|
||||
{
|
||||
// draw axis
|
||||
::glColor3fv(AXES_COLOR[m_hover_id]);
|
||||
::glBegin(GL_LINES);
|
||||
::glVertex3f(center(0), center(1), center(2));
|
||||
::glVertex3f((GLfloat)m_grabbers[m_hover_id].center(0), (GLfloat)m_grabbers[m_hover_id].center(1), (GLfloat)m_grabbers[m_hover_id].center(2));
|
||||
::glEnd();
|
||||
|
||||
// draw grabber
|
||||
m_grabbers[m_hover_id].render(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
render_grabbers_for_picking();
|
||||
}
|
||||
|
||||
double GLGizmoMove3D::calc_displacement(unsigned int preferred_plane_id, const Linef3& mouse_ray) const
|
||||
{
|
||||
double displacement = 0.0;
|
||||
|
||||
Vec3d starting_vec = m_starting_drag_position - m_starting_box_center;
|
||||
double len_starting_vec = starting_vec.norm();
|
||||
if (len_starting_vec == 0.0)
|
||||
return displacement;
|
||||
|
||||
Vec3d starting_vec_dir = starting_vec.normalized();
|
||||
Vec3d mouse_dir = mouse_ray.unit_vector();
|
||||
|
||||
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
||||
|
||||
switch (plane_id)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
displacement = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
displacement = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
displacement = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, m_starting_box_center));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return displacement;
|
||||
}
|
||||
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent)
|
||||
: GLGizmoBase(parent)
|
||||
, m_normal(0.0, 0.0, 0.0)
|
||||
, m_normal(Vec3d::Zero())
|
||||
, m_starting_center(Vec3d::Zero())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -981,10 +1167,13 @@ bool GLGizmoFlatten::on_init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_start_dragging()
|
||||
void GLGizmoFlatten::on_start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
{
|
||||
m_normal = m_planes[m_hover_id].normal;
|
||||
m_starting_center = box.center();
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
||||
|
|
@ -992,13 +1181,10 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||
// the dragged_offset is a vector measuring where was the object moved
|
||||
// with the gizmo being on. This is reset in set_flattening_data and
|
||||
// does not work correctly when there are multiple copies.
|
||||
if (!m_center) // this is the first bounding box that we see
|
||||
m_center.reset(new Vec3d(box.center()));
|
||||
Vec3d dragged_offset(Vec3d::Zero());
|
||||
if (m_dragging)
|
||||
dragged_offset = box.center() - m_starting_center;
|
||||
|
||||
Vec3d dragged_offset = box.center() - *m_center;
|
||||
|
||||
bool blending_was_enabled = ::glIsEnabled(GL_BLEND);
|
||||
bool depth_test_was_enabled = ::glIsEnabled(GL_DEPTH_TEST);
|
||||
::glEnable(GL_BLEND);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
|
@ -1020,20 +1206,15 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||
}
|
||||
}
|
||||
|
||||
if (!blending_was_enabled)
|
||||
::glDisable(GL_BLEND);
|
||||
if (!depth_test_was_enabled)
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
::glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
||||
for (unsigned int i = 0; i < m_planes.size(); ++i)
|
||||
{
|
||||
// FIXME: the color assignement will fail if the planes count is greater than 254
|
||||
// use the other color components in that case !!
|
||||
::glColor3f(1.0f, 1.0f, picking_color_component(i));
|
||||
for (const Vec2d& offset : m_instances_positions) {
|
||||
::glPushMatrix();
|
||||
|
|
@ -1049,7 +1230,6 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
|
||||
void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
||||
{
|
||||
m_center.release(); // object is not being dragged (this would not be called otherwise) - we must forget about the bounding box position...
|
||||
m_model_object = model_object;
|
||||
|
||||
// ...and save the updated positions of the object instances:
|
||||
|
|
@ -1211,9 +1391,9 @@ void GLGizmoFlatten::update_planes()
|
|||
polygon = transform(polygon, m);
|
||||
}
|
||||
|
||||
// We'll sort the planes by area and only keep the 255 largest ones (because of the picking pass limitations):
|
||||
// We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
|
||||
std::sort(m_planes.rbegin(), m_planes.rend(), [](const PlaneData& a, const PlaneData& b) { return a.area < b.area; });
|
||||
m_planes.resize(std::min((int)m_planes.size(), 255));
|
||||
m_planes.resize(std::min((int)m_planes.size(), 254));
|
||||
|
||||
// Planes are finished - let's save what we calculated it from:
|
||||
m_source_data.bounding_boxes.clear();
|
||||
|
|
@ -1251,11 +1431,9 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
|||
}
|
||||
|
||||
Vec3d GLGizmoFlatten::get_flattening_normal() const {
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.rotate(Eigen::AngleAxisd(-m_model_object->instances.front()->rotation, Vec3d::UnitZ()));
|
||||
Vec3d normal = m * m_normal;
|
||||
Vec3d normal = m_model_object->instances.front()->world_matrix(true).matrix().block(0, 0, 3, 3).inverse() * m_normal;
|
||||
m_normal = Vec3d::Zero();
|
||||
return normal;
|
||||
return normal.normalized();
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ protected:
|
|||
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
||||
GLTexture m_textures[Num_States];
|
||||
int m_hover_id;
|
||||
bool m_dragging;
|
||||
float m_base_color[3];
|
||||
float m_drag_color[3];
|
||||
float m_highlight_color[3];
|
||||
|
|
@ -82,10 +83,11 @@ public:
|
|||
|
||||
void set_highlight_color(const float* color);
|
||||
|
||||
void start_dragging();
|
||||
void start_dragging(const BoundingBoxf3& box);
|
||||
void stop_dragging();
|
||||
bool is_dragging() const { return m_dragging; }
|
||||
|
||||
void update(const Linef3& mouse_ray);
|
||||
void refresh() { on_refresh(); }
|
||||
|
||||
void render(const BoundingBoxf3& box) const { on_render(box); }
|
||||
void render_for_picking(const BoundingBoxf3& box) const { on_render_for_picking(box); }
|
||||
|
|
@ -94,10 +96,9 @@ protected:
|
|||
virtual bool on_init() = 0;
|
||||
virtual void on_set_state() {}
|
||||
virtual void on_set_hover_id() {}
|
||||
virtual void on_start_dragging() {}
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box) {}
|
||||
virtual void on_stop_dragging() {}
|
||||
virtual void on_update(const Linef3& mouse_ray) = 0;
|
||||
virtual void on_refresh() {}
|
||||
virtual void on_render(const BoundingBoxf3& box) const = 0;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
|
||||
|
||||
|
|
@ -136,7 +137,6 @@ private:
|
|||
|
||||
mutable Vec3d m_center;
|
||||
mutable float m_radius;
|
||||
mutable bool m_keep_initial_values;
|
||||
|
||||
public:
|
||||
GLGizmoRotate(GLCanvas3D& parent, Axis axis);
|
||||
|
|
@ -146,9 +146,8 @@ public:
|
|||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_set_state() { m_keep_initial_values = (m_state == On) ? false : true; }
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_update(const Linef3& mouse_ray);
|
||||
virtual void on_refresh() { m_keep_initial_values = false; }
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
||||
|
|
@ -167,56 +166,52 @@ private:
|
|||
|
||||
class GLGizmoRotate3D : public GLGizmoBase
|
||||
{
|
||||
GLGizmoRotate m_x;
|
||||
GLGizmoRotate m_y;
|
||||
GLGizmoRotate m_z;
|
||||
std::vector<GLGizmoRotate> m_gizmos;
|
||||
|
||||
public:
|
||||
explicit GLGizmoRotate3D(GLCanvas3D& parent);
|
||||
|
||||
double get_angle_x() const { return m_x.get_angle(); }
|
||||
void set_angle_x(double angle) { m_x.set_angle(angle); }
|
||||
double get_angle_x() const { return m_gizmos[X].get_angle(); }
|
||||
void set_angle_x(double angle) { m_gizmos[X].set_angle(angle); }
|
||||
|
||||
double get_angle_y() const { return m_y.get_angle(); }
|
||||
void set_angle_y(double angle) { m_y.set_angle(angle); }
|
||||
double get_angle_y() const { return m_gizmos[Y].get_angle(); }
|
||||
void set_angle_y(double angle) { m_gizmos[Y].set_angle(angle); }
|
||||
|
||||
double get_angle_z() const { return m_z.get_angle(); }
|
||||
void set_angle_z(double angle) { m_z.set_angle(angle); }
|
||||
double get_angle_z() const { return m_gizmos[Z].get_angle(); }
|
||||
void set_angle_z(double angle) { m_gizmos[Z].set_angle(angle); }
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_set_state()
|
||||
{
|
||||
m_x.set_state(m_state);
|
||||
m_y.set_state(m_state);
|
||||
m_z.set_state(m_state);
|
||||
for (GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
g.set_state(m_state);
|
||||
}
|
||||
}
|
||||
virtual void on_set_hover_id()
|
||||
{
|
||||
m_x.set_hover_id(m_hover_id == 0 ? 0 : -1);
|
||||
m_y.set_hover_id(m_hover_id == 1 ? 0 : -1);
|
||||
m_z.set_hover_id(m_hover_id == 2 ? 0 : -1);
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
|
||||
}
|
||||
}
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const Linef3& mouse_ray)
|
||||
{
|
||||
m_x.update(mouse_ray);
|
||||
m_y.update(mouse_ray);
|
||||
m_z.update(mouse_ray);
|
||||
}
|
||||
virtual void on_refresh()
|
||||
{
|
||||
m_x.refresh();
|
||||
m_y.refresh();
|
||||
m_z.refresh();
|
||||
for (GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
g.update(mouse_ray);
|
||||
}
|
||||
}
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
m_x.render_for_picking(box);
|
||||
m_y.render_for_picking(box);
|
||||
m_z.render_for_picking(box);
|
||||
for (const GLGizmoRotate& g : m_gizmos)
|
||||
{
|
||||
g.render_for_picking(box);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -230,7 +225,8 @@ class GLGizmoScale3D : public GLGizmoBase
|
|||
|
||||
Vec3d m_starting_scale;
|
||||
Vec3d m_starting_drag_position;
|
||||
Vec3d m_starting_center;
|
||||
bool m_show_starting_box;
|
||||
BoundingBoxf3 m_starting_box;
|
||||
|
||||
public:
|
||||
explicit GLGizmoScale3D(GLCanvas3D& parent);
|
||||
|
|
@ -248,13 +244,14 @@ public:
|
|||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_stop_dragging() { m_show_starting_box = false; }
|
||||
virtual void on_update(const Linef3& mouse_ray);
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
||||
private:
|
||||
void render_box() const;
|
||||
void render_box(const BoundingBoxf3& box) const;
|
||||
void render_grabbers_connection(unsigned int id_1, unsigned int id_2) const;
|
||||
|
||||
void do_scale_x(const Linef3& mouse_ray);
|
||||
|
|
@ -265,6 +262,31 @@ private:
|
|||
double calc_ratio(unsigned int preferred_plane_id, const Linef3& mouse_ray, const Vec3d& center) const;
|
||||
};
|
||||
|
||||
class GLGizmoMove3D : public GLGizmoBase
|
||||
{
|
||||
static const double Offset;
|
||||
|
||||
Vec3d m_position;
|
||||
Vec3d m_starting_drag_position;
|
||||
Vec3d m_starting_box_center;
|
||||
|
||||
public:
|
||||
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
||||
|
||||
const Vec3d& get_position() const { return m_position; }
|
||||
void set_position(const Vec3d& position) { m_position = position; }
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_update(const Linef3& mouse_ray);
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
||||
private:
|
||||
double calc_displacement(unsigned int preferred_plane_id, const Linef3& mouse_ray) const;
|
||||
};
|
||||
|
||||
class GLGizmoFlatten : public GLGizmoBase
|
||||
{
|
||||
// This gizmo does not use grabbers. The m_hover_id relates to polygon managed by the class itself.
|
||||
|
|
@ -289,7 +311,7 @@ private:
|
|||
|
||||
std::vector<PlaneData> m_planes;
|
||||
std::vector<Vec2d> m_instances_positions;
|
||||
mutable std::unique_ptr<Vec3d> m_center = nullptr;
|
||||
Vec3d m_starting_center;
|
||||
const ModelObject* m_model_object = nullptr;
|
||||
|
||||
void update_planes();
|
||||
|
|
@ -303,11 +325,12 @@ public:
|
|||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_update(const Linef3& mouse_ray) {}
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
virtual void on_set_state() {
|
||||
virtual void on_set_state()
|
||||
{
|
||||
if (m_state == On && is_plane_update_necessary())
|
||||
update_planes();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,8 @@ void set_main_frame(wxFrame *main_frame)
|
|||
g_wxMainFrame = main_frame;
|
||||
}
|
||||
|
||||
wxFrame* get_main_frame() { return g_wxMainFrame; }
|
||||
|
||||
void set_tab_panel(wxNotebook *tab_panel)
|
||||
{
|
||||
g_wxTabPanel = tab_panel;
|
||||
|
|
@ -859,10 +861,6 @@ wxWindow* get_right_panel(){
|
|||
return g_right_panel;
|
||||
}
|
||||
|
||||
wxFrame* get_main_frame() {
|
||||
return g_wxMainFrame;
|
||||
}
|
||||
|
||||
wxNotebook * get_tab_panel() {
|
||||
return g_wxTabPanel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1533,13 +1533,20 @@ void update_settings_value()
|
|||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
if (m_selected_object_id < 0 || m_objects->size() <= m_selected_object_id) {
|
||||
og->set_value("scale_x", 0);
|
||||
og->set_value("position_x", 0);
|
||||
og->set_value("position_y", 0);
|
||||
og->set_value("position_z", 0);
|
||||
og->set_value("scale_x", 0);
|
||||
og->set_value("scale_y", 0);
|
||||
og->set_value("scale_z", 0);
|
||||
og->set_value("rotation_x", 0);
|
||||
og->set_value("rotation_y", 0);
|
||||
og->set_value("rotation_z", 0);
|
||||
og->disable();
|
||||
return;
|
||||
}
|
||||
g_is_percent_scale = boost::any_cast<wxString>(og->get_value("scale_unit")) == _("%");
|
||||
update_position_values();
|
||||
update_scale_values();
|
||||
update_rotation_values();
|
||||
og->enable();
|
||||
|
|
@ -1715,50 +1722,94 @@ void update_extruder_in_config(const wxString& selection)
|
|||
}
|
||||
|
||||
void update_scale_values()
|
||||
{
|
||||
update_scale_values((*m_objects)[m_selected_object_id]->instance_bounding_box(0).size(),
|
||||
(*m_objects)[m_selected_object_id]->instances[0]->scaling_factor);
|
||||
}
|
||||
|
||||
void update_scale_values(const Vec3d& size, float scaling_factor)
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
|
||||
auto size = (*m_objects)[m_selected_object_id]->instance_bounding_box(0).size();
|
||||
|
||||
if (g_is_percent_scale) {
|
||||
auto scale = scaling_factor * 100;
|
||||
auto scale = instance->scaling_factor * 100.0;
|
||||
og->set_value("scale_x", int(scale));
|
||||
og->set_value("scale_y", int(scale));
|
||||
og->set_value("scale_z", int(scale));
|
||||
}
|
||||
else {
|
||||
og->set_value("scale_x", int(size(0) + 0.5));
|
||||
og->set_value("scale_y", int(size(1) + 0.5));
|
||||
og->set_value("scale_z", int(size(2) + 0.5));
|
||||
og->set_value("scale_x", int(instance->scaling_factor * size(0) + 0.5));
|
||||
og->set_value("scale_y", int(instance->scaling_factor * size(1) + 0.5));
|
||||
og->set_value("scale_z", int(instance->scaling_factor * size(2) + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
void update_position_values()
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
|
||||
|
||||
og->set_value("position_x", int(instance->offset(0)));
|
||||
og->set_value("position_y", int(instance->offset(1)));
|
||||
og->set_value("position_z", 0);
|
||||
}
|
||||
|
||||
void update_position_values(const Vec3d& position)
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
|
||||
og->set_value("position_x", int(position(0)));
|
||||
og->set_value("position_y", int(position(1)));
|
||||
og->set_value("position_z", int(position(2)));
|
||||
}
|
||||
|
||||
void update_scale_values(double scaling_factor)
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
|
||||
// this is temporary
|
||||
// to be able to update the values as size
|
||||
// we need to store somewhere the original size
|
||||
// or have it passed as parameter
|
||||
if (!g_is_percent_scale)
|
||||
og->set_value("scale_unit", _("%"));
|
||||
|
||||
auto scale = scaling_factor * 100.0;
|
||||
og->set_value("scale_x", int(scale));
|
||||
og->set_value("scale_y", int(scale));
|
||||
og->set_value("scale_z", int(scale));
|
||||
}
|
||||
|
||||
void update_rotation_values()
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
|
||||
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
|
||||
og->set_value("rotation_x", 0);
|
||||
og->set_value("rotation_y", 0);
|
||||
|
||||
auto rotation_z = (*m_objects)[m_selected_object_id]->instances[0]->rotation;
|
||||
auto deg = int(Geometry::rad2deg(rotation_z));
|
||||
// if (deg > 180) deg -= 360;
|
||||
|
||||
og->set_value("rotation_z", deg);
|
||||
og->set_value("rotation_z", int(Geometry::rad2deg(instance->rotation)));
|
||||
}
|
||||
|
||||
void update_rotation_value(const double angle, const std::string& axis)
|
||||
void update_rotation_value(double angle, Axis axis)
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
|
||||
int deg = int(Geometry::rad2deg(angle));
|
||||
// if (deg>180) deg -= 360;
|
||||
|
||||
og->set_value("rotation_"+axis, deg);
|
||||
std::string axis_str;
|
||||
switch (axis)
|
||||
{
|
||||
case X:
|
||||
{
|
||||
axis_str = "rotation_x";
|
||||
break;
|
||||
}
|
||||
case Y:
|
||||
{
|
||||
axis_str = "rotation_y";
|
||||
break;
|
||||
}
|
||||
case Z:
|
||||
{
|
||||
axis_str = "rotation_z";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
og->set_value(axis_str, int(Geometry::rad2deg(angle)));
|
||||
}
|
||||
|
||||
void set_uniform_scaling(const bool uniform_scale)
|
||||
|
|
|
|||
|
|
@ -112,13 +112,16 @@ void update_settings_value();
|
|||
void set_extruder_column_hidden(bool hide);
|
||||
// update extruder in current config
|
||||
void update_extruder_in_config(const wxString& selection);
|
||||
// update position values displacements or "gizmos"
|
||||
void update_position_values();
|
||||
void update_position_values(const Vec3d& position);
|
||||
// update scale values after scale unit changing or "gizmos"
|
||||
void update_scale_values();
|
||||
void update_scale_values(const Vec3d& size, float scale);
|
||||
void update_scale_values(double scaling_factor);
|
||||
// update rotation values object selection changing
|
||||
void update_rotation_values();
|
||||
// update rotation value after "gizmos"
|
||||
void update_rotation_value(const double angle, const std::string& axis);
|
||||
void update_rotation_value(double angle, Axis axis);
|
||||
void set_uniform_scaling(const bool uniform_scale);
|
||||
|
||||
void on_begin_drag(wxDataViewEvent &event);
|
||||
|
|
|
|||
|
|
@ -1,286 +0,0 @@
|
|||
#include "PngExportDialog.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
PngExportDialog::PngExportDialog( wxWindow* parent, wxWindowID id,
|
||||
const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style ) :
|
||||
wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
auto top_layout = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// Labels
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
auto labels_layout = new wxGridSizer(6, 1, 0, 0);
|
||||
|
||||
// Input File picker label
|
||||
auto filepick_text = new wxStaticText( this, wxID_ANY,
|
||||
_("Target zip file"),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
filepick_text->Wrap( -1 );
|
||||
labels_layout->Add( filepick_text, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
// Config file label
|
||||
auto confpick_text = new wxStaticText( this, wxID_ANY,
|
||||
_("Config file (optional)"),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
confpick_text->Wrap( -1 );
|
||||
labels_layout->Add( confpick_text, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
confpick_text->Disable();
|
||||
|
||||
// Resolution layout
|
||||
auto resotext = new wxStaticText( this, wxID_ANY,
|
||||
_("Resolution (w, h) [px]"),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
resotext->Wrap( -1 );
|
||||
labels_layout->Add( resotext, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
// Bed size label
|
||||
auto bed_size_text = new wxStaticText( this, wxID_ANY,
|
||||
_("Bed size (w, h) [mm]"),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
bed_size_text->Wrap( -1 );
|
||||
labels_layout->Add( bed_size_text, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
// Correction label
|
||||
auto corr_text = new wxStaticText( this, wxID_ANY, _("Scale (x, y, z)"),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
corr_text->Wrap( -1 );
|
||||
labels_layout->Add( corr_text, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
// Exp time label
|
||||
auto exp_text = new wxStaticText( this, wxID_ANY,
|
||||
_("Exposure time [s]"),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
exp_text->Wrap( -1 );
|
||||
labels_layout->Add( exp_text, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
top_layout->Add( labels_layout, 0, wxEXPAND, 5 );
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// Body
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
auto body_layout = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
// Input file picker
|
||||
auto fpicklayout = new wxBoxSizer(wxHORIZONTAL);
|
||||
filepick_ctl_ = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString,
|
||||
_("Select a file"), wxT("*.zip"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxFLP_USE_TEXTCTRL | wxFLP_SAVE,
|
||||
wxDefaultValidator,
|
||||
wxT("filepick_ctl") );
|
||||
fpicklayout->Add( filepick_ctl_, 1, wxALL | wxALIGN_CENTER, 5);
|
||||
body_layout->Add( fpicklayout, 1, wxEXPAND, 5 );
|
||||
|
||||
auto ctlpicklayout = new wxBoxSizer(wxHORIZONTAL);
|
||||
confpick_ctl_ = new wxFilePickerCtrl(
|
||||
this, wxID_ANY, wxEmptyString, _("Select a file"),
|
||||
wxT("*.json"), wxDefaultPosition, wxDefaultSize,
|
||||
wxFLP_USE_TEXTCTRL | wxFLP_DEFAULT_STYLE, wxDefaultValidator,
|
||||
wxT("filepick_ctl") );
|
||||
confpick_ctl_->Disable();
|
||||
ctlpicklayout->Add( confpick_ctl_, 1, wxALL | wxALIGN_CENTER, 5);
|
||||
body_layout->Add( ctlpicklayout, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
// Resolution controls /////////////////////////////////////////////////////
|
||||
|
||||
auto res_spins_layout = new wxBoxSizer( wxHORIZONTAL );
|
||||
spin_reso_width_ = new wxSpinCtrl( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 10000, 1440 );
|
||||
res_spins_layout->Add( spin_reso_width_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
spin_reso_height_ = new wxSpinCtrl( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 10000, 2560 );
|
||||
res_spins_layout->Add( spin_reso_height_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
reso_lock_btn_ = new wxToggleButton( this, wxID_ANY, _("Lock"),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
reso_lock_btn_->SetValue(true);
|
||||
res_spins_layout->Add( reso_lock_btn_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
body_layout->Add( res_spins_layout, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
// Bed size controls ///////////////////////////////////////////////////////
|
||||
|
||||
auto bed_spins_layout = new wxBoxSizer( wxHORIZONTAL );
|
||||
bed_width_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 1e6, 68.0 );
|
||||
|
||||
bed_spins_layout->Add( bed_width_spin_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
bed_height_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 1e6, 120.0 );
|
||||
bed_spins_layout->Add( bed_height_spin_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
bedsize_lock_btn_ = new wxToggleButton( this, wxID_ANY, _("Lock"),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, 0 );
|
||||
bedsize_lock_btn_->SetValue(true);
|
||||
bed_spins_layout->Add( bedsize_lock_btn_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
body_layout->Add( bed_spins_layout, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
// Scale correction controls ///////////////////////////////////////////////
|
||||
|
||||
auto corr_layout = new wxBoxSizer( wxHORIZONTAL );
|
||||
corr_spin_x_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 100, 1, 0.01 );
|
||||
corr_spin_x_->SetDigits(3);
|
||||
corr_spin_x_->SetMaxSize(wxSize(100, -1));
|
||||
corr_layout->Add( corr_spin_x_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
corr_spin_y_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 100, 1, 0.01 );
|
||||
corr_spin_y_->SetDigits(3);
|
||||
corr_spin_y_->SetMaxSize(wxSize(100, -1));
|
||||
corr_layout->Add( corr_spin_y_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
corr_spin_z_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 100, 1, 0.01 );
|
||||
corr_spin_z_->SetDigits(3);
|
||||
corr_spin_z_->SetMaxSize(wxSize(100, -1));
|
||||
corr_layout->Add( corr_spin_z_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
corr_layout->Add( bedsize_lock_btn_->GetSize().GetWidth(), 0, 1, wxEXPAND, 5 );
|
||||
|
||||
body_layout->Add( corr_layout, 1, wxEXPAND, 5 );
|
||||
|
||||
// Exposure time controls /////////////////////////////////////////////////
|
||||
|
||||
auto exp_layout = new wxBoxSizer( wxHORIZONTAL );
|
||||
exptime_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS, 0, 100, 1, 0.01 );
|
||||
exptime_spin_->SetDigits(3);
|
||||
exptime_spin_->SetMaxSize(wxSize(100, -1));
|
||||
|
||||
auto first_txt = new wxStaticText( this, wxID_ANY,
|
||||
_("First exp. time"),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxALIGN_RIGHT );
|
||||
|
||||
exptime_first_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxSP_ARROW_KEYS,
|
||||
0, 100, 1, 0.01 );
|
||||
exptime_first_spin_->SetDigits(3);
|
||||
exptime_first_spin_->SetMaxSize(wxSize(100, -1));
|
||||
|
||||
exp_layout->Add( exptime_spin_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
exp_layout->Add( first_txt, 1, wxALIGN_CENTER|wxALL, 5);
|
||||
exp_layout->Add( exptime_first_spin_, 1, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
export_btn_ = new wxButton( this, wxID_ANY, _("Export"), wxDefaultPosition,
|
||||
wxDefaultSize, 0, wxDefaultValidator,
|
||||
wxT("export_btn") );
|
||||
|
||||
exp_layout->Add( export_btn_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||
|
||||
body_layout->Add( exp_layout, 1, wxEXPAND, 5 );
|
||||
|
||||
top_layout->Add( body_layout, 0, wxEXPAND, 5 );
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// Finalize
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this->SetSizer(top_layout);
|
||||
this->Layout();
|
||||
|
||||
this->Fit();
|
||||
this->SetMinSize(this->GetSize());
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
filepick_ctl_->Connect(
|
||||
wxEVT_COMMAND_FILEPICKER_CHANGED,
|
||||
wxFileDirPickerEventHandler( PngExportDialog::onFileChanged ),
|
||||
NULL, this );
|
||||
spin_reso_width_->Connect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalResoSpin ),
|
||||
NULL, this );
|
||||
spin_reso_height_->Connect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalResoSpin ),
|
||||
NULL, this );
|
||||
reso_lock_btn_->Connect(
|
||||
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::ResoLock ),
|
||||
NULL, this );
|
||||
bed_width_spin_->Connect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalBedSpin ),
|
||||
NULL, this );
|
||||
bed_height_spin_->Connect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalBedSpin ),
|
||||
NULL, this );
|
||||
bedsize_lock_btn_->Connect(
|
||||
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::BedsizeLock ),
|
||||
NULL, this );
|
||||
export_btn_->Connect(
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::Close ), NULL, this );
|
||||
}
|
||||
|
||||
PngExportDialog::~PngExportDialog()
|
||||
{
|
||||
// Disconnect Events
|
||||
filepick_ctl_->Disconnect(
|
||||
wxEVT_COMMAND_FILEPICKER_CHANGED,
|
||||
wxFileDirPickerEventHandler( PngExportDialog::onFileChanged ),
|
||||
NULL, this );
|
||||
spin_reso_width_->Disconnect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalResoSpin ),
|
||||
NULL, this );
|
||||
spin_reso_height_->Disconnect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalResoSpin ),
|
||||
NULL, this );
|
||||
reso_lock_btn_->Disconnect(
|
||||
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::ResoLock ),
|
||||
NULL, this );
|
||||
bed_width_spin_->Disconnect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalBedSpin ),
|
||||
NULL, this );
|
||||
bed_height_spin_->Disconnect(
|
||||
wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( PngExportDialog::EvalBedSpin ),
|
||||
NULL, this );
|
||||
bedsize_lock_btn_->Disconnect(
|
||||
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::BedsizeLock ),
|
||||
NULL, this );
|
||||
export_btn_->Disconnect(
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( PngExportDialog::Close ), NULL, this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#ifndef PNG_EXPORT_DIALOG_HPP
|
||||
#define PNG_EXPORT_DIALOG_HPP
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/tglbtn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
#include "GUI.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PngExportDialog
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PngExportDialog : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxFilePickerCtrl* filepick_ctl_;
|
||||
wxFilePickerCtrl* confpick_ctl_;
|
||||
wxSpinCtrl* spin_reso_width_;
|
||||
wxSpinCtrl* spin_reso_height_;
|
||||
wxToggleButton* reso_lock_btn_;
|
||||
wxSpinCtrlDouble* bed_width_spin_;
|
||||
wxSpinCtrlDouble* bed_height_spin_;
|
||||
wxToggleButton* bedsize_lock_btn_;
|
||||
wxSpinCtrlDouble* exptime_spin_;
|
||||
wxSpinCtrlDouble* exptime_first_spin_;
|
||||
wxSpinCtrlDouble* corr_spin_x_;
|
||||
wxSpinCtrlDouble* corr_spin_y_;
|
||||
wxSpinCtrlDouble* corr_spin_z_;
|
||||
wxButton* export_btn_;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onFileChanged( wxFileDirPickerEvent& event ) { event.Skip(); }
|
||||
virtual void EvalResoSpin( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void ResoLock( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void EvalBedSpin( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void BedsizeLock( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void Close( wxCommandEvent& /*event*/ ) { EndModal(wxID_OK); }
|
||||
|
||||
public:
|
||||
|
||||
PngExportDialog( wxWindow* parent, wxWindowID id = wxID_ANY,
|
||||
const wxString& title = L("Slice to zipped PNG files"),
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxSize( 452,170 ),
|
||||
long style = wxDEFAULT_DIALOG_STYLE );
|
||||
~PngExportDialog();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif //PNG_EXPORT_DIALOG_HPP
|
||||
151
xs/src/slic3r/GUI/ProgressStatusBar.cpp
Normal file
151
xs/src/slic3r/GUI/ProgressStatusBar.cpp
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
#include "ProgressStatusBar.hpp"
|
||||
|
||||
#include <wx/timer.h>
|
||||
#include <wx/gauge.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/frame.h>
|
||||
#include "GUI.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id):
|
||||
self(new wxStatusBar(parent ? parent : GUI::get_main_frame(),
|
||||
id == -1? wxID_ANY : id)),
|
||||
timer_(new wxTimer(self)),
|
||||
prog_ (new wxGauge(self,
|
||||
wxGA_HORIZONTAL,
|
||||
100,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize)),
|
||||
cancelbutton_(new wxButton(self,
|
||||
-1,
|
||||
"Cancel",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize))
|
||||
{
|
||||
prog_->Hide();
|
||||
cancelbutton_->Hide();
|
||||
|
||||
self->SetFieldsCount(3);
|
||||
int w[] = {-1, 150, 155};
|
||||
self->SetStatusWidths(3, w);
|
||||
|
||||
self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) {
|
||||
if (prog_->IsShown()) timer_->Stop();
|
||||
if(is_busy()) prog_->Pulse();
|
||||
});
|
||||
|
||||
self->Bind(wxEVT_SIZE, [this](wxSizeEvent& event){
|
||||
wxRect rect;
|
||||
self->GetFieldRect(1, rect);
|
||||
auto offset = 0;
|
||||
cancelbutton_->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
cancelbutton_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
|
||||
self->GetFieldRect(2, rect);
|
||||
prog_->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
prog_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
cancelbutton_->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
|
||||
if(cancel_cb_) cancel_cb_();
|
||||
cancelbutton_->Hide();
|
||||
});
|
||||
}
|
||||
|
||||
ProgressStatusBar::~ProgressStatusBar() {
|
||||
if(timer_->IsRunning()) timer_->Stop();
|
||||
}
|
||||
|
||||
int ProgressStatusBar::get_progress() const
|
||||
{
|
||||
return prog_->GetValue();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_progress(int val)
|
||||
{
|
||||
if(!prog_->IsShown()) show_progress(true);
|
||||
|
||||
if(val == prog_->GetRange()) {
|
||||
prog_->SetValue(0);
|
||||
show_progress(false);
|
||||
} else {
|
||||
prog_->SetValue(val);
|
||||
}
|
||||
}
|
||||
|
||||
int ProgressStatusBar::get_range() const
|
||||
{
|
||||
return prog_->GetRange();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_range(int val)
|
||||
{
|
||||
if(val != prog_->GetRange()) {
|
||||
prog_->SetRange(val);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressStatusBar::show_progress(bool show)
|
||||
{
|
||||
prog_->Show(show);
|
||||
prog_->Pulse();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::start_busy(int rate)
|
||||
{
|
||||
busy_ = true;
|
||||
show_progress(true);
|
||||
if (!timer_->IsRunning()) {
|
||||
timer_->Start(rate);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressStatusBar::stop_busy()
|
||||
{
|
||||
timer_->Stop();
|
||||
show_progress(false);
|
||||
prog_->SetValue(0);
|
||||
busy_ = false;
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_cancel_callback(ProgressStatusBar::CancelFn ccb) {
|
||||
cancel_cb_ = ccb;
|
||||
if(ccb) cancelbutton_->Show();
|
||||
else cancelbutton_->Hide();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::run(int rate)
|
||||
{
|
||||
if(!timer_->IsRunning()) {
|
||||
timer_->Start(rate);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressStatusBar::embed(wxFrame *frame)
|
||||
{
|
||||
wxFrame* mf = frame? frame : GUI::get_main_frame();
|
||||
mf->SetStatusBar(self);
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_status_text(const std::string& txt)
|
||||
{
|
||||
self->SetStatusText(txt);
|
||||
}
|
||||
|
||||
void ProgressStatusBar::show_cancel_button()
|
||||
{
|
||||
cancelbutton_->Show();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::hide_cancel_button()
|
||||
{
|
||||
cancelbutton_->Hide();
|
||||
}
|
||||
|
||||
}
|
||||
64
xs/src/slic3r/GUI/ProgressStatusBar.hpp
Normal file
64
xs/src/slic3r/GUI/ProgressStatusBar.hpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef PROGRESSSTATUSBAR_HPP
|
||||
#define PROGRESSSTATUSBAR_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
class wxTimer;
|
||||
class wxGauge;
|
||||
class wxButton;
|
||||
class wxTimerEvent;
|
||||
class wxStatusBar;
|
||||
class wxWindow;
|
||||
class wxFrame;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/**
|
||||
* @brief The ProgressStatusBar class is the widgets occupying the lower area
|
||||
* of the Slicer main window. It consists of a message area to the left and a
|
||||
* progress indication area to the right with an optional cancel button.
|
||||
*/
|
||||
class ProgressStatusBar {
|
||||
wxStatusBar *self; // we cheat! It should be the base class but: perl!
|
||||
wxTimer *timer_;
|
||||
wxGauge *prog_;
|
||||
wxButton *cancelbutton_;
|
||||
public:
|
||||
|
||||
/// Cancel callback function type
|
||||
using CancelFn = std::function<void()>;
|
||||
|
||||
ProgressStatusBar(wxWindow *parent = nullptr, int id = -1);
|
||||
~ProgressStatusBar();
|
||||
|
||||
int get_progress() const;
|
||||
void set_progress(int);
|
||||
int get_range() const;
|
||||
void set_range(int = 100);
|
||||
void show_progress(bool);
|
||||
void start_busy(int = 100);
|
||||
void stop_busy();
|
||||
inline bool is_busy() const { return busy_; }
|
||||
void set_cancel_callback(CancelFn = CancelFn());
|
||||
inline void remove_cancel_callback() { set_cancel_callback(); }
|
||||
void run(int rate);
|
||||
void embed(wxFrame *frame = nullptr);
|
||||
void set_status_text(const std::string& txt);
|
||||
|
||||
// Temporary methods to satisfy Perl side
|
||||
void show_cancel_button();
|
||||
void hide_cancel_button();
|
||||
|
||||
private:
|
||||
bool busy_ = false;
|
||||
CancelFn cancel_cb_;
|
||||
};
|
||||
|
||||
namespace GUI {
|
||||
using Slic3r::ProgressStatusBar;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // PROGRESSSTATUSBAR_HPP
|
||||
|
|
@ -10,9 +10,9 @@ namespace Slic3r {
|
|||
/**
|
||||
* @brief Generic progress indication interface.
|
||||
*/
|
||||
class IProgressIndicator {
|
||||
class ProgressIndicator {
|
||||
public:
|
||||
using CancelFn = std::function<void(void)>; // Cancel functio signature.
|
||||
using CancelFn = std::function<void(void)>; // Cancel function signature.
|
||||
|
||||
private:
|
||||
float state_ = .0f, max_ = 1.f, step_;
|
||||
|
|
@ -20,7 +20,7 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
inline virtual ~IProgressIndicator() {}
|
||||
inline virtual ~ProgressIndicator() {}
|
||||
|
||||
/// Get the maximum of the progress range.
|
||||
float max() const { return max_; }
|
||||
|
|
@ -28,14 +28,14 @@ public:
|
|||
/// Get the current progress state
|
||||
float state() const { return state_; }
|
||||
|
||||
/// Set the maximum of hte progress range
|
||||
/// Set the maximum of the progress range
|
||||
virtual void max(float maxval) { max_ = maxval; }
|
||||
|
||||
/// Set the current state of the progress.
|
||||
virtual void state(float val) { state_ = val; }
|
||||
|
||||
/**
|
||||
* @brief Number of states int the progress. Can be used insted of giving a
|
||||
* @brief Number of states int the progress. Can be used instead of giving a
|
||||
* maximum value.
|
||||
*/
|
||||
virtual void states(unsigned statenum) {
|
||||
|
|
@ -45,14 +45,14 @@ public:
|
|||
/// Message shown on the next status update.
|
||||
virtual void message(const string&) = 0;
|
||||
|
||||
/// Title of the operaton.
|
||||
/// Title of the operation.
|
||||
virtual void title(const string&) = 0;
|
||||
|
||||
/// Formatted message for the next status update. Works just like sprinf.
|
||||
/// Formatted message for the next status update. Works just like sprintf.
|
||||
virtual void message_fmt(const string& fmt, ...);
|
||||
|
||||
/// Set up a cancel callback for the operation if feasible.
|
||||
inline void on_cancel(CancelFn func) { cancelfunc_ = func; }
|
||||
virtual void on_cancel(CancelFn func = CancelFn()) { cancelfunc_ = func; }
|
||||
|
||||
/**
|
||||
* Explicitly shut down the progress indicator and call the associated
|
||||
|
|
@ -60,7 +60,7 @@ public:
|
|||
*/
|
||||
virtual void cancel() { cancelfunc_(); }
|
||||
|
||||
/// Convinience function to call message and status update in one function.
|
||||
/// Convenience function to call message and status update in one function.
|
||||
void update(float st, const string& msg) {
|
||||
message(msg); state(st);
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ std::string Duet::get_upload_url(const std::string &filename) const
|
|||
{
|
||||
return (boost::format("%1%rr_upload?name=0:/gcodes/%2%&%3%")
|
||||
% get_base_url()
|
||||
% filename
|
||||
% Http::url_encode(filename)
|
||||
% timestamp_str()).str();
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ std::string Duet::timestamp_str() const
|
|||
auto tm = *std::localtime(&t);
|
||||
|
||||
char buffer[BUFFER_SIZE];
|
||||
std::strftime(buffer, BUFFER_SIZE, "time=%Y-%d-%mT%H:%M:%S", &tm);
|
||||
std::strftime(buffer, BUFFER_SIZE, "time=%Y-%m-%dT%H:%M:%S", &tm);
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
|
@ -248,9 +248,10 @@ wxString Duet::format_error(const std::string &body, const std::string &error, u
|
|||
bool Duet::start_print(wxString &msg, const std::string &filename) const
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
auto url = (boost::format("%1%rr_gcode?gcode=M32%%20\"%2%\"")
|
||||
% get_base_url()
|
||||
% filename).str();
|
||||
% Http::url_encode(filename)).str();
|
||||
|
||||
auto http = Http::get(std::move(url));
|
||||
http.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
|
|
@ -275,5 +276,4 @@ int Duet::get_err_code_from_body(const std::string &body) const
|
|||
return root.get<int>("err", 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -421,6 +421,21 @@ bool Http::ca_file_supported()
|
|||
return res;
|
||||
}
|
||||
|
||||
std::string Http::url_encode(const std::string &str)
|
||||
{
|
||||
::CURL *curl = ::curl_easy_init();
|
||||
if (curl == nullptr) {
|
||||
return str;
|
||||
}
|
||||
char *ce = ::curl_easy_escape(curl, str.c_str(), str.length());
|
||||
std::string encoded = std::string(ce);
|
||||
|
||||
::curl_free(ce);
|
||||
::curl_easy_cleanup(curl);
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const Http::Progress &progress)
|
||||
{
|
||||
os << "Http::Progress("
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ public:
|
|||
|
||||
// Tells whether current backend supports seting up a CA file using ca_file()
|
||||
static bool ca_file_supported();
|
||||
|
||||
// converts the given string to an url_encoded_string
|
||||
static std::string url_encode(const std::string &str);
|
||||
private:
|
||||
Http(const std::string &url);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue