From e594f2c4668f93ca2765fb3cc3aacf1697fa8949 Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Sun, 20 Jul 2025 14:33:24 +0200 Subject: [PATCH 1/2] fix #81 contouview ange --- intensityplot.cpp | 4 ++-- profileplot.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/intensityplot.cpp b/intensityplot.cpp index 5edff788..cbfc7a06 100644 --- a/intensityplot.cpp +++ b/intensityplot.cpp @@ -41,7 +41,7 @@ #include #include "opencv2/opencv.hpp" -#define PITORAD M_PI/180. +#define DEGTORAD M_PI/180. static double i_angle; class iSurfaceData: public QwtSyntheticPointData @@ -154,7 +154,7 @@ intensityPlot::intensityPlot(QWidget *parent): void intensityPlot::angleChanged(double a){ - i_angle = (a * PITORAD - M_PI_2); + i_angle = (a * DEGTORAD - M_PI_2); replot(); } diff --git a/profileplot.cpp b/profileplot.cpp index d7a8f2ea..4a2b1c61 100644 --- a/profileplot.cpp +++ b/profileplot.cpp @@ -58,8 +58,8 @@ extern double outputLambda; #include #include #include "percentcorrectiondlg.h" -#define PITORAD M_PI/180.; -double g_angle = 270. * PITORAD; //start at 90 deg (pointing east) +#define DEGTORAD M_PI/180.; +double g_angle = 270. * DEGTORAD; //start at 90 deg (pointing east) double y_offset = 0.; @@ -282,12 +282,12 @@ void ProfilePlot::newDisplayErrorRange(double min, double max){ void ProfilePlot::angleChanged(double a){ if (m_wf == 0) return; - g_angle = a * PITORAD; + g_angle = a * DEGTORAD; if (type == 2 || type == 0) populate(); m_plot->replot(); - emit profileAngleChanged(M_2_PI - g_angle +M_PI/4.); + emit profileAngleChanged(M_PI_2 - g_angle); } void ProfilePlot::wheelEvent(QWheelEvent *event) { From 3d38503a72446bf289d907d3118402741e6f7763 Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Sun, 20 Jul 2025 14:48:39 +0200 Subject: [PATCH 2/2] code readability --- dftcolormap.cpp | 4 +++- profileplot.cpp | 18 +++++++++--------- profileplot.h | 8 ++++++-- psiphasedisplay.cpp | 6 +++++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dftcolormap.cpp b/dftcolormap.cpp index 46103a2c..836550da 100644 --- a/dftcolormap.cpp +++ b/dftcolormap.cpp @@ -16,10 +16,12 @@ ****************************************************************************/ #include "dftcolormap.h" +#include + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif -#include + QList dftColorMap::userStops; void dftColorMap::setUserStops(QList &stops) { diff --git a/profileplot.cpp b/profileplot.cpp index 4a2b1c61..63634108 100644 --- a/profileplot.cpp +++ b/profileplot.cpp @@ -76,7 +76,7 @@ ProfilePlot::ProfilePlot(QWidget *parent , ContourTools *tools): m_defocus_mode = false; m_plot = new QwtPlot(this); new profilePlotPicker(m_plot); - type = 0; + type = ProfileType::SHOW_ONE; QHBoxLayout * l1 = new QHBoxLayout(); QVBoxLayout *v1 = new QVBoxLayout(); showNmCB = new QCheckBox("Show in Nanometers",this); @@ -237,18 +237,18 @@ void ProfilePlot::showSurface(bool flag){ } void ProfilePlot::showOne(){ - type = 0; + type = ProfileType::SHOW_ONE; m_pcdlg->close(); populate(); m_plot->replot(); } void ProfilePlot::show16(){ - type = 1; + type = ProfileType::SHOW_16; populate(); m_plot->replot(); } void ProfilePlot::showAll(){ - type = 2; + type = ProfileType::SHOW_ALL; m_pcdlg->close(); populate(); m_plot->replot(); @@ -284,7 +284,7 @@ void ProfilePlot::angleChanged(double a){ return; g_angle = a * DEGTORAD; - if (type == 2 || type == 0) + if (type == ProfileType::SHOW_ONE || type == ProfileType::SHOW_ALL) populate(); m_plot->replot(); emit profileAngleChanged(M_PI_2 - g_angle); @@ -442,7 +442,7 @@ QPolygonF ProfilePlot::createProfile(double units, wavefront *wf, bool allowOffs //else points << QPointF(radx,0.0); } - if (m_showSlopeError && ((type==1) || (type == 0) || (type == 2))){ + if (m_showSlopeError){ double arcsecLimit = (slopeLimitArcSec/3600) * M_PI/180; double xDel = points[0].x() - points[1].x(); double hDelLimit =m_showNm * m_showSurface * ((outputLambda/m_wf->lambda)*fabs(xDel * tan(arcsecLimit)) /(outputLambda * 1.e-6)); @@ -563,7 +563,7 @@ void ProfilePlot::populate() switch (type) { - case 0:{ // show one + case ProfileType::SHOW_ONE:{ QStringList path = wfs->at(0)->name.split("/"); QString name; int l = path.length(); @@ -585,7 +585,7 @@ void ProfilePlot::populate() break; } - case 1: { // show 16 diameters + case ProfileType::SHOW_16: { surfaceAnalysisTools *saTools = surfaceAnalysisTools::get_Instance(); QList list = saTools->SelectedWaveFronts(); @@ -660,7 +660,7 @@ void ProfilePlot::populate() break; } - case 2:{ // show each wave front + case ProfileType::SHOW_ALL:{ m_plot->insertLegend( new QwtLegend() , QwtPlot::BottomLegend); surfaceAnalysisTools *saTools = surfaceAnalysisTools::get_Instance(); diff --git a/profileplot.h b/profileplot.h index f00aacbd..bc12bb9d 100644 --- a/profileplot.h +++ b/profileplot.h @@ -57,7 +57,6 @@ class ProfilePlot : public QWidget QRadioButton *OneOnly; QRadioButton *Show16; QRadioButton *ShowAll; - int type; double m_showSurface; double m_showNm; bool zoomed; @@ -91,6 +90,11 @@ public slots: void make_correction_graph(); //QPolygonF createZernProfile(wavefront *wf); private: + enum class ProfileType { + SHOW_ONE = 0, + SHOW_16 = 1, + SHOW_ALL = 2 + }; void updateGradient(); bool dragging; @@ -101,8 +105,8 @@ public slots: QPushButton *showPercentCorrection; QDoubleSpinBox *slopeLimitSB; double m_defocusValue; + ProfileType type; -private: Ui::ProfilePlot *ui; bool m_defocus_mode; cv::Mat_ m_defocus_wavefront; diff --git a/psiphasedisplay.cpp b/psiphasedisplay.cpp index 72341a64..13bb435f 100644 --- a/psiphasedisplay.cpp +++ b/psiphasedisplay.cpp @@ -7,7 +7,11 @@ #include #include #include -#define M_PI 3.14159265358979323846 + +#ifndef M_PI + #define M_PI 3.14159265358979323846 +#endif + PSIphaseDisplay::PSIphaseDisplay(QVector phases,QWidget *parent) : QDialog(parent), ui(new Ui::PSIphaseDisplay),m_useRadians(false)