Skip to content

Commit

Permalink
Improved zoom outline. Corrected Ronchi offset. Added fullscreen to 3D
Browse files Browse the repository at this point in the history
and corrected contour full screen.
  • Loading branch information
githubdoe committed Jul 16, 2021
1 parent a0f37b9 commit 1946acd
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 221 deletions.
5 changes: 5 additions & 0 deletions RevisionHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,10 @@
<li>Corrected height of auto outline button.</li>
<li>Corrected display of warning messages when loading wavfronts that do not match the config parameters.</li>
<li>Fixed profile plot's error when mirror diameter is changed.</li>
<li>Fixed problem with transfrom wavefront buttons not being displayed</li>
<li>Make zoom outline fit to window</li>
<li>Fixed obscure bug in averaging wavefronts when the wavefronts vary in size too much</li>
<li>Corrected ROC offset calculations for Foucault and Ronchi simulations.</li>
<li>Corrected and added fullscreen version of 3D and Contour plots.</li>
</ul></ul>
</ul>
10 changes: 6 additions & 4 deletions foucaultview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void foucaultView::on_makePb_clicked()
double gamma = ui->gammaSb->value();
mirrorDlg *md = mirrorDlg::get_Instance();
double Radius = md->diameter/2.;
double inputWavelength = md->lambda;
double r2 = Radius * Radius;
double fl = md->roc / 2.;
double Fnumber = .5 * md->roc/md->diameter; //ROC is twice FL
Expand All @@ -94,9 +95,10 @@ void foucaultView::on_makePb_clicked()

double coc_offset_mm = ui->rocOffsetSb->value() * unitMultiplyer;

double b = (fl * 2) + coc_offset_mm;
double pv = ( sqrt((r2)+(fl * fl * 4.))
- (sqrt(r2+ b * b) - coc_offset_mm) )/ (outputLambda * 1.E-6);
double b = (md->roc) + coc_offset_mm;

double pv = ( sqrt((r2)+(md->roc * md->roc))
- (sqrt(r2+ b * b) - coc_offset_mm) )/ (md->lambda* 1.E-6);

std::vector<double> zerns = m_wf->InputZerns;
std::vector<double> newZerns = zerns;
Expand All @@ -112,7 +114,7 @@ void foucaultView::on_makePb_clicked()
sv->setSurface(m_wf);


surf_fft = sv->computeStarTest(heightMultiply * sv->nulledSurface(z3), size, pad ,true);
surf_fft = sv->computeStarTest( heightMultiply * sv->nulledSurface(z3), size, pad ,true);
//showMag(surf_fft, true, "star ", true, gamma);
size = surf_fft.cols;

Expand Down
83 changes: 39 additions & 44 deletions igramarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,101 +1840,96 @@ void IgramArea::resizeImage()
void IgramArea::paintEvent(QPaintEvent *event)

