Subversion Repositories Scribus

Rev

Rev 14170 | Rev 15344 | 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.,                                        *
24
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
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
#include "scribus.h"
40
 
14170 jghali 41
#if defined(_MSC_VER)
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>
57
using namespace Geom;
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() {};
87
        void adjustHandles();
12511 fschmid 88
        void updateMesh(bool gridOnly);
12067 fschmid 89
        void updateAndExit();
90
 
91
        bool isFirst;
92
        double w4;
93
        double w2;
94
        double ww;
95
        double deltaX;
96
        double deltaY;
97
        ScribusDoc*  m_doc;
98
        QGraphicsScene scene;
99
        QGraphicsPathItem* pItemG;
100
        QList<QGraphicsPathItem*> origPathItem;
101
        QList<NodeItem*> nodeItems;
102
        QList< Geom::Piecewise<D2<Geom::SBasis> > > origPath;
103
        std::vector<Geom::Point> handles;
12511 fschmid 104
        std::vector<Geom::Point> origHandles;
12067 fschmid 105
        Geom::D2<Geom::SBasis2d> sb2;
106
 
107
private slots:
108
        void doZoomIn();
109
        void doZoomOut();
12511 fschmid 110
        void doReset();
12067 fschmid 111
 
112
protected:
113
        void showEvent(QShowEvent *e);
114
};
115
 
116
#endif