Subversion Repositories Scribus

Rev

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