Subversion Repositories Scribus

Rev

Rev 22440 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12067 fschmid 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
/***************************************************************************
8
*   Copyright (C) 2008 by Franz Schmid                                     *
9
*   franz.schmid@altmuehlnet.de                                            *
10
*                                                                          *
11
*   This program is free software; you can redistribute it and/or modify   *
12
*   it under the terms of the GNU General Public License as published by   *
13
*   the Free Software Foundation; either version 2 of the License, or      *
14
*   (at your option) any later version.                                    *
15
*                                                                          *
16
*   This program is distributed in the hope that it will be useful,        *
17
*   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
18
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
19
*   GNU General Public License for more details.                           *
20
*                                                                          *
21
*   You should have received a copy of the GNU General Public License      *
22
*   along with this program; if not, write to the                          *
23
*   Free Software Foundation, Inc.,                                        *
18122 mrdocs 24
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.              *
12067 fschmid 25
****************************************************************************/
26
 
27
#ifndef MESHDISTORTIONDIALOG_H
28
#define MESHDISTORTIONDIALOG_H
29
 
30
#include <QDialog>
31
#include <QList>
32
#include <QGraphicsEllipseItem>
33
#include <QGraphicsPathItem>
22440 jghali 34
 
12067 fschmid 35
#include "ui_meshdistortiondialog.h"
36
#include "pluginapi.h"
37
#include "scribusdoc.h"
38
 
17539 jghali 39
#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
14170 jghali 40
#define _USE_MATH_DEFINES
41
#endif
42
 
14937 fschmid 43
#include "third_party/lib2geom/sbasis.h"
44
#include "third_party/lib2geom/sbasis-geometric.h"
45
#include "third_party/lib2geom/bezier-to-sbasis.h"
46
#include "third_party/lib2geom/sbasis-to-bezier.h"
47
#include "third_party/lib2geom/d2.h"
48
#include "third_party/lib2geom/piecewise.h"
49
#include "third_party/lib2geom/utils.h"
50
#include "third_party/lib2geom/path.h"
51
#include "third_party/lib2geom/sbasis-2d.h"
52
#include "third_party/lib2geom/transforms.h"
53
#include "third_party/lib2geom/scribushelper.h"
12067 fschmid 54
#include <vector>
22440 jghali 55
 
15344 fschmid 56
//using namespace Geom;
12067 fschmid 57
class MeshDistortionDialog;
22440 jghali 58
class QGraphicsSceneHoverEvent;
59
class QGraphicsSceneMouseEvent;
60
class QStyleOptionGraphicsItem;
12067 fschmid 61
 
62
class PLUGIN_API NodeItem : public QGraphicsEllipseItem
63
{
64
public:
23705 craig 65
        NodeItem(QRectF geom, uint num, MeshDistortionDialog* parent);
12067 fschmid 66
        ~NodeItem() {};
22440 jghali 67
 
23705 craig 68
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget* widget);
12067 fschmid 69
        uint handle;
70
        bool mouseMoving;
71
        bool mousePressed;
72
 
73
protected:
74
        void mousePressEvent(QGraphicsSceneMouseEvent *event);
75
        void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
76
        void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
12519 fschmid 77
        void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
78
        void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
79
        void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
12067 fschmid 80
        MeshDistortionDialog *dialog;
81
};
82
 
83
class PLUGIN_API MeshDistortionDialog : public QDialog, Ui::MeshDistortionDialog
84
{
85
        Q_OBJECT
86
 
87
public:
88
        MeshDistortionDialog(QWidget* parent, ScribusDoc *doc);
89
        ~MeshDistortionDialog() {};
22440 jghali 90
 
16116 fschmid 91
        void addItemsToScene(Selection* itemSelection, ScribusDoc *doc, QGraphicsPathItem* parentItem, PageItem* parent);
12067 fschmid 92
        void adjustHandles();
12511 fschmid 93
        void updateMesh(bool gridOnly);
12067 fschmid 94
        void updateAndExit();
95
 
96
        bool isFirst;
97
        double w4;
98
        double w2;
99
        double ww;
100
        double deltaX;
101
        double deltaY;
102
        ScribusDoc*  m_doc;
103
        QGraphicsScene scene;
104
        QGraphicsPathItem* pItemG;
105
        QList<QGraphicsPathItem*> origPathItem;
16116 fschmid 106
        QList<PageItem*> origPageItem;
12067 fschmid 107
        QList<NodeItem*> nodeItems;
15344 fschmid 108
        QList< Geom::Piecewise<Geom::D2<Geom::SBasis> > > origPath;
12067 fschmid 109
        std::vector<Geom::Point> handles;
12511 fschmid 110
        std::vector<Geom::Point> origHandles;
12067 fschmid 111
        Geom::D2<Geom::SBasis2d> sb2;
112
 
113
private slots:
114
        void doZoomIn();
115
        void doZoomOut();
12511 fschmid 116
        void doReset();
12067 fschmid 117
 
118
protected:
119
        void showEvent(QShowEvent *e);
120
};
121
 
122
#endif