18#include <glibmm/i18n.h>
21namespace LivePathEffect {
40 mark_distance(_(
"_Mark distance:"), _(
"Distance between successive ruler marks"),
"mark_distance", &wr, this, 20.0),
41 unit(_(
"Unit:"), _(
"Unit"),
"unit", &wr, this),
42 mark_length(_(
"Ma_jor length:"), _(
"Length of major ruler marks"),
"mark_length", &wr, this, 14.0),
43 minor_mark_length(_(
"Mino_r length:"), _(
"Length of minor ruler marks"),
"minor_mark_length", &wr, this, 7.0),
44 minor_mark_gap(_(
"Minor mark _gap:"),
46 _(
"Space between path and minor ruler mark, % of mark length"),
47 "minor_mark_gap", &wr, this, 0.0),
48 major_mark_gap(_(
"Major mar_k gap:"),
50 _(
"Space between path and major ruler mark, % of mark length"),
51 "major_mark_gap", &wr, this, 0.0),
52 major_mark_steps(_(
"Major steps_:"), _(
"Draw a major mark every ... steps"),
"major_mark_steps", &wr, this, 5),
53 mark_angle(_(
"Mark angle:"), _(
"Rotate marks (-180° to 180°)"),
"mark_angle", &wr, this, 0.0),
54 shift(_(
"Shift marks _by:"), _(
"Shift marks by this many steps"),
"shift", &wr, this, 0),
55 mark_dir(_(
"Mark direction:"), _(
"Direction of marks (when viewing along the path from start to end)"),
"mark_dir",
MarkDirTypeConverter, &wr, this,
MARKDIR_LEFT),
56 offset(_(
"_Offset:"), _(
"Offset of first mark"),
"offset", &wr, this, 0.0),
115 n_major = real_mark_length * n;
116 n_minor = real_minor_mark_length * n;
130 if (real_mark_length && real_minor_mark_length && real_mark_length < real_minor_mark_length) {
131 factor = real_mark_length/real_minor_mark_length;
138 if (real_mark_length && real_minor_mark_length && real_mark_length > real_minor_mark_length) {
139 factor = real_minor_mark_length / real_mark_length;
163 pv.
push_back(pvec[0].
portion(0, 0.5 - ((mark_gap * 0.5 * (1 + (1 - factor)))/100.0)));
164 pv.
push_back(pvec[0].
portion(0.5 + ((mark_gap * 0.5 * (1 + (1 - factor)))/100.0), 1));
187 using namespace Geom;
190 const int i_shift =
static_cast<int>(
shift) % mminterval;
196 double totlength = arclength.
lastValue();
199 std::vector<double> s_cuts;
207 if (!punit.empty() &&
prev_unit != punit) {
218 if (!punit.empty() &&
prev_unit != punit) {
241 double real_offset =
offset;
249 for (
double s = real_offset; s<totlength; s+=real_mark_distance){
253 std::vector<double> t_cuts;
258 t_cuts.push_back(
root[0]);
261 for (
size_t i = 0; i < t_cuts.size(); i++) {
262 Point A = pwd2_in(t_cuts[i]);
264 if (
static_cast<int>(i % mminterval) == i_shift) {
272 Point A = pwd2_in.firstValue();
278 Point A = pwd2_in.lastValue();
282 if ( A == pwd2_in.firstValue() &&
283 speed.
segs.size() > 1 &&
284 speed.
segs.back()[
X].size() <= 1 &&
285 speed.
segs.back()[
Y].size() <= 1 &&
286 speed.
segs.back()[
X].tailError(0) <= 1e-10 &&
287 speed.
segs.back()[
Y].tailError(0) <= 1e-10
Adaptor that creates 2D functions from 1D ones.
void push_back(Path const &path)
Append a path at the end.
Function defined as discrete pieces.
output_type lastValue() const
output_type firstValue() const
void concat(const Piecewise< T > &other)
Two-dimensional point that doubles as a vector.
Rotation around the origin.
Polynomial in symmetric power basis.
Translate inverse() const
Get the inverse translation.
void registerParameter(Parameter *param)
void param_setValue(Glib::ustring newvalue, bool write=false)
Glib::ustring param_getSVGValue() const override
void doOnApply(SPLPEItem const *lpeitem) override
Is performed a single time when the effect is freshly applied to a path.
static Geom::Point n_minor
static Geom::Point n_major
Geom::Piecewise< Geom::D2< Geom::SBasis > > ruler_mark(Geom::Point const &A, Geom::Point const &n, MarkType const &marktype)
Geom::Piecewise< Geom::D2< Geom::SBasis > > doEffect_pwd2(Geom::Piecewise< Geom::D2< Geom::SBasis > > const &pwd2_in) override
EnumParam< MarkDirType > mark_dir
LPERuler(LivePathEffectObject *lpeobject)
ScalarParam major_mark_gap
ScalarParam minor_mark_length
EnumParam< BorderMarkType > border_marks
ScalarParam minor_mark_gap
ScalarParam mark_distance
ScalarParam major_mark_steps
void param_set_digits(unsigned digits)
void param_set_range(double min, double max)
void param_set_increments(double step, double page)
void param_make_integer(bool yes=true)
void param_set_value(double val)
const gchar * get_abbreviation() const
Simplified management of enumerations of svg items with UI labels.
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
Typed SVG document implementation.
Inkscape::Util::Quantity getWidth() const
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
Inkscape::Util::Unit const * getDisplayUnit()
guaranteed not to return nullptr
LPE <ruler> implementation, see lpe-ruler.cpp.
Various utility functions.
Piecewise< D2< SBasis > > paths_to_pw(PathVector const &paths)
static float sign(double number)
Returns +1 for positive numbers, -1 for negative numbers, and 0 otherwise.
SBasisOf< T > shift(SBasisOf< T > const &a, int sh)
PathVector path_from_piecewise(Piecewise< D2< SBasis > > const &B, double tol, bool only_cubicbeziers=false)
Make a path from a d2 sbasis.
std::vector< double > roots(SBasis const &s)
Bezier portion(const Bezier &a, double from, double to)
Bezier derivative(Bezier const &a)
std::vector< std::vector< double > > multi_roots(SBasis const &f, std::vector< double > const &levels, double htol=1e-7, double vtol=1e-7, double a=0, double b=1)
Point unit_vector(Point const &a)
Piecewise< SBasis > arcLengthSb(D2< SBasis > const &M, double tol=.01)
D2< T > rot90(D2< T > const &a)
static const Util::EnumDataConverter< MarkDirType > MarkDirTypeConverter(MarkDirData, sizeof(MarkDirData)/sizeof(*MarkDirData))
static const Util::EnumData< BorderMarkType > BorderMarkData[]
static const Util::EnumDataConverter< BorderMarkType > BorderMarkTypeConverter(BorderMarkData, sizeof(BorderMarkData)/sizeof(*BorderMarkData))
static const Util::EnumData< MarkDirType > MarkDirData[]
Helper class to stream background task notifications as a series of messages.
Conversion between SBasis and Bezier basis polynomials.
Simplified management of enumerations of svg items with UI labels.