valentina/src/app/puzzle/vpmainwindow.cpp

1540 lines
56 KiB
C++
Raw Normal View History

2020-02-16 17:17:50 +01:00
/************************************************************************
**
2020-05-23 14:17:20 +02:00
** @file vpmainwindow.cpp
2020-02-16 17:17:50 +01:00
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
2020-05-23 14:17:20 +02:00
#include "vpmainwindow.h"
2020-04-18 16:32:54 +02:00
#include <QFileDialog>
2020-05-23 13:49:38 +02:00
#include <QCloseEvent>
2020-11-14 10:20:02 +01:00
#include <QtMath>
#include <QSvgGenerator>
2020-04-18 16:32:54 +02:00
2020-05-23 14:17:20 +02:00
#include "ui_vpmainwindow.h"
2020-05-23 13:49:38 +02:00
#include "dialogs/vpdialogabout.h"
2020-05-23 14:02:39 +02:00
#include "xml/vplayoutfilewriter.h"
2020-05-23 14:01:03 +02:00
#include "xml/vplayoutfilereader.h"
2020-05-23 14:10:05 +02:00
#include "vpapplication.h"
#include "../vlayout/vrawlayout.h"
#include "../vmisc/vsysexits.h"
#include "../vmisc/projectversion.h"
#include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/exception/vexception.h"
2020-11-14 10:55:57 +01:00
#include "../vwidgets/vmaingraphicsscene.h"
#include "vpsheet.h"
2020-04-19 16:01:46 +02:00
#include <QLoggingCategory>
2020-04-19 16:01:46 +02:00
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pWindow, "p.window")
QT_WARNING_POP
2020-02-16 17:17:50 +01:00
2020-02-16 18:18:39 +01:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:48:31 +02:00
VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
2020-02-16 17:17:50 +01:00
QMainWindow(parent),
2020-05-23 14:17:20 +02:00
ui(new Ui::VPMainWindow),
m_cmd(cmd)
2020-02-16 17:17:50 +01:00
{
2020-05-23 15:34:11 +02:00
m_layout = new VPLayout();
2020-04-26 12:09:28 +02:00
// create a standard sheet
VPSheet *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet 1"));
m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet();
2020-04-26 12:09:28 +02:00
// ----- for test purposes, to be removed------------------
2020-06-25 16:59:48 +02:00
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
sheet->SetSheetSizeConverted(84.1, 118.9);
sheet->SetPiecesGapConverted(1);
2020-04-19 11:58:43 +02:00
m_layout->SetUnit(Unit::Cm);
2020-04-19 12:47:38 +02:00
m_layout->SetWarningSuperpositionOfPieces(true);
m_layout->SetTitle(QString("My Test Layout"));
m_layout->SetDescription(QString("Description of my Layout"));
2020-11-14 15:58:42 +01:00
m_layout->SetTilesSizeConverted(21,29.7);
m_layout->SetTilesOrientation(PageOrientation::Portrait);
m_layout->SetTilesMarginsConverted(1,1,1,1);
// m_layout->SetShowTiles(true);
2020-11-14 15:58:42 +01:00
// --------------------------------------------------------
ui->setupUi(this);
// init the tile factory
m_tileFactory = new VPTileFactory(m_layout, qApp->Settings());
m_tileFactory->refreshTileInfos();
2020-11-20 15:51:24 +01:00
InitMenuBar();
InitProperties();
InitCarrousel();
2020-05-05 07:44:20 +02:00
InitMainGraphics();
2020-11-14 10:20:02 +01:00
InitZoomToolBar();
2020-04-19 11:58:43 +02:00
SetPropertiesData();
ReadSettings();
2020-02-16 17:17:50 +01:00
}
2020-02-16 18:18:39 +01:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
VPMainWindow::~VPMainWindow()
2020-02-16 17:17:50 +01:00
{
delete ui;
2020-05-23 14:29:18 +02:00
delete m_carrousel;
2020-02-16 17:17:50 +01:00
}
2020-02-16 18:18:39 +01:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
bool VPMainWindow::LoadFile(QString path)
2020-02-16 18:18:39 +01:00
{
2020-05-02 09:30:53 +02:00
try
{
VLayoutConverter converter(path);
path = converter.Convert();
}
catch (VException &e)
{
qCCritical(pWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
return false;
}
2020-04-19 16:01:46 +02:00
QFile file(path);
file.open(QIODevice::ReadOnly);
2020-05-23 14:01:03 +02:00
QScopedPointer<VPLayoutFileReader> fileReader(new VPLayoutFileReader());
2020-04-19 16:01:46 +02:00
if(m_layout == nullptr)
{
2020-05-23 15:34:11 +02:00
m_layout = new VPLayout();
2020-04-19 16:01:46 +02:00
}
fileReader->ReadFile(m_layout, &file);
// TODO / FIXME : better return value and error handling
return true;
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
bool VPMainWindow::SaveFile(const QString &path)
2020-04-19 16:01:46 +02:00
{
QFile file(path);
file.open(QIODevice::WriteOnly);
2020-05-23 14:02:39 +02:00
VPLayoutFileWriter *fileWriter = new VPLayoutFileWriter();
2020-04-19 16:01:46 +02:00
fileWriter->WriteFile(m_layout, &file);
// TODO / FIXME : better return value and error handling
2020-02-16 20:51:41 +01:00
return true;
2020-02-16 18:18:39 +01:00
}
2020-04-10 21:08:29 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
{
2020-04-26 12:09:28 +02:00
VRawLayout rawLayoutReader;
2020-04-26 12:09:28 +02:00
for(auto &path : rawLayouts)
{
VRawLayoutData data;
2020-04-26 12:09:28 +02:00
if (rawLayoutReader.ReadFile(path, data))
{
2020-04-26 12:09:28 +02:00
for (int i = 0; i < data.pieces.size(); ++i)
{
VLayoutPiece rawPiece = data.pieces.at(i);
2020-04-26 15:36:20 +02:00
2020-05-02 12:17:06 +02:00
// TODO / FIXME: make a few tests, on the data to check for validity. If not
//
// If seam allowance enabled, but the path is empty — invalid.
// If seam line path not hidden, but the path is empty — invalid.
// If seam allowance is built-in, but the seam line path is empty — invalid.
2020-05-05 07:44:20 +02:00
// TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece()
2020-05-23 15:42:51 +02:00
VPPiece *piece = CreatePiece(rawPiece);
2020-05-23 15:29:57 +02:00
m_layout->GetUnplacedPieceList()->AddPiece(piece);
2020-04-26 12:09:28 +02:00
}
2020-05-23 14:29:18 +02:00
m_carrousel->Refresh();
}
else
{
qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2")
2020-04-26 12:09:28 +02:00
.arg(path, rawLayoutReader.ErrorString())));
if (m_cmd != nullptr && not m_cmd->IsGuiEnabled())
{
m_cmd->ShowHelp(V_EX_DATAERR);
}
}
}
}
2020-11-13 23:31:22 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitZoom()
{
m_graphicsView->ZoomFitBest();
}
2020-04-26 12:09:28 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 15:42:51 +02:00
VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
2020-04-26 12:09:28 +02:00
{
2020-06-25 14:17:31 +02:00
VPPiece *piece = new VPPiece(rawPiece);
2020-04-26 12:09:28 +02:00
2020-06-25 14:17:31 +02:00
// cutting line : GetMappedSeamAllowancePoints();
// seamline : GetMappedContourPoints();
// rawPiece.IsGrainlineEnabled() , GrainlineAngle , GetGrainline
2020-04-26 12:09:28 +02:00
// TODO : set all the information we need for the piece!
2020-05-05 17:40:36 +02:00
//
2020-05-23 15:42:51 +02:00
connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged);
connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged);
connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged);
2020-05-05 17:40:36 +02:00
2020-04-26 12:09:28 +02:00
return piece;
}
2020-04-10 21:08:29 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::InitMenuBar()
2020-04-10 21:08:29 +02:00
{
// most of the actions are connected through name convention (auto-connection)
2020-04-13 12:24:26 +02:00
// -------------------- connects the actions for the file menu
2020-05-23 14:17:20 +02:00
connect(ui->actionExit, &QAction::triggered, this, &VPMainWindow::close);
2020-04-10 21:08:29 +02:00
2020-04-13 12:24:26 +02:00
// -------------------- connects the actions for the edit menu
2020-04-10 21:08:29 +02:00
// TODO : initialise the undo / redo
2020-04-13 12:24:26 +02:00
// -------------------- connects the actions for the windows menu
2020-04-10 21:08:29 +02:00
// TODO : initialise the entries for the different windows
2020-04-13 12:24:26 +02:00
// Add dock properties action
QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction();
ui->menuWindows->addAction(actionDockWidgetToolOptions);
2020-04-10 21:08:29 +02:00
}
2020-04-11 11:17:53 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::InitProperties()
2020-04-11 11:17:53 +02:00
{
2020-04-11 16:25:23 +02:00
InitPropertyTabCurrentPiece();
2020-11-11 19:31:39 +01:00
InitPropertyTabCurrentSheet();
2020-04-11 16:25:23 +02:00
InitPropertyTabLayout();
InitPropertyTabTiles();
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::InitPropertyTabCurrentPiece()
2020-04-11 16:25:23 +02:00
{
2020-11-11 19:31:39 +01:00
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
ui->groupBoxLayoutControl->hide();
ui->groupBoxCurrentPieceGeometry->hide();
// ------------------------------ placement -----------------------------------
connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-05-23 14:17:20 +02:00
&VPMainWindow::on_CurrentPiecePositionEdited);
connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-05-23 14:17:20 +02:00
&VPMainWindow::on_CurrentPiecePositionEdited);
2020-04-11 11:17:53 +02:00
}
2020-11-11 19:31:39 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPropertyTabCurrentSheet()
{
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
ui->pushButtonSheetRemoveUnusedLength->hide();
ui->groupBoxSheetControl->hide();
2020-04-11 16:25:23 +02:00
// some of the UI Elements are connected to the slots via auto-connect
// see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect
2020-04-11 16:25:23 +02:00
// -------------------- layout width, length, orientation ------------------------
connect(ui->doubleSpinBoxSheetWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetSizeChanged);
connect(ui->doubleSpinBoxSheetLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetSizeChanged);
connect(ui->radioButtonSheetPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetOrientationChanged);
connect(ui->radioButtonSheetLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetOrientationChanged);
2020-04-11 16:25:23 +02:00
// -------------------- margins ------------------------
connect(ui->doubleSpinBoxSheetMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
2020-04-11 16:25:23 +02:00
// ------------------- follow grainline -----------------------
connect(ui->radioButtonSheetFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
2020-04-11 16:25:23 +02:00
2020-11-20 15:51:24 +01:00
// -------------------- sheet template ---------------------------
// FIXME: find a nicer way to initiliase it
QVector<PaperSizeTemplate> sheetTemplates = QVector<PaperSizeTemplate>();
sheetTemplates.append(PaperSizeTemplate::A0);
sheetTemplates.append(PaperSizeTemplate::A1);
sheetTemplates.append(PaperSizeTemplate::A2);
sheetTemplates.append(PaperSizeTemplate::A3);
sheetTemplates.append(PaperSizeTemplate::A4);
sheetTemplates.append(PaperSizeTemplate::Letter);
sheetTemplates.append(PaperSizeTemplate::Legal);
sheetTemplates.append(PaperSizeTemplate::Tabloid);
sheetTemplates.append(PaperSizeTemplate::Roll24in);
sheetTemplates.append(PaperSizeTemplate::Roll30in);
sheetTemplates.append(PaperSizeTemplate::Roll36in);
sheetTemplates.append(PaperSizeTemplate::Roll42in);
sheetTemplates.append(PaperSizeTemplate::Roll44in);
sheetTemplates.append(PaperSizeTemplate::Roll48in);
sheetTemplates.append(PaperSizeTemplate::Roll62in);
sheetTemplates.append(PaperSizeTemplate::Roll72in);
sheetTemplates.append(PaperSizeTemplate::Custom);
ui->comboBoxSheetTemplate->blockSignals(true);
VPSheet::PopulateComboBox(&sheetTemplates, ui->comboBoxSheetTemplate);
ui->comboBoxSheetTemplate->blockSignals(false);
ui->comboBoxSheetTemplate->setCurrentIndex(0);
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::InitPropertyTabTiles()
2020-04-11 16:25:23 +02:00
{
2020-11-14 15:58:42 +01:00
// -------------------- layout width, length, orientation ------------------------
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesSizeChanged);
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesSizeChanged);
2020-11-14 17:31:34 +01:00
connect(ui->radioButtonTilesPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesOrientationChanged);
2020-11-14 17:31:34 +01:00
connect(ui->radioButtonTilesLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesOrientationChanged);
2020-11-20 15:51:24 +01:00
// -------------------- tiles template
QVector<PaperSizeTemplate> tilesTemplates = QVector<PaperSizeTemplate>();
tilesTemplates.append(PaperSizeTemplate::A0);
tilesTemplates.append(PaperSizeTemplate::A1);
tilesTemplates.append(PaperSizeTemplate::A2);
tilesTemplates.append(PaperSizeTemplate::A3);
tilesTemplates.append(PaperSizeTemplate::A4);
tilesTemplates.append(PaperSizeTemplate::Letter);
tilesTemplates.append(PaperSizeTemplate::Legal);
tilesTemplates.append(PaperSizeTemplate::Custom);
ui->comboBoxTilesTemplate->blockSignals(true);
VPSheet::PopulateComboBox(&tilesTemplates, ui->comboBoxTilesTemplate);
ui->comboBoxTilesTemplate->blockSignals(false);
ui->comboBoxTilesTemplate->setCurrentIndex(4); //A4
2020-11-14 15:58:42 +01:00
// -------------------- margins ------------------------
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesMarginChanged);
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesMarginChanged);
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesMarginChanged);
2020-11-14 17:31:34 +01:00
connect(ui->doubleSpinBoxTilesMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
2020-11-14 15:58:42 +01:00
&VPMainWindow::on_TilesMarginChanged);
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPropertyTabLayout()
{
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
ui->groupBoxLayoutControl->hide();
// -------------------- init the unit combobox ---------------------
ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch)));
// set default unit - TODO when we have the setting for the unit
// const qint32 indexUnit = -1;//ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit());
// if (indexUnit != -1)
// {
// ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit);
// }
2020-04-11 16:25:23 +02:00
}
2020-04-13 12:24:26 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:29:18 +02:00
void VPMainWindow::InitCarrousel()
2020-04-13 12:24:26 +02:00
{
2020-05-23 14:29:18 +02:00
m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
ui->dockWidgetCarrousel->setWidget(m_carrousel);
2020-04-13 12:24:26 +02:00
2020-05-23 14:29:18 +02:00
connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
&VPMainWindow::on_CarrouselLocationChanged);
2020-04-13 12:24:26 +02:00
}
2020-04-19 11:58:43 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::SetPropertiesData()
2020-04-19 11:58:43 +02:00
{
if(m_layout == nullptr)
{
// TODO : hide the tabs when there is no layout
}
else
{
SetPropertyTabCurrentPieceData();
SetPropertyTabSheetData();
2020-04-19 11:58:43 +02:00
SetPropertyTabTilesData();
SetPropertyTabLayoutData();
2020-04-19 11:58:43 +02:00
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::SetPropertyTabCurrentPieceData()
2020-04-19 11:58:43 +02:00
{
2020-05-05 17:40:36 +02:00
if(m_selectedPieces.count() == 0)
2020-04-19 11:58:43 +02:00
{
// show the content "no piece selected"
2020-05-05 17:40:36 +02:00
ui->containerCurrentPieceNoData->setVisible(true);
ui->containerCurrentPieceData->setVisible(false);
ui->containerCurrentPieceMultipleData->setVisible(false);
2020-04-19 11:58:43 +02:00
}
2020-05-05 17:40:36 +02:00
else if(m_selectedPieces.count() == 1)
2020-04-19 11:58:43 +02:00
{
// show the content "selected piece data"
2020-05-01 19:08:48 +02:00
ui->containerCurrentPieceNoData->setVisible(false);
ui->containerCurrentPieceData->setVisible(true);
ui->containerCurrentPieceMultipleData->setVisible(false);
2020-05-23 15:42:51 +02:00
VPPiece *selectedPiece = m_selectedPieces.first();
2020-05-01 19:08:48 +02:00
// set the value to the current piece
2020-05-05 17:40:36 +02:00
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
2020-11-10 20:55:39 +01:00
ui->plainTextEditCurrentPieceUUID->setPlainText(selectedPiece->GetUUID().toString());
2020-05-05 17:40:36 +02:00
ui->checkBoxCurrentPieceShowSeamline->setChecked(selectedPiece->GetShowSeamLine());
ui->checkBoxCurrentPieceMirrorPiece->setChecked(selectedPiece->GetPieceMirrored());
2020-05-01 19:08:48 +02:00
2020-05-05 17:40:36 +02:00
QPointF pos = selectedPiece->GetPosition();
2020-05-11 16:44:30 +02:00
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
2020-05-05 17:40:36 +02:00
2020-05-09 11:13:29 +02:00
qreal angle = selectedPiece->GetRotation();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);
2020-05-05 17:40:36 +02:00
}
else
{
// show the content "multiple pieces selected"
ui->containerCurrentPieceNoData->setVisible(false);
ui->containerCurrentPieceData->setVisible(false);
ui->containerCurrentPieceMultipleData->setVisible(true);
// if needed in the future, we can show some properties that coul be edited for all the pieces
2020-04-19 11:58:43 +02:00
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabSheetData()
2020-04-19 11:58:43 +02:00
{
2020-05-24 19:53:51 +02:00
// set name // TODO FIXME make it better
ui->lineEditSheetName->setText(m_layout->GetFocusedSheet()->GetName());
2020-04-19 11:58:43 +02:00
// set Width / Length
QSizeF size = m_layout->GetFocusedSheet()->GetSheetSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, size.height());
2020-04-19 11:58:43 +02:00
2020-04-19 12:47:38 +02:00
// Set Orientation
2020-11-14 15:58:42 +01:00
if(m_layout->GetFocusedSheet()->GetOrientation() == PageOrientation::Portrait)
2020-04-19 12:47:38 +02:00
{
ui->radioButtonSheetPortrait->setChecked(true);
2020-04-19 12:47:38 +02:00
}
else
{
ui->radioButtonSheetLandscape->setChecked(true);
2020-04-19 12:47:38 +02:00
}
2020-04-19 11:58:43 +02:00
// set margins
QMarginsF margins = m_layout->GetFocusedSheet()->GetSheetMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom());
2020-04-19 11:58:43 +02:00
2021-03-14 14:40:56 +01:00
// set placement grid
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, m_layout->GetFocusedSheet()->GetGridColWidthConverted());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, m_layout->GetFocusedSheet()->GetGridRowHeightConverted());
SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->GetFocusedSheet()->GetShowGrid());
2020-04-19 11:58:43 +02:00
// set pieces gap
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->GetFocusedSheet()->GetPiecesGapConverted());
2020-04-19 12:47:38 +02:00
// set the checkboxes
SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->GetFocusedSheet()->GetStickyEdges());
}
2020-11-14 15:58:42 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabTilesData()
{
// set Width / Length
QSizeF size = m_layout->GetTilesSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesLength, size.height());
// Set Orientation
if(m_layout->GetTilesOrientation() == PageOrientation::Portrait)
{
ui->radioButtonSheetPortrait->setChecked(true);
}
else
{
ui->radioButtonSheetLandscape->setChecked(true);
}
// set margins
QMarginsF margins = m_layout->GetTilesMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginBottom, margins.bottom());
// set "show tiles" checkbox
2020-11-15 12:30:29 +01:00
SetCheckBoxValue(ui->checkBoxTilesShowTiles, m_layout->GetShowTiles());
2020-11-14 15:58:42 +01:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabLayoutData()
{
2020-11-11 19:31:39 +01:00
// set the title and description
ui->lineEditLayoutName->setText(m_layout->GetTitle());
ui->plainTextEditLayoutDescription->setPlainText(m_layout->GetDescription());
// set Unit
int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit())));
if(index != -1)
{
ui->comboBoxLayoutUnit->blockSignals(true); // FIXME: is there a better way to block the signals?
ui->comboBoxLayoutUnit->setCurrentIndex(index);
ui->comboBoxLayoutUnit->blockSignals(false);
}
// set controls
2020-04-19 12:47:38 +02:00
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound());
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces());
2020-04-19 11:58:43 +02:00
}
2020-11-14 15:58:42 +01:00
2020-04-19 11:58:43 +02:00
2020-05-05 07:44:20 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::InitMainGraphics()
2020-05-05 07:44:20 +02:00
{
m_graphicsView = new VPMainGraphicsView(m_layout, m_tileFactory, this);
2020-05-05 07:44:20 +02:00
ui->centralWidget->layout()->addWidget(m_graphicsView);
m_graphicsView->RefreshLayout();
2020-11-14 10:20:02 +01:00
connect(m_graphicsView, &VPMainGraphicsView::ScaleChanged, this, &VPMainWindow::on_ScaleChanged);
2020-11-14 10:55:57 +01:00
connect(m_graphicsView->GetScene(), &VMainGraphicsScene::mouseMove, this, &VPMainWindow::on_MouseMoved);
2020-05-05 07:44:20 +02:00
}
2020-11-13 23:31:22 +01:00
//---------------------------------------------------------------------------------------------------------------------
2020-11-14 10:20:02 +01:00
void VPMainWindow::InitZoomToolBar()
2020-11-13 23:31:22 +01:00
{
2020-11-14 10:55:57 +01:00
if (not m_doubleSpinBoxScale.isNull())
{
delete m_doubleSpinBoxScale;
}
if (m_mouseCoordinate != nullptr)
{
delete m_mouseCoordinate;
}
2020-11-14 10:20:02 +01:00
// connect the zoom buttons and shortcuts to the slots
2020-11-13 23:31:22 +01:00
QList<QKeySequence> zoomInShortcuts;
zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn));
zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier));
ui->actionZoomIn->setShortcuts(zoomInShortcuts);
connect(ui->actionZoomIn, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomIn);
QList<QKeySequence> zoomOutShortcuts;
zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut));
zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier));
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
connect(ui->actionZoomOut, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOut);
QList<QKeySequence> zoomOriginalShortcuts;
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0));
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier));
ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts);
connect(ui->actionZoomOriginal, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOriginal);
QList<QKeySequence> zoomFitBestShortcuts;
zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal));
ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts);
connect(ui->actionZoomFitBest, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomFitBest);
2020-11-14 10:20:02 +01:00
// defined the scale
ui->toolBarZoom->addSeparator();
QLabel* zoomScale = new QLabel(tr("Scale:"), this);
ui->toolBarZoom->addWidget(zoomScale);
m_doubleSpinBoxScale = new QDoubleSpinBox(this);
m_doubleSpinBoxScale->setDecimals(1);
m_doubleSpinBoxScale->setSuffix("%");
on_ScaleChanged(m_graphicsView->transform().m11());
connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, [this](double d){m_graphicsView->Zoom(d/100.0);});
ui->toolBarZoom->addWidget(m_doubleSpinBoxScale);
// define the mouse position
ui->toolBarZoom->addSeparator();
m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(m_layout->GetUnit(), true)));
ui->toolBarZoom->addWidget(m_mouseCoordinate);
ui->toolBarZoom->addSeparator();
2020-11-13 23:31:22 +01:00
}
2020-04-19 11:58:43 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value)
2020-04-19 11:58:43 +02:00
{
spinBox->blockSignals(true);
spinBox->setValue(value);
spinBox->blockSignals(false);
}
2020-04-13 12:24:26 +02:00
2020-04-19 12:47:38 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
2020-04-19 12:47:38 +02:00
{
checkbox->blockSignals(true);
checkbox->setChecked(value);
checkbox->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::ReadSettings()
{
qCDebug(pWindow, "Reading settings.");
2020-05-23 15:44:44 +02:00
const VPSettings *settings = qApp->PuzzleSettings();
if (settings->status() == QSettings::NoError)
{
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive());
ui->dockWidgetPropertiesContents->setVisible(settings->IsDockWidgetPropertiesContentsActive());
// Scene antialiasing
m_graphicsView->SetAntialiasing(settings->GetGraphicalOutput());
// Stack limit
// qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
}
else
{
qWarning() << tr("Cannot read settings from a malformed .INI file.");
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::WriteSettings()
{
2020-05-23 15:44:44 +02:00
VPSettings *settings = qApp->PuzzleSettings();
settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION));
settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled());
settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled());
2020-04-19 12:47:38 +02:00
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
bool VPMainWindow::MaybeSave()
{
// TODO: Implement maybe save check
// if (this->isWindowModified())
// {
// if (curFile.isEmpty() && ui->tableWidget->rowCount() == 0)
// {
// return true;// Don't ask if file was created without modifications.
// }
// QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
// tr("Measurements have been modified.\n"
// "Do you want to save your changes?"),
// QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
// QMessageBox::Cancel, this, Qt::Sheet));
// messageBox->setDefaultButton(QMessageBox::Yes);
// messageBox->setEscapeButton(QMessageBox::Cancel);
// messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || mIsReadOnly ? tr("Save…") : tr("Save"));
// messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
// messageBox->setWindowModality(Qt::ApplicationModal);
// const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
// switch (ret)
// {
// case QMessageBox::Yes:
// if (mIsReadOnly)
// {
// return FileSaveAs();
// }
// else
// {
// return FileSave();
// }
// case QMessageBox::No:
// return true;
// case QMessageBox::Cancel:
// return false;
// default:
// break;
// }
// }
return true;
}
2020-04-13 12:24:26 +02:00
2020-11-15 13:06:57 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::generateTiledPdf(QString fileName)
{
if(not fileName.isEmpty())
{
m_graphicsView->PrepareForExport();
m_tileFactory->refreshTileInfos();
2020-11-15 13:06:57 +01:00
PageOrientation tilesOrientation = m_layout->GetTilesOrientation();
// ------------- Set up the printer
2021-05-04 08:33:19 +02:00
QScopedPointer<QPrinter> printer(new QPrinter());
2020-11-15 13:06:57 +01:00
printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+
QCoreApplication::applicationVersion());
2021-05-04 08:19:04 +02:00
printer->setPageOrientation(QPageLayout::Portrait); // in the pdf file the pages should always be in portrait
2020-11-15 13:06:57 +01:00
// here we might need to so some rounding for the size.
printer->setPageSize(QPageSize(m_layout->GetTilesSize(Unit::Mm),
QPageSize::Millimeter));
printer->setFullPage(true);
#ifdef Q_OS_MAC
printer->setOutputFormat(QPrinter::NativeFormat);
#else
printer->setOutputFormat(QPrinter::PdfFormat);
#endif
printer->setOutputFileName(fileName);
printer->setResolution(static_cast<int>(PrintDPI));
2021-03-14 16:57:20 +01:00
printer->setDocName(m_layout->GetFocusedSheet()->GetName());
2020-11-15 13:06:57 +01:00
// ------------- Set up the painter
QPainter painter;
2021-05-04 08:21:34 +02:00
if (not painter.begin(printer.data()))
2020-11-15 13:06:57 +01:00
{ // failed to open file
qCritical() << tr("Failed to open file, is it writable?");
return;
}
painter.setFont( QFont( QStringLiteral("Arial"), 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setBrush ( QBrush ( Qt::NoBrush ) );
if(tilesOrientation == PageOrientation::Landscape)
{
// The landscape tiles have to be rotated, because the pages
// stay portrait in the pdf
painter.rotate(90);
painter.translate(0, -ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm));
}
for(int row=0;row<m_tileFactory->getRowNb();row++) // for each row of the tiling grid
2020-11-15 13:06:57 +01:00
{
for(int col=0;col<m_tileFactory->getColNb();col++) // for each column of tiling grid
2020-11-15 13:06:57 +01:00
{
2020-11-15 22:34:24 +01:00
if(not (row == 0 && col == 0))
2020-11-15 13:06:57 +01:00
{
if (not printer->newPage())
{
qWarning("failed in flushing page to disk, disk full?");
return;
}
}
m_tileFactory->drawTile(&painter, m_graphicsView, row, col);
2020-11-15 13:06:57 +01:00
}
}
painter.end();
m_graphicsView->CleanAfterExport();
}
}
2020-04-10 21:08:29 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionNew_triggered()
2020-04-10 21:08:29 +02:00
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
2020-05-23 14:17:20 +02:00
msgBox.setText("TODO VPMainWindow::New");
2020-04-10 21:08:29 +02:00
int ret = msgBox.exec();
2020-04-11 16:25:23 +02:00
Q_UNUSED(ret);
2020-04-10 21:08:29 +02:00
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::closeEvent(QCloseEvent *event)
{
#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1)
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
static int numCalled = 0;
if (numCalled++ >= 1)
{
return;
}
#endif
if (MaybeSave())
{
WriteSettings();
event->accept();
deleteLater();
}
else
{
event->ignore();
}
}
2020-04-10 21:08:29 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionOpen_triggered()
2020-04-10 21:08:29 +02:00
{
qCDebug(pWindow, "Openning puzzle layout file.");
2020-04-10 21:08:29 +02:00
2020-04-19 16:01:46 +02:00
const QString filter(tr("Layout files") + QLatin1String(" (*.vlt)"));
2020-04-11 16:25:23 +02:00
2020-04-19 16:01:46 +02:00
//Get list last open files
QStringList recentFiles = qApp->PuzzleSettings()->GetRecentFileList();
QString dir;
if (recentFiles.isEmpty())
{
dir = QDir::homePath();
}
else
{
//Absolute path to last open file
dir = QFileInfo(recentFiles.first()).absolutePath();
}
qCDebug(pWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
2020-04-23 20:17:49 +02:00
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr);
2020-04-19 16:01:46 +02:00
if (filePath.isEmpty())
{
return;
}
// TODO : if m_layout == nullptr, open in current window
// otherwise open in new window
// TODO : if layout file has a lock, warning message
if(!LoadFile(filePath))
{
return;
}
// Updates the list of recent files
recentFiles.removeAll(filePath);
recentFiles.prepend(filePath);
while (recentFiles.size() > MaxRecentFiles)
{
recentFiles.removeLast();
}
qApp->PuzzleSettings()->SetRecentFileList(recentFiles);
// updates the properties with the loaded data
SetPropertiesData();
// TODO : update the Carrousel and the QGraphicView
2020-04-10 21:08:29 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionSave_triggered()
2020-04-10 21:08:29 +02:00
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
2020-05-23 14:17:20 +02:00
msgBox.setText("TODO VPMainWindow::Save");
2020-04-10 21:08:29 +02:00
int ret = msgBox.exec();
2020-04-11 16:25:23 +02:00
Q_UNUSED(ret);
2020-04-10 21:08:29 +02:00
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionSaveAs_triggered()
2020-04-10 21:08:29 +02:00
{
2020-11-15 13:06:57 +01:00
// TODO / FIXME : See valentina how the save is done over there. we need to add the
// extension .vlt, check for empty file names etc.
2020-04-10 21:08:29 +02:00
2020-04-19 16:01:46 +02:00
//Get list last open files
QStringList recentFiles = qApp->PuzzleSettings()->GetRecentFileList();
QString dir;
if (recentFiles.isEmpty())
{
dir = QDir::homePath();
}
else
{
//Absolute path to last open file
dir = QFileInfo(recentFiles.first()).absolutePath();
}
2020-04-11 16:25:23 +02:00
2020-04-19 16:01:46 +02:00
QString filters(tr("Layout files") + QLatin1String("(*.vlt)"));
2020-04-18 16:32:54 +02:00
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
2020-04-19 16:01:46 +02:00
dir + QLatin1String("/") + tr("Layout") + QLatin1String(".vlt"),
2020-04-18 16:32:54 +02:00
filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
2020-04-19 16:01:46 +02:00
SaveFile(fileName);
2020-04-10 21:08:29 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionImportRawLayout_triggered()
2020-04-10 21:08:29 +02:00
{
2020-04-26 12:09:28 +02:00
// TODO: here the code is probably just bad, to be edited
2020-04-10 21:08:29 +02:00
2020-04-26 12:09:28 +02:00
QString dir;
if (true)
{
dir = QDir::homePath();
}
else
{
// TODO / FIXME get the default path for raw layouts
}
const QString filter(tr("Raw Layout files") + QLatin1String(" (*.rld)"));
qCDebug(pWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr);
QStringList rawLayouts = QStringList();
rawLayouts.append(filePath);
ImportRawLayouts(rawLayouts);
// TODO / FIXME : better error handling
2020-04-11 16:25:23 +02:00
2020-04-10 21:08:29 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionCloseLayout_triggered()
2020-04-10 21:08:29 +02:00
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
2020-05-23 14:17:20 +02:00
msgBox.setText("TODO VPMainWindow::CloseLayout");
2020-04-10 21:08:29 +02:00
int ret = msgBox.exec();
2020-04-11 16:25:23 +02:00
Q_UNUSED(ret);
2020-04-10 21:08:29 +02:00
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionAboutQt_triggered()
2020-04-10 21:08:29 +02:00
{
QMessageBox::aboutQt(this, tr("About Qt"));
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_actionAboutPuzzle_triggered()
2020-04-10 21:08:29 +02:00
{
2020-05-23 13:49:38 +02:00
auto *aboutDialog = new VPDialogAbout(this);
2020-04-11 11:40:02 +02:00
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
aboutDialog->show();
2020-04-10 21:08:29 +02:00
}
2020-04-11 16:25:23 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
2020-04-11 16:25:23 +02:00
{
Q_UNUSED(index);
2020-04-19 12:47:38 +02:00
QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData();
2020-04-11 16:25:23 +02:00
2020-04-19 12:47:38 +02:00
if(comboBoxValue == QVariant(UnitsToStr(Unit::Cm)))
{
m_layout->SetUnit(Unit::Cm);
}
else if(comboBoxValue == QVariant(UnitsToStr(Unit::Mm)))
{
m_layout->SetUnit(Unit::Mm);
}
else if(comboBoxValue == QVariant(UnitsToStr(Unit::Inch)))
{
m_layout->SetUnit(Unit::Inch);
}
2020-04-11 16:25:23 +02:00
2020-04-19 12:47:38 +02:00
SetPropertyTabCurrentPieceData();
2020-11-15 12:30:29 +01:00
SetPropertyTabSheetData();
SetPropertyTabTilesData();
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-11-21 13:45:26 +01:00
void VPMainWindow::on_lineEditSheetName_textChanged(const QString &text)
{
m_layout->GetFocusedSheet()->SetName(text);
if(m_carrousel != nullptr)
{
m_carrousel->RefreshFocusedSheetName();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
2020-04-11 16:25:23 +02:00
{
2020-11-20 15:51:24 +01:00
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(
ui->comboBoxSheetTemplate->itemData(index).toInt()
);
2020-04-11 16:25:23 +02:00
2020-11-20 15:51:24 +01:00
QSizeF tmplSize = VPSheet::GetTemplateSize(tmpl);
if(!tmplSize.isEmpty())
{
ui->doubleSpinBoxSheetWidth->blockSignals(true);
ui->doubleSpinBoxSheetLength->blockSignals(true);
2020-04-11 16:25:23 +02:00
2020-11-20 15:51:24 +01:00
ui->doubleSpinBoxSheetWidth->setValue(UnitConvertor(tmplSize.width(), Unit::Px, m_layout->GetUnit()));
ui->doubleSpinBoxSheetLength->setValue(UnitConvertor(tmplSize.height(), Unit::Px, m_layout->GetUnit()));
2020-04-11 16:25:23 +02:00
2020-11-20 15:51:24 +01:00
on_SheetSizeChanged(false);
ui->doubleSpinBoxSheetWidth->blockSignals(false);
ui->doubleSpinBoxSheetLength->blockSignals(false);
}
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-11-20 15:51:24 +01:00
void VPMainWindow::on_SheetSizeChanged(bool changedViaSizeCombobox)
2020-04-11 16:25:23 +02:00
{
m_layout->GetFocusedSheet()->SetSheetSizeConverted(
ui->doubleSpinBoxSheetWidth->value(),
ui->doubleSpinBoxSheetLength->value()
);
2020-11-20 15:51:24 +01:00
if(changedViaSizeCombobox)
{
ui->comboBoxSheetTemplate->blockSignals(true);
// we don't try to get the right size, because it doesn't work well because of mm / inch conversion
int index = ui->comboBoxSheetTemplate->findData(
QVariant(static_cast<int>(PaperSizeTemplate::Custom)));
ui->comboBoxSheetTemplate->setCurrentIndex(index);
ui->comboBoxSheetTemplate->blockSignals(false);
}
m_tileFactory->refreshTileInfos();
2020-04-11 16:25:23 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
2020-05-05 07:44:20 +02:00
m_graphicsView->RefreshLayout();
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_SheetOrientationChanged()
2020-04-11 16:25:23 +02:00
{
2020-06-25 16:59:48 +02:00
// Updates the orientation
if(ui->radioButtonSheetPortrait->isChecked())
{
m_layout->GetFocusedSheet()->SetOrientation(PageOrientation::Portrait);
}
else
{
m_layout->GetFocusedSheet()->SetOrientation(PageOrientation::Landscape);
}
m_tileFactory->refreshTileInfos();
2020-05-05 07:44:20 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
2020-05-05 07:44:20 +02:00
m_graphicsView->RefreshLayout();
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked()
2020-04-11 16:25:23 +02:00
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked");
2020-04-11 16:25:23 +02:00
int ret = msgBox.exec();
Q_UNUSED(ret);
2020-04-11 16:32:49 +02:00
// TODO
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_SheetMarginChanged()
2020-04-11 16:25:23 +02:00
{
m_layout->GetFocusedSheet()->SetSheetMarginsConverted(
ui->doubleSpinBoxSheetMarginLeft->value(),
ui->doubleSpinBoxSheetMarginTop->value(),
ui->doubleSpinBoxSheetMarginRight->value(),
ui->doubleSpinBoxSheetMarginBottom->value()
2020-04-19 12:47:38 +02:00
);
2020-04-11 16:25:23 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
2020-05-05 07:44:20 +02:00
m_graphicsView->RefreshLayout();
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_checkBoxSheetShowGrid_toggled(bool checked)
{
m_layout->GetFocusedSheet()->SetShowGrid(checked);
m_graphicsView->RefreshLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_doubleSpinBoxSheetGridColWidth_valueChanged(double value)
{
m_layout->GetFocusedSheet()->SetGridColWidthConverted(value);
m_graphicsView->RefreshLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_doubleSpinBoxSheetGridRowHeight_valueChanged(double value)
{
m_layout->GetFocusedSheet()->SetGridRowHeightConverted(value);
m_graphicsView->RefreshLayout();
}
2020-11-20 15:51:24 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_comboBoxTilesTemplate_currentIndexChanged(int index)
{
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(
ui->comboBoxTilesTemplate->itemData(index).toInt()
);
QSizeF tmplSize = VPSheet::GetTemplateSize(tmpl);
if(!tmplSize.isEmpty())
{
ui->doubleSpinBoxTilesWidth->blockSignals(true);
ui->doubleSpinBoxTilesLength->blockSignals(true);
ui->doubleSpinBoxTilesWidth->setValue(UnitConvertor(tmplSize.width(), Unit::Px, m_layout->GetUnit()));
ui->doubleSpinBoxTilesLength->setValue(UnitConvertor(tmplSize.height(), Unit::Px, m_layout->GetUnit()));
on_TilesSizeChanged(false);
ui->doubleSpinBoxTilesWidth->blockSignals(false);
ui->doubleSpinBoxTilesLength->blockSignals(false);
}
}
2020-04-11 16:25:23 +02:00
2020-11-14 15:58:42 +01:00
//---------------------------------------------------------------------------------------------------------------------
2020-11-20 15:51:24 +01:00
void VPMainWindow::on_TilesSizeChanged(bool changedViaSizeCombobox)
2020-11-14 15:58:42 +01:00
{
m_layout->SetTilesSizeConverted(ui->doubleSpinBoxTilesWidth->value(), ui->doubleSpinBoxTilesLength->value());
m_tileFactory->refreshTileInfos();
2020-11-14 15:58:42 +01:00
2020-11-20 15:51:24 +01:00
if(changedViaSizeCombobox)
{
ui->comboBoxTilesTemplate->blockSignals(true);
// we don't try to get the right size, because it doesn't work well because of mm / inch conversion
int index = ui->comboBoxTilesTemplate->findData(
QVariant(static_cast<int>(PaperSizeTemplate::Custom)));
ui->comboBoxTilesTemplate->setCurrentIndex(index);
ui->comboBoxTilesTemplate->blockSignals(false);
}
2020-11-14 15:58:42 +01:00
// TODO Undo / Redo
2020-11-20 15:51:24 +01:00
if(m_graphicsView != nullptr)
{
m_graphicsView->RefreshLayout();
}
2020-11-14 15:58:42 +01:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_TilesOrientationChanged()
{
// Updates the orientation
if(ui->radioButtonTilesPortrait->isChecked())
{
m_layout->SetTilesOrientation(PageOrientation::Portrait);
}
else
{
m_layout->SetTilesOrientation(PageOrientation::Landscape);
}
m_tileFactory->refreshTileInfos();
2020-11-14 15:58:42 +01:00
// TODO Undo / Redo
m_graphicsView->RefreshLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_TilesMarginChanged()
{
2020-11-14 17:31:34 +01:00
m_layout->SetTilesMarginsConverted(
2020-11-14 15:58:42 +01:00
ui->doubleSpinBoxTilesMarginLeft->value(),
ui->doubleSpinBoxTilesMarginTop->value(),
ui->doubleSpinBoxTilesMarginRight->value(),
ui->doubleSpinBoxTilesMarginBottom->value()
);
m_tileFactory->refreshTileInfos();
2020-11-14 15:58:42 +01:00
// TODO Undo / Redo
m_graphicsView->RefreshLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_checkBoxTilesShowTiles_toggled(bool checked)
{
m_layout->SetShowTiles(checked);
// TODO Undo / Redo
m_graphicsView->RefreshLayout();
}
2020-11-14 17:31:34 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonTilesExport_clicked()
{
// svg export to do some test for the first test
QString dir = QDir::homePath();
QString filters(tr("PDF Files") + QLatin1String("(*.pdf)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + m_layout->GetFocusedSheet()->GetName() + QLatin1String(".pdf"),
2020-11-14 17:31:34 +01:00
filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
2020-11-15 13:06:57 +01:00
generateTiledPdf(fileName);
2020-11-14 17:31:34 +01:00
}
2020-11-14 15:58:42 +01:00
2020-04-11 16:25:23 +02:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_SheetFollowGrainlineChanged()
2020-04-11 16:25:23 +02:00
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::on_SheetFollowGrainlineChanged");
2020-04-11 16:25:23 +02:00
int ret = msgBox.exec();
Q_UNUSED(ret);
2020-04-11 16:32:49 +02:00
// TODO
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_doubleSpinBoxSheetPiecesGap_valueChanged(double value)
2020-04-11 16:25:23 +02:00
{
m_layout->GetFocusedSheet()->SetPiecesGapConverted(value);
2020-04-11 16:32:49 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
// TODO update the QGraphicView
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked)
2020-04-11 16:25:23 +02:00
{
2020-04-19 12:47:38 +02:00
m_layout->SetWarningSuperpositionOfPieces(checked);
2020-04-11 16:25:23 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
// TODO update the QGraphicView
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked)
2020-04-11 16:25:23 +02:00
{
2020-04-19 12:47:38 +02:00
m_layout->SetWarningPiecesOutOfBound(checked);
2020-04-11 16:32:49 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
// TODO update the QGraphicView
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked)
2020-04-11 16:25:23 +02:00
{
m_layout->GetFocusedSheet()->SetStickyEdges(checked);
2020-04-11 16:32:49 +02:00
2020-04-19 12:47:38 +02:00
// TODO Undo / Redo
// TODO update the QGraphicView
2020-04-11 16:25:23 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonSheetExport_clicked()
2020-04-11 16:25:23 +02:00
{
2020-11-14 12:37:43 +01:00
// svg export to do some test for the first test
2020-04-11 16:32:49 +02:00
2020-11-14 12:37:43 +01:00
QString dir = QDir::homePath();
QString filters(tr("SVG Files") + QLatin1String("(*.svg)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + m_layout->GetFocusedSheet()->GetName() + QLatin1String(".svg"),
2020-11-14 12:37:43 +01:00
filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
2020-11-14 12:46:18 +01:00
if(not fileName.isEmpty())
{
m_graphicsView->PrepareForExport();
2020-11-14 12:37:43 +01:00
const QSizeF s = m_layout->GetFocusedSheet()->GetSheetSize();
const QRectF r = QRectF(0, 0, s.width(), s.height());
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(QSize(qFloor(s.width()),qFloor(s.height())));
generator.setViewBox(r);
2021-03-14 16:57:20 +01:00
generator.setTitle(m_layout->GetFocusedSheet()->GetName());
2020-11-14 12:37:43 +01:00
generator.setDescription(m_layout->GetDescription().toHtmlEscaped());
generator.setResolution(static_cast<int>(PrintDPI));
QPainter painter;
painter.begin(&generator);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
m_graphicsView->GetScene()->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
m_graphicsView->CleanAfterExport();
2020-11-14 12:46:18 +01:00
}
2020-04-11 16:32:49 +02:00
2020-04-11 16:25:23 +02:00
}
2020-04-10 21:08:29 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked)
{
2020-05-05 17:40:36 +02:00
if(m_selectedPieces.count() == 1)
2020-05-01 19:08:48 +02:00
{
2020-05-05 17:40:36 +02:00
m_selectedPieces.first()->SetShowSeamLine(checked);
2020-05-01 19:08:48 +02:00
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked)
{
2020-05-05 17:40:36 +02:00
if(m_selectedPieces.count() == 1)
2020-05-01 19:08:48 +02:00
{
2020-05-05 17:40:36 +02:00
m_selectedPieces.first()->SetPieceMirrored(checked);
2020-05-01 19:08:48 +02:00
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonCurrentPieceRotate90Anticlockwise_clicked()
{
if(m_selectedPieces.count() == 1)
{
m_selectedPieces.first()->RotateBy(90);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonCurrentPieceRotate90Clockwise_clicked()
{
if(m_selectedPieces.count() == 1)
{
m_selectedPieces.first()->RotateBy(-90);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonCurrentPieceRotateGrainlineVertical_clicked()
{
if(m_selectedPieces.count() == 1)
{
m_selectedPieces.first()->RotateToGrainline(90, true);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonCurrentPieceRotateGrainlineHorizontal_clicked()
{
if(m_selectedPieces.count() == 1)
{
m_selectedPieces.first()->RotateToGrainline(0, true);
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value)
{
2020-05-09 11:13:29 +02:00
if(m_selectedPieces.count() == 1)
{
2020-05-23 15:42:51 +02:00
VPPiece *piece = m_selectedPieces.first();
2020-05-09 11:13:29 +02:00
piece->SetRotation(value);
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_CurrentPiecePositionEdited()
{
2020-05-05 17:40:36 +02:00
if(m_selectedPieces.count() == 1)
{
2020-05-23 15:42:51 +02:00
VPPiece *piece = m_selectedPieces.first();
2020-05-05 17:40:36 +02:00
QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px),
UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px));
piece->SetPosition(pos);
}
}
2020-04-13 12:24:26 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:29:18 +02:00
void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area)
2020-04-13 12:24:26 +02:00
{
if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea)
{
2020-05-23 14:29:18 +02:00
m_carrousel->SetOrientation(Qt::Horizontal);
2020-04-13 12:24:26 +02:00
}
else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
{
2020-05-23 14:29:18 +02:00
m_carrousel->SetOrientation(Qt::Vertical);
2020-04-13 12:24:26 +02:00
}
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_PieceSelectionChanged()
{
2020-05-05 17:40:36 +02:00
m_selectedPieces = m_layout->GetSelectedPieces();
// update the property of the piece currently selected
SetPropertyTabCurrentPieceData();
}
2020-05-05 17:40:36 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_PiecePositionChanged()
2020-05-05 17:40:36 +02:00
{
if(m_selectedPieces.count() == 1)
{
2020-05-23 15:42:51 +02:00
VPPiece *piece = m_selectedPieces.first();
2020-05-05 17:40:36 +02:00
QPointF pos = piece->GetPosition();
2020-05-10 17:35:15 +02:00
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
2020-05-05 17:40:36 +02:00
}
}
2020-05-09 14:45:36 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 14:17:20 +02:00
void VPMainWindow::on_PieceRotationChanged()
2020-05-09 14:45:36 +02:00
{
if(m_selectedPieces.count() == 1)
{
2020-05-23 15:42:51 +02:00
VPPiece *piece = m_selectedPieces.first();
2020-05-09 14:45:36 +02:00
qreal angle = piece->GetRotation();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);
}
}
2020-11-14 10:20:02 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_ScaleChanged(qreal scale)
{
if (not m_doubleSpinBoxScale.isNull())
{
m_doubleSpinBoxScale->blockSignals(true);
m_doubleSpinBoxScale->setMaximum(qFloor(VPMainGraphicsView::MaxScale()*1000)/10.0);
m_doubleSpinBoxScale->setMinimum(qFloor(VPMainGraphicsView::MinScale()*1000)/10.0);
m_doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0);
m_doubleSpinBoxScale->setSingleStep(1);
m_doubleSpinBoxScale->blockSignals(false);
}
}
2020-11-14 10:55:57 +01:00
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_MouseMoved(const QPointF &scenePos)
{
if (m_mouseCoordinate != nullptr)
{
m_mouseCoordinate->setText(QStringLiteral("%1, %2 (%3)")
.arg(static_cast<qint32>(FromPixel(scenePos.x(), m_layout->GetUnit())))
.arg(static_cast<qint32>(FromPixel(scenePos.y(), m_layout->GetUnit())))
.arg(UnitsToStr(m_layout->GetUnit(), true)));
}
}