1 //============================================================================= 2 // MusE Reader 3 // Music Score Reader 4 // 5 // Copyright (C) 2010 Werner Schweer 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 //============================================================================= 19 20 #ifndef __PATTERN_H__ 21 #define __PATTERN_H__ 22 23 #include "libmscore/score.h" 24 25 namespace Ms { 26 27 class Sym; 28 29 //--------------------------------------------------------- 30 // Pattern 31 // _n % sizeof(int) is zero, patterns are 32bit padded 32 //--------------------------------------------------------- 33 34 class Pattern { 35 protected: 36 QImage _image; 37 SymId _id; 38 QPoint _base; 39 Score *_score; 40 float **model; 41 int rows; 42 int cols; 43 44 public: 45 Pattern(); 46 ~Pattern(); 47 Pattern(Score *s, SymId id, double spatium); 48 Pattern(Score *s, QString name); 49 Pattern(QImage*, int, int, int, int); 50 51 double match(const Pattern*) const; 52 double match(const QImage* , int , int ) const; 53 double match(const QImage* img, int col, int row, double bg_parm) const; 54 55 void dump() const; image()56 const QImage* image() const { return &_image; } w()57 int w() const { return cols; /*_image.width();*/ } h()58 int h() const { return rows; /*_image.height();*/ } 59 bool dot(int x, int y) const; id()60 SymId id() const { return _id; } setId(SymId val)61 void setId(SymId val) { _id = val; } base()62 const QPoint& base() const { return _base; } setBase(const QPoint & v)63 void setBase(const QPoint& v) { _base = v; } 64 }; 65 } 66 67 #endif 68 69