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 ) );
51 view()->part()->document().selection()->showHandle(
true );
57VShearTool::statusText()
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() );
74VShearTool::setCursor()
const
76 if( isDragging() )
return;
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 ) );
101VShearTool::mouseButtonPress()
103 view()->painterFactory()->painter()->end();
104 m_activeNode = view()->part()->document().selection()->handleNode( first() );
112VShearTool::mouseDrag( )
125VShearTool::mouseDragRelease()
127 view()->part()->addCommand(
128 new VShearCmd( &view()->part()->document(), m_center, m_s1, m_s2, altPressed() ),
139 view()->repaintAll( view()->part()->document().selection()->boundingBox() );
146 KoRect rect = 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 ) );
182 m_center = view()->part()->document().selection()->boundingBox().center();
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" );
VSelection * selection() const
Returns a pointer to the selection.
The base class for all karbon objects.
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
VDocument * document() const
Return document the object belongs to.
const VObjectList & objects() const
Read only access to the selected objects.