summaryrefslogtreecommitdiff
path: root/src/connector.cpp
diff options
context:
space:
mode:
authorLukáš Lalinský <lalinsky@gmail.com>2008-12-30 10:26:14 +0100
committerLukáš Lalinský <lalinsky@gmail.com>2008-12-30 10:26:14 +0100
commit033bf7a0b5baa26af94ad006f6576d04c8609e9e (patch)
tree499e36f09515f2bc3f23cf09e2364666888002bb /src/connector.cpp
parent3a95c3cd621e3904d717b591aaa9f2c89959981e (diff)
downloaddbmodel-033bf7a0b5baa26af94ad006f6576d04c8609e9e.tar.xz
Implement orthogonal line drawing
Diffstat (limited to 'src/connector.cpp')
-rw-r--r--src/connector.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/connector.cpp b/src/connector.cpp
new file mode 100644
index 0000000..6395546
--- /dev/null
+++ b/src/connector.cpp
@@ -0,0 +1,99 @@
+// Copyright (C) 2008 Lukas Lalinsky
+//
+// 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.
+
+#include "connector.h"
+#include "hub.h"
+#include "diagramconnection.h"
+
+Connector::Connector(DiagramConnection *owner)
+ : m_owner(owner), m_hub(NULL)
+{
+}
+
+DiagramConnection *
+Connector::owner() const
+{
+ return m_owner;
+}
+
+QPointF
+Connector::pos() const
+{
+ return m_pos;
+}
+
+void
+Connector::setPos(const QPointF &pos)
+{
+ if (m_pos != pos) {
+ m_pos = pos;
+ }
+}
+
+qreal
+Connector::angle() const
+{
+ return m_angle;
+}
+
+void
+Connector::setAngle(qreal angle)
+{
+ if (m_angle != angle) {
+ m_angle = angle;
+ }
+}
+
+Hub *
+Connector::hub() const
+{
+ return m_hub;
+}
+
+void
+Connector::setHub(Hub *hub)
+{
+ if (hub)
+ hub->removeConnector(this);
+ m_hub = hub;
+ m_hub->addConnector(this);
+}
+
+bool
+Connector::isConnected() const
+{
+ return m_hub;
+}
+
+DiagramObject *
+Connector::connectedObject() const
+{
+ if (isConnected())
+ return hub()->owner();
+ return NULL;
+}
+
+Connector *
+Connector::otherEnd() const
+{
+ DiagramConnection *conn = owner();
+ if (conn->connector(0) == this) {
+ return conn->connector(1);
+ }
+ else {
+ return conn->connector(0);
+ }
+}