17#include <glibmm/i18n.h>
38 auto persp =
static_cast<Persp3D*
>(
this);
93 if (
root->viewBox_set) {
94 pt[0] *=
root->width.computed /
root->viewBox.width();
95 pt[1] *=
root->height.computed /
root->viewBox.height();
123 if (
root->viewBox_set) {
124 pt[0] *=
root->viewBox.width() /
root->width.computed;
125 pt[1] *=
root->viewBox.height() /
root->height.computed;
178 if (!SP_ACTIVE_DESKTOP) {
185 bc->_vpdrag->updateDraggers();
186 bc->_vpdrag->updateLines();
187 bc->_vpdrag->updateBoxHandles();
188 bc->_vpdrag->updateBoxReprs();
193 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
226 gchar *str =
nullptr;
252 if (is<Persp3D>(&
child)) {
253 first = cast<Persp3D>(&
child);
265 if ((flags & SP_OBJECT_WRITE_BUILD & SP_OBJECT_WRITE_EXT) && !
repr) {
271 if (flags & SP_OBJECT_WRITE_EXT) {
276 os << pt[0] <<
" : " << pt[1] <<
" : " << pt[2];
283 os << pt[0] <<
" : " << pt[1] <<
" : " << pt[2];
290 os << pt[0] <<
" : " << pt[1] <<
" : " << pt[2];
297 os << pt[0] <<
" : " << pt[1] <<
" : " << pt[2];
327 g_warning (
"VP should be infinite but is (%f : %f : %f)", vp[0], vp[1], vp[2]);
328 g_return_val_if_fail(vp[2] != 0.0,
Geom::Point(0.0, 0.0));
352 DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), _(
"Toggle vanishing point"), INKSCAPE_ICON(
"draw-cuboid"));
360 persp->toggle_VP(axis,
false);
362 DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), _(
"Toggle multiple vanishing points"), INKSCAPE_ICON(
"draw-cuboid"));
382 a += alt_pressed ? 0.5 * ((angle > 0 ) - (angle < 0)) : angle;
403 if (std::find (persp_impl->boxes.begin(), persp_impl->boxes.end(), box) != persp_impl->boxes.end()) {
406 persp_impl->boxes.push_back(box);
413 std::vector<SPBox3D *>::iterator i = std::find (persp_impl->boxes.begin(), persp_impl->boxes.end(), box);
414 if (i != persp_impl->boxes.end())
415 persp_impl->boxes.erase(i);
424 for (
auto & boxe : persp_impl->boxes) {
436 if (persp_impl->boxes.empty())
438 for (
auto & boxe : persp_impl->boxes) {
439 boxe->position_set();
447 if (!persp_impl || persp_impl->boxes.empty())
449 for (
auto & boxe : persp_impl->boxes) {
450 boxe->updateRepr(SP_OBJECT_WRITE_EXT);
451 boxe->set_z_orders();
459 if (!persp_impl || persp_impl->boxes.empty())
461 for (
auto & boxe : persp_impl->boxes) {
462 boxe->set_z_orders();
473 std::list<SPBox3D *> bx_lst;
474 for (
auto & boxe : persp_impl->boxes) {
475 bx_lst.push_back(boxe);
493 std::list<SPBox3D *> boxes_of_persp2 = other->
list_of_boxes();
495 for (
auto & box : boxes_of_persp2) {
496 box->switch_perspectives(other,
this,
true);
497 box->updateRepr(SP_OBJECT_WRITE_EXT);
506 std::list<SPBox3D *> selboxes =
set->box3DList();
508 for (
auto & boxe : persp_impl->boxes) {
509 if (std::find(selboxes.begin(), selboxes.end(), boxe) == selboxes.end()) {
522 g_print (
"=== Info for Persp3D %d ===\n", persp_impl->my_counter);
530 g_print (
" Origin: %s\n", cstr);
533 g_print (
" Boxes: ");
534 for (
auto & boxe : persp_impl->boxes) {
535 g_print (
"%d (%d) ", boxe->my_counter, boxe->get_perspective()->perspective_impl->my_counter);
538 g_print (
"========================\n");
545 if (is<Persp3D>(&
child)) {
546 cast<Persp3D>(&
child)->print_debugging_info();
554 g_print (
"\n======================================\n");
555 g_print (
"Selected perspectives and their boxes:\n");
557 std::list<Persp3D *> sel_persps = SP_ACTIVE_DESKTOP->getSelection()->perspList();
559 for (
auto & sel_persp : sel_persps) {
560 auto persp = sel_persp;
561 auto persp_impl = persp->perspective_impl.get();
562 g_print (
" %s (%d): ", persp->getRepr()->attribute(
"id"), persp->perspective_impl->my_counter);
563 for (
auto & boxe : persp_impl->boxes) {
564 g_print (
"%d ", boxe->my_counter);
568 g_print (
"======================================\n\n");
572 g_print (
"%s: current_persp3d is now %s\n",
Lookup dictionary for attributes/properties.
@ INKSCAPE_PERSP3D_ORIGIN
3x3 matrix representing an affine transformation.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
static Application & instance()
Returns the current Inkscape::Application global object.
SPDesktop * active_desktop()
double value(Unit const *u) const
Return the quantity's value in the specified unit.
Interface for refcounted XML nodes.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual void addObserver(NodeObserver &observer)=0
Add an object that will be notified of the changes to this node.
virtual void removeObserver(NodeObserver &observer)=0
Remove an object from the list of observers.
void notifyAttributeChanged(Inkscape::XML::Node &, GQuark, Inkscape::Util::ptr_shared, Inkscape::Util::ptr_shared) final
Attribute change callback.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Virtual build: set persp3d attributes from its associated XML node.
std::list< SPBox3D * > list_of_boxes() const
static void toggle_VPs(std::list< Persp3D * >, Proj::Axis axis)
double get_infinite_angle(Proj::Axis axis) const
void toggle_VP(Proj::Axis axis, bool set_undo=true)
bool perspectives_coincide(Persp3D const *rhs) const
Persp3DNodeObserver & nodeObserver()
void set(SPAttr key, char const *value) override
Virtual set: set attribute to value.
void add_box(SPBox3D *box)
static Persp3D * document_first_persp(SPDocument *document)
void update_box_displays()
Geom::Point get_infinite_dir(Proj::Axis axis) const
static Persp3D * create_xml_element(SPDocument *document)
void set_VP_state(Proj::Axis axis, Proj::VPState state)
void rotate_VP(Proj::Axis axis, double angle, bool alt_pressed)
void update(SPCtx *ctx, unsigned int flags) override
bool has_box(SPBox3D *box) const
Geom::Point get_PL_dir_from_pt(Geom::Point const &pt, Proj::Axis axis) const
void apply_affine_transformation(Geom::Affine const &xform)
std::unique_ptr< Persp3DImpl > perspective_impl
static void print_debugging_info_all(SPDocument *doc)
void print_debugging_info() const
bool has_all_boxes_in_selection(Inkscape::ObjectSet *set) const
Proj::Pt2 get_VP(Proj::Axis axis) const
void release() override
Virtual release of Persp3D members before destruction.
Geom::Point get_finite_dir(Geom::Point const &pt, Proj::Axis axis) const
static bool VP_is_finite(Persp3DImpl *persp_impl, Proj::Axis axis)
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
Virtual write: write object attributes to repr.
static void print_all_selected()
void absorb(Persp3D *persp2)
void remove_box(SPBox3D *box)
bool has_finite_image(Proj::Axis axis)
Inkscape::UI::Tools::ToolBase * getTool() const
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
Inkscape::Util::Quantity getWidth() const
SPDefs * getDefs()
Return the main defs object for the document.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
bool is_yaxisdown() const
True if the desktop Y-axis points down, false if it points up.
Inkscape::Util::Quantity getHeight() const
Inkscape::XML::Node * repr
SPObject * get_child_by_repr(Inkscape::XML::Node *repr)
Return object's child whose node pointer equals repr.
virtual void set(SPAttr key, const char *value)
virtual Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags)
virtual void update(SPCtx *ctx, unsigned int flags)
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
Editable view implementation.
TODO: insert short description here.
Macro for icon names used in Inkscape.
double atan2(Point const &p)
static R & release(R &r)
Decrements the reference count of a anchored object.
char const * string_from_axis(Proj::Axis axis)
Interface for XML node observers.
static cairo_user_data_key_t key
static int global_counter
void print_current_persp3d(gchar *func_name, Persp3D *persp)
static Proj::Pt2 legacy_transform_forward(Proj::Pt2 pt, SPDocument const *doc)
Apply viewBox and legacy desktop transformation to point loaded from SVG.
static Proj::Pt2 legacy_transform_backward(Proj::Pt2 pt, SPDocument const *doc)
Apply viewBox and legacy desktop transformation to point to be written to SVG.
SPRoot: SVG <svg> implementation.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
TODO: insert short description here.