Scribus
Open source desktop publishing at your fingertips
meshdistortiondialog.h
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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>
35 #include <QGraphicsSceneHoverEvent>
36 #include "ui_meshdistortiondialog.h"
37 #include "pluginapi.h"
38 #include "scribusdoc.h"
39 
40 
41 #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
42 #define _USE_MATH_DEFINES
43 #endif
44 
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"
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() {};
65  void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
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);
74  void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
75  void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
76  void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
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 addItemsToScene(Selection* itemSelection, ScribusDoc *doc, QGraphicsPathItem* parentItem, PageItem* parent);
88  void adjustHandles();
89  void updateMesh(bool gridOnly);
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;
102  QList<PageItem*> origPageItem;
103  QList<NodeItem*> nodeItems;
104  QList< Geom::Piecewise<Geom::D2<Geom::SBasis> > > origPath;
105  std::vector<Geom::Point> handles;
106  std::vector<Geom::Point> origHandles;
108 
109 private slots:
110  void doZoomIn();
111  void doZoomOut();
112  void doReset();
113 
114 protected:
115  void showEvent(QShowEvent *e);
116 };
117 
118 #endif
Definition: meshdistortiondialog.h:60
the Document Class
Definition: scribusdoc.h:90
Definition: pageitem.h:92
Definition: meshdistortiondialog.h:80
Definition: selection.h:34