forked from githubdoe/DFTFringe
-
Notifications
You must be signed in to change notification settings - Fork 0
test of Q_Unused #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
atsju
wants to merge
6
commits into
master
Choose a base branch
from
averageProfile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
test of Q_Unused #53
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f82eadb
reworked profile slope highlight and ploting obstruction
githubdoe aea8375
Merge branch 'averageProfile' of https://github.com/githubdoe/DFTFrin…
githubdoe fc97675
Update DFTFringe.pro
gr5 2c01f57
Update profilecurve.cpp
gr5 b8fdb79
Update profileplot.cpp
gr5 91c4d4b
fix QT5 build and add const
atsju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #include "profilecurve.h" | ||
| #include <QPainter> | ||
| #include "profilecurve.h" | ||
| #include <qpainter.h> | ||
| #include <qpainterpath.h> | ||
| #include <qwt_scale_map.h> | ||
|
|
||
| // creates a curve of the profile and will highlight segments where the slope is violated if the user has that feature enabled. | ||
| // uses the base class for most of the work. Overrides the actual painting of the line. | ||
| ProfileCurve::ProfileCurve(const QString &title) | ||
| : QwtPlotCurve(title) | ||
| , m_showSlopeError(false) | ||
| , m_slopeLimit(0.0) | ||
| , m_highlightWidth(2) | ||
| { | ||
| // Ensure we are using basic line style for the base profile | ||
| setStyle(QwtPlotCurve::Lines); | ||
| } | ||
|
|
||
| void ProfileCurve::setSlopeSettings(bool show, double limit, int highlightWidth) | ||
| { | ||
| m_showSlopeError = show; | ||
| m_slopeLimit = limit; | ||
| m_highlightWidth = highlightWidth; | ||
| } | ||
|
|
||
| #include <QPainterPath> // Ensure this is at the top of profilecurve.cpp | ||
|
|
||
| #include <qwt_scale_map.h> | ||
| #include <qpainter.h> | ||
|
|
||
| void ProfileCurve::drawLines(QPainter *painter, | ||
| const QwtScaleMap &xMap, | ||
| const QwtScaleMap &yMap, | ||
| const QRectF &canvasRect, | ||
| int from, int to) const | ||
| { | ||
| Q_UNUSED(canvasRect); // drawLines is an override function, we shall not change args | ||
| if (to <= from) return; | ||
|
|
||
| painter->save(); | ||
|
|
||
| // 1. MANUALLY DRAW THE BASE BLACK LINE (Replacing Qwt's default) | ||
| // This prevents Qwt from drawing its own spider lines. | ||
| QPen basePen = pen(); | ||
| painter->setPen(basePen); | ||
|
|
||
| for (int i = from; i < to; ++i) { | ||
| QPointF p1 = sample(i); | ||
| QPointF p2 = sample(i + 1); | ||
|
|
||
| // If either point is NaN, skip this segment entirely (lifts the pen) | ||
| if (std::isnan(p1.y()) || std::isnan(p2.y())) continue; | ||
|
|
||
| // Draw the segment only between two valid points | ||
| double x1 = xMap.transform(p1.x()); | ||
| double y1 = yMap.transform(p1.y()); | ||
| double x2 = xMap.transform(p2.x()); | ||
| double y2 = yMap.transform(p2.y()); | ||
|
|
||
| painter->drawLine(QPointF(x1, y1), QPointF(x2, y2)); | ||
| } | ||
|
|
||
| // 2. DRAW THE ORANGE HIGHLIGHTS | ||
| if (m_showSlopeError && m_slopeLimit > 0.0) { | ||
| QPen orangePen(QColor("orange"), m_highlightWidth); | ||
| orangePen.setCapStyle(Qt::RoundCap); | ||
| painter->setPen(orangePen); | ||
|
|
||
| for (int i = from; i < to; ++i) { | ||
| QPointF p1 = sample(i); | ||
| QPointF p2 = sample(i + 1); | ||
|
|
||
| if (std::isnan(p1.y()) || std::isnan(p2.y())) continue; | ||
|
|
||
| if (std::abs(p1.y() - p2.y()) > m_slopeLimit) { | ||
| painter->drawLine( | ||
| QPointF(xMap.transform(p1.x()), yMap.transform(p1.y())), | ||
| QPointF(xMap.transform(p2.x()), yMap.transform(p2.y())) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| painter->restore(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #ifndef PROFILECURVE_H | ||
| #define PROFILECURVE_H | ||
|
|
||
| #include <qwt_plot_curve.h> | ||
| #include <QPen> | ||
| #include <cmath> | ||
|
|
||
| /** | ||
| * @brief The ProfileCurve class | ||
| * A custom QwtPlotCurve that automatically highlights segments where the | ||
| * vertical delta between adjacent points exceeds a specified threshold. | ||
| */ | ||
| class ProfileCurve : public QwtPlotCurve | ||
| { | ||
| public: | ||
| explicit ProfileCurve(const QString &title = QString()); | ||
|
|
||
| /** | ||
| * @brief Configure the slope highlighting behavior | ||
| * @param show - Toggle the orange highlight on/off | ||
| * @param limit - The vertical delta threshold (hDelLimit) | ||
| * @param highlightWidth - Width of the orange pen | ||
| */ | ||
| void setSlopeSettings(bool show, double limit, int highlightWidth = 2); | ||
|
|
||
| protected: | ||
| /** | ||
| * @brief Overrides the standard line drawing to add the highlight pass | ||
| */ | ||
| virtual void drawLines(QPainter *painter, | ||
| const QwtScaleMap &xMap, | ||
| const QwtScaleMap &yMap, | ||
| const QRectF &canvasRect, | ||
| int from, int to) const override; | ||
|
|
||
| private: | ||
| bool m_showSlopeError; | ||
| double m_slopeLimit; | ||
| int m_highlightWidth; | ||
| }; | ||
|
|
||
| #endif // PROFILECURVE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy diagnostic
profileplot.cpp:431:5: warning: [clang-analyzer-security.FloatLoopCounter]