Templates for sheet and tiles
This commit is contained in:
parent
073bd93df7
commit
9140fdcb78
|
@ -88,14 +88,14 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
InitMenuBar();
|
|
||||||
InitProperties();
|
|
||||||
InitCarrousel();
|
|
||||||
|
|
||||||
// init the tile factory
|
// init the tile factory
|
||||||
m_tileFactory = new VPTileFactory(m_layout, qApp->Settings());
|
m_tileFactory = new VPTileFactory(m_layout, qApp->Settings());
|
||||||
m_tileFactory->refreshTileInfos();
|
m_tileFactory->refreshTileInfos();
|
||||||
|
|
||||||
|
InitMenuBar();
|
||||||
|
InitProperties();
|
||||||
|
InitCarrousel();
|
||||||
|
|
||||||
InitMainGraphics();
|
InitMainGraphics();
|
||||||
|
|
||||||
InitZoomToolBar();
|
InitZoomToolBar();
|
||||||
|
@ -314,11 +314,33 @@ void VPMainWindow::InitPropertyTabCurrentSheet()
|
||||||
connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
|
connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
|
||||||
&VPMainWindow::on_SheetFollowGrainlineChanged);
|
&VPMainWindow::on_SheetFollowGrainlineChanged);
|
||||||
|
|
||||||
// -------------------- export ---------------------------
|
// -------------------- sheet template ---------------------------
|
||||||
|
|
||||||
// TODO init the file format export combobox
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -334,6 +356,24 @@ void VPMainWindow::InitPropertyTabTiles()
|
||||||
connect(ui->radioButtonTilesLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
|
connect(ui->radioButtonTilesLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
|
||||||
&VPMainWindow::on_TilesOrientationChanged);
|
&VPMainWindow::on_TilesOrientationChanged);
|
||||||
|
|
||||||
|
// -------------------- 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
|
||||||
|
|
||||||
|
|
||||||
// -------------------- margins ------------------------
|
// -------------------- margins ------------------------
|
||||||
connect(ui->doubleSpinBoxTilesMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
connect(ui->doubleSpinBoxTilesMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||||
&VPMainWindow::on_TilesMarginChanged);
|
&VPMainWindow::on_TilesMarginChanged);
|
||||||
|
@ -1004,26 +1044,46 @@ void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
|
void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
// just for test purpuses, to be removed:
|
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(
|
||||||
QMessageBox msgBox;
|
ui->comboBoxSheetTemplate->itemData(index).toInt()
|
||||||
msgBox.setText("TODO VPMainWindow::SheetTemplateChanged");
|
);
|
||||||
int ret = msgBox.exec();
|
|
||||||
|
|
||||||
Q_UNUSED(index);
|
QSizeF tmplSize = VPSheet::GetTemplateSize(tmpl);
|
||||||
Q_UNUSED(ret);
|
if(!tmplSize.isEmpty())
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxSheetWidth->blockSignals(true);
|
||||||
|
ui->doubleSpinBoxSheetLength->blockSignals(true);
|
||||||
|
|
||||||
|
ui->doubleSpinBoxSheetWidth->setValue(UnitConvertor(tmplSize.width(), Unit::Px, m_layout->GetUnit()));
|
||||||
|
ui->doubleSpinBoxSheetLength->setValue(UnitConvertor(tmplSize.height(), Unit::Px, m_layout->GetUnit()));
|
||||||
|
|
||||||
// TODO
|
on_SheetSizeChanged(false);
|
||||||
|
|
||||||
|
ui->doubleSpinBoxSheetWidth->blockSignals(false);
|
||||||
|
ui->doubleSpinBoxSheetLength->blockSignals(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainWindow::on_SheetSizeChanged()
|
void VPMainWindow::on_SheetSizeChanged(bool changedViaSizeCombobox)
|
||||||
{
|
{
|
||||||
m_layout->GetFocusedSheet()->SetSheetSizeConverted(
|
m_layout->GetFocusedSheet()->SetSheetSizeConverted(
|
||||||
ui->doubleSpinBoxSheetWidth->value(),
|
ui->doubleSpinBoxSheetWidth->value(),
|
||||||
ui->doubleSpinBoxSheetLength->value()
|
ui->doubleSpinBoxSheetLength->value()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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();
|
m_tileFactory->refreshTileInfos();
|
||||||
|
|
||||||
// TODO Undo / Redo
|
// TODO Undo / Redo
|
||||||
|
@ -1079,17 +1139,54 @@ void VPMainWindow::on_SheetMarginChanged()
|
||||||
m_graphicsView->RefreshLayout();
|
m_graphicsView->RefreshLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainWindow::on_TilesSizeChanged()
|
void VPMainWindow::on_TilesSizeChanged(bool changedViaSizeCombobox)
|
||||||
{
|
{
|
||||||
m_layout->SetTilesSizeConverted(ui->doubleSpinBoxTilesWidth->value(), ui->doubleSpinBoxTilesLength->value());
|
m_layout->SetTilesSizeConverted(ui->doubleSpinBoxTilesWidth->value(), ui->doubleSpinBoxTilesLength->value());
|
||||||
m_tileFactory->refreshTileInfos();
|
m_tileFactory->refreshTileInfos();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Undo / Redo
|
// TODO Undo / Redo
|
||||||
|
|
||||||
|
if(m_graphicsView != nullptr)
|
||||||
|
{
|
||||||
m_graphicsView->RefreshLayout();
|
m_graphicsView->RefreshLayout();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainWindow::on_TilesOrientationChanged()
|
void VPMainWindow::on_TilesOrientationChanged()
|
||||||
|
|
|
@ -287,7 +287,7 @@ private slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief on_comboBoxLayoutTemplate_currentIndexChanged When the template is
|
* @brief on_comboBoxLayoutTemplate_currentIndexChanged When the template is
|
||||||
* changed in the layout property tab.
|
* changed in the sheet property tab.
|
||||||
* The slot is automatically connected through name convention.
|
* The slot is automatically connected through name convention.
|
||||||
* @param index the index of the selected templated
|
* @param index the index of the selected templated
|
||||||
*/
|
*/
|
||||||
|
@ -296,8 +296,9 @@ private slots:
|
||||||
/**
|
/**
|
||||||
* @brief on_SheetSizeChanged When the width or the length has been changed in
|
* @brief on_SheetSizeChanged When the width or the length has been changed in
|
||||||
* the sheet property tab
|
* the sheet property tab
|
||||||
|
* @param changedViaSizeCombobox true if the change happened through the combobox
|
||||||
*/
|
*/
|
||||||
void on_SheetSizeChanged();
|
void on_SheetSizeChanged(bool changedViaSizeCombobox = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief on_SheetOrientationChanged When one of the radio boxes for the sheet
|
* @brief on_SheetOrientationChanged When one of the radio boxes for the sheet
|
||||||
|
@ -332,12 +333,20 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void on_doubleSpinBoxSheetPiecesGap_valueChanged(double value);
|
void on_doubleSpinBoxSheetPiecesGap_valueChanged(double value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief on_comboBoxTilesTemplate_currentIndexChanged When the template is
|
||||||
|
* changed in the tiles property tab.
|
||||||
|
* The slot is automatically connected through name convention.
|
||||||
|
* @param index the index of the selected templated
|
||||||
|
*/
|
||||||
|
void on_comboBoxTilesTemplate_currentIndexChanged(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief on_TilesSizeChanged When the width or the length has been changed in
|
* @brief on_TilesSizeChanged When the width or the length has been changed in
|
||||||
* the tiles property tab
|
* the tiles property tab
|
||||||
|
* @param changedViaSizeCombobox true if the change happened through the combobox
|
||||||
*/
|
*/
|
||||||
void on_TilesSizeChanged();
|
void on_TilesSizeChanged(bool changedViaSizeCombobox = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief on_TilesOrientationChanged When one of the radio boxes for the tiles
|
* @brief on_TilesOrientationChanged When one of the radio boxes for the tiles
|
||||||
|
|
|
@ -176,7 +176,7 @@
|
||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -632,6 +632,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetWidth">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetWidth">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>100000.000000000000000</double>
|
<double>100000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
@ -646,6 +649,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetLength">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetLength">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>100000.000000000000000</double>
|
<double>100000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1006,42 +1012,42 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayoutTilesFormat">
|
<layout class="QFormLayout" name="formLayoutTilesFormat">
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelTilesWidth">
|
<widget class="QLabel" name="labelTilesWidth">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Width</string>
|
<string>Width</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxTilesWidth">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxTilesWidth">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>100000.000000000000000</double>
|
<double>100000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelTilesLength">
|
<widget class="QLabel" name="labelTilesLength">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Length</string>
|
<string>Length</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxTilesLength">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxTilesLength">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>100000.000000000000000</double>
|
<double>100000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="labelTilesOrientation">
|
<widget class="QLabel" name="labelTilesOrientation">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Orientation</string>
|
<string>Orientation</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayoutTilesOrientation">
|
<layout class="QHBoxLayout" name="horizontalLayoutTilesOrientation">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonTilesPortrait">
|
<widget class="QRadioButton" name="radioButtonTilesPortrait">
|
||||||
|
@ -1082,6 +1088,16 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelTilesTemplate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Template</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBoxTilesTemplate"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -43,6 +43,217 @@ VPSheet::~VPSheet()
|
||||||
delete m_pieceList;
|
delete m_pieceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QSizeF VPSheet::GetTemplateSize(PaperSizeTemplate tmpl)
|
||||||
|
{
|
||||||
|
qreal height = 0;
|
||||||
|
qreal width = 0;
|
||||||
|
|
||||||
|
switch (tmpl)
|
||||||
|
{
|
||||||
|
case PaperSizeTemplate::A0:
|
||||||
|
width = UnitConvertor(841, Unit::Mm, Unit::Px);
|
||||||
|
height = UnitConvertor(1189, Unit::Mm, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A1:
|
||||||
|
width = UnitConvertor(594, Unit::Mm, Unit::Px);
|
||||||
|
height = UnitConvertor(841, Unit::Mm, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A2:
|
||||||
|
width = UnitConvertor(420, Unit::Mm, Unit::Px);
|
||||||
|
height = UnitConvertor(594, Unit::Mm, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A3:
|
||||||
|
width = UnitConvertor(297, Unit::Mm, Unit::Px);
|
||||||
|
height = UnitConvertor(420, Unit::Mm, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A4:
|
||||||
|
width = UnitConvertor(210, Unit::Mm, Unit::Px);
|
||||||
|
height = UnitConvertor(297, Unit::Mm, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Letter:
|
||||||
|
width = UnitConvertor(8.5, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(11, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Legal:
|
||||||
|
width = UnitConvertor(8.5, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(14, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Tabloid:
|
||||||
|
width = UnitConvertor(11, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(17, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll24in:
|
||||||
|
width = UnitConvertor(24, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(48, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll30in:
|
||||||
|
width = UnitConvertor(30, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(60, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll36in:
|
||||||
|
width = UnitConvertor(36, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(72, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll42in:
|
||||||
|
width = UnitConvertor(42, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(84, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll44in:
|
||||||
|
width = UnitConvertor(44, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(88, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll48in:
|
||||||
|
width = UnitConvertor(48, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(96, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll62in:
|
||||||
|
width = UnitConvertor(62, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(124, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll72in:
|
||||||
|
width = UnitConvertor(72, Unit::Inch, Unit::Px);
|
||||||
|
height = UnitConvertor(144, Unit::Inch, Unit::Px);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QSizeF(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VPSheet::GetTemplateName(PaperSizeTemplate tmpl)
|
||||||
|
{
|
||||||
|
switch (tmpl)
|
||||||
|
{
|
||||||
|
case PaperSizeTemplate::A0:
|
||||||
|
return QString("A0");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A1:
|
||||||
|
return QString("A1");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A2:
|
||||||
|
return QString("A2");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A3:
|
||||||
|
return QString("A3");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::A4:
|
||||||
|
return QString("A4");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Letter:
|
||||||
|
return tr("Letter");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Legal:
|
||||||
|
return tr("Legal");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Tabloid:
|
||||||
|
return tr("Tabloid");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll24in:
|
||||||
|
return tr("Roll 24in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll30in:
|
||||||
|
return tr("Roll 30in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll36in:
|
||||||
|
return tr("Roll 36in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll42in:
|
||||||
|
return tr("Roll 42in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll44in:
|
||||||
|
return tr("Roll 44in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll48in:
|
||||||
|
return tr("Roll 48in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll62in:
|
||||||
|
return tr("Roll 62in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Roll72in:
|
||||||
|
return tr("Roll 72in");
|
||||||
|
|
||||||
|
case PaperSizeTemplate::Custom:
|
||||||
|
return tr("Custom");
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
PaperSizeTemplate VPSheet::GetTemplate(QSizeF size)
|
||||||
|
{
|
||||||
|
const int max = static_cast<int>(PaperSizeTemplate::Custom);
|
||||||
|
|
||||||
|
for (int i=0; i < max; i++)
|
||||||
|
{
|
||||||
|
PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
|
||||||
|
const QSizeF tmplSize = GetTemplateSize(tmpl);
|
||||||
|
|
||||||
|
if(size.width() == tmplSize.width())
|
||||||
|
{
|
||||||
|
if(isRollTemplate(tmpl))
|
||||||
|
{
|
||||||
|
return tmpl;
|
||||||
|
}
|
||||||
|
else if(size.height() == tmplSize.height())
|
||||||
|
{
|
||||||
|
return tmpl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PaperSizeTemplate::Custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VPSheet::isRollTemplate(PaperSizeTemplate tmpl)
|
||||||
|
{
|
||||||
|
switch (tmpl) {
|
||||||
|
case PaperSizeTemplate::Roll24in:
|
||||||
|
case PaperSizeTemplate::Roll30in:
|
||||||
|
case PaperSizeTemplate::Roll36in:
|
||||||
|
case PaperSizeTemplate::Roll42in:
|
||||||
|
case PaperSizeTemplate::Roll44in:
|
||||||
|
case PaperSizeTemplate::Roll48in:
|
||||||
|
case PaperSizeTemplate::Roll62in:
|
||||||
|
case PaperSizeTemplate::Roll72in:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheet::PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox)
|
||||||
|
{
|
||||||
|
for (auto tmpl : *tmpls)
|
||||||
|
{
|
||||||
|
comboBox->addItem(GetTemplateName(tmpl), QVariant(static_cast<int>(tmpl)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPLayout* VPSheet::GetLayout()
|
VPLayout* VPSheet::GetLayout()
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,11 +32,36 @@
|
||||||
#include <QSizeF>
|
#include <QSizeF>
|
||||||
#include <QMarginsF>
|
#include <QMarginsF>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
// is this the right place for the definition?
|
// is this the right place for the definition?
|
||||||
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
|
enum class FollowGrainline : qint8 {
|
||||||
|
No = 0,
|
||||||
|
Follow90 = 1,
|
||||||
|
Follow180 = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class PaperSizeTemplate : qint8 {
|
||||||
|
A0 = 0,
|
||||||
|
A1,
|
||||||
|
A2,
|
||||||
|
A3,
|
||||||
|
A4,
|
||||||
|
Letter,
|
||||||
|
Legal,
|
||||||
|
Tabloid,
|
||||||
|
Roll24in,
|
||||||
|
Roll30in,
|
||||||
|
Roll36in,
|
||||||
|
Roll42in,
|
||||||
|
Roll44in,
|
||||||
|
Roll48in,
|
||||||
|
Roll62in,
|
||||||
|
Roll72in,
|
||||||
|
Custom
|
||||||
|
};
|
||||||
|
|
||||||
class VPLayout;
|
class VPLayout;
|
||||||
class VPPieceList;
|
class VPPieceList;
|
||||||
|
@ -45,10 +70,47 @@ class VPSheet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
explicit VPSheet(VPLayout* layout);
|
explicit VPSheet(VPLayout* layout);
|
||||||
|
|
||||||
~VPSheet();
|
~VPSheet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetTemplateSize Returns the size in Px of the given template
|
||||||
|
* @param tmpl
|
||||||
|
* @return the size in Px
|
||||||
|
*/
|
||||||
|
static QSizeF GetTemplateSize(PaperSizeTemplate tmpl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetTemplateName Returns the name of the given template
|
||||||
|
* @param tmpl
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static QString GetTemplateName(PaperSizeTemplate tmpl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetTemplate GetTemplate Returns the template that corresponds to the given size
|
||||||
|
* @param size the Size in Px
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static PaperSizeTemplate GetTemplate(QSizeF size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PopulateComboBox Populates the given combo with the given templates
|
||||||
|
* @param tmpls
|
||||||
|
* @param comboBox
|
||||||
|
*/
|
||||||
|
static void PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief isRollTemplate Returns wether the given template is a roll or not.
|
||||||
|
* @param tmpl
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static bool isRollTemplate(PaperSizeTemplate tmpl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GetLayout Returns the Layout of the sheet
|
* @brief GetLayout Returns the Layout of the sheet
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -24,6 +24,8 @@ VPTileFactory::~VPTileFactory()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPTileFactory::refreshTileInfos()
|
void VPTileFactory::refreshTileInfos()
|
||||||
|
{
|
||||||
|
if(m_layout != nullptr)
|
||||||
{
|
{
|
||||||
PageOrientation tilesOrientation = m_layout->GetTilesOrientation();
|
PageOrientation tilesOrientation = m_layout->GetTilesOrientation();
|
||||||
QSizeF tilesSize = m_layout->GetTilesSize();
|
QSizeF tilesSize = m_layout->GetTilesSize();
|
||||||
|
@ -60,6 +62,7 @@ void VPTileFactory::refreshTileInfos()
|
||||||
m_nbCol = qCeil(totalDrawingWidth/m_drawingAreaWidth);
|
m_nbCol = qCeil(totalDrawingWidth/m_drawingAreaWidth);
|
||||||
m_nbRow = qCeil(totaldrawingHeight/m_drawingAreaHeight);
|
m_nbRow = qCeil(totaldrawingHeight/m_drawingAreaHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user