Merge with feature. New feature groups.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-04-07 20:00:27 +03:00
commit f0ffbafe10
73 changed files with 2209 additions and 97 deletions

View File

@ -1,4 +1,5 @@
# Version 0.5.0
- New feature. Groups.
- Tool "Curve intersect axis" store data about subpaths.
- [#444] Length along Path seems not valid.
- Added new curve path segment variables.

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

@ -17,7 +17,8 @@ HEADERS += \
$$PWD/configpages/pathpage.h \
$$PWD/dialoglayoutsettings.h \
$$PWD/dialoglayoutprogress.h \
$$PWD/dialogsavelayout.h
$$PWD/dialogsavelayout.h \
$$PWD/vwidgetgroups.h
SOURCES += \
$$PWD/dialogincrements.cpp \
@ -33,7 +34,8 @@ SOURCES += \
$$PWD/configpages/pathpage.cpp \
$$PWD/dialoglayoutsettings.cpp \
$$PWD/dialoglayoutprogress.cpp \
$$PWD/dialogsavelayout.cpp
$$PWD/dialogsavelayout.cpp \
$$PWD/vwidgetgroups.cpp
FORMS += \
$$PWD/dialogincrements.ui \
@ -44,4 +46,5 @@ FORMS += \
$$PWD/dialogpatternxmledit.ui \
$$PWD/dialoglayoutsettings.ui \
$$PWD/dialoglayoutprogress.ui \
$$PWD/dialogsavelayout.ui
$$PWD/dialogsavelayout.ui \
$$PWD/vwidgetgroups.ui

View File

@ -0,0 +1,159 @@
/************************************************************************
**
** @file vwidgetgroups.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 "vwidgetgroups.h"
#include "ui_vwidgetgroups.h"
#include "../vtools/dialogs/tools/dialoggroup.h"
#include "../vtools/undocommands/delgroup.h"
#include <QMenu>
//---------------------------------------------------------------------------------------------------------------------
VWidgetGroups::VWidgetGroups(VAbstractPattern *doc, QWidget *parent)
: QWidget(parent),
ui(new Ui::VWidgetGroups),
doc(doc)
{
ui->setupUi(this);
FillTable(doc->GetGroups());
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetGroups::GroupVisibilityChanged);
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetGroups::CtxMenu);
}
//---------------------------------------------------------------------------------------------------------------------
VWidgetGroups::~VWidgetGroups()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetGroups::GroupVisibilityChanged(int row, int column)
{
if (column != 0)
{
return;
}
QTableWidgetItem *item = ui->tableWidget->item(row, column);
const quint32 id = item->data(Qt::UserRole).toUInt();
const bool visible = not doc->GetGroupVisivility(id);
doc->SetGroupVisivility(id, visible);
if (visible)
{
item->setIcon(QIcon("://icon/16x16/open_eye.png"));
}
else
{
item->setIcon(QIcon("://icon/16x16/closed_eye.png"));
}
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetGroups::CtxMenu(const QPoint &pos)
{
QTableWidgetItem *item = ui->tableWidget->itemAt(pos);
if(not item)
{
return;
}
const int row = item->row();
item = ui->tableWidget->item(row, 0);
const quint32 id = item->data(Qt::UserRole).toUInt();
QMenu *menu = new QMenu;
QAction *actionRename = menu->addAction(tr("Rename"));
QAction *actionDelete = menu->addAction(tr("Delete"));
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (selectedAction == actionRename)
{
DialogGroup *dialog = new DialogGroup(new VContainer(qApp->TrVars(), qApp->patternUnitP()), NULL_ID, this);
dialog->SetName(doc->GetGroupName(id));
const int result = dialog->exec();
if (result == QDialog::Accepted)
{
doc->SetGroupName(id, dialog->GetName());
item = ui->tableWidget->item(row, 1);
item->setText(dialog->GetName());
}
delete dialog;
}
else if (selectedAction == actionDelete)
{
DelGroup *delGroup = new DelGroup(doc, id);
connect(delGroup, &DelGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
qApp->getUndoStack()->push(delGroup);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetGroups::UpdateGroups()
{
FillTable(doc->GetGroups());
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetGroups::FillTable(const QMap<quint32, QPair<QString, bool> > &groups)
{
ui->tableWidget->clear();
ui->tableWidget->setColumnCount(2);
ui->tableWidget->setRowCount(groups.size());
qint32 currentRow = -1;
auto i = groups.constBegin();
while (i != groups.constEnd())
{
++currentRow;
const QPair<QString, bool> data = i.value();
QTableWidgetItem *item = new QTableWidgetItem();
item->setTextAlignment(Qt::AlignHCenter);
if (data.second)
{
item->setIcon(QIcon("://icon/16x16/open_eye.png"));
}
else
{
item->setIcon(QIcon("://icon/16x16/closed_eye.png"));
}
item->setData(Qt::UserRole, i.key());
ui->tableWidget->setItem(currentRow, 0, item);
item = new QTableWidgetItem(data.first);
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableWidget->setItem(currentRow, 1, item);
++i;
}
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
}

View File

@ -0,0 +1,62 @@
/************************************************************************
**
** @file vwidgetgroups.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 VWIDGETGROUPS_H
#define VWIDGETGROUPS_H
#include <QWidget>
#include "../ifc/xml/vabstractpattern.h"
namespace Ui
{
class VWidgetGroups;
}
class VWidgetGroups : public QWidget
{
Q_OBJECT
public:
explicit VWidgetGroups(VAbstractPattern *doc, QWidget *parent = nullptr);
virtual ~VWidgetGroups();
public slots:
void UpdateGroups();
private slots:
void GroupVisibilityChanged(int row, int column);
void CtxMenu(const QPoint &pos);
private:
Q_DISABLE_COPY(VWidgetGroups)
Ui::VWidgetGroups *ui;
VAbstractPattern *doc;
void FillTable(const QMap<quint32, QPair<QString, bool> > &groups);
};
#endif // VWIDGETGROUPS_H

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VWidgetGroups</class>
<widget class="QWidget" name="VWidgetGroups">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>279</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>16</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize">
<number>10</number>
</attribute>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -54,6 +54,8 @@
#include "tools/vtooldetail.h"
#include "tools/vtooluniondetails.h"
#include "dialogs/dialogs.h"
#include "dialogs/vwidgetgroups.h"
#include "../vtools/undocommands/addgroup.h"
#include <QInputDialog>
#include <QDebug>
@ -111,11 +113,16 @@ MainWindow::MainWindow(QWidget *parent)
dialogTable(nullptr),
dialogTool(nullptr),
dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation),
currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(),
currentDrawIndex(0), currentToolBoxIndex(0),
isDockToolOptionsVisible(true),
isDockGroupsVisible(true),
drawMode(true), recentFileActs(),
separatorAct(nullptr),
leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true),
gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr),
toolOptions(nullptr), lock(nullptr)
toolOptions(nullptr),
groupsWidget(nullptr),
lock(nullptr)
{
for (int i = 0; i < MaxRecentFiles; ++i)
{
@ -150,7 +157,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->toolBox->setCurrentIndex(0);
ReadSettings();
PropertyBrowser();
InitDocksContain();
setCurrentFile("");
WindowsLocale();
@ -305,6 +312,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 +559,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 +915,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 +1000,38 @@ void MainWindow::ClosedDialogUnionDetails(int result)
doc->LiteParseTree(Document::LiteParse);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolGroup(bool checked)
{
ToolSelectGroupObjects();
currentScene->clearSelection();
SetToolButton<DialogGroup>(checked, Tool::Group, ":/cursor/group_plus_cursor.png",
tr("Select one or more 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 QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
if (not group.isNull())
{
AddGroup *addGroup = new AddGroup(group, doc);
connect(addGroup, &AddGroup::UpdateGroups, groupsWidget, &VWidgetGroups::UpdateGroups);
qApp->getUndoStack()->push(addGroup);
}
}
ArrowTool();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ToolCutArc handler tool cutArc.
@ -1018,7 +1059,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 +1070,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",
@ -1698,7 +1739,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent);
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1739,7 +1780,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 +1904,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 +1939,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);
@ -2025,7 +2070,8 @@ void MainWindow::ActionDraw(bool checked)
}
ui->dockWidgetLayoutPages->setVisible(false);
ui->dockWidgetToolOptions->setVisible(true);
ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible);
ui->dockWidgetGroups->setVisible(isDockGroupsVisible);
}
else
{
@ -2086,7 +2132,7 @@ void MainWindow::ActionDetails(bool checked)
mode = Draw::Modeling;
SetEnableTool(true);
SetEnableWidgets(true);
ui->toolBox->setCurrentIndex(4);
ui->toolBox->setCurrentIndex(5);
if (qApp->patternType() == MeasurementsType::Standard)
{
@ -2094,7 +2140,8 @@ void MainWindow::ActionDetails(bool checked)
}
ui->dockWidgetLayoutPages->setVisible(false);
ui->dockWidgetToolOptions->setVisible(true);
ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible);
ui->dockWidgetGroups->setVisible(isDockGroupsVisible);
helpLabel->setText("");
}
@ -2161,7 +2208,7 @@ void MainWindow::ActionLayout(bool checked)
mode = Draw::Layout;
SetEnableTool(true);
SetEnableWidgets(true);
ui->toolBox->setCurrentIndex(5);
ui->toolBox->setCurrentIndex(6);
mouseCoordinate->setText("");
@ -2171,7 +2218,14 @@ void MainWindow::ActionLayout(bool checked)
}
ui->dockWidgetLayoutPages->setVisible(true);
ui->dockWidgetToolOptions->blockSignals(true);
ui->dockWidgetToolOptions->setVisible(false);
ui->dockWidgetToolOptions->blockSignals(false);
ui->dockWidgetGroups->blockSignals(true);
ui->dockWidgetGroups->setVisible(false);
ui->dockWidgetGroups->blockSignals(false);
ShowPaper(ui->listWidget->currentRow());
@ -2668,6 +2722,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionUnloadMeasurements->setEnabled(enable && designStage);
actionDockWidgetToolOptions->setEnabled(enable && designStage);
actionDockWidgetGroups->setEnabled(enable && designStage);
undoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canUndo());
redoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canRedo());
@ -2875,6 +2930,18 @@ void MainWindow::ChangedHeight(const QString &text)
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::DockToolOptionsVisibilityChanged(bool visible)
{
isDockToolOptionsVisible = visible;
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::DockGropsVisibilityChanged(bool visible)
{
isDockGroupsVisible = visible;
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultHeight()
{
@ -3042,6 +3109,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools);
ui->toolButtonArcWithLength->setEnabled(drawTools);
ui->toolButtonTrueDarts->setEnabled(drawTools);
ui->toolButtonGroup->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools);
@ -3192,6 +3260,9 @@ void MainWindow::ReadSettings()
// Text under tool buton icon
ToolBarStyles();
isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible();
isDockGroupsVisible = ui->dockWidgetGroups->isVisible();
}
//---------------------------------------------------------------------------------------------------------------------
@ -3298,13 +3369,6 @@ void MainWindow::CreateMenus()
separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
//Add dock
actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions);
separatorAct = new QAction(this);
separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
AddDocks();
}
@ -3316,7 +3380,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)
{
@ -3463,6 +3527,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonTrueDarts->setChecked(true);
ToolTrueDarts(true);
break;
case Tool::Group:
ui->toolButtonGroup->setChecked(true);
ToolGroup(true);
break;
}
}
@ -3473,7 +3541,15 @@ void MainWindow::LastUsedTool()
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::AddDocks()
{
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction());
//Add dock
actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions);
connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this,
&MainWindow::DockToolOptionsVisibilityChanged);
actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetGroups);
connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, &MainWindow::DockGropsVisibilityChanged);
separatorAct = new QAction(this);
separatorAct->setSeparator(true);
@ -3481,13 +3557,17 @@ void MainWindow::AddDocks()
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::PropertyBrowser()
void MainWindow::InitDocksContain()
{
qCDebug(vMainWindow, "Initialization property browser.");
toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions);
connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked);
connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions);
qCDebug(vMainWindow, "Initialization groups dock.");
groupsWidget = new VWidgetGroups(doc, this);
ui->dockWidgetGroups->setWidget(groupsWidget);
}
//---------------------------------------------------------------------------------------------------------------------
@ -4070,6 +4150,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
}
}
toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece
groupsWidget->UpdateGroups();
}
}
@ -4459,6 +4540,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);
@ -4494,6 +4576,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);
@ -4517,6 +4600,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);
@ -4540,6 +4624,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);
@ -4563,6 +4648,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);
@ -4586,6 +4672,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);
@ -4604,11 +4691,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);
@ -4626,6 +4714,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(true);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectDetail() const
{

View File

@ -48,6 +48,7 @@ class QLabel;
class DialogIncrements;
class DialogTool;
class DialogHistory;
class VWidgetGroups;
/**
* @brief The MainWindow class main windows.
@ -120,6 +121,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 +136,7 @@ public slots:
void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result);
void ClosedDialogGroup(int result);
//tmp
void LastUsedTool();
@ -161,6 +164,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;
@ -201,6 +205,9 @@ private slots:
void ChangedSize(const QString &text);
void ChangedHeight(const QString & text);
void DockToolOptionsVisibilityChanged(bool visible);
void DockGropsVisibilityChanged(bool visible);
private:
Q_DISABLE_COPY(MainWindow)
/** @brief ui keeps information about user interface */
@ -252,6 +259,9 @@ private:
/** @brief currentToolBoxIndex save current set of tools. */
qint32 currentToolBoxIndex;
bool isDockToolOptionsVisible;
bool isDockGroupsVisible;
/** @brief drawMode true if we current draw scene. */
bool drawMode;
@ -267,6 +277,7 @@ private:
QPointer<QLabel> gradationHeightsLabel;
QPointer<QLabel> gradationSizesLabel;
VToolOptionsPropertyBrowser *toolOptions;
VWidgetGroups *groupsWidget;
std::shared_ptr<VLockGuard<char>> lock;
void SetDefaultHeight();
@ -324,7 +335,7 @@ private:
void UpdateSizesList(const QStringList &list);
void AddDocks();
void PropertyBrowser();
void InitDocksContain();
bool OpenNewValentina(const QString &fileName = QString())const;
void FileClosedCorrect();
QStringList GetUnlokedRestoreFileList()const;
@ -360,7 +371,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

@ -48,14 +48,14 @@
<string>Tools</string>
</property>
<property name="currentIndex">
<number>2</number>
<number>4</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>130</width>
<height>318</height>
</rect>
</property>
@ -375,7 +375,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>130</width>
<height>58</height>
</rect>
</property>
@ -700,7 +700,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>130</width>
<height>196</height>
</rect>
</property>
@ -937,12 +937,60 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_7">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
</rect>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/operations.png</normaloff>:/icon/16x16/operations.png</iconset>
</attribute>
<attribute name="label">
<string>Operations</string>
</attribute>
<attribute name="toolTip">
<string>Operations</string>
</attribute>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QToolButton" name="toolButtonGroup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Create new group</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/group_plus.png</normaloff>:/toolicon/32x32/group_plus.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="page_5">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>130</width>
<height>58</height>
</rect>
</property>
@ -1028,8 +1076,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>87</width>
<height>58</height>
<width>130</width>
<height>356</height>
</rect>
</property>
<attribute name="icon">
@ -1415,6 +1463,18 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidgetGroups">
<property name="enabled">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Groups</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2"/>
</widget>
<action name="actionNew">
<property name="icon">
<iconset theme="document-new">

View File

@ -60,7 +60,8 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
: QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()),
shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()),
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()),
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),
curFile(QString()),
isLayoutStale(true), margins(), paperSize(), isTiled(false)
{
InitTempLayoutScene();

View File

@ -83,6 +83,7 @@ protected:
QAction *undoAction;
QAction *redoAction;
QAction *actionDockWidgetToolOptions;
QAction *actionDockWidgetGroups;
/** @brief fileName name current pattern file. */
QString curFile;

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

@ -62,5 +62,7 @@
<file>toolicon/32x32/cubic_bezier@2x.png</file>
<file>toolicon/32x32/cubic_bezier_path.png</file>
<file>toolicon/32x32/cubic_bezier_path@2x.png</file>
<file>toolicon/32x32/group_plus.png</file>
<file>toolicon/32x32/group_plus@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<path d="M32 4h-4v-4h-4v4h-4v4h4v4h4v-4h4z" fill="#444444"></path>
<path d="M26.996 13.938c0.576 0.64 1.1 1.329 1.563 2.062-1.197 1.891-2.79 3.498-4.67 4.697-2.362 1.507-5.090 2.303-7.889 2.303s-5.527-0.796-7.889-2.303c-1.88-1.199-3.473-2.805-4.67-4.697 1.197-1.891 2.79-3.498 4.67-4.697 0.122-0.078 0.246-0.154 0.371-0.228-0.311 0.854-0.482 1.776-0.482 2.737 0 4.418 3.582 8 8 8s8-3.582 8-8c0-0.022-0.001-0.043-0.001-0.065-3.415-0.879-5.947-3.957-5.998-7.635-0.657-0.074-1.325-0.113-2.001-0.113-6.979 0-13.028 4.064-16 10 2.972 5.936 9.021 10 16 10s13.027-4.064 16-10c-0.551-1.101-1.209-2.137-1.958-3.095-0.915 0.537-1.946 0.897-3.046 1.034zM13 10c1.657 0 3 1.343 3 3s-1.343 3-3 3-3-1.343-3-3 1.343-3 3-3z" fill="#444444"></path>
</svg>

After

Width:  |  Height:  |  Size: 1017 B

View File

@ -469,7 +469,7 @@ void VPattern::customEvent(QEvent *event)
*/
void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
{
QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails;
QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails << TagGroups;
QDomNode domNode = node.firstChild();
while (domNode.isNull() == false)
{
@ -493,6 +493,10 @@ void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
qCDebug(vXML, "Tag details.");
ParseDetails(domElement, parse);
break;
case 3: // TagGroups
qCDebug(vXML, "Tag groups.");
ParseGroups(domElement);
break;
default:
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
throw e;
@ -2885,7 +2889,7 @@ bool VPattern::IsDefCustom() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return GetParametrBool(domElement, AttrCustom, QStringLiteral("false"));
return GetParametrBool(domElement, AttrCustom, falseStr);
}
else
{
@ -3054,7 +3058,7 @@ bool VPattern::IsReadOnly() const
return false;
}
return GetParametrBool(pattern, AttrReadOnly, QStringLiteral("false"));
return GetParametrBool(pattern, AttrReadOnly, falseStr);
}
//---------------------------------------------------------------------------------------------------------------------
@ -3126,7 +3130,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;
@ -3240,6 +3244,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
case Tool::Group:
break;
}
}

