Skip to content

Commit de3daed

Browse files
authored
Merge pull request #193 from githubdoe/dalework
Dalework
2 parents 76c5fc2 + 832feb6 commit de3daed

10 files changed

+343
-89
lines changed

DFTFringe_Dale.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ RC_FILE = DFTFringe.rc
423423
QMAKE_CXXFLAGS += -std=c++11
424424

425425
# The application version
426-
VERSION = Dale7.3.0
426+
VERSION = Dale7.3.2
427427

428428
# Define the preprocessor macro to get the application version in our application.
429429
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

RevisionHistory.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,18 @@
425425
<li>Added polar plot of the astig of selected wave fronts under View menu.</li>
426426
<li>Changed create movie feature to add user provided prefix to each from created.</li>
427427
<li>Added hot keys to import interferogram</li>
428-
<li>Added hot key to help</li>
428+
<li>Added hot key help</li>
429429
<li>User can move mouse cursor over any profile shown, click and drag it up or down. Useful for comparing two work sessions results so that they match at zero height.</li>
430430
<li>If mouse is over the profile plot the scroll wheel can increase or decrease the y axis range.</li>
431431
<li>Added auto collimation setting to Ronchi and Foucault feature</li>
432432
<li>Remembered last ROC offset value in Ronchi and Foucault feature to remember last setting when wave front is changed to a different value</li>
433433
</ul>
434+
</ul>
435+
d
436+
<ul><li>Version 7.3.2</li>
437+
<ul>
438+
<li>Added hover and click to astig polar plot to select the wave front and show it as the currently selected wave front. Added click to astig polar table to highlight the line on the plot and display as current wave front.</li>
439+
<li>Corrected test stand astig removal feature to display the correct image sizes on the report no matter what the screen resolution is.</li>
440+
<li>Corrected bug when subtracted wave front result is saved and then loaded so that it does not lose the fact to use or not use the null.</LI>
441+
<li>Updated the subtract dialog to display a reasonable size based on screen resolution. Improved help information.</li>
442+
</ul>

astigpolargraph.cpp

Lines changed: 122 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
#include "surfacemanager.h"
44

55

