2013-08-09 06:57:18 +02:00
|
|
|
#include "lc_global.h"
|
|
|
|
#include "lc_qimagedialog.h"
|
|
|
|
#include "ui_lc_qimagedialog.h"
|
2016-08-01 05:44:15 +02:00
|
|
|
#include "lc_application.h"
|
|
|
|
#include "project.h"
|
|
|
|
#include "lc_model.h"
|
|
|
|
#include "lc_profile.h"
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
lcQImageDialog::lcQImageDialog(QWidget* Parent)
|
|
|
|
: QDialog(Parent), ui(new Ui::lcQImageDialog)
|
2013-08-09 06:57:18 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2017-07-30 23:18:57 +02:00
|
|
|
ui->width->setValidator(new QIntValidator(1, 32768, this));
|
|
|
|
ui->height->setValidator(new QIntValidator(1, 32768, this));
|
2015-01-14 23:33:19 +01:00
|
|
|
ui->firstStep->setValidator(new QIntValidator(this));
|
|
|
|
ui->lastStep->setValidator(new QIntValidator(this));
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
Project* Project = lcGetActiveProject();
|
|
|
|
lcModel* Model = Project->GetActiveModel();
|
|
|
|
mWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
|
|
|
mHeight = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
|
|
|
|
mStart = Model->GetCurrentStep();
|
|
|
|
mEnd = Model->GetLastStep();
|
2018-04-15 03:27:16 +02:00
|
|
|
mFileName = Project->GetImageFileName(false);
|
2016-08-01 05:44:15 +02:00
|
|
|
|
|
|
|
ui->fileName->setText(mFileName);
|
|
|
|
ui->width->setText(QString::number(mWidth));
|
|
|
|
ui->height->setText(QString::number(mHeight));
|
|
|
|
ui->firstStep->setText(QString::number(mStart));
|
|
|
|
ui->lastStep->setText(QString::number(mEnd));
|
2014-10-12 01:26:23 +02:00
|
|
|
ui->rangeCurrent->setChecked(true);
|
2013-08-09 06:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lcQImageDialog::~lcQImageDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcQImageDialog::accept()
|
|
|
|
{
|
|
|
|
QString fileName = ui->fileName->text();
|
|
|
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
{
|
2014-10-12 01:26:23 +02:00
|
|
|
QMessageBox::information(this, tr("Error"), tr("Output File cannot be empty."));
|
2013-08-09 06:57:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int width = ui->width->text().toInt();
|
|
|
|
|
2017-07-30 23:18:57 +02:00
|
|
|
if (width < 1 || width > 32768)
|
2013-08-09 06:57:18 +02:00
|
|
|
{
|
2017-07-30 23:18:57 +02:00
|
|
|
QMessageBox::information(this, tr("Error"), tr("Please enter a width between 1 and 32768."));
|
2013-08-09 06:57:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int height = ui->height->text().toInt();
|
|
|
|
|
2017-07-30 23:18:57 +02:00
|
|
|
if (height < 1 || height > 32768)
|
2013-08-09 06:57:18 +02:00
|
|
|
{
|
2017-07-30 23:18:57 +02:00
|
|
|
QMessageBox::information(this, tr("Error"), tr("Please enter a height between 1 and 32768."));
|
2013-08-09 06:57:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
int start = mStart, end = mStart;
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2014-10-12 01:26:23 +02:00
|
|
|
if (ui->rangeAll->isChecked())
|
2013-08-09 06:57:18 +02:00
|
|
|
{
|
2014-10-12 01:26:23 +02:00
|
|
|
start = 1;
|
2016-08-01 05:44:15 +02:00
|
|
|
end = mEnd;
|
2013-08-09 06:57:18 +02:00
|
|
|
}
|
2014-10-12 01:26:23 +02:00
|
|
|
else if (ui->rangeCurrent->isChecked())
|
2013-08-09 06:57:18 +02:00
|
|
|
{
|
2016-08-01 05:44:15 +02:00
|
|
|
start = mStart;
|
|
|
|
end = mStart;
|
2013-08-09 06:57:18 +02:00
|
|
|
}
|
2014-10-12 01:26:23 +02:00
|
|
|
else if (ui->rangeCustom->isChecked())
|
|
|
|
{
|
|
|
|
start = ui->firstStep->text().toInt();
|
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
if (start < 1 || start > mEnd)
|
2014-10-12 01:26:23 +02:00
|
|
|
{
|
2016-08-01 05:44:15 +02:00
|
|
|
QMessageBox::information(this, tr("Error"), tr("First step must be between 1 and %1.").arg(QString::number(mEnd)));
|
2014-10-12 01:26:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
end = ui->lastStep->text().toInt();
|
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
if (end < 1 || end > mEnd)
|
2014-10-12 01:26:23 +02:00
|
|
|
{
|
2016-08-01 05:44:15 +02:00
|
|
|
QMessageBox::information(this, tr("Error"), tr("Last step must be between 1 and %1.").arg(QString::number(mEnd)));
|
2014-10-12 01:26:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end < start)
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("Error"), tr("Last step must be greater than first step."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-01 05:44:15 +02:00
|
|
|
mFileName = fileName;
|
|
|
|
mWidth = width;
|
|
|
|
mHeight = height;
|
|
|
|
mStart = start;
|
|
|
|
mEnd = end;
|
|
|
|
|
|
|
|
lcSetProfileInt(LC_PROFILE_IMAGE_WIDTH, mWidth);
|
|
|
|
lcSetProfileInt(LC_PROFILE_IMAGE_HEIGHT, mHeight);
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcQImageDialog::on_fileNameBrowse_clicked()
|
|
|
|
{
|
2014-10-12 01:26:23 +02:00
|
|
|
QString result = QFileDialog::getSaveFileName(this, tr("Save Image File"), ui->fileName->text(), tr("Supported Image Files (*.bmp *.png *.jpg);;BMP Files (*.bmp);;PNG Files (*.png);;JPEG Files (*.jpg);;All Files (*.*)"));
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
if (!result.isEmpty())
|
|
|
|
ui->fileName->setText(QDir::toNativeSeparators(result));
|
|
|
|
}
|