comparison layer/Colour3DPlotLayer.cpp @ 287:cd2492c5fe45

* Add SingleColourLayer to manage colours for layers that have a single predominant colour (i.e. most of them).
author Chris Cannam
date Thu, 12 Jul 2007 16:14:59 +0000
parents 9dd432665059
children c0b9eec70639
comparison
equal deleted inserted replaced
286:7554ae119882 287:cd2492c5fe45
341 int cw = getColourScaleWidth(paint); 341 int cw = getColourScaleWidth(paint);
342 342
343 int ch = h - 20; 343 int ch = h - 20;
344 if (ch > 20 && m_cache) { 344 if (ch > 20 && m_cache) {
345 345
346 paint.setPen(Qt::black); 346 paint.setPen(v->getForeground());
347 paint.drawRect(4, 10, cw - 8, ch - 19); 347 paint.drawRect(4, 10, cw - 8, ch - 19);
348 348
349 for (int y = 0; y < ch - 20; ++y) { 349 for (int y = 0; y < ch - 20; ++y) {
350 QRgb c = m_cache->color(((ch - 20 - y) * 255) / (ch - 20)); 350 QRgb c = m_cache->color(((ch - 20 - y) * 255) / (ch - 20));
351 // std::cerr << "y = " << y << ": rgb " << qRed(c) << "," << qGreen(c) << "," << qBlue(c) << std::endl; 351 // std::cerr << "y = " << y << ": rgb " << qRed(c) << "," << qGreen(c) << "," << qBlue(c) << std::endl;
352 paint.setPen(QColor(qRed(c), qGreen(c), qBlue(c))); 352 paint.setPen(QColor(qRed(c), qGreen(c), qBlue(c)));
353 paint.drawLine(5, 11 + y, cw - 5, 11 + y); 353 paint.drawLine(5, 11 + y, cw - 5, 11 + y);
354 } 354 }
355 } 355 }
356 356
357 paint.setPen(Qt::black); 357 paint.setPen(v->getForeground());
358 358
359 int count = v->height() / paint.fontMetrics().height(); 359 int count = v->height() / paint.fontMetrics().height();
360 int step = m_model->getHeight() / count; 360 int step = m_model->getHeight() / count;
361 if (step == 0) step = 1; 361 if (step == 0) step = 1;
362 362
641 paint.setPen(Qt::NoPen); 641 paint.setPen(Qt::NoPen);
642 paint.setBrush(brush); 642 paint.setBrush(brush);
643 643
644 if (illuminate) { 644 if (illuminate) {
645 if (r.contains(illuminatePos)) { 645 if (r.contains(illuminatePos)) {
646 paint.setPen(Qt::black);//!!! 646 paint.setPen(v->getForeground());
647 } 647 }
648 } 648 }
649 649
650 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT 650 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT
651 std::cerr << "rect " << r.x() << "," << r.y() << " " 651 std::cerr << "rect " << r.x() << "," << r.y() << " "
658 if (scx >= 0 && scx < m_cache->width() && 658 if (scx >= 0 && scx < m_cache->width() &&
659 sy >= 0 && sy < m_cache->height()) { 659 sy >= 0 && sy < m_cache->height()) {
660 float value = m_model->getValueAt(scx, sy); 660 float value = m_model->getValueAt(scx, sy);
661 sprintf(labelbuf, "%06f", value); 661 sprintf(labelbuf, "%06f", value);
662 QString text(labelbuf); 662 QString text(labelbuf);
663 paint.setPen(Qt::white); 663 paint.setPen(v->getBackground());
664 paint.drawText(rx0 + 2, 664 paint.drawText(rx0 + 2,
665 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), 665 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(),
666 text); 666 text);
667 } 667 }
668 } 668 }