28#include <karbon_part.h>
29#include <karbon_view.h>
30#include <render/vpainter.h>
31#include <render/vpainterfactory.h>
32#include <vselection.h>
33#include "vsheartool.h"
34#include <commands/vtransformcmd.h>
36VShearTool::VShearTool( KarbonView *view ) :
VTool( view,
"sheartool" )
38 setName(
"tool_shear" );
39 m_objects.setAutoDelete(
true );
43VShearTool::~VShearTool()
50 view()->setCursor( TQCursor( TQt::arrowCursor ) );
59 return i18n(
"Shear" );
65 VPainter* painter =
view()->painterFactory()->editpainter();
66 painter->setRasterOp( TQt::NotROP );
68 VObjectListIterator itr = m_objects;
69 for( ; itr.current(); ++itr )
70 itr.current()->draw( painter, &itr.current()->boundingBox() );
77 switch(
view()->part()->document().selection()->handleNode(
last() ) )
81 view()->setCursor( TQCursor( TQt::SizeFDiagCursor ) );
85 view()->setCursor( TQCursor( TQt::SizeBDiagCursor ) );
89 view()->setCursor( TQCursor( TQt::SizeHorCursor ) );
93 view()->setCursor( TQCursor( TQt::SizeVerCursor ) );
96 view()->setCursor( TQCursor( TQt::arrowCursor ) );
103 view()->painterFactory()->painter()->end();
128 new VShearCmd( &
view()->part()->document(), m_center, m_s1, m_s2,
altPressed() ),
139 view()->repaintAll(
view()->part()->document().selection()->boundingBox() );
148 if( m_activeNode == node_lt )
151 else if( m_activeNode == node_mt )
154 m_s2 = (
last().y() -
first().y() ) /
double( ( rect.height() / 2 ) );
156 else if( m_activeNode == node_rt )
159 else if( m_activeNode == node_rm)
161 m_s1 = (
last().x() -
first().x() ) /
double( ( rect.width() / 2 ) );
164 else if( m_activeNode == node_rb )
167 else if( m_activeNode == node_mb )
170 m_s2 = (
last().y() -
first().y() ) /
double( ( rect.height() / 2 ) );
172 else if( m_activeNode == node_lb )
175 else if( m_activeNode == node_lm )
177 m_s1 = (
last().x() -
first().x() ) /
double( ( rect.width() / 2 ) );
184 VShearCmd cmd( 0L, m_center, m_s1, m_s2 );
191 for ( ; itr.current() ; ++itr )
195 copy = itr.current()->
clone();
201 m_objects.append( copy );
207VShearTool::setup( TDEActionCollection *collection )
209 m_action =
static_cast<TDERadioAction *
>(collection ->
action( name() ) );
213 m_action =
new TDERadioAction( i18n(
"Shear Tool" ),
"14_shear", TQt::SHIFT+TQt::Key_H,
this, TQ_SLOT(
activate() ), collection, name() );
214 m_action->setToolTip( i18n(
"Shear" ) );
215 m_action->setExclusiveGroup(
"manipulation" );
void addCommand(VCommand *cmd, bool repaint=false)
insert a command into the undo/redo-history:
VSelection * selection() const
Returns a pointer to the selection.
virtual VObject * clone() const =0
Create an exact copy of this object.
virtual void setState(const VState state)
Sets the state to a specified new state.
@ selected
visible, active and can be manipulated by tools
@ deleted
deleted, nearly dead
@ edit
visible, active and is currently manipulated by a tool
const VObjectList & objects() const
Read only access to the selected objects.
void showHandle(bool handle=true)
Toggle selection handles on/off.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
VHandleNode handleNode(const KoPoint &point) const
Returns the handle node id, the KoPoint is inside.