Merge branch 'master' into fs_emboss

This commit is contained in:
Filip Sykala - NTB T15p 2023-02-17 13:54:00 +01:00
commit f92be6f697
6 changed files with 59 additions and 14 deletions

View File

@ -108,6 +108,10 @@ inline cInt Round(double val)
return static_cast<cInt>((val < 0) ? (val - 0.5) : (val + 0.5));
}
// Overriding the Eigen operators because we don't want to compare Z coordinate if IntPoint is 3 dimensional.
inline bool operator==(const IntPoint &l, const IntPoint &r) { return l.x() == r.x() && l.y() == r.y(); }
inline bool operator!=(const IntPoint &l, const IntPoint &r) { return l.x() != r.x() || l.y() != r.y(); }
//------------------------------------------------------------------------------
// PolyTree methods ...
//------------------------------------------------------------------------------
@ -178,19 +182,25 @@ double Area(const Path &poly)
}
//------------------------------------------------------------------------------
double Area(const OutRec &outRec)
double Area(const OutPt *op)
{
OutPt *op = outRec.Pts;
const OutPt *startOp = op;
if (!op) return 0;
double a = 0;
do {
a += (double)(op->Prev->Pt.x() + op->Pt.x()) * (double)(op->Prev->Pt.y() - op->Pt.y());
op = op->Next;
} while (op != outRec.Pts);
} while (op != startOp);
return a * 0.5;
}
//------------------------------------------------------------------------------
double Area(const OutRec &outRec)
{
return Area(outRec.Pts);
}
//------------------------------------------------------------------------------
bool PointIsVertex(const IntPoint &Pt, OutPt *pp)
{
OutPt *pp2 = pp;
@ -524,27 +534,32 @@ bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2)
p = btmPt2->Next;
while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next;
double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt));
return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
if (std::max(dx1p, dx1n) == std::max(dx2p, dx2n) &&
std::min(dx1p, dx1n) == std::min(dx2p, dx2n))
return Area(btmPt1) > 0; //if otherwise identical use orientation
else
return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
}
//------------------------------------------------------------------------------
// Called by GetLowermostRec()
OutPt* GetBottomPt(OutPt *pp)
{
OutPt* dups = 0;
OutPt* dups = nullptr;
OutPt* p = pp->Next;
while (p != pp)
{
if (p->Pt.y() > pp->Pt.y())
{
pp = p;
dups = 0;
dups = nullptr;
}
else if (p->Pt.y() == pp->Pt.y() && p->Pt.x() <= pp->Pt.x())
{
if (p->Pt.x() < pp->Pt.x())
{
dups = 0;
dups = nullptr;
pp = p;
} else
{
@ -565,6 +580,7 @@ OutPt* GetBottomPt(OutPt *pp)
}
return pp;
}
//------------------------------------------------------------------------------
bool Pt2IsBetweenPt1AndPt3(const IntPoint &pt1,

View File

@ -424,8 +424,12 @@ void PrintObject::generate_support_spots()
float(this->print()->m_config.perimeter_acceleration.getFloat()),
this->config().raft_layers.getInt(), this->config().brim_type.value,
float(this->config().brim_width.getFloat())};
auto [supp_points, partial_objects] = SupportSpotsGenerator::full_search(this, cancel_func, params);
this->m_shared_regions->generated_support_points = {this->trafo_centered(), supp_points, partial_objects};
auto [supp_points, partial_objects] = SupportSpotsGenerator::full_search(this, cancel_func, params);
Transform3d po_transform = this->trafo_centered();
if (this->layer_count() > 0) {
po_transform = Geometry::translation_transform(Vec3d{0, 0, this->layers().front()->bottom_z()}) * po_transform;
}
this->m_shared_regions->generated_support_points = {po_transform, supp_points, partial_objects};
m_print->throw_if_canceled();
}
BOOST_LOG_TRIVIAL(debug) << "Searching support spots - end";

View File

@ -3972,8 +3972,9 @@ void GLCanvas3D::update_sequential_clearance()
Pointf3s& cache_hull_2d = m_sequential_print_clearance.m_hull_2d_cache.emplace_back(Pointf3s());
cache_hull_2d.reserve(hull_2d.points.size());
const Transform3d inv_trafo = trafo.get_matrix().inverse();
for (const Point& p : hull_2d.points) {
cache_hull_2d.emplace_back(unscale<double>(p.x()), unscale<double>(p.y()), 0.0);
cache_hull_2d.emplace_back(inv_trafo * Vec3d(unscale<double>(p.x()), unscale<double>(p.y()), 0.0));
}
}
m_sequential_print_clearance_first_displacement = false;

