• 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
polygon_imp.h
Go to the documentation of this file.
1 // Copyright (C) 2004 Pino Toscano <toscano.pino@tiscali.it>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #ifndef KIG_OBJECTS_POLYGON_IMP_H
19 #define KIG_OBJECTS_POLYGON_IMP_H
20 
21 #include "object_imp.h"
22 #include "../misc/coordinate.h"
23 #include <vector>
24 
28 class AbstractPolygonImp
29  : public ObjectImp
30 {
31 protected:
32  uint mnpoints;
33  std::vector<Coordinate> mpoints;
34 // bool minside; // true: filled polygon, false: polygon boundary
35 // bool mopen; // true: polygonal curve (minside must be false)
36  Coordinate mcenterofmass;
37 public:
38  typedef ObjectImp Parent;
42  static const ObjectImpType* stype();
43 
44 // PolygonImp( const std::vector<Coordinate>& points, bool inside = true, bool open = false );
45  AbstractPolygonImp( const std::vector<Coordinate>& points );
46  AbstractPolygonImp( const uint nsides, const std::vector<Coordinate>& points,
47  const Coordinate& centerofmass );
48  ~AbstractPolygonImp();
49 // PolygonImp* copy() const;
50 
51  Coordinate attachPoint() const;
52  std::vector<Coordinate> ptransform( const Transformation& ) const;
53 
54  bool inRect( const Rect& r, int width, const KigWidget& ) const;
55  bool valid() const;
56  Rect surroundingRect() const;
57 
58  int numberOfProperties() const;
59  const QByteArrayList properties() const;
60  const QByteArrayList propertiesInternalNames() const;
61  ObjectImp* property( int which, const KigDocument& w ) const;
62  const char* iconForProperty( int which ) const;
63  const ObjectImpType* impRequirementForProperty( int which ) const;
64  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
65 
69  const std::vector<Coordinate> points() const;
73  const Coordinate centerOfMass() const;
77  uint npoints() const;
81  double operimeter() const;
82  double cperimeter() const;
86  double area() const;
87 
88  bool equals( const ObjectImp& rhs ) const;
89  bool isInPolygon( const Coordinate& p ) const;
90  bool isOnOPolygonBorder( const Coordinate& p, double dist, const KigDocument& doc ) const;
91  bool isOnCPolygonBorder( const Coordinate& p, double dist, const KigDocument& doc ) const;
92  int windingNumber() const;
93  bool isTwisted() const;
94  bool isMonotoneSteering() const;
95  bool isConvex() const;
96 };
97 
101 class FilledPolygonImp
102  : public AbstractPolygonImp
103 {
104 public:
105  typedef AbstractPolygonImp Parent;
106  FilledPolygonImp( const std::vector<Coordinate>& points );
107  static const ObjectImpType* stype();
108  static const ObjectImpType* stype3();
109  static const ObjectImpType* stype4();
110  ObjectImp* transform( const Transformation& ) const;
111  void draw( KigPainter& p ) const;
112  bool contains( const Coordinate& p, int width, const KigWidget& ) const;
113  int numberOfProperties() const;
114  const QByteArrayList properties() const;
115  const QByteArrayList propertiesInternalNames() const;
116  ObjectImp* property( int which, const KigDocument& w ) const;
117  const char* iconForProperty( int which ) const;
118  const ObjectImpType* impRequirementForProperty( int which ) const;
119  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
120 
121  const ObjectImpType* type() const;
122  void visit( ObjectImpVisitor* vtor ) const;
123 
124  FilledPolygonImp* copy() const;
125 };
126 
130 class ClosedPolygonalImp
131  : public AbstractPolygonImp
132 {
133 public:
134  typedef AbstractPolygonImp Parent;
135  ClosedPolygonalImp( const std::vector<Coordinate>& points );
136  static const ObjectImpType* stype();
137  ObjectImp* transform( const Transformation& ) const;
138  void draw( KigPainter& p ) const;
139  bool contains( const Coordinate& p, int width, const KigWidget& ) const;
140  int numberOfProperties() const;
141  const QByteArrayList properties() const;
142  const QByteArrayList propertiesInternalNames() const;
143  ObjectImp* property( int which, const KigDocument& w ) const;
144  const char* iconForProperty( int which ) const;
145  const ObjectImpType* impRequirementForProperty( int which ) const;
146  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
147 
148  const ObjectImpType* type() const;
149  void visit( ObjectImpVisitor* vtor ) const;
150 
151  ClosedPolygonalImp* copy() const;
152 };
153 
157 class OpenPolygonalImp
158  : public AbstractPolygonImp
159 {
160 public:
161  typedef AbstractPolygonImp Parent;
162  OpenPolygonalImp( const std::vector<Coordinate>& points );
163  static const ObjectImpType* stype();
164  ObjectImp* transform( const Transformation& ) const;
165  void draw( KigPainter& p ) const;
166  bool contains( const Coordinate& p, int width, const KigWidget& ) const;
167  int numberOfProperties() const;
168  const QByteArrayList properties() const;
169  const QByteArrayList propertiesInternalNames() const;
170  ObjectImp* property( int which, const KigDocument& w ) const;
171  const char* iconForProperty( int which ) const;
172  const ObjectImpType* impRequirementForProperty( int which ) const;
173  bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
174 
175  const ObjectImpType* type() const;
176  void visit( ObjectImpVisitor* vtor ) const;
177 
178  OpenPolygonalImp* copy() const;
179 };
180 
181 std::vector<Coordinate> computeConvexHull( const std::vector<Coordinate>& points );
182 
183 #endif
FilledPolygonImp::Parent
AbstractPolygonImp Parent
Definition: polygon_imp.h:105
object_imp.h
ClosedPolygonalImp
An ObjectImp representing a closed polygonal.
Definition: polygon_imp.h:130
AbstractPolygonImp::npoints
uint npoints() const
Returns the number of points of this polygon.
Definition: polygon_imp.cc:576
AbstractPolygonImp::ptransform
std::vector< Coordinate > ptransform(const Transformation &) const
Definition: polygon_imp.cc:77
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
FilledPolygonImp::draw
void draw(KigPainter &p) const
Definition: polygon_imp.cc:940
FilledPolygonImp::iconForProperty
const char * iconForProperty(int which) const
Definition: polygon_imp.cc:380
FilledPolygonImp::FilledPolygonImp
FilledPolygonImp(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:935
FilledPolygonImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: polygon_imp.cc:777
AbstractPolygonImp::numberOfProperties
int numberOfProperties() const
Definition: polygon_imp.cc:233
OpenPolygonalImp
An ObjectImp representing an open polygonal.
Definition: polygon_imp.h:157
FilledPolygonImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: polygon_imp.cc:350
FilledPolygonImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: polygon_imp.cc:630
ClosedPolygonalImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: polygon_imp.cc:759
FilledPolygonImp::copy
FilledPolygonImp * copy() const
Returns a copy of this ObjectImp.
Definition: polygon_imp.cc:615
OpenPolygonalImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: polygon_imp.cc:364
FilledPolygonImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: polygon_imp.cc:945
ClosedPolygonalImp::iconForProperty
const char * iconForProperty(int which) const
Definition: polygon_imp.cc:403
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
FilledPolygonImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: polygon_imp.cc:750
AbstractPolygonImp::isInPolygon
bool isInPolygon(const Coordinate &p) const
Definition: polygon_imp.cc:137
AbstractPolygonImp::iconForProperty
const char * iconForProperty(int which) const
Definition: polygon_imp.cc:371
ClosedPolygonalImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:678
OpenPolygonalImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: polygon_imp.cc:764
AbstractPolygonImp::points
const std::vector< Coordinate > points() const
Returns the vector with polygon points.
Definition: polygon_imp.cc:571
AbstractPolygonImp::attachPoint
Coordinate attachPoint() const
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
Definition: polygon_imp.cc:72
AbstractPolygonImp::isMonotoneSteering
bool isMonotoneSteering() const
Definition: polygon_imp.cc:893
FilledPolygonImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: polygon_imp.cc:454
AbstractPolygonImp::mcenterofmass
Coordinate mcenterofmass
Definition: polygon_imp.h:36
ClosedPolygonalImp::Parent
AbstractPolygonImp Parent
Definition: polygon_imp.h:134
OpenPolygonalImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: polygon_imp.cc:640
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
AbstractPolygonImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: polygon_imp.cc:645
ClosedPolygonalImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: polygon_imp.cc:272
FilledPolygonImp::properties
const QByteArrayList properties() const
Definition: polygon_imp.cc:303
AbstractPolygonImp::AbstractPolygonImp
AbstractPolygonImp(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:54
FilledPolygonImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: polygon_imp.cc:116
OpenPolygonalImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:696
ClosedPolygonalImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: polygon_imp.cc:357
ClosedPolygonalImp::draw
void draw(KigPainter &p) const
Definition: polygon_imp.cc:956
FilledPolygonImp::stype4
static const ObjectImpType * stype4()
Definition: polygon_imp.cc:732
FilledPolygonImp::numberOfProperties
int numberOfProperties() const
Definition: polygon_imp.cc:238
OpenPolygonalImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: polygon_imp.cc:130
AbstractPolygonImp::isConvex
bool isConvex() const
Definition: polygon_imp.cc:922
AbstractPolygonImp::~AbstractPolygonImp
~AbstractPolygonImp()
Definition: polygon_imp.cc:68
computeConvexHull
std::vector< Coordinate > computeConvexHull(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:990
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
AbstractPolygonImp::mpoints
std::vector< Coordinate > mpoints
Definition: polygon_imp.h:33
AbstractPolygonImp::windingNumber
int windingNumber() const
Definition: polygon_imp.cc:811
AbstractPolygonImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the PolygonImp type.
Definition: polygon_imp.cc:651
OpenPolygonalImp::draw
void draw(KigPainter &p) const
Definition: polygon_imp.cc:974
AbstractPolygonImp::inRect
bool inRect(const Rect &r, int width, const KigWidget &) const
Definition: polygon_imp.cc:210
ClosedPolygonalImp::copy
ClosedPolygonalImp * copy() const
Returns a copy of this ObjectImp.
Definition: polygon_imp.cc:620
Transformation
Class representing a transformation.
Definition: kigtransform.h:37
OpenPolygonalImp::OpenPolygonalImp
OpenPolygonalImp(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:969
ClosedPolygonalImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: polygon_imp.cc:785
AbstractPolygonImp::properties
const QByteArrayList properties() const
Definition: polygon_imp.cc:298
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
FilledPolygonImp::stype
static const ObjectImpType * stype()
Definition: polygon_imp.cc:660
ClosedPolygonalImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: polygon_imp.cc:497
OpenPolygonalImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: polygon_imp.cc:540
AbstractPolygonImp::operimeter
double operimeter() const
Returns the perimeter of this polygon.
Definition: polygon_imp.cc:581
AbstractPolygonImp::mnpoints
uint mnpoints
Definition: polygon_imp.h:32
AbstractPolygonImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: polygon_imp.cc:769
OpenPolygonalImp::Parent
AbstractPolygonImp Parent
Definition: polygon_imp.h:161
OpenPolygonalImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: polygon_imp.cc:286
FilledPolygonImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: polygon_imp.cc:258
AbstractPolygonImp::property
ObjectImp * property(int which, const KigDocument &w) const
Definition: polygon_imp.cc:445
ClosedPolygonalImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: polygon_imp.cc:963
ClosedPolygonalImp::ClosedPolygonalImp
ClosedPolygonalImp(const std::vector< Coordinate > &points)
Definition: polygon_imp.cc:951
AbstractPolygonImp::isTwisted
bool isTwisted() const
Definition: polygon_imp.cc:845
AbstractPolygonImp::valid
bool valid() const
Definition: polygon_imp.cc:228
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
ClosedPolygonalImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: polygon_imp.cc:123
OpenPolygonalImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: polygon_imp.cc:793
AbstractPolygonImp::isOnCPolygonBorder
bool isOnCPolygonBorder(const Coordinate &p, double dist, const KigDocument &doc) const
Definition: polygon_imp.cc:188
AbstractPolygonImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: polygon_imp.cc:253
OpenPolygonalImp::copy
OpenPolygonalImp * copy() const
Returns a copy of this ObjectImp.
Definition: polygon_imp.cc:625
AbstractPolygonImp::Parent
ObjectImp Parent
Definition: polygon_imp.h:38
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
AbstractPolygonImp::surroundingRect
Rect surroundingRect() const
Definition: polygon_imp.cc:801
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
ClosedPolygonalImp::properties
const QByteArrayList properties() const
Definition: polygon_imp.cc:317
OpenPolygonalImp::properties
const QByteArrayList properties() const
Definition: polygon_imp.cc:331
AbstractPolygonImp
An ObjectImp representing a polygon.
Definition: polygon_imp.h:28
FilledPolygonImp
An ObjectImp representing a filled polygon.
Definition: polygon_imp.h:101
OpenPolygonalImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &) const
Definition: polygon_imp.cc:980
ClosedPolygonalImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: polygon_imp.cc:635
OpenPolygonalImp::numberOfProperties
int numberOfProperties() const
Definition: polygon_imp.cc:248
FilledPolygonImp::stype3
static const ObjectImpType * stype3()
Definition: polygon_imp.cc:714
AbstractPolygonImp::cperimeter
double cperimeter() const
Definition: polygon_imp.cc:591
OpenPolygonalImp::iconForProperty
const char * iconForProperty(int which) const
Definition: polygon_imp.cc:426
ClosedPolygonalImp::numberOfProperties
int numberOfProperties() const
Definition: polygon_imp.cc:243
AbstractPolygonImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: polygon_imp.cc:343
uint
unsigned int uint
Definition: object_imp.h:87
ObjectImpVisitor
Definition: object_imp.h:56
AbstractPolygonImp::centerOfMass
const Coordinate centerOfMass() const
Returns the center of mass of the polygon.
AbstractPolygonImp::isOnOPolygonBorder
bool isOnOPolygonBorder(const Coordinate &p, double dist, const KigDocument &doc) const
Definition: polygon_imp.cc:198
AbstractPolygonImp::area
double area() const
Returns the area of this polygon.
Definition: polygon_imp.cc:602
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