author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/multimedia/tonleiter | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/multimedia/tonleiter') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/tonleiter/config.in | 2 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiter.pro | 6 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | 6 |
6 files changed, 29 insertions, 20 deletions
diff --git a/noncore/multimedia/tonleiter/config.in b/noncore/multimedia/tonleiter/config.in index d580ad7..9bd167e 100644 --- a/noncore/multimedia/tonleiter/config.in +++ b/noncore/multimedia/tonleiter/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config TONLEITER | 1 | config TONLEITER |
2 | boolean "tonleiter (shows scales on sting instruments)" | 2 | boolean "tonleiter (shows scales on sting instruments)" |
3 | default "n" | 3 | default "n" |
4 | depends ( LIBQPE || LIBQPE-X11 ) | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE |
diff --git a/noncore/multimedia/tonleiter/editinst.cpp b/noncore/multimedia/tonleiter/editinst.cpp index ccb4560..a8c20c8 100644 --- a/noncore/multimedia/tonleiter/editinst.cpp +++ b/noncore/multimedia/tonleiter/editinst.cpp | |||
@@ -1,17 +1,22 @@ | |||
1 | #include "editinst.h" | 1 | #include "editinst.h" |
2 | 2 | ||
3 | #include <qpushbutton.h> | 3 | /* OPIE */ |
4 | 4 | #include <opie2/odebug.h> | |
5 | #include <qpe/config.h> | ||
5 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | using namespace Opie::Core; | ||
8 | |||
9 | /* QT */ | ||
10 | #include <qpushbutton.h> | ||
6 | 11 | ||
7 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) | 12 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) |
8 | :QDialog(parent,name,true,0),data(data) | 13 | :QDialog(parent,name,true,0),data(data) |
9 | { | 14 | { |
10 | setCaption("Tonleiter::"+tr("Instrument")); | 15 | setCaption("Tonleiter::"+tr("Instrument")); |
11 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); | 16 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); |
12 | instid=data->getCurrentInstrumentID(); | 17 | instid=data->getCurrentInstrumentID(); |
13 | stringlist.setAutoDelete(true); | 18 | stringlist.setAutoDelete(true); |
14 | 19 | ||
15 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); | 20 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); |
16 | 21 | ||
17 | //Name combo + Add + Delete | 22 | //Name combo + Add + Delete |
@@ -91,20 +96,20 @@ void Menu::InstEditDialog::deleteString(int id) | |||
91 | } | 96 | } |
92 | //**************************************************************************** | 97 | //**************************************************************************** |
93 | void Menu::InstEditDialog::saveInstrument() | 98 | void Menu::InstEditDialog::saveInstrument() |
94 | { | 99 | { |
95 | //auto delete is set to true so widgets _should_ be deleted | 100 | //auto delete is set to true so widgets _should_ be deleted |
96 | stringlist.clear(); | 101 | stringlist.clear(); |
97 | } | 102 | } |
98 | //**************************************************************************** | 103 | //**************************************************************************** |
99 | void Menu::InstEditDialog::loadInstrument() | 104 | void Menu::InstEditDialog::loadInstrument() |
100 | { | 105 | { |
101 | stringlist.clear(); | 106 | stringlist.clear(); |
102 | Instrument inst=data->getInstrument(instid); | 107 | Instrument inst=data->getInstrument(instid); |
103 | qDebug("load Instrument : %d strings",inst.noOfStrings()); | 108 | odebug << "load Instrument : " << inst.noOfStrings() << " strings" << oendl; |
104 | for(uint s=0;s<inst.noOfStrings();s++) | 109 | for(uint s=0;s<inst.noOfStrings();s++) |
105 | { | 110 | { |
106 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); | 111 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); |
107 | } | 112 | } |
108 | } | 113 | } |
109 | //**************************************************************************** | 114 | //**************************************************************************** |
110 | //**************************************************************************** | 115 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/fretboard.cpp b/noncore/multimedia/tonleiter/fretboard.cpp index 7e63e01..58bdb86 100644 --- a/noncore/multimedia/tonleiter/fretboard.cpp +++ b/noncore/multimedia/tonleiter/fretboard.cpp | |||
@@ -1,14 +1,19 @@ | |||
1 | #include "fretboard.h" | 1 | #include "fretboard.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | /* QT */ | ||
3 | #include <qpainter.h> | 8 | #include <qpainter.h> |
4 | 9 | ||
5 | Graph::FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f) | 10 | Graph::FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f) |
6 | :QWidget(parent,name,f),data(data) | 11 | :QWidget(parent,name,f),data(data) |
7 | { | 12 | { |
8 | setBackgroundColor(QColor(0,0,0)); | 13 | setBackgroundColor(QColor(0,0,0)); |
9 | fretpen=QPen(QColor(155,155,155),0); | 14 | fretpen=QPen(QColor(155,155,155),0); |
10 | markerbrush=QBrush(QColor(155,155,155)); | 15 | markerbrush=QBrush(QColor(155,155,155)); |
11 | stringpen=QPen(QColor(255,255,255),3); | 16 | stringpen=QPen(QColor(255,255,255),3); |
12 | connect(data,SIGNAL(dataChange()),this,SLOT(dataChange())); | 17 | connect(data,SIGNAL(dataChange()),this,SLOT(dataChange())); |
13 | } | 18 | } |
14 | //**************************************************************************** | 19 | //**************************************************************************** |
@@ -18,25 +23,25 @@ Graph::FretBoard::~FretBoard() | |||
18 | //**************************************************************************** | 23 | //**************************************************************************** |
19 | void Graph::FretBoard::dataChange() | 24 | void Graph::FretBoard::dataChange() |
20 | { | 25 | { |
21 | repaint(true); | 26 | repaint(true); |
22 | } | 27 | } |
23 | //**************************************************************************** | 28 | //**************************************************************************** |
24 | void Graph::FretBoard::paintEvent(QPaintEvent* pe) | 29 | void Graph::FretBoard::paintEvent(QPaintEvent* pe) |
25 | { | 30 | { |
26 | Q_UNUSED(pe); | 31 | Q_UNUSED(pe); |
27 | 32 | ||
28 | int instid=data->getCurrentInstrumentID(); | 33 | int instid=data->getCurrentInstrumentID(); |
29 | inst=data->getInstrument(instid); | 34 | inst=data->getInstrument(instid); |
30 | //qDebug("inst %d is %s",instid,inst.instName().data()); | 35 | //odebug << "inst " << instid << " is " << inst.instName().data() << "" << oendl; |
31 | 36 | ||
32 | QRect mysize=rect(); | 37 | QRect mysize=rect(); |
33 | 38 | ||
34 | xmargin=(int)(mysize.width()*0.05); | 39 | xmargin=(int)(mysize.width()*0.05); |
35 | xmin=2*xmargin; | 40 | xmin=2*xmargin; |
36 | xmax=mysize.width()-xmargin; | 41 | xmax=mysize.width()-xmargin; |
37 | xwidth=xmax-xmin; | 42 | xwidth=xmax-xmin; |
38 | 43 | ||
39 | ymargin=(int)(mysize.height()*0.1); | 44 | ymargin=(int)(mysize.height()*0.1); |
40 | ymin=ymargin; | 45 | ymin=ymargin; |
41 | ymax=mysize.height()-2*ymargin; | 46 | ymax=mysize.height()-2*ymargin; |
42 | yheight=ymax-ymin; | 47 | yheight=ymax-ymin; |
@@ -134,35 +139,35 @@ void Graph::FretBoard::paintScale(QPainter* p) | |||
134 | int y=(int)(stringdist*s)+ymin; | 139 | int y=(int)(stringdist*s)+ymin; |
135 | int stingid=inst.noOfStrings()-(s+1); | 140 | int stingid=inst.noOfStrings()-(s+1); |
136 | for(int f=0;f<=inst.noOfFrets();f++) | 141 | for(int f=0;f<=inst.noOfFrets();f++) |
137 | { | 142 | { |
138 | int note=inst.string(stingid)+f; | 143 | int note=inst.string(stingid)+f; |
139 | if(scale.noteInScale(data->getCurrentBaseNote(),note)) | 144 | if(scale.noteInScale(data->getCurrentBaseNote(),note)) |
140 | { | 145 | { |
141 | int x=(int)(fretdist*f)+xmin; | 146 | int x=(int)(fretdist*f)+xmin; |
142 | 147 | ||
143 | //no more than six octaves can be visualised (there is a zero octave) | 148 | //no more than six octaves can be visualised (there is a zero octave) |
144 | int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note)-baseoctave; | 149 | int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note)-baseoctave; |
145 | if(octave<0) | 150 | if(octave<0) |
146 | qDebug("%d,%d",octave,baseoctave); | 151 | odebug << "" << octave << "," << baseoctave << "" << oendl; |
147 | if(octave>5) | 152 | if(octave>5) |
148 | { | 153 | { |
149 | qDebug("octave out of range"); | 154 | odebug << "octave out of range" << oendl; |
150 | octave=5; | 155 | octave=5; |
151 | } | 156 | } |
152 | 157 | ||
153 | p->setPen(QColor(255,0,0)); | 158 | p->setPen(QColor(255,0,0)); |
154 | int c= ( (note-12*baseoctave) - (12*octave+data->getCurrentBaseNote()) )*15; | 159 | int c= ( (note-12*baseoctave) - (12*octave+data->getCurrentBaseNote()) )*15; |
155 | if(c<0 || c>255) | 160 | if(c<0 || c>255) |
156 | qDebug("%d = %d - ( %d + %d)",c,note,12*octave,data->getCurrentBaseNote()); | 161 | odebug << "" << c << " = " << note << " - ( " << 12*octave << " + " << data->getCurrentBaseNote() << ")" << oendl; |
157 | QColor dotcolor(255,255,255); | 162 | QColor dotcolor(255,255,255); |
158 | 163 | ||
159 | if(octave==0) | 164 | if(octave==0) |
160 | dotcolor=QColor(c,c,255); | 165 | dotcolor=QColor(c,c,255); |
161 | else if(octave==1) | 166 | else if(octave==1) |
162 | dotcolor=QColor(c,255,c); | 167 | dotcolor=QColor(c,255,c); |
163 | else if(octave==2) | 168 | else if(octave==2) |
164 | dotcolor=QColor(255,c,c); | 169 | dotcolor=QColor(255,c,c); |
165 | else if(octave==3) | 170 | else if(octave==3) |
166 | dotcolor=QColor(255,255,c); | 171 | dotcolor=QColor(255,255,c); |
167 | else if(octave==4) | 172 | else if(octave==4) |
168 | dotcolor=QColor(255,c,255); | 173 | dotcolor=QColor(255,c,255); |
diff --git a/noncore/multimedia/tonleiter/tonleiter.pro b/noncore/multimedia/tonleiter/tonleiter.pro index 4bd1bc2..4be3bef 100644 --- a/noncore/multimedia/tonleiter/tonleiter.pro +++ b/noncore/multimedia/tonleiter/tonleiter.pro | |||
@@ -1,13 +1,11 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on | ||
3 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
4 | HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editstringwidget.h editscale.h pianoscale.h | 3 | HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editstringwidget.h editscale.h pianoscale.h |
5 | SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editstringwidget.cpp editscale.cpp pianoscale.cpp | 4 | SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editstringwidget.cpp editscale.cpp pianoscale.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
8 | LIBS += -lqpe | 7 | LIBS += -lqpe -lopiecore2 |
9 | INTERFACES = | ||
10 | TARGET = tonleiter | 8 | TARGET = tonleiter |
11 | DESTDIR = $(OPIEDIR)/bin | 9 | DESTDIR = $(OPIEDIR)/bin |
12 | #TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti | 10 | |
13 | include ( $(OPIEDIR)/include.pro ) | 11 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.cpp b/noncore/multimedia/tonleiter/tonleiterdata.cpp index 33b3c49..564b7f0 100644 --- a/noncore/multimedia/tonleiter/tonleiterdata.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdata.cpp | |||
@@ -1,18 +1,19 @@ | |||
1 | #include "tonleiterdata.h" | 1 | #include "tonleiterdata.h" |
2 | |||
3 | #include <qpe/config.h> | ||
4 | |||
5 | using namespace Data; | 2 | using namespace Data; |
6 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | #include <qpe/config.h> | ||
7 | using namespace Opie::Core; | ||
7 | 8 | ||
8 | TonleiterData::TonleiterData(QObject* parent) | 9 | TonleiterData::TonleiterData(QObject* parent) |
9 | :QObject(parent) | 10 | :QObject(parent) |
10 | { | 11 | { |
11 | drawnames=true; | 12 | drawnames=true; |
12 | loadData(); | 13 | loadData(); |
13 | } | 14 | } |
14 | //**************************************************************************** | 15 | //**************************************************************************** |
15 | TonleiterData::~TonleiterData() | 16 | TonleiterData::~TonleiterData() |
16 | { | 17 | { |
17 | saveData(); | 18 | saveData(); |
18 | } | 19 | } |
@@ -143,47 +144,47 @@ void TonleiterData::saveData() | |||
143 | //**************************************************************************** | 144 | //**************************************************************************** |
144 | int TonleiterData::noOfInstruments() | 145 | int TonleiterData::noOfInstruments() |
145 | { | 146 | { |
146 | return (int)instruments.count(); | 147 | return (int)instruments.count(); |
147 | } | 148 | } |
148 | //**************************************************************************** | 149 | //**************************************************************************** |
149 | Instrument TonleiterData::getInstrument(int id) | 150 | Instrument TonleiterData::getInstrument(int id) |
150 | { | 151 | { |
151 | if(id>=0 && id<noOfInstruments()) | 152 | if(id>=0 && id<noOfInstruments()) |
152 | return instruments[id]; | 153 | return instruments[id]; |
153 | else | 154 | else |
154 | { | 155 | { |
155 | qDebug("undefined insrtument %d of %d",id,instruments.count()); | 156 | odebug << "undefined insrtument " << id << " of " << instruments.count() << "" << oendl; |
156 | return Instrument(); | 157 | return Instrument(); |
157 | } | 158 | } |
158 | 159 | ||
159 | } | 160 | } |
160 | //**************************************************************************** | 161 | //**************************************************************************** |
161 | int TonleiterData::getCurrentInstrumentID() | 162 | int TonleiterData::getCurrentInstrumentID() |
162 | { | 163 | { |
163 | return currentInstrumentID; | 164 | return currentInstrumentID; |
164 | } | 165 | } |
165 | //**************************************************************************** | 166 | //**************************************************************************** |
166 | int TonleiterData::noOfScales() | 167 | int TonleiterData::noOfScales() |
167 | { | 168 | { |
168 | return (int)scales.count(); | 169 | return (int)scales.count(); |
169 | } | 170 | } |
170 | //**************************************************************************** | 171 | //**************************************************************************** |
171 | Scale TonleiterData::getScale(int id) | 172 | Scale TonleiterData::getScale(int id) |
172 | { | 173 | { |
173 | if(id>=0 && id<noOfScales()) | 174 | if(id>=0 && id<noOfScales()) |
174 | return scales[id]; | 175 | return scales[id]; |
175 | else | 176 | else |
176 | { | 177 | { |
177 | qDebug("Undefined scale"); | 178 | odebug << "Undefined scale" << oendl; |
178 | return Scale(); | 179 | return Scale(); |
179 | } | 180 | } |
180 | } | 181 | } |
181 | //**************************************************************************** | 182 | //**************************************************************************** |
182 | int TonleiterData::getCurrentScaleID() | 183 | int TonleiterData::getCurrentScaleID() |
183 | { | 184 | { |
184 | return currentScaleID; | 185 | return currentScaleID; |
185 | } | 186 | } |
186 | //**************************************************************************** | 187 | //**************************************************************************** |
187 | int TonleiterData::getCurrentBaseNote() | 188 | int TonleiterData::getCurrentBaseNote() |
188 | { | 189 | { |
189 | return currentNote; | 190 | return currentNote; |
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp index d904a71..285d2c1 100644 --- a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | |||
@@ -25,25 +25,25 @@ int Note::getNoteFromName(QString name,int octave) | |||
25 | { | 25 | { |
26 | notevalue=a; | 26 | notevalue=a; |
27 | break; | 27 | break; |
28 | } | 28 | } |
29 | } | 29 | } |
30 | return notevalue+12*octave; | 30 | return notevalue+12*octave; |
31 | } | 31 | } |
32 | //**************************************************************************** | 32 | //**************************************************************************** |
33 | int Note::octaveOfBaseNote(int base,int note) | 33 | int Note::octaveOfBaseNote(int base,int note) |
34 | { | 34 | { |
35 | int normnote = (note>=base) ? note-base : (12-base)+note; | 35 | int normnote = (note>=base) ? note-base : (12-base)+note; |
36 | int octave=getOctaveOfNote(normnote); | 36 | int octave=getOctaveOfNote(normnote); |
37 | //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave); | 37 | //odebug << "note " << note << " of " << base << " base is norm " << normnote << " -> ocatve " << octave << "" << oendl; |
38 | return octave; | 38 | return octave; |
39 | } | 39 | } |
40 | //**************************************************************************** | 40 | //**************************************************************************** |
41 | //**************************************************************************** | 41 | //**************************************************************************** |
42 | Instrument::Instrument() | 42 | Instrument::Instrument() |
43 | { | 43 | { |
44 | name="UNDEFINED"; | 44 | name="UNDEFINED"; |
45 | frets=0; | 45 | frets=0; |
46 | } | 46 | } |
47 | //**************************************************************************** | 47 | //**************************************************************************** |
48 | Instrument::Instrument(QString name,int frets,QValueList<int> strings) | 48 | Instrument::Instrument(QString name,int frets,QValueList<int> strings) |
49 | :name(name),frets(frets),strings(strings) | 49 | :name(name),frets(frets),strings(strings) |
@@ -122,23 +122,23 @@ QString Scale::scaleName() | |||
122 | { | 122 | { |
123 | return name; | 123 | return name; |
124 | } | 124 | } |
125 | //**************************************************************************** | 125 | //**************************************************************************** |
126 | bool Scale::noteInScale(int base,int note) | 126 | bool Scale::noteInScale(int base,int note) |
127 | { | 127 | { |
128 | int octave=Note::getOctaveOfNote(note); | 128 | int octave=Note::getOctaveOfNote(note); |
129 | note-=12*octave; | 129 | note-=12*octave; |
130 | int normnote = (note>=base) ? note-base : (12-base)+note; | 130 | int normnote = (note>=base) ? note-base : (12-base)+note; |
131 | 131 | ||
132 | if(halftones.contains(normnote)>0) | 132 | if(halftones.contains(normnote)>0) |
133 | { | 133 | { |
134 | //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote); | 134 | //odebug << "OK : base : " << base << ", note " << note << " -> norm " << normnote << "" << oendl; |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
137 | else | 137 | else |
138 | { | 138 | { |
139 | //qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote); | 139 | //odebug << "BAD : base : " << base << ", note " << note << " -> norm " << normnote << "" << oendl; |
140 | return false; | 140 | return false; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | //**************************************************************************** | 143 | //**************************************************************************** |
144 | //**************************************************************************** | 144 | //**************************************************************************** |