From eaa9bdc7bf7b73397e536edd47490d84e4420bd8 Mon Sep 17 00:00:00 2001 From: bryce Date: Sun, 30 Dec 2007 23:40:41 +0000 Subject: [PATCH] Set teeth selector in lpe-gears to an integer value >= 3. Fix trailing whitespace. --- src/live_effects/effect.cpp | 2 +- src/live_effects/effect.h | 10 +++--- src/live_effects/lpe-gears.cpp | 44 +++++++++++++----------- src/live_effects/parameter/parameter.cpp | 9 ++--- src/ui/widget/registered-widget.cpp | 4 +-- src/ui/widget/registered-widget.h | 32 ++++++++--------- 6 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ed2eb62fe..117fbcdb7 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -107,7 +107,7 @@ Effect::~Effect() } } -Glib::ustring +Glib::ustring Effect::getName() { if (lpeobj->effecttype_set && lpeobj->effecttype < INVALID_LPE) diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 98cb746c5..964bcd12b 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -90,16 +90,16 @@ public: protected: Effect(LivePathEffectObject *lpeobject); - // provide a set of doEffect functions so the developer has a choice + // provide a set of doEffect functions so the developer has a choice // of what kind of input/output parameters he desires. - // the order in which they appear is the order in which they are + // the order in which they appear is the order in which they are // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling // doEffect(std::vector ) virtual NArtBpath * doEffect_nartbpath (NArtBpath * path_in); - virtual std::vector + virtual std::vector doEffect_path (std::vector & path_in); - virtual Geom::Piecewise > + virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > & pwd2_in); void registerParameter(Parameter * param); @@ -109,7 +109,7 @@ protected: int oncanvasedit_it; - Inkscape::UI::Widget::Registry wr; + Inkscape::UI::Widget::Registry wr; Gtk::VBox * vbox; Gtk::Tooltips * tooltips; diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index 2fdc0116e..85eee66f9 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -26,41 +26,41 @@ public: double pitch_diameter() {return (_number_of_teeth * _module) / M_PI;} double pitch_radius() {return pitch_diameter() / 2.0;} void pitch_radius(double R) {_module = (2 * M_PI * R) / _number_of_teeth;} - + // base circle serves as the basis for the involute toothe profile double base_diameter() {return pitch_diameter() * cos(_pressure_angle);} double base_radius() {return base_diameter() / 2.0;} - + // diametrical pitch double diametrical_pitch() {return _number_of_teeth / pitch_diameter();} - + // height of the tooth above the pitch circle double addendum() {return 1.0 / diametrical_pitch();} // depth of the tooth below the pitch circle double dedendum() {return addendum() + _clearance;} - + // root circle specifies the bottom of the fillet between teeth double root_radius() {return pitch_radius() - dedendum();} double root_diameter() {return root_radius() * 2.0;} - + // outer circle is the outside diameter of the gear double outer_radius() {return pitch_radius() + addendum();} double outer_diameter() {return outer_radius() * 2.0;} - + // angle covered by the tooth on the pitch circle double tooth_thickness_angle() {return M_PI / _number_of_teeth;} - + Geom::Point centre() {return _centre;} void centre(Geom::Point c) {_centre = c;} - + double angle() {return _angle;} void angle(double a) {_angle = a;} - + int number_of_teeth() {return _number_of_teeth;} - + Geom::Path path(); Gear spawn(Geom::Point p); - + Gear(int n, double m, double phi) { _number_of_teeth = n; _module = m; @@ -80,10 +80,10 @@ private: D2 B; D2 I; Linear bo = Linear(start,stop); - + B[0] = cos(bo,2); B[1] = sin(bo,2); - + I = B - Linear(0,1) * derivative(B); I = I*base_radius() + _centre; return I; @@ -91,10 +91,10 @@ private: D2 _arc(double start, double stop, double R) { D2 B; Linear bo = Linear(start,stop); - + B[0] = cos(bo,2); B[1] = sin(bo,2); - + B = B*R + _centre; return B; } @@ -118,7 +118,7 @@ void makeContinuous(D2 &a, Point const b) { Geom::Path Gear::path() { Geom::Path pb; - + // angle covered by a full tooth and fillet double tooth_rotation = 2.0 * tooth_thickness_angle(); // angle covered by an involute @@ -129,10 +129,10 @@ Geom::Path Gear::path() { double root_advance = (tooth_rotation - tip_advance) - (2.0 * involute_advance); // begin drawing the involute at t if the root circle is larger than the base circle double involute_t = involute_swath_angle(root_radius())/involute_swath_angle(outer_radius()); - + //rewind angle to start drawing from the leading edge of the tooth double first_tooth_angle = _angle - ((0.5 * tip_advance) + involute_advance); - + Geom::Point prev; for (int i=0; i < _number_of_teeth; i++) { @@ -162,13 +162,13 @@ Geom::Path Gear::path() { prev = leading_end; pb.appendNew(leading_end); } - + D2 root = _arc(cursor, cursor+root_advance, root_radius()); makeContinuous(root, prev); pb.append(SBasisCurve(root)); cursor += root_advance; prev = root.at1(); - + if (base_radius() > root_radius()) { Geom::Point trailing_start = root.at1(); Geom::Point trailing_end = (base_radius() * unit_vector(trailing_start - _centre)) + _centre; @@ -176,7 +176,7 @@ Geom::Path Gear::path() { prev = trailing_end; } } - + return pb; } @@ -212,6 +212,8 @@ LPEGears::LPEGears(LivePathEffectObject *lpeobject) : teeth(_("Teeth"), _("The number of teeth"), "teeth", &wr, this, 10), phi(_("Phi"), _("???"), "phi", &wr, this, 5) { + teeth.param_make_integer(); + teeth.param_set_range(3, NR_HUGE); registerParameter( dynamic_cast(&teeth) ); registerParameter( dynamic_cast(&phi) ); } diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 9ee7faae4..500578db4 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -86,13 +86,13 @@ ScalarParam::param_writeSVGValue() const } void -ScalarParam::param_set_default() +ScalarParam::param_set_default() { param_set_value(defvalue); } void -ScalarParam::param_set_value(gdouble val) +ScalarParam::param_set_value(gdouble val) { value = val; if (integer) @@ -107,12 +107,12 @@ ScalarParam::param_set_value(gdouble val) } void -ScalarParam::param_set_range(gdouble min, gdouble max) +ScalarParam::param_set_range(gdouble min, gdouble max) { this->min = min; this->max = max; if (rsu) - rsu->getS()->setRange(min, max); + rsu->getS()->setRange(this->min, this->max); param_set_value(value); // reset value to see whether it is in ranges } @@ -139,6 +139,7 @@ ScalarParam::param_getWidget() rsu->setValue(value); rsu->getS()->setDigits(digits); rsu->getS()->setIncrements(inc_step, inc_page); + rsu->getS()->setRange(min, max); rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 4b1c2a5f8..aac9ff25c 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -256,14 +256,14 @@ RegisteredScalar::RegisteredScalar() RegisteredScalar::~RegisteredScalar() { - if (_widget) + if (_widget) delete _widget; _value_changed_connection.disconnect(); } void -RegisteredScalar::init ( const Glib::ustring& label, const Glib::ustring& tip, +RegisteredScalar::init ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument * doc_in ) { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 33d7c29cd..90fb44983 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -1,5 +1,5 @@ /** \file - * \brief + * \brief * * Authors: * Ralf Stephan @@ -93,15 +93,15 @@ public: Gtk::ToggleButton *_button; std::list _slavebuttons; - + // a slave button is only sensitive when the master button is active // i.e. a slave button is greyed-out when the master button is not checked - + void setSlaveButton(std::list btns) { _slavebuttons = btns; } - bool setProgrammatically; // true if the value was set by setValue, not changed by the user; + bool setProgrammatically; // true if the value was set by setValue, not changed by the user; // if a callback checks it, it must reset it back to false @@ -138,16 +138,16 @@ class RegisteredScalarUnit : public RegisteredWidget { public: RegisteredScalarUnit(); ~RegisteredScalarUnit(); - void init (const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, + void init (const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in); - inline void init ( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, + inline void init ( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr) { init(label, tip, key, rum, wr, NULL, NULL); }; @@ -166,15 +166,15 @@ class RegisteredScalar : public RegisteredWidget { public: RegisteredScalar(); ~RegisteredScalar(); - void init (const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, + void init (const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in); - inline void init ( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, + inline void init ( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, Registry& wr) { init(label, tip, key, wr, NULL, NULL); }; -- 2.30.2