Dialog Group.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-04-05 20:14:12 +03:00
parent 844d3764c2
commit ada64305c0
30 changed files with 453 additions and 49 deletions

View file

@ -74,7 +74,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) == 41, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
switch (item->type())
{
@ -191,7 +191,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) == 41, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -323,7 +323,7 @@ void VToolOptionsPropertyBrowser::userChangedData(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) == 41, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
switch (currentItem->type())
{

View file

@ -208,7 +208,7 @@ void DialogHistory::FillTable()
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) == 41, "Not all tools was used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in history.");
const QDomElement domElem = doc->elementById(tool.getId());
if (domElem.isElement() == false)
@ -383,6 +383,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
case Tool::Group:
return QString();
}
}

View file

@ -305,6 +305,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection);
connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection);
connect(this, &MainWindow::EnableLineSelection, sceneDraw, &VMainGraphicsScene::ToggleLineSelection);
connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection);
connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection);
connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection);
@ -551,6 +552,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
SCASSERT(scene != nullptr);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
ui->view->itemClicked(nullptr);
@ -906,7 +908,7 @@ void MainWindow::ToolPointOfContact(bool checked)
*/
void MainWindow::ToolDetail(bool checked)
{
ToolSelectAllObjects();
ToolSelectAllDrawObjects();
SetToolButton<DialogDetail>(checked, Tool::Detail, "://cursor/new_detail_cursor.png",
tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail);
}
@ -991,6 +993,33 @@ void MainWindow::ClosedDialogUnionDetails(int result)
doc->LiteParseTree(Document::LiteParse);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolGroup(bool checked)
{
ToolSelectGroupObjects();
SetToolButton<DialogGroup>(checked, Tool::Group, ":/cursor/group_plus_cursor.png",
tr("Select objects, <b>Enter</b> - finish creation"), &MainWindow::ClosedDialogGroup);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ClosedDialogGroup(int result)
{
SCASSERT(dialogTool != nullptr);
if (result == QDialog::Accepted)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr);
DialogGroup *dialog = qobject_cast<DialogGroup*>(dialogTool);
SCASSERT(dialog != nullptr);
const QString name = dialog->GetName();
const QMap<quint32, quint32> group = dialog->GetGroup();
const quint32 id = pattern->getNextId();
doc->AddGroup(id, name, group);
}
ArrowTool();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ToolCutArc handler tool cutArc.
@ -1018,7 +1047,7 @@ void MainWindow::ToolLineIntersectAxis(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCurveIntersectAxis(bool checked)
{
ToolSelectAllObjects();
ToolSelectAllDrawObjects();
SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis,
":/cursor/curve_intersect_axis_cursor.png",
tr("Select curve"),
@ -1029,7 +1058,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolArcIntersectAxis(bool checked)
{
ToolSelectAllObjects();
ToolSelectAllDrawObjects();
// Reuse ToolCurveIntersectAxis but with different cursor and tool tip
SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis,
":/cursor/arc_intersect_axis_cursor.png",
@ -1739,7 +1768,7 @@ void MainWindow::mouseMove(const QPointF &scenePos)
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) == 41, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
@ -1863,6 +1892,9 @@ void MainWindow::CancelTool()
case Tool::TrueDarts:
ui->toolButtonTrueDarts->setChecked(false);
break;
case Tool::Group:
ui->toolButtonGroup->setChecked(false);
break;
}
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
@ -1895,6 +1927,7 @@ void MainWindow::ArrowTool()
// Only true for rubber band selection
emit EnableLabelSelection(true);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -3317,7 +3350,7 @@ void MainWindow::CreateMenus()
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) == 41, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled.");
if (currentTool == lastUsedTool)
{
@ -3464,6 +3497,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonTrueDarts->setChecked(true);
ToolTrueDarts(true);
break;
case Tool::Group:
ui->toolButtonGroup->setChecked(true);
ToolGroup(true);
break;
}
}
@ -4460,6 +4497,7 @@ void MainWindow::ToolSelectPoint() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4495,6 +4533,7 @@ void MainWindow::ToolSelectSpline() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4518,6 +4557,7 @@ void MainWindow::ToolSelectSplinePath() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4541,6 +4581,7 @@ void MainWindow::ToolSelectArc() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4564,6 +4605,7 @@ void MainWindow::ToolSelectPointArc() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4587,6 +4629,7 @@ void MainWindow::ToolSelectCurve() const
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4605,11 +4648,12 @@ void MainWindow::ToolSelectCurve() const
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectAllObjects() const
void MainWindow::ToolSelectAllDrawObjects() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4627,6 +4671,30 @@ void MainWindow::ToolSelectAllObjects() const
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectGroupObjects() const
{
// Only true for rubber band selection
emit EnableLabelSelection(true);
emit EnablePointSelection(true);
emit EnableLineSelection(true);
emit EnableArcSelection(true);
emit EnableSplineSelection(true);
emit EnableSplinePathSelection(true);
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(true);
emit EnableArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectDetail() const
{

View file

@ -120,6 +120,7 @@ public slots:
void ToolTriangle(bool checked);
void ToolPointOfIntersection(bool checked);
void ToolUnionDetails(bool checked);
void ToolGroup(bool checked);
void ToolCutArc(bool checked);
void ToolLineIntersectAxis(bool checked);
void ToolCurveIntersectAxis(bool checked);
@ -134,6 +135,7 @@ public slots:
void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result);
void ClosedDialogGroup(int result);
//tmp
void LastUsedTool();
@ -161,6 +163,7 @@ signals:
void EnableLabelSelection(bool enable) const;
void EnablePointSelection(bool enable) const;
void EnableLineSelection(bool enable) const;
void EnableArcSelection(bool enable) const;
void EnableSplineSelection(bool enable) const;
void EnableSplinePathSelection(bool enable) const;
@ -360,7 +363,8 @@ private:
void ToolSelectArc() const;
void ToolSelectPointArc() const;
void ToolSelectCurve() const;
void ToolSelectAllObjects() const;
void ToolSelectAllDrawObjects() const;
void ToolSelectGroupObjects() const;
void ToolSelectDetail() const;
};

