summaryrefslogtreecommitdiffstats
path: root/src/misc/Debug.cpp
blob: 72182263885e66895b10380195f7df01afd46ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// -*- c-basic-offset: 4 -*-

/*
    Rosegarden
    A sequencer and musical notation editor.
 
    This program is Copyright 2000-2008
        Guillaume Laurent   <glaurent@telegraph-road.org>,
        Chris Cannam        <cannam@all-day-breakfast.com>,
        Richard Bown        <bownie@bownie.com>
 
    The moral right of the authors to claim authorship of this work
    has been asserted.
 
    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.  See the file
    COPYING included with this distribution for more information.
*/

#include "Strings.h"
#include "misc/Debug.h"
#include "Debug.h"

#if TDE_VERSION < KDE_MAKE_VERSION(3,2,0)
#include <tqdatetime.h>
#include <tqpoint.h>
#include <tqrect.h>
#include <tqregion.h>
#include <tqstringlist.h>
#include <tqpen.h>
#include <brush.h>
#include <tqsize.h>
#include <kurl.h>
#endif

#include "base/Event.h"
#include "base/Segment.h"
#include "base/RealTime.h"
#include "base/Colour.h"
#include "gui/editors/guitar/Chord.h"
#include "gui/editors/guitar/Fingering.h"

#ifndef NDEBUG

kdbgstream&
operator<<(kdbgstream &dbg, const std::string &s)
{
    dbg << strtoqstr(s);
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const Rosegarden::Event &e)
{
    dbg << "Event type : " << e.getType() << endl;

    dbg << "\tDuration : " << e.getDuration()
    << "\n\tAbsolute Time : " << e.getAbsoluteTime()
    << endl;

    //     for (Event::PropertyMap::const_iterator i = e.properties().begin();
    //          i != e.properties().end(); ++i) {
    //         dbg << "\t\t" << (*i).first << " : "
    //             << ((*i).second)->unparse() << '\n';
    //     }

    //     e.dump(std::cerr);

    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const Rosegarden::Segment &t)
{
    dbg << "Segment for instrument " << t.getTrack()
    << " starting at " << t.getStartTime() << endl;

    for (Rosegarden::Segment::const_iterator i = t.begin();
            i != t.end(); ++i) {
        if (!(*i)) {
            dbg << "WARNING : skipping null event ptr\n";
            continue;
        }

        dbg << "Dumping Event : \n";
        dbg << *(*i) << endl;
    }

    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const Rosegarden::RealTime &t)
{
    dbg << t.toString();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const Rosegarden::Colour &c)
{
    dbg << "Colour : rgb = " << c.getRed() << "," << c.getGreen() << "," << c.getBlue();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const Rosegarden::Guitar::Chord &c)
{
    dbg << "Chord root = " << c.getRoot() << ", ext = '" << c.getExt() << "'";

//    for(unsigned int i = 0; i < c.getNbFingerings(); ++i) {
//        dbg << "\nFingering " << i << " : " << c.getFingering(i).toString().c_str();
//    }
    
     Rosegarden::Guitar::Fingering f = c.getFingering();

     dbg << ", fingering : ";

     for(unsigned int j = 0; j < 6; ++j) {
         int pos = f[j];
         if (pos >= 0)
             dbg << pos << ' ';
         else
             dbg << "x ";
    }        
    return dbg;
}

#ifdef NOT_DEFINED

ostream&
kdbgostreamAdapter::operator<<(bool i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(short i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(unsigned short i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(char i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(unsigned char i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(int i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(unsigned int i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(long i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(unsigned long i)
{
    m_kdbgStream << i;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(const TQString& string)
{
    m_kdbgStream << string;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(const char *string)
{
    m_kdbgStream << string;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(const TQCString& string)
{
    m_kdbgStream << string;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(void * p)
{
    m_kdbgStream << p;
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(KDBGFUNC f)
{
    (*f)(m_kdbgStream);
    return *this;
}

ostream&
kdbgostreamAdapter::operator<<(double d)
{
    m_kdbgStream << d;
    return *this;
}

#endif

// ostream& endl( ostream &s)
// {
//     s << "\n"; return s;
// }

// void DBCheckThrow()
// {
//     using Rosegarden::Int;

//     Rosegarden::Event ev;

//     try {
//         int pitch = ev.get<Int>("BLAH");

//     } catch (Rosegarden::Event::NoData) {
//         RG_DEBUG << "DBCheckThrow()" << endl;
//     }
// }

#if TDE_VERSION < KDE_MAKE_VERSION(3,2,0)
kdbgstream&
operator<<(kdbgstream &dbg, const TQDateTime& time)
{
    dbg << time.toString();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQDate& date)
{
    dbg << date.toString();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQTime& time )
{
    dbg << time.toString();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQPoint& p )
{
    dbg << "(" << p.x() << ", " << p.y() << ")";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQSize& s )
{
    dbg << "[" << s.width() << "x" << s.height() << "]";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQRect& r )
{
    dbg << "[" << r.x() << "," << r.y() << " - "
    << r.width() << "x" << r.height() << "]";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQRegion& reg )
{
    dbg << "[ ";

    TQMemArray<TQRect>rs = reg.rects();
    for (uint i = 0;i < rs.size();++i)
        dbg << TQString("[%1,%2 - %3x%4] ").arg(rs[i].x()).arg(rs[i].y())
        .arg(rs[i].width()).arg(rs[i].height() ) ;

    dbg << "]";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const KURL& u )
{
    dbg << u.prettyURL();
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQStringList& l )
{
    dbg << "(";
    dbg << l.join(",");
    dbg << ")";

    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQColor& c )
{
    if ( c.isValid() )
        dbg << c.name();
    else
        dbg << "(invalid/default)";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQPen& p )
{
    static const char* const s_penStyles[] = {
                "NoPen", "SolidLine", "DashLine", "DotLine", "DashDotLine",
                "DashDotDotLine"
            };
    static const char* const s_capStyles[] = {
                "FlatCap", "SquareCap", "RoundCap"
            };
    dbg << "[ style:";
    dbg << s_penStyles[ p.style() ];
    dbg << " width:";
    dbg << p.width();
    dbg << " color:";
    if ( p.color().isValid() )
        dbg << p.color().name();
    else
        dbg << "(invalid/default)";
    if ( p.width() > 0 ) {
        dbg << " capstyle:";
        dbg << s_capStyles[ p.capStyle() >> 4 ];
    }
    dbg << " ]";
    return dbg;
}

kdbgstream&
operator<<(kdbgstream &dbg, const TQBrush& b)
{
    static const char* const s_brushStyles[] = {
                "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
                "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
                "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
                "DiagCrossPattern"
            };

    dbg << "[ style: ";
    dbg << s_brushStyles[ b.style() ];
    dbg << " color: ";
    if ( b.color().isValid() )
        dbg << b.color().name() ;
    else
        dbg << "(invalid/default)";
    if ( b.pixmap() )
        dbg << " has a pixmap";
    dbg << " ]";
    return dbg;
}
#endif

#endif