sp-marker.cpp revision f65d8b8e49fa8aadec915cd195bb9d077299b258
#define __SP_MARKER_C__
/*
* SVG <marker> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1999-2003 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "config.h"
#include "libnr/nr-matrix-fns.h"
#include "libnr/nr-matrix-ops.h"
#include "libnr/nr-scale-matrix-ops.h"
#include "libnr/nr-rotate-fns.h"
#include "display/nr-arena-group.h"
#include "attributes.h"
#include "marker.h"
struct SPMarkerView {
unsigned int key;
unsigned int size;
};
static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
static NRArenaItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_marker_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems);
static SPGroupClass *parent_class;
/**
* Registers the SPMarker class with Gdk and returns its type number.
*/
sp_marker_get_type (void)
{
if (!type) {
sizeof (SPMarkerClass),
sizeof (SPMarker),
16,
NULL, /* value_table */
};
}
return type;
}
/**
* Initializes a SPMarkerClass object. Establishes the function pointers to the class'
* member routines in the class vtable, and sets pointers to parent classes.
*/
static void
{
}
/**
* Initializes an SPMarker object. This notes the marker's viewBox is
* not set and initializes the marker's c2p identity matrix.
*/
static void
{
}
/**
* 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 sp_object_build()
*/
static void
{
}
/**
* 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 sp_object_release()
*/
static void
{
/* Destroy all NRArenaitems etc. */
/* Parent class ::hide method */
}
}
/**
* Sets an attribute, 'key', of a marker object to 'value'. Supported
* attributes that can be set with this routine include:
*
* SP_ATTR_MARKERUNITS
* SP_ATTR_REFX
* SP_ATTR_REFY
* SP_ATTR_MARKERWIDTH
* SP_ATTR_MARKERHEIGHT
* SP_ATTR_ORIENT
* SP_ATTR_VIEWBOX
* SP_ATTR_PRESERVEASPECTRATIO
*/
static void
{
switch (key) {
case SP_ATTR_MARKERUNITS:
if (value) {
}
}
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:
if (value) {
}
}
break;
case SP_ATTR_VIEWBOX:
if (value) {
char *eptr;
/* fixme: We have to take original item affine into account */
/* fixme: Think (Lauris) */
/* Set viewbox */
}
}
break;
/* Do setup before, so we can use break to escape */
if (value) {
int len;
gchar c[256];
const gchar *p, *e;
p = value;
while (*p && *p == 32) p += 1;
if (!*p) break;
e = p;
while (*e && *e != 32) e += 1;
len = e - p;
if (len > 8) break;
c[len] = 0;
/* Now the actual part */
if (!strcmp (c, "none")) {
} else if (!strcmp (c, "xMinYMin")) {
} else if (!strcmp (c, "xMidYMin")) {
} else if (!strcmp (c, "xMaxYMin")) {
} else if (!strcmp (c, "xMinYMid")) {
} else if (!strcmp (c, "xMidYMid")) {
} else if (!strcmp (c, "xMaxYMin")) {
} else if (!strcmp (c, "xMinYMax")) {
} else if (!strcmp (c, "xMidYMax")) {
} else if (!strcmp (c, "xMaxYMax")) {
} else {
break;
}
while (*e && *e == 32) e += 1;
if (e) {
if (!strcmp (e, "meet")) {
} else if (!strcmp (e, "slice")) {
} else {
break;
}
}
}
break;
default:
break;
}
}
/**
* Updates <marker> when its attributes have changed. Takes care of setting up
* transformations and viewBoxes.
*/
static void
{
NRMatrix q;
SPMarkerView *v;
/* fixme: We have to set up clip here too */
/* Copy parent context */
/* Initialize tranformations */
/* Set up viewport */
/* Start with identity transform */
/* Viewbox is always present, either implicitly or explicitly */
if (marker->viewBox_set) {
} else {
}
/* Now set up viewbox transformation */
/* Determine actual viewbox in viewport coordinates */
x = 0.0;
y = 0.0;
} else {
/* Things are getting interesting */
/* Now place viewbox to requested position */
switch (marker->aspect_align) {
case SP_ASPECT_XMIN_YMIN:
x = 0.0;
y = 0.0;
break;
case SP_ASPECT_XMID_YMIN:
y = 0.0;
break;
case SP_ASPECT_XMAX_YMIN:
y = 0.0;
break;
case SP_ASPECT_XMIN_YMID:
x = 0.0;
break;
case SP_ASPECT_XMID_YMID:
break;
case SP_ASPECT_XMAX_YMID:
break;
case SP_ASPECT_XMIN_YMAX:
x = 0.0;
break;
case SP_ASPECT_XMID_YMAX:
break;
case SP_ASPECT_XMAX_YMAX:
break;
default:
x = 0.0;
y = 0.0;
break;
}
}
/* Compose additional transformation from scale and position */
q.c[1] = 0.0;
q.c[2] = 0.0;
/* Append viewbox transformation */
/* Append reference translation */
/* fixme: lala (Lauris) */
/* If viewBox is set reinitialize child viewport */
/* Otherwise it already correct */
if (marker->viewBox_set) {
}
/* And invoke parent method */
/* As last step set additional transform of arena group */
for (unsigned i = 0 ; i < v->size ; i++) {
if (v->items[i]) {
}
}
}
}
/**
* Writes the object's properties into its repr object.
*/
{
}
if (marker->markerUnits_set) {
} else {
}
} else {
}
} else {
}
} else {
}
} else {
}
} else {
}
if (marker->orient_set) {
if (marker->orient_auto) {
} else {
}
} else {
}
/* fixme: */
return repr;
}
/**
* This routine is disabled to break propagation.
*/
static NRArenaItem *
{
/* Break propagation */
return NULL;
}
/**
* This routine is disabled to break propagation.
*/
static void
{
/* Break propagation */
}
/**
* This routine is disabled to break propagation.
*/
static void
{
/* Break propagation */
}
/**
* This routine is disabled to break propagation.
*/
static void
{
/* Break propagation */
}
/* fixme: Remove link if zero-sized (Lauris) */
/**
* Removes any SPMarkerViews that a marker has with a specific key.
* Set up the NRArenaItem 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 NRArenaItems to put in the SPMarkerView.
*/
void
{
unsigned int i;
}
/* Free old view and allocate new */
/* Parent class ::hide method */
}
if (!view) {
}
}
/**
* Shows an instance of a marker. This is called during sp_shape_update_marker_view()
* show and transform a child item in the arena for all views with the given key.
*/
{
return NULL;
}
/* Parent class ::show method */
/* fixme: Position (Lauris) */
/* nr_arena_item_unref (v->items[pos]); */
}
}
if (marker->orient_auto) {
m = base;
} else {
/* fixme: Orient units (Lauris) */
m *= get_translation(base);
}
}
}
}
}
return NULL;
}
/**
* This replaces SPItem implementation because we have our own views
* \param key SPMarkerView key to hide.
*/
void
{
SPMarkerView *v;
while (v != NULL) {
/* Parent class ::hide method */
return;
}
v = next;
}
}
/**
* Removes a given view. Also will destroy sub-items in the view if destroyitems
* is set to a non-zero value.
*/
static void
{
unsigned int i;
} else {
SPMarkerView *v;
}
if (destroyitems) {
/* We have to walk through the whole array because there may be hidden items */
}
}
}