Commits

Pam Ford authored 27da3cdd5ed
Fix plotms colorization and reindexing performance for connecting points
No tags

code/casaqt/QwtPlotter/QPScatterPlot.cc

Modified
506 506
507 507 bool reversed(m_maskedData->reverseConnect(i));
508 508 if (diffColorLine) { // set pen for colorized plot
509 509 QPen linePen;
510 510 if (!drawMaskedLine || samePen)
511 511 linePen = m_line.asQPen();
512 512 if (!drawLine)
513 513 linePen = m_maskedLine.asQPen();
514 514 thisbin = m_coloredData->binAt(i);
515 515 sameBin = (thisbin==lastbin);
516 - unsigned int colorBin = thisbin % numBins;
516 + unsigned int colorBin = thisbin % numBins;
517 517 QBrush coloredBrush = m_coloredBrushes[colorBin];
518 518 linePen.setBrush(coloredBrush);
519 519 QColor brushColor = coloredBrush.color();
520 520 linePen.setColor(brushColor);
521 521 p->setPen(linePen);
522 522 // compare then save for next point
523 523 if (reversed)
524 524 sameLine = sameBin && (thisx < lastx); // for colorized data
525 525 else
526 526 sameLine = sameBin && (thisx > lastx); // for colorized data
624 624 lastiy = yMap.transform(lasty);
625 625 for(unsigned int i = drawIndex + 1; i < n; i++) {
626 626 m_data->xAndYAt(i, thisx, thisy);
627 627 thisix = xMap.transform(thisx); thisiy = yMap.transform(thisy);
628 628 if(brect.contains(lastix, lastiy) || brect.contains(thisix, thisiy))
629 629 p->drawLine(lastix, lastiy, thisix, thisiy);
630 630 lastix = thisix; lastiy = thisiy;
631 631 }
632 632 }
633 633 }
634 -
634 +
635 635 // Draw normal/masked symbols
636 636 bool drawSymbol = m_symbol.symbol() != PlotSymbol::NOSYMBOL,
637 637 drawMaskedSymbol = !m_maskedData.null() &&
638 638 m_maskedSymbol.symbol() != PlotSymbol::NOSYMBOL,
639 639 diffColor = !m_coloredData.null() && m_coloredData->isBinned();
640 640 if(drawSymbol || drawMaskedSymbol) {
641 641 double tempx, tempy;
642 642 if(!m_maskedData.null()) {
643 643 unsigned int ptsToDraw = ( m_maskedData->plotConjugates() ? 2 : 1 );
644 644 bool mask;
681 681 } else { // conjugate for uv plot
682 682 qpt = QPoint(xMap.transform(-tempx),yMap.transform(-tempy));
683 683 }
684 684 rect.moveCenter(qpt);
685 685 if(!brect.intersects(rect)) continue;
686 686 if(drawMaskedSymbol) {
687 687 if(!samePen) p->setPen(pen);
688 688 if(!sameBrush) p->setBrush(brush);
689 689 }
690 690 if(diffColor) {
691 - unsigned int colorBin = (m_coloredData->binAt(i)) % numBins;
691 + unsigned int colorBin = (m_coloredData->binAt(i)) % numBins;
692 692 QBrush coloredBrush = m_coloredBrushes[colorBin];
693 693 QColor brushColor = coloredBrush.color();
694 694 p->setBrush(coloredBrush);
695 695 p->setPen(brushColor);
696 696 QPSymbol* coloredSym = coloredSymbol(brushColor);
697 697 coloredSym->draw(p, rect);
698 698 delete coloredSym;
699 699 } else {
700 700 QPointF qptf = QPointF(qpt);
701 701 upoints.push_back(qptf);
713 713 } else {
714 714 qpt = QPoint(xMap.transform(-tempx), yMap.transform(-tempy));
715 715 }
716 716 mRect.moveCenter(qpt);
717 717 if(!brect.intersects(mRect)) continue;
718 718 if(drawMaskedSymbol) {
719 719 if(!samePen) p->setPen(mpen);
720 720 if(!sameBrush) p->setBrush(mbrush);
721 721 }
722 722 if(diffColor) {
723 - unsigned int colorBin = (m_coloredData->binAt(i)) % numBins;
723 + unsigned int colorBin = (m_coloredData->binAt(i)) % numBins;
724 724 QBrush coloredBrush = m_coloredBrushes[colorBin];
725 725 QColor brushColor = coloredBrush.color();
726 726 p->setBrush(coloredBrush);
727 727 p->setPen(brushColor);
728 728 QPSymbol* coloredSym = coloredSymbol(brushColor);
729 729 coloredSym->draw(p, mRect);
730 730 } else {
731 731 QPointF qptf = QPointF(qpt);
732 732 mpoints.push_back(qptf);
733 733 if (mpoints.size()==15000) {
810 810
811 811 QSize size = ((QwtSymbol&)m_symbol).size();
812 812 QRect rect(0, 0, size.width(), size.height());
813 813
814 814 for(unsigned int i = drawIndex; i < n; i++) {
815 815 m_data->xAndYAt(i, tempx, tempy);
816 816 rect.moveCenter(QPoint(xMap.transform(tempx),
817 817 yMap.transform(tempy)));
818 818 if(!brect.intersects(rect)) continue;
819 819 if(diffColor) {
820 - unsigned int colorBin = m_coloredData->binAt(i) % numBins;
820 + unsigned int colorBin = m_coloredData->binAt(i) % numBins;
821 821 p->setBrush(m_coloredBrushes[colorBin]);
822 822 }
823 823 m_symbol.draw(p, rect);
824 824 }
825 825 }
826 826 }
827 827
828 828 p->restore();
829 829 }
830 830

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut