diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-03-13 08:49:02 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-03-13 08:49:02 +0000 |
| commit | c424d555260e3b5fae3260173c6bc51d6e4d6f84 (patch) | |
| tree | 5528d6d516bffe883bdba5870959227f38913c79 /src | |
| parent | update to trunk (diff) | |
| parent | Provide a toggle in the document properties to optionally turn off (diff) | |
| download | inkscape-c424d555260e3b5fae3260173c6bc51d6e4d6f84.tar.gz inkscape-c424d555260e3b5fae3260173c6bc51d6e4d6f84.zip | |
update to trunk
(bzr r11950.1.293)
Diffstat (limited to 'src')
| -rw-r--r-- | src/attributes.cpp | 1 | ||||
| -rw-r--r-- | src/attributes.h | 1 | ||||
| -rw-r--r-- | src/desktop.cpp | 2 | ||||
| -rw-r--r-- | src/display/drawing-group.cpp | 17 | ||||
| -rw-r--r-- | src/display/drawing-group.h | 2 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 1 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-parser.cpp | 5 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/svg-builder.cpp | 73 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/svg-builder.h | 2 | ||||
| -rw-r--r-- | src/filters/image.cpp | 7 | ||||
| -rw-r--r-- | src/filters/image.h | 1 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 6 | ||||
| -rw-r--r-- | src/sp-namedview.h | 1 | ||||
| -rw-r--r-- | src/sp-root.cpp | 10 | ||||
| -rw-r--r-- | src/sp-root.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/document-properties.cpp | 19 | ||||
| -rw-r--r-- | src/ui/dialog/document-properties.h | 1 |
17 files changed, 95 insertions, 56 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp index ee2a80fd3..1c62ea841 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -117,6 +117,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"}, {SP_ATTR_UNITS, "units"}, {SP_ATTR_INKSCAPE_CONNECTOR_SPACING, "inkscape:connector-spacing"}, + {SP_ATTR_INKSCAPE_ANTIALIASING, "inkscape:antialiasing"}, /* SPColorProfile */ {SP_ATTR_LOCAL, "local"}, {SP_ATTR_NAME, "name"}, diff --git a/src/attributes.h b/src/attributes.h index b8843fcb7..530c9d11a 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -118,6 +118,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_DOCUMENT_UNITS, SP_ATTR_UNITS, SP_ATTR_INKSCAPE_CONNECTOR_SPACING, + SP_ATTR_INKSCAPE_ANTIALIASING, /* SPColorProfile */ SP_ATTR_LOCAL, SP_ATTR_NAME, diff --git a/src/desktop.cpp b/src/desktop.cpp index a02baeac8..234831e69 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1736,6 +1736,8 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) if (flags & SP_OBJECT_MODIFIED_FLAG) { + desktop->getDocument()->getRoot()->setAntialiasing(nv->antialiasing); + /* Show/hide page background */ if (nv->pagecolor | (0xff != 0xffffffff)) { sp_canvas_item_show (desktop->table); diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 38ace001f..c03e0f3ba 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -22,6 +22,7 @@ DrawingGroup::DrawingGroup(Drawing &drawing) : DrawingItem(drawing) , _style(NULL) , _child_transform(NULL) + , _uses_antialiasing(true) {} DrawingGroup::~DrawingGroup() @@ -47,6 +48,15 @@ DrawingGroup::setStyle(SPStyle *style) _setStyleCommon(_style, style); } +void +DrawingGroup::setAntialiasing(bool a) +{ + if (_uses_antialiasing != a) { + _uses_antialiasing = a; + _markForUpdate(STATE_ALL, true); + } +} + /** * Set additional transform for the group. * This is applied after the normal transform and mainly useful for @@ -100,6 +110,13 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { + DrawingContext::Save aa_save; + + if (!_uses_antialiasing) { + aa_save.save(dc); + cairo_set_antialias(dc.raw(), CAIRO_ANTIALIAS_NONE); + } + if (stop_at == NULL) { // normal rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 651e9d8af..c7f1c70ce 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -30,6 +30,7 @@ public: void setStyle(SPStyle *style); void setChildTransform(Geom::Affine const &new_trans); + void setAntialiasing(bool a); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -42,6 +43,7 @@ protected: SPStyle *_style; Geom::Affine *_child_transform; + bool _uses_antialiasing; }; bool is_drawing_group(DrawingItem *item); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c502daf64..6d903867b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -35,7 +35,6 @@ #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" -#include "sp-namedview.h" using Inkscape::Debug::GdkEventLatencyTracker; diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 7edb758fd..30e120d26 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -718,10 +718,7 @@ void PdfParser::opSetMiterLimit(Object args[], int /*numArgs*/) // TODO not good that numArgs is ignored but args[] is used: void PdfParser::opSetLineWidth(Object args[], int /*numArgs*/) { - if (args[0].getNum() > 0.0) - state->setLineWidth(args[0].getNum()); - else - state->setLineWidth(1.0); // default + state->setLineWidth(args[0].getNum()); builder->updateStyle(state); } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 20cd74cdb..71e6dc6ae 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -56,9 +56,6 @@ namespace Internal { #define TRACE(_args) IFTRACE(g_print _args) -static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix -static bool ttm_is_set = false; // flag to forbid setting ttm - /** * \struct SvgTransparencyGroup * \brief Holds information about a PDF transparency group @@ -94,6 +91,9 @@ SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) _preferences = _xml_doc->createElement("svgbuilder:prefs"); _preferences->setAttribute("embedImages", "1"); _preferences->setAttribute("localFonts", "1"); + + _ttm[0] = 1; _ttm[1] = 0; _ttm[2] = 0; _ttm[3] = 1; _ttm[4] = 0; _ttm[5] = 0; + _ttm_is_set = false; } SvgBuilder::SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root) { @@ -216,9 +216,9 @@ Inkscape::XML::Node *SvgBuilder::pushGroup() { } } if (_container->parent()->attribute("inkscape:groupmode") != NULL) { - ttm[0] = ttm[3] = 1.0; // clear ttm if parent is a layer - ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0; - ttm_is_set = false; + _ttm[0] = _ttm[3] = 1.0; // clear ttm if parent is a layer + _ttm[1] = _ttm[2] = _ttm[4] = _ttm[5] = 0.0; + _ttm_is_set = false; } return _container; } @@ -298,14 +298,6 @@ static gchar *svgInterpretPath(GfxPath *path) { * Uses the given SPCSSAttr for storing the style properties */ void SvgBuilder::_setStrokeStyle(SPCSSAttr *css, GfxState *state) { - - // Check line width - if ( state->getLineWidth() <= 0.0 ) { - // Ignore stroke - sp_repr_css_set_property(css, "stroke", "none"); - return; - } - // Stroke color/pattern if ( state->getStrokeColorSpace()->getMode() == csPattern ) { gchar *urltext = _createPattern(state->getStrokePattern(), state, true); @@ -326,7 +318,14 @@ void SvgBuilder::_setStrokeStyle(SPCSSAttr *css, GfxState *state) { // Line width Inkscape::CSSOStringStream os_width; - os_width << state->getLineWidth(); + double lw = state->getLineWidth(); + if (lw > 0.0) { + os_width << lw; + } else { + // emit a stroke which is 1px in toplevel user units + double pxw = Inkscape::Util::Quantity::convert(1.0, "pt", "px"); + os_width << 1.0 / state->transformWidth(pxw); + } sp_repr_css_set_property(css, "stroke-width", os_width.str().c_str()); // Line cap @@ -570,14 +569,14 @@ bool SvgBuilder::getTransform(double *transform) { void SvgBuilder::setTransform(double c0, double c1, double c2, double c3, double c4, double c5) { // do not remember the group which is a layer - if ((_container->attribute("inkscape:groupmode") == NULL) && !ttm_is_set) { - ttm[0] = c0; - ttm[1] = c1; - ttm[2] = c2; - ttm[3] = c3; - ttm[4] = c4; - ttm[5] = c5; - ttm_is_set = true; + if ((_container->attribute("inkscape:groupmode") == NULL) && !_ttm_is_set) { + _ttm[0] = c0; + _ttm[1] = c1; + _ttm[2] = c2; + _ttm[3] = c3; + _ttm[4] = c4; + _ttm[5] = c5; + _ttm_is_set = true; } // Avoid transforming a group with an already set clip-path @@ -633,15 +632,15 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_ // construct a (pattern space) -> (current space) transform matrix ptm = shading_pattern->getMatrix(); - det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; + det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; if (det) { double ittm[6]; // invert ttm - ittm[0] = ttm[3] / det; - ittm[1] = -ttm[1] / det; - ittm[2] = -ttm[2] / det; - ittm[3] = ttm[0] / det; - ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; - ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + ittm[0] = _ttm[3] / det; + ittm[1] = -_ttm[1] / det; + ittm[2] = -_ttm[2] / det; + ittm[3] = _ttm[0] / det; + ittm[4] = (_ttm[2] * _ttm[5] - _ttm[3] * _ttm[4]) / det; + ittm[5] = (_ttm[1] * _ttm[4] - _ttm[0] * _ttm[5]) / det; m[0] = ptm[0] * ittm[0] + ptm[1] * ittm[2]; m[1] = ptm[0] * ittm[1] + ptm[1] * ittm[3]; m[2] = ptm[2] * ittm[0] + ptm[3] * ittm[2]; @@ -676,15 +675,15 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, double *p2u = tiling_pattern->getMatrix(); double m[6] = {1, 0, 0, 1, 0, 0}; double det; - det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; // see LP Bug 1168908 + det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; // see LP Bug 1168908 if (det) { double ittm[6]; // invert ttm - ittm[0] = ttm[3] / det; - ittm[1] = -ttm[1] / det; - ittm[2] = -ttm[2] / det; - ittm[3] = ttm[0] / det; - ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; - ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + ittm[0] = _ttm[3] / det; + ittm[1] = -_ttm[1] / det; + ittm[2] = -_ttm[2] / det; + ittm[3] = _ttm[0] / det; + ittm[4] = (_ttm[2] * _ttm[5] - _ttm[3] * _ttm[4]) / det; + ittm[5] = (_ttm[1] * _ttm[4] - _ttm[0] * _ttm[5]) / det; m[0] = p2u[0] * ittm[0] + p2u[1] * ittm[2]; m[1] = p2u[0] * ittm[1] + p2u[1] * ittm[3]; m[2] = p2u[2] * ittm[0] + p2u[3] * ittm[2]; diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 610822959..f1ce02cf0 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -223,6 +223,8 @@ private: Inkscape::XML::Node *_preferences; // Preferences container node double _width; // Document size in px double _height; // Document size in px + double _ttm[6]; ///< temporary transform matrix + bool _ttm_is_set; }; diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 6e50a0e3c..116939e0f 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -42,7 +42,6 @@ namespace { } SPFeImage::SPFeImage() : SPFilterPrimitive() { - this->document = NULL; this->href = NULL; this->from_element = 0; this->SVGElemRef = NULL; @@ -60,10 +59,8 @@ SPFeImage::~SPFeImage() { * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void SPFeImage::build(SPDocument *document, Inkscape::XML::Node *repr) { - // Save document reference so we can load images with relative paths. - this->document = document; - +void SPFeImage::build(SPDocument *document, Inkscape::XML::Node *repr) +{ SPFilterPrimitive::build(document, repr); /*LOAD ATTRIBUTES FROM REPR HERE*/ diff --git a/src/filters/image.h b/src/filters/image.h index 452e08134..9299f259e 100644 --- a/src/filters/image.h +++ b/src/filters/image.h @@ -32,7 +32,6 @@ public: unsigned int aspect_align : 4; unsigned int aspect_clip : 1; - SPDocument *document; bool from_element; SPItem* SVGElem; Inkscape::URIReference* SVGElemRef; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index a01ba891e..03c124117 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -90,6 +90,7 @@ SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->grids_visible = false; this->showborder = TRUE; this->showpageshadow = TRUE; + this->antialiasing = TRUE; this->guides = NULL; this->viewcount = 0; @@ -248,6 +249,7 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:snap-page" ); this->readAttr( "inkscape:current-layer" ); this->readAttr( "inkscape:connector-spacing" ); + this->readAttr( "inkscape:antialiasing" ); /* Construct guideline list */ for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { @@ -603,6 +605,10 @@ void SPNamedView::set(unsigned int key, const gchar* value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } + case SP_ATTR_INKSCAPE_ANTIALIASING: + this->antialiasing = value ? sp_str_to_bool(value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; default: SPObjectGroup::set(key, value); break; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 05cbcc398..b6e32206e 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -44,6 +44,7 @@ public: unsigned int showborder : 1; unsigned int showpageshadow : 1; unsigned int borderlayer : 2; + unsigned int antialiasing : 1; double zoom; double cx; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 12570e03e..12ac1bad4 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -25,6 +25,7 @@ #include "document.h" #include "inkscape-version.h" #include "sp-defs.h" +#include "sp-namedview.h" #include "sp-root.h" #include "display/drawing-group.h" #include "svg/stringstream.h" @@ -307,6 +308,7 @@ void SPRoot::update(SPCtx *ctx, guint flags) for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); g->setChildTransform(this->c2p); + g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } } @@ -373,6 +375,7 @@ Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key if (ai) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); g->setChildTransform(this->c2p); + g->setAntialiasing(sp_document_namedview(this->document, NULL)->antialiasing); } return ai; @@ -391,6 +394,13 @@ const char *SPRoot::displayName() const { return "SVG"; // Do not translate } +void SPRoot::setAntialiasing(bool s) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); + g->setAntialiasing(s); + } +} + /* Local Variables: mode:c++ diff --git a/src/sp-root.h b/src/sp-root.h index a25e8030c..a1954c42f 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -50,6 +50,8 @@ public: */ SPDefs *defs; + void setAntialiasing(bool a); + virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, gchar const* value); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0411c789c..ef7c9ee1d 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -106,6 +106,7 @@ DocumentProperties::DocumentProperties() _page_metadata1(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), _page_metadata2(Gtk::manage(new UI::Widget::NotebookPage(1, 1))), //--------------------------------------------------------------- + _rcb_antialias(_("Use antialiasing"), _("If unset, no antialiasing will be done on the drawing"), "inkscape:antialiasing", _wr, false), _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), _rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false), @@ -239,7 +240,8 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con yoptions = Gtk::FILL|Gtk::EXPAND; } if (docum_prop_flag) { - if( i==(n-4) || i==(n-6) ) { + // this sets the padding for subordinate widgets on the "Page" page + if( i==(n-8) || i==(n-10) ) { #if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); arr[i+1]->set_margin_left(20); @@ -316,28 +318,28 @@ void DocumentProperties::build_page() Gtk::Label* label_gen = manage (new Gtk::Label); label_gen->set_markup (_("<b>General</b>")); - Gtk::Label* label_col = manage (new Gtk::Label); - label_col->set_markup (_("<b>Color</b>")); - Gtk::Label* label_bor = manage (new Gtk::Label); - label_bor->set_markup (_("<b>Border</b>")); Gtk::Label *label_for = manage (new Gtk::Label); label_for->set_markup (_("<b>Page Size</b>")); + Gtk::Label* label_dsp = manage (new Gtk::Label); + label_dsp->set_markup (_("<b>Display</b>")); _page_sizer.init(); Gtk::Widget *const widget_array[] = { label_gen, 0, 0, &_rum_deflt, - label_col, 0, - _rcp_bg._label, &_rcp_bg, + //label_col, 0, + //_rcp_bg._label, &_rcp_bg, 0, 0, label_for, 0, 0, &_page_sizer, 0, 0, - label_bor, 0, + label_dsp, 0, 0, &_rcb_canb, 0, &_rcb_bord, 0, &_rcb_shad, + 0, &_rcb_antialias, + _rcp_bg._label, &_rcp_bg, _rcp_bord._label, &_rcp_bord, }; @@ -1472,6 +1474,7 @@ void DocumentProperties::update() _rcb_bord.setActive (nv->borderlayer == SP_BORDER_LAYER_TOP); _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); + _rcb_antialias.setActive(nv->antialiasing); if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index e3ca91731..495f3177d 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -117,6 +117,7 @@ protected: UI::Widget::Registry _wr; //--------------------------------------------------------------- + UI::Widget::RegisteredCheckButton _rcb_antialias; UI::Widget::RegisteredCheckButton _rcb_canb; UI::Widget::RegisteredCheckButton _rcb_bord; UI::Widget::RegisteredCheckButton _rcb_shad; |
