From 7605490d79cf0244db020654aa23610b2a0d83ea Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Sat, 21 Mar 2015 03:42:18 -0700 Subject: sp. fix seperate (bzr r14021) --- src/svg-profile.h | 2 +- src/ui/dialog/filter-effects-dialog.cpp | 2 +- src/uri-references.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/svg-profile.h b/src/svg-profile.h index 9d221fc76..8945ee313 100644 --- a/src/svg-profile.h +++ b/src/svg-profile.h @@ -74,7 +74,7 @@ public: SVG_PRINT_1_1, /**< */ - PROFILE_UNIQUE_CNT, /**< A marker to seperate between the entires + PROFILE_UNIQUE_CNT, /**< A marker to separate between the entires that are unique, and those which are aggregates of them. */ diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 3da0e0043..077c6f5ca 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -211,7 +211,7 @@ private: ComboBoxEnum* combo; }; -// Contains an arbitrary number of spin buttons that use seperate attributes +// Contains an arbitrary number of spin buttons that use separate attributes class MultiSpinButton : public Gtk::HBox { public: diff --git a/src/uri-references.cpp b/src/uri-references.cpp index b23bed74a..2518c173e 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -65,7 +65,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) skip = true; } - // The path contains references to seperate document files to load. + // The path contains references to separate document files to load. if(document && uri.getPath() && !skip ) { std::string base = document->getBase() ? document->getBase() : ""; std::string path = uri.getFullPath(base); -- cgit v1.2.3 From 034b578ef602f2095374800a8c967b1b6e5c21dd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 21 Mar 2015 12:41:01 +0100 Subject: Add GUI for 'viewBox'. (bzr r14022) --- src/document.cpp | 11 +++ src/document.h | 1 + src/ui/widget/page-sizer.cpp | 169 +++++++++++++++++++++++++++++++++++++------ src/ui/widget/page-sizer.h | 21 ++++++ 4 files changed, 180 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 62e2f5b46..1c6bb76de 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -764,6 +764,17 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height, bool changeSi root->updateRepr(); } +Geom::Rect SPDocument::getViewBox() const +{ + Geom::Rect viewBox; + if (root->viewBox_set) { + viewBox = root->viewBox; + } else { + viewBox = Geom::Rect::from_xywh( 0, 0, getWidth().value("px"), getHeight().value("px")); + } + return viewBox; +} + void SPDocument::setViewBox(const Geom::Rect &viewBox) { root->viewBox_set = true; diff --git a/src/document.h b/src/document.h index ed19d123b..74dcfa75e 100644 --- a/src/document.h +++ b/src/document.h @@ -247,6 +247,7 @@ public: Geom::Scale getDocumentScale() const; Inkscape::Util::Quantity getWidth() const; Inkscape::Util::Quantity getHeight() const; + Geom::Rect getViewBox() const; Geom::Point getDimensions() const; Geom::OptRect preferredBounds() const; void setWidthAndHeight(const Inkscape::Util::Quantity &width, const Inkscape::Util::Quantity &height, bool changeSize=true); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 8e647ebb4..8c86daea0 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -242,7 +242,13 @@ PageSizer::PageSizer(Registry & _wr) _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr), _lockMarginUpdate(false), _scaleX(_("Scale _x:"), _("Scale X"), "scale-x", _wr), + _scaleY(_("Scale _y:"), _("Scale Y"), "scale-y", _wr), _lockScaleUpdate(false), + _viewboxX(_("X:"), _("X"), "viewbox-x", _wr), + _viewboxY(_("Y:"), _("Y"), "viewbox-y", _wr), + _viewboxW(_("Width:"), _("Width"), "viewbox-width", _wr), + _viewboxH(_("Height:"), _("Height"), "viewbox-height", _wr), + _lockViewboxUpdate(false), _widgetRegistry(&_wr) { // set precision of scalar entry boxes @@ -254,7 +260,21 @@ PageSizer::PageSizer(Registry & _wr) _marginRight.setDigits(5); _marginBottom.setDigits(5); _scaleX.setDigits(5); + _scaleY.setDigits(5); + _viewboxX.setDigits(2); + _viewboxY.setDigits(2); + _viewboxW.setDigits(2); + _viewboxH.setDigits(2); + _scaleX.setRange( 0.00001, 100000 ); + _scaleY.setRange( 0.00001, 100000 ); + _viewboxX.setRange( -100000, 100000 ); + _viewboxY.setRange( -100000, 100000 ); + _viewboxW.setRange( 0, 200000 ); + _viewboxH.setRange( 0, 200000 ); + + _scaleY.set_sensitive (false); // We only want to display Y scale. + _wr.setUpdating (false); //# Set up the Paper Size combo box @@ -435,21 +455,62 @@ PageSizer::PageSizer(Registry & _wr) _scaleTable.set_row_spacing(4); _scaleTable.set_column_spacing(4); - _dimensionWidth.set_hexpand(); - _dimensionWidth.set_vexpand(); _scaleTable.attach(_scaleX, 0, 0, 1, 1); + _scaleTable.attach(_scaleY, 1, 0, 1, 1); - _dimensionUnits.set_hexpand(); - _dimensionUnits.set_vexpand(); - _scaleTable.attach(_scaleLabel, 1, 0, 1, 1); + _scaleTable.attach(_scaleLabel, 2, 0, 1, 1); + _scaleTable.attach(_scaleWarning, 0, 1, 2, 1); + _viewboxExpander.set_hexpand(); + _viewboxExpander.set_vexpand(); + _scaleTable.attach(_viewboxExpander, 0, 2, 2, 1); #else - _scaleTable.resize(2, 1); + _scaleTable.resize(3, 2); _scaleTable.set_row_spacings(4); _scaleTable.set_col_spacings(4); _scaleTable.attach(_scaleX, 0,1, 0,1); - _scaleTable.attach(_scaleLabel, 1,2, 0,1); + _scaleTable.attach(_scaleY, 1,2, 0,1); + _scaleTable.attach(_scaleLabel, 2,3, 0,1); + _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL); + _scaleTable.attach(_viewboxExpander, 0,3, 2,3); #endif + _scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly.")); + _scaleWarning.set_line_wrap( true ); + + _viewboxExpander.set_use_underline(); + _viewboxExpander.set_label(_("_Viewbox...")); + _viewboxExpander.add(_viewboxTable); + +#if WITH_GTKMM_3_0 + _viewboxTable.set_row_spacing(2); + _viewboxTable.set_column_spacing(2); + + _viewboxX.set_hexpand(); + _viewboxX.set_vexpand(); + _viewboxTable.attach(_viewboxX, 0, 0, 1, 1); + + _viewboxY.set_hexpand(); + _viewboxY.set_vexpand(); + _viewboxTable.attach(_viewboxY, 1, 0, 1, 1); + + _viewboxW.set_hexpand(); + _viewboxW.set_vexpand(); + _viewboxTable.attach(_viewbox, 0, 1, 1, 1); + + _viewboxH.set_hexpand(); + _viewboxH.set_vexpand(); + _viewboxTable.attach(_viewboxH, 1, 1, 1, 1); + +#else + _viewboxTable.set_border_width(4); + _viewboxTable.set_row_spacings(2); + _viewboxTable.set_col_spacings(2); + _viewboxTable.attach(_viewboxX, 0,1, 0,1); + _viewboxTable.attach(_viewboxY, 1,2, 0,1); + _viewboxTable.attach(_viewboxW, 0,1, 1,2); + _viewboxTable.attach(_viewboxH, 1,2, 1,2); +#endif + _wr.setUpdating (true); updateScaleUI(); _wr.setUpdating (false); @@ -478,7 +539,11 @@ PageSizer::init () _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed)); _changedu_connection = _dimensionUnits.getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &PageSizer::on_units_changed)); _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing)); - _changeds_connection = _scaleX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_scale_changed)); + _changeds_connection = _scaleX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_scale_changed)); + _changedvx_connection = _viewboxX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); show_all_children(); } @@ -744,10 +809,6 @@ void PageSizer::updateScaleUI() { - if (_lockScaleUpdate) { - return; - } - static bool _called = false; if (_called) { return; @@ -756,28 +817,56 @@ PageSizer::updateScaleUI() _called = true; _changeds_connection.block(); + _changedvx_connection.block(); + _changedvy_connection.block(); + _changedvw_connection.block(); + _changedvh_connection.block(); SPDesktop *dt = SP_ACTIVE_DESKTOP; if (dt) { SPDocument *doc = dt->getDocument(); + + // Update scale Geom::Scale scale = doc->getDocumentScale(); - SPNamedView *nv = dt->getNamedView(); std::stringstream ss; ss << _("User units per ") << nv->display_units->abbr << "." ; _scaleLabel.set_text( ss.str() ); - double scaleX_inv = - Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units ); - if( scaleX_inv > 0 ) { - _scaleX.setValue(1.0/scaleX_inv); - } else { - // Should never happen - std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleX_inv << std::endl; - _scaleX.setValue(1.0); + if( !_lockScaleUpdate ) { + + double scaleX_inv = + Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units ); + if( scaleX_inv > 0 ) { + _scaleX.setValue(1.0/scaleX_inv); + } else { + // Should never happen + std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleX_inv << std::endl; + _scaleX.setValue(1.0); + } + } + + { // Don't need to lock as scaleY widget not linked to callback. + double scaleY_inv = + Inkscape::Util::Quantity::convert( scale[Geom::Y], "px", nv->display_units ); + if( scaleY_inv > 0 ) { + _scaleY.setValue(1.0/scaleY_inv); + } else { + // Should never happen + std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleY_inv << std::endl; + _scaleY.setValue(1.0); + } } + if( !_lockViewboxUpdate ) { + Geom::Rect viewBox = doc->getViewBox(); + _viewboxX.setValue( viewBox.min()[Geom::X] ); + _viewboxY.setValue( viewBox.min()[Geom::Y] ); + _viewboxW.setValue( viewBox.width() ); + _viewboxH.setValue( viewBox.height() ); + } + } else { // Should never happen std::cerr << "PageSizer::updateScaleUI(): No active desktop." << std::endl; @@ -785,6 +874,10 @@ PageSizer::updateScaleUI() } _changeds_connection.unblock(); + _changedvx_connection.unblock(); + _changedvy_connection.unblock(); + _changedvw_connection.unblock(); + _changedvh_connection.unblock(); _called = false; } @@ -801,6 +894,7 @@ PageSizer::on_value_changed() setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); } + void PageSizer::on_units_changed() { @@ -830,13 +924,44 @@ PageSizer::on_scale_changed() double scaleX_inv = Inkscape::Util::Quantity(1.0/value, nv->display_units ).value("px"); _lockScaleUpdate = true; - doc->setDocumentScale( 1.0/scaleX_inv ); + doc->setDocumentScale( 1.0/scaleX_inv ); + updateScaleUI(); _lockScaleUpdate = false; DocumentUndo::done(doc, SP_VERB_NONE, _("Set page scale")); } } } +/** + * Callback for viewbox widgets + */ +void +PageSizer::on_viewbox_changed() +{ + if (_widgetRegistry->isUpdating()) return; + + double viewboxX = _viewboxX.getValue(); + double viewboxY = _viewboxY.getValue(); + double viewboxW = _viewboxW.getValue(); + double viewboxH = _viewboxH.getValue(); + + if( viewboxW > 0 && viewboxH > 0) { + SPDesktop *dt = SP_ACTIVE_DESKTOP; + if (dt) { + SPDocument *doc = dt->getDocument(); + _lockViewboxUpdate = true; + doc->setViewBox( Geom::Rect::from_xywh( viewboxX, viewboxY, viewboxW, viewboxH ) ); + updateScaleUI(); + _lockViewboxUpdate = false; + DocumentUndo::done(doc, SP_VERB_NONE, _("Set 'viewBox'")); + } + } else { + std::cerr + << "PageSizer::on_viewbox_changed(): width and height must both be greater than zero." + << std::endl; + } +} + } // namespace Widget } // namespace UI } // namespace Inkscape diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index f9a72d9f3..0eea28e61 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -264,17 +264,38 @@ protected: #endif Gtk::Label _scaleLabel; + Gtk::Label _scaleWarning; RegisteredScalar _scaleX; + RegisteredScalar _scaleY; bool _lockScaleUpdate; + // Viewbox + Gtk::Expander _viewboxExpander; +#if WITH_GTKMM_3_0 + Gtk::Grid _viewboxTable; +#else + Gtk::Table _viewboxTable; +#endif + + RegisteredScalar _viewboxX; + RegisteredScalar _viewboxY; + RegisteredScalar _viewboxW; + RegisteredScalar _viewboxH; + bool _lockViewboxUpdate; + //callback void on_value_changed(); void on_units_changed(); void on_scale_changed(); + void on_viewbox_changed(); sigc::connection _changedw_connection; sigc::connection _changedh_connection; sigc::connection _changedu_connection; sigc::connection _changeds_connection; + sigc::connection _changedvx_connection; + sigc::connection _changedvy_connection; + sigc::connection _changedvw_connection; + sigc::connection _changedvh_connection; Registry *_widgetRegistry; -- cgit v1.2.3 From ae1bd880cb7f913509b1b0e2de1fa4aa7e430d15 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 21 Mar 2015 12:45:38 +0100 Subject: Improve the cache system of bspline, "Correctly" show bspline weight power on nodes and handles (bzr r14023) --- src/ui/tool/curve-drag-point.cpp | 4 ++-- src/ui/tool/node.cpp | 15 ++++++++------- src/ui/tool/path-manipulator.cpp | 21 +++++++++++++++++---- src/ui/tool/path-manipulator.h | 2 +- 4 files changed, 28 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index 49c949107..a90dfb155 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -54,7 +54,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; // only update the nodes if the mode is bspline - if(!_pm.isBSpline(false)){ + if(!_pm.isBSpline()){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); } @@ -91,7 +91,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; //modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed - if(!_pm.isBSpline(false)){ + if(!_pm.isBSpline()){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); }else if(weight>=0.8){ diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index eeea47e4d..08cc6708d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -192,7 +192,7 @@ void Handle::move(Geom::Point const &new_pos) setRelativePos(new_delta); //move the handler and its oposite the same proportion - if(_pm().isBSpline()){ + if(_pm().isBSpline()){ setPosition(_pm().BSplineHandleReposition(this,this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this)); } @@ -222,7 +222,6 @@ void Handle::move(Geom::Point const &new_pos) setPosition(_pm().BSplineHandleReposition(this,this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this)); } - } void Handle::setPosition(Geom::Point const &p) @@ -382,7 +381,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) std::vector unselected; //if the snap adjustment is activated and it is not bspline - if (snap && !_pm().isBSpline(false)) { + if (snap && !_pm().isBSpline()) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -486,7 +485,7 @@ Glib::ustring Handle::_getTip(unsigned state) const char const *more; // a trick to mark as bspline if the node has no strength, we are going to use it later // to show the appropiate messages. We cannot do it in any different way becasue the function is constant - + Handle *h = const_cast(this); bool isBSpline = _pm().isBSpline(); bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate(); if (can_shift_rotate && !isBSpline) { @@ -550,7 +549,7 @@ Glib::ustring Handle::_getTip(unsigned state) const "Auto node handle: drag to convert to smooth node (%s)"), more); }else{ return format_tip(C_("Path handle tip", - "BSpline node handle: Shift to drag, double click to reset (%s)"), more); + "BSpline node handle: Shift to drag, double click to reset (%s). %g power"),more,_pm().BSplineHandlePosition(h,NULL)); } } } @@ -1435,6 +1434,8 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { bool isBSpline = _pm().isBSpline(); + Handle *h = const_cast(&_front); + Handle *h2 = const_cast(&_back); if (state_held_shift(state)) { bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate()); if (can_drag_out) { @@ -1469,7 +1470,7 @@ Glib::ustring Node::_getTip(unsigned state) const "%s: drag to shape the path (more: Shift, Ctrl, Alt)"), nodetype); }else if(_selection.size() == 1){ return format_tip(C_("Path node tip", - "BSpline node: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),noPower/*this->bsplineWeight*/); + "BSpline node: drag to shape the path (more: Shift, Ctrl, Alt). %g power"),_pm().BSplineHandlePosition(h,h2)); } return format_tip(C_("Path node tip", "%s: drag to shape the path, click to toggle scale/rotation handles (more: Shift, Ctrl, Alt)"), nodetype); @@ -1479,7 +1480,7 @@ Glib::ustring Node::_getTip(unsigned state) const "%s: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype); }else{ return format_tip(C_("Path node tip", - "BSpline node: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)")); + "BSpline node: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt). %g power"),_pm().BSplineHandlePosition(h,h2)); } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index dbcde240a..8b735f3e6 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1240,17 +1240,29 @@ int PathManipulator::BSplineGetSteps() const { // determines if the trace has bspline effect bool PathManipulator::isBSpline(bool recalculate){ if(recalculate){ - _is_bspline = this->BSplineGetSteps() > 0; + SPLPEItem * path = dynamic_cast(_path); + if (path){ + if(path->hasPathEffect()){ + Inkscape::LivePathEffect::Effect const *thisEffect = path->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); + if(thisEffect){ + _is_bspline = true; + return _is_bspline; + } + } + } + } + _is_bspline = false; return _is_bspline; } bool PathManipulator::isBSpline() const { - return BSplineGetSteps() > 0; + return _is_bspline; } // returns the corresponding strength to the position of the handlers -double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ +double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2) +{ using Geom::X; using Geom::Y; if(h2){ @@ -1275,7 +1287,8 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ } // give the location for the handler in the corresponding position -Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2){ +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2) +{ double pos = this->BSplineHandlePosition(h, h2); return BSplineHandleReposition(h,pos); } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 4d2bf4300..4badec569 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -107,7 +107,7 @@ private: void _createControlPointsFromGeometry(); - bool isBSpline(bool recalculate = false); + bool isBSpline(bool recalculate); bool isBSpline() const; double BSplineHandlePosition(Handle *h, Handle *h2 = NULL); Geom::Point BSplineHandleReposition(Handle *h, Handle *h2 = NULL); -- cgit v1.2.3