2015-01-21 22:49:38 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vposition.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 20 1, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2015-01-21 22:49:38 +01:00
|
|
|
** <https://bitbucket.org/dismine/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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VPOSITION_H
|
|
|
|
#define VPOSITION_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
2015-01-21 22:49:38 +01:00
|
|
|
#include <QRunnable>
|
|
|
|
#include <QVector>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QtGlobal>
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
#include "vbestsquare.h"
|
|
|
|
#include "vcontour.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vlayoutdef.h"
|
2017-01-22 10:02:02 +01:00
|
|
|
#include "vlayoutpiece.h"
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
class VPosition : public QRunnable
|
|
|
|
{
|
|
|
|
public:
|
2017-01-22 10:02:02 +01:00
|
|
|
VPosition(const VContour &gContour, int j, const VLayoutPiece &detail, int i, volatile bool *stop, bool rotate,
|
2015-05-08 12:10:56 +02:00
|
|
|
int rotationIncrease, bool saveLength);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual ~VPosition() Q_DECL_OVERRIDE{}
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
quint32 getPaperIndex() const;
|
|
|
|
void setPaperIndex(const quint32 &value);
|
|
|
|
|
|
|
|
quint32 getFrame() const;
|
|
|
|
void setFrame(const quint32 &value);
|
|
|
|
|
|
|
|
quint32 getDetailsCount() const;
|
|
|
|
void setDetailsCount(const quint32 &value);
|
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
void setDetails(const QVector<VLayoutPiece> &details);
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
VBestSquare getBestResult() const;
|
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
static void DrawDebug(const VContour &contour, const VLayoutPiece &detail, int frame, quint32 paperIndex,
|
|
|
|
int detailsCount, const QVector<VLayoutPiece> &details = QVector<VLayoutPiece>());
|
2015-01-21 22:49:38 +01:00
|
|
|
|
2015-05-06 14:03:45 +02:00
|
|
|
static int Bias(int length, int maxLength);
|
|
|
|
|
2015-01-21 22:49:38 +01:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VPosition)
|
|
|
|
VBestSquare bestResult;
|
|
|
|
const VContour gContour;
|
2017-01-22 10:02:02 +01:00
|
|
|
const VLayoutPiece detail;
|
2015-01-21 22:49:38 +01:00
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
quint32 paperIndex;
|
|
|
|
quint32 frame;
|
|
|
|
quint32 detailsCount;
|
2017-01-22 10:02:02 +01:00
|
|
|
QVector<VLayoutPiece> details;
|
2015-05-06 16:09:58 +02:00
|
|
|
volatile bool *stop;
|
2015-01-22 15:11:50 +01:00
|
|
|
bool rotate;
|
|
|
|
int rotationIncrease;
|
2015-05-15 17:16:15 +02:00
|
|
|
/**
|
|
|
|
* @brief angle_between keep angle between global edge and detail edge. Need for optimization rotation.
|
|
|
|
*/
|
|
|
|
qreal angle_between;
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
enum class CrossingType : char
|
|
|
|
{
|
|
|
|
NoIntersection = 0,
|
|
|
|
Intersection = 1,
|
|
|
|
EdgeError = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class InsideType : char
|
|
|
|
{
|
|
|
|
Outside = 0,
|
|
|
|
Inside = 1,
|
|
|
|
EdgeError = 2
|
|
|
|
};
|
|
|
|
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void run() Q_DECL_OVERRIDE;
|
2015-05-06 16:09:58 +02:00
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
void SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detail, int globalI, int detJ, BestFrom type);
|
2015-01-21 22:49:38 +01:00
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
bool CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge);
|
|
|
|
bool CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int angle) const;
|
2015-01-21 22:49:38 +01:00
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
CrossingType Crossing(const VLayoutPiece &detail) const;
|
2015-01-21 22:49:38 +01:00
|
|
|
bool SheetContains(const QRectF &rect) const;
|
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
void CombineEdges(VLayoutPiece &detail, const QLineF &globalEdge, const int &dEdge);
|
|
|
|
void RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, int angle) const;
|
2015-01-21 22:49:38 +01:00
|
|
|
|
|
|
|
static QPainterPath ShowDirection(const QLineF &edge);
|
|
|
|
static QPainterPath DrawContour(const QVector<QPointF> &points);
|
2017-01-22 10:02:02 +01:00
|
|
|
static QPainterPath DrawDetails(const QVector<VLayoutPiece> &details);
|
2015-01-21 22:49:38 +01:00
|
|
|
|
2015-01-22 12:47:20 +01:00
|
|
|
void Rotate(int increase);
|
2015-01-21 22:49:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VPOSITION_H
|