{
QPainter painter(this);
QPainter painterThis(this);
int pw = parentWidget()->width();
int dw = pw/2;
int dh = parentWidget()->height();

QRect dirtyRect = event->rect();
if ((zoomIndex > 1 && m_zoomMode == EDGEZOOM) && (
((m_current_boundry == OutSideOutline) && (outterPcount == 2)) ||
((m_current_boundry != OutSideOutline) && (innerPcount == 2))
)){
painter.fillRect(this->rect(), Qt::gray);
int viewW = m_zoomBoxWidth;
painterThis.fillRect(this->rect(), Qt::gray);
int viewW = 3 * m_zoomBoxWidth / zoomIndex;
double scale = zoomIndex;
int dw = parentWidget()->width()/2;
int dh = parentWidget()->height();

QImage roi(viewW * 2, viewW, igramGray.format());
roi.fill(QColor(0,0,0));
QImage small(viewW * 4, viewW *2, igramColor.format());
small.fill(Qt::gray);
QPainter smallPainter(&small); // used to assemble the edge samples beore it is enlarged to fill the window.
QImage zoomImg(viewW *2,viewW, igramColor.format());
QPainter zoomPainter(&zoomImg);



painterThis.fillRect(0,0,pw,dw, Qt::gray);

CircleOutline circle((m_current_boundry == OutSideOutline) ? m_OutterP1 : m_innerP1,
(m_current_boundry == OutSideOutline) ? m_OutterP2 : m_innerP2);

//painter.drawImage(dirtyRect, igramDisplay, dirtyRect);
mirrorDlg &md = *mirrorDlg::get_Instance();
double e = 1.;
if (md.isEllipse()){
e = md.m_verticalAxis/md.diameter;
}


//top ************************************************************
int topx = circle.m_center.rx() - viewW;
int topy = circle.m_center.ry() - circle.m_radius * e - viewW/2;
int shifty = 0;

if (topy < 0){
shifty = -1 * topy;
topy = 0;
}

QPainter ptop(&roi);
ptop.drawImage(0,shifty, m_withOutlines, topx,topy + shifty,viewW * 2, viewW-shifty);
QImage top2 = roi.scaled(scale * roi.width(), scale * roi.height());
int w = top2.width();
int h = top2.height();
painter.drawImage(dw - viewW, dh/2- viewW - 20, top2, w/2 - viewW , (h - viewW)/2, viewW * 2, viewW);
qDebug() << "viewW" << viewW << "scale"<< zoomIndex;
QImage roi = m_withOutlines.copy(topx,topy, viewW * 2, viewW);
smallPainter.drawImage(viewW ,0, roi);

//bottom *************************************************************
QImage bottom = roi.copy();
bottom.fill(QColor(0,0,0));
QPainter pbottom(&bottom);
topy = (circle.m_center.ry() + circle.m_radius * e - viewW/2);
shifty = 0;
int shifty = 0;
if (topy > m_withOutlines.height()){
shifty = topy - m_withOutlines.height();
}
pbottom.drawImage(0,0-shifty, m_withOutlines, topx, topy - shifty,viewW * 2, viewW-shifty);
top2 = bottom.scaled(scale * bottom.width(), scale * bottom.height());
w = top2.width();
h = top2.height();
painter.drawImage(dw - viewW, dh/2+ 20, top2, w/2 - viewW , (h - viewW)/2, viewW * 2, viewW);
roi = m_withOutlines.copy(topx,topy, viewW * 2, viewW);
smallPainter.drawImage(viewW, viewW, roi);

//Left *************************************************************
QImage roi2(viewW, 2 * viewW, igramGray.format());
roi2.fill(QColor(0,0,0));
QPainter p2(&roi2);
topx = circle.m_center.rx() - circle.m_radius - viewW/2;
topy = circle.m_center.ry() - viewW;
roi = m_withOutlines.copy(topx,topy,viewW,viewW * 2);
int shiftl = 0;
if (topx < 0){
topx *= 1;
shiftl = topx;
}
p2.drawImage(shiftl,0,m_withOutlines, topx + shiftl,topy ,viewW - shiftl, viewW * 2);
top2 = roi2.scaled(scale * roi2.width(), scale * roi2.height());
w = top2.width();
h = top2.height();
painter.drawImage(dw - 2 * viewW - 20, dh/2 - viewW, top2, (w - viewW)/2, h/2 - viewW, viewW, 2 * viewW);
smallPainter.drawImage(0,0,roi);


// right ************************************************************
topx = circle.m_center.rx() + circle.m_radius - viewW/2;
QImage right(viewW, 2 * viewW, igramGray.format());
right.fill(QColor(0,0,0));
QPainter pright(&right);
topx = circle.m_center.rx() + circle.m_radius - viewW/2;
topy = circle.m_center.ry() - viewW;
shiftl = 0;

if (topx > m_withOutlines.width()){
topx = topx - m_withOutlines.width();
shiftl = topx;
}
pright.drawImage(shiftl,0,m_withOutlines, topx + shiftl, topy ,viewW-shiftl, viewW * 2);
top2 = right.scaled(scale * right.width(), scale * right.height());
w = top2.width();
h = top2.height();
painter.drawImage(dw + viewW + 20, dh/2 - viewW, top2, (w - viewW)/2, h/2 - viewW, viewW, 2 * viewW);
roi = m_withOutlines.copy(topx,topy, viewW , viewW * 2);

smallPainter.drawImage(viewW*3,0,roi);
smallPainter.setPen(QPen(Qt::gray,2));
smallPainter.drawLine(viewW,0,viewW, viewW*2);
smallPainter.drawLine(viewW * 3,0,viewW * 3, viewW*2);
smallPainter.drawLine(viewW,viewW,viewW * 3, viewW);
painterThis.drawImage(0,0, small.scaled(this->size()));

} else {
painter.drawImage(dirtyRect, igramDisplay, dirtyRect);
painterThis.drawImage(dirtyRect, igramDisplay, dirtyRect);
}



}

