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 
44 class ObjectImp;
45 class KigWidget;
46 
47 extern const double double_inf;
48 
54 double getDoubleFromUser( const TQString& caption, const TQString& label, double value,
55  TQWidget* parent, bool* ok, double min, double max, int decimals );
56 
60 class LineData {
61 public:
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 
103 bool operator==( const LineData& l, const LineData& r );
104 
109 Coordinate calcRotatedPoint( const Coordinate& a, const Coordinate& c, const double arc );
110 
115 Coordinate calcPointOnPerpend( const LineData& l, const Coordinate& t );
116 
121 Coordinate calcPointOnPerpend( const Coordinate& dir, const Coordinate& t );
122 
127 Coordinate calcPointOnParallel( const LineData& l, const Coordinate& t );
128 
133 Coordinate calcPointOnParallel( const Coordinate& dir, const Coordinate& t );
134 
135 
139 Coordinate calcIntersectionPoint( const LineData& l, const LineData& m );
140 
150 const Coordinate calcCircleLineIntersect( const Coordinate& c,
151  const double sqr,
152  const LineData& l,
153  int side );
154 
164 const Coordinate calcArcLineIntersect( const Coordinate& c, const double sqr,
165  const double sa, const double angle,
166  const LineData& l, int side );
167 
172 const Coordinate calcPointProjection( const Coordinate& p,
173  const LineData& l );
174 
178 double calcDistancePointLine( const Coordinate& p,
179  const LineData& l );
180 
185 void calcBorderPoints( Coordinate& p1, Coordinate& p2, const Rect& r );
189 void calcBorderPoints( double& xa, double& xb, double& ya, double& yb, const Rect& r);
193 const LineData calcBorderPoints( const LineData& l, const Rect& r );
194 
198 void calcRayBorderPoints( const Coordinate& a, Coordinate& b, const Rect& r );
199 
204 const Coordinate calcCenter(
205  const Coordinate& a, const Coordinate& b, const Coordinate& c );
206 
210 void calcRayBorderPoints( const double xa, const double xb, double& ya,
211  double& yb, const Rect& r );
212 
216 const Coordinate calcMirrorPoint( const LineData& l,
217  const Coordinate& p );
218 
222 bool areCollinear( const Coordinate& p1, const Coordinate& p2,
223  const Coordinate& p3 );
224 
229 bool isSingular( const double& a, const double& b,
230  const double& c, const double& d );
231 
236 bool isOnLine( const Coordinate& o, const Coordinate& a,
237  const Coordinate& b, const double fault );
238 
244 bool isOnSegment( const Coordinate& o, const Coordinate& a,
245  const Coordinate& b, const double fault );
246 
247 bool isOnRay( const Coordinate& o, const Coordinate& a,
248  const Coordinate& b, const double fault );
249 
250 bool isOnArc( const Coordinate& o, const Coordinate& c, const double r,
251  const double sa, const double a, const double fault );
252 
253 Coordinate calcCircleRadicalStartPoint( const Coordinate& ca,
254  const Coordinate& cb,
255  double sqra, double sqrb );
256 
262 bool lineInRect( const Rect& r, const Coordinate& a, const Coordinate& b,
263  const int width, const ObjectImp* imp, const KigWidget& w );
264 
265 template <typename T>
266 T kigMin( const T& a, const T& b )
267 {
268  return a < b ? a : b;
269 }
270 
271 template <typename T>
272 T kigMax( const T& a, const T& b )
273 {
274  return a > b ? a : b;
275 }
276 
277 template <typename T>
278 T kigAbs( const T& a )
279 {
280  return a >= 0 ? a : -a;
281 }
282 
283 template <typename T>
284 int kigSgn( const T& a )
285 {
286  return a == 0 ? 0 : a > 0 ? +1 : -1;
287 }
288 
289 extern 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.
KDE Logo
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed May 15 2024 03:39:42 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2001