|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/**
|
|
|
|
|
* \file mainwindow.cpp
|
|
|
|
|
* \version v1.0
|
|
|
|
|
* \author Ing. Dominik Malcik
|
|
|
|
|
*/
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
#include "projectwizard.h"
|
|
|
|
|
#include "xmlparser.h"
|
|
|
|
|
#include "layercomposer.h"
|
|
|
|
|
#include "customgraphicsview.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <QPixmapCache>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
#include <QColorDialog>
|
|
|
|
|
|
|
|
|
|
// CONSTS
|
|
|
|
|
const QString MainWindow::APPL_NAME = QString("microAnalyzer ::");
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief = CONSTRUCTOR
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
// signals
|
|
|
|
|
connect(cProject::Instance(), SIGNAL(imagesValueChanged()), this, SLOT(reloadImagesList()));
|
|
|
|
|
connect(cProject::Instance(), SIGNAL(layersValueChanged()), this, SLOT(reloadLayersList()));
|
|
|
|
|
|
|
|
|
|
imageView = new CustomGraphicsView();
|
|
|
|
|
imageView->setBackgroundRole(QPalette::Dark);
|
|
|
|
|
imageView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
|
|
|
|
setCentralWidget(imageView);
|
|
|
|
|
|
|
|
|
|
connect(imageView, SIGNAL(colorPickerPosition(int, int)), this, SLOT(graphicsClicked(int, int)));
|
|
|
|
|
connect(this, SIGNAL(colorPickerPosition(int, int)), this, SLOT(graphicsClicked(int, int)));
|
|
|
|
|
|
|
|
|
|
histogramBtn = false;
|
|
|
|
|
|
|
|
|
|
// init values
|
|
|
|
|
initStageAndValues();
|
|
|
|
|
|
|
|
|
|
// limit cache
|
|
|
|
|
QPixmapCache::setCacheLimit(4194304);
|
|
|
|
|
|
|
|
|
|
// statusbar init
|
|
|
|
|
statusBar()->showMessage("To activate function do Open project or Open image action."); // + tr("%1").arg(QPixmapCache::cacheLimit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::initStageAndValues() {
|
|
|
|
|
|
|
|
|
|
// disable functions that are available only after a project is loaded
|
|
|
|
|
menuChangeAvailability(false);
|
|
|
|
|
|
|
|
|
|
openedNewProjDialog = false;
|
|
|
|
|
|
|
|
|
|
// setup of bitmap layers table
|
|
|
|
|
bitmapLayersTBL = NULL;
|
|
|
|
|
bitmapLayersTBL = new TableFormat();
|
|
|
|
|
ui->bitmapTableView->setModel(bitmapLayersTBL);
|
|
|
|
|
ui->bitmapTableView->resizeRowsToContents(); // Adjust the row height.
|
|
|
|
|
ui->bitmapTableView->resizeColumnsToContents(); // Adjust the column width.
|
|
|
|
|
ui->bitmapTableView->setColumnWidth( 0, 20 );
|
|
|
|
|
ui->bitmapTableView->setColumnWidth( 1, 150 );
|
|
|
|
|
ui->bitmapTableView->setColumnWidth( 2, 20 );
|
|
|
|
|
|
|
|
|
|
// setup of vector layers table
|
|
|
|
|
vectorLayersTBL = NULL;
|
|
|
|
|
vectorLayersTBL = new TableFormat();
|
|
|
|
|
ui->vectorTableView->setModel(vectorLayersTBL);
|
|
|
|
|
ui->vectorTableView->resizeRowsToContents(); // Adjust the row height.
|
|
|
|
|
ui->vectorTableView->resizeColumnsToContents(); // Adjust the column width.
|
|
|
|
|
ui->vectorTableView->setColumnWidth( 0, 20 );
|
|
|
|
|
ui->vectorTableView->setColumnWidth( 1, 150 );
|
|
|
|
|
ui->vectorTableView->setColumnWidth( 2, 20 );
|
|
|
|
|
|
|
|
|
|
// init the dial element
|
|
|
|
|
lastDialValue = 0;
|
|
|
|
|
onOpenNew_dialReset();
|
|
|
|
|
|
|
|
|
|
// colorpicker initial reset
|
|
|
|
|
QImage tmpImg(1,1, QImage::Format_ARGB32);
|
|
|
|
|
actualizeGraphicsView(&tmpImg);
|
|
|
|
|
|
|
|
|
|
ui->frame->setStyleSheet("QFrame {border: 1px solid #828790;}");
|
|
|
|
|
actualColor = qRgb(255,255,255);
|
|
|
|
|
actualizeFrameColor();
|
|
|
|
|
|
|
|
|
|
imageView->resetMatrix();
|
|
|
|
|
|
|
|
|
|
// channel correction sliders
|
|
|
|
|
ui->rLabel->setStyleSheet("QLabel { background-color: red; color: white;}");
|
|
|
|
|
ui->gLabel->setStyleSheet("QLabel { background-color: green; color: white;}");
|
|
|
|
|
ui->bLabel->setStyleSheet("QLabel { background-color: blue; color: white;}");
|
|
|
|
|
|
|
|
|
|
// colour analysis button
|
|
|
|
|
for (int i = 0; i < ui->menuTools->actions().count(); i++) {
|
|
|
|
|
if (ui->menuTools->actions().at(i)->isCheckable()) {
|
|
|
|
|
ui->menuTools->actions().at(i)->setChecked(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetSlidersValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::resetSlidersValues() {
|
|
|
|
|
ui->rSlider->setValue(DEF_SLIDER_VALUE);
|
|
|
|
|
ui->gSlider->setValue(DEF_SLIDER_VALUE);
|
|
|
|
|
ui->bSlider->setValue(DEF_SLIDER_VALUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeThisProject() {
|
|
|
|
|
// project init
|
|
|
|
|
cProject::Instance()->valueInit();
|
|
|
|
|
initStageAndValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::importImage(QString &imageFileName, bool addToVector) {
|
|
|
|
|
if (imageFileName.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
if (addToVector) {
|
|
|
|
|
// add an image to project
|
|
|
|
|
cProject::Instance()->addToImages(imageFileName);
|
|
|
|
|
cProject::Instance()->setFileImported(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QImage image(imageFileName);
|
|
|
|
|
|
|
|
|
|
if (image.isNull()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
actualizeGraphicsView(&image);
|
|
|
|
|
|
|
|
|
|
// align an image to center after import
|
|
|
|
|
imageResizer(0.99999999999999);
|
|
|
|
|
imageView->resetMatrix();
|
|
|
|
|
|
|
|
|
|
onOpenNew_dialReset();
|
|
|
|
|
|
|
|
|
|
// allow functions from menu
|
|
|
|
|
menuChangeAvailability(true);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::menuChangeAvailability(bool setting, bool sliders) {
|
|
|
|
|
|
|
|
|
|
ui->imageDial->setEnabled(setting);
|
|
|
|
|
|
|
|
|
|
ui->rSlider->setEnabled(sliders);
|
|
|
|
|
ui->gSlider->setEnabled(sliders);
|
|
|
|
|
ui->bSlider->setEnabled(sliders);
|
|
|
|
|
|
|
|
|
|
ui->bitmapTableView->setEnabled(!sliders);
|
|
|
|
|
ui->vectorTableView->setEnabled(!sliders);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief = DESTRUKTOR
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief = TLACITKO EXIT
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionExit_triggered() {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::saveAskDialog() {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionHelp_triggered()
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::about(this, APPL_NAME + tr(" HELP"), tr("<p><br>Under construction.</p><p></p>"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionAbout_microAnalyzer_triggered()
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::about(this, APPL_NAME + tr(" About"),
|
|
|
|
|
QString::fromLocal8Bit("<p> </p><p><strong>microAnalyzer</strong>.</p>"
|
|
|
|
|
"<p>Author: Ing. Dominik Malcik</p>"
|
|
|
|
|
"<p>E-mail: imalcik@fit.vutbr.cz</p>"
|
|
|
|
|
"<p>Year: 2014-2016</p><p> </p>"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionOpen_Image_triggered()
|
|
|
|
|
{
|
|
|
|
|
QString imageFileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::currentPath(), "*.bmp *.png *.tif *.jpg *.jpeg");
|
|
|
|
|
|
|
|
|
|
if (importImage(imageFileName, true)) {
|
|
|
|
|
statusBar()->showMessage("Image loaded.");
|
|
|
|
|
menuChangeAvailability(true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox::critical(this, APPL_NAME + tr(" ERROR"), tr("Error: The image %1 could not be loaded.").arg(imageFileName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::onOpenNew_dialReset() {
|
|
|
|
|
ui->imageDial->setValue(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionZoom_in_25_triggered()
|
|
|
|
|
{
|
|
|
|
|
imageResizer (1.2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionZoom_out_25_triggered()
|
|
|
|
|
{
|
|
|
|
|
imageResizer (0.8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::imageResizer(double resizeCoeff)
|
|
|
|
|
{
|
|
|
|
|
imageView->scale(resizeCoeff, resizeCoeff);
|
|
|
|
|
|
|
|
|
|
QString statusMessage = " OUT -" + tr("%1").arg((1.0 - resizeCoeff) * 100) + " %";
|
|
|
|
|
if (resizeCoeff > 1.0) {
|
|
|
|
|
statusMessage = " IN +" + tr("%1").arg((resizeCoeff - 1.0) * 100) + " %";
|
|
|
|
|
}
|
|
|
|
|
statusBar()->showMessage("Zoom" + statusMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionFit_in_Window_triggered()
|
|
|
|
|
{
|
|
|
|
|
imageView->fitInView(imageView->scene()->sceneRect(), Qt::KeepAspectRatio);
|
|
|
|
|
statusBar()->showMessage("Fit in window");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_actionOriginal_Size_triggered()
|
|
|
|
|
{
|
|
|
|
|
imageView->resetMatrix();
|
|
|
|
|
statusBar()->showMessage("Original size.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief = ZMENA VELIKOSTI OBRAZKU NA ZAKLADE POHYBU DIALU
|
|
|
|
|
*/
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
void MainWindow::on_imageDial_actionTriggered(int action) {
|
|
|
|
|
double newRatio = 1.0;
|
|
|
|
|
int dialValue = ui->imageDial->value();
|
|
|
|
|
|
|
|
|
|
int difference = lastDialValue - dialValue;
|
|
|
|
|
lastDialValue = dialValue;
|
|
|
|
|
|
|
|
|
|
newRatio += ((double)(difference * (-1.0)) / 10000.0);
|
|
|
|
|
|
|
|
|
|
if (newRatio <= 1.1 && newRatio >= 0.9) {
|
|
|
|
|
imageResizer (newRatio);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::invertOpenedDialog_slot() {
|
|
|
|
|
openedNewProjDialog = !openedNewProjDialog;
|
|
|
|
|
this->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionNew_Project_triggered() {
|
|
|
|
|
ProjectWizard * pw = new ProjectWizard;
|
|
|
|
|
|
|
|
|
|
if (!openedNewProjDialog) {
|
|
|
|
|
openedNewProjDialog = true;
|
|
|
|
|
Qt::WindowFlags flags = pw->windowFlags();
|
|
|
|
|
pw->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
|
|
|
|
|
pw->show();
|
|
|
|
|
|
|
|
|
|
this->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
connect(pw, SIGNAL(accepted()), this, SLOT(openProject_slot()));
|
|
|
|
|
connect(pw, SIGNAL(rejected()), this, SLOT(invertOpenedDialog_slot()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* SLOT after accepting of the wizard
|
|
|
|
|
*/
|
|
|
|
|
void MainWindow::openProject_slot() {
|
|
|
|
|
|
|
|
|
|
invertOpenedDialog_slot();
|
|
|
|
|
|
|
|
|
|
menuChangeAvailability(true);
|
|
|
|
|
openProject(cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getProjectFileName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_Project_triggered() {
|
|
|
|
|
|
|
|
|
|
QString projectFileName = QFileDialog::getOpenFileName(this, tr("Open microAnalyzer Project"), QDir::currentPath(), "*.mapro");
|
|
|
|
|
|
|
|
|
|
if (!projectFileName.isEmpty()) {
|
|
|
|
|
openProject(projectFileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::openProject(QString projectFileName) {
|
|
|
|
|
|
|
|
|
|
// if a project file was chosen
|
|
|
|
|
if (!projectFileName.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
// close currently opened project
|
|
|
|
|
closeThisProject();
|
|
|
|
|
|
|
|
|
|
QFile projFile(projectFileName);
|
|
|
|
|
|
|
|
|
|
// set root directory of the project
|
|
|
|
|
QFileInfo fi(projFile);
|
|
|
|
|
cProject::Instance()->setProjectRootDir(fi.path());
|
|
|
|
|
|
|
|
|
|
// open file for reading
|
|
|
|
|
if(!projFile.open(QIODevice::ReadOnly)) {
|
|
|
|
|
QMessageBox::critical(0, APPL_NAME + " ERROR", projFile.errorString());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
XMLparser * xml = new XMLparser;
|
|
|
|
|
|
|
|
|
|
if (!xml->read(&projFile)) {
|
|
|
|
|
QMessageBox::critical(0, APPL_NAME + " ERROR", "Project could not be loaded!");
|
|
|
|
|
statusBar()->showMessage(tr("Error within project loading! Try again, please."), 3000);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// import bitmap layers
|
|
|
|
|
if (cProject::Instance()->getFileImported()) {
|
|
|
|
|
for (uint i = 0; i < cProject::Instance()->getImages().size(); i++) {
|
|
|
|
|
QString imageFileNameToOpen = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/" + cProject::Instance()->getImages()[i];
|
|
|
|
|
importImage(imageFileNameToOpen, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menuChangeAvailability(true);
|
|
|
|
|
|
|
|
|
|
setWindowTitle(APPL_NAME + " project - " + projectFileName);
|
|
|
|
|
statusBar()->showMessage(tr("Project loaded ..."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
projFile.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_Project_triggered() {
|
|
|
|
|
bool removeSubDirs = false;
|
|
|
|
|
saveProjectToDest(cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getProjectFileName(), removeSubDirs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_Project_As_triggered() {
|
|
|
|
|
|
|
|
|
|
QString saveFileName = QFileDialog::getSaveFileName(this, "Save file", "", "*" + Project::PROJ_FILE_EXT);
|
|
|
|
|
|
|
|
|
|
if (!saveFileName.isEmpty()) {
|
|
|
|
|
bool removeSubDirs = true;
|
|
|
|
|
saveProjectToDest(saveFileName, removeSubDirs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::saveProjectToDest(QString projectFileName_withPath, bool removeSubDirs) {
|
|
|
|
|
|
|
|
|
|
QFile projFile(projectFileName_withPath);
|
|
|
|
|
QFileInfo fi(projFile);
|
|
|
|
|
|
|
|
|
|
cProject::Instance()->prepareProject(fi.path(), fi.baseName(),
|
|
|
|
|
fi.fileName(), cProject::Instance()->getFileImported(),
|
|
|
|
|
cProject::Instance()->getImages(),
|
|
|
|
|
cProject::Instance()->getLayers());
|
|
|
|
|
|
|
|
|
|
// attempt to save + appropriate reaction
|
|
|
|
|
if (!cProject::Instance()->saveToFile(removeSubDirs)) {
|
|
|
|
|
QMessageBox::critical(0, APPL_NAME + " ERROR", "Project could not be saved!");
|
|
|
|
|
statusBar()->showMessage(tr("Error within project saving! Try again, please."), 3000);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
statusBar()->showMessage(tr("Project saved to ") + projectFileName_withPath);
|
|
|
|
|
setWindowTitle(APPL_NAME + " project - " + projectFileName_withPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::reloadImagesList() {
|
|
|
|
|
|
|
|
|
|
// show updated list/table of images
|
|
|
|
|
TableFormat * thisTable = reloadTableList(TABLE_BITMAPS);
|
|
|
|
|
bitmapLayersTBL = thisTable;
|
|
|
|
|
ui->bitmapTableView->setModel(thisTable);
|
|
|
|
|
ui->bitmapTableView->setStyleSheet("QTableView {selection-background-color: #D10000; selection-color: #FFFFFF;}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::reloadLayersList() {
|
|
|
|
|
|
|
|
|
|
// show updated list/table of images
|
|
|
|
|
TableFormat * thisTable = reloadTableList(TABLE_LAYERS);
|
|
|
|
|
vectorLayersTBL = thisTable;
|
|
|
|
|
ui->vectorTableView->setModel(thisTable);
|
|
|
|
|
ui->vectorTableView->setStyleSheet("QTableView {selection-background-color: #2D60ED; selection-color: #FFFFFF;}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TableFormat * MainWindow::reloadTableList(int tableSpec) {
|
|
|
|
|
|
|
|
|
|
QString name = "";
|
|
|
|
|
QString opacity = "100";
|
|
|
|
|
|
|
|
|
|
TableFormat * table = new TableFormat;
|
|
|
|
|
|
|
|
|
|
unsigned int size = 0;
|
|
|
|
|
if (tableSpec == TABLE_LAYERS) {
|
|
|
|
|
size = cProject::Instance()->getLayers().size();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
size = cProject::Instance()->getImages().size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = (size - 1); i >= 0; i--) {
|
|
|
|
|
|
|
|
|
|
if (tableSpec == TABLE_LAYERS) {
|
|
|
|
|
name = cProject::Instance()->getSelectedLayer(i);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
name = cProject::Instance()->getSelectedImage(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// insert row
|
|
|
|
|
table->insertRows(0, 1, QModelIndex());
|
|
|
|
|
|
|
|
|
|
// insert information to the row
|
|
|
|
|
QModelIndex index = table->index(0, 0, QModelIndex());
|
|
|
|
|
table->setData(index, QVariant(Qt::Checked), Qt::CheckStateRole);
|
|
|
|
|
|
|
|
|
|
index = table->index(0, 1, QModelIndex());
|
|
|
|
|
table->setData(index, name, Qt::EditRole);
|
|
|
|
|
|
|
|
|
|
index = table->index(0, 2, QModelIndex());
|
|
|
|
|
table->setData(index, opacity, Qt::EditRole);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_bitmapTableView_activated(QModelIndex index)
|
|
|
|
|
{
|
|
|
|
|
std::vector<int> selectedIndexes = getImportedIndexes();
|
|
|
|
|
if (selectedIndexes.size() > 0) {
|
|
|
|
|
|
|
|
|
|
QString imageName = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/";
|
|
|
|
|
// !!!!! MAGIC 0 > we are allowing only one layer !!
|
|
|
|
|
imageName += cProject::Instance()->getSelectedImage (selectedIndexes[0]);
|
|
|
|
|
|
|
|
|
|
// load image
|
|
|
|
|
QImage image(imageName);
|
|
|
|
|
actualizeGraphicsView(&image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<int> MainWindow::getImportedIndexes () {
|
|
|
|
|
QModelIndexList indexes = ui->bitmapTableView->selectionModel()->selectedRows(1);
|
|
|
|
|
|
|
|
|
|
return getSelectedIndexes(indexes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<int> MainWindow::getAnalysingIndexes () {
|
|
|
|
|
QModelIndexList indexes = ui->vectorTableView->selectionModel()->selectedRows(1);
|
|
|
|
|
|
|
|
|
|
return getSelectedIndexes(indexes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int> MainWindow::getSelectedIndexes (QModelIndexList indexes) {
|
|
|
|
|
std::vector<int> selectedIndexes;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < indexes.count(); ++i) {
|
|
|
|
|
QModelIndex index = indexes.at(i);
|
|
|
|
|
selectedIndexes.push_back(index.row());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return selectedIndexes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionClose_Project_Image_triggered()
|
|
|
|
|
{
|
|
|
|
|
switch( QMessageBox::question(
|
|
|
|
|
this,
|
|
|
|
|
APPL_NAME + tr(" Close project?"),
|
|
|
|
|
tr("Do you really want to close this project?"),
|
|
|
|
|
|
|
|
|
|
QMessageBox::Yes |
|
|
|
|
|
QMessageBox::Cancel,
|
|
|
|
|
|
|
|
|
|
QMessageBox::Cancel ) )
|
|
|
|
|
{
|
|
|
|
|
case QMessageBox::Yes: {
|
|
|
|
|
closeThisProject();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::Cancel: {
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionAnalyze_edges_triggered()
|
|
|
|
|
{
|
|
|
|
|
if (cProject::Instance()->getImages().size() > 0) {
|
|
|
|
|
|
|
|
|
|
std::vector<int> selectedIdx = getImportedIndexes();
|
|
|
|
|
if (!(selectedIdx.size() > 0)) {
|
|
|
|
|
QMessageBox::information(this, APPL_NAME + " No bitmap layer selected.", tr("Please select a BACKGROUND layer in the left tools panel."
|
|
|
|
|
" Click on the demanded layer and try again."));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QString fileName = cProject::Instance()->getImages()[ selectedIdx[0] ];
|
|
|
|
|
QString test = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/" + fileName;
|
|
|
|
|
QImage imgToAnalyze( test );
|
|
|
|
|
|
|
|
|
|
if (imgToAnalyze.isNull()) {
|
|
|
|
|
QMessageBox::critical(this, APPL_NAME + " ERROR", "Bad file name or out of memory limit - shrink the image resolution please!\n\n" + test);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
// ram limit !!!
|
|
|
|
|
if ( (imgToAnalyze.width() / 1000) * (imgToAnalyze.height() / 1000) <= 75) {
|
|
|
|
|
|
|
|
|
|
OpenCVprocessor * openCVproc = new OpenCVprocessor();
|
|
|
|
|
int resultDialog = getIntDialog();
|
|
|
|
|
bool edgeSearch = true;
|
|
|
|
|
if (resultDialog >= 0) {
|
|
|
|
|
QImage result = openCVproc->processThreshold_Edges(&imgToAnalyze, edgeSearch, resultDialog);
|
|
|
|
|
|
|
|
|
|
// ---------------- SAVE
|
|
|
|
|
int number = cProject::Instance()->layersCount();
|
|
|
|
|
QString dstDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getLayersDir() + "/";
|
|
|
|
|
QString ext = ".png";
|
|
|
|
|
QString addition = "_E";
|
|
|
|
|
QString destFileName = saveAnalysingImageToDir(fileName, dstDir, ext, addition, number);
|
|
|
|
|
|
|
|
|
|
result.save(dstDir + destFileName, "PNG");
|
|
|
|
|
cProject::Instance()->addToLayers(destFileName);
|
|
|
|
|
|
|
|
|
|
// autoSave
|
|
|
|
|
on_actionSave_Project_triggered();
|
|
|
|
|
// ---------------- // SAVE
|
|
|
|
|
|
|
|
|
|
// show saved image
|
|
|
|
|
actualizeGraphicsView(&result);
|
|
|
|
|
|
|
|
|
|
statusBar()->showMessage(tr("Edges found ..."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox::critical(this, APPL_NAME + " TOO BIG IMAGE", "The selected image is too big, please shrink resolution. Max. total amount of pixels is 75 mil (for example 10000 x 7500).");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionHough_triggered() {
|
|
|
|
|
makeCvFunction(2, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionThreshold_triggered() {
|
|
|
|
|
int resultDialog = getIntDialog();
|
|
|
|
|
if (resultDialog >= 0) {
|
|
|
|
|
makeCvFunction(1, resultDialog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::makeCvFunction(int number, int param = 0) {
|
|
|
|
|
|
|
|
|
|
std::vector<int> selectedIdx = getImportedIndexes();
|
|
|
|
|
|
|
|
|
|
QString fileName = cProject::Instance()->getImages()[selectedIdx[0]];
|
|
|
|
|
QImage imgToAnalyze(cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/" + fileName);
|
|
|
|
|
|
|
|
|
|
OpenCVprocessor * openCVproc = new OpenCVprocessor();
|
|
|
|
|
|
|
|
|
|
QImage result;
|
|
|
|
|
QString suffix = "";
|
|
|
|
|
switch(number) {
|
|
|
|
|
case 0: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
statusBar()->showMessage(tr("Threshold found ..."));
|
|
|
|
|
bool edgeSearch = false;
|
|
|
|
|
result = openCVproc->processThreshold_Edges(&imgToAnalyze, edgeSearch, param);
|
|
|
|
|
suffix = "TH";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
statusBar()->showMessage(tr("Hough proceded ..."));
|
|
|
|
|
bool edgeSearch = true;
|
|
|
|
|
result = openCVproc->processThreshold_Edges(&imgToAnalyze, edgeSearch, param);
|
|
|
|
|
suffix = "H";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QFileInfo fi(fileName);
|
|
|
|
|
QString newPngFile = fi.baseName() + suffix + ".png";
|
|
|
|
|
result.save(cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/" + newPngFile, "PNG");
|
|
|
|
|
|
|
|
|
|
cProject::Instance()->addToImages(newPngFile);
|
|
|
|
|
|
|
|
|
|
actualizeGraphicsView(&result);
|
|
|
|
|
|
|
|
|
|
// autoSave
|
|
|
|
|
on_actionSave_Project_triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int MainWindow::getIntDialog() {
|
|
|
|
|
bool ok;
|
|
|
|
|
int i = QInputDialog::getInt(this, tr("QInputDialog::getInteger()"),
|
|
|
|
|
tr("Threshold value"), 100, 0, 255, 1, &ok);
|
|
|
|
|
if (ok) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
|
|
|
|
|
|
|
|
|
if (!openedNewProjDialog && saveAskDialog()) {
|
|
|
|
|
// close window
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// push cancel - does not close the window
|
|
|
|
|
event->ignore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_2_clicked() {
|
|
|
|
|
|
|
|
|
|
LayerComposer * composer = new LayerComposer();
|
|
|
|
|
|
|
|
|
|
importedIndexes = getImportedIndexes();
|
|
|
|
|
analysingIndexes = getAnalysingIndexes();
|
|
|
|
|
|
|
|
|
|
if (importedIndexes.size() > 0 && analysingIndexes.size() > 0) {
|
|
|
|
|
|
|
|
|
|
// merging of selected layers
|
|
|
|
|
QString bgRootDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/";
|
|
|
|
|
QString overlayRootDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getLayersDir() + "/";
|
|
|
|
|
QImage result = composer->composeLayers(cProject::Instance()->getImages(),
|
|
|
|
|
cProject::Instance()->getLayers(),
|
|
|
|
|
importedIndexes, analysingIndexes,
|
|
|
|
|
bgRootDir, overlayRootDir);
|
|
|
|
|
|
|
|
|
|
actualizeGraphicsView(&result);
|
|
|
|
|
|
|
|
|
|
statusBar()->showMessage("Layers merged ...");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
statusBar()->showMessage("Layers NOT merged, select layers to merge first, please.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_clicked() {
|
|
|
|
|
LayerComposer * composer = new LayerComposer();
|
|
|
|
|
|
|
|
|
|
analysingIndexes = getAnalysingIndexes();
|
|
|
|
|
|
|
|
|
|
if (analysingIndexes.size() > 0) {
|
|
|
|
|
|
|
|
|
|
std::vector<int> bgVector;
|
|
|
|
|
bgVector.push_back(analysingIndexes[0]); // !!!!!!! 0 v indexu
|
|
|
|
|
|
|
|
|
|
std::vector<int> analysingVector;
|
|
|
|
|
for (unsigned int i = 1; i < analysingIndexes.size(); i++) {
|
|
|
|
|
analysingVector.push_back(analysingIndexes[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// merging of selected layers
|
|
|
|
|
QString bgRootDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getLayersDir() + "/";
|
|
|
|
|
QString overlayRootDir = bgRootDir;
|
|
|
|
|
QImage result = composer->composeLayers(cProject::Instance()->getLayers(),
|
|
|
|
|
cProject::Instance()->getLayers(),
|
|
|
|
|
bgVector, analysingVector, bgRootDir, overlayRootDir);
|
|
|
|
|
|
|
|
|
|
actualizeGraphicsView(&result);
|
|
|
|
|
|
|
|
|
|
statusBar()->showMessage("Layers merged ...");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
statusBar()->showMessage("Layers NOT merged, select layers to merge first, please.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionAnalyze_Colors_triggered() {
|
|
|
|
|
|
|
|
|
|
bool setting = ui->imageDial->isEnabled();
|
|
|
|
|
bool sliders = !(ui->rSlider->isEnabled());
|
|
|
|
|
|
|
|
|
|
menuChangeAvailability(setting, sliders);
|
|
|
|
|
|
|
|
|
|
if (sliders) {
|
|
|
|
|
makeColorAnalyzeStep();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QString bgImageFileName = cProject::Instance()->getSelectedImage(importedIndexes[0]); // !!!!!! 0
|
|
|
|
|
|
|
|
|
|
switch( QMessageBox::question(
|
|
|
|
|
this,
|
|
|
|
|
APPL_NAME + tr(" Save this layer?"),
|
|
|
|
|
tr("<p>Would you like to save this layer?</p><p>Choose <b>Yes to proceed</b>, <b>No to abort</b>.</p>"),
|
|
|
|
|
|
|
|
|
|
QMessageBox::Yes |
|
|
|
|
|
QMessageBox::No,
|
|
|
|
|
|
|
|
|
|
QMessageBox::Yes ) )
|
|
|
|
|
{
|
|
|
|
|
case QMessageBox::Yes: {
|
|
|
|
|
// ---------------- SAVE
|
|
|
|
|
int number = cProject::Instance()->layersCount();
|
|
|
|
|
QString dstDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getLayersDir() + "/";
|
|
|
|
|
QString ext = ".png";
|
|
|
|
|
QString addition = "_C";
|
|
|
|
|
QString destFileName = saveAnalysingImageToDir(bgImageFileName, dstDir, ext, addition, number);
|
|
|
|
|
|
|
|
|
|
visibleImage.save(dstDir + destFileName, "PNG");
|
|
|
|
|
cProject::Instance()->addToLayers(destFileName);
|
|
|
|
|
|
|
|
|
|
// autoSave
|
|
|
|
|
on_actionSave_Project_triggered();
|
|
|
|
|
// ---------------- // SAVE
|
|
|
|
|
|
|
|
|
|
statusBar()->showMessage("Layer SAVED ...");
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::No: {
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
QString srcDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/";
|
|
|
|
|
QImage image(srcDir + bgImageFileName);
|
|
|
|
|
if (!(image.isNull())) {
|
|
|
|
|
actualizeGraphicsView(&image);
|
|
|
|
|
}
|
|
|
|
|
statusBar()->showMessage("Layer saving aborted ...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetSlidersValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_rSlider_valueChanged(int value) {
|
|
|
|
|
if (ui->rSlider->isEnabled()) {
|
|
|
|
|
makeColorAnalyzeStep();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_gSlider_valueChanged(int value) {
|
|
|
|
|
if (ui->gSlider->isEnabled()) {
|
|
|
|
|
makeColorAnalyzeStep();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_bSlider_valueChanged(int value) {
|
|
|
|
|
if (ui->bSlider->isEnabled()) {
|
|
|
|
|
makeColorAnalyzeStep();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::makeColorAnalyzeStep () {
|
|
|
|
|
|
|
|
|
|
importedIndexes = getImportedIndexes();
|
|
|
|
|
if (importedIndexes.size() > 0) {
|
|
|
|
|
|
|
|
|
|
QString bgRootDir = cProject::Instance()->getProjectRootDir() + "/" + cProject::Instance()->getImagesDir() + "/";
|
|
|
|
|
QString bgImageFileName = cProject::Instance()->getSelectedImage(importedIndexes[0]); // !!!!!! 0
|
|
|
|
|
QRgb maskColor = actualColor;
|
|
|
|
|
|
|
|
|
|
LayerComposer * composer = new LayerComposer();
|
|
|
|
|
visibleImage = composer->maskSelectedLayer(bgImageFileName, bgRootDir, maskColor, ui->rSlider->value(), ui->gSlider->value(), ui->bSlider->value());
|
|
|
|
|
|
|
|
|
|
actualizeGraphicsView(&visibleImage);
|
|
|
|
|
|
|
|
|
|
statusBar()->showMessage("Layer processed ...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::graphicsClicked(int xPos, int yPos) {
|
|
|
|
|
|
|
|
|
|
if (!(ui->rSlider->isEnabled())) {
|
|
|
|
|
|
|
|
|
|
// find coordinates of the cursor position
|
|
|
|
|
QPointF point = imageView->mapToScene(xPos, yPos);
|
|
|
|
|
|
|
|
|
|
actualColor = visibleImage.pixel(point.x(), point.y());
|
|
|
|
|
actualizeFrameColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::actualizeFrameColor() {
|
|
|
|
|
|
|
|
|
|
QPalette palette = ui->frame->palette();
|
|
|
|
|
palette.setColor( backgroundRole(), actualColor);
|
|
|
|
|
|
|
|
|
|
ui->frame->setPalette(palette);
|
|
|
|
|
ui->frame->setAutoFillBackground(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::actualizeGraphicsView(QImage * toShow) {
|
|
|
|
|
QPixmapCache::clear();
|
|
|
|
|
QPixmap pm = QPixmap::fromImage(*toShow);
|
|
|
|
|
QPixmapCache::insert("loadedImage", pm);
|
|
|
|
|
|
|
|
|
|
// show result
|
|
|
|
|
visibleImage = *toShow;
|
|
|
|
|
QGraphicsScene * thisScene = new QGraphicsScene;
|
|
|
|
|
thisScene->addPixmap(pm);
|
|
|
|
|
|
|
|
|
|
if (histogramBtn) {
|
|
|
|
|
// DOES NOT WORK YET
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
imageView->setScene(thisScene);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString MainWindow::saveAnalysingImageToDir(QString origFN, QString dstDir, QString ext, QString addition, int number) {
|
|
|
|
|
|
|
|
|
|
QFileInfo fi(origFN);
|
|
|
|
|
|
|
|
|
|
QString newExt = ext;
|
|
|
|
|
QString newPngFile = fi.baseName() + addition;
|
|
|
|
|
QString numStr = QString::number(number);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
QFile destFile(dstDir + newPngFile + numStr + newExt);
|
|
|
|
|
|
|
|
|
|
if (!destFile.exists()) {
|
|
|
|
|
newPngFile = newPngFile + numStr + newExt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
number++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
numStr = QString::number(number);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return newPngFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::deleteDialog(QString layerType) {
|
|
|
|
|
switch( QMessageBox::question(
|
|
|
|
|
this,
|
|
|
|
|
APPL_NAME + tr(" Delete selected layers?"),
|
|
|
|
|
tr("<p>Do you really want to permanently remove selected ") + layerType + tr(" layers.</p>"),
|
|
|
|
|
|
|
|
|
|
QMessageBox::Yes |
|
|
|
|
|
QMessageBox::No,
|
|
|
|
|
|
|
|
|
|
QMessageBox::No ) )
|
|
|
|
|
{
|
|
|
|
|
case QMessageBox::Yes: {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::No: {
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// delete analysing
|
|
|
|
|
void MainWindow::on_pushButton_3_clicked() {
|
|
|
|
|
QString layerType = "ANALYSING";
|
|
|
|
|
|
|
|
|
|
if (deleteDialog(layerType)) {
|
|
|
|
|
analysingIndexes = getAnalysingIndexes();
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < analysingIndexes.size(); i++) {
|
|
|
|
|
cProject::Instance()->deleteAnalysing(analysingIndexes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cProject::Instance()->emitDeleteAnalysings();
|
|
|
|
|
|
|
|
|
|
// autoSave
|
|
|
|
|
on_actionSave_Project_triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// delete imported
|
|
|
|
|
void MainWindow::on_pushButton_4_clicked() {
|
|
|
|
|
QString layerType = "BACKGROUND";
|
|
|
|
|
|
|
|
|
|
if (deleteDialog(layerType)) {
|
|
|
|
|
importedIndexes = getImportedIndexes();
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < importedIndexes.size(); i++) {
|
|
|
|
|
cProject::Instance()->deleteImported(importedIndexes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cProject::Instance()->emitDeleteImported();
|
|
|
|
|
|
|
|
|
|
// autoSave
|
|
|
|
|
on_actionSave_Project_triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionHistogram_triggered() {
|
|
|
|
|
histogramBtn = !histogramBtn;
|
|
|
|
|
}
|