Vespucci  1.0.0
plotviewer.cpp
Go to the documentation of this file.
3 #include "ui_plotviewer.h"
4 #include "Global/global.h"
5 class PlotWidget;
6 PlotViewer::PlotViewer(MainWindow *parent, QSharedPointer<VespucciWorkspace> workspace) :
7  QDockWidget(parent),
8  ui(new Ui::PlotViewer)
9 {
10  ui->setupUi(this);
11  workspace_ = workspace;
12 }
13 
15 {
16  delete ui;
17 }
18 
19 void PlotViewer::AddPlot(const mat & paired_data, const QString &tab_title)
20 {
21  if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
22  PlotWidget *plot_widget = qobject_cast<PlotWidget *>(ui->tabWidget->currentWidget());
23  plot_widget->AddPlot(paired_data);
24  }
25  else{
26  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
27  plot_widget->AddPlot(paired_data);
28  ui->tabWidget->addTab(plot_widget, tab_title);
29  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
30  }
31 }
32 
33 void PlotViewer::AddPlot(const vec &abscissa, const vec &data, const QString &tab_title)
34 {
35  if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
36  PlotWidget *plot_widget = qobject_cast<PlotWidget *>(ui->tabWidget->currentWidget());
37  plot_widget->AddPlot(abscissa, data);
38  }
39  else{
40  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
41  plot_widget->AddPlot(abscissa, data);
42  ui->tabWidget->addTab(plot_widget, tab_title);
43  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
44  }
45 }
46 
47 void PlotViewer::AddTransientPlot(const vec &abscissa, const vec &data, const QString &tab_title)
48 {
49  if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
50  PlotWidget *plot_widget = qobject_cast<PlotWidget*>(ui->tabWidget->currentWidget());
51  plot_widget->AddTransientPlot(abscissa, data);
52  }
53  else{
54  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
55  plot_widget->AddTransientPlot(abscissa, data);
56  ui->tabWidget->addTab(plot_widget, tab_title);
57  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
58  }
59 }
60 
61 void PlotViewer::AddTransientPlot(const mat & paired_data, const QString &tab_title)
62 {
63  if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
64  PlotWidget *plot_widget = qobject_cast<PlotWidget*>(ui->tabWidget->currentWidget());
65  plot_widget->AddTransientPlot(paired_data);
66  }
67  else{
68  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
69  plot_widget->AddTransientPlot(paired_data);
70  ui->tabWidget->addTab(plot_widget, tab_title);
71  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
72  }
73 }
74 
75 void PlotViewer::AddScatterPlot(const mat &paired_data, const QString &tab_title)
76 { if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
77  PlotWidget *plot_widget = qobject_cast<PlotWidget *>(ui->tabWidget->currentWidget());
78  plot_widget->AddPlot(paired_data);
79  }
80  else{
81  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
82  plot_widget->AddScatterPlot(paired_data);
83  ui->tabWidget->addTab(plot_widget, tab_title);
84  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
85  }
86 
87 }
88 
89 void PlotViewer::AddScatterPlot(const vec &abscissa, const vec &data, const QString &tab_title)
90 {
91  if (ui->holdCheckBox->isChecked() && ui->tabWidget->count()){
92  PlotWidget *plot_widget = qobject_cast<PlotWidget *>(ui->tabWidget->currentWidget());
93  plot_widget->AddPlot(abscissa, data);
94  }
95  else{
96  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
97  plot_widget->AddScatterPlot(abscissa, data);
98  ui->tabWidget->addTab(plot_widget, tab_title);
99  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
100  }
101 }
102 
108 void PlotViewer::AddTab(const QString &tab_title)
109 {
110  PlotWidget *plot_widget = new PlotWidget(this, workspace_);
111  ui->tabWidget->addTab(plot_widget, tab_title);
112  ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
113 }
114 
116 {
117  ui->holdCheckBox->setChecked(checked);
118 }
119 
121 {
122  PlotWidget *plot_widget = qobject_cast<PlotWidget*>(ui->tabWidget->currentWidget());
123  if (plot_widget->TransientOnly()) ui->tabWidget->removeTab(ui->tabWidget->currentIndex());
124 }
125 
126 void PlotViewer::closeEvent(QCloseEvent *ev)
127 {
128  QDockWidget::closeEvent(ev);
129  emit SetActionChecked(false);
130 }
131 
132 void PlotViewer::on_tabWidget_tabCloseRequested(int index)
133 {
134  ui->tabWidget->removeTab(index);
135 }
136 
137 
138 void PlotViewer::on_exportPushButton_clicked()
139 {
140  PlotWidget *plot_widget = qobject_cast<PlotWidget *>(ui->tabWidget->currentWidget());
141  if (plot_widget != 0){
142  QString filename = QFileDialog::getSaveFileName(this, "Export Plot",
143  workspace_->directory(),
144  "Tagged Image File Format (*.tif);;"
145  "Portable Network Graphics (*.png);;"
146  "Joint Photographic Experts Group (*.jpg);;"
147  "Scalable Vector Graphics (*.svg);;"
148  "Windows Bitmap (*.bmp)");
149  plot_widget->SavePlot(filename);
150  }
151 }
void AddScatterPlot(const mat &paired_data)
PlotWidget::AddScatterPlot.
Definition: plotwidget.cpp:179
PlotWidget(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
Definition: plotwidget.cpp:24
Definition: ahcadialog.h:26
void AddTab(const QString &tab_title)
PlotViewer::AddTab.
Definition: plotviewer.cpp:108
void SavePlot(QString filename)
Definition: plotwidget.cpp:341
void AddTransientPlot(const vec &abscissa, const vec &data)
Definition: plotwidget.cpp:100
void AddPlot(const mat &paired_data)
Definition: plotwidget.cpp:54
void closeEvent(QCloseEvent *ev)
Definition: plotviewer.cpp:126
bool TransientOnly() const
Definition: plotwidget.cpp:336
void SetHoldCheckBoxChecked(bool checked)
Definition: plotviewer.cpp:115
void SetActionChecked(bool checked)
PlotViewer(MainWindow *parent, QSharedPointer< VespucciWorkspace > workspace)
Definition: plotviewer.cpp:6
void AddPlot(const mat &paired_data, const QString &tab_title)
Definition: plotviewer.cpp:19
void CloseTransientTab()
Definition: plotviewer.cpp:120
void AddScatterPlot(const mat &paired_data, const QString &tab_title)
Definition: plotviewer.cpp:75
The MainWindow class The main window of the program, this is where the user performs most operations...
Definition: mainwindow.h:58
void AddTransientPlot(const vec &abscissa, const vec &data, const QString &tab_title)
Definition: plotviewer.cpp:47