27#include <karbon_part.h>
28#include <karbon_view.h>
29#include <core/vcolor.h>
30#include <core/vcomposite.h>
31#include <core/vfill.h>
32#include <core/vstroke.h>
33#include <core/vglobal.h>
34#include <core/vcursor.h>
35#include <render/vpainter.h>
36#include <render/vpainterfactory.h>
37#include "vpolylinetool.h"
38#include <commands/vshapecmd.h>
39#include <commands/vcommand.h>
40#include <widgets/vcanvas.h>
42VPolylineTool::VPolylineTool( KarbonView *view )
43 :
VTool( view,
"tool_polyline" )
45 m_bezierPoints.setAutoDelete(
true );
50VPolylineTool::~VPolylineTool()
58 TQString s = i18n(
"<qt><b>Polyline tool:</b><br>" );
59 s += i18n(
"- <i>Click</i> to add a node and <i>drag</i> to set its bezier vector.<br>" );
60 s += i18n(
"- Press <i>Ctrl</i> while dragging to edit the previous bezier vector.<br>" );
61 s += i18n(
"- Press <i>Shift</i> while dragging to change the curve in a straight line.<br>" );
62 s += i18n(
"- Press <i>Backspace</i> to cancel the last curve.<br>" );
63 s += i18n(
"- Press <i>Esc</i> to cancel the whole polyline.<br>" );
64 s += i18n(
"- Press <i>Enter</i> or <i>double click</i> to end the polyline.</qt>" );
73 view()->statusMessage()->setText( i18n(
"Polyline Tool" ) );
74 view()->setCursor( *m_crossCursor );
79 connect(
view()->part()->commandHistory(), TQ_SIGNAL(commandExecuted()),
this, TQ_SLOT(commandExecuted()) );
102 path.curveTo( *p3, *p4, *p4 );
106 path.curveTo( *p2, *p2, *p4 );
108 path.curveTo( *p2, *p3, *p4 );
116 VPath* polyline = 0L;
119 polyline =
new VPath( 0L );
126 VShapeCmd* cmd =
new VShapeCmd(
127 &
view()->part()->document(),
148 disconnect(
view()->part()->commandHistory(), TQ_SIGNAL(commandExecuted()),
this, TQ_SLOT(commandExecuted()) );
154 VPainter* painter =
view()->painterFactory()->editpainter();
155 painter->setRasterOp( TQt::NotROP );
159 VPath polyline( 0L );
170 VPainter* painter =
view()->painterFactory()->editpainter();
174 float zoomFactor =
view()->zoom();
176 painter->setRasterOp( TQt::NotROP );
182 painter->setPen( TQt::DotLine );
183 painter->setBrush( TQt::NoBrush );
185 painter->moveTo( start );
186 painter->lineTo( end );
187 painter->strokePath();
188 painter->setRasterOp( TQt::XorROP );
190 painter->setPen( TQt::yellow );
194 painter->moveTo( KoPoint(
195 end.x() - width / zoomFactor,
196 end.y() - width / zoomFactor ) );
197 painter->lineTo( KoPoint(
198 end.x() + width / zoomFactor,
199 end.y() - width / zoomFactor ) );
200 painter->lineTo( KoPoint(
201 end.x() + width / zoomFactor,
202 end.y() + width / zoomFactor ) );
203 painter->lineTo( KoPoint(
204 end.x() - width / zoomFactor,
205 end.y() + width / zoomFactor ) );
206 painter->lineTo( KoPoint(
207 end.x() - width / zoomFactor,
208 end.y() - width / zoomFactor ) );
210 painter->strokePath();
219 KoPoint _last =
view()->canvasWidget()->snapToGrid(
last() );
234 KoPoint _last =
view()->canvasWidget()->snapToGrid(
last() );
254 KoPoint _last =
view()->canvasWidget()->snapToGrid(
last() );
262 VPainter* painter =
view()->painterFactory()->editpainter();
264 painter->setZoomFactor(
view()->zoom() );
265 painter->setRasterOp( TQt::XorROP );
266 VStroke stroke( TQt::yellow, 0L, 1.0 );
267 painter->setPen( stroke );
268 painter->setBrush( TQt::yellow );
271 painter->strokePath();
345 KoPoint _last =
view()->canvasWidget()->snapToGrid(
last() );
466 view()->setPos( p1 );
485 m_action =
static_cast<TDERadioAction *
>(collection ->
action( name() ) );
489 TDEShortcut shortcut( TQt::Key_Plus );
490 shortcut.append( TDEShortcut( TQt::Key_F9 ) );
491 m_action =
new TDERadioAction( i18n(
"Polyline Tool" ),
"14_polyline", shortcut,
this, TQ_SLOT(
activate() ), collection, name() );
492 m_action->setToolTip( i18n(
"Polyline" ) );
493 m_action->setExclusiveGroup(
"freehand" );
499VPolylineTool::commandExecuted()
504#include "vpolylinetool.moc"
void addCommand(VCommand *cmd, bool repaint=false)
insert a command into the undo/redo-history:
@ CrossHair
unthemed crosshair cursor
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.
virtual void setState(const VState state)
Sets the state to a specified new state.
@ edit
visible, active and is currently manipulated by a tool
A composite path consists of one or many subpaths.
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
void close()
Closes the current subpath.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
Manages stroke properties.