summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-31 22:33:03 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-31 22:33:03 +0000
commitf1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b (patch)
treece3ca9ef9daa04c0474e859c939dfabd1ebab557 /src
parentAdded percent support back to select toolbar. (diff)
downloadinkscape-f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b.tar.gz
inkscape-f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b.zip
Eliminate "unit-constants.h".
(bzr r12380.1.54)
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile_insert1
-rw-r--r--src/document.cpp4
-rw-r--r--src/doxygen-main.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.cpp5
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp4
-rw-r--r--src/extension/internal/cairo-renderer.cpp18
-rw-r--r--src/extension/internal/emf-win32-inout.cpp1
-rw-r--r--src/extension/internal/emf-win32-print.cpp2
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp4
-rw-r--r--src/extension/internal/latex-pstricks.cpp6
-rw-r--r--src/extension/internal/latex-text-renderer.cpp4
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp8
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp4
-rw-r--r--src/helper/pixbuf-ops.cpp4
-rw-r--r--src/main.cpp12
-rw-r--r--src/selection-chemistry.cpp14
-rw-r--r--src/sp-text.cpp1
-rw-r--r--src/style.cpp32
-rw-r--r--src/svg/svg-length.cpp14
-rw-r--r--src/text-editing.cpp12
-rw-r--r--src/ui/clipboard.cpp8
-rw-r--r--src/ui/dialog/export.cpp7
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp8
-rw-r--r--src/ui/dialog/print.cpp12
-rw-r--r--src/ui/dialog/text-edit.cpp4
-rw-r--r--src/ui/widget/rendering-options.cpp6
-rw-r--r--src/unit-constants.h47
-rw-r--r--src/widgets/font-selector.cpp1
29 files changed, 95 insertions, 151 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 537e13200..4f7592119 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -481,7 +481,6 @@ set(inkscape_SRC
unclump.h
undo-stack-observer.h
unicoderange.h
- unit-constants.h
uri-references.h
uri.h
vanishing-point.h
diff --git a/src/Makefile_insert b/src/Makefile_insert
index ff64dc183..429c725cd 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -250,7 +250,6 @@ ink_common_sources += \
unclump.cpp unclump.h \
undo-stack-observer.h \
unicoderange.cpp unicoderange.h \
- unit-constants.h \
uri.cpp uri.h \
uri-references.cpp uri-references.h \
vanishing-point.cpp vanishing-point.h \
diff --git a/src/document.cpp b/src/document.cpp
index a024cc790..afd0a6ddc 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -62,7 +62,7 @@
#include "sp-object-repr.h"
#include "sp-symbol.h"
#include "transf_mat_3x4.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "xml/repr.h"
#include "xml/rebase-hrefs.h"
#include "libcroco/cr-cascade.h"
@@ -966,7 +966,7 @@ void SPDocument::setupViewport(SPItemCtx *ctx)
if (root->viewBox_set) { // if set, take from viewBox
ctx->viewport = root->viewBox;
} else { // as a last resort, set size to A4
- ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM);
+ ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * Inkscape::Util::Quantity::convert(1, "mm", "px"), 297 * Inkscape::Util::Quantity::convert(1, "mm", "px"));
}
ctx->i2vp = Geom::identity();
}
diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp
index 42eb5dd13..a1d3f3604 100644
--- a/src/doxygen-main.cpp
+++ b/src/doxygen-main.cpp
@@ -348,7 +348,7 @@ namespace XML {}
* Inkscape::Whiteboard::UndoStackObserver [\ref undo-stack-observer.cpp, \ref composite-undo-stack-observer.cpp]
* [\ref document-undo.cpp]
*
- * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h] [\ref unit-constants.h]
+ * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h]
*/
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index d7a560f04..09b769229 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -44,12 +44,11 @@
#include "sp-pattern.h"
#include "sp-mask.h"
#include "sp-clippath.h"
+#include "util/units.h"
#ifdef WIN32
#include "libnrtype/FontFactory.h" // USE_PANGO_WIN32
#endif
-#include <unit-constants.h>
-
#include "cairo-render-context.h"
#include "cairo-renderer.h"
#include "extension/system.h"
@@ -855,7 +854,7 @@ CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t
_surface = surface;
if (_vector_based_target) {
- cairo_scale(_cr, PT_PER_PX, PT_PER_PX);
+ cairo_scale(_cr, Inkscape::Util::Quantity::convert(1, "px", "pt"), Inkscape::Util::Quantity::convert(1, "px", "pt"));
} else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) {
// set background color on non-alpha surfaces
// TODO: bgcolor should be derived from SPDocument
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 6f641fd36..da4cf1bc1 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -39,7 +39,7 @@
#include <2geom/affine.h>
#include "document.h"
-#include "unit-constants.h"
+#include "util/units.h"
namespace Inkscape {
namespace Extension {
@@ -197,7 +197,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
float new_bleedmargin_px = 0.;
try {
- new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM;
+ new_bleedmargin_px = mod->get_param_float("bleed") * Inkscape::Util::Quantity::convert(1, "mm", "px");
}
catch(...) {
g_warning("Parameter <bleed> might not exist");
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 0a3cff26a..f7ab63c98 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -55,7 +55,7 @@
#include "sp-mask.h"
#include "sp-clippath.h"
-#include <unit-constants.h>
+#include "util/units.h"
#include "helper/png-write.h"
#include "helper/pixbuf-ops.h"
@@ -442,7 +442,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
*/
res = ctx->getBitmapResolution();
if(res == 0) {
- res = PX_PER_IN;
+ res = Inkscape::Util::Quantity::convert(1, "in", "px");
}
TRACE(("sp_asbitmap_render: resolution: %f\n", res ));
@@ -463,8 +463,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
// The width and height of the bitmap in pixels
- unsigned width = ceil(bbox->width() * (res / PX_PER_IN));
- unsigned height = ceil(bbox->height() * (res / PX_PER_IN));
+ unsigned width = ceil(bbox->width() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
+ unsigned height = ceil(bbox->height() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
if (width == 0 || height == 0) return;
@@ -477,7 +477,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
double shift_y = bbox->max()[Geom::Y];
// For default 90 dpi, snap bitmap to pixel grid
- if (res == PX_PER_IN) {
+ if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) {
shift_x = round (shift_x);
shift_y = -round (-shift_y); // Correct rounding despite coordinate inversion.
// Remove the negations when the inversion is gone.
@@ -629,7 +629,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ctx->_vector_based_target) {
// convert from px to pt
- d *= Geom::Scale(PT_PER_PX);
+ d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "pt"));
}
ctx->_width = d.width();
@@ -647,11 +647,11 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
} else {
double high = doc->getHeight();
if (ctx->_vector_based_target)
- high *= PT_PER_PX;
+ high *= Inkscape::Util::Quantity::convert(1, "px", "pt");
// this transform translates the export drawing to a virtual page (0,0)-(width,height)
- Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0)));
ctx->transform(tp);
}
}
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index e9360a0ea..62cb53413 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -37,7 +37,6 @@
#include "extension/output.h"
#include "display/drawing.h"
#include "display/drawing-item.h"
-#include "unit-constants.h"
#include "clear-n_.h"
#include "document.h"
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index 2b79fd5a4..99f101bb8 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -43,8 +43,6 @@
#include "emf-win32-print.h"
-#include "unit-constants.h"
-
#include "extension/system.h"
#include "extension/print.h"
#include "document.h"
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index abfad518f..994258ccc 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -12,7 +12,7 @@
#include "selection-chemistry.h"
#include "sp-image.h"
#include "document-undo.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "image-resolution.h"
#include <set>
@@ -79,7 +79,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
double width = gdk_pixbuf_get_width(pb);
double height = gdk_pixbuf_get_height(pb);
- double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", PX_PER_IN);
+ double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px"));
bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
ImageResolution *ir = 0;
double xscale = 1;
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index c1eddf539..2ece1ba87 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -21,7 +21,7 @@
#include <2geom/hvlinesegment.h>
#include <errno.h>
#include <signal.h>
-#include <unit-constants.h>
+#include "util/units.h"
#include "helper/geom-curves.h"
#include "extension/print.h"
@@ -117,8 +117,8 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc
}
// width and height in pt
- _width = doc->getWidth() * PT_PER_PX;
- _height = doc->getHeight() * PT_PER_PX;
+ _width = doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ _height = doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt");
if (res >= 0) {
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index ecc201733..57a71b467 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -39,7 +39,7 @@
#include "sp-rect.h"
#include "text-editing.h"
-#include <unit-constants.h>
+#include "util/units.h"
#include "extension/system.h"
@@ -611,7 +611,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl
// scaling of the image when including it in LaTeX
os << " \\ifx\\svgwidth\\undefined%\n";
- os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ os << " \\setlength{\\unitlength}{" << d.width() * Inkscape::Util::Quantity::convert(1, "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
os << " \\ifx\\svgscale\\undefined%\n";
os << " \\relax%\n";
os << " \\else%\n";
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 3be7af34f..3b63e9cbe 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -34,7 +34,7 @@ extern "C" {
#include "svg-builder.h"
#include "Gfx.h"
#include "pdf-parser.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "goo/gmem.h"
#include "goo/GooTimer.h"
@@ -279,14 +279,14 @@ PdfParser::PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *bui
ignoreUndef = 0;
operatorHistory = NULL;
builder = builderA;
- builder->setDocumentSize(state->getPageWidth()*PX_PER_PT,
- state->getPageHeight()*PX_PER_PT);
+ builder->setDocumentSize(state->getPageWidth()*Inkscape::Util::Quantity::convert(1, "pt", "px"),
+ state->getPageHeight()*Inkscape::Util::Quantity::convert(1, "pt", "px"));
double *ctm = state->getCTM();
double scaledCTM[6];
for (int i = 0; i < 6; ++i) {
baseMatrix[i] = ctm[i];
- scaledCTM[i] = PX_PER_PT * ctm[i];
+ scaledCTM[i] = Inkscape::Util::Quantity::convert(1, "pt", "px") * ctm[i];
}
saveState();
builder->setTransform((double*)&scaledCTM);
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 75849f6cc..6d9ac1b1a 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -33,7 +33,7 @@
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "color.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "io/stringstream.h"
#include "io/base64stream.h"
#include "display/nr-filter-utils.h"
@@ -777,7 +777,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for
Geom::Affine pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3],
matrix[4], matrix[5]);
if ( !for_shading && _is_top_level ) {
- Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * PT_PER_PX);
+ Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * Inkscape::Util::Quantity::convert(1, "px", "pt"));
pat_matrix *= flip;
}
gchar *transform_text = sp_svg_transform_write(pat_matrix);
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index 9cd1967d8..75c002c57 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -29,7 +29,7 @@
#include "sp-root.h"
#include "sp-use.h"
#include "sp-defs.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "helper/pixbuf-ops.h"
@@ -121,7 +121,7 @@ GdkPixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*
origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2));
origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2));
- Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN));
+ Geom::Scale scale( (xdpi / Inkscape::Util::Quantity::convert(1, "in", "px")), (ydpi / Inkscape::Util::Quantity::convert(1, "in", "px")));
Geom::Affine affine = scale * Geom::Translate(-origin * scale);
/* Create ArenaItems and set transform */
diff --git a/src/main.cpp b/src/main.cpp
index d425b88bb..577cc3d79 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -68,7 +68,7 @@
#include "color.h"
#include "sp-item.h"
#include "sp-root.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
@@ -1524,7 +1524,7 @@ static int sp_do_export_png(SPDocument *doc)
// default dpi
if (dpi == 0.0) {
- dpi = PX_PER_IN;
+ dpi = Inkscape::Util::Quantity::convert(1, "in", "px");
}
unsigned long int width = 0;
@@ -1537,7 +1537,7 @@ static int sp_do_export_png(SPDocument *doc)
g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX);
return 1;
}
- dpi = (gdouble) width * PX_PER_IN / area.width();
+ dpi = (gdouble) width * Inkscape::Util::Quantity::convert(1, "in", "px") / area.width();
}
if (sp_export_height) {
@@ -1547,15 +1547,15 @@ static int sp_do_export_png(SPDocument *doc)
g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX);
return 1;
}
- dpi = (gdouble) height * PX_PER_IN / area.height();
+ dpi = (gdouble) height * Inkscape::Util::Quantity::convert(1, "in", "px") / area.height();
}
if (!sp_export_width) {
- width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5);
+ width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
}
if (!sp_export_height) {
- height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5);
+ height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
}
guint32 bgcolor = 0x00000000;
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index dc786f340..5976555f4 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -89,7 +89,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-item.h"
#include "box3d.h"
#include "persp3d.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "xml/simple-document.h"
#include "sp-filter-reference.h"
#include "gradient-drag.h"
@@ -3397,7 +3397,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
res = prefs_res;
} else if (0 < prefs_min) {
// If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it
- res = PX_PER_IN * prefs_min / MIN(bbox->width(), bbox->height());
+ res = Inkscape::Util::Quantity::convert(1, "in", "px") * prefs_min / MIN(bbox->width(), bbox->height());
} else {
float hint_xdpi = 0, hint_ydpi = 0;
Glib::ustring hint_filename;
@@ -3412,14 +3412,14 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
res = hint_xdpi;
} else {
// if all else fails, take the default 90 dpi
- res = PX_PER_IN;
+ res = Inkscape::Util::Quantity::convert(1, "in", "px");
}
}
}
// The width and height of the bitmap in pixels
- unsigned width = (unsigned) floor(bbox->width() * res / PX_PER_IN);
- unsigned height =(unsigned) floor(bbox->height() * res / PX_PER_IN);
+ unsigned width = (unsigned) floor(bbox->width() * res / Inkscape::Util::Quantity::convert(1, "in", "px"));
+ unsigned height =(unsigned) floor(bbox->height() * res / Inkscape::Util::Quantity::convert(1, "in", "px"));
// Find out if we have to run an external filter
gchar const *run = NULL;
@@ -3451,7 +3451,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
double shift_x = bbox->min()[Geom::X];
double shift_y = bbox->max()[Geom::Y];
- if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid
+ if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 90 dpi, snap it to pixel grid
shift_x = round(shift_x);
shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone
}
@@ -3484,7 +3484,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Create the repr for the image
Inkscape::XML::Node * repr = xml_doc->createElement("svg:image");
sp_embed_image(repr, pb, "image/png");
- if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid
+ if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 90 dpi, snap it to pixel grid
sp_repr_set_svg_double(repr, "width", width);
sp_repr_set_svg_double(repr, "height", height);
} else {
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index d84bbdc6c..9e0befcca 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -55,7 +55,6 @@
#include "sp-tspan.h"
#include "text-editing.h"
-#include "unit-constants.h"
/*#####################################################
# SPTEXT
diff --git a/src/style.cpp b/src/style.cpp
index 479f30597..f617973ca 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -45,7 +45,7 @@
#include "svg/css-ostringstream.h"
#include "xml/repr.h"
#include "xml/simple-document.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "macros.h"
#include "preferences.h"
@@ -2483,11 +2483,11 @@ sp_style_css_size_px_to_units(double size, int unit)
case SP_CSS_UNIT_NONE: unit_size = size; break;
case SP_CSS_UNIT_PX: unit_size = size; break;
- case SP_CSS_UNIT_PT: unit_size = size * PT_PER_PX; break;
- case SP_CSS_UNIT_PC: unit_size = size * (PT_PER_PX / PT_PER_PC); break;
- case SP_CSS_UNIT_MM: unit_size = size * MM_PER_PX; break;
- case SP_CSS_UNIT_CM: unit_size = size * CM_PER_PX; break;
- case SP_CSS_UNIT_IN: unit_size = size * IN_PER_PX; break;
+ case SP_CSS_UNIT_PT: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "pt"); break;
+ case SP_CSS_UNIT_PC: unit_size = size * (Inkscape::Util::Quantity::convert(1, "px", "pt") / Inkscape::Util::Quantity::convert(1, "pc", "pt")); break;
+ case SP_CSS_UNIT_MM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "mm"); break;
+ case SP_CSS_UNIT_CM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "cm"); break;
+ case SP_CSS_UNIT_IN: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "in"); break;
case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break;
case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break;
case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break;
@@ -3400,19 +3400,19 @@ sp_style_read_ilength(SPILength *val, gchar const *str)
} else if (!strcmp(e, "pt")) {
/* Userspace / DEVICESCALE */
val->unit = SP_CSS_UNIT_PT;
- val->computed = value * PX_PER_PT;
+ val->computed = value * Inkscape::Util::Quantity::convert(1, "pt", "px");
} else if (!strcmp(e, "pc")) {
val->unit = SP_CSS_UNIT_PC;
- val->computed = value * PX_PER_PC;
+ val->computed = value * Inkscape::Util::Quantity::convert(1, "pc", "px");
} else if (!strcmp(e, "mm")) {
val->unit = SP_CSS_UNIT_MM;
- val->computed = value * PX_PER_MM;
+ val->computed = value * Inkscape::Util::Quantity::convert(1, "mm", "px");
} else if (!strcmp(e, "cm")) {
val->unit = SP_CSS_UNIT_CM;
- val->computed = value * PX_PER_CM;
+ val->computed = value * Inkscape::Util::Quantity::convert(1, "cm", "px");
} else if (!strcmp(e, "in")) {
val->unit = SP_CSS_UNIT_IN;
- val->computed = value * PX_PER_IN;
+ val->computed = value * Inkscape::Util::Quantity::convert(1, "in", "px");
} else if (!strcmp(e, "em")) {
/* EM square */
val->unit = SP_CSS_UNIT_EM;
@@ -3971,23 +3971,23 @@ sp_style_write_ilength(gchar *p, gint const len, gchar const *const key,
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_PT:
- os << key << ":" << val->computed * PT_PER_PX << "pt;";
+ os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") << "pt;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_PC:
- os << key << ":" << val->computed * PT_PER_PX / 12.0 << "pc;";
+ os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") / 12.0 << "pc;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_MM:
- os << key << ":" << val->computed * MM_PER_PX << "mm;";
+ os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "mm") << "mm;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_CM:
- os << key << ":" << val->computed * CM_PER_PX << "cm;";
+ os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "cm") << "cm;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_IN:
- os << key << ":" << val->computed * IN_PER_PX << "in;";
+ os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "in") << "in;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_EM:
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index d2f4332d8..7f93f9f0f 100644
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
@@ -23,7 +23,7 @@
#include "svg.h"
#include "stringstream.h"
-#include "../unit-constants.h"
+#include "util/units.h"
static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next);
@@ -365,7 +365,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PT;
}
if (computed) {
- *computed = v * PX_PER_PT;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "pt", "px");
}
break;
case UVAL('p','c'):
@@ -373,7 +373,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PC;
}
if (computed) {
- *computed = v * PX_PER_PC;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "pc", "px");
}
break;
case UVAL('m','m'):
@@ -381,7 +381,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::MM;
}
if (computed) {
- *computed = v * PX_PER_MM;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "mm", "px");
}
break;
case UVAL('c','m'):
@@ -389,7 +389,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::CM;
}
if (computed) {
- *computed = v * PX_PER_CM;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "cm", "px");
}
break;
case UVAL('i','n'):
@@ -397,7 +397,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::INCH;
}
if (computed) {
- *computed = v * PX_PER_IN;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "in", "px");
}
break;
case UVAL('f','t'):
@@ -405,7 +405,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::FOOT;
}
if (computed) {
- *computed = v * PX_PER_FT;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "ft", "px");
}
break;
case UVAL('e','m'):
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 401f56bb2..0d30863d9 100644
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -24,7 +24,7 @@
#include "inkscape.h"
#include "message-stack.h"
#include "style.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "document.h"
#include "xml/repr.h"
@@ -1278,23 +1278,23 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_PT:
- style->line_height.computed += zby * PT_PER_PX;
+ style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "pt");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_PC:
- style->line_height.computed += zby * (PT_PER_PX / 12);
+ style->line_height.computed += zby * (Inkscape::Util::Quantity::convert(1, "px", "pt") / 12);
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_MM:
- style->line_height.computed += zby * MM_PER_PX;
+ style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "mm");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_CM:
- style->line_height.computed += zby * CM_PER_PX;
+ style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "cm");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_IN:
- style->line_height.computed += zby * IN_PER_PX;
+ style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "in");
style->line_height.value = style->line_height.computed;
break;
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 72ddd90a9..629960613 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -79,7 +79,7 @@
#include "text-editing.h"
#include "tools-switch.h"
#include "path-chemistry.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "helper/png-write.h"
#include "svg/svg-color.h"
#include "sp-namedview.h"
@@ -1078,14 +1078,14 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
try {
if (out == outlist.end() && target == "image/png")
{
- gdouble dpi = PX_PER_IN;
+ gdouble dpi = Inkscape::Util::Quantity::convert(1, "in", "px");
guint32 bgcolor = 0x00000000;
Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed);
Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions());
- unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5);
- unsigned long int height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5);
+ unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
+ unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
// read from namedview
Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview");
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 5cb9357c3..063902aa7 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -50,7 +50,6 @@
#include "ui/widget/unit-menu.h"
#include "util/units.h"
-#include "unit-constants.h"
#include "helper/window.h"
#include "inkscape-private.h"
#include "document.h"
@@ -98,7 +97,7 @@
#define SP_EXPORT_MIN_SIZE 1.0
-#define DPI_BASE PX_PER_IN
+#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px")
#define EXPORT_COORD_PRECISION 3
@@ -1048,8 +1047,8 @@ void Export::onExport ()
Geom::OptRect area = item->desktopVisualBounds();
if (area) {
- gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5);
- gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5);
+ gint width = (gint) (area->width() * dpi / DPI_BASE + 0.5);
+ gint height = (gint) (area->height() * dpi / DPI_BASE + 0.5);
if (width > 1 && height > 1) {
// Do export
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index bc648002d..7890b0b4c 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -28,7 +28,7 @@
#include "preferences.h"
#include "verbs.h"
#include "selcue.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include <iostream>
#include "enums.h"
#include "desktop-handles.h"
@@ -1428,10 +1428,10 @@ void InkscapePreferences::initPageBitmaps()
_("Automatically reload linked images when file is changed on disk"));
_misc_bitmap_editor.init("/options/bitmapeditor/value", true);
_page_bitmaps.add_line( false, _("_Bitmap editor:"), _misc_bitmap_editor, "", "", true);
- _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
+ _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Default export _resolution:"), _importexport_export_res, _("dpi"),
_("Default bitmap resolution (in dots per inch) in the Export dialog"), false);
- _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
+ _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Resolution for Create Bitmap _Copy:"), _bitmap_copy_res, _("dpi"),
_("Resolution used by the Create Bitmap Copy command"), false);
{
@@ -1443,7 +1443,7 @@ void InkscapePreferences::initPageBitmaps()
_bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false);
_page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false);
}
- _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
+ _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"),
_("Default bitmap resolution (in dots per inch) for bitmap import"), false);
_importexport_import_res_override.init(_("Override file resolution"), "/dialogs/import/forcexdpi", false);
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index 2ab8cf121..4c8c77f96 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -26,7 +26,7 @@
#include "ui/widget/rendering-options.h"
#include "document.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "helper/png-write.h"
#include "svg/svg-color.h"
#include "io/sys.h"
@@ -72,8 +72,8 @@ static void draw_page(
sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0,
width, height,
- (unsigned long)(width * dpi / PX_PER_IN),
- (unsigned long)(height * dpi / PX_PER_IN),
+ (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")),
+ (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")),
dpi, dpi, bgcolor, NULL, NULL, true, NULL);
// This doesn't seem to work:
@@ -90,7 +90,7 @@ static void draw_page(
cairo_t *cr = gtk_print_context_get_cairo_context (context);
cairo_matrix_t m;
cairo_get_matrix(cr, &m);
- cairo_scale(cr, PT_PER_IN / dpi, PT_PER_IN / dpi);
+ cairo_scale(cr, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi);
// FIXME: why is the origin offset??
cairo_set_source_surface(cr, png->cobj(), -16.0, -16.0);
cairo_paint(cr);
@@ -195,8 +195,8 @@ Print::Print(SPDocument *doc, SPItem *base) :
// set up paper size to match the document size
gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS);
GtkPageSetup *page_setup = gtk_page_setup_new();
- gdouble doc_width = _doc->getWidth() * PT_PER_PX;
- gdouble doc_height = _doc->getHeight() * PT_PER_PX;
+ gdouble doc_width = _doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ gdouble doc_height = _doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt");
GtkPaperSize *paper_size;
if (doc_width > doc_height) {
gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index a662495a0..4a25f723b 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -58,7 +58,7 @@ extern "C" {
#include "widgets/font-selector.h"
#include <glibmm/i18n.h>
#include <glibmm/markup.h>
-#include "unit-constants.h"
+#include "util/units.h"
#include "sp-textpath.h"
namespace Inkscape {
@@ -401,7 +401,7 @@ void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
- double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * PT_PER_PX;
+ double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt");
// Pango font size is in 1024ths of a point
// C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE );
diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp
index f26e71553..d6248df69 100644
--- a/src/ui/widget/rendering-options.cpp
+++ b/src/ui/widget/rendering-options.cpp
@@ -13,7 +13,7 @@
#endif
#include "rendering-options.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include <glibmm/i18n.h>
namespace Inkscape {
@@ -59,8 +59,8 @@ RenderingOptions::RenderingOptions () :
_radio_bitmap.signal_toggled().connect(sigc::mem_fun(*this, &RenderingOptions::_toggled));
// configure default DPI
- _dpi.setRange(PT_PER_IN,2400.0);
- _dpi.setValue(PT_PER_IN);
+ _dpi.setRange(Inkscape::Util::Quantity::convert(1, "in", "pt"),2400.0);
+ _dpi.setValue(Inkscape::Util::Quantity::convert(1, "in", "pt"));
_dpi.setIncrements(1.0,10.0);
_dpi.setDigits(0);
_dpi.update();
diff --git a/src/unit-constants.h b/src/unit-constants.h
deleted file mode 100644
index c56c0a6e8..000000000
--- a/src/unit-constants.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef INKSCAPE_UNIT_CONSTANTS_H
-#define INKSCAPE_UNIT_CONSTANTS_H
-
-// 72 points per inch divided by the SVG-recommended value of 90 pixels per inch for computer screen
-// For now it is constant throughout Inkscape, later we may make it changeable.
-// Ideally this should be the only place to change it, but this is not guaranteed (be careful!)
-#define DEVICESCALE 0.8
-
-#define PT_PER_IN 72.0
-#define PT_PER_PX DEVICESCALE
-#define PT_PER_PC 12.0
-#define PX_PER_PT (1/DEVICESCALE)
-#define PX_PER_PC (PX_PER_PT * PT_PER_PC)
-#define PX_PER_IN (PT_PER_IN / PT_PER_PX)
-#define PC_PER_IN (PT_PER_IN / PT_PER_PC)
-#define M_PER_IN 0.0254
-#define M_PER_PX (M_PER_IN / PX_PER_IN)
-#define CM_PER_IN 2.54
-#define MM_PER_IN 25.4
-#define MM_PER_MM 1.0
-#define MM_PER_CM 10.0
-#define MM_PER_M 1000.0
-#define IN_PER_PT (1 / PT_PER_IN)
-#define IN_PER_PX (1 / PX_PER_IN)
-#define IN_PER_CM (1 / CM_PER_IN)
-#define IN_PER_MM (1 / MM_PER_IN)
-#define IN_PER_FT 12.0
-#define FT_PER_IN (1 / IN_PER_FT)
-#define PT_PER_CM (PT_PER_IN / CM_PER_IN)
-#define PX_PER_CM (PX_PER_IN / CM_PER_IN)
-#define M_PER_PT (M_PER_IN / PT_PER_IN)
-#define PT_PER_M (PT_PER_IN / M_PER_IN)
-#define PX_PER_M (PX_PER_IN / M_PER_IN)
-#define CM_PER_PT (CM_PER_IN / PT_PER_IN)
-#define CM_PER_PX (CM_PER_IN / PX_PER_IN)
-#define MM_PER_PT (MM_PER_IN / PT_PER_IN)
-#define PT_PER_MM (PT_PER_IN / MM_PER_IN)
-#define PX_PER_MM (PX_PER_IN / MM_PER_IN)
-#define MM_PER_PX (MM_PER_IN / PX_PER_IN)
-#define PX_PER_FT (PX_PER_IN / FT_PER_IN)
-#define PT_PER_PT 1.0
-#define PC_PER_PC 1.0
-#define IN_PER_IN 1.0
-#define PX_PER_PX 1.0
-#define FT_PER_FT 1.0
-
-#endif /* !INKSCAPE_UNIT_CONSTANTS_H */
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 7fa848f1e..5f9098d44 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -33,7 +33,6 @@
#include "desktop.h"
#include "widgets/font-selector.h"
#include "preferences.h"
-#include "unit-constants.h"
/* SPFontSelector */