Subversion Repositories Scribus

Rev

Rev 18122 | Rev 22440 | Go to most recent revision | 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>
34
#include <QGraphicsSceneMouseEvent>
12519 fschmid 35
#include <QGraphicsSceneHoverEvent>
12067 fschmid 36
#include "ui_meshdistortiondialog.h"
37
#include "pluginapi.h"
38
#include "scribusdoc.h"
39
 
19080 craig 40
 
17539 jghali 41
#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
14170 jghali 42
#define _USE_MATH_DEFINES
43
#endif
44
 
14937 fschmid 45
#include "third_party/lib2geom/sbasis.h"
46
#include "third_party/lib2geom/sbasis-geometric.h"
47
#include "third_party/lib2geom/bezier-to-sbasis.h"
48
#include "third_party/lib2geom/sbasis-to-bezier.h"
49
#include "third_party/lib2geom/d2.h"
50
#include "third_party/lib2geom/piecewise.h"
51
#include "third_party/lib2geom/utils.h"
52
#include "third_party/lib2geom/path.h"
53
#include "third_party/lib2geom/sbasis-2d.h"
54
#include "third_party/lib2geom/transforms.h"
55
#include "third_party/lib2geom/scribushelper.h"
12067 fschmid 56
#include <vector>
15344 fschmid 57
//using namespace Geom;
12067 fschmid 58
class MeshDistortionDialog;
59
 
60
class PLUGIN_API NodeItem : public QGraphicsEllipseItem
61
{
62
public:
63
        NodeItem(QRectF geom, uint num, MeshDistortionDialog *parent);
64
        ~NodeItem() {};
12519 fschmid 65
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
12067 fschmid 66
        uint handle;
67
        bool mouseMoving;
68
        bool mousePressed;
69
 
70
protected:
71
        void mousePressEvent(QGraphicsSceneMouseEvent *event);
72
        void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
73
        void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
12519 fschmid 74
        void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
75
        void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
76
        void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
12067 fschmid 77
        MeshDistortionDialog *dialog;
78
};
79
 
80
class PLUGIN_API MeshDistortionDialog : public QDialog, Ui::MeshDistortionDialog
81
{
82
        Q_OBJECT
83
 
84
public:
85
        MeshDistortionDialog(QWidget* parent, ScribusDoc *doc);
86
        ~MeshDistortionDialog() {};
16116 fschmid 87
        void addItemsToScene(Selection* itemSelection, ScribusDoc *doc, QGraphicsPathItem* parentItem, PageItem* parent);
12067 fschmid 88
        void adjustHandles();
12511 fschmid 89
        void updateMesh(bool gridOnly);
12067 fschmid 90
        void updateAndExit();
91
 
92
        bool isFirst;
93
        double w4;
94
        double w2;
95
        double ww;
96
        double deltaX;
97
        double deltaY;
98
        ScribusDoc*  m_doc;
99
        QGraphicsScene scene;
100
        QGraphicsPathItem* pItemG;
101
        QList<QGraphicsPathItem*> origPathItem;
16116 fschmid 102
        QList<PageItem*> origPageItem;
12067 fschmid 103
        QList<NodeItem*> nodeItems;
15344 fschmid 104
        QList< Geom::Piecewise<Geom::D2<Geom::SBasis> > > origPath;
12067 fschmid 105
        std::vector<Geom::Point> handles;
12511 fschmid 106
        std::vector<Geom::Point> origHandles;
12067 fschmid 107
        Geom::D2<Geom::SBasis2d> sb2;
108
 
109
private slots:
110
        void doZoomIn();
111
        void doZoomOut();
12511 fschmid 112
        void doReset();
12067 fschmid 113
 
114
protected:
115
        void showEvent(QShowEvent *e);
116
};
117
 
118
#endif