kig
#include <object_calcer.h>
![Inheritance graph](classObjectCalcer__inherit__graph.png)
Public Types | |
typedef myboost::intrusive_ptr < ObjectCalcer > | shared_ptr |
Public Member Functions | |
virtual | ~ObjectCalcer () |
void | addChild (ObjectCalcer *c) |
virtual void | calc (const KigDocument &)=0 |
virtual bool | canMove () const |
std::vector< ObjectCalcer * > | children () const |
void | delChild (ObjectCalcer *c) |
virtual const ObjectImp * | imp () const =0 |
virtual const ObjectImpType * | impRequirement (ObjectCalcer *o, const std::vector< ObjectCalcer * > &os) const =0 |
virtual bool | isDefinedOnOrThrough (const ObjectCalcer *o) const =0 |
virtual bool | isFreelyTranslatable () const |
virtual std::vector < ObjectCalcer * > | movableParents () const |
virtual void | move (const Coordinate &to, const KigDocument &doc) |
virtual Coordinate | moveReferencePoint () const |
virtual std::vector < ObjectCalcer * > | parents () const =0 |
Protected Member Functions | |
ObjectCalcer () | |
void | deref () |
void | ref () |
Protected Attributes | |
std::vector< ObjectCalcer * > | mchildren |
int | refcount |
Friends | |
void | intrusive_ptr_add_ref (ObjectCalcer *p) |
void | intrusive_ptr_release (ObjectCalcer *p) |
Detailed Description
An ObjectCalcer is an object that represents an algorithm for calculating an ObjectImp from other ObjectImp's.
It is also a node in the dependency graph of a certain document. E.g. a LineImp can be calculated from the two PointImp's it has to go through; every time either of them moves, this calculation is redone. In this case, there would be an ObjectCalcer that keeps a reference to its two parents ( the ObjectCalcer's representing the points ), and that will calculate its ObjectImp value every time it is asked to do so ( i.e. every time one of its parents moves ).
Each ObjectHolder keeps its ObjectImp itself, and recalculates it from its parents in its calc() method ( if necessary ).
Because of the complex relations that ObjectCalcer's hold to other ObjectCalcer's and to other classes, they have been made reference-counted. This means that they keep a count internally of how much times a pointer to them is held. If this count reaches 0, this means that nobody needs them anymore, and they delete themselves. E.g. an ObjectCalcer always keeps a reference to its parents, to ensure that those aren't deleted before it is deleted.
At runtime, there will be an entire graph of ObjectCalcer that depend on their parents. At the bottom, there are Calcer's that the user is aware of, and that are held by ObjectHolder's. At the top, there are Calcer's without parents that serve only to hold some data. Those are most likely ObjectConstCalcer's. There are some algorithms to work with the dependency graph in various ways in ../misc/calcpath.h
ObjectCalcer's also decide how an object should be allowed to move. If the user selects a point, and tries to move it, then its ObjectCalcer will be asked whether it can move, and if so, will be asked to move. See below with the canMove(), move() and moveReferencePoint() methods.
Definition at line 66 of file object_calcer.h.
Member Typedef Documentation
Definition at line 101 of file object_calcer.h.
Constructor & Destructor Documentation
|
protected |
Definition at line 311 of file object_calcer.cc.
|
virtual |
Definition at line 51 of file object_calcer.cc.
Member Function Documentation
void ObjectCalcer::addChild | ( | ObjectCalcer * | c | ) |
a calcer should call this to register itself as a child of this calcer.
This automatically takes a reference.
Definition at line 110 of file object_calcer.cc.
|
pure virtual |
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
Implemented in ObjectPropertyCalcer, ObjectConstCalcer, ObjectTypeCalcer, and MeasureTransportCalcer.
|
virtual |
Returns whether this ObjectCalcer supports moving.
Reimplemented in ObjectTypeCalcer.
Definition at line 260 of file object_calcer.cc.
std::vector< ObjectCalcer * > ObjectCalcer::children | ( | ) | const |
Returns the child ObjectCalcer's of this ObjectCalcer.
Definition at line 209 of file object_calcer.cc.
void ObjectCalcer::delChild | ( | ObjectCalcer * | c | ) |
a calcer should call this in its destructor, to inform its parent that it is no longer a child of this calcer.
This will release the reference taken in addChild.
Definition at line 116 of file object_calcer.cc.
|
protected |
Definition at line 85 of file object_calcer.cc.
|
pure virtual |
Returns the ObjectImp of this ObjectCalcer.
Implemented in ObjectPropertyCalcer, ObjectConstCalcer, and ObjectTypeCalcer.
|
pure virtual |
An ObjectCalcer expects its parents to have an ObjectImp of a certain type.
This method returns the ObjectImpType that o
should have. os
is a list of all the parents in order, and o
is part of it. This method will return the ObjectImpType that the parent should at least be. For example, a Translated object can translate any sort of object, so it will return ObjectImp::stype() here ( the topmost ObjectImpType, that all other ObjectImpType's inherit ).
Implemented in ObjectPropertyCalcer, ObjectConstCalcer, ObjectTypeCalcer, and MeasureTransportCalcer.
|
pure virtual |
If this ObjectCalcer represents a curve, return true if the given point is by construction on this curve.
If this ObjectCalcer represents a point, return true if this point is by construction on the given curve.
Implemented in ObjectPropertyCalcer, ObjectConstCalcer, and ObjectTypeCalcer.
|
virtual |
Returns whether this ObjectCalcer can be translated at any position in the coordinate plane.
Note that a ConstrainedPointType can be moved, but cannot be moved everywhere.
Reimplemented in ObjectTypeCalcer.
Definition at line 265 of file object_calcer.cc.
|
virtual |
Moving an object most of the time signifies invoking changes in some of its parents.
This method returns the set of parents that will be changed in the move() method. The object itself should not be included.
Reimplemented in ObjectTypeCalcer.
Definition at line 316 of file object_calcer.cc.
|
virtual |
This is the method that does the real moving work.
It will be invoked to tell the object to move to the new location to. After this, the calc() method will be calced, so you only need to do the real changes in this method, updating the ObjectImp should be done in the calc() method, not here.
Reimplemented in ObjectTypeCalcer.
Definition at line 276 of file object_calcer.cc.
|
virtual |
In order to support simultaneously moving objects that are in different locations, we need for each object a location that it is assumed to be at, at the moment the moving starts.
This method returns such a point.
Reimplemented in ObjectTypeCalcer.
Definition at line 270 of file object_calcer.cc.
|
pure virtual |
Returns the parent ObjectCalcer's of this ObjectCalcer.
Implemented in ObjectPropertyCalcer, ObjectConstCalcer, ObjectTypeCalcer, and MeasureTransportCalcer.
|
protected |
Definition at line 80 of file object_calcer.cc.
Friends And Related Function Documentation
|
friend |
ObjectCalcer's are reference counted.
They all take a reference to their parents, and some other classes like ObjectHolder take a reference to some ObjectCalcer's that they don't want to see deleted.
Definition at line 90 of file object_calcer.cc.
|
friend |
Definition at line 95 of file object_calcer.cc.
Member Data Documentation
|
protected |
Definition at line 84 of file object_calcer.h.
|
protected |
Definition at line 77 of file object_calcer.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.