summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-11-29 19:01:07 +0000
committerTed Gould <ted@gould.cx>2009-11-29 19:01:07 +0000
commit29d3c0b15028e61f176df3a75189bf0959d0d03e (patch)
tree727afe596c693a9bdd098d72618abd9ceb0d1969 /src/display
parentAdd the build dir dbus directory to grab some headerfiles for distcheck. (diff)
parenthopefully fix build on linux (diff)
downloadinkscape-29d3c0b15028e61f176df3a75189bf0959d0d03e.tar.gz
inkscape-29d3c0b15028e61f176df3a75189bf0959d0d03e.zip
Merging in from trunk
(bzr r8254.1.37)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-axonomgrid.cpp2
-rw-r--r--src/display/curve-test.h2
-rw-r--r--src/display/curve.cpp8
-rw-r--r--src/display/nr-filter-image.cpp7
-rw-r--r--src/display/nr-filter.cpp22
-rw-r--r--src/display/snap-indicator.cpp317
-rw-r--r--src/display/sp-canvas.cpp2
7 files changed, 190 insertions, 170 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 71b22d2ad..a92e7cf5b 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -311,7 +311,7 @@ CanvasAxonomGrid::readRepr()
if ( (value = repr->attribute("spacingy")) ) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &lengthy, &gridunit);
lengthy = sp_units_get_pixels(lengthy, *(gridunit));
- if (lengthy < 1.0) lengthy = 1.0;
+ if (lengthy < 0.0500) lengthy = 0.0500;
}
if ( (value = repr->attribute("gridanglex")) ) {
diff --git a/src/display/curve-test.h b/src/display/curve-test.h
index d779fe09b..784ccee89 100644
--- a/src/display/curve-test.h
+++ b/src/display/curve-test.h
@@ -90,7 +90,7 @@ public:
pv[0] = path1;
TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 3u);
pv[0] = path2;
- TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 3u);
+ TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 2u); // zero length closing segments do not increase the nodecount.
pv[0] = path3;
TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 5u);
pv[0] = path4;
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 5a1e2abeb..7d7dbc987 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -629,10 +629,14 @@ SPCurve::nodes_in_path() const
nr++; // count last node (this works also for closed paths because although they don't have a 'last node', they do have an extra segment
- if (it->closed()) {
+ // do not count closing knot double for zero-length closing line segments
+ // however, if the path is only a moveto, and is closed, do not subtract 1 (otherwise the result will be zero nodes)
+ if ( it->closed()
+ && ((*it).size() != 0) )
+ {
Geom::Curve const &c = it->back_closed();
if (are_near(c.initialPoint(), c.finalPoint())) {
- nr--; // do not count closing knot double for zero-length closing line segments
+ nr--;
}
}
}
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index 9679e56e7..2b799f8d2 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -107,6 +107,13 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) {
if (!image_pixbuf){
try {
+ /* TODO: If feImageHref is absolute, then use that (preferably handling the
+ * case that it's not a file URI). Otherwise, go up the tree looking
+ * for an xml:base attribute, and use that as the base URI for resolving
+ * the relative feImageHref URI. Otherwise, if document && document->base,
+ * then use that as the base URI. Otherwise, use feImageHref directly
+ * (i.e. interpreting it as relative to our current working directory).
+ * (See http://www.w3.org/TR/xmlbase/#resolution .) */
gchar *fullname = feImageHref;
if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) {
// Try to load from relative postion combined with document base
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index af432bdf3..d0e0ec11e 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -52,7 +52,7 @@
#if defined (SOLARIS) && (SOLARIS == 8)
#include "round.h"
using Inkscape::round;
-#endif
+#endif
namespace Inkscape {
namespace Filters {
@@ -92,9 +92,9 @@ Filter::Filter()
Filter::Filter(int n)
{
_primitive_count = 0;
- _primitive_table_size = n;
- _primitive = new FilterPrimitive*[n];
- for ( int i = 0 ; i < n ; i++ ) {
+ _primitive_table_size = (n > 0) ? n : 1; // we guarantee there is at least 1(one) filter slot
+ _primitive = new FilterPrimitive*[_primitive_table_size];
+ for ( int i = 0 ; i < _primitive_table_size ; i++ ) {
_primitive[i] = NULL;
}
_common_init();
@@ -159,7 +159,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
// It's no use to try and filter an empty object.
return 1;
}
-
+
FilterUnits units(_filter_units, _primitive_units);
units.set_ctm(trans);
units.set_item_bbox(item_bbox);
@@ -168,6 +168,8 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
// TODO: with filterRes of 0x0 should return an empty image
std::pair<double,double> resolution
= _filter_resolution(filter_area, trans, filterquality);
+ if(!(resolution.first > 0 && resolution.second > 0))
+ return 1;
units.set_resolution(resolution.first, resolution.second);
if (_x_pixels > 0) {
units.set_automatic_resolution(false);
@@ -370,7 +372,11 @@ void Filter::_enlarge_primitive_table() {
for (int i = _primitive_count ; i < _primitive_table_size ; i++) {
new_tbl[i] = NULL;
}
- delete[] _primitive;
+ if(_primitive != NULL) {
+ delete[] _primitive;
+ } else {
+ g_warning("oh oh");
+ }
_primitive = new_tbl;
}
@@ -434,7 +440,7 @@ void Filter::clear_primitives()
}
void Filter::set_x(SVGLength const &length)
-{
+{
if (length._set)
_region_x = length;
}
@@ -449,7 +455,7 @@ void Filter::set_width(SVGLength const &length)
_region_width = length;
}
void Filter::set_height(SVGLength const &length)
-{
+{
if (length._set)
_region_height = length;
}
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
index 081496fd0..20ea7d58c 100644
--- a/src/display/snap-indicator.cpp
+++ b/src/display/snap-indicator.cpp
@@ -26,8 +26,8 @@ namespace Display {
SnapIndicator::SnapIndicator(SPDesktop * desktop)
: _snaptarget(NULL),
- _snaptarget_tooltip(NULL),
- _snapsource(NULL),
+ _snaptarget_tooltip(NULL),
+ _snapsource(NULL),
_desktop(desktop)
{
}
@@ -35,14 +35,14 @@ SnapIndicator::SnapIndicator(SPDesktop * desktop)
SnapIndicator::~SnapIndicator()
{
// remove item that might be present
- remove_snaptarget();
- remove_snapsource();
+ remove_snaptarget();
+ remove_snapsource();
}
void
SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p)
{
- remove_snaptarget(); //only display one snaptarget at a time
+ remove_snaptarget(); //only display one snaptarget at a time
g_assert(_desktop != NULL);
@@ -59,191 +59,194 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p)
// TRANSLATORS: undefined target for snapping
gchar *target_name = _("UNDEFINED");
switch (p.getTarget()) {
- case SNAPTARGET_UNDEFINED:
- target_name = _("UNDEFINED");
- break;
- case SNAPTARGET_GRID:
- target_name = _("grid line");
- break;
+ case SNAPTARGET_UNDEFINED:
+ target_name = _("UNDEFINED");
+ break;
+ case SNAPTARGET_GRID:
+ target_name = _("grid line");
+ break;
case SNAPTARGET_GRID_INTERSECTION:
- target_name = _("grid intersection");
- break;
+ target_name = _("grid intersection");
+ break;
case SNAPTARGET_GUIDE:
- target_name = _("guide");
- break;
+ target_name = _("guide");
+ break;
case SNAPTARGET_GUIDE_INTERSECTION:
- target_name = _("guide intersection");
- break;
+ target_name = _("guide intersection");
+ break;
+ case SNAPTARGET_GUIDE_ORIGIN:
+ target_name = _("guide origin");
+ break;
case SNAPTARGET_GRID_GUIDE_INTERSECTION:
- target_name = _("grid-guide intersection");
- break;
+ target_name = _("grid-guide intersection");
+ break;
case SNAPTARGET_NODE_CUSP:
- target_name = _("cusp node");
- break;
+ target_name = _("cusp node");
+ break;
case SNAPTARGET_NODE_SMOOTH:
- target_name = _("smooth node");
- break;
- case SNAPTARGET_PATH:
- target_name = _("path");
- break;
+ target_name = _("smooth node");
+ break;
+ case SNAPTARGET_PATH:
+ target_name = _("path");
+ break;
case SNAPTARGET_PATH_INTERSECTION:
- target_name = _("path intersection");
- break;
+ target_name = _("path intersection");
+ break;
case SNAPTARGET_BBOX_CORNER:
- target_name = _("bounding box corner");
- break;
+ target_name = _("bounding box corner");
+ break;
case SNAPTARGET_BBOX_EDGE:
- target_name = _("bounding box side");
- break;
+ target_name = _("bounding box side");
+ break;
case SNAPTARGET_GRADIENTS_PARENT_BBOX:
- target_name = _("bounding box");
- break;
+ target_name = _("bounding box");
+ break;
case SNAPTARGET_PAGE_BORDER:
- target_name = _("page border");
- break;
+ target_name = _("page border");
+ break;
case SNAPTARGET_LINE_MIDPOINT:
- target_name = _("line midpoint");
- break;
+ target_name = _("line midpoint");
+ break;
case SNAPTARGET_OBJECT_MIDPOINT:
- target_name = _("object midpoint");
- break;
+ target_name = _("object midpoint");
+ break;
case SNAPTARGET_ROTATION_CENTER:
- target_name = _("object rotation center");
- break;
+ target_name = _("object rotation center");
+ break;
case SNAPTARGET_HANDLE:
- target_name = _("handle");
- break;
+ target_name = _("handle");
+ break;
case SNAPTARGET_BBOX_EDGE_MIDPOINT:
- target_name = _("bounding box side midpoint");
- break;
+ target_name = _("bounding box side midpoint");
+ break;
case SNAPTARGET_BBOX_MIDPOINT:
- target_name = _("bounding box midpoint");
- break;
+ target_name = _("bounding box midpoint");
+ break;
case SNAPTARGET_PAGE_CORNER:
- target_name = _("page corner");
- break;
+ target_name = _("page corner");
+ break;
case SNAPTARGET_CONVEX_HULL_CORNER:
- target_name = _("convex hull corner");
- break;
+ target_name = _("convex hull corner");
+ break;
case SNAPTARGET_ELLIPSE_QUADRANT_POINT:
- target_name = _("quadrant point");
- break;
+ target_name = _("quadrant point");
+ break;
case SNAPTARGET_CENTER:
- target_name = _("center");
- break;
+ target_name = _("center");
+ break;
case SNAPTARGET_CORNER:
- target_name = _("corner");
- break;
+ target_name = _("corner");
+ break;
case SNAPTARGET_TEXT_BASELINE:
- target_name = _("text baseline");
- break;
+ target_name = _("text baseline");
+ break;
default:
- g_warning("Snap target has not yet been defined!");
+ g_warning("Snap target has not yet been defined!");
break;
}
gchar *source_name = _("UNDEFINED");
- switch (p.getSource()) {
- case SNAPSOURCE_UNDEFINED:
- source_name = _("UNDEFINED");
- break;
- case SNAPSOURCE_BBOX_CORNER:
- source_name = _("Bounding box corner");
- break;
- case SNAPSOURCE_BBOX_MIDPOINT:
- source_name = _("Bounding box midpoint");
- break;
- case SNAPSOURCE_BBOX_EDGE_MIDPOINT:
- source_name = _("Bounding box side midpoint");
- break;
- case SNAPSOURCE_NODE_SMOOTH:
- source_name = _("Smooth node");
- break;
- case SNAPSOURCE_NODE_CUSP:
- source_name = _("Cusp node");
- break;
- case SNAPSOURCE_LINE_MIDPOINT:
- source_name = _("Line midpoint");
- break;
- case SNAPSOURCE_OBJECT_MIDPOINT:
- source_name = _("Object midpoint");
- break;
- case SNAPSOURCE_ROTATION_CENTER:
- source_name = _("Object rotation center");
- break;
- case SNAPSOURCE_HANDLE:
- source_name = _("Handle");
- break;
- case SNAPSOURCE_PATH_INTERSECTION:
- source_name = _("Path intersection");
- break;
- case SNAPSOURCE_GUIDE:
- source_name = _("Guide");
- break;
- case SNAPSOURCE_GUIDE_ORIGIN:
- source_name = _("Guide origin");
- break;
- case SNAPSOURCE_CONVEX_HULL_CORNER:
- source_name = _("Convex hull corner");
- break;
- case SNAPSOURCE_ELLIPSE_QUADRANT_POINT:
- source_name = _("Quadrant point");
- break;
- case SNAPSOURCE_CENTER:
- source_name = _("Center");
- break;
- case SNAPSOURCE_CORNER:
- source_name = _("Corner");
- break;
- case SNAPSOURCE_TEXT_BASELINE:
- source_name = _("Text baseline");
- break;
- default:
- g_warning("Snap source has not yet been defined!");
- break;
- }
+ switch (p.getSource()) {
+ case SNAPSOURCE_UNDEFINED:
+ source_name = _("UNDEFINED");
+ break;
+ case SNAPSOURCE_BBOX_CORNER:
+ source_name = _("Bounding box corner");
+ break;
+ case SNAPSOURCE_BBOX_MIDPOINT:
+ source_name = _("Bounding box midpoint");
+ break;
+ case SNAPSOURCE_BBOX_EDGE_MIDPOINT:
+ source_name = _("Bounding box side midpoint");
+ break;
+ case SNAPSOURCE_NODE_SMOOTH:
+ source_name = _("Smooth node");
+ break;
+ case SNAPSOURCE_NODE_CUSP:
+ source_name = _("Cusp node");
+ break;
+ case SNAPSOURCE_LINE_MIDPOINT:
+ source_name = _("Line midpoint");
+ break;
+ case SNAPSOURCE_OBJECT_MIDPOINT:
+ source_name = _("Object midpoint");
+ break;
+ case SNAPSOURCE_ROTATION_CENTER:
+ source_name = _("Object rotation center");
+ break;
+ case SNAPSOURCE_HANDLE:
+ source_name = _("Handle");
+ break;
+ case SNAPSOURCE_PATH_INTERSECTION:
+ source_name = _("Path intersection");
+ break;
+ case SNAPSOURCE_GUIDE:
+ source_name = _("Guide");
+ break;
+ case SNAPSOURCE_GUIDE_ORIGIN:
+ source_name = _("Guide origin");
+ break;
+ case SNAPSOURCE_CONVEX_HULL_CORNER:
+ source_name = _("Convex hull corner");
+ break;
+ case SNAPSOURCE_ELLIPSE_QUADRANT_POINT:
+ source_name = _("Quadrant point");
+ break;
+ case SNAPSOURCE_CENTER:
+ source_name = _("Center");
+ break;
+ case SNAPSOURCE_CORNER:
+ source_name = _("Corner");
+ break;
+ case SNAPSOURCE_TEXT_BASELINE:
+ source_name = _("Text baseline");
+ break;
+ default:
+ g_warning("Snap source has not yet been defined!");
+ break;
+ }
//std::cout << "Snapped " << source_name << " to " << target_name << std::endl;
- remove_snapsource(); // Don't set both the source and target indicators, as these will overlap
+ remove_snapsource(); // Don't set both the source and target indicators, as these will overlap
// Display the snap indicator (i.e. the cross)
SPCanvasItem * canvasitem = NULL;
- if (p.getTarget() == SNAPTARGET_NODE_SMOOTH || p.getTarget() == SNAPTARGET_NODE_CUSP) {
- canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop),
- SP_TYPE_CTRL,
- "anchor", GTK_ANCHOR_CENTER,
- "size", 10.0,
- "stroked", TRUE,
- "stroke_color", 0xf000f0ff,
- "mode", SP_KNOT_MODE_XOR,
- "shape", SP_KNOT_SHAPE_DIAMOND,
- NULL );
- } else {
- canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop),
- SP_TYPE_CTRL,
- "anchor", GTK_ANCHOR_CENTER,
- "size", 10.0,
- "stroked", TRUE,
- "stroke_color", 0xf000f0ff,
- "mode", SP_KNOT_MODE_XOR,
- "shape", SP_KNOT_SHAPE_CROSS,
- NULL );
- }
+ if (p.getTarget() == SNAPTARGET_NODE_SMOOTH || p.getTarget() == SNAPTARGET_NODE_CUSP) {
+ canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop),
+ SP_TYPE_CTRL,
+ "anchor", GTK_ANCHOR_CENTER,
+ "size", 10.0,
+ "stroked", TRUE,
+ "stroke_color", 0xf000f0ff,
+ "mode", SP_KNOT_MODE_XOR,
+ "shape", SP_KNOT_SHAPE_DIAMOND,
+ NULL );
+ } else {
+ canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop),
+ SP_TYPE_CTRL,
+ "anchor", GTK_ANCHOR_CENTER,
+ "size", 10.0,
+ "stroked", TRUE,
+ "stroke_color", 0xf000f0ff,
+ "mode", SP_KNOT_MODE_XOR,
+ "shape", SP_KNOT_SHAPE_CROSS,
+ NULL );
+ }
- const int timeout_val = 1200; // TODO add preference for snap indicator timeout?
+ const int timeout_val = 1200; // TODO add preference for snap indicator timeout?
- SP_CTRL(canvasitem)->moveto(p.getPoint());
- _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val);
+ SP_CTRL(canvasitem)->moveto(p.getPoint());
+ _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val);
- gchar *tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL);
- Geom::Point tooltip_pos = p.getPoint() + _desktop->w2d(Geom::Point(15, -15));
+ gchar *tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL);
+ Geom::Point tooltip_pos = p.getPoint() + _desktop->w2d(Geom::Point(15, -15));
- SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str);
- g_free(tooltip_str);
+ SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str);
+ g_free(tooltip_str);
- sp_canvastext_set_anchor((SPCanvasText* )canvas_tooltip, -1, 1);
- _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val);
- }
+ sp_canvastext_set_anchor((SPCanvasText* )canvas_tooltip, -1, 1);
+ _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val);
+ }
}
void
@@ -255,16 +258,16 @@ SnapIndicator::remove_snaptarget()
}
if (_snaptarget_tooltip) {
- _desktop->remove_temporary_canvasitem(_snaptarget_tooltip);
- _snaptarget_tooltip = NULL;
- }
+ _desktop->remove_temporary_canvasitem(_snaptarget_tooltip);
+ _snaptarget_tooltip = NULL;
+ }
}
void
SnapIndicator::set_new_snapsource(std::pair<Geom::Point, int> const p)
{
- remove_snapsource();
+ remove_snapsource();
g_assert(_desktop != NULL);
@@ -284,7 +287,7 @@ SnapIndicator::set_new_snapsource(std::pair<Geom::Point, int> const p)
SP_CTRL(canvasitem)->moveto(p.first);
_snapsource = _desktop->add_temporary_canvasitem(canvasitem, 1000);
- }
+ }
}
void
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 664713582..e640911d6 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1494,7 +1494,7 @@ sp_canvas_button (GtkWidget *widget, GdkEventButton *event)
int retval = FALSE;
- /* dispatch normally regardless of the event's window if an item has
+ /* dispatch normally regardless of the event's window if an item
has a pointer grab in effect */
if (!canvas->grabbed_item &&
event->window != SP_CANVAS_WINDOW (canvas))