2D Plater: Change cursor to hand cursor when over selectable items. Includes function to check if any instance in a PlaterObject includes a point (makes logic much more readable).

This commit is contained in:
Joseph Lenox 2018-05-12 16:05:02 -05:00
parent c08d0de7d0
commit f1ec1f068f
3 changed files with 18 additions and 7 deletions

View File

@ -154,14 +154,16 @@ void Plate2D::mouse_drag(wxMouseEvent& e) {
); );
model_object->update_bounding_box(); model_object->update_bounding_box();
this->Refresh(); this->Refresh();
} else { } else { // moving
auto cursor = wxSTANDARD_CURSOR;
/* if (std::any_of(this->objects.cbegin(), this->objects.cend(),
if (find_first_of(this->objects.begin(), this->objects.end(); [=](const PlaterObject& o) { return o.contour->contains_point(point);} ) == this->object.end()) { [=](const Slic3r::GUI::PlaterObject o) { return o.instance_contains(point); })
cursor = wxCursor(wxCURSOR_HAND); )
{
this->SetCursor(wxCURSOR_HAND);
} else {
this->SetCursor(*wxSTANDARD_CURSOR);
} }
*/
this->SetCursor(*cursor);
} }
} }

View File

@ -55,4 +55,11 @@ Slic3r::ExPolygonCollection& PlaterObject::transform_thumbnail(std::shared_ptr<S
return this->transformed_thumbnail; return this->transformed_thumbnail;
} }
bool PlaterObject::instance_contains(Slic3r::Point point) const {
return std::any_of(this->instance_thumbnails.cbegin(), this->instance_thumbnails.cend(),
[point](const ExPolygonCollection ep) {
return ep.contains(point);
});
}
} } // Namespace Slic3r::GUI } } // Namespace Slic3r::GUI

View File

@ -33,6 +33,8 @@ public:
Slic3r::ExPolygonCollection& transform_thumbnail(const Slic3r::Model model, int obj_idx); Slic3r::ExPolygonCollection& transform_thumbnail(const Slic3r::Model model, int obj_idx);
Slic3r::ExPolygonCollection& transform_thumbnail(const std::shared_ptr<Slic3r::Model> model, int obj_idx); Slic3r::ExPolygonCollection& transform_thumbnail(const std::shared_ptr<Slic3r::Model> model, int obj_idx);
bool instance_contains(Slic3r::Point point) const;
protected: protected:
const std::string LogChannel {"PlaterObject"}; const std::string LogChannel {"PlaterObject"};