Add alignment option to arrange settings dialog
Also make it work
This commit is contained in:
parent
3054156f9e
commit
0a5a401d32
5 changed files with 41 additions and 1 deletions
|
@ -85,7 +85,13 @@ template<class PConf>
|
||||||
void fill_config(PConf& pcfg, const ArrangeParams ¶ms) {
|
void fill_config(PConf& pcfg, const ArrangeParams ¶ms) {
|
||||||
|
|
||||||
// Align the arranged pile into the center of the bin
|
// Align the arranged pile into the center of the bin
|
||||||
pcfg.alignment = PConf::Alignment::CENTER;
|
switch (params.alignment) {
|
||||||
|
case Pivots::Center: pcfg.alignment = PConf::Alignment::CENTER; break;
|
||||||
|
case Pivots::BottomLeft: pcfg.alignment = PConf::Alignment::BOTTOM_LEFT; break;
|
||||||
|
case Pivots::BottomRight: pcfg.alignment = PConf::Alignment::BOTTOM_RIGHT; break;
|
||||||
|
case Pivots::TopLeft: pcfg.alignment = PConf::Alignment::TOP_LEFT; break;
|
||||||
|
case Pivots::TopRight: pcfg.alignment = PConf::Alignment::TOP_RIGHT; break;
|
||||||
|
}
|
||||||
|
|
||||||
// Start placing the items from the center of the print bed
|
// Start placing the items from the center of the print bed
|
||||||
pcfg.starting_point = PConf::Alignment::CENTER;
|
pcfg.starting_point = PConf::Alignment::CENTER;
|
||||||
|
|
|
@ -75,6 +75,10 @@ struct ArrangePolygon {
|
||||||
|
|
||||||
using ArrangePolygons = std::vector<ArrangePolygon>;
|
using ArrangePolygons = std::vector<ArrangePolygon>;
|
||||||
|
|
||||||
|
enum class Pivots {
|
||||||
|
Center, TopLeft, BottomLeft, BottomRight, TopRight
|
||||||
|
};
|
||||||
|
|
||||||
struct ArrangeParams {
|
struct ArrangeParams {
|
||||||
|
|
||||||
/// The minimum distance which is allowed for any
|
/// The minimum distance which is allowed for any
|
||||||
|
@ -93,6 +97,12 @@ struct ArrangeParams {
|
||||||
|
|
||||||
bool allow_rotations = false;
|
bool allow_rotations = false;
|
||||||
|
|
||||||
|
/// Final alignment of the merged pile after arrangement
|
||||||
|
Pivots alignment = Pivots::Center;
|
||||||
|
|
||||||
|
/// Starting position hint for the arrangement
|
||||||
|
Pivots starting_point = Pivots::Center;
|
||||||
|
|
||||||
/// Progress indicator callback called when an object gets packed.
|
/// Progress indicator callback called when an object gets packed.
|
||||||
/// The unsigned argument is the number of items remaining to pack.
|
/// The unsigned argument is the number of items remaining to pack.
|
||||||
std::function<void(unsigned)> progressind;
|
std::function<void(unsigned)> progressind;
|
||||||
|
|
|
@ -4145,6 +4145,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||||
std::string dist_key = "min_object_distance";
|
std::string dist_key = "min_object_distance";
|
||||||
std::string dist_bed_key = "min_bed_distance";
|
std::string dist_bed_key = "min_bed_distance";
|
||||||
std::string rot_key = "enable_rotation";
|
std::string rot_key = "enable_rotation";
|
||||||
|
std::string align_key = "alignment";
|
||||||
std::string postfix;
|
std::string postfix;
|
||||||
|
|
||||||
if (ptech == ptSLA) {
|
if (ptech == ptSLA) {
|
||||||
|
@ -4163,6 +4164,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||||
dist_key += postfix;
|
dist_key += postfix;
|
||||||
dist_bed_key += postfix;
|
dist_bed_key += postfix;
|
||||||
rot_key += postfix;
|
rot_key += postfix;
|
||||||
|
align_key += postfix;
|
||||||
|
|
||||||
imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix()));
|
imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix()));
|
||||||
|
|
||||||
|
@ -4186,6 +4188,12 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||||
settings_changed = true;
|
settings_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imgui->combo(_("Alignment"), {"Center", "Top left", "Bottom left", "Bottom right", "Top right", "Random"}, settings.alignment)) {
|
||||||
|
settings_out.alignment = settings.alignment;
|
||||||
|
appcfg->set("arrange", align_key.c_str(), std::to_string(settings_out.alignment));
|
||||||
|
settings_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (imgui->button(_L("Reset"))) {
|
if (imgui->button(_L("Reset"))) {
|
||||||
|
|
|
@ -463,6 +463,7 @@ public:
|
||||||
// float distance_sla = 6.;
|
// float distance_sla = 6.;
|
||||||
float accuracy = 0.65f; // Unused currently
|
float accuracy = 0.65f; // Unused currently
|
||||||
bool enable_rotation = false;
|
bool enable_rotation = false;
|
||||||
|
int alignment = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -298,6 +298,21 @@ arrangement::ArrangeParams get_arrange_params(Plater *p)
|
||||||
params.min_obj_distance = scaled(settings.distance);
|
params.min_obj_distance = scaled(settings.distance);
|
||||||
params.min_bed_distance = scaled(settings.distance_from_bed);
|
params.min_bed_distance = scaled(settings.distance_from_bed);
|
||||||
|
|
||||||
|
arrangement::Pivots pivot = arrangement::Pivots::Center;
|
||||||
|
|
||||||
|
int pivot_max = static_cast<int>(arrangement::Pivots::TopRight);
|
||||||
|
if (settings.alignment > pivot_max) {
|
||||||
|
// means it should be random
|
||||||
|
std::random_device rd{};
|
||||||
|
std::mt19937 rng(rd());
|
||||||
|
std::uniform_int_distribution<std::mt19937::result_type> dist(0, pivot_max);
|
||||||
|
pivot = static_cast<arrangement::Pivots>(dist(rng));
|
||||||
|
} else {
|
||||||
|
pivot = static_cast<arrangement::Pivots>(settings.alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.alignment = pivot;
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue