Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a basic "ellipse" shape.

  • Loading branch information...
commit 2c87242842af31ec6b05673f6048f13279431fbf 1 parent 7505101
@mjwybrow authored
View
6 plugins/shapes/basic/basic.pro
@@ -9,8 +9,10 @@ include(../shape_plugin_options.pri)
HEADERS = \
diamond.h \
- roundedrect.h
+ roundedrect.h \
+ ellipse.h
SOURCES = plugin.cpp \
diamond.cpp \
- roundedrect.cpp
+ roundedrect.cpp \
+ ellipse.cpp
View
50 plugins/shapes/basic/ellipse.cpp
@@ -0,0 +1,50 @@
+/*
+ * Dunnart - Constraint-based Diagram Editor
+ *
+ * Copyright (C) 2012 Monash University
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * Author(s): Michael Wybrow <http://michael.wybrow.info/>
+*/
+
+#include <QString>
+
+#include "libdunnartcanvas/canvasitem.h"
+using namespace dunnart;
+
+#include "ellipse.h"
+
+//===========================================================================
+// "Ellipse" shape code:
+
+EllipseShape::EllipseShape()
+ : ShapeObj("ellipse")
+{
+}
+
+QPainterPath EllipseShape::buildPainterPath(void)
+{
+ QPainterPath painter_path;
+
+ painter_path.addEllipse(-width() / 2, -height() / 2, width(), height());
+
+ return painter_path;
+}
+
+
+// vim: filetype=cpp ts=4 sw=4 et tw=0 wm=0 cindent
View
44 plugins/shapes/basic/ellipse.h
@@ -0,0 +1,44 @@
+/*
+ * Dunnart - Constraint-based Diagram Editor
+ *
+ * Copyright (C) 2012 Monash University
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * Author(s): Michael Wybrow <http://michael.wybrow.info/>
+*/
+
+
+
+#ifndef ELLIPSE_H
+#define ELLIPSE_H
+
+#include "libdunnartcanvas/shape.h"
+using dunnart::ShapeObj;
+
+class EllipseShape: public ShapeObj
+{
+ public:
+ EllipseShape();
+ virtual ~EllipseShape() { }
+
+ virtual QPainterPath buildPainterPath(void);
+};
+
+
+#endif // ELLIPSE_H
+// vim: filetype=cpp ts=4 sw=4 et tw=0 wm=0 cindent
View
6 plugins/shapes/basic/plugin.cpp
@@ -31,6 +31,7 @@ using namespace dunnart;
#include "diamond.h"
#include "roundedrect.h"
+#include "ellipse.h"
class BasicShapesPlugin : public QObject, public ShapePluginInterface
{
@@ -51,6 +52,7 @@ class BasicShapesPlugin : public QObject, public ShapePluginInterface
shapes << "org.dunnart.shapes.rect";
shapes << "org.dunnart.shapes.diamond";
shapes << "org.dunnart.shapes.roundedRect";
+ shapes << "org.dunnart.shapes.ellipse";
return shapes;
}
ShapeObj *generateShapeOfType(QString shapeType)
@@ -67,6 +69,10 @@ class BasicShapesPlugin : public QObject, public ShapePluginInterface
{
return new RoundedRectShape();
}
+ else if (shapeType == "org.dunnart.shapes.ellipse")
+ {
+ return new EllipseShape();
+ }
return NULL;
}
};
View
6 plugins/shapes/basic/roundedrect.h
@@ -25,8 +25,8 @@
-#ifndef ELLIPSE_H
-#define ELLIPSE_H
+#ifndef ROUNDEDRECT_H
+#define ROUNDEDRECT_H
#include "libdunnartcanvas/shape.h"
using dunnart::ShapeObj;
@@ -41,5 +41,5 @@ class RoundedRectShape: public ShapeObj
};
-#endif // ELLIPSE_H
+#endif // ROUNDEDRECT_H
// vim: filetype=cpp ts=4 sw=4 et tw=0 wm=0 cindent
Please sign in to comment.
Something went wrong with that request. Please try again.