3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #define DEBUG_KP_TOOL_POLYLINE 0
32 #include <kpToolPolyline.h>
37 #include <kpPainter.h>
40 kpToolPolyline::kpToolPolyline (kpToolEnvironment
*environ
, QObject
*parent
)
41 : kpToolPolygonalBase (
42 i18n ("Connected Lines"),
43 i18n ("Draws connected lines"),
51 kpToolPolyline::~kpToolPolyline ()
56 // private virtual [base kpToolPolygonalBase]
57 QString
kpToolPolyline::haventBegunShapeUserMessage () const
59 return i18n ("Drag to draw the first line.");
64 void kpToolPolyline::DrawShape (kpImage
*image
,
65 const QPolygon
&points
,
66 const kpColor
&fcolor
, int penWidth
,
67 const kpColor
&bcolor
,
73 kpPainter::drawPolyline (image
,
79 // public virtual [base kpTool]
80 void kpToolPolyline::endDraw (const QPoint
&, const QRect
&)
82 #if DEBUG_KP_TOOL_POLYLINE
83 kDebug () << "kpToolPolyline::endDraw() points="
84 << points ()->toList () << endl
;
87 // A click of the other mouse button (to finish shape, instead of adding
88 // another control point) would have caused endShape() to have been
89 // called in kpToolPolygonalBase::beginDraw(). The points list would now
90 // be empty. We are being called by kpTool::mouseReleaseEvent().
91 if (points ()->count () == 0)
94 if (points ()->count () >= kpToolPolygonalBase::MaxPoints
)
96 #if DEBUG_KP_TOOL_POLYLINE
97 kDebug () << "\tending shape";
103 if (originatingMouseButton () == 0)
105 setUserMessage (i18n ("Left drag another line or right click to finish."));
109 setUserMessage (i18n ("Right drag another line or left click to finish."));
114 #include <kpToolPolyline.moc>