Dialog Pin tool.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-31 14:28:48 +02:00
parent 637eaa4256
commit b9d635dab2
23 changed files with 663 additions and 26 deletions

View File

@ -76,7 +76,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser()
void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
switch (item->type())
{
@ -203,7 +203,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
}
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
switch (currentItem->type())
{
@ -348,7 +348,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property)
}
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
switch (currentItem->type())
{

View File

@ -212,7 +212,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
QString DialogHistory::Record(const VToolRecord &tool)
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in history.");
const QDomElement domElem = doc->elementById(tool.getId());
if (domElem.isElement() == false)
@ -405,6 +405,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::FlippingByAxis:
case Tool::Move:
case Tool::PiecePath:
case Tool::Pin:
return QString();
}
}

View File

@ -576,6 +576,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
dialogTool->Build(t);
break;
case Tool::PiecePath:
case Tool::Pin:
dialogTool->SetPiecesList(doc->GetActivePPPieces());
break;
default:
@ -995,6 +996,14 @@ void MainWindow::ToolPiecePath(bool checked)
&MainWindow::ClosedDialogPiecePath);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPin(bool checked)
{
ToolSelectAllDrawObjects();
SetToolButton<DialogPin>(checked, Tool::Pin, "://cursor/pin_cursor.png", tr("Select pin point"),
&MainWindow::ClosedDialogPin);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ToolHeight handler tool height.
@ -1144,6 +1153,18 @@ void MainWindow::ClosedDialogPiecePath(int result)
doc->LiteParseTree(Document::LiteParse);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ClosedDialogPin(int result)
{
// SCASSERT(dialogTool != nullptr);
// if (result == QDialog::Accepted)
// {
// VToolPin::Create(dialogTool, sceneDetails, doc, pattern);
// }
ArrowTool();
// doc->LiteParseTree(Document::LiteParse);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ToolCutArc handler tool cutArc.
@ -1760,7 +1781,7 @@ void MainWindow::InitToolButtons()
}
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Check if all tools were connected.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Check if all tools were connected.");
connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine);
connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine);
@ -1806,6 +1827,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint);
connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs);
connect(ui->toolButtonEllipticalArc, &QToolButton::clicked, this, &MainWindow::ToolEllipticalArc);
connect(ui->toolButtonPin, &QToolButton::clicked, this, &MainWindow::ToolPin);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1833,7 +1855,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
void MainWindow::CancelTool()
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
@ -1989,6 +2011,9 @@ void MainWindow::CancelTool()
case Tool::EllipticalArc:
ui->toolButtonEllipticalArc->setChecked(false);
break;
case Tool::Pin:
ui->toolButtonPin->setChecked(false);
break;
}
// Crash: using CRTL+Z while using line tool.
@ -3040,7 +3065,7 @@ void MainWindow::SetEnableTool(bool enable)
}
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
//Drawing Tools
ui->toolButtonEndLine->setEnabled(drawTools);
@ -3081,6 +3106,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonMove->setEnabled(drawTools);
ui->toolButtonMidpoint->setEnabled(drawTools);
ui->toolButtonEllipticalArc->setEnabled(drawTools);
ui->toolButtonPin->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools);
@ -3362,7 +3388,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
void MainWindow::LastUsedTool()
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
if (currentTool == lastUsedTool)
{
@ -3549,6 +3575,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonEllipticalArc->setChecked(true);
ToolEllipticalArc(true);
break;
case Tool::Pin:
ui->toolButtonPin->setChecked(true);
ToolPin(true);
break;
}
}

View File

@ -138,6 +138,7 @@ private slots:
void ToolPointOfContact(bool checked);
void ToolDetail(bool checked);
void ToolPiecePath(bool checked);
void ToolPin(bool checked);
void ToolHeight(bool checked);
void ToolTriangle(bool checked);
void ToolPointOfIntersection(bool checked);
@ -171,6 +172,7 @@ private slots:
void ClosedDialogUnionDetails(int result);
void ClosedDialogGroup(int result);
void ClosedDialogPiecePath(int result);
void ClosedDialogPin(int result);
void LoadIndividual();
void LoadStandard();

View File

