21 #include "ui_mapviewer.h" 32 QMainWindow(parent), ui(new
Ui::
MapViewer), map_keys_(map_keys)
37 name_ = map_keys.last();
38 directory_ = ws->directory_ptr();
39 ui->mapPlot->setBackground(palette().window());
40 statusbar_label_ =
new QLabel(
"(0, 0, 0)");
41 ui->statusbar->addWidget(statusbar_label_);
51 ui->mapPlot->setBackground(Qt::white);
79 QString text =
"(" + QString::number(x) +
", " +
80 QString::number(y) +
", " +
81 QString::number(z) +
")";
82 statusbar_label_->setText(text);
89 void MapViewer::on_actionInterpolate_toggled(
bool arg1)
91 workspace_->GetMap(map_keys_)->setInterpolate(arg1);
97 void MapViewer::on_actionSave_Image_As_triggered()
99 QString path = *directory_;
100 path = path +
"/" + name_;
103 QFileDialog::getSaveFileName(
this,
106 tr(
"Scalable Vector Graphics (*.svg);; " 107 "Enhanced Windows Metafile (*.emf);; " 108 "Portable Document Format (*.pdf);; " 109 "Tagged Image File Format (*.tif);; " 110 "Windows Bitmap (*.bmp);; " 111 "Portable Network Graphics (*.png);; " 113 ui->mapPlot->SaveImage(filename);
121 void MapViewer::on_actionShow_Axes_toggled(
bool arg1)
123 workspace_->GetMap(map_keys_)->ShowAxes(arg1);
131 void MapViewer::on_actionShow_Color_Scale_toggled(
bool arg1)
133 workspace_->GetMap(map_keys_)->ShowColorScale(arg1);
140 void MapViewer::on_actionSet_Color_Scheme_triggered()
142 if (!workspace_->GetMap(map_keys_)->global_gradient_key().isEmpty())
143 QMessageBox::warning(
this,
"Global Gradient",
144 "Changing the color gradient will detach this map" 145 "from the global gradient");
146 QStringList gradient_names = workspace_->GradientNames();
147 QString gradient_key = QInputDialog::getItem(
this,
"Select Gradient",
"Gradient",
150 workspace_->GetMap(map_keys_)->setGradient(new_gradient);
156 void MapViewer::on_actionAdd_Scale_Bar_triggered()
160 scale_bar_dialog->setAttribute(Qt::WA_DeleteOnClose);
161 scale_bar_dialog->show();
169 void MapViewer::on_actionLock_Size_toggled(
bool arg1)
171 workspace_->GetMap(map_keys_)->LockMapDisplaySize(arg1);
177 void MapViewer::on_actionReset_Size_triggered()
179 workspace_->GetMap(map_keys_)->ResetMapWidgetSize();
186 void MapViewer::on_actionReproportion_triggered()
188 workspace_->GetMap(map_keys_)->RescaleMapWidget();
191 void MapViewer::on_actionSet_Font_triggered()
194 QFont font = QFontDialog::getFont(&ok,
195 QFont(
"Arial", 12, QFont::Normal),
196 this,
"Select Font");
197 if (ok) workspace_->GetMap(map_keys_)->SetFonts(font);
200 void MapViewer::on_actionSet_Color_Scale_Label_triggered()
202 QString current_label = ui->mapPlot->ColorScaleLabel();
204 QString new_label = QInputDialog::getText(
this,
"Enter label",
208 if (ok) ui->mapPlot->SetColorScaleLabel(new_label);
211 void MapViewer::on_actionSet_Global_Color_Scale_triggered()
213 QStringList global_scale_names = workspace_->GlobalGradientKeys();
214 if (!global_scale_names.size()){
215 QMessageBox::information(
this,
"No Global Gradients",
216 "No global gradients exist. To create a new" 217 "gradient, select Tools->Global Color Scales" 218 "in the main window");
222 QString key = QInputDialog::getItem(
this,
"Select Global Gradient",
223 "Gradient", global_scale_names,
226 workspace_->GetMap(map_keys_)->SetGlobalGradient(key);
234 switch (event->key()) {
238 ui->mapPlot->MoveHorizontalCrosshair(1);
243 ui->mapPlot->MoveHorizontalCrosshair(-1);
248 ui->mapPlot->MoveVerticalCrosshair(-1);
253 ui->mapPlot->MoveVerticalCrosshair(1);
260 ui->mapPlot->GetCrosshairPosition());
269 workspace_->main_window()->plot_viewer()->AddTab(name_);
270 workspace_->main_window()->SetPlotViewerActionChecked(
true);
275 void MapViewer::on_actionCenter_Color_Scale_at_0_triggered()
277 ui->mapPlot->CenterAtZero();
void keyPressEvent(QKeyEvent *event)
void showEvent(QShowEvent *event)
void RequestSpectrumPlot(QString dataset_key, QString map_name, size_t index)
void CoordinatesChanged(double x, double y, double z)
PlotViewer * plot_viewer()
void SetStatusbar(double x, double y, double z)
The MapPlot class A subclass of QCustomPlot for handling a specfic kind of color map. Provides a wrapper for a QCPColorScale and a QCPColorMap which are child widgets.
void SpectrumRequested(QString dataset_key, QString map_name, size_t index)
void HeldSpectrumRequested(QString dataset_key, QString map_name, size_t index)
void SpectrumRequested(size_t index)
MapViewer::SpectrumRequested.
The MapViewer class Displays the image created by MapData.
void SpectrumRequested(size_t index)
void SetHoldCheckBoxChecked(bool checked)
The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot...
Defines a color gradient for use with e.g. QCPColorMap.
MapViewer(MainWindow *parent, QStringList map_keys, QSharedPointer< VespucciWorkspace > ws)
MapViewer::MapViewer.
The MainWindow class The main window of the program, this is where the user performs most operations...
void RequestHeldSpectrumPlot(QString dataset_key, QString map_name, size_t index)
The ScaleBarDialog class Dialog for the user to create a scale bar on the image.