DataManager::DataManager(QObject* parent) :
QObject(parent),
- m_sequenceRejected(false)
+ m_sequenceRejected(false),
+ m_graphToImageExportDialog(ImageDrawer::supportedImageFormats())
{
m_sequences.push_back(std::make_pair<const QString, std::shared_ptr<Sequence>>("Single runs", std::shared_ptr<Sequence>(new Sequence())));
m_seqSelModel.setSequences(&m_sequences);
m_sigNameCodec = QTextCodec::codecForName("ISO-8859-1");
-
- m_oldExportToImageParams = ExportGraphToImageDialog::Parameters();
}
void DataManager::saveUserDataOnExit()
void DataManager::onExportGraphToImage()
{
- ExportGraphToImageDialog dlg(ImageDrawer::supportedImageFormats(), m_oldExportToImageParams);
+ QMetaObject::Connection conn;
std::shared_ptr<SingleRunData> sr;
int ret = 1;
if (sr == nullptr)
return;
- connect(&dlg, &ExportGraphToImageDialog::fileNameChanged, [&dlg, this](const QString& name) {
+ m_graphToImageExportDialog.removeAllSignals();
+
+ conn = connect(&m_graphToImageExportDialog, &ExportGraphToImageDialog::fileNameChanged, [this](const QString& name) {
int idx = ImageDrawer::guessFormatFromSuffix(name);
if (idx > 0)
- dlg.onFormatChanged(idx);
+ m_graphToImageExportDialog.onFormatChanged(idx);
});
for (const std::pair<std::string, std::shared_ptr<SignalController>>& p : sr->allControllers()) {
GUIViewport vp = p.second->guiViewport();
- dlg.addSignal(vp.absFromTime, vp.absFromValue, vp.absToTime, vp.absToValue, p.first);
+ m_graphToImageExportDialog.addSignal(vp.absFromTime, vp.absFromValue, vp.absToTime, vp.absToValue, p.first);
}
do {
- if (dlg.exec() == QDialog::Accepted) {
- const std::string key = dlg.selectedSignal().toStdString();
+ if (m_graphToImageExportDialog.exec() == QDialog::Accepted) {
+ const std::string key = m_graphToImageExportDialog.selectedSignal().toStdString();
std::shared_ptr<SignalController> ctrl = sr->controllerAt(key);
GraphLayers gl = GraphLayers::GRAPH | GraphLayers::SCALE;
ImageDrawer::ReturnCode drwRet;
continue;
}
- if (dlg.path().length() == 0) {
+ if (m_graphToImageExportDialog.path().length() == 0) {
QMessageBox::warning(nullptr, "Error while exporting to image", "Invalid path");
continue;
}
- if (dlg.includePeaks())
+ if (m_graphToImageExportDialog.includePeaks())
gl |= GraphLayers::INTEGRATION;
- relFromX = ctrl->timeToRel(dlg.fromX());
- relToX = ctrl->timeToRel(dlg.toX());
- relFromY = ctrl->valueToRel(dlg.fromY());
- relToY = ctrl->valueToRel(dlg.toY());
+ relFromX = ctrl->timeToRel(m_graphToImageExportDialog.fromX());
+ relToX = ctrl->timeToRel(m_graphToImageExportDialog.toX());
+ relFromY = ctrl->valueToRel(m_graphToImageExportDialog.fromY());
+ relToY = ctrl->valueToRel(m_graphToImageExportDialog.toY());
ImageDrawer imageDrawer(ctrl);
- drwRet = imageDrawer.render(dlg.path(), dlg.imageFormat().toLatin1(), dlg.imageWidth(), dlg.imageHeight(),
+ drwRet = imageDrawer.render(m_graphToImageExportDialog.path(), m_graphToImageExportDialog.imageFormat().toLatin1(),
+ m_graphToImageExportDialog.imageWidth(), m_graphToImageExportDialog.imageHeight(),
relFromX, relFromY, relToX, relToY, gl);
switch (drwRet) {
case ImageDrawer::ReturnCode::SUCCESS:
break;
} while (ret == 1);
- m_oldExportToImageParams = dlg.parameters();
+ disconnect(conn);
+
}
void DataManager::onExportPeaks()
ui(new Ui::ExportGraphToImageDialog)
{
ui->setupUi(this);
+ m_lastUsedPath = "";
+ m_lastUsedParameters = params;
for (const QByteArray ba : formats)
ui->qcbox_outputFormat->addItem(QString::fromLatin1(ba));
connect(ui->qcbox_signal, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeBounds(QString)));
connect(ui->qle_destPath, SIGNAL(textChanged(QString)), this, SLOT(onFileNameChanged(QString)));
+ ui->qle_destPath->setText(m_lastUsedPath);
ui->qle_width->setText(QString::number(params.width));
ui->qle_height->setText(QString::number(params.height));
ui->qcbox_outputFormat->setCurrentIndex(params.formatIdx);
return ui->qle_destPath->text();
}
+void ExportGraphToImageDialog::removeAllSignals()
+{
+ while (ui->qcbox_signal->count())
+ ui->qcbox_signal->removeItem(0);
+
+ m_signalKeys.clear();
+ m_bounds.clear();
+}
+
QString ExportGraphToImageDialog::selectedSignal() const
{
return ui->qcbox_signal->currentText();
} catch (std::out_of_range&) {
}
+
+ m_lastUsedParameters = Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked());
+ m_lastUsedPath = ui->qle_destPath->text();
accept();
}