summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBryce Harrington <bryce@bryceharrington.org>2007-12-30 23:40:41 +0000
committerbryce <bryce@users.sourceforge.net>2007-12-30 23:40:41 +0000
commit839e7e7279023ab60c9beaaf3f1d73cc4217e5b0 (patch)
treef67cd36fa8de65f5c0f3d428991f32a1d5d40f49 /src
parentcomment fix (diff)
downloadinkscape-839e7e7279023ab60c9beaaf3f1d73cc4217e5b0.tar.gz
inkscape-839e7e7279023ab60c9beaaf3f1d73cc4217e5b0.zip
Set teeth selector in lpe-gears to an integer value >= 3.
Fix trailing whitespace. (bzr r4342)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/effect.h10
-rw-r--r--src/live_effects/lpe-gears.cpp44
-rw-r--r--src/live_effects/parameter/parameter.cpp9
-rw-r--r--src/ui/widget/registered-widget.cpp4
-rw-r--r--src/ui/widget/registered-widget.h32
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<Geom::Path> )
virtual NArtBpath *
doEffect_nartbpath (NArtBpath * path_in);
- virtual std::vector<Geom::Path>
+ virtual std::vector<Geom::Path>
doEffect_path (std::vector<Geom::Path> & path_in);
- virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
+ virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & 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<SBasis> B;
D2<SBasis> 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<SBasis> _arc(double start, double stop, double R) {
D2<SBasis> 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<SBasis> &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<LineSegment>(leading_end);
}
-
+
D2<SBasis> 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<Parameter *>(&teeth) );
registerParameter( dynamic_cast<Parameter *>(&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 <ralf@ark.in-berlin.de>
@@ -93,15 +93,15 @@ public:
Gtk::ToggleButton *_button;
std::list<Gtk::ToggleButton*> _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<Gtk::ToggleButton*> 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); };