31 QStringList data_keys,
33 QSharedPointer<VespucciWorkspace> workspace)
34 :name_(name), type_(type)
36 workspace_ = workspace;
37 if (workspace_->GetMatrix(data_keys).n_cols <= data_column)
38 throw invalid_argument(
"Requested column out of bounds");
39 data_keys_ = data_keys;
40 data_column_ = data_column;
41 dataset_ = workspace_->GetDataset(data_keys.first());
42 QStringList map_keys = {dataset_->name(), name_};
44 map_display_ =
new MapViewer(workspace_->main_window(), map_keys, workspace_);
45 map_display_->setWindowTitle(name_);
46 map_qcp_ = map_display_->
mapPlot();
47 vec x = dataset_->x();
48 vec y = dataset_->y();
49 vec z = workspace_->GetMatrix(data_keys_).col(data_column_);
51 vec unique_z = unique(z);
93 QString window_title = dataset_->name() +
"—" + name +
" " +
type;
94 map_display_->setWindowTitle(window_title);
99 if (workspace_->GlobalGradientKeys().contains(name)){
100 global_gradient_key_ =
name;
114 return QStringList({dataset_->name(), name_});
127 map_display_->setVisible(show);
128 map_display_->raise();
136 if(map_display_->isVisible())
137 map_display_->close();
146 return map_display_->isVisible();
157 int key_size = map_qcp_->
keySize();
161 map_qcp_->resize(key_size, value_size);
164 map_display_->resize(key_size, value_size);
173 x_axis_description_ = description;
182 y_axis_description_ = description;
251 bool success = map_qcp_->
saveBmp(fileName, width, height, scale);
272 bool success = map_qcp_->
savePdf(fileName,
true, width, height,
"Vespucci",
name());
287 bool MapData::savePng(
const QString &fileName,
int width,
int height,
double scale,
int quality)
292 bool success = map_qcp_->
savePng(fileName, width, height, scale, quality);
308 bool MapData::saveJpg(
const QString &fileName,
int width,
int height,
double scale,
int quality)
313 bool success = map_qcp_->
saveJpg(fileName, width, height, scale, quality);
329 bool MapData::saveTiff(
const QString &fileName,
int width,
int height,
double scale,
int quality)
334 bool success = map_qcp_->
saveRastered(fileName, width, height, scale,
"TIF", quality);
349 global_gradient_key_ = QString();
384 map_qcp_->
addItem(scale_bar_text);
386 QString text = QString::number(width) +
" " + units;
393 QBrush brush(color, Qt::SolidPattern);
400 double key_max = key_range.
upper;
401 double key_min = key_range.
lower;
402 double value_max = value_range.
upper;
403 double value_min = value_range.
lower;
405 double x_min, y_min, x_max, y_max;
407 if (position ==
"Top Left"){
408 x_min = key_min + 2.0;
409 x_max = x_min + width;
410 y_max = value_max - 4.0;
411 y_min = y_max - height;
414 else if (position ==
"Top Right"){
415 x_max = key_max - 2.0;
416 x_min = x_max - width;
417 y_max = value_max - 4.0;
418 y_min = y_max - height;
421 else if (position ==
"Bottom Left"){
422 x_min = key_min + 2.0;
423 x_max = x_min + width;
424 y_min = value_min + 2.0;
425 y_max = y_min + height;
429 x_max = key_max - 2.0;
430 x_min = x_max - width;
431 y_min = value_min + 2.0;
432 y_max = y_min + height;
437 double x_mid = ((x_max - x_min) / 2.0) + x_min;
438 double y_text = y_max + 1;
439 if (font.pointSize() >= 32){
440 y_text += (font.pointSize() - 32) / 4;
466 double width_ratio = map_qcp_->width()/initial_map_size_.width();
467 double height_ratio = map_qcp_->height()/initial_map_size_.height();
468 double max_ratio =
std::max(width_ratio, height_ratio);
469 double new_height = max_ratio * initial_map_size_.height();
470 double new_width = max_ratio * initial_map_size_.width();
471 map_qcp_->resize(new_width, new_height);
472 map_display_->resize(new_width + 50, new_height + 50);
483 map_display_->setFixedSize(map_display_->size());
485 map_display_->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
493 map_qcp_->resize(initial_map_size_);
494 map_display_->resize(initial_map_size_.width() + 50, initial_map_size_.height() + 50);
506 return global_gradient_key_;
515 return map_qcp_->
min();
520 return map_qcp_->
max();
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0)
MapData::saveBmp.
void SetGradient(QCPColorGradient gradient)
void ColorScaleVisible(bool visible)
void DrawScaleBar(double width, double height, QString units, QColor color, QString position, QFont font)
MapData::DrawScaleBar.
void SetMapPlot(MapPlot *plot)
void UpdateGlobalGradient()
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
void SetYDescription(QString description)
MapData::SetYDescription.
void RescaleMapWidget()
MapData::RescaleMapWidget Changes the proportions of the map window back to the initial proportions...
QCPItemPosition *const topLeft
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
MapData::saveJpg.
void SetFonts(const QFont &font)
void ResetMapWidgetSize()
MapData::ResetMapWidgetSize Returns the size of the map window to the original proportions.
void setGradient(const QCPColorGradient &gradient)
MapData::setGradient.
void SetMapData(const vec &x, const vec &y, const vec &z)
MapPlot::SetMapData.
bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1)
void SetFonts(const QFont &font)
double min()
MapData::min.
QCPColorGradient gradient
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
void setInterpolate(bool interpolate)
void setCoords(double key, double value)
void setInterpolate(bool enabled)
MapData::setInterpolate.
void SetDataRange(QCPRange new_range)
MapData::SetDataRange.
void setColor(const QColor &color)
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0)
QString type()
MapData::type.
bool savePdf(const QString &fileName, int width, int height)
MapData::savePDF.
void setBackground(const QPixmap &pm)
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint)
void ShowCrosshairs(bool show)
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
MapData::savePng.
VESPUCCI_EXPORT void position(arma::uword index, arma::uword n_rows, arma::uword n_cols, arma::uword &i, arma::uword &j)
Vespucci::Math::position Find row and column numbers for index.
void HideMapWindow()
MapData::HideMapWindow Closes the map window.
bool addItem(QCPAbstractItem *item)
void ShowMapWindow(bool show)
MapData::ShowMapWindow Shows or hides the map window.
QString global_gradient_key()
void SetClusterTicks(size_t count)
void setDataRange(const QCPRange &dataRange)
void SetColorScaleTickCount(int ticks)
bool MapWindowVisible()
MapData::MapWindowVisible.
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 ShowColorScale(bool enabled)
MapData::ShowColorScale.
The MapViewer class Displays the image created by MapData.
void CreateImage(QCPColorGradient color_scheme, bool interpolation, int tick_count)
MapData::CreateImage.
MapData(QString name, QString type, QStringList data_keys, uword data_column, QSharedPointer< VespucciWorkspace > workspace)
MapData::~MapData Deletes everything the new keyword is used on in this object. Destructor triggered ...
void setBrush(const QBrush &brush)
bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot...
void SetColorScaleTickCount(int ticks)
void ShowAxes(bool enabled)
MapData::ShowAxes.
void LockMapDisplaySize(bool lock)
MapData::LockMapDisplaySize.
void rescaleDataRange(bool onlyVisibleMaps=false)
void SetXDescription(QString description)
MapData::SetXDescription.
QCPItemPosition *const position
void setText(const QString &text)
bool interpolate()
MapData::interpolate.
Defines a color gradient for use with e.g. QCPColorMap.
Represents the range an axis is encompassing.
void setPositionAlignment(Qt::Alignment alignment)
void SetName(QString name, QString type)
MapData::set_name.
void SetGlobalGradient(QString name)
void setPen(const QPen &pen)
bool saveTiff(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=0)
MapData::saveTiff.
QCPItemPosition *const bottomRight
QString name()
MapData::name.
void setFont(const QFont &font)