13#include <glibmm/i18n.h>
14#include <gtkmm/messagedialog.h>
32 centerY(
"", C_(
"Polar arrange tab",
"Y coordinate of the center"), UNIT_TYPE_LINEAR),
33 centerX(
"", C_(
"Polar arrange tab",
"X coordinate of the center"), centerY),
34 radiusY(
"", C_(
"Polar arrange tab",
"Y coordinate of the radius"), UNIT_TYPE_LINEAR),
35 radiusX(
"", C_(
"Polar arrange tab",
"X coordinate of the radius"), radiusY),
36 angleY(
"", C_(
"Polar arrange tab",
"Ending angle"), UNIT_TYPE_RADIAL),
37 angleX(
"", C_(
"Polar arrange tab",
"Starting angle"), angleY)
41 anchorPointLabel.set_markup(C_(
"Polar arrange tab",
"<b>Anchor point:</b>"));
61 arrangeOnLabel.set_markup(C_(
"Polar arrange tab",
"<b>Arrange on:</b>"));
84 centerLabel.set_text(C_(
"Polar arrange tab",
"Center X/Y:"));
97 radiusLabel.set_text(C_(
"Polar arrange tab",
"Radius X/Y:"));
134 angleX.set_sensitive(
false);
135 angleY.set_sensitive(
false);
177static float calcAngle(
float arcBegin,
float arcEnd,
int count,
int n)
179 float arcLength = arcEnd - arcBegin;
180 float delta = std::abs(std::abs(arcLength) - 2*M_PI);
181 if(
delta > 0.01) count--;
183 float angle = n / (float)count;
185 angle = angle * arcLength;
197 return Geom::Point(cx + cos(angle) * rx, cy + sin(angle) * ry);
215 source[0] = bbox->min()[
Geom::X];
225 source[0] = bbox->max()[
Geom::X];
234 source[1] = bbox->min()[
Geom::Y];
244 source[1] = bbox->max()[
Geom::Y];
275 const std::vector<SPItem*> tmp(selection->
items().begin(), selection->
items().end());
283 if (arrangeOnEllipse) {
284 for (
auto item : tmp) {
285 if (
auto ellipse = cast<SPGenericEllipse>(
item)) {
286 if (!referenceEllipse || !arrangeOnFirstEllipse) {
287 referenceEllipse = ellipse;
298 float arcBeg, arcEnd;
300 if (arrangeOnEllipse) {
301 if (!referenceEllipse) {
307 cx = referenceEllipse->
cx.
value;
308 cy = referenceEllipse->
cy.
value;
309 rx = referenceEllipse->
rx.
value;
310 ry = referenceEllipse->
ry.
value;
311 arcBeg = referenceEllipse->
start;
312 arcEnd = referenceEllipse->
end;
329 referenceEllipse =
nullptr;
352 if(
item != referenceEllipse)
354 float angle =
calcAngle(arcBeg, arcEnd, count, i);
361 angle = -atan2f(-yaxisdir * (newLocation.
x() - realCenter.
x()), -yaxisdir * (newLocation.
y() - realCenter.
y()));
380 centerX.set_sensitive(arrangeParametric);
381 centerY.set_sensitive(arrangeParametric);
383 angleX.set_sensitive(arrangeParametric);
384 angleY.set_sensitive(arrangeParametric);
386 radiusX.set_sensitive(arrangeParametric);
387 radiusY.set_sensitive(arrangeParametric);
3x3 matrix representing an affine transformation.
void setIdentity()
Sets this matrix to be the Identity Affine.
Affine inverse() const
Compute the inverse matrix.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
Rotation around the origin.
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
SPItemRange items()
Returns a range of selected SPItems.
The set of selected SPObjects for a given document and layer model.
SPDesktop * getDesktop() const
void updateSelection()
Respond to selection change.
Gtk::Label anchorPointLabel
Gtk::CheckButton arrangeOnParametersRadio
void arrange() override
Do the actual arrangement.
void on_anchor_radio_changed()
Inkscape::UI::Widget::ScalarUnit radiusX
Inkscape::UI::Widget::ScalarUnit centerY
Gtk::Label arrangeOnLabel
void on_arrange_radio_changed()
Gtk::CheckButton anchorBoundingBoxRadio
Gtk::CheckButton arrangeOnFirstCircleRadio
Gtk::CheckButton anchorObjectPivotRadio
Gtk::Grid parametersTable
PolarArrangeTab(ArrangeDialog *parent_)
Gtk::CheckButton rotateObjectsCheckBox
Inkscape::UI::Widget::ScalarUnit angleX
Inkscape::UI::Widget::ScalarUnit radiusY
Inkscape::UI::Widget::AnchorSelector anchorSelector
Gtk::CheckButton arrangeOnLastCircleRadio
Inkscape::UI::Widget::ScalarUnit angleY
Inkscape::UI::Widget::ScalarUnit centerX
SPDocument * getDocument() const
Inkscape::Selection * getSelection() const
void showNotice(Glib::ustring const &msg, int timeout=0)
const Geom::Affine & doc2dt() const
Document to desktop coordinate transformation.
Base class for visual SVG elements.
void set_i2d_affine(Geom::Affine const &transform)
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
Geom::OptRect documentVisualBounds() const
Get item's visual bbox in document coordinate system.
Geom::Point getCenter(bool ensure_uptodate=true) const
void move_rel(Geom::Translate const &tr)
void doWriteTransform(Geom::Affine const &transform, Geom::Affine const *adv=nullptr, bool compensate=true)
Set a new transform on an object.
void setCenter(Geom::Point const &object_centre)
Sets the transform_center_x and transform_center_y properties to retain the rotation center.
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
Editable view implementation.
static char const *const parent
TODO: insert short description here.
Macro for icon names used in Inkscape.
static void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation)
This function rotates an item around a given point by a given amount.
static Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle)
Calculates the point at which an object needs to be, given the center of the ellipse,...
static Geom::Point getAnchorPoint(int anchor, SPItem *item)
Returns the selected anchor point in desktop coordinates.
static void moveToPoint(int anchor, SPItem *item, Geom::Point p)
Moves an SPItem to a given location, the location is based on the given anchor point.
static float calcAngle(float arcBegin, float arcEnd, int count, int n)
Calculates the angle at which to put an object given the total amount of objects, the index of the ob...
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Dialog for creating grid type arrangements of selected objects.