@ -48,7 +48,7 @@
<string>Tools</string>
</property>
<property name="currentIndex">
<number>5</number>
<number>6</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -1144,7 +1144,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
<height>326</height>
</rect>
</property>
<attribute name="icon">
@ -1449,6 +1449,32 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="toolButtonPin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Pin tool</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/pin.png</normaloff>:/toolicon/32x32/pin.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutPage">
@ -1457,7 +1483,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
<height>326</height>
</rect>
</property>
<attribute name="icon">
@ -2574,8 +2600,8 @@
</customwidget>
</customwidgets>
<resources>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
<include location="share/resources/toolicon.qrc"/>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -80,5 +80,7 @@
<file>cursor/el_arc_cursor@2x.png</file>
<file>cursor/path_cursor.png</file>
<file>cursor/path_cursor@2x.png</file>
<file>cursor/pin_cursor.png</file>
<file>cursor/pin_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -78,5 +78,7 @@
<file>toolicon/32x32/el_arc@2x.png</file>
<file>toolicon/32x32/path.png</file>
<file>toolicon/32x32/path@2x.png</file>
<file>toolicon/32x32/pin.png</file>
<file>toolicon/32x32/pin@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
version="1.1"
width="24"
id="svg14"
sodipodi:docname="pin.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina_cpoint/valentina/src/app/valentina/share/resources/toolicon/32x32/pin@2x.png"
inkscape:export-xdpi="256"
inkscape:export-ydpi="256"
inkscape:version="0.92.0 unknown">
<metadata
id="metadata20">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs18" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1460"
inkscape:window-height="829"
id="namedview16"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="-8.0847458"
inkscape:cy="12"
inkscape:window-x="75"
inkscape:window-y="34"
inkscape:window-maximized="0"
inkscape:current-layer="svg14" />
<g
transform="matrix(1.080652,0,0,1.0806515,-1.8456748,-1111.4295)"
id="g12">
<g
transform="matrix(0.70711,0.70711,-0.70711,0.70711,737.68,297.72)"
id="g10">
<path
d="m 11,1028.4 v 13 h 1 6.406 c -0.595,-1.1 -1.416,-2.1 -2.406,-2.8 v -8 c 0.616,-0.6 1.131,-1.4 1.531,-2.2 H 12 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:#c0392b" />
<path
d="m 11,13 v 2 4 2 l 1,2 v -2 -6 -2 z"
transform="translate(0,1028.4)"
id="path4"
inkscape:connector-curvature="0"
style="fill:#bdc3c7" />
<path
d="m 12,13 v 2 4 2 2 l 1,-2 v -2 -4 -2 z"
transform="translate(0,1028.4)"
id="path6"
inkscape:connector-curvature="0"
style="fill:#7f8c8d" />
<path
d="m 6.4688,1028.4 c 0.4006,0.8 0.915,1.6 1.5312,2.2 v 8 c -0.9897,0.7 -1.8113,1.7 -2.4062,2.8 H 12 v -13 z"
id="path8"
inkscape:connector-curvature="0"
style="fill:#e74c3c" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -3726,7 +3726,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
QRectF VPattern::ActiveDrawBoundingRect() const
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used.");
QRectF rec;
@ -3860,6 +3860,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::NodeSplinePath:
case Tool::Group:
case Tool::PiecePath:
case Tool::Pin:
break;
}
}

View File

@ -1588,7 +1588,7 @@ QStringList VAbstractPattern::ListPointExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment a number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1660,7 +1660,7 @@ QStringList VAbstractPattern::ListArcExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1714,7 +1714,7 @@ QStringList VAbstractPattern::ListElArcExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagElArc);
@ -1785,7 +1785,7 @@ QStringList VAbstractPattern::ListPathPointExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1852,7 +1852,7 @@ QStringList VAbstractPattern::ListOperationExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagOperation);
@ -1907,7 +1907,7 @@ QStringList VAbstractPattern::ListPathExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPath);
@ -1960,7 +1960,7 @@ QStringList VAbstractPattern::ListPieceExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 51);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagDetail);

View File

