improve multiple selection and add grainline to pieces
This commit is contained in:
parent
e2b816f192
commit
d72be9029f
|
@ -184,9 +184,17 @@ VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
|
||||||
VPuzzlePiece *piece = new VPuzzlePiece();
|
VPuzzlePiece *piece = new VPuzzlePiece();
|
||||||
piece->SetName(rawPiece.GetName());
|
piece->SetName(rawPiece.GetName());
|
||||||
piece->SetUuid(rawPiece.GetUUID());
|
piece->SetUuid(rawPiece.GetUUID());
|
||||||
|
|
||||||
piece->SetCuttingLine(rawPiece.GetMappedSeamAllowancePoints());
|
piece->SetCuttingLine(rawPiece.GetMappedSeamAllowancePoints());
|
||||||
piece->SetSeamLine(rawPiece.GetMappedContourPoints());
|
piece->SetSeamLine(rawPiece.GetMappedContourPoints());
|
||||||
|
|
||||||
|
piece->SetIsGrainlineEnabled(rawPiece.IsGrainlineEnabled());
|
||||||
|
if(rawPiece.IsGrainlineEnabled())
|
||||||
|
{
|
||||||
|
piece->SetGrainlineAngle(rawPiece.GrainlineAngle());
|
||||||
|
piece->SetGrainline(rawPiece.GetGrainline());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO : set all the information we need for the piece!
|
// TODO : set all the information we need for the piece!
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -339,16 +347,20 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
|
||||||
{
|
{
|
||||||
if(m_selectedPieces.count() == 0)
|
if(m_selectedPieces.count() == 0)
|
||||||
{
|
{
|
||||||
// TODO : update current piece data to show a "no current piece selected"
|
// show the content "no piece selected"
|
||||||
|
|
||||||
ui->containerCurrentPieceNoData->setVisible(true);
|
ui->containerCurrentPieceNoData->setVisible(true);
|
||||||
ui->containerCurrentPieceData->setVisible(false);
|
ui->containerCurrentPieceData->setVisible(false);
|
||||||
|
ui->containerCurrentPieceMultipleData->setVisible(false);
|
||||||
}
|
}
|
||||||
else if(m_selectedPieces.count() == 1)
|
else if(m_selectedPieces.count() == 1)
|
||||||
{
|
{
|
||||||
VPuzzlePiece *selectedPiece = m_selectedPieces.first();
|
// show the content "selected piece data"
|
||||||
|
|
||||||
ui->containerCurrentPieceNoData->setVisible(false);
|
ui->containerCurrentPieceNoData->setVisible(false);
|
||||||
ui->containerCurrentPieceData->setVisible(true);
|
ui->containerCurrentPieceData->setVisible(true);
|
||||||
|
ui->containerCurrentPieceMultipleData->setVisible(false);
|
||||||
|
|
||||||
|
VPuzzlePiece *selectedPiece = m_selectedPieces.first();
|
||||||
|
|
||||||
// set the value to the current piece
|
// set the value to the current piece
|
||||||
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
|
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
|
||||||
|
@ -364,7 +376,13 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO in the future
|
// 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,16 +882,6 @@ void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PuzzleMainWindow::on_PieceSelectionChanged()
|
void PuzzleMainWindow::on_PieceSelectionChanged()
|
||||||
{
|
{
|
||||||
// for now we have only single selection
|
|
||||||
// FIXME / TODO : To be updated when we support multiple selection.
|
|
||||||
|
|
||||||
for (auto piece : m_selectedPieces)
|
|
||||||
{
|
|
||||||
if(piece->GetIsSelected())
|
|
||||||
{
|
|
||||||
piece->SetIsSelected(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_selectedPieces = m_layout->GetSelectedPieces();
|
m_selectedPieces = m_layout->GetSelectedPieces();
|
||||||
|
|
||||||
// update the property of the piece currently selected
|
// update the property of the piece currently selected
|
||||||
|
|
|
@ -228,9 +228,9 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>-542</y>
|
||||||
<width>342</width>
|
<width>342</width>
|
||||||
<height>894</height>
|
<height>1302</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
@ -250,31 +250,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="containerCurrentPieceNoData" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="containerCurrentPieceNoDataLayout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="labelCurrentPieceNoPieceSelected">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>400</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>No piece selected</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="containerCurrentPieceData" native="true">
|
<widget class="QWidget" name="containerCurrentPieceData" native="true">
|
||||||
<layout class="QVBoxLayout" name="containerCurrentPieceDataLayout">
|
<layout class="QVBoxLayout" name="containerCurrentPieceDataLayout">
|
||||||
|
@ -380,6 +355,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionX">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionX">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-10000.000000000000000</double>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>10000.000000000000000</double>
|
<double>10000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
@ -397,6 +375,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionY">
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionY">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-10000.000000000000000</double>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>10000.000000000000000</double>
|
<double>10000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
@ -411,6 +392,53 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="containerCurrentPieceNoData" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="containerCurrentPieceNoDataLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelCurrentPieceNoPieceSelected">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>400</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>No piece selected</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="containerCurrentPieceMultipleData" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelCurrentPieceMultiplePieceSelected">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>400</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Multiple pieces selected</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacerCurrentPiece">
|
<spacer name="verticalSpacerCurrentPiece">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -221,3 +221,9 @@ void VPieceCarrousel::RefreshOrientation()
|
||||||
// FIXME: find a nicer way than putting directly the 120 width of the piece
|
// FIXME: find a nicer way than putting directly the 120 width of the piece
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPieceCarrousel::ClearSelection()
|
||||||
|
{
|
||||||
|
m_layout->ClearSelection();
|
||||||
|
}
|
||||||
|
|
|
@ -72,10 +72,9 @@ public:
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SelectPiece Updates the carrousel so that the given piece is selected
|
* @brief ClearSelection Clears the selection of the carrousel.
|
||||||
* @param piece the piece to select
|
|
||||||
*/
|
*/
|
||||||
void SelectPiece(VPuzzlePiece* piece);
|
void ClearSelection();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vpiececarrousellayer.h"
|
#include "vpiececarrousellayer.h"
|
||||||
|
#include "vpiececarrousel.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -35,9 +37,9 @@
|
||||||
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
|
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent) :
|
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel) :
|
||||||
QWidget(parent),
|
|
||||||
m_layer(layer),
|
m_layer(layer),
|
||||||
|
m_carrousel(carrousel),
|
||||||
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
|
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -80,7 +82,7 @@ void VPieceCarrouselLayer::Refresh()
|
||||||
{
|
{
|
||||||
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
||||||
|
|
||||||
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece);
|
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece, this);
|
||||||
m_carrouselPieces.append(carrouselPiece);
|
m_carrouselPieces.append(carrouselPiece);
|
||||||
layout()->addWidget(carrouselPiece);
|
layout()->addWidget(carrouselPiece);
|
||||||
|
|
||||||
|
@ -98,3 +100,9 @@ QList<VPieceCarrouselPiece*> VPieceCarrouselLayer::GetCarrouselPieces()
|
||||||
return m_carrouselPieces;
|
return m_carrouselPieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPieceCarrousel* VPieceCarrouselLayer::GetCarrousel()
|
||||||
|
{
|
||||||
|
return m_carrousel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,13 @@
|
||||||
#include "vpuzzlelayer.h"
|
#include "vpuzzlelayer.h"
|
||||||
#include "vpiececarrouselpiece.h"
|
#include "vpiececarrouselpiece.h"
|
||||||
|
|
||||||
|
class VPieceCarrousel;
|
||||||
|
|
||||||
class VPieceCarrouselLayer : public QWidget
|
class VPieceCarrouselLayer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent = nullptr);
|
VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel);
|
||||||
~VPieceCarrouselLayer();
|
~VPieceCarrouselLayer();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -45,10 +47,13 @@ public:
|
||||||
|
|
||||||
QList<VPieceCarrouselPiece*> GetCarrouselPieces();
|
QList<VPieceCarrouselPiece*> GetCarrouselPieces();
|
||||||
|
|
||||||
|
VPieceCarrousel* GetCarrousel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPieceCarrouselLayer)
|
Q_DISABLE_COPY(VPieceCarrouselLayer)
|
||||||
|
|
||||||
VPuzzleLayer *m_layer;
|
VPuzzleLayer *m_layer;
|
||||||
|
VPieceCarrousel *m_carrousel;
|
||||||
QList<VPieceCarrouselPiece*> m_carrouselPieces;
|
QList<VPieceCarrouselPiece*> m_carrouselPieces;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "vpuzzlemimedatapiece.h"
|
#include "vpuzzlemimedatapiece.h"
|
||||||
|
#include "vpiececarrousellayer.h"
|
||||||
|
#include "vpiececarrousel.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
@ -44,9 +46,10 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) :
|
VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer) :
|
||||||
QFrame(parent),
|
m_piece(piece),
|
||||||
m_piece(piece)
|
m_carrouselLayer(carrouselLayer),
|
||||||
|
m_dragStart(QPoint())
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -169,10 +172,16 @@ void VPieceCarrouselPiece::mousePressEvent(QMouseEvent *event)
|
||||||
|
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
if(!m_piece->GetIsSelected())
|
if(!(event->modifiers() & Qt::ControlModifier))
|
||||||
{
|
{
|
||||||
|
m_carrouselLayer->GetCarrousel()->ClearSelection();
|
||||||
m_piece->SetIsSelected(true);
|
m_piece->SetIsSelected(true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_piece->SetIsSelected(!m_piece->GetIsSelected());
|
||||||
|
}
|
||||||
|
|
||||||
m_dragStart = event->pos();
|
m_dragStart = event->pos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +199,11 @@ void VPieceCarrouselPiece::mouseMoveEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure the multiple selection is removed
|
||||||
|
m_carrouselLayer->GetCarrousel()->ClearSelection();
|
||||||
|
m_piece->SetIsSelected(true);
|
||||||
|
|
||||||
|
// starts the dragging
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
VPuzzleMimeDataPiece *mimeData = new VPuzzleMimeDataPiece();
|
VPuzzleMimeDataPiece *mimeData = new VPuzzleMimeDataPiece();
|
||||||
mimeData->SetPiecePtr(m_piece);
|
mimeData->SetPiecePtr(m_piece);
|
||||||
|
|
|
@ -37,11 +37,13 @@
|
||||||
#include "vpiececarrouselpiecepreview.h"
|
#include "vpiececarrouselpiecepreview.h"
|
||||||
|
|
||||||
|
|
||||||
|
class VPieceCarrouselLayer;
|
||||||
|
|
||||||
class VPieceCarrouselPiece : public QFrame
|
class VPieceCarrouselPiece : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent = nullptr);
|
explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer);
|
||||||
~VPieceCarrouselPiece();
|
~VPieceCarrouselPiece();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -70,6 +72,9 @@ private:
|
||||||
Q_DISABLE_COPY(VPieceCarrouselPiece)
|
Q_DISABLE_COPY(VPieceCarrouselPiece)
|
||||||
|
|
||||||
VPuzzlePiece *m_piece;
|
VPuzzlePiece *m_piece;
|
||||||
|
|
||||||
|
VPieceCarrouselLayer *m_carrouselLayer;
|
||||||
|
|
||||||
QLabel *m_label{nullptr};
|
QLabel *m_label{nullptr};
|
||||||
VPieceCarrouselPiecePreview *m_piecePreview{nullptr};
|
VPieceCarrouselPiecePreview *m_piecePreview{nullptr};
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@ VPuzzleGraphicsPiece::VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *p
|
||||||
QGraphicsObject(parent),
|
QGraphicsObject(parent),
|
||||||
m_piece(piece),
|
m_piece(piece),
|
||||||
m_cuttingLine(QPainterPath()),
|
m_cuttingLine(QPainterPath()),
|
||||||
m_seamLine(QPainterPath())
|
m_seamLine(QPainterPath()),
|
||||||
|
m_grainline(QPainterPath())
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -63,9 +64,6 @@ void VPuzzleGraphicsPiece::Init()
|
||||||
setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
|
setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
|
||||||
setCursor(QCursor(Qt::OpenHandCursor));
|
setCursor(QCursor(Qt::OpenHandCursor));
|
||||||
|
|
||||||
//setAcceptHoverEvents(true); // maybe we can do some stuff with this
|
|
||||||
|
|
||||||
|
|
||||||
// initialises the seam line
|
// initialises the seam line
|
||||||
QVector<QPointF> seamLinePoints = m_piece->GetSeamLine();
|
QVector<QPointF> seamLinePoints = m_piece->GetSeamLine();
|
||||||
m_seamLine.moveTo(seamLinePoints.first());
|
m_seamLine.moveTo(seamLinePoints.first());
|
||||||
|
@ -78,8 +76,14 @@ void VPuzzleGraphicsPiece::Init()
|
||||||
for (int i = 1; i < cuttingLinepoints.size(); ++i)
|
for (int i = 1; i < cuttingLinepoints.size(); ++i)
|
||||||
m_cuttingLine.lineTo(cuttingLinepoints.at(i));
|
m_cuttingLine.lineTo(cuttingLinepoints.at(i));
|
||||||
|
|
||||||
|
// initialises the grainline
|
||||||
|
QVector<QPointF> grainLinepoints = m_piece->GetGrainline();
|
||||||
|
m_grainline.moveTo(grainLinepoints.first());
|
||||||
|
for (int i = 1; i < grainLinepoints.size(); ++i)
|
||||||
|
m_grainline.lineTo(grainLinepoints.at(i));
|
||||||
|
|
||||||
// TODO : initialises the other elements like grain line, labels, passmarks etc.
|
|
||||||
|
// TODO : initialises the other elements labels, passmarks etc.
|
||||||
|
|
||||||
// Initialises the connectors
|
// Initialises the connectors
|
||||||
connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPuzzleGraphicsPiece::on_PieceSelectionChanged);
|
connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPuzzleGraphicsPiece::on_PieceSelectionChanged);
|
||||||
|
@ -126,47 +130,69 @@ void VPuzzleGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->setBrush(noBrush);
|
painter->setBrush(noBrush);
|
||||||
|
|
||||||
|
// paint the cutting line
|
||||||
if(!m_cuttingLine.isEmpty())
|
if(!m_cuttingLine.isEmpty())
|
||||||
{
|
{
|
||||||
painter->drawPath(m_cuttingLine);
|
painter->drawPath(m_cuttingLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paint the seam line
|
||||||
if(!m_seamLine.isEmpty())
|
if(!m_seamLine.isEmpty())
|
||||||
{
|
{
|
||||||
painter->drawPath(m_seamLine);
|
painter->drawPath(m_seamLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paint the grainline
|
||||||
|
if(!m_grainline.isEmpty())
|
||||||
|
{
|
||||||
|
painter->drawPath(m_grainline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPuzzleGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void VPuzzleGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
bool selectionState = isSelected();
|
||||||
//perform the default behaviour
|
//perform the default behaviour
|
||||||
QGraphicsItem::mousePressEvent(event);
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
|
||||||
// change the cursor when clicking left button
|
// change the cursor when clicking left button
|
||||||
if (!(event->buttons() & Qt::LeftButton))
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
return;
|
setSelected(true);
|
||||||
|
setCursor(Qt::ClosedHandCursor);
|
||||||
|
|
||||||
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
|
{
|
||||||
|
setSelected(!selectionState);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setSelected(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelected(true);
|
|
||||||
|
|
||||||
setCursor(Qt::ClosedHandCursor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
bool selectionState = isSelected();
|
||||||
|
|
||||||
//perform the default behaviour
|
//perform the default behaviour
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
|
||||||
// change the cursor when clicking left button
|
qCDebug(pGraphicsPiece, "piiiiieeece --- mouse release");
|
||||||
if (!(event->buttons() & Qt::LeftButton))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setCursor(Qt::OpenHandCursor);
|
// change the cursor when clicking left button
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
setCursor(Qt::OpenHandCursor);
|
||||||
|
|
||||||
|
qCDebug(pGraphicsPiece, "piiiiieeece --- left button");
|
||||||
|
|
||||||
|
setSelected(selectionState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ private:
|
||||||
|
|
||||||
QPainterPath m_cuttingLine;
|
QPainterPath m_cuttingLine;
|
||||||
QPainterPath m_seamLine;
|
QPainterPath m_seamLine;
|
||||||
|
QPainterPath m_grainline;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPUZZLEGRAPHICSPIECE_H
|
#endif // VPUZZLEGRAPHICSPIECE_H
|
||||||
|
|
|
@ -268,3 +268,12 @@ bool VPuzzleLayout::GetStickyEdges() const
|
||||||
{
|
{
|
||||||
return m_stickyEdges;
|
return m_stickyEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPuzzleLayout::ClearSelection()
|
||||||
|
{
|
||||||
|
for(auto piece : GetSelectedPieces())
|
||||||
|
{
|
||||||
|
piece->SetIsSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -194,6 +194,12 @@ public:
|
||||||
void SetStickyEdges(bool state);
|
void SetStickyEdges(bool state);
|
||||||
bool GetStickyEdges() const;
|
bool GetStickyEdges() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ClearSelection goes through the layers & pieces and calls
|
||||||
|
* SetIsSelected(false) for the pieces that were selected.
|
||||||
|
*/
|
||||||
|
void ClearSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPuzzleLayout)
|
Q_DISABLE_COPY(VPuzzleLayout)
|
||||||
VPuzzleLayer *m_unplacedPiecesLayer;
|
VPuzzleLayer *m_unplacedPiecesLayer;
|
||||||
|
|
|
@ -142,4 +142,7 @@ void VPuzzleMainGraphicsView::AddPiece(VPuzzlePiece *piece, QPointF pos)
|
||||||
item->blockSignals(true);
|
item->blockSignals(true);
|
||||||
piece->SetPosition(pos);
|
piece->SetPosition(pos);
|
||||||
item->blockSignals(false);
|
item->blockSignals(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,9 +152,11 @@ qreal VPuzzlePiece::GetRotation()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPuzzlePiece::SetIsSelected(bool value)
|
void VPuzzlePiece::SetIsSelected(bool value)
|
||||||
{
|
{
|
||||||
m_isSelected = value;
|
if(m_isSelected != value)
|
||||||
|
{
|
||||||
emit SelectionChanged();
|
m_isSelected = value;
|
||||||
|
emit SelectionChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -163,5 +165,38 @@ bool VPuzzlePiece::GetIsSelected()
|
||||||
return m_isSelected;
|
return m_isSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPuzzlePiece::SetIsGrainlineEnabled(bool value)
|
||||||
|
{
|
||||||
|
m_isGrainlineEnabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VPuzzlePiece::GetIsGrainlineEnabled()
|
||||||
|
{
|
||||||
|
return m_isGrainlineEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPuzzlePiece::SetGrainlineAngle(qreal value)
|
||||||
|
{
|
||||||
|
m_grainlineAngle = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal VPuzzlePiece::GetGrainlineAngle()
|
||||||
|
{
|
||||||
|
return m_grainlineAngle;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPuzzlePiece::SetGrainline(QVector<QPointF> grainline)
|
||||||
|
{
|
||||||
|
m_grainline = grainline;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<QPointF> VPuzzlePiece::GetGrainline()
|
||||||
|
{
|
||||||
|
return m_grainline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,42 @@ public:
|
||||||
*/
|
*/
|
||||||
bool GetIsSelected();
|
bool GetIsSelected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SetIsGrainlineEnabled Wether the piece has a grainline or not
|
||||||
|
* @param value true or false
|
||||||
|
*/
|
||||||
|
void SetIsGrainlineEnabled(bool value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetIsGrainlineEnabled Returns wether the grainline is enabled for this piece
|
||||||
|
* @return true if enabled
|
||||||
|
*/
|
||||||
|
bool GetIsGrainlineEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SetGrainlineAngle Sets the angle of the grainline
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetGrainlineAngle(qreal value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetGrainlineAngle Returns the angle of the grainline for this piece
|
||||||
|
* @return the angle
|
||||||
|
*/
|
||||||
|
qreal GetGrainlineAngle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SetGrainline Sets the grainline to the given vector of points
|
||||||
|
* @param grainline the grainline
|
||||||
|
*/
|
||||||
|
void SetGrainline(QVector<QPointF> grainline);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GetGrainline Returns the grainline for this piece
|
||||||
|
* @return the vector
|
||||||
|
*/
|
||||||
|
QVector<QPointF> GetGrainline();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -184,6 +220,10 @@ private:
|
||||||
QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
|
QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
|
||||||
QVector<QPointF> m_seamLine{QVector<QPointF>()};
|
QVector<QPointF> m_seamLine{QVector<QPointF>()};
|
||||||
|
|
||||||
|
QVector<QPointF> m_grainline{QVector<QPointF>()};
|
||||||
|
bool m_isGrainlineEnabled{false};
|
||||||
|
qreal m_grainlineAngle{0};
|
||||||
|
|
||||||
QTransform m_transform{QTransform()};
|
QTransform m_transform{QTransform()};
|
||||||
|
|
||||||
bool m_showSeamline{true};
|
bool m_showSeamline{true};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user