Optimizing the piece carrousel
This commit is contained in:
parent
e27e543fbc
commit
497cb65cb2
|
@ -144,6 +144,14 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
|
|||
|
||||
// TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece()
|
||||
|
||||
|
||||
// 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.
|
||||
|
||||
|
||||
VPuzzlePiece *piece = CreatePiece(rawPiece);
|
||||
m_layout->GetUnplacedPiecesLayer()->AddPiece(piece);
|
||||
}
|
||||
|
@ -165,10 +173,12 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
|
||||
{
|
||||
|
||||
VPuzzlePiece *piece = new VPuzzlePiece();
|
||||
piece->SetName(rawPiece.GetName());
|
||||
piece->SetUuid(rawPiece.GetUUID());
|
||||
piece->SetCuttingLine(rawPiece.GetMappedSeamAllowancePoints());
|
||||
piece->SetSeamLine(rawPiece.GetMappedContourPoints());
|
||||
|
||||
// TODO : set all the information we need for the piece!
|
||||
|
||||
|
|
|
@ -75,8 +75,10 @@ void VPieceCarrousel::Init()
|
|||
QVBoxLayout *layersContainerLayout = new QVBoxLayout();
|
||||
layersContainerLayout->setMargin(0);
|
||||
m_layersContainer->setLayout(layersContainerLayout);
|
||||
m_layersContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
QSpacerItem *spacer = new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
|
||||
layersContainerWrapperLayout->addWidget(m_layersContainer);
|
||||
layersContainerWrapperLayout->addSpacerItem(spacer);
|
||||
|
||||
|
@ -92,9 +94,6 @@ void VPieceCarrousel::Init()
|
|||
|
||||
// ------ then we fill the carrousel with the layout content
|
||||
Refresh();
|
||||
|
||||
// ------ and make sure the calculation for the qlayout is right
|
||||
SetOrientation(Qt::Vertical);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -126,6 +125,8 @@ void VPieceCarrousel::Refresh()
|
|||
}
|
||||
|
||||
on_ActiveLayerChanged(0);
|
||||
|
||||
RefreshOrientation();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -188,8 +189,14 @@ void VPieceCarrousel::on_ActiveLayerChanged(int index)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceCarrousel::SetOrientation(Qt::Orientation orientation)
|
||||
{
|
||||
m_orientation = orientation;
|
||||
RefreshOrientation();
|
||||
}
|
||||
|
||||
QBoxLayout::Direction direction = (orientation == Qt::Horizontal)?
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceCarrousel::RefreshOrientation()
|
||||
{
|
||||
QBoxLayout::Direction direction = (m_orientation == Qt::Horizontal)?
|
||||
QBoxLayout::LeftToRight
|
||||
:
|
||||
QBoxLayout::TopToBottom;
|
||||
|
@ -207,7 +214,7 @@ void VPieceCarrousel::SetOrientation(Qt::Orientation orientation)
|
|||
}
|
||||
|
||||
// then update the scrollarea min height / width and scrollbar behaviour
|
||||
if(orientation == Qt::Horizontal)
|
||||
if(m_orientation == Qt::Horizontal)
|
||||
{
|
||||
m_comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
|
@ -232,7 +239,6 @@ void VPieceCarrousel::SetOrientation(Qt::Orientation orientation)
|
|||
m_scrollArea->setMinimumWidth(124 + m_scrollArea->verticalScrollBar()->sizeHint().width()+2);
|
||||
// FIXME: find a nicer way than putting directly the 120 width of the piece
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -43,8 +43,19 @@ public:
|
|||
explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr);
|
||||
virtual ~VPieceCarrousel();
|
||||
|
||||
/**
|
||||
* @brief SetOrientation Sets the orientation to the given value and refreshes
|
||||
* the orientation of the carrousel.
|
||||
* @param orientation the orientation to set the carrousel to.
|
||||
*/
|
||||
void SetOrientation(Qt::Orientation orientation);
|
||||
|
||||
/**
|
||||
* @brief RefreshOrientation Refreshes the orientation of the carrousel with the
|
||||
* m_orientation value;
|
||||
*/
|
||||
void RefreshOrientation();
|
||||
|
||||
/**
|
||||
* @brief Inits the carroussel
|
||||
*/
|
||||
|
@ -85,6 +96,8 @@ private:
|
|||
|
||||
QList<VPieceCarrouselLayer*> m_carrouselLayers;
|
||||
|
||||
Qt::Orientation m_orientation{Qt::Vertical};
|
||||
|
||||
|
||||
private slots:
|
||||
void on_ActiveLayerChanged(int index);
|
||||
|
|
|
@ -72,6 +72,7 @@ void VPieceCarrouselPiece::Init()
|
|||
m_graphicsView->setScene(graphicsScene);
|
||||
m_graphicsView->setFixedSize(120,100);
|
||||
m_graphicsView->setStyleSheet("border: 4px solid transparent;");
|
||||
m_graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
|
||||
// define the label
|
||||
m_label = new QLabel();
|
||||
|
@ -98,9 +99,11 @@ void VPieceCarrouselPiece::Refresh()
|
|||
{
|
||||
// update the graphic view / the scene
|
||||
|
||||
// TODO / FIXME : not perfect and maybe not the right way, still need to work on this
|
||||
// for instance: use a painter to habve a better quality, less pixeled.
|
||||
QVector<QPointF> points = m_piece->GetCuttingLine();
|
||||
QVector<QPointF> points = m_piece->GetSeamLine();
|
||||
if(points.isEmpty())
|
||||
{
|
||||
points = m_piece->GetCuttingLine();
|
||||
}
|
||||
|
||||
QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||||
pen.setCosmetic(true);
|
||||
|
|
|
@ -79,6 +79,17 @@ void VPuzzlePiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
|
|||
m_cuttingLine = cuttingLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPuzzlePiece::GetSeamLine() const
|
||||
{
|
||||
return m_seamLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPuzzlePiece::SetSeamLine(const QVector<QPointF> &seamLine)
|
||||
{
|
||||
m_seamLine = seamLine;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VPuzzlePiece::GetShowSeamLine()
|
||||
|
|
|
@ -61,10 +61,30 @@ public:
|
|||
*/
|
||||
void SetUuid(const QUuid &uuid);
|
||||
|
||||
/**
|
||||
* @brief GetCuttingLine Returns the vector points of the cutting line
|
||||
* @return the vector points of the cutting line
|
||||
*/
|
||||
QVector<QPointF> GetCuttingLine() const;
|
||||
|
||||
/**
|
||||
* @brief SetCuttingLine Sets the vector points of the cutting line to the given value
|
||||
* @param cuttingLine the new vector points for the cutting line
|
||||
*/
|
||||
void SetCuttingLine(const QVector<QPointF> &cuttingLine);
|
||||
|
||||
/**
|
||||
* @brief GetSeamLine Returns the vector points of the seam line
|
||||
* @return the vector points of the seam line
|
||||
*/
|
||||
QVector<QPointF> GetSeamLine() const;
|
||||
|
||||
/**
|
||||
* @brief SetSeamLine Sets the vector points of the seam line to the given value
|
||||
* @param seamLine the new vector points for the seam line
|
||||
*/
|
||||
void SetSeamLine(const QVector<QPointF> &seamLine);
|
||||
|
||||
/**
|
||||
* @brief GetShowSeamLine returns wether the seam line of the piece has to be shown or not
|
||||
* @return true if the seamline has to be shown
|
||||
|
@ -94,6 +114,7 @@ private:
|
|||
QUuid m_uuid{QUuid()};
|
||||
QString m_name{QString()};
|
||||
QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
|
||||
QVector<QPointF> m_seamLine{QVector<QPointF>()};
|
||||
bool m_showSeamline{true};
|
||||
bool m_mirrorPiece{false};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user