View File

@ -2537,8 +2537,7 @@ CommonGizmosDataID GLGizmoCut3D::on_get_requirements() const {
return CommonGizmosDataID(
int(CommonGizmosDataID::SelectionInfo)
| int(CommonGizmosDataID::InstancesHider)
| int(CommonGizmosDataID::ObjectClipper)
| int(CommonGizmosDataID::Raycaster));
| int(CommonGizmosDataID::ObjectClipper));
}
void GLGizmoCut3D::data_changed()

View File

@ -16,6 +16,7 @@
#include "Tab.hpp"
#define FTS_FUZZY_MATCH_IMPLEMENTATION
#include "ExtraRenderers.hpp"
#include "fts_fuzzy_match.h"
#include "imgui/imconfig.h"
@ -500,6 +501,10 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
search_list_model = new SearchListModel(this);
search_list->AssociateModel(search_list_model);
#ifdef __WXMSW__
search_list->AppendColumn(new wxDataViewColumn("", new BitmapTextRenderer(true, wxDATAVIEW_CELL_INERT), SearchListModel::colIconMarkedText, wxCOL_WIDTH_AUTOSIZE, wxALIGN_LEFT));
search_list->GetColumn(SearchListModel::colIconMarkedText)->SetWidth(48 * em_unit());
#else
search_list->AppendBitmapColumn("", SearchListModel::colIcon);
wxDataViewTextRenderer* const markupRenderer = new wxDataViewTextRenderer();
@ -512,6 +517,7 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em_unit());
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(40 * em_unit());
#endif
wxBoxSizer* check_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -725,10 +731,12 @@ void SearchDialog::OnLeftDown(wxMouseEvent& event)
void SearchDialog::msw_rescale()
{
const int& em = em_unit();
#ifdef __WXMSW__
search_list->GetColumn(SearchListModel::colIconMarkedText)->SetWidth(48 * em);
#else
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
#endif
const wxSize& size = wxSize(40 * em, 30 * em);
SetMinSize(size);
@ -787,8 +795,13 @@ void SearchListModel::sys_color_changed()
wxString SearchListModel::GetColumnType(unsigned int col) const
{
#ifdef __WXMSW__
if (col == colIconMarkedText)
return "DataViewBitmapText";
#else
if (col == colIcon)
return "wxBitmap";
#endif
return "string";
}
@ -797,12 +810,20 @@ void SearchListModel::GetValueByRow(wxVariant& variant,
{
switch (col)
{
#ifdef __WXMSW__
case colIconMarkedText: {
const ScalableBitmap& icon = m_icon[m_values[row].second];
variant << DataViewBitmapText(m_values[row].first, icon.bmp().GetBitmapFor(icon.parent()));
break;
}
#else
case colIcon:
variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent());
break;
case colMarkedText:
variant = m_values[row].first;
break;
#endif
case colMax:
wxFAIL_MSG("invalid column");
default:

View File

@ -202,8 +202,12 @@ class SearchListModel : public wxDataViewVirtualListModel
public:
enum {
#ifdef __WXMSW__
colIconMarkedText,
#else
colIcon,
colMarkedText,
#endif
colMax
};