View File

@ -112,9 +112,9 @@ private:
void ParseDrawElement(const QDomNode& node, const Document &parse);
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
void ParseDetailElement(const QDomElement &domElement,
const Document &parse);
void ParseDetailElement(const QDomElement &domElement, const Document &parse);
void ParseDetails(const QDomElement &domElement, const Document &parse);
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document &parse, const QString &type);
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,

View File

@ -13,6 +13,7 @@
<file>schema/pattern/v0.2.5.xsd</file>
<file>schema/pattern/v0.2.6.xsd</file>
<file>schema/pattern/v0.2.7.xsd</file>
<file>schema/pattern/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

View File

@ -0,0 +1,480 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="extension" type="imageExtension"></xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="crossType"></xs:attribute>
<xs:attribute name="vCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="hCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="length1" type="xs:string"></xs:attribute>
<xs:attribute name="length2" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="length1" type="xs:string"></xs:attribute>
<xs:attribute name="length2" type="xs:string"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="duplicate" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groups" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="object" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="tool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="imageExtension">
<xs:restriction base="xs:string">
<xs:enumeration value="PNG"/>
<xs:enumeration value="JPG"/>
<xs:enumeration value="BMP"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="crossType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -31,6 +31,8 @@
#include "exception/vexceptionemptyparameter.h"
#include "vpatternconverter.h"
#include "../qmuparser/qmutokenparser.h"
#include "../exception/vexceptionobjecterror.h"
#include "../vtools/tools/vdatatool.h"
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
@ -44,6 +46,9 @@ const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements")
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagLine = QStringLiteral("line");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
@ -55,6 +60,9 @@ const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagUnit = QStringLiteral("unit");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
@ -289,6 +297,56 @@ bool VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &ele
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
QMap<quint32, quint32> itemTool;
QMap<quint32, bool> itemVisibility;
QDomNode domNode = domElement.firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == TagGroup)
{
const QPair<bool, QMap<quint32, quint32> > groupData = ParseItemElement(domElement);
const QMap<quint32, quint32> group = groupData.second;
auto i = group.constBegin();
while (i != group.constEnd())
{
if (not itemTool.contains(i.key()))
{
itemTool.insert(i.key(), i.value());
}
const bool previous = itemVisibility.value(i.key(), false);
itemVisibility.insert(i.key(), previous || groupData.first);
++i;
}
}
}
}
domNode = domNode.nextSibling();
}
auto i = itemTool.constBegin();
while (i != itemTool.constEnd())
{
if (tools.contains(i.value()))
{
VDataTool* tool = tools.value(i.value());
tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true));
}
++i;
}
}
//---------------------------------------------------------------------------------------------------------------------
int VAbstractPattern::CountPP() const
{
@ -595,7 +653,7 @@ QMap<GHeights, bool> VAbstractPattern::GetGradationHeights() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
const QString defValue = trueStr;
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
@ -761,7 +819,7 @@ QMap<GSizes, bool> VAbstractPattern::GetGradationSizes() const
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
const QString defValue = trueStr;
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
@ -1375,6 +1433,44 @@ bool VAbstractPattern::IsFunction(const QString &token) const
return false;
}
//---------------------------------------------------------------------------------------------------------------------
QPair<bool, QMap<quint32, quint32> > VAbstractPattern::ParseItemElement(const QDomElement &domElement)
{
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
try
{
const bool visible = GetParametrBool(domElement, AttrVisible, trueStr);
QMap<quint32, quint32> items;
const QDomNodeList nodeList = domElement.childNodes();
const qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
{
const QDomElement element = nodeList.at(i).toElement();
if (not element.isNull() && element.tagName() == TagGroupItem)
{
const quint32 object = GetParametrUInt(element, AttrObject, NULL_ID_STR);
const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR);
items.insert(object, tool);
}
}
QPair<bool, QMap<quint32, quint32> > group;
group.first = visible;
group.second = items;
return group;
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating group"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief IsModified state of the document for cases that do not cover QUndoStack.
@ -1410,3 +1506,187 @@ QDomElement VAbstractPattern::GetDraw(const QString &name) const
}
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractPattern::CreateGroups()
{
QDomElement draw;
if (GetActivDrawElement(draw))
{
QDomElement groups = draw.firstChildElement(TagGroups);
if (groups.isNull())
{
groups = createElement(TagGroups);
draw.appendChild(groups);
}
return groups;
}
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData)
{
if (id == NULL_ID || groupData.isEmpty())
{
return QDomElement();
}
QDomElement group = createElement(TagGroup);
SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name);
SetAttribute(group, AttrVisible, true);
auto i = groupData.constBegin();
while (i != groupData.constEnd())
{
QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrObject, i.key());
item.setAttribute(AttrTool, i.value());
group.appendChild(item);
++i;
}
return group;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetGroupName(quint32 id)
{
QString name = tr("New group");
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
QDomElement group = elementById(id);
if (group.isElement())
{
name = GetParametrString(group, AttrName, name);
return name;
}
else
{
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
qDebug("Can't get group by id = %u.", id);
return name;
}
}
else
{
qDebug("Can't get tag Groups.");
return name;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
{
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
QDomElement group = elementById(id);
if (group.isElement())
{
group.setAttribute(AttrName, name);
modified = true;
emit patternChanged(false);
}
else
{
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
qDebug("Can't get group by id = %u.", id);
return;
}
}
else
{
qDebug("Can't get tag Groups.");
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
QMap<quint32, QPair<QString, bool> > VAbstractPattern::GetGroups()
{
QMap<quint32, QPair<QString, bool> > data;
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
QDomNode domNode = groups.firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
const QDomElement group = domNode.toElement();
if (group.isNull() == false)
{
if (group.tagName() == TagGroup)
{
const quint32 id = GetParametrUInt(group, AttrId, "0");
const bool visible = GetParametrBool(group, AttrVisible, trueStr);
const QString name = GetParametrString(group, AttrName, tr("New group"));
data.insert(id, qMakePair(name, visible));
}
}
}
domNode = domNode.nextSibling();
}
}
else
{
qDebug("Can't get tag Groups.");
}
return data;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::GetGroupVisivility(quint32 id)
{
QDomElement group = elementById(id);
if (group.isElement())
{
return GetParametrBool(group, AttrVisible, trueStr);
}
else
{
qDebug("Can't get group by id = %u.", id);
return true;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible)
{
QDomElement group = elementById(id);
if (group.isElement())
{
SetAttribute(group, AttrVisible, visible);
modified = true;
emit patternChanged(false);
QDomElement groups = CreateGroups();
if (not groups.isNull())
{
ParseGroups(groups);
}
}
else
{
qDebug("Can't get group by id = %u.", id);
return;
}
}

View File

@ -119,6 +119,15 @@ public:
QDomElement GetDraw(const QString &name) const;
void ParseGroups(const QDomElement &domElement);
QDomElement CreateGroups();
QDomElement CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData);
QString GetGroupName(quint32 id);
void SetGroupName(quint32 id, const QString &name);
QMap<quint32, QPair<QString, bool> > GetGroups();
bool GetGroupVisivility(quint32 id);
void SetGroupVisivility(quint32 id, bool visible);
static const QString TagPattern;
static const QString TagCalculation;
static const QString TagModeling;
@ -131,6 +140,9 @@ public:
static const QString TagIncrements;
static const QString TagIncrement;
static const QString TagDraw;
static const QString TagGroups;
static const QString TagGroup;
static const QString TagGroupItem;
static const QString TagPoint;
static const QString TagLine;
static const QString TagSpline;
@ -142,6 +154,9 @@ public:
static const QString TagUnit;
static const QString AttrName;
static const QString AttrVisible;
static const QString AttrObject;
static const QString AttrTool;
static const QString AttrType;
static const QString AttrAll;
@ -281,6 +296,8 @@ private:
bool IsVariable(const QString& token) const;
bool IsPostfixOperator(const QString& token) const;
bool IsFunction(const QString& token) const;
QPair<bool, QMap<quint32, quint32> > ParseItemElement(const QDomElement &domElement);
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -255,7 +255,7 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
//---------------------------------------------------------------------------------------------------------------------
NodeUsage VDomDocument::GetParametrUsage(const QDomElement &domElement, const QString &name) const
{
const bool value = GetParametrBool(domElement, name, QStringLiteral("true"));
const bool value = GetParametrBool(domElement, name, trueStr);
if (value)
{
return NodeUsage::InUse;
@ -271,11 +271,11 @@ void VDomDocument::SetParametrUsage(QDomElement &domElement, const QString &name
{
if (value == NodeUsage::InUse)
{
domElement.setAttribute(name, QStringLiteral("true"));
domElement.setAttribute(name, trueStr);
}
else
{
domElement.setAttribute(name, QStringLiteral("false"));
domElement.setAttribute(name, falseStr);
}
}

View File

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.7");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.7.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.0.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -111,6 +111,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000206):
return QStringLiteral("://schema/pattern/v0.2.6.xsd");
case (0x000207):
return QStringLiteral("://schema/pattern/v0.3.0.xsd");
case (0x000300):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -210,6 +212,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH
}
case (0x000207):
{
ToV0_3_0();
const QString schema = XSDSchema(0x000300);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000300):
break;
default:
break;
@ -331,6 +340,13 @@ void VPatternConverter::ToV0_2_7()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_3_0()
{
SetVersion(QStringLiteral("0.3.0"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -68,6 +68,7 @@ private:
void ToV0_2_5();
void ToV0_2_6();
void ToV0_2_7();
void ToV0_3_0();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -408,6 +408,8 @@ const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-clos
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.
const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false");
//---------------------------------------------------------------------------------------------------------------------
void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY)

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
};
@ -583,6 +584,8 @@ extern const QString cursorArrowOpenHand;
extern const QString cursorArrowCloseHand;
extern const QString degreeSymbol;
extern const QString trueStr;
extern const QString falseStr;
void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1);
void RestoreOverrideCursor(const QString & pixmapPath);

View File

@ -55,5 +55,11 @@
<file>icon/16x16/toolsectioncurve@2x.png</file>
<file>icon/16x16/toolsectionline@2x.png</file>
<file>icon/16x16/toolsectionpoint@2x.png</file>
<file>icon/16x16/operations.png</file>
<file>icon/16x16/operations@2x.png</file>
<file>icon/16x16/closed_eye.png</file>
<file>icon/16x16/closed_eye@2x.png</file>
<file>icon/16x16/open_eye.png</file>
<file>icon/16x16/open_eye@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
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"
viewBox="0 0 32 32"
version="1.1"
x="0px"
y="0px"
id="svg2"
inkscape:version="0.91 r"
sodipodi:docname="closed_eye.svg"
width="32"
height="32"
inkscape:export-filename="/home/dismine/CAD/Valentina_groups/Valentina/src/libs/vmisc/share/resources/icon/svg/closed_eye.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45">
<metadata
id="metadata32">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Closed Eye</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs30" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1436"
inkscape:window-height="885"
id="namedview28"
showgrid="false"
inkscape:zoom="15.733333"
inkscape:cx="23.672261"
inkscape:cy="17.880242"
inkscape:window-x="75"
inkscape:window-y="34"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<title
id="title4">Closed Eye</title>
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
<g
id="g6"
style="fill:#000000;fill-rule:evenodd"
transform="matrix(1.9803301,0,0,2.3359228,0,3.0481403)">
<g
id="g8">
<g
id="g10"
style="fill:#000000">
<path
d="m 8.0719097,8.5 c 4.4579933,0 8.0719093,-4 8.0719093,-4 0,0 -3.613916,-4 -8.0719093,-4 C 3.6139169,0.5 0,4.5 0,4.5 c 0,0 3.6139169,4 8.0719097,4 z m 0,0"
id="path12"
inkscape:connector-curvature="0" />
<path
d="m 0.9330127,7.2059403 0,2 1,0 0,-2 -1,0 z m 0,0"
transform="matrix(0.81915204,0.57357644,-0.57357644,0.81915204,4.9658913,0.66208498)"
id="path14"
inkscape:connector-curvature="0" />
<path
d="m 13.933013,7.2059403 0,2 1,0 0,-2 -1,0 z m 0,0"
transform="matrix(0.81915204,-0.57357644,0.57357644,0.81915204,-2.0965529,9.7624636)"
id="path16"
inkscape:connector-curvature="0" />
<path
d="m 7.5,9.3 0,2 1,0 0,-2 -1,0 z m 0,0"
id="path18"
inkscape:connector-curvature="0" />
<path
d="m 10.998327,8.7083027 0,2.0000003 1,0 0,-2.0000003 -1,0 z m 0,0"
transform="matrix(0.94551858,-0.32556815,0.32556815,0.94551858,-2.5342691,4.2724113)"
id="path20"
inkscape:connector-curvature="0" />
<path
d="m 4.1436217,8.7146863 0,1.9999997 1,0 0,-1.9999997 -1,0 z m 0,0"
transform="matrix(0.94551858,0.32556815,-0.32556815,0.94551858,3.4157835,-0.98254551)"
id="path22"
inkscape:connector-curvature="0" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<path d="M16 6c-6.979 0-13.028 4.064-16 10 2.972 5.936 9.021 10 16 10s13.027-4.064 16-10c-2.972-5.936-9.021-10-16-10zM23.889 11.303c1.88 1.199 3.473 2.805 4.67 4.697-1.197 1.891-2.79 3.498-4.67 4.697-2.362 1.507-5.090 2.303-7.889 2.303s-5.527-0.796-7.889-2.303c-1.88-1.199-3.473-2.805-4.67-4.697 1.197-1.891 2.79-3.498 4.67-4.697 0.122-0.078 0.246-0.154 0.371-0.228-0.311 0.854-0.482 1.776-0.482 2.737 0 4.418 3.582 8 8 8s8-3.582 8-8c0-0.962-0.17-1.883-0.482-2.737 0.124 0.074 0.248 0.15 0.371 0.228v0zM16 13c0 1.657-1.343 3-3 3s-3-1.343-3-3 1.343-3 3-3 3 1.343 3 3z" fill="#444444"></path>
</svg>

After

Width:  |  Height:  |  Size: 877 B

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);
@ -342,3 +334,10 @@ QString VAbstractSpline::name() const
{
return ObjectName<VAbstractCurve>(id);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
setVisible(visible);
}

View File

@ -53,6 +53,7 @@ public:
QString name() const;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;

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);
@ -90,6 +92,19 @@ void VToolDoublePoint::SetEnabled(bool enabled)
SetToolEnabled(this, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::GroupVisibility(quint32 object, bool visible)
{
if (object == p1id)
{
firstPoint->setVisible(visible);
}
else if (object == p2id)
{
secondPoint->setVisible(visible);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
{
@ -138,6 +153,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

@ -56,6 +56,7 @@ public:
void SetEnabled(bool enabled);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
void Label1ChangePosition(const QPointF &pos);
void Label2ChangePosition(const QPointF &pos);
@ -64,6 +65,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

@ -66,6 +66,7 @@ VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quin
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolSinglePoint::contextMenuEvent);
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolSinglePoint::DeleteFromLabel);
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolSinglePoint::PointChoosed);
connect(namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VToolSinglePoint::PointSelected);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition);
lineName = new QGraphicsLineItem(this);
this->setBrush(QBrush(Qt::NoBrush));
@ -96,6 +97,13 @@ void VToolSinglePoint::SetEnabled(bool enabled)
SetToolEnabled(lineName, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
setVisible(visible);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NameChangePosition handle change posion point label.
@ -167,6 +175,12 @@ void VToolSinglePoint::PointChoosed()
emit ChoosedTool(id, SceneObject::Point);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::PointSelected(bool selected)
{
setSelected(selected);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -270,15 +284,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

@ -53,12 +53,14 @@ public:
void SetEnabled(bool enabled);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
void NameChangePosition(const QPointF &pos);
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
void PointChoosed();
void PointSelected(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

@ -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);
@ -479,6 +470,13 @@ void VToolLine::SetLineColor(const QString &value)
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
setVisible(visible);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLine::GetFirstPoint() const
{

View File

@ -63,6 +63,7 @@ public:
virtual void SetTypeLine(const QString &value) Q_DECL_OVERRIDE;
virtual void SetLineColor(const QString &value) Q_DECL_OVERRIDE;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;

View File

@ -108,6 +108,13 @@ void VAbstractNode::SetParentType(const ParentType &value)
parentType = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
Q_UNUSED(visible);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToModeling add tag to modeling tag current pattern peace.

View File

@ -54,6 +54,8 @@ public:
ParentType GetParentType() const;
void SetParentType(const ParentType &value);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
protected:
ParentType parentType;
protected:

View File

@ -46,11 +46,12 @@ class VDataTool : public QObject
public:
explicit VDataTool(VContainer *data, QObject *parent = nullptr);
virtual ~VDataTool() Q_DECL_OVERRIDE;
VContainer getData() const;
void setData(const VContainer *value);
virtual quint32 referens() const;
virtual void incrementReferens();
virtual void decrementReferens();
VContainer getData() const;
void setData(const VContainer *value);
virtual quint32 referens() const;
virtual void incrementReferens();
virtual void decrementReferens();
virtual void GroupVisibility(quint32 object, bool visible)=0;
protected:
/** @brief data container with data */
VContainer data;

View File

@ -628,6 +628,13 @@ void VToolDetail::ShowVisualization(bool show)
Q_UNUSED(show)
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
Q_UNUSED(visible);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -86,6 +86,7 @@ public:
enum { Type = UserType + static_cast<int>(Tool::Detail)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void FullUpdateFromGuiOk(int result);

View File

@ -488,6 +488,13 @@ void VToolUnionDetails::decrementReferens()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolUnionDetails::GroupVisibility(quint32 object, bool visible)
{
Q_UNUSED(object);
Q_UNUSED(visible);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.

View File

@ -84,6 +84,7 @@ public:
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.

View File

@ -0,0 +1,112 @@
/************************************************************************
**
** @file addgroup.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 "addgroup.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../vmisc/vabstractapplication.h"
//---------------------------------------------------------------------------------------------------------------------
AddGroup::AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP())
{
setText(tr("add group"));
nodeId = doc->GetParametrId(xml);
}
//---------------------------------------------------------------------------------------------------------------------
AddGroup::~AddGroup()
{
}
//---------------------------------------------------------------------------------------------------------------------
void AddGroup::undo()
{
qCDebug(vUndo, "Undo.");
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
QDomElement groups = doc->CreateGroups();
if (not groups.isNull())
{
QDomElement group = doc->elementById(nodeId);
if (group.isElement())
{
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
doc->ParseGroups(groups);
if (groups.removeChild(group).isNull())
{
qCDebug(vUndo, "Can't delete group.");
return;
}
emit UpdateGroups();
}
else
{
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
return;
}
}
else
{
qCDebug(vUndo, "Can't get tag Groups.");
return;
}
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
}
//---------------------------------------------------------------------------------------------------------------------
void AddGroup::redo()
{
qCDebug(vUndo, "Redo.");
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
QDomElement groups = doc->CreateGroups();
if (not groups.isNull())
{
groups.appendChild(xml);
doc->ParseGroups(groups);
emit UpdateGroups();
}
else
{
qCDebug(vUndo, "Can't get tag Groups.");
return;
}
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}

View File

@ -0,0 +1,49 @@
/************************************************************************
**
** @file addgroup.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 ADDGROUP_H
#define ADDGROUP_H
#include "vundocommand.h"
class AddGroup : public VUndoCommand
{
Q_OBJECT
public:
AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
virtual ~AddGroup();
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
signals:
void UpdateGroups();
private:
Q_DISABLE_COPY(AddGroup)
const QString nameActivDraw;
};
#endif // ADDGROUP_H

View File

@ -0,0 +1,112 @@
/************************************************************************
**
** @file delgroup.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 "delgroup.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../vmisc/vabstractapplication.h"
//---------------------------------------------------------------------------------------------------------------------
DelGroup::DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), nameActivDraw(doc->GetNameActivPP())
{
setText(tr("delete group"));
nodeId = id;
xml = doc->CloneNodeById(nodeId);
}
//---------------------------------------------------------------------------------------------------------------------
DelGroup::~DelGroup()
{
}
//---------------------------------------------------------------------------------------------------------------------
void DelGroup::undo()
{
qCDebug(vUndo, "Undo.");
doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
QDomElement groups = doc->CreateGroups();
if (not groups.isNull())
{
groups.appendChild(xml);
doc->ParseGroups(groups);
emit UpdateGroups();
}
else
{
qCDebug(vUndo, "Can't get tag Groups.");
return;
}
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}
//---------------------------------------------------------------------------------------------------------------------
void DelGroup::redo()
{
qCDebug(vUndo, "Redo.");
//Keep first!
doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
QDomElement groups = doc->CreateGroups();
if (not groups.isNull())
{
QDomElement group = doc->elementById(nodeId);
if (group.isElement())
{
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
doc->ParseGroups(groups);
if (groups.removeChild(group).isNull())
{
qCDebug(vUndo, "Can't delete group.");
return;
}
emit UpdateGroups();
if (groups.childNodes().isEmpty())
{
QDomNode parent = groups.parentNode();
parent.removeChild(groups);
}
}
else
{
qCDebug(vUndo, "Can't get group by id = %u.", nodeId);
return;
}
}
else
{
qCDebug(vUndo, "Can't get tag Groups.");
return;
}
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}

View File

@ -0,0 +1,49 @@
/************************************************************************
**
** @file delgroup.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 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 DELGROUP_H
#define DELGROUP_H
#include "vundocommand.h"
class DelGroup : public VUndoCommand
{
Q_OBJECT
public:
DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr);
virtual ~DelGroup();
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
signals:
void UpdateGroups();
private:
Q_DISABLE_COPY(DelGroup)
const QString nameActivDraw;
};
#endif // DELGROUP_H

View File

@ -18,7 +18,9 @@ HEADERS += \
$$PWD/vundocommand.h \
$$PWD/renamepp.h \
$$PWD/movelabel.h \
$$PWD/movedoublelabel.h
$$PWD/movedoublelabel.h \
$$PWD/addgroup.h \
$$PWD/delgroup.h
SOURCES += \
$$PWD/addtocalc.cpp \
@ -37,4 +39,6 @@ SOURCES += \
$$PWD/vundocommand.cpp \
$$PWD/renamepp.cpp \
$$PWD/movelabel.cpp \
$$PWD/movedoublelabel.cpp
$$PWD/movedoublelabel.cpp \
$$PWD/addgroup.cpp \
$$PWD/delgroup.cpp

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)