mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-04 02:38:05 -05:00
Arrange read the zones of the selected plate only and applied them to every bed it packed. Arranging all plates with a plate in Primary selected spread a parallel plate's parts across its whole bed, and with a parallel plate selected, a Primary plate's parts were squeezed into the zone. Arranging a single plate other than the first also ignored its collision strips: they were tagged with the plate's index, while the plate packs into the arranger's bed 0. The IDEX/IQEX constraints now live in ImexArranger (IMEXArrange), and ArrangeJob only snapshots each plate's zones on the main thread and calls it: - When every bed, plates the arrange may add included, has the same primary zone, the bed shape is that zone, so parts stay centered in it. - Otherwise each plate in a parallel mode fences off the rest of its bed with fixed items on its own bed, and its parts are then arranged again inside the zone, so they sit centered rather than piled against the zone edge nearest the bed's center. Plates in Primary keep the whole bed, and plates the arrange adds take the process preset's mode. - Zone edges inside the bed get the bed's own edge margin, and strips also keep room for the brim. - A part too big for its zone, which libnest2d's first-fit retry places across the fixed items, is left unarranged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
3.5 KiB
C++
113 lines
3.5 KiB
C++
#ifndef ARRANGEJOB_HPP
|
|
#define ARRANGEJOB_HPP
|
|
|
|
|
|
#include <map>
|
|
#include "libslic3r/Polygon.hpp"
|
|
#include <exception>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
#include "Job.hpp"
|
|
#include "libslic3r/Arrange.hpp"
|
|
#include "libslic3r/BoundingBox.hpp"
|
|
#include "libslic3r/IMEXArrange.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
class ModelInstance;
|
|
|
|
namespace GUI {
|
|
|
|
class Plater;
|
|
|
|
class ArrangeJob : public Job
|
|
{
|
|
using ArrangePolygon = arrangement::ArrangePolygon;
|
|
using ArrangePolygons = arrangement::ArrangePolygons;
|
|
|
|
//BBS: add locked logic
|
|
ArrangePolygons m_selected, m_unselected, m_unprintable, m_locked;
|
|
std::vector<ModelInstance*> m_unarranged;
|
|
std::map<int, ArrangePolygons> m_selected_groups; // groups of selected items for sequential printing
|
|
std::vector<int> m_uncompatible_plates; // plate indices with different printing sequence than global
|
|
|
|
// IMEX zone snapshot, taken on the main thread in prepare().
|
|
//
|
|
// process() runs on the worker thread (see Job::process). PartPlate::imex_primary_zone() is
|
|
// non-const and calls ensure_imex_zones(), which reads wxGetApp().preset_bundle -- main-thread
|
|
// GUI state -- on every call, and on a cache miss calls calc_imex_zones(), which destroys and
|
|
// rebuilds std::vector<GLModel> members. ~GLModel issues glDeleteBuffers/glDeleteVertexArrays,
|
|
// and no GL context is current on the worker, while the GUI thread may be painting those same
|
|
// vectors from GLCanvas3D::on_paint. (imex_collision_zones() is itself const and merely reads
|
|
// the member -- but it is only valid once imex_primary_zone() has warmed the cache, so it
|
|
// cannot be moved off the main thread on its own.) Snapshotting plain geometry here keeps
|
|
// every one of those touches on the main thread.
|
|
//
|
|
// The zones are stored already converted to plate-local coordinates, which is the space the
|
|
// arranger works in.
|
|
ImexArrangeInput m_imex;
|
|
|
|
arrangement::ArrangeParams params;
|
|
int current_plate_index = 0;
|
|
Polygon bed_poly;
|
|
Plater *m_plater;
|
|
|
|
// BBS: add flag for whether on current part plate
|
|
bool only_on_partplate{false};
|
|
|
|
// clear m_selected and m_unselected, reserve space for next usage
|
|
void clear_input();
|
|
|
|
// Prepare the selected and unselected items separately. If nothing is
|
|
// selected, behaves as if everything would be selected.
|
|
void prepare_selected();
|
|
|
|
void prepare_all();
|
|
|
|
//BBS:prepare the items from current selected partplate
|
|
void prepare_partplate();
|
|
void prepare_wipe_tower();
|
|
void prepare_belt_regions(int num_plates);
|
|
void prepare_imex_zones();
|
|
|
|
ArrangePolygon prepare_arrange_polygon(void* instance);
|
|
|
|
protected:
|
|
|
|
void check_unprintable();
|
|
|
|
public:
|
|
|
|
void prepare();
|
|
|
|
void process(Ctl &ctl) override;
|
|
|
|
ArrangeJob();
|
|
|
|
int status_range() const
|
|
{
|
|
// ensure finalize() is called after all operations in process() is finished.
|
|
return int(m_selected.size() + m_unprintable.size() + 1);
|
|
}
|
|
|
|
void finalize(bool canceled, std::exception_ptr &e) override;
|
|
};
|
|
|
|
std::optional<arrangement::ArrangePolygon> get_wipe_tower_arrangepoly(const Plater &);
|
|
|
|
// The gap between logical beds in the x axis expressed in ratio of
|
|
// the current bed width.
|
|
static const constexpr double LOGICAL_BED_GAP = 1. / 5.;
|
|
|
|
//BBS: add sudoku-style strides for x and y
|
|
// Stride between logical beds
|
|
double bed_stride_x(const Plater* plater);
|
|
double bed_stride_y(const Plater* plater);
|
|
|
|
arrangement::ArrangeParams init_arrange_params(Plater *p);
|
|
|
|
}} // namespace Slic3r::GUI
|
|
|
|
#endif // ARRANGEJOB_HPP
|