View file

@ -64,5 +64,7 @@
<file>cursor/cubic_bezier_cursor@2x.png</file>
<file>cursor/cubic_bezier_path_cursor.png</file>
<file>cursor/cubic_bezier_path_cursor@2x.png</file>
<file>cursor/group_plus_cursor.png</file>
<file>cursor/group_plus_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -3123,7 +3123,7 @@ void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
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) == 41, "Not all tools was used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used.");
QRectF rec;
@ -3237,6 +3237,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
case Tool::Group:
break;
}
}

View file

@ -1355,3 +1355,9 @@ QDomElement VAbstractPattern::GetDraw(const QString &name) const
}
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group)
{
}

View file

@ -114,6 +114,8 @@ public:
QDomElement GetDraw(const QString &name) const;
void AddGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &group);
static const QString TagPattern;
static const QString TagCalculation;
static const QString TagModeling;

View file

@ -101,6 +101,7 @@ enum class Tool : ToolVisHolderType
PointFromArcAndTangent,
TrueDarts,
UnionDetails,
Group,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};

View file

@ -36,7 +36,8 @@ HEADERS += \
$$PWD/tools/dialogtruedarts.h \
$$PWD/tools/dialogpointofintersectioncurves.h \
$$PWD/tools/dialogcubicbezier.h \
$$PWD/tools/dialogcubicbezierpath.h
$$PWD/tools/dialogcubicbezierpath.h \
$$PWD/tools/dialoggroup.h
SOURCES += \
$$PWD/tools/dialogalongline.cpp \
@ -72,7 +73,8 @@ SOURCES += \
$$PWD/tools/dialogtruedarts.cpp \
$$PWD/tools/dialogpointofintersectioncurves.cpp \
$$PWD/tools/dialogcubicbezier.cpp \
$$PWD/tools/dialogcubicbezierpath.cpp
$$PWD/tools/dialogcubicbezierpath.cpp \
$$PWD/tools/dialoggroup.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -107,4 +109,5 @@ FORMS += \
$$PWD/tools/dialogtruedarts.ui \
$$PWD/tools/dialogpointofintersectioncurves.ui \
$$PWD/tools/dialogcubicbezier.ui \
$$PWD/tools/dialogcubicbezierpath.ui
$$PWD/tools/dialogcubicbezierpath.ui \
$$PWD/tools/dialoggroup.ui

View file

@ -60,6 +60,7 @@
#include "dialogs/tools/dialogpointfromcircleandtangent.h"
#include "dialogs/tools/dialogpointfromarcandtangent.h"
#include "dialogs/tools/dialogtruedarts.h"
#include "dialogs/tools/dialoggroup.h"
#include "dialogs/support/dialogeditwrongformula.h"
#include "dialogs/support/dialogundo.h"

View file

