1 // Copyright (C) 2004 Pino Toscano <toscano.pino@tiscali.it>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
18 #ifndef KIG_OBJECTS_POLYGON_IMP_H
19 #define KIG_OBJECTS_POLYGON_IMP_H
21 #include "object_imp.h"
22 #include "../misc/coordinate.h"
26 * An ObjectImp representing a polygon.
32 std::vector
<Coordinate
> mpoints
;
33 Coordinate mcenterofmass
;
35 typedef ObjectImp Parent
;
37 * Returns the ObjectImpType representing the PolygonImp type..
39 static const ObjectImpType
* stype();
40 static const ObjectImpType
* stype3();
41 static const ObjectImpType
* stype4();
44 * Constructs a polygon.
46 PolygonImp( const std::vector
<Coordinate
>& points
);
47 PolygonImp( const uint nsides
, const std::vector
<Coordinate
>& points
,
48 const Coordinate
& centerofmass
);
50 PolygonImp
* copy() const;
52 Coordinate
attachPoint() const;
53 ObjectImp
* transform( const Transformation
& ) const;
55 void draw( KigPainter
& p
) const;
56 bool contains( const Coordinate
& p
, int width
, const KigWidget
& ) const;
57 bool inRect( const Rect
& r
, int width
, const KigWidget
& ) const;
59 Rect
surroundingRect() const;
61 const uint
numberOfProperties() const;
62 const QCStringList
properties() const;
63 const QCStringList
propertiesInternalNames() const;
64 ObjectImp
* property( uint which
, const KigDocument
& w
) const;
65 const char* iconForProperty( uint which
) const;
66 const ObjectImpType
* impRequirementForProperty( uint which
) const;
67 bool isPropertyDefinedOnOrThroughThisImp( uint which
) const;
69 const ObjectImpType
* type() const;
70 void visit( ObjectImpVisitor
* vtor
) const;
73 * Returns the vector with polygon points.
75 const std::vector
<Coordinate
> points() const;
77 * Returns the center of mass of the polygon.
79 const Coordinate
centerOfMass() const;
81 * Returns the number of points of this polygon.
83 const uint
npoints() const;
85 bool equals( const ObjectImp
& rhs
) const;
86 bool isInPolygon( const Coordinate
& p
) const;
87 int windingNumber() const;
88 bool isMonotoneSteering() const;
89 bool isConvex() const;
92 std::vector
<Coordinate
> computeConvexHull( const std::vector
<Coordinate
>& points
);