sp-item.h revision 9275d1d75811bbc0b1810bdc7b5ee6675292d9fd
#ifndef SEEN_SP_ITEM_H
#define SEEN_SP_ITEM_H
/**
* @file
* Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx, SPItemClass, SPEvent.
*/
/*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Abhishek Sharma
*
* Copyright (C) 1999-2006 authors
* Copyright (C) 2001-2002 Ximian, Inc.
* Copyright (C) 2004 Monash University
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <vector>
#include "sp-object.h"
#include "snap-preferences.h"
#include "snap-candidate.h"
//class SPGuideConstraint;
#include "sp-guide-constraint.h"
struct SPPrintContext;
typedef unsigned int guint32;
}
enum {
};
// TODO make a completely new function that transforms either the fill or
// stroke of any SPItem without adding an extra parameter to adjust_pattern.
enum PatternTransform {
};
/**
* Event structure.
*
* @todo This is just placeholder. Plan:
* We do extensible event structure, that hold applicable (ui, non-ui)
* to process correct ones in meaningful way.
* Also, this probably goes to SPObject base class.
*
*/
unsigned int type;
void* data;
};
unsigned int flags;
unsigned int key;
};
/* flags */
#define SP_ITEM_BBOX_VISUAL 1
#define SP_ITEM_SHOW_DISPLAY (1 << 0)
/**
* Flag for referenced views (i.e. markers, clippaths, masks and patterns);
* currently unused, does the same as DISPLAY
*/
/**
*/
/** Item to document transformation */
/** Viewport size */
/** Item to viewport transformation */
};
/**
* 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.
*/
enum BBoxType {
// legacy behavior: includes crude stroke, markers; excludes long miters, blur margin; is known to be wrong for caps
// includes only the bare path bbox, no stroke, no nothing
// includes everything: correctly done stroke (with proper miters and caps), markers, filter margins (e.g. blur)
};
SPItem();
unsigned int sensitive : 1;
unsigned int stop_paint: 1;
double transform_center_x;
double transform_center_y;
bool freeze_stroke_width;
// Used for object-avoiding connectors
bool isLocked() const;
bool isHidden() const;
// Objects dialogue
bool isSensitive() const {
return sensitive;
};
bool isHighlightSet() const;
guint32 highlight_color() const;
void unsetHighlightColor();
//====================
bool isEvaluated() const;
void setEvaluated(bool visible);
void resetEvaluated();
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 unsetCenter();
bool isCenterSet() const;
bool isVisibleAndUnlocked() const;
bool isVisibleAndUnlocked(unsigned display_key) const;
void raiseOne();
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).
*/
}
/**
* Get item's geometric bounding box in this item's coordinate system.
*
* The geometric bounding box includes only the path, disregarding all style attributes.
*/
/**
* Get item's visual bounding box in this item's coordinate system.
*
* The visual bounding box includes the stroke and the filter region.
*/
/**
* 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.
*/
/**
* Get item's visual bbox in document coordinate system.
*/
/**
* 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.
*/
/**
* Get item's visual bbox in desktop coordinate system.
*/
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.
*/
bool isFiltered() const;
/**
* 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);
/**
* Set a new transform on an object.
*
* 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.
*/
/**
* Return the arenaitem corresponding to the given item in the display
* with the given key
*/
/**
* Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
* @pre (item != NULL) and SP_IS_ITEM(item).
*/
/**
* Returns the transformation from item to desktop coords
*/
/**
* should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa).
*/
char *_highlightColor;
enum EvaluatedStatus
{
};
mutable bool _is_evaluated;
static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, Inkscape::DrawingItem *arenaitem);
virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags);
virtual const char* displayName() const;
virtual char* description() const;
virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
virtual void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const;
virtual void convert_to_guides() const;
};
// Utility
/**
* @pre \a ancestor really is an ancestor (\>=) of \a object, or NULL.
* ("Ancestor (\>=)" here includes as far as \a object itself.)
*/
/* fixme: - these are evil, but OK */
#endif // SEEN_SP_ITEM_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :