summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-02-25 17:29:16 +0000
committerMartin Owens <doctormo@gmail.com>2014-02-25 17:29:16 +0000
commite84ae2ae2b7035f2dd7ae0bfb026f80ff8bc8f87 (patch)
tree7bfc20c5f22bb0120ebde7c81bc4410aca0dace4 /src
parentNot finished by improved data uri support (diff)
parentFix infinite loop (?) by disabling saving the order of filters when they are ... (diff)
downloadinkscape-e84ae2ae2b7035f2dd7ae0bfb026f80ff8bc8f87.tar.gz
inkscape-e84ae2ae2b7035f2dd7ae0bfb026f80ff8bc8f87.zip
Merge from trunk
(bzr r13047.1.3)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/emf-inout.cpp2
-rw-r--r--src/extension/internal/emf-print.cpp10
-rw-r--r--src/extension/internal/wmf-inout.cpp10
-rw-r--r--src/extension/internal/wmf-print.cpp16
-rw-r--r--src/seltrans-handles.cpp16
-rw-r--r--src/sp-image.cpp42
-rw-r--r--src/ui/dialog/document-properties.cpp8
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp7
-rw-r--r--src/ui/dialog/symbols.cpp4
-rw-r--r--src/ui/tools/dropper-tool.cpp2
-rw-r--r--src/ui/tools/freehand-base.cpp2
-rw-r--r--src/ui/tools/measure-tool.cpp2
-rw-r--r--src/ui/tools/text-tool.cpp2
-rw-r--r--src/ui/tools/zoom-tool.cpp2
-rw-r--r--src/ui/widget/page-sizer.cpp30
-rw-r--r--src/util/units.cpp13
-rw-r--r--src/util/units.h8
17 files changed, 100 insertions, 76 deletions
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index 276dee362..b73c5e9e5 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -554,6 +554,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint
else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; }
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -1531,6 +1532,7 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr,
tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n";
tmp_image << " transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset
+ tmp_image << " preserveAspectRatio=\"none\"\n";
tmp_image << "/> \n";
*(d->outsvg) += tmp_image.str().c_str();
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 6d5bb6f4b..c103100b3 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -1562,7 +1562,7 @@ unsigned int PrintEmf::image(
unsigned int w, /** width of bitmap */
unsigned int h, /** height of bitmap */
unsigned int rs, /** row stride (normally w*4) */
- Geom::Affine const &/*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */
+ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */
SPStyle const *style) /** provides indirect link to image object */
{
double x1, y1, dw, dh;
@@ -1574,10 +1574,10 @@ unsigned int PrintEmf::image(
g_error("Fatal programming error in PrintEmf::image at EMRHEADER");
}
- x1 = atof(style->object->getAttribute("x"));
- y1 = atof(style->object->getAttribute("y"));
- dw = atof(style->object->getAttribute("width"));
- dh = atof(style->object->getAttribute("height"));
+ x1 = tf_rect[4];
+ y1 = tf_rect[5];
+ dw = ((double) w) * tf_rect[0];
+ dh = ((double) h) * tf_rect[3];
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index fc54350df..3c348f5c4 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -525,6 +525,7 @@ uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsa
else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; }
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -619,6 +620,7 @@ uint32_t Wmf::add_bm16_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *
*(d->defs) += " xlink:href=\"data:image/png;base64,";
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -1269,6 +1271,7 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
SVGOStringStream tmp_image;
int dibparams;
+ tmp_image << "\n\t <image\n";
tmp_image << " y=\"" << dy << "\"\n x=\"" << dx <<"\"\n ";
// The image ID is filled in much later when tmp_image is converted
@@ -1355,12 +1358,11 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
}
tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n";
-
tmp_image << " transform=" << current_matrix(d, 0.0, 0.0, 0); // returns an identity matrix, no offsets.
- *(d->outsvg) += "\n\t <image\n";
- *(d->outsvg) += tmp_image.str().c_str();
+ tmp_image << " preserveAspectRatio=\"none\"\n";
+ tmp_image << "/> \n";
- *(d->outsvg) += "/> \n";
+ *(d->outsvg) += tmp_image.str().c_str();
*(d->path) = "";
}
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 1c7b42c82..32c7ac0bd 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -1103,7 +1103,7 @@ unsigned int PrintWmf::image(
unsigned int w, /** width of bitmap */
unsigned int h, /** height of bitmap */
unsigned int rs, /** row stride (normally w*4) */
- Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */
+ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */
SPStyle const *style) /** provides indirect link to image object */
{
double x1, y1, dw, dh;
@@ -1115,15 +1115,19 @@ unsigned int PrintWmf::image(
g_error("Fatal programming error in PrintWmf::image at EMRHEADER");
}
- x1 = g_ascii_strtod(style->object->getAttribute("x"), NULL);
- y1 = g_ascii_strtod(style->object->getAttribute("y"), NULL);
- dw = g_ascii_strtod(style->object->getAttribute("width"), NULL);
- dh = g_ascii_strtod(style->object->getAttribute("height"), NULL);
+ x1 = tf_rect[4];
+ y1 = tf_rect[5];
+ dw = ((double) w) * tf_rect[0];
+ dh = ((double) h) * tf_rect[3];
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
+ /* adjust scale of w and h. This works properly when there is no rotation. The values are
+ a bit strange when there is rotation, but since WMF cannot handle rotation in any case, all
+ answers are equally wrong.
+ */
Geom::Point pWH(dw, dh);
- Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale
+ Geom::Point pWH2 = pWH * tf.withoutTranslation();
char *px;
uint32_t cbPx;
diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp
index 6dd94d297..2f9fb9076 100644
--- a/src/seltrans-handles.cpp
+++ b/src/seltrans-handles.cpp
@@ -17,22 +17,22 @@ SPSelTransHandle const hands[] = {
//center handle will be 0 so we can reference it quickly.
{HANDLE_CENTER, SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, 0.5, 0.5},
//handle-type anchor-nudge cursor image x y
- {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1},
- {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5},
- {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0},
- {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5},
{HANDLE_SCALE, SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, 0, 1},
+ {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1},
{HANDLE_SCALE, SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, 1, 1},
+ {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5},
{HANDLE_SCALE, SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, 1, 0},
+ {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0},
{HANDLE_SCALE, SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, 0, 0},
- {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1},
- {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5},
- {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0},
- {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5},
+ {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5},
{HANDLE_ROTATE, SP_ANCHOR_SE, GDK_EXCHANGE, 4, 0, 1},
+ {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1},
{HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 5, 1, 1},
+ {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5},
{HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 6, 1, 0},
+ {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0},
{HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 7, 0, 0},
+ {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5},
};
/*
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 5f630f7b7..2c20331a9 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -500,39 +500,15 @@ void SPImage::print(SPPrintContext *ctx) {
int w = pb->width();
int h = pb->height();
int rs = pb->rowstride();
- //int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8;
- int pixskip = 4;
-
- if (this->aspect_align == SP_ASPECT_NONE) {
- Geom::Affine t;
- Geom::Translate tp(this->x.computed, this->y.computed);
- Geom::Scale s(this->width.computed, -this->height.computed);
- Geom::Translate ti(0.0, -1.0);
- t = s * tp;
- t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style);
- } else { // preserveAspectRatio
- double vw = this->width.computed / this->sx;
- double vh = this->height.computed / this->sy;
-
- int trimwidth = std::min<int>(w, ceil(this->width.computed / vw * w));
- int trimheight = std::min<int>(h, ceil(this->height.computed / vh * h));
- int trimx = std::max<int>(0, floor((this->x.computed - this->ox) / vw * w));
- int trimy = std::max<int>(0, floor((this->y.computed - this->oy) / vh * h));
-
- double vx = std::max<double>(this->ox, this->x.computed);
- double vy = std::max<double>(this->oy, this->y.computed);
- double vcw = std::min<double>(this->width.computed, vw);
- double vch = std::min<double>(this->height.computed, vh);
-
- Geom::Affine t;
- Geom::Translate tp(vx, vy);
- Geom::Scale s(vcw, -vch);
- Geom::Translate ti(0.0, -1.0);
- t = s * tp;
- t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, this->style);
- }
+
+ double vx = this->ox;
+ double vy = this->oy;
+
+ Geom::Affine t;
+ Geom::Translate tp(vx, vy);
+ Geom::Scale s(this->sx, this->sy);
+ t = s * tp;
+ sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style);
delete pb;
}
}
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index d344fb1d6..0411c789c 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1734,8 +1734,14 @@ void DocumentProperties::onDocUnitChange()
prefs->setBool("/options/transform/gradient", true);
{
ShapeEditor::blockSetItem(true);
+ gdouble viewscale = doc->getWidth().value("px")/doc->getRoot()->viewBox.width();
+ if (doc->getHeight().value("px")/doc->getRoot()->viewBox.height() < viewscale)
+ viewscale = doc->getHeight().value("px")/doc->getRoot()->viewBox.height();
gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit);
- doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px")));
+ doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(-viewscale*doc->getRoot()->viewBox.min()[Geom::X] +
+ (doc->getWidth().value("px") - viewscale*doc->getRoot()->viewBox.width())/2,
+ viewscale*doc->getRoot()->viewBox.min()[Geom::Y] +
+ (doc->getHeight().value("px") + viewscale*doc->getRoot()->viewBox.height())/2));
ShapeEditor::blockSetItem(false);
}
prefs->setBool("/options/transform/stroke", transform_stroke);
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 6a3a4c3f1..e8b09db8b 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1515,11 +1515,16 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa
}
void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& /*path*/) {
+/* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous!
+ Writing back the reordered list to XML (reordering XML nodes) should be implemented differently.
+ Note that the dialog does also not update its list of filters when the order is manually changed
+ using the XML dialog
for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
SPObject* object = (*i)[_columns.filter];
- if(object && object->getRepr())
+ if(object && object->getRepr()) ;
object->getRepr()->setPosition(0);
}
+*/
}
void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path)
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 98754fb4f..62a2f8572 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -381,8 +381,10 @@ void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) {
}
}
-void SymbolsDialog::documentReplaced(SPDesktop */*desktop*/, SPDocument */*document*/)
+void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document)
{
+ currentDesktop = desktop;
+ currentDocument = document;
rebuild();
}
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 9c47b50e9..88ed342df 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -152,6 +152,8 @@ void DropperTool::finish() {
#endif
cursor_dropper_fill = NULL;
}
+
+ ToolBase::finish();
}
/**
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index c3c269743..1e0e6b3b6 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -167,6 +167,8 @@ void FreehandBase::finish() {
}
spdc_free_colors(this);
+
+ ToolBase::finish();
}
void FreehandBase::set(const Inkscape::Preferences::Entry& /*value*/) {
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 0d823dfda..4d7f1e074 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -254,6 +254,8 @@ void MeasureTool::finish() {
sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME);
this->grabbed = NULL;
}
+
+ ToolBase::finish();
}
//void MeasureTool::setup() {
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 9b5ab1016..ba68c7829 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -266,6 +266,8 @@ void TextTool::finish() {
}
this->text_selection_quads.clear();
+
+ ToolBase::finish();
}
bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index d4ede1053..0996e6cf4 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -63,6 +63,8 @@ void ZoomTool::finish() {
sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME);
this->grabbed = NULL;
}
+
+ ToolBase::finish();
}
void ZoomTool::setup() {
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index b13567adb..eae0d4a95 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -547,36 +547,40 @@ PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr)
/**
* Returns an iterator pointing to a row in paperSizeListStore which
- * contains a paper of the specified size (specified in px), or
+ * contains a paper of the specified size, or
* paperSizeListStore->children().end() if no such paper exists.
+ *
+ * The code is not tested for the case where w and h have different units.
*/
Gtk::ListStore::iterator
PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const
{
- double smaller = w.quantity;
- double larger = h.quantity;
+ using Inkscape::Util::Quantity;
+ using std::swap;
+
+ // The code below assumes that w < h, so make sure that's the case:
if ( h < w ) {
- smaller = h.quantity; larger = w.quantity;
+ swap(h,w);
}
- g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end());
+ g_return_val_if_fail(w <= h, _paperSizeListStore->children().end());
std::map<Glib::ustring, PaperSize>::const_iterator iter;
for (iter = _paperSizeTable.begin() ;
iter != _paperSizeTable.end() ; ++iter) {
PaperSize paper = iter->second;
- double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit);
- double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit);
+ Quantity smallX (paper.smaller, paper.unit);
+ Quantity largeX (paper.larger, paper.unit);
- g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end());
+ g_return_val_if_fail(smallX.quantity < largeX.quantity + 0.001, _paperSizeListStore->children().end());
- if ((std::abs(smaller - smallX) <= 0.1) &&
- (std::abs(larger - largeX) <= 0.1) ) {
- Gtk::ListStore::iterator p;
+ if ( are_near(w, smallX, 0.1) && are_near(h, largeX, 0.1) ) {
+ Gtk::ListStore::iterator p = _paperSizeListStore->children().begin();
+ Gtk::ListStore::iterator pend = _paperSizeListStore->children().end();
// We need to search paperSizeListStore explicitly for the
// specified paper size because it is sorted in a different
// way than paperSizeTable (which is sorted alphabetically)
- for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) {
+ for ( ; p != pend; ++p) {
if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) {
return p;
}
@@ -601,7 +605,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing()
SPDocument *doc;
SPNamedView *nv;
Inkscape::XML::Node *nv_repr;
-
+
if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP))
&& (nv = sp_document_namedview(doc, 0))
&& (nv_repr = nv->getRepr())) {
diff --git a/src/util/units.cpp b/src/util/units.cpp
index 40cce028d..d2053f60b 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -505,16 +505,23 @@ double Quantity::convert(double from_dist, char const *from, char const *to)
return convert(from_dist, unit_table.getUnit(from), unit_table.getUnit(to));
}
-bool Quantity::operator<(Quantity const &other) const
+bool Quantity::operator<(Quantity const &rhs) const
{
- if (unit->type != other.unit->type) {
+ if (unit->type != rhs.unit->type) {
g_warning("Incompatible units");
return false;
}
- return quantity < other.value(unit);
+ return quantity < rhs.value(unit);
}
bool Quantity::operator==(Quantity const &other) const
{
+ /** \fixme This is overly strict. I think we should change this to:
+ if (unit->type != other.unit->type) {
+ g_warning("Incompatible units");
+ return false;
+ }
+ return are_near(quantity, other.value(unit));
+ */
return (*unit == *other.unit) && (quantity == other.quantity);
}
diff --git a/src/util/units.h b/src/util/units.h
index 597371369..efe1dbec7 100644
--- a/src/util/units.h
+++ b/src/util/units.h
@@ -16,6 +16,7 @@
#include <map>
#include <boost/operators.hpp>
#include <glibmm/ustring.h>
+#include <2geom/coord.h>
#include "svg/svg-length.h"
#include "unordered-containers.h"
@@ -112,10 +113,15 @@ public:
static double convert(double from_dist, char const *from, char const *to);
/** Comparison operators. */
- bool operator<(Quantity const &other) const;
+ bool operator<(Quantity const &rhs) const;
bool operator==(Quantity const &other) const;
};
+inline bool are_near(Quantity const &a, Quantity const &b, double eps=Geom::EPSILON)
+{
+ return Geom::are_near(a.quantity, b.value(a.unit), eps);
+}
+
class UnitTable {
public:
/**