Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit bb375962 authored by Lukáš Tvrdý's avatar Lukáš Tvrdý

Initial commit for dyna tool made from dynabrush. Turned off with BUILD_EVERYTHING

svn path=/trunk/koffice/; revision=941678
parent fd09e2a8
......@@ -11,4 +11,8 @@ add_subdirectory( tool_perspectivegrid )
add_subdirectory( tool_grid )
#add_subdirectory( tool_perspectivetransform )
if ( BUILD_EVERYTHING )
add_subdirectory ( tool_dyna )
endif( BUILD_EVERYTHING )
message("Krita: Port the perspective transform tool")
set(kritatooldyna_PART_SRCS
tool_dyna.cpp
kis_tool_dyna.cpp
)
kde4_add_plugin(kritatooldyna ${kritatooldyna_PART_SRCS})
target_link_libraries(kritatooldyna kritaui)
install(TARGETS kritatooldyna DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
# TODO
# install( FILES tool_crop_cursor.png tool_crop.png DESTINATION ${DATA_INSTALL_DIR}/krita/pics)
install( FILES kritatooldyna.desktop DESTINATION ${SERVICES_INSTALL_DIR})
This diff is collapsed.
/*
* Copyright (c) 2009 Lukáš Tvrdý <lukast.dev@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_TOOL_DYNA_H_
#define KIS_TOOL_DYNA_H_
#include "kis_tool_freehand.h"
#include "KoToolFactory.h"
#include "KoPointerEvent.h"
#include <flake/kis_node_shape.h>
class QTimer;
class QCheckBox;
class QComboBox;
class QGridLayout;
class QSlider;
class KoCanvasBase;
class DynaFilter {
public:
DynaFilter() {
curx = 0;
cury = 0;
lastx = 0;
lasty = 0;
velx = 0.0;
vely = 0.0;
accx = 0.0;
accy = 0.0;
}
void init(qreal x, qreal y) {
curx = x;
cury = y;
lastx = x;
lasty = y;
velx = 0.0;
vely = 0.0;
accx = 0.0;
accy = 0.0;
}
~DynaFilter(){}
public:
qreal curx, cury;
qreal velx, vely, vel;
qreal accx, accy, acc;
qreal angx, angy;
qreal mass, drag;
qreal lastx, lasty;
bool fixedangle;
};
class KisToolDyna : public KisToolFreehand
{
Q_OBJECT
public:
KisToolDyna(KoCanvasBase * canvas);
virtual ~KisToolDyna();
// TODO vymyslet GUI
QWidget * createOptionWidget();
virtual void mousePressEvent(KoPointerEvent *e);
virtual void mouseMoveEvent(KoPointerEvent *e);
protected:
virtual void initPaint(KoPointerEvent *e);
virtual void endPaint();
private slots:
void timeoutPaint();
void slotSetSmoothness(int smoothness);
void slotSetMagnetism(int magnetism);
private:
qint32 m_rate;
QTimer * m_timer;
QGridLayout* m_optionLayout;
QCheckBox * m_chkSmooth;
QCheckBox * m_chkAssistant;
QCheckBox * m_chkQueueing;
QSlider * m_sliderMagnetism;
QSlider * m_sliderSmoothness;
qreal m_previousPressure;
// dyna algorithm
QVector<QPointF> m_prevPosition;
qreal m_odelx, m_odely;
// mouse info
QPointF m_mousePos;
bool first;
// settings variables
qreal m_width;
qreal m_curmass;
qreal m_curdrag;
DynaFilter m_mouse;
qreal m_xangle;
qreal m_yangle;
qreal m_widthRange;
// methods
qreal flerp(qreal f0, qreal f1, qreal p) { return ((f0 * (1.0 - p)) + (f1 * p)); }
void initMouse(const QPointF &point) {
m_mousePos.setX( point.x() / currentImage()->width() );
m_mousePos.setY( point.y() / currentImage()->height() );
}
void initDyna();
int applyFilter(qreal mx, qreal my);
void drawSegment(KoPointerEvent * event);
};
class KisToolDynaFactory : public KoToolFactory
{
public:
KisToolDynaFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KritaShape/KisToolDyna", i18n("Paint")) {
setToolTip(i18n("Paint with brushes using dynamic movements"));
// Temporarily
setToolType(TOOL_TYPE_SHAPE);
setIcon("krita_tool_dyna");
// TODO
//setShortcut(KShortcut(Qt::Key_F));
setPriority(0);
//setActivationShapeId( KIS_NODE_SHAPE_ID );
setInputDeviceAgnostic(false);
}
virtual ~KisToolDynaFactory() {}
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolDyna(canvas);
}
};
#endif // KIS_TOOL_DYNA_H_
[Desktop Entry]
Name=Dyna Tool
X-KDE-ServiceTypes=Krita/Tool
Type=Service
X-KDE-Library=kritatooldyna
X-Krita-Version=3
/*
* tool_dyna.cpp -- Part of Krita
*
* Copyright (c) 2009 Lukáš Tvrdý <lukast.dev@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "tool_dyna.h"
#include <stdlib.h>
#include <vector>
#include <QPoint>
#include <klocale.h>
#include <kiconloader.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <kis_debug.h>
#include <kis_paint_device.h>
#include <kgenericfactory.h>
#include <kis_global.h>
#include <kis_types.h>
#include <KoToolRegistry.h>
#include "kis_tool_dyna.h"
typedef KGenericFactory<ToolDyna> ToolDynaFactory;
K_EXPORT_COMPONENT_FACTORY(kritatooldyna, ToolDynaFactory("krita"))
ToolDyna::ToolDyna(QObject *parent, const QStringList &)
: KParts::Plugin(parent)
{
setComponentData(ToolDynaFactory::componentData());
KoToolRegistry * r = KoToolRegistry::instance();
r->add(new KisToolDynaFactory(r, QStringList()));
}
ToolDyna::~ToolDyna()
{
}
#include "tool_dyna.moc"
/*
* Copyright (c) 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TOOL_DYNA_H_
#define TOOL_DYNA_H_
#include <kparts/plugin.h>
/**
* A module that provides a polygon tool.
*/
class ToolDyna : public KParts::Plugin
{
Q_OBJECT
public:
ToolDyna(QObject *parent, const QStringList &);
virtual ~ToolDyna();
};
#endif // TOOL_DYNA_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment