sp-marker.cpp revision 895d84383ce6dc9fe3cdf4dc4025d703f83f46e4
/*
* SVG <marker> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Bryce Harrington <bryce@bryceharrington.org>
* Abhishek Sharma
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1999-2003 Lauris Kaplinski
* 2004-2006 Bryce Harrington
* 2008 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <cstring>
#include <string>
#include "config.h"
#include "display/drawing-group.h"
#include "attributes.h"
#include "sp-marker.h"
#include "document.h"
#include "document-private.h"
#include "preferences.h"
class SPMarkerView {
public:
SPMarkerView() {};
~SPMarkerView() {
delete items[i];
}
}
};
#include "sp-factory.h"
namespace {
SPObject* createMarker() {
return new SPMarker();
}
}
this->markerUnits = 0;
this->markerUnits_set = 0;
this->orient_mode = MARKER_ORIENT_ANGLE;
this->orient_set = 0;
this->orient = 0;
}
/**
* Initializes an SPMarker object. This notes the marker's viewBox is
* not set and initializes the marker's c2p identity matrix.
*/
}
/**
* Virtual build callback for SPMarker.
*
* This is to be invoked immediately after creation of an SPMarker. This
* method fills an SPMarker object with its SVG attributes, and calls the
* parent class' build routine to attach the object to its document and
* repr. The result will be creation of the whole document tree.
*
* \see SPObject::build()
*/
this->readAttr( "markerUnits" );
this->readAttr( "refX" );
this->readAttr( "refY" );
this->readAttr( "markerWidth" );
this->readAttr( "markerHeight" );
this->readAttr( "orient" );
this->readAttr( "viewBox" );
this->readAttr( "preserveAspectRatio" );
}
/**
* Removes, releases and unrefs all children of object
*
* This is the inverse of sp_marker_build(). It must be invoked as soon
* as the marker is removed from the tree, even if it is still referenced
* by other objects. It hides and removes any views of the marker, then
* calls the parent classes' release function to deregister the object
* and release its SPRepr bindings. The result will be the destruction
* of the entire document tree.
*
* \see SPObject::release()
*/
}
}
switch (key) {
case SP_ATTR_MARKERUNITS:
this->markerUnits_set = FALSE;
this->markerUnits = SP_MARKER_UNITS_STROKEWIDTH;
if (value) {
this->markerUnits_set = TRUE;
this->markerUnits_set = TRUE;
}
}
break;
case SP_ATTR_REFX:
break;
case SP_ATTR_REFY:
break;
case SP_ATTR_MARKERWIDTH:
break;
case SP_ATTR_MARKERHEIGHT:
break;
case SP_ATTR_ORIENT:
this->orient_set = FALSE;
this->orient_mode = MARKER_ORIENT_ANGLE;
this->orient = 0.0;
if (value) {
this->orient_mode = MARKER_ORIENT_AUTO;
this->orient_set = TRUE;
this->orient_set = TRUE;
} else {
this->orient_mode = MARKER_ORIENT_ANGLE;
}
}
}
break;
case SP_ATTR_VIEWBOX:
set_viewBox( value );
break;
break;
default:
break;
}
}
// Copy parent context
// Initialize transformations
// Set up viewport
ictx.viewport = Geom::Rect::from_xywh(0, 0, this->markerWidth.computed, this->markerHeight.computed);
// Shift according to refX, refY
// And invoke parent method
// As last step set additional transform of drawing group
g->setChildTransform(this->c2p);
}
}
}
}
Inkscape::XML::Node* SPMarker::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
if (this->markerUnits_set) {
if (this->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
} else {
}
} else {
}
} else {
}
} else {
}
if (this->markerWidth._set) {
} else {
}
if (this->markerHeight._set) {
} else {
}
if (this->orient_set) {
if (this->orient_mode == MARKER_ORIENT_AUTO) {
} else if (this->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) {
} else {
}
} else {
}
/* fixme: */
//XML Tree being used directly here while it shouldn't be....
//XML Tree being used directly here while it shouldn't be....
return repr;
}
Inkscape::DrawingItem* SPMarker::show(Inkscape::Drawing &/*drawing*/, unsigned int /*key*/, unsigned int /*flags*/) {
// Markers in tree are never shown directly even if outside of <defs>.
return 0;
}
Inkscape::DrawingItem* SPMarker::private_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) {
}
// CPPIFY: correct?
}
}
}
/* fixme: Remove link if zero-sized (Lauris) */
/**
* Removes any SPMarkerViews that a marker has with a specific key.
* Set up the DrawingItem array's size in the specified SPMarker's SPMarkerView.
* This is called from sp_shape_update() for shapes that have markers. It
* removes the old view of the marker and establishes a new one, registering
* it with the marker's list of views for future updates.
*
* \param marker Marker to create views in.
* \param key Key to give each SPMarkerView.
* \param size Number of DrawingItems to put in the SPMarkerView.
*/
// If marker views are always created in order, then this function could be eliminated
// by doing the push_back in sp_marker_show_instance.
void
{
// Need to change size of vector! (We should not really need to do this.)
for (unsigned int i = 0; i < size; ++i) {
}
}
} else {
for (unsigned int i = 0; i < size; ++i) {
}
}
}
/**
* Shows an instance of a marker. This is called during sp_shape_update_marker_view()
* show and transform a child item in the drawing for all views with the given key.
*/
{
// Do not show marker if linewidth == 0 and markerUnits == strokeWidth
// otherwise Cairo will fail to render anything on the tile
// that contains the "degenerate" marker.
return NULL;
}
// Key not found
return NULL;
}
// Position index too large, doesn't exist.
return NULL;
}
// If not already created
/* Parent class ::show method */
/* fixme: Position (Lauris) */
}
}
m = base;
m = base;
} else {
/* fixme: Orient units (Lauris) */
}
}
}
}
/**
* This replaces SPItem implementation because we have our own views
* \param key SPMarkerView key to hide.
*/
void
{
}
const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move)
{
// Uncommenting this will make the marker fixed-size independent of stroke width.
// Commented out for consistency with standard markers which scale when you change
// stroke width:
//repr->setAttribute("markerUnits", "userSpaceOnUse");
dup_transform *= move;
}
return mark_id;
}
{
return marker;
}
return marker;
}
// Turn off garbage-collectable or it might be collected before we can use it
}
return marker_new;
}
/*
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 :