1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
// SPDX-FileCopyrightText: 2002 Dominique Devriese <devriese@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common.h"
class ObjectFactory
{
public:
static const ObjectFactory *instance();
/**
* this returns a fixed point. Note that the returned object is
* not added to the document.
*/
ObjectHolder *fixedPoint(const Coordinate &c) const;
ObjectTypeCalcer *fixedPointCalcer(const Coordinate &c) const;
/**
* this returns a numeric label with the value \p value at the position
* \p loc . Note that the returned object is not added to the document
* but calced already.
*/
ObjectHolder *numericValue(const double value, const Coordinate &loc, const KigDocument &doc) const;
ObjectTypeCalcer *numericValueCalcer(const double value, const Coordinate &loc, const KigDocument &doc) const;
/**
* this returns a CursorPointType; this is used during special
* constructions (e.g. regular polygons) where the constructor
* wants to use the cursor position without actually generating
* an object depending on a new point there.
*/
ObjectTypeCalcer *cursorPointCalcer(const Coordinate &c) const;
/**
* this returns a relative point (to an object). Note that the returned object
* is not added to the document.
*/
ObjectTypeCalcer *relativePointCalcer(ObjectCalcer *o, const Coordinate &loc) const;
/**
* this returns a constrained point. Note that the returned object
* is not added to the document.
*/
ObjectHolder *constrainedPoint(ObjectCalcer *curve, double param) const;
ObjectTypeCalcer *constrainedPointCalcer(ObjectCalcer *curve, double param) const;
/**
* overload, changes nothing to the semantics, only calcs the param
* value for you.
*/
ObjectTypeCalcer *constrainedPointCalcer(ObjectCalcer *curve, const Coordinate &c, const KigDocument &) const;
ObjectHolder *constrainedPoint(ObjectCalcer *curve, const Coordinate &c, const KigDocument &) const;
ObjectTypeCalcer *constrainedRelativePointCalcer(ObjectCalcer *curve, double param) const;
/**
* this returns a "sensible point".
* By a "sensible point", I mean a point that would be about what
* the user expects when he asks for a point at point \p c . This is a
* constrained point if \p c is on a curve, and otherwise a fixed
* point. I might add the possibility for an intersection point
* sometime. Note that the returned object is not added to
* the document.
*/
ObjectTypeCalcer *sensiblePointCalcer(const Coordinate &c, const KigDocument &d, const KigWidget &w) const;
ObjectHolder *sensiblePoint(const Coordinate &c, const KigDocument &d, const KigWidget &w) const;
/**
* set point to what sensiblePoint would have returned.
*/
void redefinePoint(ObjectTypeCalcer *point, const Coordinate &c, KigDocument &d, const KigWidget &w) const;
/**
* return a locus, defined by the two points ( one constrained, and
* one following ) \p a and \p b . \p a should be the constrained point,
* and thus, it has to be of type ObjectTypeCalcer where a->type() is of
* type ConstrainedPointType. The semantics of LocusType are a bit
* weird ( but I believe correct :) ), so this function takes care
* of the complication there.
*/
ObjectTypeCalcer *locusCalcer(ObjectCalcer *a, ObjectCalcer *b) const;
ObjectHolder *locus(ObjectCalcer *a, ObjectCalcer *b) const;
/**
* returns a label with text \p s at point \p c .. It ( and its parents )
* is calced already.
*/
ObjectHolder *label(const QString &s, const Coordinate &loc, bool needframe, const std::vector<ObjectCalcer *> &parents, const KigDocument &doc) const;
ObjectTypeCalcer *
labelCalcer(const QString &s, const Coordinate &loc, bool needframe, const std::vector<ObjectCalcer *> &parents, const KigDocument &doc) const;
/**
* this one does the same as the above, only that the new label is
* attached to locationparent if it is non-null.
*/
ObjectTypeCalcer *attachedLabelCalcer(const QString &s,
ObjectCalcer *locationparent,
const Coordinate &loc,
bool needframe,
const std::vector<ObjectCalcer *> &parents,
const KigDocument &doc) const;
/**
* this has been added because it comes handy when redefining
* a text label, we move here all the code for getting an
* attach point from the method above
*/
ObjectCalcer *getAttachPoint(ObjectCalcer *locationparent, const Coordinate &loc, const KigDocument &doc) const;
ObjectHolder *attachedLabel(const QString &s,
ObjectCalcer *locationparent,
const Coordinate &loc,
bool needframe,
const std::vector<ObjectCalcer *> &parents,
const KigDocument &doc) const;
/**
* returns a property object for the property \p p of object \p o .
*
* \note
* \p o should have already been calc'd, or this will fail and
* return 0. The returned object also needs to be calced after
* this.
*/
ObjectPropertyCalcer *propertyObjectCalcer(ObjectCalcer *o, const char *p) const;
ObjectHolder *propertyObject(ObjectCalcer *o, const char *p) const;
};
|