24#include "karbon_part.h"
25#include "karbon_view.h"
27#include "vcomposite.h"
30#include "vpainterfactory.h"
32#include "vshapetool.h"
33#include "vselection.h"
36VShapeTool::VShapeTool( KarbonView *view,
const char *name,
bool polar )
46VShapeTool::~VShapeTool()
54 TQString s = i18n(
"<qt><b>Shape tool</b><br>" );
55 s += i18n(
"<i>Click and drag</i> to place your own shape.<br>" );
56 s += i18n(
"<i>Click</i> to place a shape using the tool properties values.</qt>" );
64 view()->setCursor( *m_cursor );
77 VPainter* painter =
view()->painterFactory()->editpainter();
78 painter->setRasterOp( TQt::NotROP );
80 VPath* composite = shape();
104 VPath* composite = shape(
true );
108 VShapeCmd* cmd =
new VShapeCmd(
109 &
view()->part()->document(),
117 m_isCentered =
false;
137 VShapeCmd* cmd =
new VShapeCmd(
138 &
view()->part()->document(),
144 m_isCentered =
false;
192 m_isCentered =
false;
207 m_isCentered =
false;
217 KoPoint _first =
view()->canvasWidget()->snapToGrid(
first() );
218 KoPoint _last =
view()->canvasWidget()->snapToGrid(
last() );
225 ( _last.x() - _first.x() ) * ( _last.x() - _first.x() ) +
226 ( _last.y() - _first.y() ) * ( _last.y() - _first.y() ) );
229 m_d2 = atan2( _last.y() - _first.y(), _last.x() - _first.x() );
232 m_d2 -= VGlobal::pi_2;
239 m_d1 = _last.x() - _first.x();
240 m_d2 = _last.y() - _first.y();
242 const int m_sign1 = VGlobal::sign( m_d1 );
244 const int m_sign2 = VGlobal::sign( -m_d2 );
262 _first.x() - ( m_sign1 == -1 ? m_d1 : 0.0 ) );
265 _first.y() + ( m_sign2 == -1 ? m_d2 : 0.0 ) );
269 m_p.setX( m_p.x() - m_sign1 * tqRound( m_d1 * 0.5 ) );
270 m_p.setY( m_p.y() + m_sign2 * tqRound( m_d2 * 0.5 ) );
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.
VSelection * selection() const
Returns a pointer to the selection.
virtual void setState(const VState state)
Sets the state to a specified new state.
@ edit
visible, active and is currently manipulated by a tool
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
void showHandle(bool handle=true)
Toggle selection handles on/off.