1 // Copyright (C) 2003 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_LOCUS_IMP_H
19 #define KIG_OBJECTS_LOCUS_IMP_H
21 #include "curve_imp.h"
22 #include "../misc/object_hierarchy.h"
25 * LocusImp is an imp that consists of a copy of the curveimp that the
26 * moving point moves over, and an ObjectHierarchy that can calc (
27 * given a point, and optionally some more parent objects the position
28 * of the moving point. The hierarchy should take the moving point as
29 * its *first* argument and all others after that. The others are
30 * used to make it possible for Locus to be updated when some of the
31 * other objects that appear in the path from the moving point to the
32 * dependent point change.
34 * This may seem rather complicated, but I think it is absolutely
35 * necessary to support locuses using Kig's object system. It would
36 * be very bad for LocusImp to have to keep references to its parents
37 * as Objects ( since only the objects know how they are related to
38 * their parents ). This is how we used to do it, but the current
39 * method is far superior. First and foremost because the separation
40 * between ObjectImp and Object is something that Kig depends on very
41 * much, and because every ObjectImp should contain all the data it
42 * needs itself. ObjectImp's are entirely independent objects.
43 * That's also why we don't keep a pointer to the old CurveImp, but a
46 * i hope this is a bit clear, if not, feel free to ask for
47 * explanation of what you don't understand..
53 const ObjectHierarchy mhier
;
55 double getDist(double param
, const Coordinate
& p
, const KigDocument
& doc
) const;
56 void getInterval(double& x1
,double& x2
,double incr
,const Coordinate
& p
, const KigDocument
& doc
) const;
57 double getParamofmin(double a
, double b
, const Coordinate
& p
, const KigDocument
& doc
) const;
59 typedef CurveImp Parent
;
60 static const ObjectImpType
* stype();
62 LocusImp( CurveImp
*, const ObjectHierarchy
& );
64 LocusImp
* copy() const;
66 ObjectImp
* transform( const Transformation
& ) const;
68 void draw( KigPainter
& p
) const;
69 bool contains( const Coordinate
& p
, int width
, const KigWidget
& ) const;
70 Rect
surroundingRect() const;
71 bool inRect( const Rect
& r
, int width
, const KigWidget
& ) const;
72 double getParam( const Coordinate
& point
, const KigDocument
& ) const;
73 const Coordinate
getPoint( double param
, const KigDocument
& ) const;
76 const uint
numberOfProperties() const;
77 const QCStringList
properties() const;
78 const QCStringList
propertiesInternalNames() const;
79 ObjectImp
* property( uint which
, const KigDocument
& w
) const;
80 const char* iconForProperty( uint which
) const;
81 const ObjectImpType
* impRequirementForProperty( uint which
) const;
82 bool isPropertyDefinedOnOrThroughThisImp( uint which
) const;
84 const CurveImp
* curve() const;
85 const ObjectHierarchy
& hierarchy() const;
87 const ObjectImpType
* type() const;
88 void visit( ObjectImpVisitor
* vtor
) const;
90 bool equals( const ObjectImp
& rhs
) const;
92 bool containsPoint( const Coordinate
& p
, const KigDocument
& d
) const;
93 bool internalContainsPoint( const Coordinate
& p
, double threshold
, const KigDocument
& doc
) const;