6-
astigPolargraph::astigPolargraph( QList<int>list, QWidget *parent) :
7-
QDialog(parent),
8-
ui(new Ui::astigPolargraph), m_list(list)
6+
astigPolargraph::astigPolargraph( QList<astigSample>list, QWidget *parent) :
7+
8+
QDialog(parent),ui(new Ui::astigPolargraph)
99
{
1010
ui->setupUi(this);
11-
12-
QPolarChart *chart = new QPolarChart();
11+
12+
chart = new QPolarChart();
1313

1414
// process each wave front and place astig on the chart
15-
ui->waveFrontTable->setRowCount(m_list.size());
15+
ui->waveFrontTable->setRowCount(list.size());
16+
ui->waveFrontTable->setSelectionBehavior(QAbstractItemView::SelectRows);
1617

18+
// Configure selection mode (e.g., single selection)
19+
ui->waveFrontTable->setSelectionMode(QAbstractItemView::SingleSelection);
1720
QValueAxis *angularAxis = new QValueAxis();
1821
angularAxis->setTickCount(9); // First and last ticks are co-located on 0/360 angle.
1922
angularAxis->setLabelFormat("%.0f");
@@ -28,21 +31,30 @@ astigPolargraph::astigPolargraph( QList<int>list, QWidget *parent) :
2831
double maxAstig = 1.;
2932

3033
QVector<wavefront *> wavefronts =SurfaceManager::get_instance()->m_wavefronts;
31-
32-
for(int ndx = 0; ndx < m_list.length(); ++ndx){
33-
wavefront *wf = wavefronts[m_list[ndx]];
34-
QString name = wf->name;
34+
QScreen *screen = QGuiApplication::primaryScreen();
35+
qreal screenDPI = screen->physicalDotsPerInchX();
36+
int pensize = 5 * screenDPI/256.; // adjust pen size to screen resolution. 256 is DPI of my 4K 17 inch laptop
37+
if (pensize < 1)
38+
pensize = 1;
39+
for(int ndx = 0; ndx < list.length(); ++ndx){
40+
41+
QString name = list[ndx].m_name;
3542
int slashndx = name.lastIndexOf('/');
3643
QString shortName = name.mid(name.lastIndexOf('/',slashndx-1));
3744
QTableWidgetItem *item = new QTableWidgetItem(shortName, 0);
3845
ui->waveFrontTable->setItem(ndx,0,item);
39-
double xastig = wf->InputZerns[4];
40-
double yastig = wf->InputZerns[5];
46+
double xastig = list[ndx].m_xastig;
47+
double yastig = list[ndx].m_yastig;
4148
double mag = sqrt(xastig * xastig + yastig * yastig);
4249
if (mag > maxAstig) maxAstig = mag;
4350

4451
double angle = (atan2(yastig,xastig)/2.) * 180./M_PI;
52+
4553
angle = 90 - angle;
54+
55+
astigSample sample(name, angle, mag);
56+
57+
m_list << sample;
4658
QScatterSeries *series = new QScatterSeries();
4759

4860
int lastndx = name.lastIndexOf('/');
@@ -61,9 +73,12 @@ astigPolargraph::astigPolargraph( QList<int>list, QWidget *parent) :
6173
chart->addSeries(line);
6274
line->attachAxis(radialAxis);
6375
line->attachAxis(angularAxis);
76+
line->setName(name);
77+
connect(line, &QLineSeries::hovered, this, &astigPolargraph::tooltip);
78+
connect(line, &QLineSeries::clicked, this, &astigPolargraph::clicked);
6479
chart->legend()->markers(line)[0]->setVisible(false);
6580

66-
line->setPen(QPen(series->brush(),5));
81+
line->setPen(QPen(series->brush(),pensize));
6782

6883
QTableWidgetItem *pv = new QTableWidgetItem(QString().number(mag), 0);
6984
item->setForeground(series->brush());
@@ -73,18 +88,110 @@ astigPolargraph::astigPolargraph( QList<int>list, QWidget *parent) :
7388
}
7489

7590
chart->setTitle("Magnitude and axis of high edge");
76-
if (m_list.length() > 4)
91+
if (list.length() > 4)
7792
chart->legend()->setAlignment(Qt::AlignRight);
7893
else chart->legend()->setAlignment(Qt::AlignBottom);
7994

8095
maxAstig = ceil(maxAstig);
8196
radialAxis->setRange(0, maxAstig);
8297
angularAxis->setRange(0, 360);
83-
98+
ui->waveFrontTable->resizeColumnsToContents();
8499
ui->polarChart->setChart(chart);
100+
85101
}
102+
void astigPolargraph::tooltip(QPointF point, bool state)
103+
{
104+
if (state) {
105+
findClosestPoint(point);
106+
}
86107

108+
}
109+
void astigPolargraph::clicked(QPointF point)
110+
{
111+
112+
findClosestPoint(point);
113+
114+
}
87115
astigPolargraph::~astigPolargraph()
88116
{
89117
delete ui;
118+
delete chart;
90119
}
120+
121+
void astigPolargraph::hideHoverHelp(){
122+
ui->hoverText->hide();
123+
}
124+
int astigPolargraph::findClosestPoint(const QPointF clickedPoint){
125+
126+
QPointF closest(INT_MAX, INT_MAX);
127+
qreal distance(INT_MAX);
128+
int closeNdx = -1;
129+
int ndx = 0;
130+
for (auto sample : m_list) {
131+
QPointF currentPoint(sample.m_xastig, sample.m_yastig);
132+
qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x())
133+
* (currentPoint.x() - clickedPoint.x())
134+
+ (currentPoint.y() - clickedPoint.y())
135+
* (currentPoint.y() - clickedPoint.y()));
136+
137+
if (currentDistance < distance) {
138+
distance = currentDistance;
139+
closest = currentPoint;
140+
closeNdx = ndx;
141+
142+
}
143+
++ndx;
144+
}
145+
QString name = m_list[closeNdx].m_name;
146+
emit waveSeleted(name);
147+
int slashndx = name.lastIndexOf('/');
148+
QString shortName = name.mid(name.lastIndexOf('/',slashndx-1));
149+
150+
QList<QTableWidgetItem*> items = ui->waveFrontTable->findItems(shortName, Qt::MatchEndsWith);
151+
152+
153+
if (items.length() > 0){
154+
155+
ui->waveFrontTable->selectRow(items[0]->row());
156+
}
157+
return closeNdx;
158+
}
159+
160+
void astigPolargraph::on_waveFrontTable_itemClicked(QTableWidgetItem *item)
161+
{
162+
QString name = ui->waveFrontTable->item(item->row(),0)->text();
163+
emit waveSeleted(name);
164+
165+
int lastndx = name.lastIndexOf('/');
166+
if (lastndx != -1)
167+
name = name.mid(lastndx);
168+
169+
170+
int seriesCount = chart->series().count();
171+
172+
for (int i = 0; i < seriesCount; ++i) {
173+
QAbstractSeries* series = chart->series().at(i);
174+
if (series) {
175+
176+
if (series->type()== QAbstractSeries::SeriesTypeLine){
177+
if (series->name() == name){
178+
QLineSeries *line = static_cast<QLineSeries*>(series);
179+
// Create a pen object to get the current pen attributes.
180+
QPen pen = line->pen();
181+
if (pen.style() == Qt::DotLine){
182+
pen.setStyle(Qt::SolidLine);
183+
pen.setWidth(pen.width()/4);
184+
}
185+
else {
186+
pen.setStyle(Qt::DotLine);
187+
pen.setWidth(pen.width() * 4);
188+
}
189+
190+
line->setPen(pen);
191+
}
192+
}
193+
194+
}
195+
}
196+
}
197+