void IgramArea::createActions()
Expand Down
20 changes: 8 additions & 12 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const QString toolButtonStyle("QToolButton {"
m_contourView = new contourView(this, m_contourTools);
connect(m_contourView, SIGNAL(zoomMe(bool)),this, SLOT(zoomContour(bool)));
m_ogl = new OGLView(0, m_contourTools, m_surfTools);

connect(m_ogl, SIGNAL(fullScreen()), this, SLOT(zoomOgl()));

connect(userMapDlg, SIGNAL(colorMapChanged(int)), m_contourView->getPlot(), SLOT(ContourMapColorChanged(int)));
//connect(userMapDlg, SIGNAL(colorMapChanged(int)),m_ogl->m_gl, SLOT(colorMapChanged(int)));
Expand Down Expand Up @@ -726,10 +726,7 @@ void MainWindow::rocChanged(double v){
m_mirrorDlg->on_roc_Changed(v);
}

void MainWindow::on_actionLighting_properties_triggered()
{
//m_ogl->m_gl->openLightingDlg();
}


void MainWindow::on_SelectOutSideOutline_clicked(bool checked)
{
Expand Down Expand Up @@ -1373,12 +1370,14 @@ void MainWindow::restoreContour(){
}

void MainWindow::restoreOgl(){

m_contourView->setMinimumHeight(0);
review->s1->insertWidget(0,m_ogl);
m_ogl->enableFullScreen();
}

void MainWindow::restoreProfile(){
m_profilePlot->zoomed = false;
review->s2->insertWidget(0,m_profilePlot);
review->s2->insertWidget(1,m_profilePlot);
}

void MainWindow::zoomProfile(bool flag){
Expand Down Expand Up @@ -1411,12 +1410,9 @@ void MainWindow::zoomContour(bool flag){
contourFv->showMaximized();
}

void MainWindow::zoomOgl(bool flag)
void MainWindow::zoomOgl()
{
if (!flag){
oglFv->close();
return;
}

oglFv = new QWidget(0);
oglFv->setAttribute( Qt::WA_DeleteOnClose );
connect(oglFv,SIGNAL(destroyed(QObject*)),this, SLOT(restoreOgl()));
Expand Down
4 changes: 1 addition & 3 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public slots:
void restoreContour();
void restoreProfile();
void zoomContour(bool flag);
void zoomOgl(bool flag);
void zoomOgl();
void zoomProfile(bool flag);
void imageSize(QString txt);
void skipBatchItem();
Expand Down Expand Up @@ -137,8 +137,6 @@ private slots:

void on_actionSave_Wavefront_triggered();

void on_actionLighting_properties_triggered();

void on_SelectOutSideOutline_clicked(bool checked);

void on_SelectObsOutline_clicked(bool checked);
Expand Down
7 changes: 3 additions & 4 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -88,7 +88,6 @@
<string>View</string>
</property>
<addaction name="separator"/>
<addaction name="actionLighting_properties"/>
<addaction name="actionError_Margins"/>
<addaction name="actionShow_Statistics_of_Loaded_wavefronts"/>
<addaction name="separator"/>
Expand Down Expand Up @@ -422,7 +421,7 @@ QPushButton:hover{rgb(85, 255, 255)}</string>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>74</width>
<height>0</height>
</size>
</property>
Expand Down
10 changes: 8 additions & 2 deletions metricsdisplay.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
<height>710</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>228</width>
<height>408</height>
<width>100</width>
<height>409</height>
</size>
</property>
<property name="windowTitle">
Expand Down
29 changes: 27 additions & 2 deletions oglview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,50 @@ OGLView::OGLView(QWidget *parent, ContourTools *m_tool,
lightingPb = new QPushButton("3D Controls",this);
QPushButton *saveImagePb = new QPushButton("save Image");
QPushButton *showSelectedPb = new QPushButton("show selected");
m_fullScreenPb = new QPushButton("FullScreen");
lh->addWidget(lightingPb);
lh->addWidget(saveImagePb);
lh->addWidget(showSelectedPb);
lh->addWidget(m_fullScreenPb);
connect(lightingPb, SIGNAL(pressed()), this,SLOT(openLightDlg()));
connect(saveImagePb, SIGNAL(pressed()), this, SLOT(saveImage()));
connect(showSelectedPb, SIGNAL(pressed()), this, SLOT(showSelected()));
connect(m_tool,SIGNAL(ContourMapColorChanged(int)), m_surface, SLOT(setColorMap(int)));

connect(m_fullScreenPb, SIGNAL(pressed()), this, SLOT(fullScreenPressed()));
lh->addStretch();
lv->addWidget(m_container);
topH->addLayout(lv,10);
topH->addLayout(rightcontrols,1);
setLayout(topH);

setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
SLOT(showContextMenu(QPoint)));
}
OGLView::~OGLView(){
m_controls->close();
delete m_controls;
}

void OGLView::showContextMenu(const QPoint &pos)
{
// Handle global position
QPoint globalPos = mapToGlobal(pos);

// Create menu and insert some actions
QMenu myMenu;

myMenu.addAction("FullScreen", this, SLOT(fullScreenPressed()));

// Show context menu at handling position
myMenu.exec(globalPos);
}
void OGLView::fullScreenPressed(){
m_fullScreenPb->setEnabled(false);
emit fullScreen();
}
void OGLView::enableFullScreen(){
m_fullScreenPb->setEnabled(true);
}
void OGLView::openLightDlg(){
m_controls->show();
}
Expand Down
8 changes: 6 additions & 2 deletions oglview.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class OGLView : public QWidget
Q_OBJECT
Surface3dControlsDlg *m_controls;
public:
QPushButton *m_fullScreenPb;
explicit OGLView(QWidget *parent = 0, ContourTools *m_tool = 0,
surfaceAnalysisTools *surfTools = 0);
~OGLView();
Expand All @@ -48,12 +49,15 @@ class OGLView : public QWidget

QSize sizeHint() const;
int m_spinRate;

signals:
void fullScreen();
public slots:

void fullScreenPressed();
void openLightDlg();
void saveImage();
void showSelected();
void enableFullScreen();
void showContextMenu(const QPoint &pos);

};

Expand Down
2 changes: 1 addition & 1 deletion profileplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ QPolygonF ProfilePlot::createProfile(double units, wavefront *wf){
mirrorDlg &md = *mirrorDlg::get_Instance();
double radius = md.m_clearAperature/2.;
double obs_radius = md.obs/2.;
qDebug() << "clear app radius" << radius;

// qDebug() << "Clear" << radius;
for (double rad = -1.; rad < 1; rad += steps){
int dx, dy;
Expand Down
2 changes: 1 addition & 1 deletion surfaceanalysistools.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<property name="minimumSize">
<size>
<width>524</width>
<height>733</height>
<height>400</height>
</size>
</property>
<property name="windowTitle">
Expand Down
Loading

0 comments on commit 1946acd

Please sign in to comment.