@ -147,6 +147,7 @@ enum class Tool : ToolVisHolderType
Move,
Midpoint,
EllipticalArc,
Pin,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};
@ -193,7 +194,8 @@ enum class Vis : ToolVisHolderType
ToolMove,
ToolEllipticalArc,
ToolPiece,
ToolPiecePath
ToolPiecePath,
ToolPin
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, CurveCLength, LineAngle, CurveAngle,

View File

@ -43,7 +43,8 @@ HEADERS += \
$$PWD/tools/dialogmove.h \
$$PWD/tools/dialogellipticalarc.h \
$$PWD/tools/dialogseamallowance.h \
$$PWD/tools/dialogpiecepath.h
$$PWD/tools/dialogpiecepath.h \
$$PWD/tools/dialogpin.h
SOURCES += \
$$PWD/tools/dialogalongline.cpp \
@ -86,7 +87,8 @@ SOURCES += \
$$PWD/tools/dialogmove.cpp \
$$PWD/tools/dialogellipticalarc.cpp \
$$PWD/tools/dialogseamallowance.cpp \
$$PWD/tools/dialogpiecepath.cpp
$$PWD/tools/dialogpiecepath.cpp \
$$PWD/tools/dialogpin.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -128,4 +130,5 @@ FORMS += \
$$PWD/tools/dialogmove.ui \
$$PWD/tools/dialogellipticalarc.ui \
$$PWD/tools/dialogseamallowance.ui \
$$PWD/tools/dialogpiecepath.ui
$$PWD/tools/dialogpiecepath.ui \
$$PWD/tools/dialogpin.ui

View File

@ -67,6 +67,7 @@
#include "tools/dialogmove.h"
#include "tools/dialogellipticalarc.h"
#include "tools/dialogpiecepath.h"
#include "tools/dialogpin.h"
#include "support/dialogeditwrongformula.h"
#include "support/dialogundo.h"

View File

