00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KoPathControlPointMoveStrategy.h"
00022
00023 #include "KoPathTool.h"
00024 #include "KoPathCommand.h"
00025
00026 KoPathControlPointMoveStrategy::KoPathControlPointMoveStrategy( KoPathTool *tool, KoCanvasBase *canvas, KoPathPoint *point, KoPathPoint::KoPointType type, const QPointF &pos )
00027 : KoInteractionStrategy( tool, canvas )
00028 , m_lastPosition( pos )
00029 , m_move( 0, 0 )
00030 , m_tool( tool )
00031 , m_point( point )
00032 , m_pointType( type )
00033 {
00034 }
00035
00036 KoPathControlPointMoveStrategy::~KoPathControlPointMoveStrategy()
00037 {
00038 }
00039
00040 void KoPathControlPointMoveStrategy::handleMouseMove( const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers )
00041 {
00042 QPointF docPoint = m_tool->snapToGrid( mouseLocation, modifiers );
00043 QPointF move = docPoint - m_lastPosition;
00044
00045
00046 m_lastPosition = docPoint;
00047
00048 m_move += move;
00049
00050 KoControlPointMoveCommand cmd( m_point, move, m_pointType );
00051 cmd.execute();
00052 }
00053
00054 void KoPathControlPointMoveStrategy::finishInteraction( Qt::KeyboardModifiers modifiers )
00055 {
00056 Q_UNUSED( modifiers );
00057 }
00058
00059 KCommand* KoPathControlPointMoveStrategy::createCommand()
00060 {
00061 KCommand *cmd = 0;
00062 if( !m_move.isNull() )
00063 {
00064 cmd = new KoControlPointMoveCommand( m_point, m_move, m_pointType );
00065 }
00066 return cmd;
00067 }