Kig Python Scripting API Documentation

common.h
1
22#ifndef KIG_MISC_COMMON_H
23#define KIG_MISC_COMMON_H
24
25#include "coordinate.h"
26#include "rect.h"
27
28#include <tqrect.h>
29#include <tdeversion.h>
30
31#include <vector>
32#include <assert.h>
33
34#ifdef KDE_IS_VERSION
35#if KDE_IS_VERSION( 3, 1, 0 )
36#define KIG_USE_KDOUBLEVALIDATOR
37#else
38#undef KIG_USE_KDOUBLEVALIDATOR
39#endif
40#else
41#undef KIG_USE_KDOUBLEVALIDATOR
42#endif
43
44class ObjectImp;
45class KigWidget;
46
47extern const double double_inf;
48
54double getDoubleFromUser( const TQString& caption, const TQString& label, double value,
55 TQWidget* parent, bool* ok, double min, double max, int decimals );
56
60class LineData {
61public:
67 LineData() : a(), b() {}
71 LineData( const Coordinate& na, const Coordinate& nb ) : a( na ), b( nb ) {}
83 const Coordinate dir() const { return b - a; }
87 double length() const { return ( b - a ).length(); }
88
92 bool isParallelTo( const LineData& l ) const;
93
97 bool isOrthogonalTo( const LineData& l ) const;
98};
99
103bool operator==( const LineData& l, const LineData& r );
104
109Coordinate calcRotatedPoint( const Coordinate& a, const Coordinate& c, const double arc );
110
115Coordinate calcPointOnPerpend( const LineData& l, const Coordinate& t );
116
121Coordinate calcPointOnPerpend( const Coordinate& dir, const Coordinate& t );
122
127Coordinate calcPointOnParallel( const LineData& l, const Coordinate& t );
128
133Coordinate calcPointOnParallel( const Coordinate& dir, const Coordinate& t );
134
135
139Coordinate calcIntersectionPoint( const LineData& l, const LineData& m );
140
150const Coordinate calcCircleLineIntersect( const Coordinate& c,
151 const double sqr,
152 const LineData& l,
153 int side );
154
164const Coordinate calcArcLineIntersect( const Coordinate& c, const double sqr,
165 const double sa, const double angle,
166 const LineData& l, int side );
167
172const Coordinate calcPointProjection( const Coordinate& p,
173 const LineData& l );
174
178double calcDistancePointLine( const Coordinate& p,
179 const LineData& l );
180
185void calcBorderPoints( Coordinate& p1, Coordinate& p2, const Rect& r );
189void calcBorderPoints( double& xa, double& xb, double& ya, double& yb, const Rect& r);
193const LineData calcBorderPoints( const LineData& l, const Rect& r );
194
198void calcRayBorderPoints( const Coordinate& a, Coordinate& b, const Rect& r );
199
204const Coordinate calcCenter(
205 const Coordinate& a, const Coordinate& b, const Coordinate& c );
206
210void calcRayBorderPoints( const double xa, const double xb, double& ya,
211 double& yb, const Rect& r );
212
216const Coordinate calcMirrorPoint( const LineData& l,
217 const Coordinate& p );
218
222bool areCollinear( const Coordinate& p1, const Coordinate& p2,
223 const Coordinate& p3 );
224
229bool isSingular( const double& a, const double& b,
230 const double& c, const double& d );
231
236bool isOnLine( const Coordinate& o, const Coordinate& a,
237 const Coordinate& b, const double fault );
238
244bool isOnSegment( const Coordinate& o, const Coordinate& a,
245 const Coordinate& b, const double fault );
246
247bool isOnRay( const Coordinate& o, const Coordinate& a,
248 const Coordinate& b, const double fault );
249
250bool isOnArc( const Coordinate& o, const Coordinate& c, const double r,
251 const double sa, const double a, const double fault );
252
253Coordinate calcCircleRadicalStartPoint( const Coordinate& ca,
254 const Coordinate& cb,
255 double sqra, double sqrb );
256
262bool lineInRect( const Rect& r, const Coordinate& a, const Coordinate& b,
263 const int width, const ObjectImp* imp, const KigWidget& w );
264
265template <typename T>
266T kigMin( const T& a, const T& b )
267{
268 return a < b ? a : b;
269}
270
271template <typename T>
272T kigMax( const T& a, const T& b )
273{
274 return a > b ? a : b;
275}
276
277template <typename T>
278T kigAbs( const T& a )
279{
280 return a >= 0 ? a : -a;
281}
282
283template <typename T>
284int kigSgn( const T& a )
285{
286 return a == 0 ? 0 : a > 0 ? +1 : -1;
287}
288
289extern const double test_threshold;
290
291#endif
The Coordinate class is the basic class representing a 2D location by its x and y components.
Definition: coordinate.h:34
Simple class representing a line.
Definition: common.h:60
Coordinate b
Another point on the line.
Definition: common.h:79
const Coordinate dir() const
The direction of the line.
Definition: common.h:83
LineData(const Coordinate &na, const Coordinate &nb)
Constructor.
Definition: common.h:71
bool isOrthogonalTo(const LineData &l) const
Return true if this line is orthogonal to l.
Coordinate a
One point on the line.
Definition: common.h:75
double length() const
The length from a to b.
Definition: common.h:87
bool isParallelTo(const LineData &l) const
Return true if this line is parallel to l.
LineData()
Definition: common.h:67
The Object class represents the behaviour of an object after it is calculated.
Definition: object_imp.h:219
KDE Logo
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Dec 21 2024 20:11:58 by doxygen 1.9.4 written by Dimitri van Heesch, © 1997-2001