From 6ec468643f8822203bf97eb61a0d1b7bfa826961 Mon Sep 17 00:00:00 2001 From: Bayram Yenikaya Date: Sat, 11 Nov 2023 22:14:54 -0800 Subject: [PATCH] do not re-draw everything when plotting marks --- gui/polyView.cpp | 58 ++++++++++++++++++++++++++++++++++++------------ gui/polyView.h | 2 ++ 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/gui/polyView.cpp b/gui/polyView.cpp index 523cf4d..acbad53 100644 --- a/gui/polyView.cpp +++ b/gui/polyView.cpp @@ -633,20 +633,12 @@ void polyView::displayData(QPainter *paint) { // This draws the polygon being created if in that mode drawPolyBeingPlotted(m_currPolyX, m_currPolyY, paint); - // Draw the marks if there - if (m_markX.size() > 0) { - for (unsigned i = 0; i < m_markX.size(); i++){ - int x0, y0; - worldToPixelCoords(m_markX[i], m_markY[i], // inputs - x0, y0 ); // outputs - drawMark(x0, y0, QColor(m_prefs.fgColor.c_str()), - m_prefs.lineWidth, paint); - } - } - // If in diff mode plotDistBwPolyClips(paint); + // Draw the marks if there + drawMarks(paint); + // Wipe this temporary data now that the display changed m_snappedPoints.clear(); m_nonSnappedPoints.clear(); @@ -654,6 +646,19 @@ void polyView::displayData(QPainter *paint) { return; } +void polyView::drawMarks(QPainter *paint){ + // Draw the marks if there + if (m_markX.size() > 0) { + for (unsigned i = 0; i < m_markX.size(); i++){ + int x0, y0; + worldToPixelCoords(m_markX[i], m_markY[i], // inputs + x0, y0 ); // outputs + drawMark(x0, y0, QColor(m_prefs.fgColor.c_str()), + m_prefs.lineWidth, paint); + } + } +} + // Plot a given dPoly with given options. // The viewing window in world coordinates corresponding to current // drawing region on screen is: @@ -2475,8 +2480,9 @@ void polyView::getOnePointShape(int x0, int y0, void polyView::drawMark(int x0, int y0, QColor color, int lineWidth, QPainter * paint) { - int len = 6; + int len = 8; + lineWidth = std::max(lineWidth, 2); paint->setBrush(Qt::NoBrush); paint->setPen(QPen(color, lineWidth)); @@ -2954,6 +2960,7 @@ void polyView::addAnno() { } void polyView::markAcute() { + bool need_to_refresh = m_markX.size() > 0; m_markX.clear(); m_markY.clear(); @@ -2964,7 +2971,20 @@ void polyView::markAcute() { m_markY.push_back(pt.y); } } - refreshPixmap(); + + if (m_markX.empty()){ + cout <<"No acute angles"< 0; cout << "mark " << x << ' ' << y << endl; m_markX.resize(1); m_markX[0] = x; m_markY.resize(1); m_markY[0] = y; - refreshPixmap(); + + if (need_to_refresh){ + refreshPixmap(); + } else { + QPainter paint(&m_pixmap); + + drawMarks(&paint); + update(); + } + return; } diff --git a/gui/polyView.h b/gui/polyView.h index 1017cc8..d5a5c86 100644 --- a/gui/polyView.h +++ b/gui/polyView.h @@ -233,6 +233,8 @@ public slots: bool hasSelectedPolygons() const; void displayData( QPainter *paint ); + void drawMarks(QPainter *paint); + void plotDPoly(bool plotPoints, bool plotEdges, bool plotFilled, bool showAnno, bool scatter_annotation,