summaryrefslogtreecommitdiffstats
path: root/kivio/plugins/kivioconnectortool
diff options
context:
space:
mode:
Diffstat (limited to 'kivio/plugins/kivioconnectortool')
-rw-r--r--kivio/plugins/kivioconnectortool/Makefile.am41
-rw-r--r--kivio/plugins/kivioconnectortool/cr22-action-kivio_connector.pngbin0 -> 743 bytes
-rw-r--r--kivio/plugins/kivioconnectortool/hi22-action-kivio_connector.pngbin0 -> 166 bytes
-rw-r--r--kivio/plugins/kivioconnectortool/kivio_connector_cursor1.pngbin0 -> 176 bytes
-rw-r--r--kivio/plugins/kivioconnectortool/kivio_connector_cursor2.pngbin0 -> 175 bytes
-rw-r--r--kivio/plugins/kivioconnectortool/kivioconnectortool.desktop63
-rw-r--r--kivio/plugins/kivioconnectortool/kivioconnectortool.rc12
-rw-r--r--kivio/plugins/kivioconnectortool/plugin.cpp58
-rw-r--r--kivio/plugins/kivioconnectortool/plugin.h44
-rw-r--r--kivio/plugins/kivioconnectortool/straight_connector/Makefile.am32
-rw-r--r--kivio/plugins/kivioconnectortool/straight_connector/straight_connector.cpp379
-rw-r--r--kivio/plugins/kivioconnectortool/straight_connector/straight_connector.h95
-rw-r--r--kivio/plugins/kivioconnectortool/straight_connector/straight_connector.xpm41
-rw-r--r--kivio/plugins/kivioconnectortool/tool_connector.cpp375
-rw-r--r--kivio/plugins/kivioconnectortool/tool_connector.h101
15 files changed, 1241 insertions, 0 deletions
diff --git a/kivio/plugins/kivioconnectortool/Makefile.am b/kivio/plugins/kivioconnectortool/Makefile.am
new file mode 100644
index 00000000..10f0edd0
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/Makefile.am
@@ -0,0 +1,41 @@
+SUBDIRS = straight_connector .
+kde_module_LTLIBRARIES =libkivioconnectortool.la
+
+
+INCLUDES = -I$(top_srcdir)/kivio/kiviopart/config \
+ -I$(top_builddir)/kivio/kiviopart/config \
+ -I$(top_srcdir)/kivio/kiviopart\
+ -I$(top_srcdir)/kivio/kiviopart/kiviosdk\
+ -I$(top_srcdir)/kivio/kiviopart/tools\
+ -I$(top_srcdir)/kivio/plugins/kivioconnectortool/straight_connector \
+ -I$(top_srcdir)/kivio/plugins/kivioconnectortool/polyline_connector \
+ $(KOFFICE_INCLUDES) $(KOTEXT_INCLUDES) $(all_includes)
+libkivioconnectortool_la_METASOURCES = AUTO
+libkivioconnectortool_la_SOURCES = \
+ plugin.cpp\
+ tool_connector.cpp
+EXTRA_DIST = \
+ plugin.h\
+ plugin.cpp\
+ kivio_connector.xpm\
+ tool_connector.h\
+ tool_connector.cpp\
+ kivioconnectortool.rc\
+ kivioconnectortool.desktop\
+ kivio_connector_cursor2.xpm\
+ kivio_connector_cursor1.xpm
+
+libkivioconnectortool_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+libkivioconnectortool_la_LIBADD = $(LIB_KOPAINTER) $(top_builddir)/kivio/kiviopart/libkiviocommon.la
+
+rc_DATA = kivioconnectortool.rc
+rcdir = $(kde_datadir)/kivio/kpartplugins
+
+desktop_DATA = kivioconnectortool.desktop
+desktopdir = $(kde_servicesdir)
+
+kiviopics_DATA = kivio_connector_cursor1.png kivio_connector_cursor2.png
+kiviopicsdir = $(kde_datadir)/kivio/pics
+
+kivioicondir = $(kde_datadir)/kivio/icons
+kivioicon_ICON = AUTO
diff --git a/kivio/plugins/kivioconnectortool/cr22-action-kivio_connector.png b/kivio/plugins/kivioconnectortool/cr22-action-kivio_connector.png
new file mode 100644
index 00000000..666742d7
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/cr22-action-kivio_connector.png
Binary files differ
diff --git a/kivio/plugins/kivioconnectortool/hi22-action-kivio_connector.png b/kivio/plugins/kivioconnectortool/hi22-action-kivio_connector.png
new file mode 100644
index 00000000..fa74ce62
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/hi22-action-kivio_connector.png
Binary files differ
diff --git a/kivio/plugins/kivioconnectortool/kivio_connector_cursor1.png b/kivio/plugins/kivioconnectortool/kivio_connector_cursor1.png
new file mode 100644
index 00000000..d3819e5a
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/kivio_connector_cursor1.png
Binary files differ
diff --git a/kivio/plugins/kivioconnectortool/kivio_connector_cursor2.png b/kivio/plugins/kivioconnectortool/kivio_connector_cursor2.png
new file mode 100644
index 00000000..a3c8ebff
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/kivio_connector_cursor2.png
Binary files differ
diff --git a/kivio/plugins/kivioconnectortool/kivioconnectortool.desktop b/kivio/plugins/kivioconnectortool/kivioconnectortool.desktop
new file mode 100644
index 00000000..1f232bcb
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/kivioconnectortool.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+X-KDE-Library=libkivioconnectortool
+Name=ConnectorTool for Kivio
+Name[af]=Konnekteer gereedskap vir Kivio
+Name[ar]=أداة اتصال Kivio
+Name[az]=Kivio üçün bağlantı vasitəsi
+Name[bg]=Инструмент за свързване за Kivio
+Name[bs]=Konektor alat za Kivio
+Name[ca]=Eina connectora per a Kivio
+Name[cs]=Spojovací nástroj pro Kivio
+Name[cy]=ErfynCysylltu i Kivio
+Name[da]=Connector-værktøj for Kivio
+Name[de]=Verbindungs-Programm für Kivio
+Name[el]=Εργαλείο σύνδεσης για το Kivio
+Name[eo]=Konektilo por Kivio
+Name[es]=Herramienta de conexiones para Kivio
+Name[et]=Kivio ühenduste loomise tööriist
+Name[eu]=Kivio-ren konexiorako tresna
+Name[fa]=ابزار اتصال برای Kivio
+Name[fi]=Yhdistystyökalu Kivioon
+Name[fr]=Outil connexion pour Kivio
+Name[fy]=Ferbiningsark foar Kivio
+Name[gl]=Ferramenta de Conexón para Kivio
+Name[he]=כלי חיבור של Kivio
+Name[hr]=Alat povezivanja za Kivio
+Name[hu]=Összekapcsoló eszköz a Kivio-hoz
+Name[id]=Alat Connector buat Kivio
+Name[is]=Tengitól fyrir Kivio
+Name[it]=Strumento di connessione per Kivio
+Name[ja]=Kivio コネクタツール
+Name[km]=ឧបករណ៍​តភ្ជាប់​សម្រាប់ Kivio
+Name[lo]=ເຄື່ອງມືການເຊື່ອມຕໍ່ສຳລັບແຜນຜັງໄດອະແກຣມ K
+Name[lt]=ConnectorTool skirtas Kivio
+Name[lv]=Savienotājrīks priekš Kivio
+Name[ms]=Alat Penyambung bagi Kivio
+Name[mt]=Għodda tal-Konnessjoni għall-Kivio
+Name[nb]=Koblingsverktøy for Kivio
+Name[nds]=Tokoppelwarktüüch för Kivio
+Name[ne]=किभियोका लागि योजक उपकरण
+Name[nl]=Verbindingsgereedschap voor Kivio
+Name[nn]=Sambandsverktøy for Kivio
+Name[pl]=Narzędzie łącznika dla Kivio
+Name[pt]=Ferramenta de Ligação para o Kivio
+Name[pt_BR]=Ferramenta de conexão para o Kivio
+Name[ro]=Unealtă conectare pentru Kivio
+Name[ru]=ConnectorTool для Kivio
+Name[se]=Oktavuohtareaidu Kivio várás
+Name[sk]=Spojovací nástroj pre Kivio
+Name[sl]=Priključno orodje za Kivio
+Name[sr]=Алат за повезивање за Kivio
+Name[sr@Latn]=Alat za povezivanje za Kivio
+Name[sv]=Kopplingsverktyg för Kivio
+Name[ta]=Kivio இணைப்புக்கருவி
+Name[tg]=Асбоби Алоқакунанда барои Kivio
+Name[th]=เครื่องมือการเชื่อมต่อสำหรับแผนผังไดอะแกรม K
+Name[tr]=Kivio için Bağlantı Aracı
+Name[uk]=Засіб з'єднання для Kivio
+Name[ven]=tshishumiswa tshau tumanya tsha Kivio
+Name[xh]=Isixhobo Somxhulumanisi we Kivio
+Name[zh_CN]=Kivio 连接件工具
+Name[zh_TW]=Kivio 連接器工具
+Name[zu]=Ithuluzi lokuhlanganisa i Kivio
+Type=Service
diff --git a/kivio/plugins/kivioconnectortool/kivioconnectortool.rc b/kivio/plugins/kivioconnectortool/kivioconnectortool.rc
new file mode 100644
index 00000000..de828226
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/kivioconnectortool.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="KivioConnectorTool" library="libkivioconnectortool" version="5">
+<MenuBar>
+ <Menu name="Tools">
+ <Action name="connector"/>
+ <Action name="polyLineConnector"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="ToolsToolBar">
+ <Action name="polyLineConnector"/>
+</ToolBar>
+</kpartgui>
diff --git a/kivio/plugins/kivioconnectortool/plugin.cpp b/kivio/plugins/kivioconnectortool/plugin.cpp
new file mode 100644
index 00000000..2b4c6e41
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/plugin.cpp
@@ -0,0 +1,58 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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 "plugin.h"
+#include "tool_connector.h"
+
+#include "kivio_view.h"
+
+#include <kinstance.h>
+#include <kiconloader.h>
+
+/***************************************************
+ * Factory
+ ***************************************************/
+K_EXPORT_COMPONENT_FACTORY( libkivioconnectortool, ConnectorToolFactory )
+
+KInstance* ConnectorToolFactory::s_global = 0;
+
+ConnectorToolFactory::ConnectorToolFactory( QObject* parent, const char* name )
+: KLibFactory( parent, name )
+{
+ s_global = new KInstance("kivio");
+}
+
+ConnectorToolFactory::~ConnectorToolFactory()
+{
+ delete s_global;
+}
+
+QObject* ConnectorToolFactory::createObject( QObject* parent, const char*, const char*, const QStringList& )
+{
+ if ( !parent->inherits("KivioView") )
+ return 0;
+
+ QObject *obj = new ConnectorTool( (KivioView*)parent );
+ return obj;
+}
+
+KInstance* ConnectorToolFactory::global()
+{
+ return s_global;
+}
+#include "plugin.moc"
diff --git a/kivio/plugins/kivioconnectortool/plugin.h b/kivio/plugins/kivioconnectortool/plugin.h
new file mode 100644
index 00000000..0fbb5a9a
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/plugin.h
@@ -0,0 +1,44 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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.
+ */
+#ifndef CONNECTOR_PLUGIN_H
+#define CONNECTOR_PLUGIN_H
+
+#include <qstringlist.h>
+#include <qobject.h>
+
+#include <klibloader.h>
+
+class KInstance;
+
+class ConnectorToolFactory : public KLibFactory
+{ Q_OBJECT
+public:
+ ConnectorToolFactory( QObject* parent = 0, const char* name = 0 );
+ ~ConnectorToolFactory();
+
+ virtual QObject* createObject( QObject* parent = 0, const char* name = 0,
+ const char* classname = "QObject", const QStringList &args = QStringList() );
+
+ static KInstance* global();
+
+private:
+ static KInstance* s_global;
+};
+
+#endif
diff --git a/kivio/plugins/kivioconnectortool/straight_connector/Makefile.am b/kivio/plugins/kivioconnectortool/straight_connector/Makefile.am
new file mode 100644
index 00000000..47d68538
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/straight_connector/Makefile.am
@@ -0,0 +1,32 @@
+stencildir = $(kde_datadir)/kivio/autoloadStencils
+stencil_DATA = straight_connector.xpm
+
+kde_module_LTLIBRARIES =straight_connector.la
+
+straight_connector_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+# Hack to make it work (dave m)
+straight_connector_la_LIBADD = $(LIB_KOPAINTER) $(top_builddir)/kivio/kiviopart/libkiviocommon.la
+
+INCLUDES = -I$(top_srcdir)/kivio/kiviopart\
+ -I$(top_srcdir)/kivio/kiviopart/kiviosdk\
+ -I$(top_srcdir)/kivio/kiviopart/tools\
+ $(KOTEXT_INCLUDES)\
+ $(KOFFICE_INCLUDES) $(all_includes)
+METASOURCES = AUTO
+
+straight_connector_la_SOURCES = \
+ straight_connector.cpp
+EXTRA_DIST = \
+ straight_connector.cpp\
+ straight_connector.h\
+ straight_connector.xpm
+
+install-data-local:
+ $(mkinstalldirs) $(DESTDIR)$(stencildir)
+ -rm -f $(DESTDIR)$(stencildir)/straight_connector.so
+ $(LN_S) $(kde_moduledir)/straight_connector.so $(DESTDIR)$(stencildir)/straight_connector.so
+
+uninstall-local:
+ -rm -f $(DESTDIR)$(stencildir)/straight_connector.so
+
diff --git a/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.cpp b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.cpp
new file mode 100644
index 00000000..233c7ab8
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.cpp
@@ -0,0 +1,379 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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 <stdio.h>
+#include <math.h>
+#include "straight_connector.h"
+
+#include "kivio_common.h"
+#include "kivio_connector_target.h"
+#include "kivio_layer.h"
+#include "kivio_line_style.h"
+#include "kivio_page.h"
+#include "kivio_painter.h"
+#include "kivio_stencil.h"
+#include "kivio_stencil_spawner.h"
+#include "kivio_stencil_spawner_info.h"
+#include "kivio_stencil_spawner_set.h"
+#include "kivio_text_style.h"
+#include "tkmath.h"
+
+#include <qcolor.h>
+#include <qpixmap.h>
+#include <kdebug.h>
+#include <KoZoomHandler.h>
+
+#include "straight_connector.xpm"
+
+
+static QPixmap *pIcon = NULL;
+
+static KivioStencilSpawnerInfo sinfo = KivioStencilSpawnerInfo("Dave Marotti", "Straight Connector", "Dave Marotti - Straight Connector", "Basic Straight Connector", "0.1", "http://localhost/", "", "off");
+
+#include <kgenericfactory.h>
+K_EXPORT_COMPONENT_FACTORY( straight_connector, KGenericFactory<KivioConnectorFactory>( "KivioConnectorFactory" ) )
+
+KivioConnectorFactory::KivioConnectorFactory(QObject *parent, const char* name, const QStringList& args) :
+ KivioStencilFactory(parent, name, args)
+{
+ kdDebug(43000) << "new straight line connector factory: " << endl;
+}
+
+KivioStencil *KivioConnectorFactory::NewStencil()
+{
+ return new KivioStraightConnector();
+}
+
+KivioStencil *KivioConnectorFactory::NewStencil(const QString&)
+{
+ return new KivioStraightConnector();
+}
+
+//FIXME: Is this a memory leak?
+QPixmap *KivioConnectorFactory::GetIcon()
+{
+ if( pIcon )
+ return pIcon;
+
+ pIcon = new QPixmap( (const char **)straight_connector_xpm );
+ return pIcon;
+}
+
+KivioStencilSpawnerInfo *KivioConnectorFactory::GetSpawnerInfo()
+{
+ return &sinfo;
+}
+
+
+KivioStraightConnector::KivioStraightConnector()
+ : Kivio1DStencil()
+{
+ m_pStart->setPosition(0.0f, 0.0f, false);
+ m_pEnd->setPosition(72.0f, 72.0f, false);
+
+ m_startAH = new KivioArrowHead();
+ m_endAH = new KivioArrowHead();
+ m_needsWidth = false;
+ m_needsText = true;
+
+ m_pCanProtect->clearBit( kpAspect );
+ m_pCanProtect->clearBit( kpWidth );
+ m_pCanProtect->clearBit( kpHeight );
+ m_pCanProtect->clearBit( kpX );
+ m_pCanProtect->clearBit( kpY );
+
+ // This is a stencil of type connector
+ setType(kstConnector);
+}
+
+KivioStraightConnector::~KivioStraightConnector()
+{
+ delete m_startAH;
+ delete m_endAH;
+}
+
+void KivioStraightConnector::setStartPoint( double x, double y )
+{
+ m_pStart->setPosition( x, y, false );
+ m_pStart->disconnect();
+}
+
+void KivioStraightConnector::setEndPoint( double x, double y )
+{
+ m_pEnd->setPosition( x, y, false );
+ m_pEnd->disconnect();
+
+ if( m_needsText )
+ {
+ m_pTextConn->setPosition( (m_pStart->x()+m_pEnd->x())/2.0f,
+ (m_pStart->y()+m_pEnd->y())/2.0f,
+ false );
+ }
+}
+
+KivioCollisionType KivioStraightConnector::checkForCollision( KoPoint *p, double threshold )
+{
+ const double end_thresh = 4.0f;
+
+ double px = p->x();
+ double py = p->y();
+
+ KivioConnectorPoint *pPoint;
+
+ int i = kctCustom + 1;
+ pPoint = m_pConnectorPoints->first();
+ while( pPoint )
+ {
+ if( px >= pPoint->x() - end_thresh &&
+ px <= pPoint->x() + end_thresh &&
+ py >= pPoint->y() - end_thresh &&
+ py <= pPoint->y() + end_thresh )
+ {
+ return (KivioCollisionType)i;
+ }
+
+ i++;
+ pPoint = m_pConnectorPoints->next();
+ }
+
+
+ if( collisionLine( m_pStart->x(), m_pStart->y(),
+ m_pEnd->x(), m_pEnd->y(),
+ px, py,
+ threshold ) )
+ {
+ return kctBody;
+ }
+
+ return kctNone;
+}
+
+KivioStencil *KivioStraightConnector::duplicate()
+{
+ KivioStraightConnector *pStencil = new KivioStraightConnector();
+
+ copyBasicInto( pStencil );
+
+ // Copy the arrow head information
+ pStencil->setStartAHType( m_startAH->type() );
+ pStencil->setStartAHWidth( m_startAH->width() );
+ pStencil->setStartAHLength( m_startAH->length() );
+
+ pStencil->setEndAHType( m_endAH->type() );
+ pStencil->setEndAHWidth( m_endAH->width() );
+ pStencil->setEndAHLength( m_endAH->length() );
+
+ *(pStencil->protection()) = *m_pProtection;
+ *(pStencil->canProtect()) = *m_pCanProtect;
+
+ return pStencil;
+}
+
+void KivioStraightConnector::paint( KivioIntraStencilData *pData )
+{
+ KivioPainter *painter = pData->painter;
+ KoZoomHandler* zoomHandler = pData->zoomHandler;
+ double x1, y1, x2, y2;
+ double vecX, vecY;
+ double len;
+
+
+ painter->setLineStyle(m_pLineStyle);
+ double lineWidth = m_pLineStyle->width();
+ painter->setLineWidth(zoomHandler->zoomItY(lineWidth));
+
+ x1 = zoomHandler->zoomItX(m_pStart->x());
+ x2 = zoomHandler->zoomItX(m_pEnd->x());
+
+ y1 = zoomHandler->zoomItY(m_pStart->y());
+ y2 = zoomHandler->zoomItY(m_pEnd->y());
+
+
+ // Calculate the direction vector from start -> end
+ vecX = m_pEnd->x() - m_pStart->x();
+ vecY = m_pEnd->y() - m_pStart->y();
+
+ // Normalize the vector
+ len = sqrt( vecX*vecX + vecY*vecY );
+ if( len )
+ {
+ vecX /= len;
+ vecY /= len;
+
+ // Move the endpoints by the cuts
+ x1 += vecX * zoomHandler->zoomItX(m_startAH->cut());
+ y1 += vecY * zoomHandler->zoomItY(m_startAH->cut());
+
+ x2 -= vecX * zoomHandler->zoomItX(m_endAH->cut());
+ y2 -= vecY * zoomHandler->zoomItY(m_endAH->cut());
+ }
+
+
+ // Draw the line
+ painter->drawLine( x1, y1, x2, y2 );
+
+
+ // Now draw the arrow heads
+ if( len )
+ {
+ painter->setBGColor( m_pFillStyle->color() );
+
+ m_startAH->paint(painter, m_pStart->x(), m_pStart->y(), -vecX, -vecY, zoomHandler);
+ m_endAH->paint(painter, m_pEnd->x(), m_pEnd->y(), vecX, vecY, zoomHandler);
+ }
+
+ // Text
+ drawText(pData);
+}
+
+void KivioStraightConnector::paintOutline( KivioIntraStencilData *pData )
+{
+ KivioPainter *painter = pData->painter;
+ KoZoomHandler* zoomHandler = pData->zoomHandler;
+ double x1, y1, x2, y2;
+ double vecX, vecY;
+ double len;
+
+
+ painter->setLineStyle(m_pLineStyle);
+ double lineWidth = m_pLineStyle->width();
+ painter->setLineWidth(zoomHandler->zoomItY(lineWidth));
+
+ x1 = zoomHandler->zoomItX(m_pStart->x());
+ x2 = zoomHandler->zoomItX(m_pEnd->x());
+
+ y1 = zoomHandler->zoomItY(m_pStart->y());
+ y2 = zoomHandler->zoomItY(m_pEnd->y());
+
+
+ // Calculate the direction vector from start -> end
+ vecX = m_pEnd->x() - m_pStart->x();
+ vecY = m_pEnd->y() - m_pStart->y();
+
+ // Normalize the vector
+ len = sqrt( vecX*vecX + vecY*vecY );
+ if( len )
+ {
+ vecX /= len;
+ vecY /= len;
+
+ // Move the endpoints by the cuts
+ x1 += vecX * zoomHandler->zoomItX(m_startAH->cut());
+ y1 += vecY * zoomHandler->zoomItY(m_startAH->cut());
+
+ x2 -= vecX * zoomHandler->zoomItX(m_endAH->cut());
+ y2 -= vecY * zoomHandler->zoomItY(m_endAH->cut());
+ }
+
+
+ // Draw the line
+ painter->drawLine( x1, y1, x2, y2 );
+
+
+ // Now draw the arrow heads
+ if( len )
+ {
+ painter->setBGColor( m_pFillStyle->color() );
+
+ m_startAH->paint(painter, m_pStart->x(), m_pStart->y(), -vecX, -vecY, zoomHandler);
+ m_endAH->paint(painter, m_pEnd->x(), m_pEnd->y(), vecX, vecY, zoomHandler);
+ }
+
+ // Text
+ // Don't paint text in outline mode as it makes moving harder
+ drawText(pData);
+}
+
+bool KivioStraightConnector::saveCustom( QDomElement &e, QDomDocument &doc )
+{
+ e.appendChild( saveArrowHeads(doc) );
+
+ return true;
+}
+
+bool KivioStraightConnector::loadCustom( const QDomElement &e )
+{
+ QDomNode node;
+ QString name;
+
+ node = e.firstChild();
+ while( !node.isNull() )
+ {
+ name = node.nodeName();
+ if( name == "KivioArrowHeads" )
+ {
+ loadArrowHeads( node.toElement() );
+ }
+
+ node = node.nextSibling();
+ }
+
+ updateGeometry();
+
+ return true;
+}
+
+QDomElement KivioStraightConnector::saveArrowHeads( QDomDocument &doc )
+{
+ QDomElement e = doc.createElement("KivioArrowHeads");
+
+ e.appendChild( m_startAH->saveXML(doc) );
+ e.appendChild( m_endAH->saveXML(doc) );
+
+ return e;
+}
+
+bool KivioStraightConnector::loadArrowHeads( const QDomElement &e )
+{
+ QDomNode node;
+ QString nodeName;
+ QDomElement arrowE;
+ bool first=true;
+
+ node = e.firstChild();
+ while( !node.isNull() )
+ {
+ nodeName = node.nodeName();
+ arrowE = node.toElement();
+
+ if( nodeName == "KivioArrowHead" )
+ {
+ if( first==true )
+ {
+ m_startAH->loadXML(arrowE);
+
+ first = false;
+ }
+ else
+ {
+ m_endAH->loadXML(arrowE);
+ }
+ }
+
+ node = node.nextSibling();
+ }
+
+ return true;
+}
+
+bool KivioStraightConnector::hasTextBox() const
+{
+ return true;
+}
+
+#include "straight_connector.moc"
diff --git a/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.h b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.h
new file mode 100644
index 00000000..9cc602a5
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.h
@@ -0,0 +1,95 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ *
+ * 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.
+ */
+#ifndef STRAIGHT_CONNECTOR_H
+#define STRAIGHT_CONNECTOR_H
+
+
+#include "kivio_arrowhead.h"
+#include "kivio_connector_point.h"
+#include "kivio_custom_drag_data.h"
+#include "kivio_intra_stencil_data.h"
+#include "kiviostencilfactory.h"
+#include "kivio_point.h"
+#include "kivio_stencil.h"
+
+class KivioPage;
+
+#include <qcolor.h>
+#include <qdom.h>
+
+#include "kivio_1d_stencil.h"
+
+
+class KivioStraightConnector : public Kivio1DStencil
+{
+ protected:
+ KivioArrowHead *m_startAH;
+ KivioArrowHead *m_endAH;
+
+ bool loadArrowHeads( const QDomElement & );
+ QDomElement saveArrowHeads( QDomDocument & );
+
+ public:
+ KivioStraightConnector();
+ virtual ~KivioStraightConnector();
+
+ virtual void setStartPoint( double, double );
+ virtual void setEndPoint( double, double );
+
+ virtual KivioCollisionType checkForCollision( KoPoint *, double );
+
+ virtual KivioStencil* duplicate();
+
+ virtual void paint( KivioIntraStencilData * );
+ virtual void paintOutline( KivioIntraStencilData * );
+
+ virtual bool loadCustom( const QDomElement & );
+ virtual bool saveCustom( QDomElement &, QDomDocument & );
+
+
+ virtual void setStartAHType( int i ) { m_startAH->setType(i); }
+ virtual void setStartAHWidth( double f ) { m_startAH->setWidth(f); }
+ virtual void setStartAHLength( double f ) { m_startAH->setLength(f); }
+ virtual void setEndAHType( int i ) { m_endAH->setType(i); }
+ virtual void setEndAHWidth( double f ) { m_endAH->setWidth(f); }
+ virtual void setEndAHLength( double f ) { m_endAH->setLength(f); }
+
+ virtual int startAHType() { return m_startAH->type(); }
+ virtual double startAHWidth() { return m_startAH->width(); }
+ virtual double startAHLength() { return m_startAH->length(); }
+ virtual int endAHType() { return m_endAH->type(); }
+ virtual double endAHWidth() { return m_endAH->width(); }
+ virtual double endAHLength() { return m_endAH->length(); }
+
+ virtual bool hasTextBox() const;
+};
+
+class KIVIOPLUGINS_EXPORT KivioConnectorFactory : public KivioStencilFactory
+{
+ Q_OBJECT
+ public:
+ KivioConnectorFactory(QObject *parent=0, const char* name=0, const QStringList& args = QStringList());
+ KivioStencil *NewStencil(const QString& name);
+ KivioStencil *NewStencil();
+ QPixmap *GetIcon();
+ KivioStencilSpawnerInfo *GetSpawnerInfo();
+};
+
+#endif
+
diff --git a/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.xpm b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.xpm
new file mode 100644
index 00000000..ffe56ed7
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/straight_connector/straight_connector.xpm
@@ -0,0 +1,41 @@
+/* XPM */
+static const char * straight_connector_xpm[] = {
+"32 32 6 1",
+" c None",
+". c #F8FCF8",
+"+ c #808080",
+"@ c #FFFA00",
+"# c #000000",
+"$ c #29D82F",
+"...............................+",
+".+++++++++++++++++++++++++++++.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@####@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@#$$#@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@#$$#@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@####@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@#@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@#@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@#@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@#@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@#@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@#@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@#@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@#@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@#@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@#@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@#@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@#@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@#@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@#@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@#@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@####@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@#$$#@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@#$$#@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@####@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@.+",
+"...............................+",
+"++++++++++++++++++++++++++++++++"};
diff --git a/kivio/plugins/kivioconnectortool/tool_connector.cpp b/kivio/plugins/kivioconnectortool/tool_connector.cpp
new file mode 100644
index 00000000..87ec4729
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/tool_connector.cpp
@@ -0,0 +1,375 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ * Copyright (C) 2003-2005 Peter Simonsson <[email protected]>
+ *
+ * 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 "tool_connector.h"
+
+#include <qcursor.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <KoPoint.h>
+#include <KoZoomHandler.h>
+#include <klocale.h>
+#include <KoGuides.h>
+
+#include "kivio_view.h"
+#include "kivio_canvas.h"
+#include "kivio_page.h"
+#include "kivio_doc.h"
+#include "kivio_factory.h"
+
+#include "kivio_stencil_spawner_set.h"
+#include "kivio_stencil_spawner.h"
+#include "kivio_custom_drag_data.h"
+#include "kivio_layer.h"
+#include "kivio_point.h"
+#include "kivio_stencil.h"
+#include "straight_connector.h"
+#include "kivio_pluginmanager.h"
+#include "kivio_1d_stencil.h"
+#include "kiviopolylineconnector.h"
+#include "polylineconnectorspawner.h"
+#include "mousetoolaction.h"
+
+ConnectorTool::ConnectorTool( KivioView* parent ) : Kivio::MouseTool(parent, "Connector Mouse Tool")
+{
+ m_connectorAction = new Kivio::MouseToolAction(i18n("Straight Connector"), "kivio_connector", 0,
+ actionCollection(), "connector");
+ connect(m_connectorAction, SIGNAL(toggled(bool)), this, SLOT(setActivated(bool)));
+ connect(m_connectorAction, SIGNAL(activated()), this, SLOT(activateStraight()));
+ connect(m_connectorAction, SIGNAL(doubleClicked()), this, SLOT(makePermanent()));
+ m_connectorAction->setExclusiveGroup("ConnectorTool");
+
+ m_polyLineAction = new Kivio::MouseToolAction(i18n("Polyline Connector"), "kivio_connector", 0,
+ actionCollection(), "polyLineConnector");
+ connect(m_polyLineAction, SIGNAL(toggled(bool)), this, SLOT(setActivated(bool)));
+ connect(m_polyLineAction, SIGNAL(activated()), this, SLOT(activatePolyline()));
+ connect(m_connectorAction, SIGNAL(doubleClicked()), this, SLOT(makePermanent()));
+ m_polyLineAction->setExclusiveGroup("ConnectorTool");
+
+ m_permanent = false;
+
+ m_type = StraightConnector;
+ m_mode = stmNone;
+ m_pDragData = 0;
+
+ m_pConnectorCursor1 = new QCursor(BarIcon("kivio_connector_cursor1",KivioFactory::global()),2,2);
+ m_pConnectorCursor2 = new QCursor(BarIcon("kivio_connector_cursor2",KivioFactory::global()),2,2);
+}
+
+ConnectorTool::~ConnectorTool()
+{
+ delete m_pConnectorCursor1;
+ delete m_pConnectorCursor2;
+ delete m_pDragData;
+ m_pDragData = 0;
+}
+
+
+/**
+ * Event delegation
+ *
+ * @param e The event to be identified and processed
+ *
+ */
+bool ConnectorTool::processEvent(QEvent* e)
+{
+ switch (e->type())
+ {
+ case QEvent::MouseButtonPress:
+ mousePress( static_cast<QMouseEvent*>(e) );
+ return true;
+ break;
+
+ case QEvent::MouseButtonRelease:
+ mouseRelease( static_cast<QMouseEvent*>(e) );
+ return true;
+ break;
+
+ case QEvent::MouseMove:
+ mouseMove( static_cast<QMouseEvent*>(e) );
+ return true;
+ break;
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+void ConnectorTool::setActivated(bool a)
+{
+ if(a) {
+ view()->canvasWidget()->setCursor(*m_pConnectorCursor1);
+ m_mode = stmNone;
+ m_pStencil = 0;
+ m_pDragData = 0;
+ view()->canvasWidget()->setShowConnectorTargets(true);
+ view()->canvasWidget()->repaint();
+ emit activated(this);
+ } else {
+ if(m_pStencil && (m_mode == stmDrawRubber) && (m_type == PolyLineConnector)) {
+ Kivio::PolyLineConnector* polyconnector = static_cast<Kivio::PolyLineConnector*>(m_pStencil);
+ polyconnector->removeLastPoint();
+
+ if(polyconnector->pointCount() > 1) {
+ connector(view()->canvasWidget()->rect());
+ } else {
+ view()->activePage()->unselectStencil(polyconnector);
+ view()->activePage()->curLayer()->takeStencil(polyconnector);
+ delete polyconnector;
+ polyconnector = 0;
+ }
+
+ view()->canvasWidget()->guideLines().repaintAfterSnapping();
+ }
+
+ m_pStencil = 0;
+ delete m_pDragData;
+ m_pDragData = 0;
+ m_type = StraightConnector;
+ m_connectorAction->setChecked(false);
+ m_polyLineAction->setChecked(false);
+ m_permanent = false;
+ view()->setStatusBarInfo("");
+ view()->canvasWidget()->setShowConnectorTargets(false);
+ view()->canvasWidget()->repaint();
+ }
+}
+
+void ConnectorTool::connector(QRect)
+{
+ if (!m_pStencil)
+ return;
+
+ delete m_pDragData;
+ m_pDragData = 0;
+
+ KivioDoc* doc = view()->doc();
+ KivioPage* page = view()->activePage();
+
+ m_pStencil->searchForConnections(page, view()->zoomHandler()->unzoomItY(4));
+ doc->updateView(page);
+}
+
+void ConnectorTool::mousePress( QMouseEvent *e )
+{
+ if(e->button() == LeftButton) {
+ bool ok = true;
+ if(!m_pStencil || (m_type == StraightConnector)) {
+ ok = startRubberBanding(e);
+ } else {
+ if(m_pStencil) {
+ Kivio::PolyLineConnector* connector = static_cast<Kivio::PolyLineConnector*>(m_pStencil);
+ KivioCanvas* canvas = view()->canvasWidget();
+ KivioPage* pPage = canvas->activePage();
+ bool hit = false;
+ KoPoint point = pPage->snapToTarget(canvas->mapFromScreen(e->pos()), 8.0, hit);
+
+ if(!hit) {
+ point = canvas->snapToGrid(startPoint);
+ }
+
+ if((m_mode == stmDrawRubber) && hit) {
+ endRubberBanding(e);
+ } else {
+ connector->addPoint(point);
+ }
+ }
+ }
+
+ if(ok) {
+ m_mode = stmDrawRubber;
+ } else {
+ m_mode = stmNone;
+ }
+ } else if(e->button() == RightButton) {
+ if(m_type == PolyLineConnector) {
+ if(m_mode == stmDrawRubber) {
+ endRubberBanding(e);
+ }
+
+ view()->canvasWidget()->setCursor(*m_pConnectorCursor1);
+ m_mode = stmNone;
+ }
+ }
+}
+
+
+/**
+ * Tests if we should start rubber banding (always returns true).
+ */
+bool ConnectorTool::startRubberBanding( QMouseEvent *e )
+{
+ KivioCanvas* canvas = view()->canvasWidget();
+ KivioDoc* doc = view()->doc();
+ KivioPage* pPage = canvas->activePage();
+ QString spawnerId;
+
+ if(m_type == StraightConnector) {
+ spawnerId = "Dave Marotti - Straight Connector";
+ } else {
+ spawnerId = "Internal - PolyLine Connector";
+ }
+
+ KivioStencilSpawner* ss = doc->findInternalStencilSpawner(spawnerId);
+
+ if(!ss) {
+ kdDebug(43000) << "ConnectorTool: Failed to find StencilSpawner!" << endl;
+ return false;
+ }
+
+ // Create the stencil
+ m_pStencil = static_cast<Kivio1DStencil*>(ss->newStencil());
+
+ bool hit = false;
+ startPoint = pPage->snapToTarget(canvas->mapFromScreen(e->pos()), 8.0, hit);
+
+ if(!hit) {
+ startPoint = canvas->snapToGrid(startPoint);
+ }
+
+
+ if(!m_pStencil) {
+ return false;
+ }
+
+ m_pStencil->setTextFont(doc->defaultFont());
+
+ // Unselect everything, add the stencil to the page, and select it
+ pPage->unselectAllStencils();
+ pPage->addStencil(m_pStencil);
+ pPage->selectStencil(m_pStencil);
+ // Get drag info ready
+ m_pDragData = new KivioCustomDragData();
+ m_pDragData->page = pPage;
+ m_pDragData->x = startPoint.x();
+ m_pDragData->y = startPoint.y();
+
+ if(m_type == StraightConnector) {
+ KivioStraightConnector* connector = static_cast<KivioStraightConnector*>(m_pStencil);
+ m_pDragData->id = kctCustom + 2;
+
+ connector->setStartPoint(startPoint.x(), startPoint.y());
+ connector->setEndPoint(startPoint.x() + 10.0, startPoint.y() + 10.0);
+ } else {
+ Kivio::PolyLineConnector* connector = static_cast<Kivio::PolyLineConnector*>(m_pStencil);
+ m_pDragData->id = kctCustom + 1;
+ connector->addPoint(startPoint);
+ connector->addPoint(startPoint);
+ }
+
+ m_pStencil->customDrag(m_pDragData);
+
+ canvas->repaint();
+ canvas->setCursor(*m_pConnectorCursor2);
+ return true;
+}
+
+void ConnectorTool::mouseMove( QMouseEvent * e )
+{
+ switch( m_mode )
+ {
+ case stmDrawRubber:
+ continueRubberBanding(e);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void ConnectorTool::continueRubberBanding( QMouseEvent *e )
+{
+ KivioCanvas* canvas = view()->canvasWidget();
+ KivioPage* pPage = view()->activePage();
+ bool hit = false;
+ KoPoint endPoint = pPage->snapToTarget(canvas->mapFromScreen(e->pos()), 8.0, hit);
+
+ if(!hit) {
+ endPoint = canvas->snapToGridAndGuides(endPoint);
+ }
+
+ m_pDragData->x = endPoint.x();
+ m_pDragData->y = endPoint.y();
+
+ if(m_type == StraightConnector) {
+ KivioStraightConnector* connector = static_cast<KivioStraightConnector*>(m_pStencil);
+ connector->setEndPoint(endPoint.x(), endPoint.y());
+
+ m_pDragData->id = kctCustom + 2;
+ } else {
+ Kivio::PolyLineConnector* connector = static_cast<Kivio::PolyLineConnector*>(m_pStencil);
+ m_pDragData->id = kctCustom + connector->pointCount();
+ }
+
+ m_pStencil->customDrag(m_pDragData);
+ m_pStencil->updateGeometry();
+ canvas->repaint();
+}
+
+void ConnectorTool::mouseRelease( QMouseEvent *e )
+{
+ if(m_type == StraightConnector) {
+ switch( m_mode )
+ {
+ case stmDrawRubber:
+ endRubberBanding(e);
+ break;
+ }
+
+ view()->canvasWidget()->setCursor(*m_pConnectorCursor1);
+ m_mode = stmNone;
+ }
+}
+
+void ConnectorTool::endRubberBanding(QMouseEvent *)
+{
+ connector(view()->canvasWidget()->rect());
+ m_pStencil = 0;
+ m_mode = stmNone;
+ view()->canvasWidget()->guideLines().repaintAfterSnapping();
+
+ if(!m_permanent) {
+ view()->pluginManager()->activateDefaultTool();
+ }
+}
+
+void ConnectorTool::activateStraight()
+{
+ m_type = StraightConnector;
+ m_connectorAction->setChecked(true);
+ m_polyLineAction->setChecked(false);
+}
+
+void ConnectorTool::activatePolyline()
+{
+ m_type = PolyLineConnector;
+ m_connectorAction->setChecked(false);
+ m_polyLineAction->setChecked(true);
+ view()->setStatusBarInfo(i18n("Left mouse button to start drawing, right to end drawing."));
+}
+
+void ConnectorTool::makePermanent()
+{
+ m_permanent = true;
+}
+
+#include "tool_connector.moc"
diff --git a/kivio/plugins/kivioconnectortool/tool_connector.h b/kivio/plugins/kivioconnectortool/tool_connector.h
new file mode 100644
index 00000000..d0bb8b01
--- /dev/null
+++ b/kivio/plugins/kivioconnectortool/tool_connector.h
@@ -0,0 +1,101 @@
+/*
+ * Kivio - Visual Modelling and Flowcharting
+ * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
+ * Copyright (C) 2003-2005 Peter Simonsson <[email protected]>
+ *
+ * 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.
+ */
+#ifndef TOOL_CONNECTOR_H
+#define TOOL_CONNECTOR_H
+
+#include "kivio_mousetool.h"
+#include <KoPoint.h>
+
+class QMouseEvent;
+class QCursor;
+
+namespace Kivio {
+ class MouseToolAction;
+}
+
+class KivioView;
+class KivioPage;
+class Kivio1DStencil;
+class KivioCustomDragData;
+
+class ConnectorTool : public Kivio::MouseTool
+{
+ Q_OBJECT
+ public:
+ ConnectorTool( KivioView* parent );
+ ~ConnectorTool();
+
+ virtual bool processEvent(QEvent* e);
+
+ void connector(QRect);
+
+ public slots:
+ void setActivated(bool a);
+
+ protected slots:
+ void activateStraight();
+ void activatePolyline();
+
+ void makePermanent();
+
+ signals:
+ void operationDone();
+
+ protected:
+ void mousePress(QMouseEvent *);
+ void mouseMove(QMouseEvent *);
+ void mouseRelease(QMouseEvent *);
+
+ bool startRubberBanding(QMouseEvent*);
+ void continueRubberBanding(QMouseEvent *);
+ void endRubberBanding(QMouseEvent *);
+
+ QPoint m_startPoint, m_releasePoint;
+
+ // Connector Tool Mode
+ enum
+ {
+ stmNone,
+ stmDrawRubber
+ };
+
+ enum {
+ StraightConnector,
+ PolyLineConnector
+ };
+
+ private:
+ int m_mode; // Flag to indicate that we are drawing a rubber band
+ int m_type; // Type of connector
+ QCursor* m_pConnectorCursor1;
+ QCursor* m_pConnectorCursor2;
+ Kivio1DStencil* m_pStencil;
+ KoPoint startPoint;
+ KivioCustomDragData* m_pDragData;
+
+ Kivio::MouseToolAction* m_connectorAction;
+ Kivio::MouseToolAction* m_polyLineAction;
+
+ bool m_permanent;
+};
+
+#endif
+
+