Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DFTFringe_Dale.pro
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ RC_FILE = DFTFringe.rc
QMAKE_CXXFLAGS += -std=c++11

# The application version
VERSION = Dale7.3.0
VERSION = Dale7.3.2

# Define the preprocessor macro to get the application version in our application.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
Expand Down
11 changes: 10 additions & 1 deletion RevisionHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,18 @@
<li>Added polar plot of the astig of selected wave fronts under View menu.</li>
<li>Changed create movie feature to add user provided prefix to each from created.</li>
<li>Added hot keys to import interferogram</li>
<li>Added hot key to help</li>
<li>Added hot key help</li>
<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>
<li>If mouse is over the profile plot the scroll wheel can increase or decrease the y axis range.</li>
<li>Added auto collimation setting to Ronchi and Foucault feature</li>
<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>
</ul>
</ul>
d
<ul><li>Version 7.3.2</li>
<ul>
<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>
<li>Corrected test stand astig removal feature to display the correct image sizes on the report no matter what the screen resolution is.</li>
<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>
<li>Updated the subtract dialog to display a reasonable size based on screen resolution. Improved help information.</li>
</ul>
137 changes: 122 additions & 15 deletions astigpolargraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
#include "surfacemanager.h"


astigPolargraph::astigPolargraph( QList<int>list, QWidget *parent) :
QDialog(parent),
ui(new Ui::astigPolargraph), m_list(list)
astigPolargraph::astigPolargraph( QList<astigSample>list, QWidget *parent) :

QDialog(parent),ui(new Ui::astigPolargraph)
{
ui->setupUi(this);
QPolarChart *chart = new QPolarChart();

chart = new QPolarChart();

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

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

QVector<wavefront *> wavefronts =SurfaceManager::get_instance()->m_wavefronts;

for(int ndx = 0; ndx < m_list.length(); ++ndx){
wavefront *wf = wavefronts[m_list[ndx]];
QString name = wf->name;
QScreen *screen = QGuiApplication::primaryScreen();
qreal screenDPI = screen->physicalDotsPerInchX();
int pensize = 5 * screenDPI/256.; // adjust pen size to screen resolution. 256 is DPI of my 4K 17 inch laptop
if (pensize < 1)
pensize = 1;
for(int ndx = 0; ndx < list.length(); ++ndx){

QString name = list[ndx].m_name;
int slashndx = name.lastIndexOf('/');
QString shortName = name.mid(name.lastIndexOf('/',slashndx-1));
QTableWidgetItem *item = new QTableWidgetItem(shortName, 0);
ui->waveFrontTable->setItem(ndx,0,item);
double xastig = wf->InputZerns[4];
double yastig = wf->InputZerns[5];
double xastig = list[ndx].m_xastig;
double yastig = list[ndx].m_yastig;
double mag = sqrt(xastig * xastig + yastig * yastig);
if (mag > maxAstig) maxAstig = mag;

double angle = (atan2(yastig,xastig)/2.) * 180./M_PI;

angle = 90 - angle;

astigSample sample(name, angle, mag);

m_list << sample;
QScatterSeries *series = new QScatterSeries();

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

line->setPen(QPen(series->brush(),5));
line->setPen(QPen(series->brush(),pensize));

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

chart->setTitle("Magnitude and axis of high edge");
if (m_list.length() > 4)
if (list.length() > 4)
chart->legend()->setAlignment(Qt::AlignRight);
else chart->legend()->setAlignment(Qt::AlignBottom);

maxAstig = ceil(maxAstig);
radialAxis->setRange(0, maxAstig);
angularAxis->setRange(0, 360);

ui->waveFrontTable->resizeColumnsToContents();
ui->polarChart->setChart(chart);

}
void astigPolargraph::tooltip(QPointF point, bool state)
{
if (state) {
findClosestPoint(point);
}

}
void astigPolargraph::clicked(QPointF point)
{

findClosestPoint(point);

}
astigPolargraph::~astigPolargraph()
{
delete ui;
delete chart;
}

void astigPolargraph::hideHoverHelp(){
ui->hoverText->hide();
}
int astigPolargraph::findClosestPoint(const QPointF clickedPoint){

QPointF closest(INT_MAX, INT_MAX);
qreal distance(INT_MAX);
int closeNdx = -1;
int ndx = 0;
for (auto sample : m_list) {
QPointF currentPoint(sample.m_xastig, sample.m_yastig);
qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x())
* (currentPoint.x() - clickedPoint.x())
+ (currentPoint.y() - clickedPoint.y())
* (currentPoint.y() - clickedPoint.y()));

if (currentDistance < distance) {
distance = currentDistance;
closest = currentPoint;
closeNdx = ndx;

}
++ndx;
}
QString name = m_list[closeNdx].m_name;
emit waveSeleted(name);
int slashndx = name.lastIndexOf('/');
QString shortName = name.mid(name.lastIndexOf('/',slashndx-1));

QList<QTableWidgetItem*> items = ui->waveFrontTable->findItems(shortName, Qt::MatchEndsWith);


if (items.length() > 0){

ui->waveFrontTable->selectRow(items[0]->row());
}
return closeNdx;
}