@ -0,0 +1,106 @@
/************************************************************************
**
** @file dialoggroup.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 4 4, 2016
**
** @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) 2016 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 "dialoggroup.h"
#include "ui_dialoggroup.h"
#include "../vtools/tools/drawTools/drawtools.h"
//---------------------------------------------------------------------------------------------------------------------
DialogGroup::DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogGroup),
group()
{
ui->setupUi(this);
InitOkCancel(ui);
CheckState();
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogGroup::NameChanged);
}
//---------------------------------------------------------------------------------------------------------------------
DialogGroup::~DialogGroup()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogGroup::SetName(const QString &name)
{
ui->lineEditName->setText(name);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogGroup::GetName() const
{
return ui->lineEditName->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogGroup::ShowDialog(bool click)
{
if (not click)
{
if (group.isEmpty())
{
return;
}
SetName(tr("New group"));
setModal(true);
emit ToolTip("");
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogGroup::SelectedObject(bool selected, quint32 object, quint32 tool)
{
if (selected)
{
group.insert(object, tool);
}
else
{
group.remove(object);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogGroup::NameChanged()
{
ui->lineEditName->text().isEmpty() ? flagName = false : flagName = true;
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
QMap<quint32, quint32> DialogGroup::GetGroup() const
{
return group;
}

View file

@ -0,0 +1,66 @@
/************************************************************************
**
** @file dialoggroup.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 4 4, 2016
**
** @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) 2016 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 DIALOGGROUP_H
#define DIALOGGROUP_H
#include "dialogtool.h"
namespace Ui
{
class DialogGroup;
}
class DialogGroup : public DialogTool
{
Q_OBJECT
public:
explicit DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogGroup();
void SetName(const QString &name);
QString GetName() const;
QMap<quint32, quint32> GetGroup() const;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
public slots:
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE;
private slots:
void NameChanged();
private:
Q_DISABLE_COPY(DialogGroup)
Ui::DialogGroup *ui;
QMap<quint32, quint32> group;
};
#endif // DIALOGGROUP_H

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogGroup</class>
<widget class="QDialog" name="DialogGroup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>80</height>
</rect>
</property>
<property name="windowTitle">
<string>Group</string>
</property>
<property name="windowIcon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Group name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditName">
<property name="toolTip">
<string>Unique pattern piece name</string>
</property>
<property name="placeholderText">
<string>Choose group name</string>
</property>
</widget>
</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>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogGroup</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>DialogGroup</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

@ -694,6 +694,14 @@ void DialogTool::ChosenObject(quint32 id, const SceneObject &type)
Q_UNUSED(type);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SelectedObject(bool selected, quint32 object, quint32 tool)
{
Q_UNUSED(selected);
Q_UNUSED(object);
Q_UNUSED(tool);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NamePointChanged check name of point

View file

@ -92,6 +92,7 @@ signals:
public slots:
void ShowVisToolTip(const QString &toolTip);
virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void SelectedObject(bool selected, quint32 object, quint32 tool);
void NamePointChanged();
virtual void DialogAccepted();
/**

View file

@ -166,15 +166,7 @@ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, c
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
emit ChangedToolSelection(value.toBool(), id, id);
}
return QGraphicsItem::itemChange(change, value);

View file

@ -42,6 +42,7 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin
firstPoint = new VSimplePoint(p1id, QColor(baseColor), *data->GetPatternUnit(), &factor);
firstPoint->setParentItem(this);
connect(firstPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point1Choosed);
connect(firstPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point1Selected);
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition);
@ -50,6 +51,7 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin
secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor);
secondPoint->setParentItem(this);
connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed);
connect(secondPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point2Selected);
connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition);
@ -138,6 +140,18 @@ void VToolDoublePoint::Point2Choosed()
emit ChoosedTool(p2id, SceneObject::Point);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Point1Selected(bool selected)
{
emit ChangedToolSelection(selected, p1id, id);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Point2Selected(bool selected)
{
emit ChangedToolSelection(selected, p2id, id);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::FullUpdateFromFile()
{

View file

@ -64,6 +64,8 @@ public slots:
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
void Point1Choosed();
void Point2Choosed();
void Point1Selected(bool selected);
void Point2Selected(bool selected);
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;

View file

@ -270,15 +270,10 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
namePoint->blockSignals(true);
namePoint->setSelected(value.toBool());
namePoint->blockSignals(false);
emit ChangedToolSelection(value.toBool(), id, id);
}
return QGraphicsEllipseItem::itemChange(change, value);

View file

@ -61,6 +61,9 @@ public:
QString GetLineColor() const;
virtual void SetLineColor(const QString &value);
signals:
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
public slots:
virtual void ShowTool(quint32 id, bool enable);
virtual void ChangedActivDraw(const QString &newName);
@ -238,6 +241,7 @@ void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool)
SCASSERT(tool != nullptr);
QObject::connect(tool, &T::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QObject::connect(tool, &T::ChangedToolSelection, scene, &VMainGraphicsScene::SelectedItem);
QObject::connect(scene, &VMainGraphicsScene::NewFactor, tool, &T::SetFactor);
QObject::connect(scene, &VMainGraphicsScene::DisableItem, tool, &T::Disable);
QObject::connect(scene, &VMainGraphicsScene::EnableToolMove, tool, &T::EnableToolMove);

View file

@ -149,9 +149,8 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
{
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation);
scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable);
InitDrawToolConnections(scene, line);
connect(scene, &VMainGraphicsScene::EnablePointItemSelection, line, &VToolLine::AllowSelecting);
connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
doc->AddTool(id, line);
@ -327,15 +326,7 @@ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const Q
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
emit ChangedToolSelection(value.toBool(), id, id);
}
return QGraphicsItem::itemChange(change, value);

View file

@ -152,6 +152,10 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
changeFinished = true;
}
}
if (change == QGraphicsItem::ItemSelectedChange)
{
emit PointSelected(value.toBool());
}
return QGraphicsItem::itemChange(change, value);
}

View file

@ -63,6 +63,7 @@ signals:
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
void DeleteTool();
void PointChoosed();
void PointSelected(bool selected);
protected:
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event ) Q_DECL_OVERRIDE;

View file

@ -258,6 +258,12 @@ void VMainGraphicsScene::ChoosedItem(quint32 id, const SceneObject &type)
emit ChoosedObject(id, type);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::SelectedItem(bool selected, quint32 object, quint32 tool)
{
emit SelectedObject(selected, object, tool);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
@ -299,6 +305,12 @@ void VMainGraphicsScene::TogglePointSelection(bool enabled)
emit EnablePointItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLineSelection(bool enabled)
{
emit EnableLineItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleArcSelection(bool enabled)
{

View file

@ -55,6 +55,7 @@ public:
void SetOriginsVisible(bool visible);
public slots:
void ChoosedItem(quint32 id, const SceneObject &type);
void SelectedItem(bool selected, quint32 object, quint32 tool);
void SetFactor(qreal factor);
void EnableItemMove(bool move);
void EnableDetailsMode(bool mode);
@ -62,6 +63,7 @@ public slots:
void ToggleLabelSelection(bool enabled);
void TogglePointSelection(bool enabled);
void ToggleLineSelection(bool enabled);
void ToggleArcSelection(bool enabled);
void ToggleSplineSelection(bool enabled);
void ToggleSplinePathSelection(bool enabled);
@ -98,6 +100,7 @@ signals:
* @param type object scene type.
*/
void ChoosedObject(quint32 id, SceneObject type);
void SelectedObject(bool selected, quint32 object, quint32 tool);
/**
* @brief NewFactor send new scale factor.
* @param factor scene scale factor.
@ -110,6 +113,7 @@ signals:
void EnableLabelItemSelection(bool enable);
void EnablePointItemSelection(bool enable);
void EnableLineItemSelection(bool enable);
void EnableArcItemSelection(bool enable);
void EnableSplineItemSelection(bool enable);
void EnableSplinePathItemSelection(bool enable);

View file

@ -46,6 +46,7 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor &currentColor, Unit patternU
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VSimplePoint::DeleteFromLabel);
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VSimplePoint::PointChoosed);
connect(namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VSimplePoint::PointSelected);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VSimplePoint::ChangedPosition);
lineName = new QGraphicsLineItem(this);
this->setBrush(QBrush(Qt::NoBrush));
@ -165,6 +166,12 @@ void VSimplePoint::PointChoosed()
emit Choosed(id);
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::PointSelected(bool selected)
{
emit Selected(selected, id);
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::ChangedPosition(const QPointF &pos)
{
@ -222,6 +229,20 @@ void VSimplePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsEllipseItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
QVariant VSimplePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
namePoint->blockSignals(true);
namePoint->setSelected(value.toBool());
namePoint->blockSignals(false);
emit Selected(value.toBool(), id);
}
return QGraphicsEllipseItem::itemChange(change, value);
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
QColor VSimplePoint::GetCurrentColor() const

View file

@ -65,6 +65,7 @@ signals:
* @param id point id.
*/
void Choosed(quint32 id);
void Selected(bool selected, quint32 id);
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
void Delete();
void NameChangedPosition(const QPointF &pos);
@ -72,14 +73,16 @@ signals:
public slots:
void DeleteFromLabel();
void PointChoosed();
void PointSelected(bool selected);
void ChangedPosition(const QPointF &pos);
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VSimplePoint)