~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/paintops/dynadraw/filter.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (c) 2008 Lukas Tvrdy <lukast.dev@gmail.com>
 
2
 *  Copyright (c) 2009-2010 Lukáš Tvrdý <lukast.dev@gmail.com>
3
3
 *
4
4
 *  This program is free software; you can redistribute it and/or modify
5
5
 *  it under the terms of the GNU General Public License as published by
19
19
#ifndef _DYNA_FILTER_H_
20
20
#define _DYNA_FILTER_H_
21
21
 
 
22
#include <QtGlobal>
22
23
 
23
24
class DynaFilter
24
25
{
25
26
public:
26
 
    DynaFilter() {
27
 
        curx = 0;
28
 
        cury = 0;
29
 
        lastx = 0;
30
 
        lasty = 0;
31
 
        velx = 0.0;
32
 
        vely = 0.0;
33
 
        accx = 0.0;
34
 
        accy = 0.0;
35
 
    }
36
 
 
37
 
    void init(qreal x, qreal y) {
38
 
        curx = x;
39
 
        cury = y;
40
 
        lastx = x;
41
 
        lasty = y;
42
 
        velx = 0.0;
43
 
        vely = 0.0;
44
 
        accx = 0.0;
45
 
        accy = 0.0;
46
 
    }
47
 
 
 
27
    DynaFilter() { initFilterPosition(0.0,0.0);  }
48
28
    ~DynaFilter() {}
49
29
 
50
 
public:
51
 
    qreal curx, cury;
52
 
    qreal velx, vely, vel;
53
 
    qreal accx, accy, acc;
54
 
    qreal angx, angy;
55
 
    qreal mass, drag;
56
 
    qreal lastx, lasty;
57
 
    bool fixedangle;
58
 
 
 
30
    void initFilterPosition(qreal x, qreal y);
 
31
    bool applyFilter(qreal cursorX, qreal cursorY);
 
32
    void setFixedAngles(qreal angleX, qreal angleY);
 
33
/* setters */    
 
34
    void setMass(qreal mass){ m_mass = mass;}
 
35
    void setDrag(qreal drag){ m_drag = drag;}
 
36
    void setUseFixedAngle(bool useFixed){ m_fixedAngle = useFixed; }
 
37
/* getters */        
 
38
    qreal velocity(){ return m_vel; }
 
39
    qreal velocityX(){ return m_velx; }
 
40
    qreal velocityY(){ return m_vely; }
 
41
    
 
42
    qreal x() { return m_filterX; }
 
43
    qreal y() { return m_filterY; }
 
44
    qreal prevX() { return m_prevX; }
 
45
    qreal prevY() { return m_prevY; }
 
46
    qreal angleX() { return m_angleX; }
 
47
    qreal angleY() { return m_angleY; }
 
48
    qreal acceleration() { return m_acc; }
 
49
     
 
50
private:
 
51
    qreal m_filterX, m_filterY;
 
52
    qreal m_velx, m_vely, m_vel; // velocity
 
53
    qreal m_accx, m_accy, m_acc; // acceleration
 
54
    qreal m_angleX, m_angleY;
 
55
    qreal m_prevX, m_prevY; // previous filtered X,Y
 
56
 
 
57
    bool m_fixedAngle;
 
58
    qreal m_fixedAngleX;
 
59
    qreal m_fixedAngleY;
 
60
 
 
61
    qreal m_mass;
 
62
    qreal m_drag;
 
63
 
 
64
private:
 
65
    // linear interpolation between f0 and f1
 
66
    qreal flerp(qreal f0, qreal f1, qreal p) {
 
67
        return ((f0 *(1.0 - p)) + (f1 * p));
 
68
    }
 
69
 
 
70
    
59
71
};
60
72
 
61
73
#endif