QImage supports a maximum of 32768x32768 px images.
--HG-- branch : develop
This commit is contained in:
parent
9aa2eb79dc
commit
b0e0f73aa3
|
@ -218,9 +218,14 @@ void DialogLayoutSettings::SetAutoCrop(bool autoCrop)
|
||||||
void DialogLayoutSettings::TemplateSelected()
|
void DialogLayoutSettings::TemplateSelected()
|
||||||
{
|
{
|
||||||
const QSizeF size = Template();
|
const QSizeF size = Template();
|
||||||
|
|
||||||
|
oldPaperUnit = PaperUnit();
|
||||||
|
ui->doubleSpinBoxPaperWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||||
|
ui->doubleSpinBoxPaperHeight->setMaximum(qApp->fromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||||
|
|
||||||
ui->doubleSpinBoxPaperWidth->setValue(size.width());
|
ui->doubleSpinBoxPaperWidth->setValue(size.width());
|
||||||
ui->doubleSpinBoxPaperHeight->setValue(size.height());
|
ui->doubleSpinBoxPaperHeight->setValue(size.height());
|
||||||
oldPaperUnit = PaperUnit();
|
|
||||||
CorrectPaperDecimals();
|
CorrectPaperDecimals();
|
||||||
PaperSizeChanged();
|
PaperSizeChanged();
|
||||||
}
|
}
|
||||||
|
@ -231,6 +236,10 @@ void DialogLayoutSettings::ConvertPaperSize()
|
||||||
const Unit paperUnit = PaperUnit();
|
const Unit paperUnit = PaperUnit();
|
||||||
const qreal width = ui->doubleSpinBoxPaperWidth->value();
|
const qreal width = ui->doubleSpinBoxPaperWidth->value();
|
||||||
const qreal height = ui->doubleSpinBoxPaperHeight->value();
|
const qreal height = ui->doubleSpinBoxPaperHeight->value();
|
||||||
|
|
||||||
|
ui->doubleSpinBoxPaperWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, paperUnit));
|
||||||
|
ui->doubleSpinBoxPaperHeight->setMaximum(qApp->fromPixel(QIMAGE_MAX, paperUnit));
|
||||||
|
|
||||||
ui->doubleSpinBoxPaperWidth->setValue(VAbstractMeasurements::UnitConvertor(width, oldPaperUnit, paperUnit));
|
ui->doubleSpinBoxPaperWidth->setValue(VAbstractMeasurements::UnitConvertor(width, oldPaperUnit, paperUnit));
|
||||||
ui->doubleSpinBoxPaperHeight->setValue(VAbstractMeasurements::UnitConvertor(height, oldPaperUnit, paperUnit));
|
ui->doubleSpinBoxPaperHeight->setValue(VAbstractMeasurements::UnitConvertor(height, oldPaperUnit, paperUnit));
|
||||||
oldPaperUnit = paperUnit;
|
oldPaperUnit = paperUnit;
|
||||||
|
@ -244,6 +253,10 @@ void DialogLayoutSettings::ConvertLayoutSize()
|
||||||
const Unit unit = LayoutUnit();
|
const Unit unit = LayoutUnit();
|
||||||
const qreal layoutWidth = ui->doubleSpinBoxLayoutWidth->value();
|
const qreal layoutWidth = ui->doubleSpinBoxLayoutWidth->value();
|
||||||
const qreal shift = ui->doubleSpinBoxShift->value();
|
const qreal shift = ui->doubleSpinBoxShift->value();
|
||||||
|
|
||||||
|
ui->doubleSpinBoxLayoutWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, unit));
|
||||||
|
ui->doubleSpinBoxShift->setMaximum(qApp->fromPixel(QIMAGE_MAX, unit));
|
||||||
|
|
||||||
ui->doubleSpinBoxLayoutWidth->setValue(VAbstractMeasurements::UnitConvertor(layoutWidth, oldLayoutUnit, unit));
|
ui->doubleSpinBoxLayoutWidth->setValue(VAbstractMeasurements::UnitConvertor(layoutWidth, oldLayoutUnit, unit));
|
||||||
ui->doubleSpinBoxShift->setValue(VAbstractMeasurements::UnitConvertor(shift, oldLayoutUnit, unit));
|
ui->doubleSpinBoxShift->setValue(VAbstractMeasurements::UnitConvertor(shift, oldLayoutUnit, unit));
|
||||||
oldLayoutUnit = unit;
|
oldLayoutUnit = unit;
|
||||||
|
@ -425,27 +438,27 @@ QSizeF DialogLayoutSettings::Template()
|
||||||
case PaperSizeTemplate::Roll24in:
|
case PaperSizeTemplate::Roll24in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(6000, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll30in:
|
case PaperSizeTemplate::Roll30in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(6000, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll36in:
|
case PaperSizeTemplate::Roll36in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(6000, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll42in:
|
case PaperSizeTemplate::Roll42in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(6000, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll44in:
|
case PaperSizeTemplate::Roll44in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(6000, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -746,6 +746,9 @@ QIcon TableWindow::ScenePreview(int i) const
|
||||||
const QRectF r = paper->rect();
|
const QRectF r = paper->rect();
|
||||||
// Create the image with the exact size of the shrunk scene
|
// Create the image with the exact size of the shrunk scene
|
||||||
image = QImage(QSize(static_cast<qint32>(r.width()), static_cast<qint32>(r.height())), QImage::Format_RGB32);
|
image = QImage(QSize(static_cast<qint32>(r.width()), static_cast<qint32>(r.height())), QImage::Format_RGB32);
|
||||||
|
|
||||||
|
if (not image.isNull())
|
||||||
|
{
|
||||||
image.fill(Qt::white);
|
image.fill(Qt::white);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
|
@ -757,6 +760,11 @@ QIcon TableWindow::ScenePreview(int i) const
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
qWarning()<<"Cannot create image. Size too big";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
image = QImage(QSize(101, 146), QImage::Format_RGB32);
|
image = QImage(QSize(101, 146), QImage::Format_RGB32);
|
||||||
image.fill(Qt::white);
|
image.fill(Qt::white);
|
||||||
|
|
|
@ -46,6 +46,9 @@ enum class BestFrom : char
|
||||||
Combine = 1
|
Combine = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable
|
||||||
|
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
|
||||||
|
*/
|
||||||
//#define LAYOUT_DEBUG // Enable debug mode
|
//#define LAYOUT_DEBUG // Enable debug mode
|
||||||
|
|
||||||
// This block help rule debug mode. Don't turn all options at the same time!
|
// This block help rule debug mode. Don't turn all options at the same time!
|
||||||
|
@ -57,11 +60,11 @@ enum class BestFrom : char
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
# define SHOW_CANDIDATE // Show each position
|
# define SHOW_CANDIDATE // Show each position
|
||||||
# define SHOW_ROTATION // For each position show rotation part
|
//# define SHOW_ROTATION // For each position show rotation part
|
||||||
# define SHOW_COMBINE // For each position show edge combine part
|
//# define SHOW_COMBINE // For each position show edge combine part
|
||||||
# define SHOW_MIRROR // For each position show mirror part
|
//# define SHOW_MIRROR // For each position show mirror part
|
||||||
//# define SHOW_CANDIDATE_BEST // For only correct positions that pass checks
|
//# define SHOW_CANDIDATE_BEST // For only correct positions that pass checks
|
||||||
//# define SHOW_BEST // Show only best position for workpiece
|
# define SHOW_BEST // Show only best position for workpiece
|
||||||
#endif//LAYOUT_DEBUG
|
#endif//LAYOUT_DEBUG
|
||||||
|
|
||||||
#endif // VLAYOUTDEF_H
|
#endif // VLAYOUTDEF_H
|
||||||
|
|
|
@ -186,6 +186,8 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
|
||||||
thread_pool->setExpiryTimeout(1000);
|
thread_pool->setExpiryTimeout(1000);
|
||||||
QVector<VPosition *> threads;
|
QVector<VPosition *> threads;
|
||||||
|
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
for (int j=1; j <= d->globalContour.EdgesCount(); ++j)
|
for (int j=1; j <= d->globalContour.EdgesCount(); ++j)
|
||||||
{
|
{
|
||||||
for (int i=1; i<= detail.EdgesCount(); i++)
|
for (int i=1; i<= detail.EdgesCount(); i++)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vposition.h"
|
#include "vposition.h"
|
||||||
|
#include "../../utils/def.h"
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QtWidgets>
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||||
# include "../../utils/vmath.h"
|
# include "../../utils/vmath.h"
|
||||||
#else
|
#else
|
||||||
|
@ -149,33 +151,42 @@ VBestSquare VPosition::getBestResult() const
|
||||||
void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex,
|
void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex,
|
||||||
int detailsCount, const QVector<VLayoutDetail> &details)
|
int detailsCount, const QVector<VLayoutDetail> &details)
|
||||||
{
|
{
|
||||||
QImage frameImage(contour.GetWidth()*2, contour.GetHeight()*2, QImage::Format_RGB32);
|
const int biasWidth = Bias(contour.GetWidth(), QIMAGE_MAX);
|
||||||
|
const int biasHeight = Bias(contour.GetHeight(), QIMAGE_MAX);
|
||||||
|
|
||||||
|
QImage frameImage(contour.GetWidth()+biasWidth, contour.GetHeight()+biasHeight, QImage::Format_RGB32);
|
||||||
|
|
||||||
|
if (frameImage.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frameImage.fill(Qt::white);
|
frameImage.fill(Qt::white);
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
paint.begin(&frameImage);
|
paint.begin(&frameImage);
|
||||||
|
|
||||||
paint.setPen(QPen(Qt::darkRed, 15, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
paint.setPen(QPen(Qt::darkRed, 15, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
||||||
paint.drawRect(QRectF(contour.GetWidth()/2, contour.GetHeight()/2, contour.GetWidth(), contour.GetHeight()));
|
paint.drawRect(QRectF(biasWidth/2, biasHeight/2, contour.GetWidth(), contour.GetHeight()));
|
||||||
|
|
||||||
paint.setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
paint.setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
||||||
QPainterPath p;
|
QPainterPath p;
|
||||||
if (contour.GetContour().isEmpty())
|
if (contour.GetContour().isEmpty())
|
||||||
{
|
{
|
||||||
p = DrawContour(contour.CutEdge(QLineF(0, 0, contour.GetWidth(), 0)));
|
p = DrawContour(contour.CutEdge(QLineF(0, 0, contour.GetWidth(), 0)));
|
||||||
p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
|
p.translate(biasWidth/2, biasHeight/2);
|
||||||
paint.drawPath(p);
|
paint.drawPath(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = DrawContour(contour.GetContour());
|
p = DrawContour(contour.GetContour());
|
||||||
p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
|
p.translate(biasWidth/2, biasHeight/2);
|
||||||
paint.drawPath(p);
|
paint.drawPath(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOW_CANDIDATE
|
#ifdef SHOW_CANDIDATE
|
||||||
paint.setPen(QPen(Qt::darkGreen, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
paint.setPen(QPen(Qt::darkGreen, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
||||||
p = DrawContour(detail.GetLayoutAllowencePoints());
|
p = DrawContour(detail.GetLayoutAllowencePoints());
|
||||||
p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
|
p.translate(biasWidth/2, biasHeight/2);
|
||||||
paint.drawPath(p);
|
paint.drawPath(p);
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(detail)
|
Q_UNUSED(detail)
|
||||||
|
@ -185,7 +196,7 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail,
|
||||||
#ifdef ARRANGED_DETAILS
|
#ifdef ARRANGED_DETAILS
|
||||||
paint.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
paint.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
|
||||||
p = DrawDetails(details);
|
p = DrawDetails(details);
|
||||||
p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
|
p.translate(biasWidth/2, biasHeight/2);
|
||||||
paint.drawPath(p);
|
paint.drawPath(p);
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(details)
|
Q_UNUSED(details)
|
||||||
|
@ -197,6 +208,19 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail,
|
||||||
frameImage.save (path);
|
frameImage.save (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VPosition::Bias(int length, int maxLength)
|
||||||
|
{
|
||||||
|
if (length < maxLength && length*2 < maxLength)
|
||||||
|
{
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return maxLength-length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ,
|
void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ,
|
||||||
BestFrom type)
|
BestFrom type)
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
static void DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex,
|
static void DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex,
|
||||||
int detailsCount, const QVector<VLayoutDetail> &details = QVector<VLayoutDetail>());
|
int detailsCount, const QVector<VLayoutDetail> &details = QVector<VLayoutDetail>());
|
||||||
|
|
||||||
|
static int Bias(int length, int maxLength);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPosition)
|
Q_DISABLE_COPY(VPosition)
|
||||||
VBestSquare bestResult;
|
VBestSquare bestResult;
|
||||||
|
|
|
@ -32,6 +32,14 @@
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
/* QImage supports a maximum of 32768x32768 px images (signed short).
|
||||||
|
* This follows from the condition: width * height * colordepth < INT_MAX (4 billion) -> 32768 * 32768 * 4 = 4 billion.
|
||||||
|
* The second condition is of course that malloc is able to allocate the requested memory.
|
||||||
|
*
|
||||||
|
* If you really need bigger images you will have to use another wrapper or split into multiple QImage's.
|
||||||
|
*/
|
||||||
|
#define QIMAGE_MAX 32768
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow
|
* This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow
|
||||||
* you to continue afterwards should you choose to.
|
* you to continue afterwards should you choose to.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user