astigpolargraph.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,43 @@
99
#include <QtCharts/QValueAxis>
1010
#include <QtCharts/QPolarChart>
1111
#include "wavefront.h"
12+
#include <QTableWidgetItem>
1213

14+
QT_CHARTS_USE_NAMESPACE
1315
namespace Ui {
1416
class astigPolargraph;
1517
}
18+
class astigSample{
19+
20+
public:
21+
QString m_name;
22+
double m_xastig;
23+
double m_yastig;
24+
astigSample(QString name, double xastig, double yastig): m_name(name), m_xastig(xastig), m_yastig(yastig){};
25+
};
1626

1727
class astigPolargraph : public QDialog
1828
{
1929
Q_OBJECT
2030

2131
public:
22-
explicit astigPolargraph(QList<int> list,QWidget *parent = nullptr);
32+
explicit astigPolargraph(QList<astigSample> list,QWidget *parent = nullptr);
2333
~astigPolargraph();
2434

35+
signals:
36+
void waveSeleted(QString);
37+
private slots:
38+
void tooltip(QPointF point, bool state);
39+
void clicked(QPointF point);
40+
void on_waveFrontTable_itemClicked(QTableWidgetItem *item);
41+
2542
private:
43+
int findClosestPoint(const QPointF clickedPoint );
2644
Ui::astigPolargraph *ui;
27-
QList<int> m_list; // list index of selected wave fronts in surface manager's list.
45+
QPolarChart *chart;
46+
QList<astigSample> m_list;
47+
public:
48+
void hideHoverHelp();
2849
};
2950

3051
#endif // ASTIGPOLARGRAPH_H

astigpolargraph.ui

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@
1616
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>
1818
<layout class="QHBoxLayout" name="horizontalLayout">
19+
<item>
20+
<spacer name="horizontalSpacer">
21+
<property name="orientation">
22+
<enum>Qt::Horizontal</enum>
23+
</property>
24+
<property name="sizeHint" stdset="0">
25+
<size>
26+
<width>40</width>
27+
<height>20</height>
28+
</size>
29+
</property>
30+
</spacer>
31+
</item>
32+
<item>
33+
<widget class="QLabel" name="hoverText">
34+
<property name="text">
35+
<string>Hover or left click over right side end point to highlight associated wave front.</string>
36+
</property>
37+
</widget>
38+
</item>
39+
</layout>
40+
</item>
41+
<item>
42+
<layout class="QHBoxLayout" name="horizontalLayout_2">
1943
<item>
2044
<widget class="QTableWidget" name="waveFrontTable">
2145
<property name="editTriggers">
@@ -55,7 +79,7 @@
5579
<enum>Qt::Horizontal</enum>
5680
</property>
5781
<property name="standardButtons">
58-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
82+
<set>QDialogButtonBox::NoButton</set>
5983
</property>
6084
</widget>
6185
</item>

mainwindow.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,21 @@ void MainWindow::on_actionastig_in_polar_triggered()
20742074
{
20752075
surfaceAnalysisTools *saTools = surfaceAnalysisTools::get_Instance();
20762076
QList<int> list = saTools->SelectedWaveFronts();
2077-
astigPolargraph * graph = new astigPolargraph( list, this);
2078-
graph->resize(2000,1000);
2077+
2078+
QList<astigSample> samples;
2079+
foreach(int i, list){
2080+
wavefront *wf = m_surfaceManager->m_wavefronts[i];
2081+
astigSample sample(wf->name, wf->InputZerns[4], wf->InputZerns[5]);
2082+
samples << sample;
2083+
}
2084+
astigPolargraph * graph = new astigPolargraph(samples);
2085+
connect(graph, SIGNAL(waveSeleted(QString)), m_surfaceManager, SLOT(wavefrontDClicked(QString)));
2086+
QScreen *screen = QGuiApplication::primaryScreen();
2087+
QSizeF physicalSize = screen->availableSize();
2088+
graph->resize(physicalSize.width()/2,physicalSize.height()/2);
2089+
20792090
graph->exec();
2091+
graph->disconnect();
2092+
delete graph;
20802093
}
20812094

0 commit comments

Comments
 (0)