void astigPolargraph::on_waveFrontTable_itemClicked(QTableWidgetItem *item)
{
QString name = ui->waveFrontTable->item(item->row(),0)->text();
emit waveSeleted(name);

int lastndx = name.lastIndexOf('/');
if (lastndx != -1)
name = name.mid(lastndx);


int seriesCount = chart->series().count();

for (int i = 0; i < seriesCount; ++i) {
QAbstractSeries* series = chart->series().at(i);
if (series) {

if (series->type()== QAbstractSeries::SeriesTypeLine){
if (series->name() == name){
QLineSeries *line = static_cast<QLineSeries*>(series);
// Create a pen object to get the current pen attributes.
QPen pen = line->pen();
if (pen.style() == Qt::DotLine){
pen.setStyle(Qt::SolidLine);
pen.setWidth(pen.width()/4);
}
else {
pen.setStyle(Qt::DotLine);
pen.setWidth(pen.width() * 4);
}

line->setPen(pen);
}
}

}
}
}

25 changes: 23 additions & 2 deletions astigpolargraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,43 @@
#include <QtCharts/QValueAxis>
#include <QtCharts/QPolarChart>
#include "wavefront.h"
#include <QTableWidgetItem>

QT_CHARTS_USE_NAMESPACE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do ? Can we avoid using namespace in .h ? It often creates conflicts

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt has an include structure for charts that I never remember exactly how to address. The .h file did not work until I added that which I got from their example code. Without out using the complier thinks on of the polarchart classes I added is not defined. I don't have time to figure out the right syntax. If you desire you can provide the correct thing and I will update.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix later if it clashes. Thanks for the insight as a Google search didn't lead me to result.

namespace Ui {
class astigPolargraph;
}
class astigSample{

public:
QString m_name;
double m_xastig;
double m_yastig;
astigSample(QString name, double xastig, double yastig): m_name(name), m_xastig(xastig), m_yastig(yastig){};
};

class astigPolargraph : public QDialog
{
Q_OBJECT

public:
explicit astigPolargraph(QList<int> list,QWidget *parent = nullptr);
explicit astigPolargraph(QList<astigSample> list,QWidget *parent = nullptr);
~astigPolargraph();

signals:
void waveSeleted(QString);
private slots:
void tooltip(QPointF point, bool state);
void clicked(QPointF point);
void on_waveFrontTable_itemClicked(QTableWidgetItem *item);

private:
int findClosestPoint(const QPointF clickedPoint );
Ui::astigPolargraph *ui;
QList<int> m_list; // list index of selected wave fronts in surface manager's list.
QPolarChart *chart;
QList<astigSample> m_list;
public:
void hideHoverHelp();
};

#endif // ASTIGPOLARGRAPH_H
26 changes: 25 additions & 1 deletion astigpolargraph.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="hoverText">
<property name="text">
<string>Hover or left click over right side end point to highlight associated wave front.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTableWidget" name="waveFrontTable">
<property name="editTriggers">
Expand Down Expand Up @@ -55,7 +79,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::NoButton</set>
</property>
</widget>
</item>
Expand Down
17 changes: 15 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2074,8 +2074,21 @@ void MainWindow::on_actionastig_in_polar_triggered()
{
surfaceAnalysisTools *saTools = surfaceAnalysisTools::get_Instance();
QList<int> list = saTools->SelectedWaveFronts();
astigPolargraph * graph = new astigPolargraph( list, this);
graph->resize(2000,1000);

QList<astigSample> samples;
foreach(int i, list){
wavefront *wf = m_surfaceManager->m_wavefronts[i];
astigSample sample(wf->name, wf->InputZerns[4], wf->InputZerns[5]);
samples << sample;
}
astigPolargraph * graph = new astigPolargraph(samples);
connect(graph, SIGNAL(waveSeleted(QString)), m_surfaceManager, SLOT(wavefrontDClicked(QString)));
QScreen *screen = QGuiApplication::primaryScreen();
QSizeF physicalSize = screen->availableSize();
graph->resize(physicalSize.width()/2,physicalSize.height()/2);

graph->exec();
graph->disconnect();
delete graph;
}

Loading
Loading