2005-07-15 18:20:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004-05 by Enrico Ros <eros.kde@email.it> *
|
|
|
|
* Copyright (C) 2005 by Piotr Szymanski <niedakh@gmail.com> *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#ifndef _OKULAR_AREA_H_
|
|
|
|
#define _OKULAR_AREA_H_
|
|
|
|
|
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtGui/QColor>
|
|
|
|
#include <QtGui/QPainterPath>
|
2007-07-30 23:58:04 +00:00
|
|
|
#include <kdebug.h>
|
2006-09-21 08:45:36 +00:00
|
|
|
|
2011-06-01 08:31:44 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "okular_export.h"
|
2006-09-21 08:45:36 +00:00
|
|
|
|
2006-10-28 18:03:33 +00:00
|
|
|
class QPolygonF;
|
2005-07-15 18:20:57 +00:00
|
|
|
class QRect;
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
namespace Okular {
|
|
|
|
|
|
|
|
class Annotation;
|
2007-04-20 12:37:12 +00:00
|
|
|
class Action;
|
2006-03-20 22:40:11 +00:00
|
|
|
class NormalizedShape;
|
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
/**
|
2006-11-27 08:05:56 +00:00
|
|
|
* NormalizedPoint is a helper class which stores the coordinates
|
|
|
|
* of a normalized point. Normalized means that the coordinates are
|
|
|
|
* between 0 and 1 so that it is page size independent.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* The normalized point is (0.5, 0.3)
|
|
|
|
*
|
|
|
|
* If you want to draw it on a 800x600 page, just multiply the x coordinate (0.5) with
|
|
|
|
* the page width (800) and the y coordinate (0.3) with the page height (600), so
|
|
|
|
* the point will be drawn on the page at (400, 180).
|
|
|
|
*
|
|
|
|
* That allows you to zoom the page by just multiplying the normalized points with the
|
|
|
|
* zoomed page size.
|
2005-07-15 18:20:57 +00:00
|
|
|
*/
|
2006-05-08 20:12:04 +00:00
|
|
|
class OKULAR_EXPORT NormalizedPoint
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Creates a new empty normalized point.
|
|
|
|
*/
|
2005-07-15 18:20:57 +00:00
|
|
|
NormalizedPoint();
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Creates a new normalized point with the normalized coordinates (@p x, @p y ).
|
|
|
|
*/
|
|
|
|
NormalizedPoint( double x, double y );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new normalized point with the coordinates (@p x, @p y) which are normalized
|
|
|
|
* by the scaling factors @p xScale and @p yScale.
|
|
|
|
*/
|
|
|
|
NormalizedPoint( int x, int y, int xScale, int yScale );
|
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
NormalizedPoint& operator=( const NormalizedPoint& );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the normalized point with the operations defined by @p matrix.
|
|
|
|
*/
|
2006-11-20 07:53:32 +00:00
|
|
|
void transform( const QMatrix &matrix );
|
2006-11-27 08:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The normalized x coordinate.
|
|
|
|
*/
|
|
|
|
double x;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The normalized y coordinate.
|
|
|
|
*/
|
|
|
|
double y;
|
2005-07-15 18:20:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2006-11-27 08:05:56 +00:00
|
|
|
* NormalizedRect is a helper class which stores the coordinates
|
|
|
|
* of a normalized rect, which is a rectangle of @see NormalizedPoints.
|
2005-07-15 18:20:57 +00:00
|
|
|
*/
|
2006-05-08 20:12:04 +00:00
|
|
|
class OKULAR_EXPORT NormalizedRect
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Creates a null normalized rectangle.
|
|
|
|
* @see isNull()
|
|
|
|
*/
|
2005-07-15 18:20:57 +00:00
|
|
|
NormalizedRect();
|
2006-11-27 08:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a normalized rectangle with the normalized coordinates
|
|
|
|
* @p left, @p top, @p right, @p bottom.
|
|
|
|
*
|
|
|
|
* If you need the x, y, width and height coordinates use the
|
|
|
|
* following formulas:
|
|
|
|
*
|
|
|
|
* @li x = left
|
|
|
|
* @li y = top
|
|
|
|
* @li width = right - left
|
|
|
|
* @li height = bottom - top
|
|
|
|
*/
|
|
|
|
NormalizedRect( double left, double top, double right, double bottom );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a normalized rectangle of the given @p rectangle which is normalized
|
|
|
|
* by the scaling factors @p xScale and @p yScale.
|
|
|
|
*/
|
|
|
|
NormalizedRect( const QRect &rectangle, double xScale, double yScale );
|
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
NormalizedRect( const NormalizedRect& );
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
NormalizedRect& operator=( const NormalizedRect &other );
|
|
|
|
|
2007-02-01 18:31:45 +00:00
|
|
|
/**
|
|
|
|
* Build a normalized rect from a QRectF.
|
|
|
|
*/
|
|
|
|
static NormalizedRect fromQRectF( const QRectF &rect );
|
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Returns whether this normalized rectangle is a null normalized rect.
|
|
|
|
*/
|
2005-07-15 18:20:57 +00:00
|
|
|
bool isNull() const;
|
2006-11-27 08:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the normalized rectangle contains the normalized coordinates
|
|
|
|
* @p x and @p y.
|
|
|
|
*/
|
2005-07-15 18:20:57 +00:00
|
|
|
bool contains( double x, double y ) const;
|
2006-11-27 08:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the normalized rectangle intersects the @p other normalized
|
|
|
|
* rectangle.
|
|
|
|
*/
|
|
|
|
bool intersects( const NormalizedRect &other ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an overloaded member function, provided for convenience. It behaves essentially
|
|
|
|
* like the above function.
|
|
|
|
*/
|
|
|
|
bool intersects( const NormalizedRect *other ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the normalized rectangle intersects an other normalized
|
|
|
|
* rectangle, which is defined by @p left, @p top, @p right and @p bottom.
|
|
|
|
*/
|
|
|
|
bool intersects( double left, double top, double right, double bottom ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the rectangle that accrues when the normalized rectangle is multiplyed
|
|
|
|
* with the scaling @p xScale and @p yScale.
|
|
|
|
*/
|
2005-07-15 18:20:57 +00:00
|
|
|
QRect geometry( int xScale, int yScale ) const;
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2011-07-02 15:24:50 +00:00
|
|
|
/**
|
2011-08-17 04:45:46 +00:00
|
|
|
* Same functionality as geometry, but the output is now rounded before typecasting to int
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-07-02 15:24:50 +00:00
|
|
|
QRect roundedGeometry( int xScale, int yScale ) const;
|
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Returns the normalized bounding rectangle of the normalized rectangle
|
|
|
|
* combined with the @p other normalized rectangle.
|
|
|
|
*/
|
|
|
|
NormalizedRect operator|( const NormalizedRect &other ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the normalized rectangle to the normalized bounding rectangle
|
|
|
|
* of itself combined with the @p other normalized rectangle.
|
|
|
|
*/
|
|
|
|
NormalizedRect& operator|=( const NormalizedRect &other );
|
|
|
|
|
2008-05-18 21:08:31 +00:00
|
|
|
/**
|
|
|
|
* Returns the intersection of this normalized rectangle with the specified
|
|
|
|
* @p other. If the rects do not intersect then the result is null.
|
|
|
|
*
|
|
|
|
* @since 0.7 (KDE 4.1)
|
|
|
|
*/
|
|
|
|
NormalizedRect operator&( const NormalizedRect &other ) const;
|
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the normalized rectangle is equal to the @p other
|
|
|
|
* normalized rectangle.
|
|
|
|
*/
|
|
|
|
bool operator==( const NormalizedRect &other ) const;
|
|
|
|
|
2009-11-12 21:45:35 +00:00
|
|
|
/**
|
|
|
|
* Returns the center of the rectangle
|
|
|
|
* @since 0.10 (KDE 4.4)
|
|
|
|
*/
|
|
|
|
NormalizedPoint center() const;
|
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* Transforms the normalized rectangle with the operations defined by @p matrix.
|
|
|
|
*/
|
2006-11-20 07:53:32 +00:00
|
|
|
void transform( const QMatrix &matrix );
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2011-06-25 05:11:33 +00:00
|
|
|
/**
|
2011-08-17 04:45:46 +00:00
|
|
|
* Returns true if the point pt is located to the bottom of the rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isBottom(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-06-25 05:11:33 +00:00
|
|
|
return bottom < pt.y;
|
|
|
|
}
|
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the point pt is located on the top of the rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isTop(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-06-25 05:11:33 +00:00
|
|
|
return top > pt.y;
|
|
|
|
}
|
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the point pt is located under the top of the rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isBottomOrLevel(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-08-04 04:34:11 +00:00
|
|
|
return top < pt.y;
|
|
|
|
}
|
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the point pt is located above the bottom of the rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isTopOrLevel(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-08-04 04:34:11 +00:00
|
|
|
return bottom > pt.y;
|
|
|
|
}
|
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the point pt is located to the right of the left arm of rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isLeft(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-07-28 12:53:40 +00:00
|
|
|
return left < pt.x;
|
2011-06-25 05:11:33 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 04:45:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the point pt is located to the left of the right arm of rectangle
|
2011-11-02 22:05:19 +00:00
|
|
|
* @since 0.14 (KDE 4.8)
|
2011-08-17 04:45:46 +00:00
|
|
|
*/
|
2011-08-22 16:36:47 +00:00
|
|
|
bool isRight(const NormalizedPoint& pt) const
|
2011-08-21 04:44:42 +00:00
|
|
|
{
|
2011-07-28 12:53:40 +00:00
|
|
|
return right > pt.x;
|
2011-06-25 05:11:33 +00:00
|
|
|
}
|
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
/**
|
|
|
|
* The normalized left coordinate.
|
|
|
|
*/
|
|
|
|
double left;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The normalized top coordinate.
|
|
|
|
*/
|
|
|
|
double top;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The normalized right coordinate.
|
|
|
|
*/
|
|
|
|
double right;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The normalized bottom coordinate.
|
|
|
|
*/
|
|
|
|
double bottom;
|
|
|
|
};
|
2007-07-15 15:57:10 +00:00
|
|
|
KDE_DUMMY_QHASH_FUNCTION(NormalizedRect)
|
2005-07-15 18:20:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short NormalizedRect that contains a reference to an object.
|
|
|
|
*
|
2007-04-20 13:02:45 +00:00
|
|
|
* These rects contains a pointer to a okular object (such as an action or something
|
2005-07-15 18:20:57 +00:00
|
|
|
* like that). The pointer is read and stored as 'void pointer' so cast is
|
|
|
|
* performed by accessors based on the value returned by objectType(). Objects
|
|
|
|
* are reparented to this class.
|
|
|
|
*
|
|
|
|
* Type / Class correspondency tab:
|
2007-04-20 13:02:45 +00:00
|
|
|
* - Action : class Action: description of an action
|
2006-09-21 08:45:36 +00:00
|
|
|
* - Image : class Image : description of an image (n/a)
|
2006-09-19 17:17:29 +00:00
|
|
|
* - Annotation: class Annotation: description of an annotation
|
2005-07-15 18:20:57 +00:00
|
|
|
*/
|
2006-07-13 15:03:18 +00:00
|
|
|
class OKULAR_EXPORT ObjectRect
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Describes the type of storable object.
|
|
|
|
*/
|
|
|
|
enum ObjectType
|
|
|
|
{
|
2007-04-20 13:02:45 +00:00
|
|
|
Action, ///< An action
|
2007-01-02 17:05:49 +00:00
|
|
|
Image, ///< An image
|
|
|
|
OAnnotation, ///< An annotation
|
|
|
|
SourceRef ///< A source reference
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new object rectangle.
|
|
|
|
*
|
|
|
|
* @param left The left coordinate of the rectangle.
|
|
|
|
* @param top The top coordinate of the rectangle.
|
|
|
|
* @param right The right coordinate of the rectangle.
|
|
|
|
* @param bottom The bottom coordinate of the rectangle.
|
|
|
|
* @param ellipse If true the rectangle describes an ellipse.
|
|
|
|
* @param type The type of the storable object @see ObjectType.
|
|
|
|
* @param object The pointer to the storable object.
|
|
|
|
*/
|
|
|
|
ObjectRect( double left, double top, double right, double bottom, bool ellipse, ObjectType type, void *object );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an overloaded member function, provided for convenience.
|
|
|
|
*/
|
|
|
|
ObjectRect( const NormalizedRect &rect, bool ellipse, ObjectType type, void *object );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an overloaded member function, provided for convenience.
|
|
|
|
*/
|
|
|
|
ObjectRect( const QPolygonF &poly, ObjectType type, void *object );
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Destroys the object rectangle.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
virtual ~ObjectRect();
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the object type of the object rectangle.
|
|
|
|
* @see ObjectType
|
|
|
|
*/
|
|
|
|
ObjectType objectType() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the storable object of the object rectangle.
|
|
|
|
*/
|
|
|
|
const void *object() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the region that is covered by the object rectangle.
|
|
|
|
*/
|
2006-11-20 07:53:32 +00:00
|
|
|
const QPainterPath ®ion() const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bounding rect of the object rectangle for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
virtual QRect boundingRect( double xScale, double yScale ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the object rectangle contains the point @p x, @p y for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
|
|
|
virtual bool contains( double x, double y, double xScale, double yScale ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the object rectangle with the operations defined by @p matrix.
|
|
|
|
*/
|
2006-11-20 07:53:32 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2009-03-23 12:05:00 +00:00
|
|
|
/**
|
|
|
|
* Returns the square of the distance between the object and the point @p x, @p y
|
|
|
|
* for the scaling factor @p xScale and @p yScale.
|
|
|
|
*
|
|
|
|
* @since 0.8.2 (KDE 4.2.2)
|
|
|
|
*/
|
|
|
|
// FIXME this should most probably be a virtual method
|
|
|
|
double distanceSqr( double x, double y, double xScale, double yScale ) const;
|
|
|
|
|
2006-09-19 17:17:29 +00:00
|
|
|
protected:
|
2005-07-15 18:20:57 +00:00
|
|
|
ObjectType m_objectType;
|
2007-01-02 17:05:49 +00:00
|
|
|
void * m_object;
|
2006-07-13 15:03:18 +00:00
|
|
|
QPainterPath m_path;
|
2007-01-02 17:05:49 +00:00
|
|
|
QPainterPath m_transformedPath;
|
2005-07-15 18:20:57 +00:00
|
|
|
};
|
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* This class describes the object rectangle for an annotation.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
class OKULAR_EXPORT AnnotationObjectRect : public ObjectRect
|
|
|
|
{
|
|
|
|
public:
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Creates a new annotation object rectangle with the
|
|
|
|
* given @p annotation.
|
|
|
|
*/
|
|
|
|
AnnotationObjectRect( Annotation *annotation );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the annotation object rectangle.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
virtual ~AnnotationObjectRect();
|
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the annotation object of the annotation object rectangle.
|
|
|
|
*/
|
|
|
|
Annotation *annotation() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bounding rect of the annotation object rectangle for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
virtual QRect boundingRect( double xScale, double yScale ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the annotation object rectangle contains the point @p x, @p y for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
2006-09-19 17:17:29 +00:00
|
|
|
virtual bool contains( double x, double y, double xScale, double yScale ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the annotation object rectangle with the operations defined by @p matrix.
|
|
|
|
*/
|
2006-11-20 07:53:32 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2006-09-19 17:17:29 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-02 17:05:49 +00:00
|
|
|
Annotation * m_annotation;
|
2006-09-19 17:17:29 +00:00
|
|
|
};
|
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* This class describes the object rectangle for a source reference.
|
|
|
|
*/
|
2006-11-17 22:15:15 +00:00
|
|
|
class OKULAR_EXPORT SourceRefObjectRect : public ObjectRect
|
|
|
|
{
|
2009-03-23 12:05:00 +00:00
|
|
|
friend class ObjectRect;
|
|
|
|
|
2006-11-17 22:15:15 +00:00
|
|
|
public:
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Creates a new source reference object rectangle.
|
|
|
|
*
|
|
|
|
* @param point The point of the source reference.
|
|
|
|
* @param reference The storable source reference object.
|
|
|
|
*/
|
|
|
|
SourceRefObjectRect( const NormalizedPoint& point, void *reference );
|
2006-11-17 22:15:15 +00:00
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the bounding rect of the source reference object rectangle for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
2006-11-17 22:15:15 +00:00
|
|
|
virtual QRect boundingRect( double xScale, double yScale ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the source reference object rectangle contains the point @p x, @p y for the
|
|
|
|
* scaling factor @p xScale and @p yScale.
|
|
|
|
*/
|
2006-11-17 22:15:15 +00:00
|
|
|
virtual bool contains( double x, double y, double xScale, double yScale ) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
NormalizedPoint m_point;
|
|
|
|
};
|
|
|
|
|
2007-08-27 23:02:48 +00:00
|
|
|
/// @cond PRIVATE
|
2006-12-23 15:39:26 +00:00
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
2006-12-27 17:10:06 +00:00
|
|
|
void doDelete( T& t )
|
2006-12-23 15:39:26 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
(void)t;
|
|
|
|
}
|
2006-12-23 15:39:26 +00:00
|
|
|
|
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
2006-12-27 17:10:06 +00:00
|
|
|
T* givePtr( T& t )
|
2006-12-23 15:39:26 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
return &t;
|
|
|
|
}
|
2006-12-23 16:18:54 +00:00
|
|
|
|
2006-12-27 17:10:06 +00:00
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
|
|
|
T& deref( T& t )
|
|
|
|
{
|
|
|
|
return t;
|
|
|
|
}
|
2006-12-24 18:19:18 +00:00
|
|
|
|
2006-12-27 17:10:06 +00:00
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
|
|
|
static void doDelete( T* t )
|
|
|
|
{
|
|
|
|
delete t;
|
|
|
|
}
|
2006-12-24 18:19:18 +00:00
|
|
|
|
2006-12-27 17:10:06 +00:00
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
|
|
|
static T* givePtr( T* t )
|
|
|
|
{
|
|
|
|
return t;
|
|
|
|
}
|
2006-12-24 18:19:18 +00:00
|
|
|
|
2006-12-27 17:10:06 +00:00
|
|
|
/** @internal */
|
|
|
|
template <typename T>
|
|
|
|
static T& deref( T* t )
|
|
|
|
{
|
|
|
|
return *t;
|
|
|
|
}
|
2007-08-27 23:02:48 +00:00
|
|
|
/// @endcond
|
2006-12-23 15:39:26 +00:00
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
/**
|
|
|
|
* @short A regular area of NormalizedShape which normalizes a Shape
|
2006-12-23 16:31:56 +00:00
|
|
|
*
|
|
|
|
* Class NormalizedShape \b must have the following functions/operators defined:
|
|
|
|
* - bool contains( double, double )
|
|
|
|
* - bool intersects( NormalizedShape )
|
|
|
|
* - bool isNull()
|
|
|
|
* - Shape geometry( int, int )
|
|
|
|
* - operator|=( NormalizedShape ) which unite two NormalizedShape's
|
2005-07-15 18:20:57 +00:00
|
|
|
*/
|
2011-06-25 05:11:33 +00:00
|
|
|
template <class NormalizedShape, class Shape> class RegularArea : public QList<NormalizedShape>
|
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
public:
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Destroys a regular area.
|
|
|
|
*/
|
2006-12-23 15:39:26 +00:00
|
|
|
~RegularArea();
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the regular area contains the
|
|
|
|
* normalized point @p x, @p y.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
bool contains( double x, double y ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the regular area contains the
|
|
|
|
* given @p shape.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
bool contains( const NormalizedShape& shape ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the regular area intersects with the given @p area.
|
|
|
|
*/
|
2006-12-29 18:18:07 +00:00
|
|
|
bool intersects( const RegularArea<NormalizedShape,Shape> *area ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the regular area intersects with the given @p shape.
|
|
|
|
*/
|
2006-12-29 18:18:07 +00:00
|
|
|
bool intersects( const NormalizedShape& shape ) const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the given @p area to the regular area.
|
|
|
|
*/
|
2006-12-29 18:18:07 +00:00
|
|
|
void appendArea( const RegularArea<NormalizedShape,Shape> *area );
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the given @p shape to the regular area.
|
|
|
|
*/
|
2007-09-05 14:57:15 +00:00
|
|
|
void appendShape( const NormalizedShape& shape, MergeSide side = MergeAll );
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simplifies the regular area by merging its intersecting subareas.
|
|
|
|
*/
|
2006-12-29 18:18:07 +00:00
|
|
|
void simplify();
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the regular area is a null area.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
bool isNull() const;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the subareas of the regular areas as shapes for the given scaling factor
|
|
|
|
* @p xScale and @p yScale, translated by @p dx and @p dy.
|
|
|
|
*/
|
|
|
|
QList<Shape> geometry( int xScale, int yScale, int dx = 0, int dy = 0 ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the regular area with the operations defined by @p matrix.
|
|
|
|
*/
|
2006-12-29 18:18:07 +00:00
|
|
|
void transform( const QMatrix &matrix );
|
2005-07-15 18:20:57 +00:00
|
|
|
};
|
|
|
|
|
2006-12-23 15:39:26 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
2007-03-18 17:14:36 +00:00
|
|
|
RegularArea<NormalizedShape, Shape>::~RegularArea()
|
2006-12-23 15:39:26 +00:00
|
|
|
{
|
|
|
|
int size = this->count();
|
|
|
|
for ( int i = 0; i < size; ++i )
|
2006-12-27 17:10:06 +00:00
|
|
|
doDelete( (*this)[i] );
|
2006-12-23 15:39:26 +00:00
|
|
|
}
|
|
|
|
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
|
|
|
void RegularArea<NormalizedShape, Shape>::simplify()
|
|
|
|
{
|
2006-11-18 17:07:15 +00:00
|
|
|
#ifdef DEBUG_REGULARAREA
|
|
|
|
int prev_end = this->count();
|
|
|
|
#endif
|
|
|
|
int end = this->count() - 1, x = 0;
|
|
|
|
for ( int i = 0; i < end; ++i )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
if ( givePtr( (*this)[x] )->intersects( deref( (*this)[i+1] ) ) )
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
deref((*this)[x]) |= deref((*this)[i+1]);
|
2006-12-24 18:19:18 +00:00
|
|
|
NormalizedShape& tobedeleted = (*this)[i+1];
|
2006-11-18 17:07:15 +00:00
|
|
|
this->removeAt( i + 1 );
|
2006-12-27 17:10:06 +00:00
|
|
|
doDelete( tobedeleted );
|
2006-11-18 17:07:15 +00:00
|
|
|
--end;
|
|
|
|
--i;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x=i+1;
|
|
|
|
}
|
|
|
|
}
|
2006-10-11 22:20:11 +00:00
|
|
|
#ifdef DEBUG_REGULARAREA
|
2007-07-31 10:19:48 +00:00
|
|
|
kDebug() << "from" << prev_end << "to" << this->count();
|
2006-10-11 22:20:11 +00:00
|
|
|
#endif
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
|
|
|
bool RegularArea<NormalizedShape, Shape>::isNull() const
|
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( this->isEmpty() )
|
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator it = this->begin(), itEnd = this->end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
|
|
|
if ( !givePtr( *it )->isNull() )
|
2006-11-27 08:05:56 +00:00
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
return true;
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class NormalizedShape, class Shape>
|
2006-11-27 08:05:56 +00:00
|
|
|
bool RegularArea<NormalizedShape, Shape>::intersects( const NormalizedShape& rect ) const
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( this->isEmpty() )
|
|
|
|
return false;
|
|
|
|
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator it = this->begin(), itEnd = this->end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
|
|
|
if ( !givePtr( *it )->isNull() && givePtr( *it )->intersects( rect ) )
|
2006-11-27 08:05:56 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class NormalizedShape, class Shape>
|
2006-11-27 08:05:56 +00:00
|
|
|
bool RegularArea<NormalizedShape, Shape>::intersects( const RegularArea<NormalizedShape,Shape> *area ) const
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( this->isEmpty() )
|
|
|
|
return false;
|
|
|
|
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator it = this->begin(), itEnd = this->end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
2006-11-27 08:05:56 +00:00
|
|
|
{
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator areaIt = area->begin(), areaItEnd = area->end();
|
|
|
|
for ( ; areaIt != areaItEnd; ++areaIt )
|
2006-11-27 08:05:56 +00:00
|
|
|
{
|
2007-07-15 15:57:10 +00:00
|
|
|
if ( !( *it ).isNull() && ( *it ).intersects( *areaIt ) )
|
2006-11-27 08:05:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class NormalizedShape, class Shape>
|
2006-11-27 08:05:56 +00:00
|
|
|
void RegularArea<NormalizedShape, Shape>::appendArea( const RegularArea<NormalizedShape, Shape> *area )
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
2007-07-15 15:52:17 +00:00
|
|
|
return;
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator areaIt = area->begin(), areaItEnd = area->end();
|
|
|
|
for ( ; areaIt != areaItEnd; ++areaIt )
|
|
|
|
this->append( *areaIt );
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-23 16:18:54 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
2007-09-05 14:57:15 +00:00
|
|
|
void RegularArea<NormalizedShape, Shape>::appendShape( const NormalizedShape& shape, MergeSide side )
|
2006-12-23 16:18:54 +00:00
|
|
|
{
|
|
|
|
if ( !this )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int size = this->count();
|
|
|
|
// if the list is empty, adds the shape normally
|
|
|
|
if ( size == 0 )
|
|
|
|
{
|
|
|
|
this->append( shape );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 14:57:15 +00:00
|
|
|
bool intersection = false;
|
|
|
|
NormalizedShape& last = (*this)[size - 1];
|
|
|
|
#define O_LAST givePtr( last )
|
|
|
|
# define O_LAST_R O_LAST->right
|
|
|
|
# define O_LAST_L O_LAST->left
|
|
|
|
# define O_LAST_T O_LAST->top
|
|
|
|
# define O_LAST_B O_LAST->bottom
|
|
|
|
#define O_NEW givePtr( shape )
|
|
|
|
# define O_NEW_R O_NEW->right
|
|
|
|
# define O_NEW_L O_NEW->left
|
|
|
|
# define O_NEW_T O_NEW->top
|
|
|
|
# define O_NEW_B O_NEW->bottom
|
|
|
|
switch ( side )
|
|
|
|
{
|
|
|
|
case MergeRight:
|
|
|
|
intersection = ( O_LAST_R >= O_NEW_L ) && ( O_LAST_L <= O_NEW_R )
|
|
|
|
&& ( ( O_LAST_T <= O_NEW_T && O_LAST_B >= O_NEW_B )
|
|
|
|
|| ( O_LAST_T >= O_NEW_T && O_LAST_B <= O_NEW_B ) );
|
|
|
|
break;
|
|
|
|
case MergeBottom:
|
|
|
|
intersection = ( O_LAST_B >= O_NEW_T ) && ( O_LAST_T <= O_NEW_B )
|
|
|
|
&& ( ( O_LAST_R <= O_NEW_R && O_LAST_L >= O_NEW_L )
|
|
|
|
|| ( O_LAST_R >= O_NEW_R && O_LAST_L <= O_NEW_L ) );
|
|
|
|
break;
|
|
|
|
case MergeLeft:
|
|
|
|
intersection = ( O_LAST_L <= O_NEW_R ) && ( O_LAST_R >= O_NEW_L )
|
|
|
|
&& ( ( O_LAST_T <= O_NEW_T && O_LAST_B >= O_NEW_B )
|
|
|
|
|| ( O_LAST_T >= O_NEW_T && O_LAST_B <= O_NEW_B ) );
|
|
|
|
break;
|
|
|
|
case MergeTop:
|
|
|
|
intersection = ( O_LAST_T <= O_NEW_B ) && ( O_LAST_B >= O_NEW_T )
|
|
|
|
&& ( ( O_LAST_R <= O_NEW_R && O_LAST_L >= O_NEW_L )
|
|
|
|
|| ( O_LAST_R >= O_NEW_R && O_LAST_L <= O_NEW_L ) );
|
|
|
|
break;
|
|
|
|
case MergeAll:
|
|
|
|
intersection = O_LAST->intersects( shape );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#undef O_LAST
|
|
|
|
# undef O_LAST_R
|
|
|
|
# undef O_LAST_L
|
|
|
|
# undef O_LAST_T
|
|
|
|
# undef O_LAST_B
|
|
|
|
#undef O_NEW
|
|
|
|
# undef O_NEW_R
|
|
|
|
# undef O_NEW_L
|
|
|
|
# undef O_NEW_T
|
|
|
|
# undef O_NEW_B
|
2006-12-23 16:18:54 +00:00
|
|
|
// if the new shape intersects with the last shape in the list, then
|
|
|
|
// merge it with that and delete the shape
|
2007-09-05 14:57:15 +00:00
|
|
|
if ( intersection )
|
2006-12-23 16:18:54 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
deref((*this)[size - 1]) |= deref( shape );
|
|
|
|
doDelete( const_cast<NormalizedShape&>( shape ) );
|
2006-12-23 16:18:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
this->append( shape );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
2006-11-27 08:05:56 +00:00
|
|
|
bool RegularArea<NormalizedShape, Shape>::contains( double x, double y ) const
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( this->isEmpty() )
|
|
|
|
return false;
|
|
|
|
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator it = this->begin(), itEnd = this->end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
2007-07-15 15:57:10 +00:00
|
|
|
if ( ( *it ).contains( x, y ) )
|
2006-11-27 08:05:56 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
2006-11-27 08:05:56 +00:00
|
|
|
bool RegularArea<NormalizedShape, Shape>::contains( const NormalizedShape& shape ) const
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
{
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( !this )
|
|
|
|
return false;
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
|
2006-11-27 08:05:56 +00:00
|
|
|
if ( this->isEmpty() )
|
|
|
|
return false;
|
|
|
|
|
2006-12-24 14:40:49 +00:00
|
|
|
return QList<NormalizedShape>::contains( shape );
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
2006-12-27 17:10:06 +00:00
|
|
|
QList<Shape> RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale, int dx, int dy ) const
|
2005-07-15 18:20:57 +00:00
|
|
|
{
|
2006-12-27 17:10:06 +00:00
|
|
|
if ( !this || this->isEmpty() )
|
|
|
|
return QList<Shape>();
|
2006-11-27 08:05:56 +00:00
|
|
|
|
2006-12-27 17:10:06 +00:00
|
|
|
QList<Shape> ret;
|
2006-11-27 08:05:56 +00:00
|
|
|
Shape t;
|
2007-07-15 15:52:17 +00:00
|
|
|
typename QList<NormalizedShape>::const_iterator it = this->begin(), itEnd = this->end();
|
|
|
|
for ( ; it != itEnd; ++it )
|
2006-11-27 08:05:56 +00:00
|
|
|
{
|
2007-07-15 15:52:17 +00:00
|
|
|
t = givePtr( *it )->geometry( xScale, yScale );
|
2006-11-27 08:05:56 +00:00
|
|
|
t.translate( dx, dy );
|
2006-12-27 17:10:06 +00:00
|
|
|
ret.append( t );
|
2006-11-27 08:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2005-07-15 18:20:57 +00:00
|
|
|
}
|
|
|
|
|
2006-12-29 18:18:07 +00:00
|
|
|
template <class NormalizedShape, class Shape>
|
|
|
|
void RegularArea<NormalizedShape, Shape>::transform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
if ( !this )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( this->isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for ( int i = 0; i < this->count(); ++i )
|
|
|
|
givePtr( (*this)[i] )->transform( matrix );
|
|
|
|
}
|
|
|
|
|
2007-07-10 23:22:45 +00:00
|
|
|
class OKULAR_EXPORT RegularAreaRect : public RegularArea< NormalizedRect, QRect >
|
2007-07-10 23:15:14 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
RegularAreaRect();
|
|
|
|
RegularAreaRect( const RegularAreaRect& rar );
|
|
|
|
~RegularAreaRect();
|
|
|
|
|
|
|
|
RegularAreaRect& operator=( const RegularAreaRect& rar );
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* This class stores the coordinates of a highlighting area
|
|
|
|
* together with the id of the highlight owner and the color.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
class HighlightAreaRect : public RegularAreaRect
|
|
|
|
{
|
|
|
|
public:
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Creates a new highlight area rect with the coordinates of
|
|
|
|
* the given @p area.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
HighlightAreaRect( const RegularAreaRect *area = 0 );
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* The search ID of the highlight owner.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
int s_id;
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The color of the highlight.
|
|
|
|
*/
|
2006-11-27 08:05:56 +00:00
|
|
|
QColor color;
|
2005-07-15 18:20:57 +00:00
|
|
|
};
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
}
|
|
|
|
|
2007-07-30 23:58:04 +00:00
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
2007-01-02 17:05:49 +00:00
|
|
|
/**
|
|
|
|
* Debug operator for normalized @p point.
|
|
|
|
*/
|
2007-07-30 23:58:04 +00:00
|
|
|
OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedPoint &point );
|
2007-01-02 17:05:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug operator for normalized @p rect.
|
|
|
|
*/
|
2007-07-30 23:58:04 +00:00
|
|
|
OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedRect &rect );
|
|
|
|
#endif
|
2006-12-31 17:52:24 +00:00
|
|
|
|
2005-07-15 18:20:57 +00:00
|
|
|
#endif
|