• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • objects
bezier_imp.h
Go to the documentation of this file.
1 // Copyright (C) 2009 Petr Gajdos <pgajdos@suse.cz> and
2 // Maurizio Paolini <paolini@dmf.unicatt.it>
3 
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 // 02110-1301, USA.
18 
19 #ifndef KIG_OBJECTS_BEZIER_IMP_H
20 #define KIG_OBJECTS_BEZIER_IMP_H
21 
22 #include "curve_imp.h"
23 
24 #include "object_imp.h"
25 #include "../misc/coordinate.h"
26 #include <vector>
27 
31 class BezierImp
32  : public CurveImp
33 {
34  uint mnpoints;
35  std::vector<Coordinate> mpoints;
36  Coordinate mcenterofmass;
37 
38  Coordinate deCasteljau( unsigned int m, unsigned int k, double p ) const;
39 
40 public:
41  typedef CurveImp Parent;
45  static const ObjectImpType* stype();
46  static const ObjectImpType* stype2();
47  static const ObjectImpType* stype3();
48 
52  BezierImp( const std::vector<Coordinate>& points );
53  ~BezierImp();
54  BezierImp* copy() const;
55 
56  Coordinate attachPoint() const;
57  ObjectImp* transform( const Transformation& ) const;
58 
59  void draw( KigPainter& p ) const;
60  bool contains( const Coordinate& p, int width, const KigWidget& ) const;
61  bool inRect( const Rect& r, int width, const KigWidget& ) const;
62  bool valid() const;
63  Rect surroundingRect() const;
64 
65  const Coordinate getPoint( double param, const KigDocument& ) const;
66  bool containsPoint( const Coordinate& p, const KigDocument& doc ) const;
67  bool internalContainsPoint( const Coordinate& p, double threshold,
68  const KigDocument& doc ) const;
69 
70  int numberOfProperties() const;
71  const QByteArrayList properties() const;
72  const QByteArrayList propertiesInternalNames() const;
73  ObjectImp* property( int which, const KigDocument& w ) const;
74  const char* iconForProperty( int which ) const;
75  const ObjectImpType* impRequirementForProperty( int which ) const;
76  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
77 
78  const ObjectImpType* type() const;
79  void visit( ObjectImpVisitor* vtor ) const;
80 
84  const std::vector<Coordinate> points() const;
88  const Coordinate centerOfMass() const;
92  uint npoints() const;
93 
94  bool equals( const ObjectImp& rhs ) const;
95 };
96 
100 class RationalBezierImp
101  : public CurveImp
102 {
103  uint mnpoints;
104  std::vector<Coordinate> mpoints;
105  std::vector<double> mweights;
106  Coordinate mcenterofmass;
107 
108  Coordinate deCasteljauPoints( unsigned int m, unsigned int k, double p ) const;
109  double deCasteljauWeights( unsigned int m, unsigned int k, double p ) const;
110 
111 public:
112  typedef CurveImp Parent;
116  static const ObjectImpType* stype();
117  static const ObjectImpType* stype2();
118  static const ObjectImpType* stype3();
119 
123  RationalBezierImp( const std::vector<Coordinate>& points, const std::vector<double>& weights );
124  ~RationalBezierImp();
125  RationalBezierImp* copy() const;
126 
127  Coordinate attachPoint() const;
128  ObjectImp* transform( const Transformation& ) const;
129 
130  void draw( KigPainter& p ) const;
131  bool contains( const Coordinate& p, int width, const KigWidget& ) const;
132  bool inRect( const Rect& r, int width, const KigWidget& ) const;
133  bool valid() const;
134  Rect surroundingRect() const;
135 
136  const Coordinate getPoint( double param, const KigDocument& ) const;
137  bool containsPoint( const Coordinate& p, const KigDocument& doc ) const;
138  bool internalContainsPoint( const Coordinate& p, double threshold,
139  const KigDocument& doc ) const;
140 
141  int numberOfProperties() const;
142  const QByteArrayList properties() const;
143  const QByteArrayList propertiesInternalNames() const;
144  ObjectImp* property( int which, const KigDocument& w ) const;
145  const char* iconForProperty( int which ) const;
146  const ObjectImpType* impRequirementForProperty( int which ) const;
147  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
148 
149  const ObjectImpType* type() const;
150  void visit( ObjectImpVisitor* vtor ) const;
151 
155  const std::vector<Coordinate> points() const;
159  const Coordinate centerOfMass() const;
163  uint npoints() const;
164 
165  bool equals( const ObjectImp& rhs ) const;
166 };
167 
168 
169 #endif
object_imp.h
BezierImp::attachPoint
Coordinate attachPoint() const
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
Definition: bezier_imp.cc:61
BezierImp
An ObjectImp representing polynomial Bézier Curve.
Definition: bezier_imp.h:31
BezierImp::draw
void draw(KigPainter &p) const
Definition: bezier_imp.cc:87
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
BezierImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: bezier_imp.cc:66
RationalBezierImp::~RationalBezierImp
~RationalBezierImp()
Definition: bezier_imp.cc:355
RationalBezierImp::draw
void draw(KigPainter &p) const
Definition: bezier_imp.cc:385
BezierImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: bezier_imp.cc:123
BezierImp::stype3
static const ObjectImpType * stype3()
Definition: bezier_imp.cc:254
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
RationalBezierImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bezier_imp.cc:507
RationalBezierImp
An ObjectImp representing a rational Bézier curve.
Definition: bezier_imp.h:100
BezierImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: bezier_imp.cc:281
RationalBezierImp::Parent
CurveImp Parent
Definition: bezier_imp.h:112
RationalBezierImp::stype3
static const ObjectImpType * stype3()
Definition: bezier_imp.cc:552
BezierImp::npoints
uint npoints() const
Returns the number of control points.
Definition: bezier_imp.cc:194
BezierImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: bezier_imp.cc:143
RationalBezierImp::RationalBezierImp
RationalBezierImp(const std::vector< Coordinate > &points, const std::vector< double > &weights)
Constructs a rational Bézier curve.
Definition: bezier_imp.cc:336
RationalBezierImp::getPoint
const Coordinate getPoint(double param, const KigDocument &) const
Definition: bezier_imp.cc:628
RationalBezierImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: bezier_imp.cc:441
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
RationalBezierImp::properties
const QByteArrayList properties() const
Definition: bezier_imp.cc:431
BezierImp::iconForProperty
const char * iconForProperty(int which) const
Definition: bezier_imp.cc:150
RationalBezierImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: bezier_imp.cc:364
RationalBezierImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the RationalBezierImp type.
Definition: bezier_imp.cc:516
BezierImp::stype2
static const ObjectImpType * stype2()
Definition: bezier_imp.cc:236
RationalBezierImp::attachPoint
Coordinate attachPoint() const
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
Definition: bezier_imp.cc:359
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
BezierImp::inRect
bool inRect(const Rect &r, int width, const KigWidget &) const
Definition: bezier_imp.cc:92
RationalBezierImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: bezier_imp.cc:579
RationalBezierImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: bezier_imp.cc:597
RationalBezierImp::iconForProperty
const char * iconForProperty(int which) const
Definition: bezier_imp.cc:448
Transformation
Class representing a transformation.
Definition: kigtransform.h:37
BezierImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bezier_imp.cc:272
RationalBezierImp::containsPoint
bool containsPoint(const Coordinate &p, const KigDocument &doc) const
Return whether this Curve contains the given point.
Definition: bezier_imp.cc:602
BezierImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: bezier_imp.cc:165
BezierImp::numberOfProperties
int numberOfProperties() const
Definition: bezier_imp.cc:118
BezierImp::getPoint
const Coordinate getPoint(double param, const KigDocument &) const
Definition: bezier_imp.cc:323
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
RationalBezierImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: bezier_imp.cc:421
BezierImp::centerOfMass
const Coordinate centerOfMass() const
Returns the center of mass of the control polygon.
BezierImp::~BezierImp
~BezierImp()
Definition: bezier_imp.cc:57
BezierImp::copy
BezierImp * copy() const
Returns a copy of this ObjectImp.
Definition: bezier_imp.cc:199
BezierImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: bezier_imp.cc:299
RationalBezierImp::npoints
uint npoints() const
Returns the number of control points.
Definition: bezier_imp.cc:492
BezierImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bezier_imp.cc:209
BezierImp::containsPoint
bool containsPoint(const Coordinate &p, const KigDocument &doc) const
Return whether this Curve contains the given point.
Definition: bezier_imp.cc:304
RationalBezierImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bezier_imp.cc:570
BezierImp::internalContainsPoint
bool internalContainsPoint(const Coordinate &p, double threshold, const KigDocument &doc) const
Definition: bezier_imp.cc:309
BezierImp::surroundingRect
Rect surroundingRect() const
Definition: bezier_imp.cc:289
RationalBezierImp::internalContainsPoint
bool internalContainsPoint(const Coordinate &p, double threshold, const KigDocument &doc) const
Definition: bezier_imp.cc:607
RationalBezierImp::points
const std::vector< Coordinate > points() const
Returns the vector with control points.
Definition: bezier_imp.cc:487
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
BezierImp::valid
bool valid() const
Definition: bezier_imp.cc:110
BezierImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the BezierImp type.
Definition: bezier_imp.cc:218
RationalBezierImp::centerOfMass
const Coordinate centerOfMass() const
Returns the center of mass of the control polygon.
RationalBezierImp::copy
RationalBezierImp * copy() const
Returns a copy of this ObjectImp.
Definition: bezier_imp.cc:497
RationalBezierImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bezier_imp.cc:502
BezierImp::points
const std::vector< Coordinate > points() const
Returns the vector with control points.
Definition: bezier_imp.cc:189
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
RationalBezierImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: bezier_imp.cc:463
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
BezierImp::Parent
CurveImp Parent
Definition: bezier_imp.h:41
curve_imp.h
RationalBezierImp::valid
bool valid() const
Definition: bezier_imp.cc:408
BezierImp::properties
const QByteArrayList properties() const
Definition: bezier_imp.cc:133
RationalBezierImp::surroundingRect
Rect surroundingRect() const
Definition: bezier_imp.cc:587
RationalBezierImp::numberOfProperties
int numberOfProperties() const
Definition: bezier_imp.cc:416
RationalBezierImp::inRect
bool inRect(const Rect &r, int width, const KigWidget &) const
Definition: bezier_imp.cc:390
BezierImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bezier_imp.cc:204
RationalBezierImp::stype2
static const ObjectImpType * stype2()
Definition: bezier_imp.cc:534
uint
unsigned int uint
Definition: object_imp.h:87
BezierImp::BezierImp
BezierImp(const std::vector< Coordinate > &points)
Constructs a Bézier curve.
Definition: bezier_imp.cc:43
ObjectImpVisitor
Definition: object_imp.h:56
CurveImp
This class represents a curve: something which is composed of points, like a line, a circle, a locus.
Definition: curve_imp.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal