-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathcontourview.cpp
More file actions
142 lines (117 loc) · 3.83 KB
/
contourview.cpp
File metadata and controls
142 lines (117 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/******************************************************************************
**
** Copyright 2016 Dale Eason
** This file is part of DFTFringe
** is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation version 3 of the License
** DFTFringe is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with DFTFringe. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "contourview.h"
#include "ui_contourview.h"
#include <QMenu>
#include "math.h"
#include "pixelstats.h"
#include <QSettings>
#include <QGuiApplication>
#include <QScreen>
contourView::contourView(QWidget *parent, ContourTools *tools) :
QWidget(parent),
zoomed(false), ui(new Ui::contourView), tools(tools)
{
ui->setupUi(this);
ui->widget->setTool(tools);
QSettings set;
ui->doubleSpinBox->setValue(set.value("contourRange", .100).toDouble());
ui->fillContourCB->setChecked(set.value("contourShowFill", true).toBool());
ui->showRuler->setChecked(set.value("contourShowRuler",false).toBool());
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this,
&contourView::showContextMenu);
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ps = new pixelStats;
ui->LinkProfileCB->setChecked(set.value("linkProfilePlot", true).toBool());
}
contourView::~contourView()
{
delete ui;
}
void contourView::zoom(){
zoomed = !zoomed;
emit zoomMe(zoomed);
}
QImage contourView::getPixstatsImage(){
//resize(3000,2000);
int height = QGuiApplication::primaryScreen()->geometry().height() * .75;
QImage psImage = QImage(height, height,QImage::Format_ARGB32 );
QPainter p3(&psImage);
ps->resize(height * .7, height);
ps->render(&p3);
return psImage;
}
void contourView::setSurface(const wavefront *wf){
getPlot()->setSurface(wf);
ps->setData(wf);
}
void contourView::showContextMenu(QPoint pos)
{
// Handle global position
QPoint globalPos = mapToGlobal(pos);
// Create menu and insert some actions
QMenu myMenu;
QString txt = (zoomed)? tr("Restore to MainWindow") : tr("FullScreen");
myMenu.addAction(txt, this, &contourView::zoom);
// Show context menu at handling position
myMenu.exec(globalPos);
}
ContourPlot *contourView::getPlot(){
return ui->widget;
}
void contourView::on_doubleSpinBox_valueChanged(double arg1)
{
ui->widget->showContoursChanged(arg1);
if (arg1 == 0.){
ui->fillContourCB->setChecked(true);
on_fillContourCB_clicked(true);
}
}
void contourView::on_pushButton_pressed()
{
emit showAllContours();
}
void contourView::on_histogram_clicked()
{
ps->show();
}
void contourView::on_fillContourCB_clicked(bool checked)
{
QSettings set;
ui->widget->showSpectrogram(checked);
}
void contourView::updateRuler(){
if (getPlot()->m_wf){
QSettings settings;
getPlot()->m_rulerPen = QPen(QColor(settings.value("ContourRulerColor", "grey").toString()));
getPlot()->m_radialDeg = settings.value("contourRulerRadialDeg",30).toInt();
setSurface(getPlot()->m_wf);
}
}
void contourView::on_showRuler_clicked(bool checked)
{
QSettings set;
set.setValue("contourShowRuler", checked);
if (getPlot()->m_wf)
setSurface(getPlot()->m_wf);
}
void contourView::on_LinkProfileCB_clicked(bool checked)
{
QSettings set;
set.setValue("linkProfilePlot", checked);
getPlot()->m_linkProfile = checked;
}