1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
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_LINE_IMP_H
19 #define KIG_OBJECTS_LINE_IMP_H
21 #include "curve_imp.h"
23 #include "../misc/common.h"
28 * An ObjectImp class that is the base of the line-like ObjectImp's:
29 * SegmentImp, LineImp and RayImp..
36 AbstractLineImp( const LineData
& d
);
37 AbstractLineImp( const Coordinate
& a
, const Coordinate
& b
);
40 typedef CurveImp Parent
;
42 * Returns the ObjectImpType representing the AbstractLineImp
45 static const ObjectImpType
* stype();
49 bool inRect( const Rect
& r
, int width
, const KigWidget
& ) const;
51 const uint
numberOfProperties() const;
52 const QCStringList
properties() const;
53 const QCStringList
propertiesInternalNames() const;
54 ObjectImp
* property( uint which
, const KigDocument
& d
) const;
55 const char* iconForProperty( uint which
) const;
56 const ObjectImpType
* impRequirementForProperty( uint which
) const;
57 bool isPropertyDefinedOnOrThroughThisImp( uint which
) const;
60 * Get the slope of this AbstractLineImp.. For a line through
61 * points a( xa, ya ) and b ( xb, yb ), this means the value ( yb -
66 * Get a string containing the equation of this line in the form "y
69 const QString
equationString() const;
71 * Get the LineData for this AbstractLineImp.
73 LineData
data() const;
75 bool equals( const ObjectImp
& rhs
) const;
79 * An ObjectImp representing a segment
82 : public AbstractLineImp
85 typedef AbstractLineImp Parent
;
87 * Returns the ObjectImpType representing the SegmentImp
90 static const ObjectImpType
* stype();
93 * Construct a new segment from point a to point b.
95 SegmentImp( const Coordinate
& a
, const Coordinate
& b
);
97 * Construct a new segment from a LineData.
99 SegmentImp( const LineData
& d
);
101 void draw( KigPainter
& p
) const;
102 bool contains( const Coordinate
& p
, int width
, const KigWidget
& si
) const;
103 Rect
surroundingRect() const;
105 ObjectImp
* transform( const Transformation
& ) const;
107 const Coordinate
getPoint( double param
, const KigDocument
& ) const;
108 double getParam( const Coordinate
&, const KigDocument
& ) const;
110 const uint
numberOfProperties() const;
111 const QCStringList
properties() const;
112 const QCStringList
propertiesInternalNames() const;
113 ObjectImp
* property( uint which
, const KigDocument
& d
) const;
114 const char* iconForProperty( uint which
) const;
115 const ObjectImpType
* impRequirementForProperty( uint which
) const;
117 SegmentImp
* copy() const;
120 * Get the length of this segment.
122 double length() const;
124 const ObjectImpType
* type() const;
125 void visit( ObjectImpVisitor
* vtor
) const;
127 bool containsPoint( const Coordinate
& p
, const KigDocument
& doc
) const;
128 bool internalContainsPoint( const Coordinate
& p
, double threshold
) const;
132 * An ObjectImp representing a ray. This means half of a line, it is
133 * infinite in one direction, but ends at a certain point in the other
137 : public AbstractLineImp
140 typedef AbstractLineImp Parent
;
142 * Returns the ObjectImpType representing the RayImp
145 static const ObjectImpType
* stype();
148 * Construct a ray, starting at a, and going through b.
150 RayImp( const Coordinate
& a
, const Coordinate
& b
);
152 * Construct a ray from a LineData.
154 RayImp( const LineData
& d
);
156 void draw( KigPainter
& p
) const;
157 bool contains( const Coordinate
& p
, int width
, const KigWidget
& si
) const;
158 Rect
surroundingRect() const;
160 ObjectImp
* transform( const Transformation
& ) const;
162 const Coordinate
getPoint( double param
, const KigDocument
& ) const;
163 double getParam( const Coordinate
&, const KigDocument
& ) const;
165 RayImp
* copy() const;
167 const ObjectImpType
* type() const;
168 void visit( ObjectImpVisitor
* vtor
) const;
170 bool containsPoint( const Coordinate
& p
, const KigDocument
& doc
) const;
171 bool internalContainsPoint( const Coordinate
& p
, double threshold
) const;
175 * An ObjectImp representing a line.
178 : public AbstractLineImp
181 typedef AbstractLineImp Parent
;
184 * Returns the ObjectImpType representing the LineImp
187 static const ObjectImpType
* stype();
190 * Construct a LineImp going through points a and b.
192 LineImp( const Coordinate
& a
, const Coordinate
& b
);
194 * Construct a LineImp from a LineData.
196 LineImp( const LineData
& d
);
197 void draw( KigPainter
& p
) const;
198 bool contains( const Coordinate
& p
, int width
, const KigWidget
& si
) const;
199 Rect
surroundingRect() const;
201 ObjectImp
* transform( const Transformation
& ) const;
203 const Coordinate
getPoint( double param
, const KigDocument
& ) const;
204 double getParam( const Coordinate
&, const KigDocument
& ) const;
206 LineImp
* copy() const;
208 const ObjectImpType
* type() const;
209 void visit( ObjectImpVisitor
* vtor
) const;
211 bool containsPoint( const Coordinate
& p
, const KigDocument
& doc
) const;
212 bool internalContainsPoint( const Coordinate
& p
, double threshold
) const;