diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-item.cpp | 101 | ||||
| -rw-r--r-- | src/sp-item.h | 150 |
2 files changed, 141 insertions, 110 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 967756055..ebb08e3d8 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1,6 +1,3 @@ -/** \file - * Base class for visual SVG elements - */ /* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -15,12 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/** \class SPItem - * - * SPItem is an abstract base class for all graphic (visible) SVG nodes. It - * is a subclass of SPObject, with great deal of specific functionality. - */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -232,20 +223,12 @@ bool SPItem::isEvaluated() const { return _is_evaluated; } -/** - * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box. - * Corresponds to setExplicitlyHidden. - */ bool SPItem::isExplicitlyHidden() const { return (style->display.set && style->display.value == SP_CSS_DISPLAY_NONE); } -/** - * Sets the display CSS property to `hidden' if \a val is true, - * otherwise makes it unset - */ void SPItem::setExplicitlyHidden(bool val) { style->display.set = val; style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE ); @@ -253,9 +236,6 @@ void SPItem::setExplicitlyHidden(bool val) { updateRepr(); } -/** - * Sets the transform_center_x and transform_center_y properties to retain the rotation center -*/ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); @@ -389,11 +369,6 @@ void SPItem::lowerToBottom() { } } -/* - * Move this SPItem into or after another SPItem in the doc - * \param target - the SPItem to move into or after - * \param intoafter - move to after the target (false), move inside (sublayer) of the target (true) - */ void SPItem::moveTo(SPItem *target, bool intoafter) { Inkscape::XML::Node *target_ref = ( target ? target->getRepr() : NULL ); @@ -826,11 +801,7 @@ Geom::OptRect SPItem::bbox(Geom::Affine const & /*transform*/, SPItem::BBoxType //throw; return Geom::OptRect(); } -/** - * Get item's geometric bounding box in this item's coordinate system. - * - * The geometric bounding box includes only the path, disregarding all style attributes. - */ + Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { Geom::OptRect bbox; @@ -843,11 +814,6 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const return bbox; } -/** - * Get item's visual bounding box in this item's coordinate system. - * - * The visual bounding box includes the stroke and the filter region. - */ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const { using Geom::X; @@ -924,14 +890,11 @@ Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const } } -/** Get item's geometric bbox in document coordinate system. - * Document coordinates are the default coordinates of the root element: - * the origin is at the top left, X grows to the right and Y grows downwards. */ Geom::OptRect SPItem::documentGeometricBounds() const { return geometricBounds(i2doc_affine()); } -/// Get item's visual bbox in document coordinate system. + Geom::OptRect SPItem::documentVisualBounds() const { if (!bbox_valid) { @@ -948,14 +911,12 @@ Geom::OptRect SPItem::documentBounds(BBoxType type) const return documentVisualBounds(); } } -/** Get item's geometric bbox in desktop coordinate system. - * Desktop coordinates should be user defined. Currently they are hardcoded: - * origin is at bottom left, X grows to the right and Y grows upwards. */ + Geom::OptRect SPItem::desktopGeometricBounds() const { return geometricBounds(i2dt_affine()); } -/// Get item's visual bbox in desktop coordinate system. + Geom::OptRect SPItem::desktopVisualBounds() const { /// @fixme hardcoded desktop transform @@ -1079,11 +1040,6 @@ gchar* SPItem::description() const { return g_strdup(""); } -/** - * Returns a string suitable for status bar, formatted in pango markup language. - * - * Must be freed by caller. - */ gchar *SPItem::detailedDescription() const { gchar* s = g_strdup_printf("<b>%s</b> %s", this->displayName(), this->description()); @@ -1117,20 +1073,10 @@ gchar *SPItem::detailedDescription() const { return s; } -/** - * Returns true if the item is filtered, false otherwise. Used with groups/lists to determine how many, or if any, are filtered - * - */ bool SPItem::isFiltered() const { return (style && style->filter.href && style->filter.href->getObject()); } -/** - * Allocates unique integer keys. - * \param numkeys Number of keys required. - * \return First allocated key; hence if the returned key is n - * you can use n, n + 1, ..., n + (numkeys - 1) - */ unsigned SPItem::display_key_new(unsigned numkeys) { static unsigned dkey = 0; @@ -1367,9 +1313,6 @@ static Geom::Affine sp_item_transform_repr (SPItem *item) } -/** - * Recursively scale stroke width in \a item and its children by \a expansion. - */ void SPItem::adjust_stroke_width_recursive(double expansion) { adjust_stroke (expansion); @@ -1414,9 +1357,6 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) } } -/** - * Recursively compensate pattern or gradient transform. - */ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Affine t_ancestors, bool is_pattern) { // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors @@ -1478,14 +1418,6 @@ Geom::Affine SPItem::set_transform(Geom::Affine const &transform) { return transform; } -/** - * Set a new transform on an object. - * - * Compensate for stroke scaling and gradient/pattern fill transform, if - * necessary. Call the object's set_transform method if transforms are - * stored optimized. Send _transformed_signal. Invoke _write method so that - * the repr is updated with the new transform. - */ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv, bool compensate) { g_return_if_fail(repr != NULL); @@ -1597,10 +1529,6 @@ gint SPItem::emitEvent(SPEvent &event) return this->event(&event); } -/** - * Sets item private transform (not propagated to repr), without compensating stroke widths, - * gradients, patterns as sp_item_write_transform does. - */ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) { if (!Geom::are_near(transform_matrix, transform, 1e-18)) { @@ -1618,12 +1546,7 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) //} -/** - * \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL. - * ("Ancestor (\>=)" here includes as far as \a object itself.) - */ -Geom::Affine -i2anc_affine(SPObject const *object, SPObject const *const ancestor) { +Geom::Affine i2anc_affine(SPObject const *object, SPObject const *const ancestor) { Geom::Affine ret(Geom::identity()); g_return_val_if_fail(object != NULL, ret); @@ -1650,18 +1573,11 @@ Geom::Affine SPItem::getRelativeTransform(SPObject const *dest) const { return i2i_affine(this, dest); } -/** - * Returns the accumulated transformation of the item and all its ancestors, including root's viewport. - * \pre (item != NULL) and SP_IS_ITEM(item). - */ Geom::Affine SPItem::i2doc_affine() const { return i2anc_affine(this, NULL); } -/** - * Returns the transformation from item to desktop coords - */ Geom::Affine SPItem::i2dt_affine() const { Geom::Affine ret; @@ -1692,9 +1608,6 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) } -/** - * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa) - */ Geom::Affine SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ @@ -1738,10 +1651,6 @@ sp_item_view_list_remove(SPItemView *list, SPItemView *view) return ret; } -/** - * Return the arenaitem corresponding to the given item in the display - * with the given key - */ Inkscape::DrawingItem *SPItem::get_arenaitem(unsigned key) { for ( SPItemView *iv = display ; iv ; iv = iv->next ) { diff --git a/src/sp-item.h b/src/sp-item.h index 1656a0c2b..b9d71c551 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -1,7 +1,8 @@ #ifndef SEEN_SP_ITEM_H #define SEEN_SP_ITEM_H -/** \file +/** + * @file * Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx, SPItemClass, SPEvent. */ @@ -65,7 +66,7 @@ enum PatternTransform { /** * Event structure. * - * \todo This is just placeholder. Plan: + * @todo This is just placeholder. Plan: * We do extensible event structure, that hold applicable (ui, non-ui) * data pointers. So it is up to given object/arena implementation * to process correct ones in meaningful way. @@ -78,7 +79,6 @@ public: void* data; }; -/// SPItemView class SPItemView { public: SPItemView *next; @@ -95,17 +95,21 @@ public: /** * Flag for referenced views (i.e. markers, clippaths, masks and patterns); - currently unused, does the same as DISPLAY + * currently unused, does the same as DISPLAY */ #define SP_ITEM_REFERENCE_FLAGS (1 << 1) -/// Contains transformations to document/viewport and the viewport size. +/** + * Contains transformations to document/viewport and the viewport size. + */ class SPItemCtx : public SPCtx { public: /** Item to document transformation */ Geom::Affine i2doc; + /** Viewport size */ Geom::Rect viewport; + /** Item to viewport transformation */ Geom::Affine i2vp; }; @@ -113,7 +117,11 @@ public: #define SP_ITEM(obj) (dynamic_cast<SPItem*>((SPObject*)obj)) #define SP_IS_ITEM(obj) (dynamic_cast<const SPItem*>((SPObject*)obj) != NULL) -/** Abstract base class for all visible shapes. */ +/** + * Base class for visual SVG elements. + * SPItem is an abstract base class for all graphic (visible) SVG nodes. It + * is a subclass of SPObject, with great deal of specific functionality. + */ class SPItem : public SPObject { public: enum BBoxType { @@ -156,7 +164,7 @@ public: bool isHidden() const; void setHidden(bool hidden); - /* Objects dialogue */ + // Objects dialogue bool isSensitive() const { return sensitive; }; @@ -167,7 +175,7 @@ public: void setHighlightColor(guint32 color); void unsetHighlightColor(); - /********************/ + //==================== bool isEvaluated() const; void setEvaluated(bool visible); @@ -175,11 +183,23 @@ public: bool isHidden(unsigned display_key) const; + /** + * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box. + * Corresponds to setExplicitlyHidden. + */ bool isExplicitlyHidden() const; + /** + * Sets the display CSS property to `hidden' if \a val is true, + * otherwise makes it unset. + */ void setExplicitlyHidden(bool val); + /** + * Sets the transform_center_x and transform_center_y properties to retain the rotation center + */ void setCenter(Geom::Point const &object_centre); + void unsetCenter(); bool isCenterSet() const; Geom::Point getCenter() const; @@ -195,52 +215,155 @@ public: void lowerOne(); void raiseToTop(); void lowerToBottom(); + + /** + * Move this SPItem into or after another SPItem in the doc. + * + * @param target the SPItem to move into or after. + * @param intoafter move to after the target (false), move inside (sublayer) of the target (true). + */ void moveTo(SPItem *target, bool intoafter); sigc::connection connectTransformed(sigc::slot<void, Geom::Affine const *, SPItem *> slot) { return _transformed_signal.connect(slot); } + /** + * Get item's geometric bounding box in this item's coordinate system. + * + * The geometric bounding box includes only the path, disregarding all style attributes. + */ Geom::OptRect geometricBounds(Geom::Affine const &transform = Geom::identity()) const; + + /** + * Get item's visual bounding box in this item's coordinate system. + * + * The visual bounding box includes the stroke and the filter region. + */ Geom::OptRect visualBounds(Geom::Affine const &transform = Geom::identity()) const; + Geom::OptRect bounds(BBoxType type, Geom::Affine const &transform = Geom::identity()) const; + + /** + * Get item's geometric bbox in document coordinate system. + * Document coordinates are the default coordinates of the root element: + * the origin is at the top left, X grows to the right and Y grows downwards. + */ Geom::OptRect documentGeometricBounds() const; + + /** + * Get item's visual bbox in document coordinate system. + */ Geom::OptRect documentVisualBounds() const; + Geom::OptRect documentBounds(BBoxType type) const; + + /** + * Get item's geometric bbox in desktop coordinate system. + * Desktop coordinates should be user defined. Currently they are hardcoded: + * origin is at bottom left, X grows to the right and Y grows upwards. + */ Geom::OptRect desktopGeometricBounds() const; + + /** + * Get item's visual bbox in desktop coordinate system. + */ Geom::OptRect desktopVisualBounds() const; + Geom::OptRect desktopPreferredBounds() const; Geom::OptRect desktopBounds(BBoxType type) const; unsigned int pos_in_parent() const; + /** + * Returns a string suitable for status bar, formatted in pango markup language. + * + * Must be freed by caller. + */ char *detailedDescription() const; + /** + * Returns true if the item is filtered, false otherwise. + * Used with groups/lists to determine how many, or if any, are filtered. + */ bool isFiltered() const; void invoke_print(SPPrintContext *ctx); + + /** + * Allocates unique integer keys. + * + * @param numkeys Number of keys required. + * @return First allocated key; hence if the returned key is n + * you can use n, n + 1, ..., n + (numkeys - 1) + */ static unsigned int display_key_new(unsigned int numkeys); + Inkscape::DrawingItem *invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); void invoke_hide(unsigned int key); void getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs=0) const; void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false, PatternTransform = TRANSFORM_BOTH); void adjust_gradient(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false); void adjust_stroke(double ex); + + /** + * Recursively scale stroke width in \a item and its children by \a expansion. + */ void adjust_stroke_width_recursive(double ex); + void freeze_stroke_width_recursive(bool freeze); + + /** + * Recursively compensate pattern or gradient transform. + */ void adjust_paint_recursive(Geom::Affine advertized_transform, Geom::Affine t_ancestors, bool is_pattern); + void adjust_livepatheffect(Geom::Affine const &postmul, bool set = false); + + /** + * Set a new transform on an object. + * + * Compensate for stroke scaling and gradient/pattern fill transform, if + * necessary. Call the object's set_transform method if transforms are + * stored optimized. Send _transformed_signal. Invoke _write method so that + * the repr is updated with the new transform. + */ void doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv = NULL, bool compensate = true); + + /** + * Sets item private transform (not propagated to repr), without compensating stroke widths, + * gradients, patterns as sp_item_write_transform does. + */ void set_item_transform(Geom::Affine const &transform_matrix); + int emitEvent (SPEvent &event); + + /** + * Return the arenaitem corresponding to the given item in the display + * with the given key + */ Inkscape::DrawingItem *get_arenaitem(unsigned int key); + /** + * Returns the accumulated transformation of the item and all its ancestors, including root's viewport. + * @pre (item != NULL) and SP_IS_ITEM(item). + */ Geom::Affine i2doc_affine() const; + + /** + * Returns the transformation from item to desktop coords + */ Geom::Affine i2dt_affine() const; + void set_i2d_affine(Geom::Affine const &transform); + + /** + * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa). + */ Geom::Affine dt2i_affine() const; char *_highlightColor; + private: enum EvaluatedStatus { @@ -281,17 +404,16 @@ public: // Utility +/** + * @pre \a ancestor really is an ancestor (\>=) of \a object, or NULL. + * ("Ancestor (\>=)" here includes as far as \a object itself.) + */ Geom::Affine i2anc_affine(SPObject const *item, SPObject const *ancestor); + Geom::Affine i2i_affine(SPObject const *src, SPObject const *dest); /* fixme: - these are evil, but OK */ -/* Fill *TRANSFORM with the item-to-desktop transform. See doc/coordinates.txt - * for a description of `Desktop coordinates'; though see also mental's comment - * at the top of that file. - * - * \return TRANSFORM. - */ int sp_item_repr_compare_position(SPItem const *first, SPItem const *second); SPItem *sp_item_first_item_child (SPObject *obj); SPItem const *sp_item_first_item_child (SPObject const *obj); |
