optimization current piece tab

This commit is contained in:
Ronan Le Tiec 2020-05-01 19:08:48 +02:00
parent f5e325a235
commit 9a8fabc25e
8 changed files with 214 additions and 125 deletions

View file

@ -72,7 +72,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa
InitProperties(); InitProperties();
InitPieceCarrousel(); InitPieceCarrousel();
SetPropertiesData(); SetPropertiesData();
} }
@ -328,14 +327,22 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
else else
{ {
// TODO : update current piece data to show a "no current piece selected" // TODO : update current piece data to show a "no current piece selected"
ui->containerCurrentPieceNoData->setVisible(true);
ui->containerCurrentPieceData->setVisible(false);
} }
} }
else else
{ {
ui->containerCurrentPieceNoData->setVisible(false);
ui->containerCurrentPieceData->setVisible(true);
// set the value to the current piece // set the value to the current piece
ui->lineEditCurrentPieceName->setText(m_selectedPiece->GetName()); ui->lineEditCurrentPieceName->setText(m_selectedPiece->GetName());
// TODO: checkbox show seamline, mirror piece, rotation and placement; ui->checkBoxCurrentPieceShowSeamline->setChecked(m_selectedPiece->GetShowSeamLine());
ui->checkBoxCurrentPieceMirrorPiece->setChecked(m_selectedPiece->GetPieceMirrored());
// TODO:rotation and placement;
} }
} }
@ -752,29 +759,19 @@ void PuzzleMainWindow::on_pushButtonLayoutExport_clicked()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked)
{ {
// just for test purpuses, to be removed: if(m_selectedPiece != nullptr)
QMessageBox msgBox; {
msgBox.setText("TODO PuzzleMainWindow::CurrentPieceShowSeamlineChanged"); m_selectedPiece->SetShowSeamLine(checked);
int ret = msgBox.exec(); }
Q_UNUSED(checked);
Q_UNUSED(ret);
// TODO
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked)
{ {
// just for test purpuses, to be removed: if(m_selectedPiece != nullptr)
QMessageBox msgBox; {
msgBox.setText("TODO PuzzleMainWindow::CurrentPieceMirrorPieceChanged"); m_selectedPiece->SetPieceMirrored(checked);
int ret = msgBox.exec(); }
Q_UNUSED(checked);
Q_UNUSED(ret);
// TODO
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -175,7 +175,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -232,8 +232,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>356</width> <width>342</width>
<height>760</height> <height>894</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -254,44 +254,24 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxCurrentPieceInfo"> <widget class="QWidget" name="containerCurrentPieceNoData" native="true">
<property name="title"> <layout class="QVBoxLayout" name="containerCurrentPieceNoDataLayout">
<string>Infos</string> <property name="spacing">
</property> <number>0</number>
<layout class="QFormLayout" name="formLayout_4"> </property>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditCurrentPieceName">
<property name="text">
<string>DummyName</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCurrentPieceName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxCurrentPieceSeamline">
<property name="title">
<string>Seamline</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="QCheckBox" name="checkBoxCurrentPieceShowSeamline"> <widget class="QLabel" name="labelCurrentPieceNoPieceSelected">
<property name="text"> <property name="minimumSize">
<string>Show Seamline</string> <size>
<width>0</width>
<height>400</height>
</size>
</property> </property>
<property name="checked"> <property name="text">
<bool>true</bool> <string>No piece selected</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -299,85 +279,136 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxCurrentPieceGeometry"> <widget class="QWidget" name="containerCurrentPieceData" native="true">
<property name="title"> <layout class="QVBoxLayout" name="containerCurrentPieceDataLayout">
<string>Geometry</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item> <item>
<widget class="QCheckBox" name="checkBoxCurrentPieceMirrorPiece"> <widget class="QGroupBox" name="groupBoxCurrentPieceInfo">
<property name="text"> <property name="title">
<string>Mirror piece</string> <string>Infos</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_4">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditCurrentPieceName">
<property name="text">
<string>DummyName</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCurrentPieceName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> <item>
</widget> <widget class="QGroupBox" name="groupBoxCurrentPieceSeamline">
</item> <property name="title">
<item> <string>Seamline</string>
<widget class="QGroupBox" name="groupBoxCurrentPieceRotation">
<property name="title">
<string>Rotation</string>
</property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="labelCurrentPieceAngle">
<property name="text">
<string>Angle:</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="checkBoxCurrentPieceShowSeamline">
<property name="text">
<string>Show Seamline</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceAngle"> <widget class="QGroupBox" name="groupBoxCurrentPieceGeometry">
<property name="maximum"> <property name="title">
<double>360.000000000000000</double> <string>Geometry</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QCheckBox" name="checkBoxCurrentPieceMirrorPiece">
<property name="text">
<string>Mirror piece</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> <item>
</widget> <widget class="QGroupBox" name="groupBoxCurrentPieceRotation">
</item> <property name="title">
<item> <string>Rotation</string>
<widget class="QGroupBox" name="groupBoxCurrentPiecePlacement">
<property name="title">
<string>Placement</string>
</property>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="labelCurrentPiecePositionX">
<property name="text">
<string>X:</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="labelCurrentPieceAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceAngle">
<property name="maximum">
<double>360.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionX"> <widget class="QGroupBox" name="groupBoxCurrentPiecePlacement">
<property name="maximum"> <property name="title">
<double>10000.000000000000000</double> <string>Placement</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCurrentPiecePositionY">
<property name="text">
<string>Y:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionY">
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property> </property>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="labelCurrentPiecePositionX">
<property name="text">
<string>X:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionX">
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCurrentPiecePositionY">
<property name="text">
<string>Y:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxCurrentPieceBoxPositionY">
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View file

@ -78,3 +78,29 @@ void VPuzzlePiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
{ {
m_cuttingLine = cuttingLine; m_cuttingLine = cuttingLine;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetShowSeamLine()
{
return m_showSeamline;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetShowSeamLine(bool value)
{
m_showSeamline = value;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetPieceMirrored()
{
return m_mirrorPiece;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetPieceMirrored(bool value)
{
m_mirrorPiece = value;
}

View file

@ -65,11 +65,37 @@ public:
void SetCuttingLine(const QVector<QPointF> &cuttingLine); void SetCuttingLine(const QVector<QPointF> &cuttingLine);
/**
* @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
*/
bool GetShowSeamLine();
/**
* @brief SetShowSeamLine sets wether the seam line of the piece has to be shown or not
* @param value true if the seamline has to be shown
*/
void SetShowSeamLine(bool value);
/**
* @brief GetMirrorPiece returns wether the piece is mirrored or not
* @return true if the piece is mirrored
*/
bool GetPieceMirrored();
/**
* @brief SetMirrorPiece sets wether the piece is mirrored or not
* @param value true if the piece will be mirrored
*/
void SetPieceMirrored(bool value);
private: private:
QUuid m_uuid{QUuid()}; QUuid m_uuid{QUuid()};
QString m_name{QString()}; QString m_name{QString()};
QVector<QPointF> m_cuttingLine{QVector<QPointF>()}; QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
bool m_showSeamline{true};
bool m_mirrorPiece{false};
}; };
#endif // VPUZZLEPIECE_H #endif // VPUZZLEPIECE_H

View file

@ -60,4 +60,5 @@ const QString AttrFollowGrainLine = QStringLiteral("followGrainLine");
const QString AttrID = QStringLiteral("id"); const QString AttrID = QStringLiteral("id");
const QString AttrMirrored = QStringLiteral("mirrored"); const QString AttrMirrored = QStringLiteral("mirrored");
const QString AttrTransform = QStringLiteral("transform"); const QString AttrTransform = QStringLiteral("transform");
const QString AttrShowSeamline = QStringLiteral("showSeamline");
} }

View file

@ -65,6 +65,7 @@ extern const QString AttrFollowGrainLine;
extern const QString AttrID; extern const QString AttrID;
extern const QString AttrMirrored; extern const QString AttrMirrored;
extern const QString AttrTransform; extern const QString AttrTransform;
extern const QString AttrShowSeamline;
} }

View file

@ -249,9 +249,15 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece)
QXmlStreamAttributes attribs = attributes(); QXmlStreamAttributes attribs = attributes();
piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece")));
QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here? QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here?
piece->SetUuid(QUuid(uuidStr)); piece->SetUuid(QUuid(uuidStr));
bool showSeamline = ReadAttributeBool(attribs, ML::AttrShowSeamline, trueStr);
piece->SetShowSeamLine(showSeamline);
bool pieceMirrored = ReadAttributeBool(attribs, ML::AttrMirrored, falseStr);
piece->SetPieceMirrored(pieceMirrored);
// TODO read the further attributes // TODO read the further attributes

View file

@ -165,7 +165,8 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece)
writeStartElement(ML::TagPiece); writeStartElement(ML::TagPiece);
SetAttribute(ML::AttrID, piece->GetUuid().toString()); SetAttribute(ML::AttrID, piece->GetUuid().toString());
SetAttribute(ML::AttrName, piece->GetName()); SetAttribute(ML::AttrName, piece->GetName());
SetAttribute(ML::AttrMirrored, "false"); // TODO / Fixme get the right value SetAttribute(ML::AttrMirrored, piece->GetPieceMirrored()); // TODO / Fixme get the right value
SetAttribute(ML::AttrShowSeamline, piece->GetShowSeamLine()); // TODO / Fixme get the right value
SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value
// TODO cuttingLine // TODO cuttingLine