@ -0,0 +1,204 @@
/************************************************************************
**
** @file dialogpin.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 1, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <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/>.
**
*************************************************************************/
#include "dialogpin.h"
#include "ui_dialogpin.h"
#include "visualization/line/vistoolpin.h"
#include "../../tools/vabstracttool.h"
#include "../../tools/vtoolseamallowance.h"
//---------------------------------------------------------------------------------------------------------------------
DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogPin),
m_showMode(false),
m_flagPoint(false)
{
ui->setupUi(this);
InitOkCancel(ui);
FillComboBoxPoints(ui->comboBoxPoint);
flagError = false;
CheckState();
vis = new VisToolPin(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPin::~DialogPin()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::EnbleShowMode(bool disable)
{
m_showMode = disable;
ui->comboBoxPiece->setDisabled(m_showMode);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPin::GetPieceId() const
{
return getCurrentObjectId(ui->comboBoxPiece);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::SetPieceId(quint32 id)
{
if (ui->comboBoxPiece->count() <= 0)
{
const VPiece piece = data->GetPiece(id);
ui->comboBoxPiece->addItem(piece.GetName(), id);
}
else
{
const qint32 index = ui->comboBoxPiece->findData(id);
if (index != -1)
{
ui->comboBoxPiece->setCurrentIndex(index);
}
else
{
ui->comboBoxPiece->setCurrentIndex(0);
}
}
CheckPieces();
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPin::GetPointId() const
{
return getCurrentObjectId(ui->comboBoxPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::SetPointId(quint32 id)
{
setCurrentPointId(ui->comboBoxPoint, id);
VisToolPin *point = qobject_cast<VisToolPin *>(vis);
SCASSERT(point != nullptr)
point->setObject1Id(id);
CheckPoint();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::SetPiecesList(const QVector<quint32> &list)
{
for (int i=0; i < list.size(); ++i)
{
const VPiece piece = data->GetPiece(list.at(i));
ui->comboBoxPiece->addItem(piece.GetName(), list.at(i));
}
CheckPieces();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare)
{
if (type == SceneObject::Point)
{
if (SetObject(id, ui->comboBoxPoint, ""))
{
vis->VisualMode(id);
CheckPoint();
prepare = true;
this->setModal(true);
this->show();
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(m_flagPoint && flagError);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::ShowVisualization()
{
AddVisualization<VisToolPin>();
if (m_showMode)
{
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(GetPieceId()));
SCASSERT(tool != nullptr);
auto visPoint = qobject_cast<VisToolPin *>(vis);
SCASSERT(visPoint != nullptr);
visPoint->setParentItem(tool);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::CheckPieces()
{
if (not m_showMode)
{
QColor color = okColor;
if (ui->comboBoxPiece->count() <= 0)
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelPiece, color);
CheckState();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::CheckPoint()
{
QColor color = okColor;
if (ui->comboBoxPoint->currentIndex() != -1)
{
m_flagPoint = true;
color = okColor;
}
else
{
m_flagPoint = false;
color = errorColor;
}
ChangeColor(ui->labelPoint, color);
CheckState();
}

View File

@ -0,0 +1,73 @@
/************************************************************************
**
** @file dialogpin.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 1, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <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 DIALOGPIN_H
#define DIALOGPIN_H
#include "dialogtool.h"
namespace Ui
{
class DialogPin;
}
class DialogPin : public DialogTool
{
Q_OBJECT
public:
explicit DialogPin(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogPin();
void EnbleShowMode(bool disable);
quint32 GetPieceId() const;
void SetPieceId(quint32 id);
quint32 GetPointId() const;
void SetPointId(quint32 id);
virtual void SetPiecesList(const QVector<quint32> &list) Q_DECL_OVERRIDE;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
protected:
virtual void CheckState() Q_DECL_OVERRIDE;
virtual void ShowVisualization() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(DialogPin)
Ui::DialogPin *ui;
bool m_showMode;
bool m_flagPoint;
void CheckPieces();
void CheckPoint();
};
#endif // DIALOGPIN_H

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPin</class>
<widget class="QDialog" name="DialogPin">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>114</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="toolTip">
<string>Pin tool</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelPoint">
<property name="text">
<string>Point:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxPoint"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelPiece">
<property name="text">
<string>Piece:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxPiece"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPin</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPin</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,65 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 1, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <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/>.
**
*************************************************************************/
#include "vistoolpin.h"
#include "../vwidgets/vsimplepoint.h"
#include "../vgeometry/vpointf.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolPin::VisToolPin(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent),
m_point(nullptr)
{
this->mainColor = Qt::red;
this->setZValue(2);// Show on top real tool
m_point = new VSimplePoint(NULL_ID, mainColor, *Visualization::data->GetPatternUnit(), &factor);
m_point->SetPointHighlight(true);
m_point->setParentItem(this);
m_point->SetVisualizationMode(true);
m_point->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPin::~VisToolPin()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPin::RefreshGeometry()
{
if (object1Id > NULL_ID)
{
const QSharedPointer<VPointF> point = Visualization::data->GeometricObject<VPointF>(object1Id);
m_point->SetOnlyPoint(mode == Mode::Creation);
m_point->RefreshGeometry(*point);
m_point->setVisible(true);
}
}

View File

@ -0,0 +1,51 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 1, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <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 VISTOOLPIN_H
#define VISTOOLPIN_H
#include "visline.h"
class VSimplePoint;
class VisToolPin : public VisLine
{
Q_OBJECT
public:
explicit VisToolPin(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPin() Q_DECL_OVERRIDE;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPin)};
private:
Q_DISABLE_COPY(VisToolPin)
VSimplePoint *m_point;
};
#endif // VISTOOLPIN_H

View File

@ -40,7 +40,8 @@ HEADERS += \
$$PWD/line/operation/vistoolmove.h \
$$PWD/path/vistoolellipticalarc.h \
$$PWD/path/vistoolpiece.h \
$$PWD/path/vistoolpiecepath.h
$$PWD/path/vistoolpiecepath.h \
$$PWD/line/vistoolpin.h
SOURCES += \
$$PWD/visualization.cpp \
@ -81,4 +82,5 @@ SOURCES += \
$$PWD/line/operation/vistoolmove.cpp \
$$PWD/path/vistoolellipticalarc.cpp \
$$PWD/path/vistoolpiece.cpp \
$$PWD/path/vistoolpiecepath.cpp
$$PWD/path/vistoolpiecepath.cpp \
$$PWD/line/vistoolpin.cpp