Okular
annotations.cpp
36 static bool isLeftOfVector(const NormalizedPoint &a, const NormalizedPoint &b, const NormalizedPoint &c)
47 static double distanceSqr(double x, double y, double xScale, double yScale, const QList<NormalizedPoint> &path)
82 * In other words, this approximation will estimate the distance to be slightly more than it actually is
83 * for as long as we are far "outside" the line, becoming more accurate the closer we get to the line
84 * boundary. Trivially, it also fulfils (a1 < a2) => ((a1^2 - b^2) < (a2^2 - b^2)) making it monotonic.
131 void AnnotationUtils::storeAnnotation(const Annotation *ann, QDomElement &annElement, QDomDocument &document)
155 QRect AnnotationUtils::annotationGeometry(const Annotation *annotation, double scaleX, double scaleY)
157 const QRect rect = annotation->transformedBoundingRectangle().geometry((int)scaleX, (int)scaleY);
158 if (annotation->subType() == Annotation::AText && (((TextAnnotation *)annotation)->textType() == TextAnnotation::Linked)) {
161 const QRect rect24 = QRect((int)(annotation->transformedBoundingRectangle().left * scaleX), (int)(annotation->transformedBoundingRectangle().top * scaleY), 24, 24);
174 const QString stampFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/stamps.svg"));
186 const QSize pixmapSize = stampSize.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio);
203 pixmap = pixmap.scaled(size, size, keepAspectRatio ? Qt::KeepAspectRatioByExpanding : Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
822 e.setAttribute(QStringLiteral("flags"), d->m_flags & ~(External | ExternallyDrawn | BeingMoved | BeingResized));
840 if (d->m_style.width() != 1 || d->m_style.lineStyle() != Solid || d->m_style.xCorners() != 0 || d->m_style.yCorners() != 0.0 || d->m_style.marks() != 3 || d->m_style.spaces() != 0) {
860 if (d->m_window.flags() != -1 || !d->m_window.title().isEmpty() || !d->m_window.summary().isEmpty()) {
904 const int internalFlags = d_ptr->m_flags & (External | ExternallyDrawn | BeingMoved | BeingResized);
959 void AnnotationPrivate::adjust(const NormalizedPoint &deltaCoord1, const NormalizedPoint &deltaCoord2)
961 m_boundary.left = m_boundary.left + qBound(-m_boundary.left, deltaCoord1.x, m_boundary.right - m_boundary.left);
962 m_boundary.top = m_boundary.top + qBound(-m_boundary.top, deltaCoord1.y, m_boundary.bottom - m_boundary.top);
964 m_boundary.right = m_boundary.right + qBound(m_boundary.left - m_boundary.right, deltaCoord2.x, 1. - m_boundary.right);
965 m_boundary.bottom = m_boundary.bottom + qBound(m_boundary.top - m_boundary.bottom, deltaCoord2.y, 1. - m_boundary.bottom);
995 m_creationDate = QDateTime::fromString(e.attribute(QStringLiteral("creationDate")), Qt::ISODate);
1018 m_boundary = NormalizedRect(ee.attribute(QStringLiteral("l")).toDouble(), ee.attribute(QStringLiteral("t")).toDouble(), ee.attribute(QStringLiteral("r")).toDouble(), ee.attribute(QStringLiteral("b")).toDouble());
1037 m_window.setTopLeft(NormalizedPoint(ee.attribute(QStringLiteral("top")).toDouble(), ee.attribute(QStringLiteral("left")).toDouble()));
1055 revision.setScope((Annotation::RevisionScope)revElement.attribute(QStringLiteral("revScope")).toInt());
1056 revision.setType((Annotation::RevisionType)revElement.attribute(QStringLiteral("revType")).toInt());
1319 return (m_textType == Okular::TextAnnotation::Linked) || (m_inplaceIntent == TextAnnotation::InplaceIntent::Unknown);
1352 m_inplaceIntent = (TextAnnotation::InplaceIntent)e.attribute(QStringLiteral("intent")).toInt();
1604 QList<NormalizedPoint>::const_iterator it = d->m_linePoints.begin(), end = d->m_linePoints.end();
1670 m_lineStartStyle = (LineAnnotation::TermStyle)e.attribute(QStringLiteral("startStyle")).toInt();
1722 double LineAnnotationPrivate::distanceSqr(double x, double y, double xScale, double yScale) const
1741 return strokeDistance(::distanceSqr(x, y, xScale, yScale, transformedLinePoints), m_style.width() * xScale / (m_page->m_width * 2));
1864 double GeomAnnotationPrivate::distanceSqr(double x, double y, double xScale, double yScale) const
1887 const double lambda = sqrt(focusXSqr * focusYSqr / (focusYSqr * pow(x - centerX, 2) + focusXSqr * pow(y - centerY, 2)));
1913 const QList<NormalizedPoint> edges = {NormalizedPoint(m_transformedBoundary.left, m_transformedBoundary.top),
2181 m_highlightType = (HighlightAnnotation::HighlightType)e.attribute(QStringLiteral("type")).toInt();
2193 q.setPoint(NormalizedPoint(qe.attribute(QStringLiteral("ax"), QStringLiteral("0.0")).toDouble(), qe.attribute(QStringLiteral("ay"), QStringLiteral("0.0")).toDouble()), 0);
2194 q.setPoint(NormalizedPoint(qe.attribute(QStringLiteral("bx"), QStringLiteral("0.0")).toDouble(), qe.attribute(QStringLiteral("by"), QStringLiteral("0.0")).toDouble()), 1);
2195 q.setPoint(NormalizedPoint(qe.attribute(QStringLiteral("cx"), QStringLiteral("0.0")).toDouble(), qe.attribute(QStringLiteral("cy"), QStringLiteral("0.0")).toDouble()), 2);
2196 q.setPoint(NormalizedPoint(qe.attribute(QStringLiteral("dx"), QStringLiteral("0.0")).toDouble(), qe.attribute(QStringLiteral("dy"), QStringLiteral("0.0")).toDouble()), 3);
2216 double HighlightAnnotationPrivate::distanceSqr(double x, double y, double xScale, double yScale) const
2224 // this is the case, if the point is always on one side of each segments delimiting the polygon:
2418 QList<QList<NormalizedPoint>>::const_iterator pIt = d->m_inkPaths.begin(), pEnd = d->m_inkPaths.end();
void append(const T &value)
T & first()
KDOCTOOLS_EXPORT QString transform(const QString &file, const QString &stylesheet, const QVector< const char * > ¶ms=QVector< const char * >())
double distanceSqr(double x, double y, double xScale, double yScale) const
Returns squared distance to normalized point (x, y) on a reference area of size xScale x yScale.
Definition: area.cpp:51
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the movie annotation as xml in document under the given parentNode.
Definition: annotations.cpp:2920
void setAnnotation(Annotation *annotation)
Sets the annotation the revision belongs to.
Definition: annotations.cpp:519
QDomNode getAnnotationPropertiesDomNode() const
Retrieve the QDomNode representing this annotation's properties.
Definition: annotations.cpp:890
void setCapEnd(bool value)
Sets whether a cap should be used at the end.
Definition: annotations.cpp:2014
void setSoundIconName(const QString &iconName)
Sets the iconName of the icon for the sound annotation.
Definition: annotations.cpp:2843
@ ExternallyDrawn
Is drawn externally (by the generator which provided it)
Definition: annotations.h:139
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the rich media annotation as xml in document under the given parentNode.
Definition: annotations.cpp:3212
QDomNode firstChild() const const
QDomElement toElement() const const
void render(QPainter *painter)
QString number(int n, int base)
bool containsPoint(const QPointF &point, Qt::FillRule fillRule) const const
void setAuthor(const QString &author)
Sets the author of the annotation.
Definition: annotations.cpp:593
QString tagName() const const
NormalizedRect boundingRectangle() const
Returns the bounding rectangle of the annotation.
Definition: annotations.cpp:675
SubType subType() const override
Returns the sub type of the screen annotation.
Definition: annotations.cpp:3020
Type type(const QSqlDatabase &db)
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:95
static void storeAnnotation(const Annotation *annotation, QDomElement &element, QDomDocument &document)
Saves the annotation as a child of element taking care of saving all revisions if it has any.
Definition: annotations.cpp:131
void adjust(const NormalizedPoint &deltaCoord1, const NormalizedPoint &deltaCoord2)
Adjust the annotation by the specified coordinates.
Definition: annotations.cpp:697
int count(const T &value) const const
bool isNull() const const
QList< Revision > & revisions()
Returns a reference to the revision list of the annotation.
Definition: annotations.cpp:737
void append(const T &value)
SubType subType() const override
Returns the sub type of the sound annotation.
Definition: annotations.cpp:2832
void setAdditionalAction(AdditionalActionType type, Action *action)
Sets the additional action of the given type.
Definition: annotations.cpp:3128
void store(QDomNode &node, QDomDocument &document) const override
Stores the sound annotation as xml in document under the given parent node.
Definition: annotations.cpp:2822
QIcon fromTheme(const QString &name)
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:116
void fill(const QColor &color)
SubType subType() const override
Returns the sub type of the rich media annotation.
Definition: annotations.cpp:3222
bool isValid() const const
QDomElement createElement(const QString &tagName)
QRect united(const QRect &rectangle) const const
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
bool capStart() const
Returns whether a cap should be used at the start.
Definition: annotations.cpp:2009
bool exists() const const
void setCreationDate(const QDateTime &date)
Sets the creation date of the annotation.
Definition: annotations.cpp:641
void setAdditionalAction(AdditionalActionType type, Action *action)
Sets the additional action of the given type.
Definition: annotations.cpp:3025
void setAnnotationProperties(const QDomNode &node)
Sets annotations internal properties according to the contents of node.
Definition: annotations.cpp:899
The Style class contains all information about style of the annotation.
Definition: annotations.h:320
bool elementExists(const QString &id) const const
void setSound(Sound *s)
Sets the s representing the sound of the file attachment annotation.
Definition: annotations.cpp:2855
Action * action() const
Returns the action that is executed when the annotation is triggered or 0 if not action has been defi...
Definition: annotations.cpp:3053
void setAttribute(const QString &name, const QString &value)
QRect geometry(int xScale, int yScale) const
Returns the rectangle mapped to a reference area of xScale x yScale.
Definition: area.cpp:232
NormalizedPoint transformedPoint(int index) const
Returns the transformed (e.g.
Definition: annotations.cpp:1995
void setEmbeddedFile(EmbeddedFile *embeddedFile)
Sets the embeddedFile representing the embedded file.
Definition: annotations.cpp:3249
bool end()
QString::const_iterator constBegin() const const
KeepAspectRatioByExpanding
void setPoint(const NormalizedPoint &point, int index)
Sets the normalized point at index.
Definition: annotations.cpp:1977
WindingFill
KOSM_EXPORT double distance(const std::vector< const OSM::Node * > &path, Coordinate coord)
void(* DisposeDataFunction)(const Okular::Annotation *)
A function to be called when the annotation is destroyed.
Definition: annotations.h:209
void setTopLeft(const NormalizedPoint &point)
Sets the top-left point of the window.
Definition: annotations.cpp:429
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the screen annotation as xml in document under the given parentNode.
Definition: annotations.cpp:3010
The Revision class contains all information about the revision of the annotation.
Definition: annotations.h:550
bool isEmpty() const const
void setAction(Action *action)
Sets the action that is executed when the annotation is triggered.
Definition: annotations.cpp:3045
Style & style()
Returns a reference to the style object of the annotation.
Definition: annotations.cpp:713
Window & window()
Returns a reference to the window object of the annotation.
Definition: annotations.cpp:725
void setBoundingRectangle(const NormalizedRect &rectangle)
Sets the bounding rectangle of the annotation.
Definition: annotations.cpp:665
QSize toSize() const const
QRectF boundsOnElement(const QString &id) const const
int toInt(bool *ok, int base) const const
void setDisposeDataFunction(DisposeDataFunction func)
Sets a function to be called when the annotation is destroyed.
Definition: annotations.cpp:761
void setUniqueName(const QString &name)
Sets the unique name of the annotation.
Definition: annotations.cpp:617
void setCapStart(bool value)
Sets whether a cap should be used at the start.
Definition: annotations.cpp:2004
HexArgb
QString::const_iterator constEnd() const const
QDateTime fromString(const QString &string, Qt::DateFormat format)
A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.
Definition: area.h:188
NormalizedPoint point(int index) const
Returns the normalized point at index.
Definition: annotations.cpp:1986
static QRect annotationGeometry(const Annotation *annotation, double scaleX, double scaleY)
Returns the geometry of the given annotation scaled by scaleX and scaleY.
Definition: annotations.cpp:155
T & back()
double toDouble(bool *ok) const const
QDateTime creationDate() const
Returns the creation date of the annotation.
Definition: annotations.cpp:647
@ BeingMoved
Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it.
Definition: annotations.h:140
void setLineEffect(LineEffect effect)
Sets the line effect of the style.
Definition: annotations.cpp:356
static Annotation * createAnnotation(const QDomElement &element)
Restore an annotation (with revisions if needed) from the dom element.
Definition: annotations.cpp:93
void store(QDomNode &parentNode, QDomDocument &document) const override
Stores the widget annotation as xml in document under the given parentNode.
Definition: annotations.cpp:3113
void setEffectIntensity(double intensity)
Sets the effect intensity of the style.
Definition: annotations.cpp:366
bool isNull() const const
bool load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
QString toLower() const const
Action * additionalAction(AdditionalActionType type) const
Returns the additional action of the given type or 0 if no action has been defined.
Definition: annotations.cpp:3138
bool hasAttribute(const QString &name) const const
QPixmap scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
GenericDataLocation
void setSummary(const QString &summary)
Sets the summary of the window.
Definition: annotations.cpp:469
SubType subType() const override
Returns the sub type of the widget annotation.
Definition: annotations.cpp:3123
int count() const const
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) const const
void transform(const QTransform &matrix)
Transforms the normalized rectangle with the operations defined by matrix.
Definition: area.cpp:253
Describes a highlight quad of a text markup annotation.
Definition: annotations.h:1172
QDomNode appendChild(const QDomNode &newChild)
NormalizedPoint topLeft() const
Returns the top-left point of the window.
Definition: annotations.cpp:434
QString path(const QString &relativePath)
The Window class contains all information about the popup window of the annotation that is used to ed...
Definition: annotations.h:455
QFont font()
static QPixmap loadStamp(const QString &nameOrPath, int size, bool keepAspectRatio=true)
Returns a pixmap for a stamp symbol.
Definition: annotations.cpp:168
QSize scaled(int width, int height, Qt::AspectRatioMode mode) const const
const char * name(StandardAction id)
@ BeingResized
Is being resized (mouse drag and drop). If ExternallyDrawn, the generator must not draw it.
Definition: annotations.h:141
NormalizedRect transformedBoundingRectangle() const
Returns the transformed bounding rectangle of the annotation.
Definition: annotations.cpp:681
SubType subType() const override
Returns the sub type of the movie annotation.
Definition: annotations.cpp:2930
QDomNode nextSibling() const const
QList::iterator begin()
QSizeF size() const const
virtual void store(QDomNode &node, QDomDocument &document) const
Stores the annotation as xml in document under the given parent node.
Definition: annotations.cpp:796
void setNativeId(const QVariant &id)
Sets the "native" id of the annotation.
Definition: annotations.cpp:749
bool openDialogAfterCreation() const
Returns whether the annotation dialog should be open after creation of the annotation or not.
Definition: annotations.cpp:707
QString attribute(const QString &name, const QString &defValue) const const
QDateTime modificationDate() const
Returns the last modification date of the annotation.
Definition: annotations.cpp:635
double effectIntensity() const
Returns the effect intensity of the style.
Definition: annotations.cpp:371
bool isElement() const const
SmoothTransformation
void setContents(const QString &contents)
Sets the contents of the annotation.
Definition: annotations.cpp:605
void setModificationDate(const QDateTime &date)
Sets the last modification date of the annotation.
Definition: annotations.cpp:629
virtual SubType subType() const =0
Returns the sub type of the annotation.
QDomCDATASection toCDATASection() const const
const QList< QKeySequence > & end()
QString & append(QChar ch)
transparent
static QDomElement findChildElement(const QDomNode &parentNode, const QString &name)
Returns the child element with the given name from the direct children of parentNode or a null elemen...
Definition: annotations.cpp:140
bool canBeResized() const
Returns whether the annotation can be resized.
Definition: annotations.cpp:784
ISODate
Q_D(Todo)
virtual QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
Action * additionalAction(AdditionalActionType type) const
Returns the additional action of the given type or 0 if no action has been defined.
Definition: annotations.cpp:3035
Annotation * annotation() const
Returns the annotation the revision belongs to.
Definition: annotations.cpp:524
void translate(const NormalizedPoint &coord)
Move the annotation by the specified coordinates.
Definition: annotations.cpp:687
QString data() const const
void transform(const QTransform &matrix)
Transforms the quad coordinates with the transformation defined by matrix.
Definition: annotations.cpp:2034
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:53:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:53:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.