Merge with feature.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-05-19 17:20:22 +03:00
commit d30ea3bca8
213 changed files with 5841 additions and 1739 deletions

View File

@ -23,6 +23,7 @@
- [#478] Rename 'Print preview tiled' to 'Preview Tiled PDF'.
- [#472] Add 'Full Name' column to Formula dialog.
- [#487] True dart point always goes to origin when the label is moved.
- [#128] New Tool: Slash and Spread.
# Version 0.4.5
- [#435] Valentina doesn't change the cursor.

View File

@ -59,6 +59,12 @@ QString VLitePattern::GenerateLabel(const LabelType &type, const QString &reserv
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
QString VLitePattern::GenerateSuffix() const
{
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
void VLitePattern::UpdateToolData(const quint32 &id, VContainer *data)
{

View File

@ -43,6 +43,7 @@ public:
virtual void DecrementReferens(quint32 id) const Q_DECL_OVERRIDE;
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const Q_DECL_OVERRIDE;
virtual QString GenerateSuffix() const Q_DECL_OVERRIDE;
virtual void UpdateToolData(const quint32 &id, VContainer *data) Q_DECL_OVERRIDE;

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) == 42, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
switch (item->type())
{
@ -177,6 +177,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolTrueDarts::Type:
ShowOptionsToolTrueDarts(item);
break;
case VToolRotation::Type:
ShowOptionsToolRotation(item);
break;
default:
break;
}
@ -191,7 +194,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) == 42, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -288,6 +291,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolTrueDarts::Type:
UpdateOptionsToolTrueDarts();
break;
case VToolRotation::Type:
UpdateOptionsToolRotation();
break;
default:
break;
}
@ -323,7 +329,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) == 42, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -414,6 +420,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolTrueDarts::Type:
ChangeDataToolTrueDarts(prop);
break;
case VToolRotation::Type:
ChangeDataToolRotation(prop);
break;
default:
break;
}
@ -481,7 +490,6 @@ void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &
AddProperty(itemName, AttrName);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName)
@ -502,6 +510,17 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &
AddProperty(itemName, AttrName2);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyOperationSuffix(Tool *i, const QString &propertyName, bool readOnly)
{
auto itemSuffix = new VStringProperty(propertyName);
itemSuffix->setClearButtonEnable(true);
itemSuffix->setValue(i->Suffix());
itemSuffix->setReadOnly(readOnly);
AddProperty(itemSuffix, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName)
@ -645,6 +664,43 @@ void VToolOptionsPropertyBrowser::SetPointName2(const QString &name)
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix)
{
if (Tool *item = qgraphicsitem_cast<Tool *>(currentItem))
{
if (suffix == item->Suffix())
{
return;
}
if (suffix.isEmpty())
{
idToProperty[AttrSuffix]->setValue(item->Suffix());
return;
}
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i)
{
const QString name = uniqueNames.at(i) + suffix;
if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name))
{
idToProperty[AttrSuffix]->setValue(item->Suffix());
return;
}
}
item->SetSuffix(suffix);
}
else
{
qWarning()<<"Can't cast item";
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Type>
Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value)
@ -934,9 +990,6 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VProperty *property)
case 4: // AttrLength
i->SetFormula(value.value<VFormula>());
break;
case 27: // AttrTypeColor
i->SetLineColor(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -961,9 +1014,6 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSpline(VProperty *property)
case 4: // AttrLength
i->SetFormula(value.value<VFormula>());
break;
case 27: // AttrTypeColor
i->SetLineColor(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -988,9 +1038,6 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSplinePath(VProperty *propert
case 4: // AttrLength
i->SetFormula(value.value<VFormula>());
break;
case 27: // AttrTypeColor
i->SetLineColor(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1525,6 +1572,30 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCurveIntersectAxis(VProperty *pr
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolRotation *i = qgraphicsitem_cast<VToolRotation *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 38: // AttrSuffix
SetOperationSuffix<VToolRotation>(value.toString());
break;
case 5: // AttrAngle
i->SetFormulaAngle(value.value<VFormula>());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
{
@ -1625,7 +1696,6 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item)
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1637,7 +1707,6 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item)
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1649,7 +1718,6 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1907,6 +1975,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item)
{
VToolRotation *i = qgraphicsitem_cast<VToolRotation *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool rotation"));
AddPropertyOperationSuffix(i, tr("Suffix"));
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
{
@ -2044,9 +2123,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc()
QVariant valueFormula;
valueFormula.setValue(i->GetFormula());
idToProperty[AttrLength]->setValue(valueFormula);
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2059,9 +2135,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline()
QVariant valueFormula;
valueFormula.setValue(i->GetFormula());
idToProperty[AttrLength]->setValue(valueFormula);
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2074,9 +2147,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath()
QVariant valueFormula;
valueFormula.setValue(i->GetFormula());
idToProperty[AttrLength]->setValue(valueFormula);
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2365,6 +2435,17 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis()
idToProperty[AttrAngle]->setValue(valueAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation()
{
VToolRotation *i = qgraphicsitem_cast<VToolRotation *>(currentItem);
idToProperty[AttrSuffix]->setValue(i->Suffix());
QVariant valueAngle;
valueAngle.setValue(i->GetFormulaAngle());
idToProperty[AttrAngle]->setValue(valueAngle);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
{
@ -2405,6 +2486,7 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
<< AttrVCrossPoint /* 34 */
<< AttrHCrossPoint /* 35 */
<< AttrLength1 /* 36 */
<< AttrLength2; /* 37 */
<< AttrLength2 /* 37 */
<< AttrSuffix; /* 38 */
return attr;
}

View File

@ -74,6 +74,9 @@ private:
template<class Tool>
void SetPointName2(const QString &name);
template<class Tool>
void SetOperationSuffix(const QString &suffix);
template<class Type>
Type GetCrossPoint(const QVariant &value);
@ -95,6 +98,9 @@ private:
template<class Tool>
void AddPropertyPointName2(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyOperationSuffix(Tool *i, const QString &propertyName, bool readOnly = false);
template<class Tool>
void AddPropertyCrossPoint(Tool *i, const QString &propertyName);
@ -144,6 +150,7 @@ private:
void ChangeDataToolTriangle(VPE::VProperty *property);
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
void ChangeDataToolRotation(VPE::VProperty *property);
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
void ShowOptionsToolEndLine(QGraphicsItem *item);
@ -174,6 +181,7 @@ private:
void ShowOptionsToolTriangle(QGraphicsItem *item);
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolRotation(QGraphicsItem *item);
void UpdateOptionsToolSinglePoint();
void UpdateOptionsToolEndLine();
@ -204,6 +212,7 @@ private:
void UpdateOptionsToolTriangle();
void UpdateOptionsToolLineIntersectAxis();
void UpdateOptionsToolCurveIntersectAxis();
void UpdateOptionsToolRotation();
};
#endif // VTOOLOPTIONSPROPERTYBROWSER_H

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

View File

@ -130,17 +130,8 @@ MainWindow::MainWindow(QWidget *parent)
}
CreateActions();
CreateMenus();
ToolBarDraws();
ToolBarStages();
InitToolButtons();
InitScenes();
helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working."));
ui->statusBar->addWidget(helpLabel);
ToolBarTools();
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear);
connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified);
@ -150,6 +141,17 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP);
qApp->setCurrentDocument(doc);
InitDocksContain();
CreateMenus();
ToolBarDraws();
ToolBarStages();
InitToolButtons();
helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working."));
ui->statusBar->addWidget(helpLabel);
ToolBarTools();
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
InitAutoSave();
@ -157,7 +159,6 @@ MainWindow::MainWindow(QWidget *parent)
ui->toolBox->setCurrentIndex(0);
ReadSettings();
InitDocksContain();
setCurrentFile("");
WindowsLocale();
@ -613,6 +614,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
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::DialogApplied, this, applyDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
@ -1004,12 +1006,22 @@ void MainWindow::ClosedDialogUnionDetails(int result)
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::ToolRotation(bool checked)
{
ToolSelectOperationObjects();
SetToolButtonWithApply<DialogRotation>(checked, Tool::Rotation,
":/cursor/rotation_cursor.png",
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
&MainWindow::ClosedDialogWithApply<VToolRotation>,
&MainWindow::ApplyDialog<VToolRotation>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ClosedDialogGroup(int result)
{
@ -1737,6 +1749,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
connect(ui->toolButtonRotation, &QToolButton::clicked, this, &MainWindow::ToolRotation);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1777,12 +1790,16 @@ 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) == 42, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
dialogTool = nullptr;
qCDebug(vMainWindow, "Dialog closed.");
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
switch ( currentTool )
{
case Tool::Arrow:
@ -1904,9 +1921,10 @@ void MainWindow::CancelTool()
case Tool::Group:
ui->toolButtonGroup->setChecked(false);
break;
case Tool::Rotation:
ui->toolButtonRotation->setChecked(false);
break;
}
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
// Crash: using CRTL+Z while using line tool.
// related bug report:
@ -3109,6 +3127,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonArcWithLength->setEnabled(drawTools);
ui->toolButtonTrueDarts->setEnabled(drawTools);
ui->toolButtonGroup->setEnabled(drawTools);
ui->toolButtonRotation->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools);
@ -3353,12 +3372,14 @@ void MainWindow::CreateMenus()
//Add Undo/Redo actions.
undoAction = qApp->getUndoStack()->createUndoAction(this, tr("&Undo"));
connect(undoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions);
undoAction->setShortcuts(QKeySequence::Undo);
undoAction->setIcon(QIcon::fromTheme("edit-undo"));
ui->menuPatternPiece->insertAction(ui->actionLast_tool, undoAction);
ui->toolBarTools->addAction(undoAction);
redoAction = qApp->getUndoStack()->createRedoAction(this, tr("&Redo"));
connect(redoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions);
redoAction->setShortcuts(QKeySequence::Redo);
redoAction->setIcon(QIcon::fromTheme("edit-redo"));
ui->menuPatternPiece->insertAction(ui->actionLast_tool, redoAction);
@ -3379,7 +3400,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) == 42, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was handled.");
if (currentTool == lastUsedTool)
{
@ -3530,6 +3551,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonGroup->setChecked(true);
ToolGroup(true);
break;
case Tool::Rotation:
ui->toolButtonRotation->setChecked(true);
ToolRotation(true);
break;
}
}
@ -4714,12 +4739,12 @@ void MainWindow::ToolSelectAllDrawObjects() const
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectGroupObjects() const
void MainWindow::ToolSelectOperationObjects() const
{
// Only true for rubber band selection
emit EnableLabelSelection(true);
emit EnablePointSelection(true);
emit EnableLineSelection(true);
emit EnableLineSelection(false);
emit EnableArcSelection(true);
emit EnableSplineSelection(true);
emit EnableSplinePathSelection(true);
@ -4727,7 +4752,7 @@ void MainWindow::ToolSelectGroupObjects() const
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
@ -4737,6 +4762,17 @@ void MainWindow::ToolSelectGroupObjects() const
ui->view->AllowRubberBand(true);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectGroupObjects() const
{
ToolSelectOperationObjects();
// Only true for rubber band selection
emit EnableLineSelection(true);
// Hovering
emit EnableLineHover(true);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectDetail() const
{

View File

@ -122,6 +122,7 @@ public slots:
void ToolPointOfIntersection(bool checked);
void ToolUnionDetails(bool checked);
void ToolGroup(bool checked);
void ToolRotation(bool checked);
void ToolCutArc(bool checked);
void ToolLineIntersectAxis(bool checked);
void ToolCurveIntersectAxis(bool checked);
@ -372,6 +373,7 @@ private:
void ToolSelectPointArc() const;
void ToolSelectCurve() const;
void ToolSelectAllDrawObjects() const;
void ToolSelectOperationObjects() const;
void ToolSelectGroupObjects() const;
void ToolSelectDetail() const;
};

View File

@ -983,6 +983,32 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButtonRotation">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Rotate objects</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/rotation.png</normaloff>:/toolicon/32x32/rotation.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">

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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"
width="64mm"
height="64mm"
viewBox="0 0 226.77165 226.77165"
id="svg2"
version="1.1"
inkscape:version="0.91 r"
sodipodi:docname="rotation.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2"
inkscape:cx="95.256309"
inkscape:cy="193.75942"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-109.37599,-227.40381)">
<g
id="g4161"
transform="matrix(1.4799279,0,0,1.514144,-50.49258,-240.01162)">
<path
style="fill:#4c4c4e"
d="m 175.63227,452.76646 c -4.46875,-0.93774 -11.21875,-3.08929 -15,-4.78121 -8.24709,-3.69017 -21.35406,-13.37364 -24.40567,-18.03098 -2.17124,-3.31373 -2.15358,-3.39279 1.41601,-6.34044 8.98492,-7.41942 8.5619,-7.37711 15.15272,-1.51551 7.49569,6.66635 18.87856,12.10104 29.12615,13.90613 15.6875,2.76328 32.5699,-2.90492 44.78685,-15.03701 21.30761,-21.15965 21.42043,-54.09472 0.25774,-75.24597 -16.4986,-16.48969 -40.34704,-20.56179 -61.06292,-10.42646 -7.89028,3.86036 -20.27088,15.13215 -20.27088,18.45542 0,1.46429 2.69199,3.44216 8.18114,6.01083 4.49962,2.10564 7.97069,4.45977 7.71347,5.2314 -0.76092,2.28276 -43.5192,27.43921 -44.63742,26.26202 -0.85926,-0.90458 -7.53255,-46.56479 -7.51343,-51.40866 0.004,-1.03123 2.60033,-0.271 7.47059,2.1875 4.1054,2.07239 8.48533,3.76799 9.73318,3.76799 1.26595,0 4.32338,-2.75199 6.91685,-6.22583 8.0603,-10.79646 20.45023,-19.26242 35.88562,-24.52041 9.52071,-3.2432 30.42538,-3.25368 40,-0.0201 24.10475,8.14083 41.33866,25.60172 48.25576,48.8913 3.36888,11.34283 3.081,28.84652 -0.6646,40.40947 -11.1378,34.38337 -46.87719,55.6626 -81.34116,48.4305 z"
id="path3349"
inkscape:connector-curvature="0" />
<path
d="m 205.99674,384.45563 a 16.359516,16.624689 0 0 1 -16.33832,16.62467 16.359516,16.624689 0 0 1 -16.38066,-16.58158 16.359516,16.624689 0 0 1 16.29586,-16.66766 16.359516,16.624689 0 0 1 16.4229,16.53839"
sodipodi:open="true"
sodipodi:end="6.2780017"
sodipodi:start="0"
sodipodi:ry="16.624689"
sodipodi:rx="16.359516"
sodipodi:cy="384.45563"
sodipodi:cx="189.63722"
sodipodi:type="arc"
id="path3357"
style="opacity:1;fill:#da4d3b;fill-opacity:1;fill-rule:evenodd;stroke:#da4d3b;stroke-width:1.82180572;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -305,8 +305,7 @@ quint32 VPattern::SPointActiveDraw()
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == VToolSinglePoint::TagName &&
domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
if (domElement.tagName() == TagPoint && domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
{
return GetParametrId(domElement);
}
@ -527,7 +526,7 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const
{
scene = sceneDetail;
}
QStringList tags = QStringList() << TagPoint << TagLine << TagSpline << TagArc << TagTools;
const QStringList tags = QStringList() << TagPoint << TagLine << TagSpline << TagArc << TagTools << TagOperation;
const QDomNodeList nodeList = node.childNodes();
const qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
@ -557,6 +556,10 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const
qCDebug(vXML, "Tag tools.");
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
break;
case 5: // TagOperation
qCDebug(vXML, "Tag operation.");
ParseOperationElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
break;
default:
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
throw e;
@ -596,7 +599,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
{
if (element.tagName() == VToolDetail::TagNode)
{
const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, NULL_ID_STR);
const quint32 id = GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
const qreal mx = qApp->toPixel(GetParametrDouble(element, AttrMx, "0.0"));
const qreal my = qApp->toPixel(GetParametrDouble(element, AttrMy, "0.0"));
const bool reverse = GetParametrUInt(element, VToolDetail::AttrReverse, "0");
@ -654,7 +657,7 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == VToolDetail::TagName)
if (domElement.tagName() == TagDetail)
{
ParseDetailElement(domElement, parse);
}
@ -840,7 +843,7 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
{
ToolsCommonAttributes(domElement, id);
idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
}
@ -1279,7 +1282,7 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
qreal my = 0;
PointsCommonAttributes(domElement, id, mx, my);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
QSharedPointer<VPointF> point;
try
@ -1291,8 +1294,7 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
Q_UNUSED(e);
return;// Just ignore
}
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling));
data->UpdateGObject(id, new VPointF(*point, point->name(), mx, my, idObject, Draw::Modeling));
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
@ -1410,11 +1412,8 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
const QString formula = GetParametrString(domElement, AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
const QString color = GetParametrString(domElement, AttrColor,
ColorBlack);
VToolCutSpline::Create(id, name, f, splineId, mx, my, color, scene, this, data, parse,
Source::FromFile);
VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
@ -1455,11 +1454,8 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
QString f = formula;//need for saving fixed formula;
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath,
NULL_ID_STR);
const QString color = GetParametrString(domElement, AttrColor,
ColorBlack);
VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, color, scene, this, data, parse,
Source::FromFile);
VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
@ -1499,9 +1495,8 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen
const QString formula = GetParametrString(domElement, AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
VToolCutArc::Create(id, name, f, arcId, mx, my, color, scene, this, data, parse, Source::FromFile);
VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
@ -2330,7 +2325,7 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
quint32 id = 0;
ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
VArc *arc = nullptr;
try
@ -2401,6 +2396,49 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
try
{
quint32 id = NULL_ID;
ToolsCommonAttributes(domElement, id);
const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
const QString angle = GetParametrString(domElement, AttrAngle, "10");
QString a = angle;//need for saving fixed formula;
const QString suffix = GetParametrString(domElement, AttrSuffix, "");
QVector<quint32> source;
QVector<DestinationItem> destination;
VToolRotation::ExtractData(this, domElement, source, destination);
VToolRotation::Create(id, center, a, suffix, source, destination, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (a != angle)
{
SetAttribute(domElement, AttrAngle, a);
modified = true;
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
catch (qmu::QmuParserError &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
{
@ -2644,6 +2682,27 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
const QString &type)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
const QStringList opers = QStringList() << VToolRotation::ToolType; /*0*/
switch (opers.indexOf(type))
{
case 0: //VToolRotation::ToolType
ParseToolRotation(scene, domElement, parse);
break;
default:
VException e(tr("Unknown operation type '%1'.").arg(type));
throw e;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ParseIncrementsElement parse increments tag.
@ -2814,10 +2873,9 @@ void VPattern::SetIncrementDescription(const QString &name, const QString &text)
*/
QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedName) const
{
QDomNodeList drawList = elementsByTagName(TagDraw);
if (type == LabelType::NewPatternPiece)
{
const QDomNodeList drawList = elementsByTagName(TagDraw);
QString name;
int i = 0;
for (;;)
@ -2838,25 +2896,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa
}
else if (type == LabelType::NewLabel)
{
if (drawList.isEmpty())
{
const QString label = GetLabelBase(0);
qCDebug(vXML, "Point label: %s", qUtf8Printable(label));
return label;
}
int index = 0;
for (int i = 0; i < drawList.size(); ++i)
{
QDomElement node = drawList.at(i).toElement();
if (node.attribute(AttrName) == nameActivPP)
{
index = i;
break;
}
}
QString labelBase = GetLabelBase(static_cast<quint32>(index));
const QString labelBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP()));
qint32 num = 1;
QString name;
@ -2876,6 +2916,40 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GenerateSuffix() const
{
const QString suffixBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP())).toLower();
const QStringList uniqueNames = data->AllUniqueNames();
qint32 num = 1;
QString suffix;
for (;;)
{
suffix = QString("%1%2").arg(suffixBase).arg(num);
for (int i=0; i < uniqueNames.size(); ++i)
{
if (not data->IsUnique(uniqueNames.at(i) + suffix))
{
break;
}
if (i == uniqueNames.size()-1)
{
qCDebug(vXML, "Suffix is: %s", qUtf8Printable(suffix));
return suffix;
}
}
if (num == INT_MAX)
{
break;
}
++num;
}
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPattern::IsDefCustom() const
{
@ -3130,7 +3204,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) == 42, "Not all tools was used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used.");
QRectF rec;
@ -3237,6 +3311,9 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::TrueDarts:
rec = ToolBoundingRect<VToolTrueDarts>(rec, tool.getId());
break;
case Tool::Rotation:
rec = ToolBoundingRect<VToolRotation>(rec, tool.getId());
break;
//These tools are not accesseble in Draw mode, but still 'history' contains them.
case Tool::Detail:
case Tool::UnionDetails:

View File

@ -77,6 +77,7 @@ public:
void SetIncrementDescription(const QString &name, const QString &text);
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const Q_DECL_OVERRIDE;
virtual QString GenerateSuffix() const Q_DECL_OVERRIDE;
bool IsDefCustom() const;
void SetDefCustom(bool value);
@ -125,6 +126,8 @@ private:
const Document &parse, const QString& type);
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document &parse, const QString& type);
void ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
const QString& type);
void ParseIncrementsElement(const QDomNode& node);
void PrepareForParse(const Document &parse);
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
@ -185,6 +188,8 @@ private:
void ParseNodeArc(const QDomElement &domElement, const Document &parse);
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
QDomElement MakeEmptyIncrement(const QString &name);

View File

@ -128,6 +128,8 @@ const QString AttrCCenter = QStringLiteral("cCenter");
const QString AttrTangent = QStringLiteral("tangent");
const QString AttrCRadius = QStringLiteral("cRadius");
const QString AttrArc = QStringLiteral("arc");
const QString AttrSuffix = QStringLiteral("suffix");
const QString AttrIdObject = QStringLiteral("idObject");
const QString TypeLineNone = QStringLiteral("none");
const QString TypeLineLine = QStringLiteral("hair");

View File

@ -130,6 +130,8 @@ extern const QString AttrCCenter;
extern const QString AttrTangent;
extern const QString AttrCRadius;
extern const QString AttrArc;
extern const QString AttrSuffix;
extern const QString AttrIdObject;
extern const QString TypeLineNone;
extern const QString TypeLineLine;

View File

@ -14,6 +14,7 @@
<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/pattern/v0.3.1.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,515 @@
<?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="operation" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="source" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="destination" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="suffix" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string" use="required"></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

@ -38,6 +38,7 @@ const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
@ -54,6 +55,7 @@ const QString VAbstractPattern::TagLine = QStringLiteral("line");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
const QString VAbstractPattern::TagGradation = QStringLiteral("gradation");
const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
@ -1170,6 +1172,28 @@ void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &ele
SetVersion();
}
//---------------------------------------------------------------------------------------------------------------------
int VAbstractPattern::GetIndexActivPP() const
{
const QDomNodeList drawList = elementsByTagName(TagDraw);
int index = 0;
if (not drawList.isEmpty())
{
for (int i = 0; i < drawList.size(); ++i)
{
QDomElement node = drawList.at(i).toElement();
if (node.attribute(AttrName) == nameActivPP)
{
index = i;
break;
}
}
}
return index;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListIncrements() const
{
@ -1201,6 +1225,7 @@ QStringList VAbstractPattern::ListExpressions() const
list << ListArcExpressions();
list << ListSplineExpressions();
list << ListIncrementExpressions();
list << ListOperationExpressions();
return list;
}
@ -1208,6 +1233,10 @@ QStringList VAbstractPattern::ListExpressions() const
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
for (int i=0; i < list.size(); ++i)
@ -1275,6 +1304,10 @@ QStringList VAbstractPattern::ListPointExpressions() const
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListArcExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
for (int i=0; i < list.size(); ++i)
@ -1332,6 +1365,10 @@ QStringList VAbstractPattern::ListSplineExpressions() const
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListPathPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
for (int i=0; i < list.size(); ++i)
@ -1391,6 +1428,33 @@ QStringList VAbstractPattern::ListIncrementExpressions() const
return expressions;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListOperationExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagOperation);
for (int i=0; i < list.size(); ++i)
{
const QDomElement dom = list.at(i).toElement();
// Each tag can contains several attributes.
try
{
expressions.append(GetParametrString(dom, AttrAngle));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
}
return expressions;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsVariable(const QString &token) const
{

View File

@ -74,6 +74,7 @@ public:
virtual void DecrementReferens(quint32 id) const=0;
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const=0;
virtual QString GenerateSuffix() const=0;
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0;
@ -132,6 +133,7 @@ public:
static const QString TagCalculation;
static const QString TagModeling;
static const QString TagDetails;
static const QString TagDetail;
static const QString TagAuthor;
static const QString TagDescription;
static const QString TagImage;
@ -148,6 +150,7 @@ public:
static const QString TagSpline;
static const QString TagArc;
static const QString TagTools;
static const QString TagOperation;
static const QString TagGradation;
static const QString TagHeights;
static const QString TagSizes;
@ -210,7 +213,7 @@ public:
signals:
/**
* @brief ChangedActivDraw change active pattern peace.
* @brief ChangedActivPP change active pattern peace.
* @param newName new pattern peace name.
*/
void ChangedActivPP(const QString &newName);
@ -282,6 +285,7 @@ protected:
QDomElement CheckTagExists(const QString &tag);
void InsertTag(const QStringList &tags, const QDomElement &element);
int GetIndexActivPP() const;
private:
Q_DISABLE_COPY(VAbstractPattern)
@ -292,6 +296,7 @@ private:
QStringList ListSplineExpressions() const;
QStringList ListPathPointExpressions() const;
QStringList ListIncrementExpressions() const;
QStringList ListOperationExpressions() const;
bool IsVariable(const QString& token) const;
bool IsPostfixOperator(const QString& token) const;

View File

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.0.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.1.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -111,8 +111,10 @@ 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");
return QStringLiteral("://schema/pattern/v0.2.7.xsd");
case (0x000300):
return QStringLiteral("://schema/pattern/v0.3.0.xsd");
case (0x000301):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -128,97 +130,62 @@ void VPatternConverter::ApplyPatches()
switch (ver)
{
case (0x000100):
{
ToV0_1_1();
const QString schema = XSDSchema(0x000101);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000101), fileName);
V_FALLTHROUGH
}
case (0x000101):
{
ToV0_1_2();
const QString schema = XSDSchema(0x000102);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000102), fileName);
V_FALLTHROUGH
}
case (0x000102):
{
ToV0_1_3();
const QString schema = XSDSchema(0x000103);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000103), fileName);
V_FALLTHROUGH
}
case (0x000103):
{
ToV0_1_4();
const QString schema = XSDSchema(0x000104);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000104), fileName);
V_FALLTHROUGH
}
case (0x000104):
{
ToV0_2_0();
const QString schema = XSDSchema(0x000200);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000200), fileName);
V_FALLTHROUGH
}
case (0x000200):
{
ToV0_2_1();
const QString schema = XSDSchema(0x000201);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000201), fileName);
V_FALLTHROUGH
}
case (0x000201):
{
ToV0_2_2();
const QString schema = XSDSchema(0x000202);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000202), fileName);
V_FALLTHROUGH
}
case (0x000202):
{
ToV0_2_3();
const QString schema = XSDSchema(0x000203);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000203), fileName);
V_FALLTHROUGH
}
case (0x000203):
{
ToV0_2_4();
const QString schema = XSDSchema(0x000204);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000204), fileName);
V_FALLTHROUGH
}
case (0x000204):
{
ToV0_2_5();
const QString schema = XSDSchema(0x000205);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000205), fileName);
V_FALLTHROUGH
}
case (0x000205):
{
ToV0_2_6();
const QString schema = XSDSchema(0x000206);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000206), fileName);
V_FALLTHROUGH
}
case (0x000206):
{
ToV0_2_7();
const QString schema = XSDSchema(0x000207);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000207), fileName);
V_FALLTHROUGH
}
case (0x000207):
{
ToV0_3_0();
const QString schema = XSDSchema(0x000300);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000300), fileName);
V_FALLTHROUGH
}
case (0x000300):
ToV0_3_1();
ValidateXML(XSDSchema(0x000301), fileName);
V_FALLTHROUGH
case (0x000301):
break;
default:
break;
@ -347,6 +314,14 @@ void VPatternConverter::ToV0_3_0()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_3_1()
{
SetVersion(QStringLiteral("0.3.1"));
RemoveColorToolCutV0_3_1();
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
@ -808,6 +783,26 @@ void VPatternConverter::ConvertMeasurementsToV0_2_1()
ConvertPathPointExpressionsToV0_2_0(names);
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::RemoveColorToolCutV0_3_1()
{
const QDomNodeList list = elementsByTagName("point");
for (int i=0; i < list.size(); ++i)
{
QDomElement element = list.at(i).toElement();
if (not element.isNull())
{
const QString type = element.attribute(QStringLiteral("type"));
if (type == QStringLiteral("cutArc") ||
type == QStringLiteral("cutSpline") ||
type == QStringLiteral("cutSplinePath"))
{
element.removeAttribute(QStringLiteral("color"));
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VPatternConverter::MUnitV0_1_4() const
{

View File

@ -69,6 +69,7 @@ private:
void ToV0_2_6();
void ToV0_2_7();
void ToV0_3_0();
void ToV0_3_1();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
@ -77,6 +78,8 @@ private:
void ConvertMeasurementsToV0_2_1();
void RemoveColorToolCutV0_3_1();
QSet<QString> FixIncrementsToV0_2_0();
QString FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet<QString> &names);
void FixPointExpressionsToV0_2_0(const QSet<QString> &names);

View File

@ -107,33 +107,21 @@ void VVITConverter::ApplyPatches()
switch (ver)
{
case (0x000200):
{
ToV0_3_0();
const QString schema = XSDSchema(0x000300);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000300), fileName);
V_FALLTHROUGH
}
case (0x000300):
{
ToV0_3_1();
const QString schema = XSDSchema(0x000301);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000301), fileName);
V_FALLTHROUGH
}
case (0x000301):
{
ToV0_3_2();
const QString schema = XSDSchema(0x000302);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000302), fileName);
V_FALLTHROUGH
}
case (0x000302):
{
ToV0_3_3();
const QString schema = XSDSchema(0x000303);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000303), fileName);
V_FALLTHROUGH
}
case (0x000303):
break;
default:

View File

@ -105,26 +105,17 @@ void VVSTConverter::ApplyPatches()
switch (ver)
{
case (0x000300):
{
ToV0_4_0();
const QString schema = XSDSchema(0x000400);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000400), fileName);
V_FALLTHROUGH
}
case (0x000400):
{
ToV0_4_1();
const QString schema = XSDSchema(0x000401);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000401), fileName);
V_FALLTHROUGH
}
case (0x000401):
{
ToV0_4_2();
const QString schema = XSDSchema(0x000402);
ValidateXML(schema, fileName);
ValidateXML(XSDSchema(0x000402), fileName);
V_FALLTHROUGH
}
case (0x000402):
break;
default:

View File

@ -0,0 +1,208 @@
/************************************************************************
**
** @file vabstractarc.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 "vabstractarc.h"
#include "vabstractarc_p.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData())
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1, formulaF1, f2, formulaF2))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1, f2))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const QString &formulaLength, const VPointF &center,
qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(formulaLength, center, f1, formulaF1))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const VAbstractArc &arc)
: VAbstractCurve(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc &VAbstractArc::operator=(const VAbstractArc &arc)
{
if ( &arc == this )
{
return *this;
}
VAbstractCurve::operator=(arc);
d = arc.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::~VAbstractArc()
{}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF1() const
{
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaF1(const QString &formula, qreal value)
{
d->formulaF1 = formula;
d->f1 = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetStartAngle() const
{
return d->f1;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF2() const
{
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaF2(const QString &formula, qreal value)
{
d->formulaF2 = formula;
d->f2 = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetEndAngle() const
{
return d->f2;
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VAbstractArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetCenter(const VPointF &point)
{
d->center = point;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaLength() const
{
return d->formulaLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaLength(const QString &formula, qreal value)
{
d->formulaLength = formula;
FindF2(value);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractArc::IsFlipped() const
{
return d->isFlipped;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::AngleArc() const
{
{
const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle());
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{
return 360;
}
}
QLineF l1(0, 0, 100, 0);
l1.setAngle(GetStartAngle());
QLineF l2(0, 0, 100, 0);
l2.setAngle(GetEndAngle());
qreal ang = l1.angleTo(l2);
if (IsFlipped())
{
ang = 360 - ang;
}
return ang;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFlipped(bool value)
{
d->isFlipped = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaLength(const QString &formula)
{
d->formulaLength = formula;
}

View File

@ -0,0 +1,80 @@
/************************************************************************
**
** @file vabstractarc.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 VABSTRACTARC_H
#define VABSTRACTARC_H
#include "vabstractcurve.h"
class VAbstractArcData;
class VPointF;
class VAbstractArc : public VAbstractCurve
{
public:
explicit VAbstractArc(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject = 0,
Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const QString &formulaLength, const VPointF &center, qreal f1,
const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, quint32 idObject = 0,
Draw mode = Draw::Calculation);
explicit VAbstractArc(const VAbstractArc &arc);
VAbstractArc& operator= (const VAbstractArc &arc);
virtual ~VAbstractArc();
QString GetFormulaF1 () const;
void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
QString GetFormulaF2 () const;
void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
VPointF GetCenter () const;
void SetCenter (const VPointF &point);
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
bool IsFlipped() const;
qreal AngleArc() const;
protected:
void SetFlipped(bool value);
virtual void FindF2(qreal length)=0;
void SetFormulaLength(const QString &formula);
private:
QSharedDataPointer<VAbstractArcData> d;
};
#endif // VABSTRACTARC_H

View File

@ -0,0 +1,148 @@
/************************************************************************
**
** @file VAbstractArcData.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 VABSTRACTARC_P_H
#define VABSTRACTARC_P_H
#include <QSharedData>
#include "vgeometrydef.h"
#include "../vmisc/vabstractapplication.h"
#include "vpointf.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
class VAbstractArcData : public QSharedData
{
public:
VAbstractArcData();
VAbstractArcData(const VPointF &center, qreal f1, const QString &formulaF1, qreal f2, const QString &formulaF2);
VAbstractArcData(const QString &formulaLength, VPointF center, qreal f1, QString formulaF1);
VAbstractArcData(const VPointF &center, qreal f1);
VAbstractArcData(const VPointF &center, qreal f1, qreal f2);
VAbstractArcData(const VAbstractArcData &arc);
virtual ~VAbstractArcData();
/** @brief f1 start angle in degree. */
qreal f1;
/** @brief formulaF1 formula for start angle. */
QString formulaF1;
/** @brief f2 end angle in degree. */
qreal f2;
/** @brief formulaF2 formula for end angle. */
QString formulaF2;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
private:
VAbstractArcData &operator=(const VAbstractArcData &) Q_DECL_EQ_DELETE;
};
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData()
: f1(0),
formulaF1(),
f2(0),
formulaF2(),
center(),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2)
: f1(f1),
formulaF1(formulaF1),
f2(f2),
formulaF2(formulaF2),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const QString &formulaLength, VPointF center, qreal f1, QString formulaF1)
: f1(f1),
formulaF1(formulaF1),
f2(0),
formulaF2("0"),
center(center),
isFlipped(false),
formulaLength(formulaLength)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1)
: f1(f1),
formulaF1(QString().number(f1)),
f2(0),
formulaF2("0"),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1, qreal f2)
: f1(f1),
formulaF1(QString().number(f1)),
f2(f2),
formulaF2(QString().number(f2)),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VAbstractArcData &arc)
: QSharedData(arc),
f1(arc.f1),
formulaF1(arc.formulaF1),
f2(arc.f2),
formulaF2(arc.formulaF2),
center(arc.center),
isFlipped(arc.isFlipped),
formulaLength(arc.formulaLength)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::~VAbstractArcData()
{}
#endif // VABSTRACTARCDATA_H

View File

@ -97,7 +97,7 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
const qreal parT = GetParmT(length);
QLineF seg1_2 ( GetP1 ().toQPointF(), GetControlPoint1 () );
QLineF seg1_2 ( GetP1 (), GetControlPoint1 () );
seg1_2.setLength(seg1_2.length () * parT);
const QPointF p12 = seg1_2.p2();
@ -109,7 +109,7 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
seg12_23.setLength(seg12_23.length () * parT);
const QPointF p123 = seg12_23.p2();
QLineF seg3_4 ( GetControlPoint2 (), GetP4 ().toQPointF() );
QLineF seg3_4 ( GetControlPoint2 (), GetP4 () );
seg3_4.setLength(seg3_4.length () * parT);
const QPointF p34 = seg3_4.p2();
@ -547,7 +547,7 @@ qreal VAbstractCubicBezier::LengthT(qreal t) const
qDebug()<<"Wrong value t.";
return 0;
}
QLineF seg1_2 ( GetP1 ().toQPointF(), GetControlPoint1 () );
QLineF seg1_2 ( GetP1 (), GetControlPoint1 () );
seg1_2.setLength(seg1_2.length () * t);
const QPointF p12 = seg1_2.p2();
@ -559,7 +559,7 @@ qreal VAbstractCubicBezier::LengthT(qreal t) const
seg12_23.setLength(seg12_23.length () * t);
const QPointF p123 = seg12_23.p2();
QLineF seg3_4 ( GetControlPoint2 (), GetP4 ().toQPointF() );
QLineF seg3_4 ( GetControlPoint2 (), GetP4 () );
seg3_4.setLength(seg3_4.length () * t);
const QPointF p34 = seg3_4.p2();
@ -571,5 +571,5 @@ qreal VAbstractCubicBezier::LengthT(qreal t) const
seg123_234.setLength(seg123_234.length () * t);
const QPointF p1234 = seg123_234.p2();
return LengthBezier ( GetP1().toQPointF(), p12, p123, p1234);
return LengthBezier ( GetP1(), p12, p123, p1234);
}

View File

@ -244,6 +244,18 @@ void VAbstractCurve::SetDuplicate(quint32 number)
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractCurve::GetColor() const
{
return d->color;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractCurve::SetColor(const QString &color)
{
d->color = color;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line)
{

View File

@ -69,6 +69,9 @@ public:
quint32 GetDuplicate() const;
void SetDuplicate(quint32 number);
QString GetColor() const;
void SetColor(const QString &color);
static QVector<QPointF> CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line);
virtual QString NameForHistory(const QString &toolName) const=0;

View File

@ -31,6 +31,8 @@
#include <QSharedData>
#include "../ifc/ifcdef.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
@ -41,11 +43,11 @@ class VAbstractCurveData : public QSharedData
public:
VAbstractCurveData ()
: duplicate(0)
: duplicate(0), color(ColorBlack)
{}
VAbstractCurveData(const VAbstractCurveData &curve)
: QSharedData(curve), duplicate(curve.duplicate)
: QSharedData(curve), duplicate(curve.duplicate), color(curve.color)
{}
virtual ~VAbstractCurveData();
@ -53,6 +55,8 @@ public:
/** @brief duplicate helps create unique name for curves that connects the same start and finish points. */
quint32 duplicate;
QString color;
private:
VAbstractCurveData &operator=(const VAbstractCurveData &) Q_DECL_EQ_DELETE;
};

View File

@ -42,7 +42,8 @@
* @brief VArc default constructor.
*/
VArc::VArc ()
:VAbstractCurve(GOType::Arc), d (new VArcData)
: VAbstractArc(GOType::Arc),
d (new VArcData)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -53,34 +54,36 @@ VArc::VArc ()
* @param f1 start angle (degree).
* @param f2 end angle (degree).
*/
VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2))
VArc::VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VArcData(radius, formulaRadius))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2))
VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
QString formulaF1, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1))
VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius,
const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VArcData(radius, formulaRadius))
{
CreateName();
FindF2(length);
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1))
VArc::VArc(qreal length, const VPointF &center, qreal radius, qreal f1)
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
{
CreateName();
FindF2(length);
@ -92,7 +95,7 @@ VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
* @param arc arc
*/
VArc::VArc(const VArc &arc)
: VAbstractCurve(arc), d (arc.d)
: VAbstractArc(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -107,11 +110,24 @@ VArc &VArc::operator =(const VArc &arc)
{
return *this;
}
VAbstractCurve::operator=(arc);
VAbstractArc::operator=(arc);
d = arc.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const VPointF center = GetCenter().Rotate(originPoint, degrees);
const QPointF p1 = VPointF::RotatePF(originPoint, GetP1(), degrees);
const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees);
VArc arc(center, GetRadius(), QLineF(center, p1).angle(), QLineF(center, p2).angle());
arc.setName(name() + prefix);
return arc;
}
//---------------------------------------------------------------------------------------------------------------------
VArc::~VArc()
{}
@ -124,7 +140,7 @@ VArc::~VArc()
qreal VArc::GetLength() const
{
qreal length = d->radius * qDegreesToRadians(AngleArc());
if (d->isFlipped)
if (IsFlipped())
{
length *= -1;
}
@ -140,8 +156,8 @@ qreal VArc::GetLength() const
QPointF VArc::GetP1() const
{
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP1(GetCenter().toQPointF(), p1);
centerP1.setAngle(d->f1);
QLineF centerP1(GetCenter(), p1);
centerP1.setAngle(GetStartAngle());
return centerP1.p2();
}
@ -153,40 +169,11 @@ QPointF VArc::GetP1() const
QPointF VArc::GetP2 () const
{
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP2(GetCenter().toQPointF(), p2);
centerP2.setAngle(d->f2);
QLineF centerP2(GetCenter(), p2);
centerP2.setAngle(GetEndAngle());
return centerP2.p2();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AngleArc calculate arc angle.
* @return angle in degree.
*/
qreal VArc::AngleArc() const
{
{
const qreal angleDiff = qAbs(d->f1 - d->f2);
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{
return 360;
}
}
QLineF l1(0, 0, 100, 0);
l1.setAngle(d->f1);
QLineF l2(0, 0, 100, 0);
l2.setAngle(d->f2);
qreal ang = l1.angleTo(l2);
if (d->isFlipped)
{
ang = 360 - ang;
}
return ang;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetPoints return list of points needed for drawing arc.
@ -198,7 +185,7 @@ QVector<QPointF> VArc::GetPoints() const
QVector<qreal> sectionAngle;
QPointF pStart;
d->isFlipped ? pStart = GetP2() : pStart = GetP1();
IsFlipped() ? pStart = GetP2() : pStart = GetP1();
{
qreal angle = AngleArc();
@ -234,7 +221,7 @@ QVector<QPointF> VArc::GetPoints() const
{
const qreal lDistance = GetRadius() * 4.0/3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25);
const QPointF center = GetCenter().toQPointF();
const QPointF center = GetCenter();
QLineF lineP1P2(pStart, center);
lineP1P2.setAngle(lineP1P2.angle() - 90.0);
@ -299,14 +286,14 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
qreal n = qRadiansToDegrees(len/d->radius); // n - is angle in degrees
QLineF line(GetCenter().toQPointF(), GetP1());
QLineF line(GetCenter(), GetP1());
line.setAngle(line.angle()+n);
arc1 = VArc (d->center, d->radius, d->formulaRadius, d->f1, d->formulaF1, line.angle(),
arc1 = VArc (GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
QString().setNum(line.angle()), getIdObject(), getMode());
arc2 = VArc (d->center, d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), d->f2,
d->formulaF2, getIdObject(), getMode());
arc2 = VArc (GetCenter(), d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), GetEndAngle(),
GetFormulaF2(), getIdObject(), getMode());
return line.p2();
}
@ -319,34 +306,6 @@ QPointF VArc::CutArc(const qreal &length) const
return this->CutArc(length, arc1, arc2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId keep id arc in data.
* @param id id arc in data.
*/
void VArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(this->GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::CreateName()
{
@ -368,7 +327,7 @@ void VArc::CreateName()
//---------------------------------------------------------------------------------------------------------------------
void VArc::FindF2(qreal length)
{
length < 0 ? d->isFlipped = true : d->isFlipped = false;
SetFlipped(length < 0);
if (length >= MaxLength())
{
@ -377,16 +336,15 @@ void VArc::FindF2(qreal length)
qreal arcAngle = qAbs(qRadiansToDegrees(length/d->radius));
if (d->isFlipped)
if (IsFlipped())
{
arcAngle = arcAngle * -1;
}
QLineF startAngle(0, 0, 100, 0);
startAngle.setAngle(d->f1 + arcAngle);// We use QLineF just because it is easy way correct angle value
startAngle.setAngle(GetStartAngle() + arcAngle);// We use QLineF just because it is easy way correct angle value
d->f2 = startAngle.angle();
d->formulaF2 = QString().number(d->f2);
SetFormulaF2(QString().number(startAngle.angle()), startAngle.angle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -395,60 +353,6 @@ qreal VArc::MaxLength() const
return M_2PI*d->radius;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return start angle.
* @return angle in degree.
*/
QString VArc::GetFormulaF1() const
{
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF1(const QString &formula, qreal value)
{
d->formulaF1 = formula;
d->f1 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return formula for start angle.
* @return string with formula.
*/
qreal VArc::GetStartAngle() const
{
return d->f1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return end angle.
* @return angle in degree.
*/
QString VArc::GetFormulaF2() const
{
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF2(const QString &formula, qreal value)
{
d->formulaF2 = formula;
d->f2 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return formula for end angle.
* @return string with formula.
*/
qreal VArc::GetEndAngle() const
{
return d->f2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetRadius return arc radius.
@ -475,32 +379,3 @@ qreal VArc::GetRadius() const
{
return d->radius;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetCenter return center point.
* @return center point.
*/
VPointF VArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetCenter(const VPointF &value)
{
d->center = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString VArc::GetFormulaLength() const
{
return d->formulaLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaLength(const QString &formula, qreal value)
{
d->formulaLength = formula;
FindF2(value);
}

View File

@ -29,7 +29,7 @@
#ifndef VARC_H
#define VARC_H
#include "vabstractcurve.h"
#include "vabstractarc.h"
#include "vpointf.h"
#include <QCoreApplication>
@ -39,55 +39,41 @@ class VArcData;
/**
* @brief VArc class for anticlockwise arc.
*/
class VArc: public VAbstractCurve
class VArc: public VAbstractArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public:
VArc ();
VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (VPointF center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, VPointF center, qreal radius, qreal f1);
VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (const VPointF &center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, const VPointF &center, qreal radius, qreal f1);
VArc(const VArc &arc);
VArc& operator= (const VArc &arc);
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VArc() Q_DECL_OVERRIDE;
QString GetFormulaF1 () const;
void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
QString GetFormulaRadius () const;
void SetFormulaRadius (const QString &formula, qreal value);
qreal GetRadius () const;
QString GetFormulaF2 () const;
void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
qreal GetLength () const;
QString GetFormulaRadius () const;
void SetFormulaRadius (const QString &formula, qreal value);
qreal GetRadius () const;
QPointF GetP1() const;
QPointF GetP2 () const;
VPointF GetCenter () const;
void SetCenter (const VPointF &value);
QVector<QPointF> GetPoints () const;
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
virtual qreal GetLength () const Q_DECL_OVERRIDE;
QPointF GetP1() const;
QPointF GetP2 () const;
qreal AngleArc() const;
virtual QVector<QPointF> GetPoints () const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VArcData> d;
void FindF2(qreal length);
qreal MaxLength() const;
};

View File

@ -32,7 +32,6 @@
#include <QSharedData>
#include "vgeometrydef.h"
#include "../vmisc/vabstractapplication.h"
#include "vpointf.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
@ -42,72 +41,48 @@
class VArcData : public QSharedData
{
public:
VArcData ()
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(VPointF()), isFlipped(false), formulaLength()
{}
VArcData (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength()
{}
VArcData(VPointF center, qreal radius, qreal f1, qreal f2)
: f1(f1), formulaF1(QString().number(f1)),
f2(f2), formulaF2(QString().number(f2)),
radius(radius), formulaRadius(QString().number(qApp->fromPixel(radius))),
center(center), isFlipped(false), formulaLength()
{}
VArcData (QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1)
: f1(f1), formulaF1(formulaF1), f2(0), formulaF2("0"), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength(formulaLength)
{}
VArcData(VPointF center, qreal radius, qreal f1)
: f1(f1), formulaF1(QString().number(f1)), f2(0), formulaF2("0"), radius(radius),
formulaRadius(QString().number(qApp->fromPixel(radius))), center(center), isFlipped(false), formulaLength()
{}
VArcData(const VArcData &arc)
: QSharedData(arc), f1(arc.f1), formulaF1(arc.formulaF1), f2(arc.f2), formulaF2(arc.formulaF2),
radius(arc.radius), formulaRadius(arc.formulaRadius), center(arc.center), isFlipped(arc.isFlipped),
formulaLength(arc.formulaLength)
{}
VArcData();
VArcData(qreal radius, QString formulaRadius);
VArcData(qreal radius);
VArcData(const VArcData &arc);
virtual ~VArcData();
/** @brief f1 start angle in degree. */
qreal f1;
/** @brief formulaF1 formula for start angle. */
QString formulaF1;
/** @brief f2 end angle in degree. */
qreal f2;
/** @brief formulaF2 formula for end angle. */
QString formulaF2;
/** @brief radius arc radius. */
qreal radius;
/** @brief formulaRadius formula for arc radius. */
QString formulaRadius;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
private:
VArcData &operator=(const VArcData &) Q_DECL_EQ_DELETE;
};
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData()
: radius(0),
formulaRadius(QString())
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(qreal radius, QString formulaRadius)
: radius(radius),
formulaRadius(formulaRadius)
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(qreal radius)
: radius(radius),
formulaRadius(QString().number(qApp->fromPixel(radius)))
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(const VArcData &arc)
: QSharedData(arc),
radius(arc.radius),
formulaRadius(arc.formulaRadius)
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::~VArcData()
{}

View File

@ -61,6 +61,18 @@ VCubicBezier &VCubicBezier::operator=(const VCubicBezier &curve)
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const VPointF p1 = GetP1().Rotate(originPoint, degrees);
const VPointF p2 = GetP2().Rotate(originPoint, degrees);
const VPointF p3 = GetP3().Rotate(originPoint, degrees);
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::~VCubicBezier()
{
@ -117,13 +129,13 @@ void VCubicBezier::SetP4(const VPointF &p)
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezier::GetStartAngle() const
{
return QLineF(GetP1().toQPointF(), GetP2().toQPointF()).angle();
return QLineF(GetP1(), GetP2()).angle();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezier::GetEndAngle() const
{
return QLineF(GetP4().toQPointF(), GetP3().toQPointF()).angle();
return QLineF(GetP4(), GetP3()).angle();
}
//---------------------------------------------------------------------------------------------------------------------
@ -133,7 +145,7 @@ qreal VCubicBezier::GetEndAngle() const
*/
qreal VCubicBezier::GetLength() const
{
return LengthBezier (GetP1().toQPointF(), GetP2().toQPointF(), GetP3().toQPointF(), GetP4().toQPointF());
return LengthBezier (GetP1(), GetP2(), GetP3(), GetP4());
}
//---------------------------------------------------------------------------------------------------------------------
@ -143,17 +155,17 @@ qreal VCubicBezier::GetLength() const
*/
QVector<QPointF> VCubicBezier::GetPoints() const
{
return GetCubicBezierPoints(GetP1().toQPointF(), GetP2().toQPointF(), GetP3().toQPointF(), GetP4().toQPointF());
return GetCubicBezierPoints(GetP1(), GetP2(), GetP3(), GetP4());
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VCubicBezier::GetControlPoint1() const
{
return GetP2().toQPointF();
return GetP2();
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VCubicBezier::GetControlPoint2() const
{
return GetP3().toQPointF();
return GetP3();
}

View File

@ -42,6 +42,7 @@ public:
VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &p3, const VPointF &p4, quint32 idObject = 0,
Draw mode = Draw::Calculation);
VCubicBezier &operator=(const VCubicBezier &curve);
VCubicBezier Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VCubicBezier();
virtual VPointF GetP1() const Q_DECL_OVERRIDE;

View File

@ -79,6 +79,19 @@ VCubicBezierPath &VCubicBezierPath::operator=(const VCubicBezierPath &curve)
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const QVector<VPointF> points = GetCubicPath();
VCubicBezierPath curve;
for(int i=0; i < points.size(); ++i)
{
curve.append(points.at(i).Rotate(originPoint, degrees));
}
curve.setName(name() + prefix);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::~VCubicBezierPath()
{
@ -99,7 +112,7 @@ const VPointF &VCubicBezierPath::at(int indx) const
//---------------------------------------------------------------------------------------------------------------------
void VCubicBezierPath::append(const VPointF &point)
{
if (d->path.size() > 0 && d->path.last().toQPointF() != point.toQPointF())
if (d->path.size() > 0 && d->path.last() != point)
{
return;
}
@ -143,18 +156,18 @@ VSpline VCubicBezierPath::GetSpline(qint32 index) const
const qint32 base = SubSplOffset(index);
// Correction the first control point of each next spline curve except for the first.
QPointF p2 = d->path.at(base + 1).toQPointF();
QPointF p2 = d->path.at(base + 1);
if (base + 1 > 1)
{
const QPointF b = d->path.at(base).toQPointF();
QLineF foot1(b, d->path.at(base - 1).toQPointF());
const QPointF b = d->path.at(base);
QLineF foot1(b, d->path.at(base - 1));
QLineF foot2(b, p2);
foot2.setAngle(foot1.angle() + 180);
p2 = foot2.p2();
}
VSpline spl(d->path.at(base), p2, d->path.at(base + 2).toQPointF(), d->path.at(base + 3));
VSpline spl(d->path.at(base), p2, d->path.at(base + 2), d->path.at(base + 3));
return spl;
}

View File

@ -45,6 +45,7 @@ public:
VCubicBezierPath(const VCubicBezierPath &curve);
VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
VCubicBezierPath &operator=(const VCubicBezierPath &curve);
VCubicBezierPath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VCubicBezierPath();
VPointF &operator[](int indx);

View File

@ -39,7 +39,7 @@
* @brief VEllipticalArc default constructor.
*/
VEllipticalArc::VEllipticalArc()
:VAbstractCurve(GOType::EllipticalArc), d (new VEllipticalArcData)
: VAbstractArc(GOType::EllipticalArc), d (new VEllipticalArcData)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -51,41 +51,40 @@ VEllipticalArc::VEllipticalArc()
* @param f1 start angle (degree).
* @param f2 end angle (degree).
*/
VEllipticalArc::VEllipticalArc (VPointF center, qreal radius1, qreal radius2,
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, qreal f2,
QString formulaF2, qreal rotationAngle, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
d (new VEllipticalArcData(center, radius1, radius2, formulaRadius1, formulaRadius2,
f1, formulaF1, f2, formulaF2, rotationAngle))
VEllipticalArc::VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, qreal rotationAngle, quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(center, radius1, radius2, f1, f2, rotationAngle))
VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2,
qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, qreal rotationAngle,
quint32 idObject, Draw mode)
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2,
f1, formulaF1, rotationAngle))
VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius1,
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal rotationAngle, quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
{
CreateName();
FindF2(length);
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1,
qreal rotationAngle)
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(center, radius1, radius2, f1, rotationAngle))
VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1,
qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
FindF2(length);
@ -97,7 +96,7 @@ VEllipticalArc::VEllipticalArc(qreal length, VPointF center, qreal radius1, qrea
* @param arc arc
*/
VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
: VAbstractCurve(arc), d (arc.d)
: VAbstractArc(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -112,11 +111,24 @@ VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc)
{
return *this;
}
VAbstractCurve::operator=(arc);
VAbstractArc::operator=(arc);
d = arc.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const VPointF center = GetCenter().Rotate(originPoint, degrees);
const QPointF p1 = VPointF::RotatePF(originPoint, GetP1(), degrees);
const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees);
const qreal f1 = QLineF(center, p1).angle() - GetRotationAngle();
const qreal f2 = QLineF(center, p2).angle() - GetRotationAngle();
VEllipticalArc elArc(center, GetRadius1(), GetRadius2(), f1, f2, GetRotationAngle());
elArc.setName(name() + prefix);
return elArc;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::~VEllipticalArc()
{}
@ -130,7 +142,7 @@ qreal VEllipticalArc::GetLength() const
{
qreal length = PathLength(GetPoints());
if (d->isFlipped)
if (IsFlipped())
{
length = length * -1;
}
@ -145,7 +157,7 @@ qreal VEllipticalArc::GetLength() const
*/
QPointF VEllipticalArc::GetP1() const
{
return GetPoint(d->f1);
return GetPoint(GetStartAngle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -155,7 +167,7 @@ QPointF VEllipticalArc::GetP1() const
*/
QPointF VEllipticalArc::GetP2 () const
{
return GetPoint(d->f2);
return GetPoint(GetEndAngle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -165,74 +177,121 @@ QPointF VEllipticalArc::GetP2 () const
*/
QPointF VEllipticalArc::GetPoint (qreal angle) const
{
// Original idea http://alex-black.ru/article.php?content=109#head_3
if (angle > 360 || angle < 0)
{// Filter incorect value of angle
QLineF dummy(0,0, 100, 0);
QLineF dummy(0, 0, 100, 0);
dummy.setAngle(angle);
angle = dummy.angle();
}
// p - point without rotation
qreal x = qAbs((d->radius1 * d->radius2)/
(qSqrt(d->radius2*d->radius2+d->radius1*d->radius1*qTan(M_PI*angle/180)*qTan(M_PI*angle/180))));
qreal y = qAbs(qTan(M_PI*angle/180) * x);
qreal x = 0;
qreal y = 0;
if (angle > 90 && angle <= 180)
{
x = -x;
qreal angleRad = qDegreesToRadians(angle);
const int n = GetQuadransRad(angleRad);
if (VFuzzyComparePossibleNulls(angleRad, 0) || VFuzzyComparePossibleNulls(angleRad, M_2PI) ||
VFuzzyComparePossibleNulls(angleRad, -M_2PI))
{ // 0 (360, -360) degress
x = d->radius1;
y = 0;
}
else if (angle > 180 && angle < 270)
{
x = -x;
y = -y;
}
else if (angle > 270)
{
y = -y;
}
else if (VFuzzyComparePossibleNulls(angle, 90))
{
else if (VFuzzyComparePossibleNulls(angleRad, M_PI_2) || VFuzzyComparePossibleNulls(angleRad, -3 * M_PI_2))
{ // 90 (-270) degress
x = 0;
y = d->radius2;
}
else if (VFuzzyComparePossibleNulls(angle, 270))
{
else if (VFuzzyComparePossibleNulls(angleRad, M_PI) || VFuzzyComparePossibleNulls(angleRad, -M_PI))
{ // 180 (-180) degress
x = -d->radius1;
y = 0;
}
else if (VFuzzyComparePossibleNulls(angleRad, 3 * M_PI_2) || VFuzzyComparePossibleNulls(angleRad, -M_PI_2))
{ // 270 (-90) degress
x = 0;
y = -d->radius2;
}
QPointF p ( GetCenter().x () + x, GetCenter().y () + y);
else
{ // cases between
const qreal r1Pow = qPow(d->radius1, 2);
const qreal r2Pow = qPow(d->radius2, 2);
const qreal angleTan = qTan(angleRad);
const qreal angleTan2 = qPow(angleTan, 2);
x = qSqrt((r1Pow * r2Pow) / (r1Pow * angleTan2 + r2Pow));
y = angleTan * x;
}
switch (n)
{
case 1:
x = +x;
y = +y;
break;
case 2:
x = -x;
y = +y;
break;
case 3:
x = -x;
y = -y;
break;
case 4:
x = +x;
y = -y;
break;
default:
break;
}
QPointF p (GetCenter().x() + x, GetCenter().y() + y);
// rotation of point
QLineF line(GetCenter().toQPointF(), p);
QLineF line(GetCenter(), p);
line.setAngle(line.angle() + GetRotationAngle());
return line.p2();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AngleArc calculate arc angle.
* @return angle in degree.
*/
qreal VEllipticalArc::AngleArc() const
int VEllipticalArc::GetQuadransRad(qreal &rad)
{
if ((qFuzzyIsNull(d->f1) && qFuzzyCompare(d->f2, 360)) ||
(qFuzzyCompare(d->f1, 360) && qFuzzyIsNull(d->f2)))
if (rad > M_PI)
{
return 360;
}
QLineF l1(0, 0, 100, 100);
l1.setAngle(d->f1);
QLineF l2(0, 0, 100, 100);
l2.setAngle(d->f2);
qreal ang = l1.angleTo(l2);
if (d->isFlipped)
{
ang = 360 - ang;
rad = rad - M_2PI;
}
return ang;
if (rad < -M_PI)
{
rad = rad + M_2PI;
}
int n = 0;
if (rad > 0)
{
if (rad >= 0 && rad <= M_PI_2)
{
n = 1;
rad = -rad;
}
else if (rad > M_PI_2 && rad <= M_PI)
{
n = 2;
rad = M_PI+rad;
}
}
else
{
if (rad <= 0 && rad >= -M_PI_2)
{
n = 4;
}
else if (rad < -M_PI_2 && rad >= -M_PI)
{
n = 3;
rad = M_PI-rad;
}
}
return n;
}
//---------------------------------------------------------------------------------------------------------------------
@ -247,7 +306,7 @@ QVector<qreal> VEllipticalArc::GetAngles() const
if (qFuzzyIsNull(angle))
{// Return the array that includes one angle
sectionAngle.append(d->f1);
sectionAngle.append(GetStartAngle());
return sectionAngle;
}
@ -284,7 +343,7 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
QVector<qreal> sectionAngle = GetAngles();
qreal currentAngle;
d->isFlipped ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
IsFlipped() ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
for (int i = 0; i < sectionAngle.size(); ++i)
{
QPointF startPoint = GetPoint(currentAngle);
@ -348,13 +407,13 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
}
// the first arc has given length and startAngle just like in the origin arc
arc1 = VEllipticalArc (len, QString().setNum(length), d->center, d->radius1, d->radius2,
d->formulaRadius1, d->formulaRadius2, d->f1, d->formulaF1, d->rotationAngle,
arc1 = VEllipticalArc (len, QString().setNum(length), GetCenter(), d->radius1, d->radius2,
d->formulaRadius1, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
getIdObject(), getMode());
// the second arc has startAngle just like endAngle of the first arc
// and it has endAngle just like endAngle of the origin arc
arc2 = VEllipticalArc (d->center, d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
arc1.GetEndAngle(), arc1.GetFormulaF2(), d->f2, d->formulaF2, d->rotationAngle,
arc2 = VEllipticalArc (GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
arc1.GetEndAngle(), arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
getIdObject(), getMode());
return arc1.GetP1();
}
@ -368,34 +427,6 @@ QPointF VEllipticalArc::CutArc(const qreal &length) const
return this->CutArc(length, arc1, arc2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId keep id arc in data.
* @param id id arc in data.
*/
void VEllipticalArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VEllipticalArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(this->GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::CreateName()
{
@ -420,7 +451,7 @@ void VEllipticalArc::FindF2(qreal length)
qreal gap = 180;
if (length < 0)
{
d->isFlipped = true;
SetFlipped(true);
gap = -gap;
}
while (length > MaxLength())
@ -432,15 +463,21 @@ void VEllipticalArc::FindF2(qreal length)
// first approximation of angle between start and end angles
qreal endAngle = GetStartAngle() + gap;
d->f2 = endAngle; // we need to set the end anngle, because we want to use GetLength()
// we need to set the end angle, because we want to use GetLength()
SetFormulaF2(QString::number(endAngle), endAngle);
qreal lenBez = GetLength(); // first approximation of length
qreal eps = 0.001 * qAbs(length);
const qreal eps = ToPixel(0.1, Unit::Mm);
while (qAbs(lenBez - length) > eps)
{
gap = gap/2;
if (gap < 0.0001)
{
break;
}
if (lenBez > length)
{ // we selected too big end angle
endAngle = endAngle - qAbs(gap);
@ -450,75 +487,21 @@ void VEllipticalArc::FindF2(qreal length)
endAngle = endAngle + qAbs(gap);
}
// we need to set d->f2, because we use it when we calculate GetLength
d->f2 = endAngle;
SetFormulaF2(QString::number(endAngle), endAngle);
lenBez = GetLength();
}
d->formulaF2 = QString().number(d->f2);
d->formulaLength = QString().number(qApp->fromPixel(lenBez));
SetFormulaF2(QString::number(endAngle), endAngle);
SetFormulaLength(QString::number(qApp->fromPixel(lenBez)));
}
//---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::MaxLength() const
{
const qreal h = ((d->radius1-d->radius2)*(d->radius1-d->radius2))/((d->radius1+d->radius2)*(d->radius1+d->radius2));
const qreal ellipseLength = M_PI*(d->radius1+d->radius2)*(1+3*h/(10+qSqrt(4-3*h)));
const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2);
const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1+3*h/(10+qSqrt(4-3*h)));
return ellipseLength;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return start angle.
* @return angle in degree.
*/
QString VEllipticalArc::GetFormulaF1() const
{
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::SetFormulaF1(const QString &formula, qreal value)
{
d->formulaF1 = formula;
d->f1 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return formula for start angle.
* @return string with formula.
*/
qreal VEllipticalArc::GetStartAngle() const
{
return d->f1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return end angle.
* @return angle in degree.
*/
QString VEllipticalArc::GetFormulaF2() const
{
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::SetFormulaF2(const QString &formula, qreal value)
{
d->formulaF2 = formula;
d->f2 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return formula for end angle.
* @return string with formula.
*/
qreal VEllipticalArc::GetEndAngle() const
{
return d->f2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetRadius return arc major radius.
@ -582,32 +565,3 @@ qreal VEllipticalArc::GetRadius2() const
{
return d->radius2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetCenter return center point.
* @return center point.
*/
VPointF VEllipticalArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::SetCenter(const VPointF &value)
{
d->center = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString VEllipticalArc::GetFormulaLength() const
{
return d->formulaLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::SetFormulaLength(const QString &formula, qreal value)
{
d->formulaLength = formula;
FindF2(value);
}

View File

@ -29,78 +29,63 @@
#ifndef VELLIPTICALARC_H
#define VELLIPTICALARC_H
#include "vabstractcurve.h"
#include "vabstractarc.h"
#include "vpointf.h"
#include <QCoreApplication>
class VEllipticalArcData;
class VEllipticalArc : public VAbstractCurve
class VEllipticalArc : public VAbstractArc
{
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
public:
VEllipticalArc();
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle,
quint32 idObject = 0, Draw mode = Draw::Calculation);
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArc (qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1,
qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
VEllipticalArc (qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2,
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1,
qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
VEllipticalArc (qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
VEllipticalArc(const VEllipticalArc &arc);
VEllipticalArc& operator= (const VEllipticalArc &arc);
VEllipticalArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
QString GetFormulaF1 () const;
void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
qreal GetRotationAngle() const;
QString GetFormulaF2 () const;
void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
QString GetFormulaRadius1 () const;
void SetFormulaRadius1 (const QString &formula, qreal value);
qreal GetRadius1 () const;
qreal GetRotationAngle() const;
QString GetFormulaRadius2 () const;
void SetFormulaRadius2 (const QString &formula, qreal value);
qreal GetRadius2 () const;
QString GetFormulaRadius1 () const;
void SetFormulaRadius1 (const QString &formula, qreal value);
qreal GetRadius1 () const;
qreal GetLength () const;
QString GetFormulaRadius2 () const;
void SetFormulaRadius2 (const QString &formula, qreal value);
qreal GetRadius2 () const;
QPointF GetP1() const;
QPointF GetP2() const;
VPointF GetCenter () const;
void SetCenter (const VPointF &value);
QVector<QPointF> GetPoints () const;
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
virtual qreal GetLength () const Q_DECL_OVERRIDE;
QPointF GetP1() const;
QPointF GetP2 () const;
qreal AngleArc() const;
QVector<qreal> GetAngles () const;
virtual QVector<QPointF> GetPoints () const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
QPointF CutArc (const qreal &length) const;
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
QPointF CutArc (const qreal &length) const;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VEllipticalArcData> d;
void FindF2(qreal length);
qreal MaxLength() const;
QPointF GetPoint (qreal angle) const;
QVector<qreal> GetAngles () const;
qreal MaxLength() const;
QPointF GetPoint (qreal angle) const;
static int GetQuadransRad(qreal &rad);
};
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE);

View File

@ -13,81 +13,68 @@
class VEllipticalArcData : public QSharedData
{
public:
VEllipticalArcData ()
: f1(0), f2(0), formulaF1(QString()), formulaF2(QString()),
radius1(0), radius2(0), formulaRadius1(QString()), formulaRadius2(QString()),
center(VPointF()), isFlipped(false), formulaLength(), rotationAngle(0)
{}
VEllipticalArcData (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle)
: f1(f1), f2(f2), formulaF1(formulaF1), formulaF2(formulaF2),
radius1(radius1), radius2(radius2), formulaRadius1(formulaRadius1), formulaRadius2(formulaRadius2),
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
{}
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
: f1(f1), f2(f2), formulaF1(QString().number(f1)),
formulaF2(QString().number(f2)), radius1(radius1), radius2(radius2),
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
{}
VEllipticalArcData (QString formulaLength, VPointF center, qreal radius1, qreal radius2,
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1,
qreal rotationAngle)
: f1(f1), f2(0), formulaF1(formulaF1), formulaF2("0"), radius1(radius1),radius2(radius2),
formulaRadius1(formulaRadius1), formulaRadius2(formulaRadius2),
center(center), isFlipped(false), formulaLength(formulaLength), rotationAngle(rotationAngle)
{}
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle)
: f1(f1), f2(0), formulaF1(QString().number(f1)), formulaF2("0"),
radius1(radius1), radius2(radius2),
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
{}
VEllipticalArcData(const VEllipticalArcData &arc)
: QSharedData(arc), f1(arc.f1), f2(arc.f2), formulaF1(arc.formulaF1), formulaF2(arc.formulaF2),
radius1(arc.radius1), radius2(arc.radius2),
formulaRadius1(arc.formulaRadius1), formulaRadius2(arc.formulaRadius2),
center(arc.center), isFlipped(arc.isFlipped), formulaLength(arc.formulaLength),
rotationAngle(arc.rotationAngle)
{}
VEllipticalArcData ();
VEllipticalArcData (qreal radius1, qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2,
qreal rotationAngle);
VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle);
VEllipticalArcData(const VEllipticalArcData &arc);
virtual ~VEllipticalArcData();
/** @brief f1 start angle in degree. */
qreal f1;
/** @brief f2 end angle in degree. */
qreal f2;
/** @brief formulaF1 formula for start angle. */
QString formulaF1;
/** @brief formulaF2 formula for end angle. */
QString formulaF2;
/** @brief radius1 elliptical arc major radius. */
qreal radius1;
qreal radius1;
/** @brief radius2 elliptical arc minor radius. */
qreal radius2;
qreal radius2;
/** @brief formulaRadius1 formula for elliptical arc major radius. */
QString formulaRadius1;
QString formulaRadius1;
/** @brief formulaRadius2 formula for elliptical arc minor radius. */
QString formulaRadius2;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
QString formulaRadius2;
/** @brief rotationAngle in degree. */
qreal rotationAngle;
qreal rotationAngle;
private:
VEllipticalArcData &operator=(const VEllipticalArcData &) Q_DECL_EQ_DELETE;
};
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData()
: radius1(0),
radius2(0),
formulaRadius1(),
formulaRadius2(),
rotationAngle(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal rotationAngle)
: radius1(radius1),
radius2(radius2),
formulaRadius1(formulaRadius1),
formulaRadius2(formulaRadius2),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle)
: radius1(radius1),
radius2(radius2),
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(const VEllipticalArcData &arc)
: QSharedData(arc),
radius1(arc.radius1),
radius2(arc.radius2),
formulaRadius1(arc.formulaRadius1),
formulaRadius2(arc.formulaRadius2),
rotationAngle(arc.rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::~VEllipticalArcData()
{}

View File

@ -13,7 +13,8 @@ SOURCES += \
$$PWD/vcubicbezier.cpp \
$$PWD/vabstractcubicbezier.cpp \
$$PWD/vabstractcubicbezierpath.cpp \
$$PWD/vcubicbezierpath.cpp
$$PWD/vcubicbezierpath.cpp \
$$PWD/vabstractarc.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -41,4 +42,6 @@ HEADERS += \
$$PWD/vabstractcubicbezier.h \
$$PWD/vabstractcubicbezierpath.h \
$$PWD/vcubicbezierpath.h \
$$PWD/vcubicbezierpath_p.h
$$PWD/vcubicbezierpath_p.h \
$$PWD/vabstractarc.h \
$$PWD/vabstractarc_p.h

View File

@ -29,8 +29,6 @@
#ifndef VGEOMETRYDEF_H
#define VGEOMETRYDEF_H
#include <QString>
enum class Draw : char { Calculation, Modeling, Layout };
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, CubicBezierPath, Unknown };
enum class SplinePointPosition : char { FirstPoint, LastPoint };

View File

@ -28,6 +28,7 @@
#include "vpointf.h"
#include "vpointf_p.h"
#include <QLineF>
#include <QPointF>
#include <QString>
@ -100,13 +101,22 @@ VPointF &VPointF::operator =(const VPointF &point)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief toQPointF convert to QPointF
* @return QPointF point
*/
QPointF VPointF::toQPointF() const
VPointF::operator const QPointF() const
{
return QPointF(d->_x, d->_y);
return toQPointF();
}
//---------------------------------------------------------------------------------------------------------------------
VPointF::operator QPointF()
{
return toQPointF();
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VPointF::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const QPointF p = RotatePF(originPoint, toQPointF(), degrees);
return VPointF(p, name() + prefix, mx(), my());
}
//---------------------------------------------------------------------------------------------------------------------
@ -149,6 +159,12 @@ void VPointF::setMy(qreal my)
d->_my = my;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPointF::toQPointF() const
{
return QPointF(d->_x, d->_y);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief x return x coordinate
@ -188,3 +204,11 @@ void VPointF::setY(const qreal &value)
{
d->_y = value;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
{
QLineF axis(originPoint, point);
axis.setAngle(axis.angle() + degrees);
return axis.p2();
}

View File

@ -58,6 +58,9 @@ public:
const Draw &mode = Draw::Calculation);
virtual ~VPointF() Q_DECL_OVERRIDE;
VPointF &operator=(const VPointF &point);
operator QPointF();
operator const QPointF() const;
VPointF Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
qreal mx() const;
qreal my() const;
void setMx(qreal mx);
@ -67,6 +70,8 @@ public:
void setX(const qreal &value);
qreal y() const;
void setY(const qreal &value);
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
private:
QSharedDataPointer<VPointFData> d;
};

View File

@ -101,12 +101,26 @@ VSpline::VSpline(VPointF p1, VPointF p4, qreal angle1, const QString &angle1Form
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
const QString &c2LengthFormula, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2,angle2Formula, c1Length, c1LengthFormula, c2Length,
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
c2LengthFormula))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
const VPointF p1 = GetP1().Rotate(originPoint, degrees);
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
const QPointF p2 = VPointF::RotatePF(originPoint, GetP2(), degrees);
const QPointF p3 = VPointF::RotatePF(originPoint, GetP3(), degrees);
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
VSpline::~VSpline()
{}
@ -118,7 +132,7 @@ VSpline::~VSpline()
*/
qreal VSpline::GetLength () const
{
return LengthBezier ( GetP1().toQPointF(), GetP2(), GetP3(), GetP4().toQPointF());
return LengthBezier ( GetP1(), GetP2(), GetP3(), GetP4());
}
//---------------------------------------------------------------------------------------------------------------------
@ -142,7 +156,7 @@ QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const
*/
QVector<QPointF> VSpline::GetPoints () const
{
return GetCubicBezierPoints(GetP1().toQPointF(), GetP2(), GetP3(), GetP4().toQPointF());
return GetCubicBezierPoints(GetP1(), GetP2(), GetP3(), GetP4());
}
//---------------------------------------------------------------------------------------------------------------------
@ -334,7 +348,7 @@ void VSpline::SetC2Length(qreal length, const QString &formula)
*/
qreal VSpline::GetKasm1() const
{
return QLineF(d->p1.toQPointF(), GetP2()).length() / VSplineData::GetL(d->p1.toQPointF(), d->p4.toQPointF(),
return QLineF(d->p1, GetP2()).length() / VSplineData::GetL(d->p1, d->p4,
d->kCurve);
}
@ -345,7 +359,7 @@ qreal VSpline::GetKasm1() const
*/
qreal VSpline::GetKasm2() const
{
return QLineF(d->p4.toQPointF(), GetP3()).length() / VSplineData::GetL(d->p1.toQPointF(), d->p4.toQPointF(),
return QLineF(d->p4, GetP3()).length() / VSplineData::GetL(d->p1, d->p4,
d->kCurve);
}
@ -455,8 +469,8 @@ qreal VSpline::ParamT (const QPointF &pBt) const
{
QVector<qreal> ts;
// Calculate t coefficient for each axis
ts += CalcT (GetP1().toQPointF().x(), GetP2().x(), GetP3().x(), GetP4().toQPointF().x(), pBt.x());
ts += CalcT (GetP1().toQPointF().y(), GetP2().y(), GetP3().y(), GetP4().toQPointF().y(), pBt.y());
ts += CalcT (GetP1().x(), GetP2().x(), GetP3().x(), GetP4().x(), pBt.x());
ts += CalcT (GetP1().y(), GetP2().y(), GetP3().y(), GetP4().y(), pBt.y());
if (ts.isEmpty())
{
@ -471,10 +485,10 @@ qreal VSpline::ParamT (const QPointF &pBt) const
for (int i=0; i< ts.size(); ++i)
{
const qreal t = ts.at(i);
const QPointF p0 = GetP1().toQPointF();
const QPointF p0 = GetP1();
const QPointF p1 = GetP2();
const QPointF p2 = GetP3();
const QPointF p3 = GetP4().toQPointF();
const QPointF p3 = GetP4();
//The explicit form of the Cubic Bézier curve
const qreal pointX = pow(1-t, 3)*p0.x() + 3*pow(1-t, 2)*t*p1.x() + 3*(1-t)*pow(t, 2)*p2.x() + pow(t, 3)*p3.x();
const qreal pointY = pow(1-t, 3)*p0.y() + 3*pow(1-t, 2)*t*p1.y() + 3*(1-t)*pow(t, 2)*p2.y() + pow(t, 3)*p3.y();

View File

@ -52,6 +52,7 @@ public:
VSpline (VPointF p1, VPointF p4, qreal angle1, const QString &angle1Formula, qreal angle2,
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VSpline();
VSpline &operator=(const VSpline &spl);

View File

@ -136,7 +136,7 @@ VSplineData::VSplineData(VPointF p1, VPointF p4, qreal angle1, qreal angle2, qre
c2LengthF("0"),
kCurve(kCurve)
{
const qreal L = GetL(p1.toQPointF(), p4.toQPointF(), kCurve);
const qreal L = GetL(p1, p4, kCurve);
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
p1p2.setAngle(angle1);
@ -163,7 +163,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4)
c2LengthF("0"),
kCurve(1)
{
QLineF p1p2(p1.toQPointF(), p2);
QLineF p1p2(p1, p2);
angle1 = p1p2.angle();
angle1F = QString().number(angle1);
@ -171,7 +171,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4)
c1Length = p1p2.length();
c1LengthF = QString().number(qApp->fromPixel(c1Length));
QLineF p4p3(p4.toQPointF(), p3);
QLineF p4p3(p4, p3);
angle2 = p4p3.angle();
angle2F = QString().number(angle2);

View File

@ -57,12 +57,7 @@ VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, qui
return;
}
QVector<VSplinePoint> newPoints;
for (int i=0; i < points.size(); ++i)
{
newPoints.append(VSplinePoint());
}
QVector<VSplinePoint> newPoints(points.size());
for (qint32 i = 1; i <= points.size()-1; ++i)
{
const VFSplinePoint &p1 = points.at(i-1);
@ -106,6 +101,30 @@ VSplinePath::VSplinePath(const VSplinePath &splPath)
d(splPath.d)
{}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
{
QVector<VSplinePoint> newPoints(CountPoints());
for (qint32 i = 1; i <= CountSubSpl(); ++i)
{
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
VSpline spl = GetSpline(i).Rotate(originPoint, degrees);
newPoints[i-1].SetP(p1.P());
newPoints[i-1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(p2.P());
newPoints[i].SetAngle1(p2.Angle1(), spl.GetEndAngleFormula());
newPoints[i].SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
}
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
return splPath;
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath::~VSplinePath()
{}
@ -117,7 +136,7 @@ VSplinePath::~VSplinePath()
*/
void VSplinePath::append(const VSplinePoint &point)
{
if (d->path.size() > 0 && d->path.last().P().toQPointF() == point.P().toQPointF()) //-V807
if (d->path.size() > 0 && d->path.last().P() == point.P()) //-V807
{
return;
}

View File

@ -50,6 +50,7 @@ public:
Draw mode = Draw::Calculation);
VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
VSplinePath(const VSplinePath& splPath);
VSplinePath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VSplinePath() Q_DECL_OVERRIDE;
VSplinePath &operator=(const VSplinePath &path);

View File

@ -102,6 +102,7 @@ enum class Tool : ToolVisHolderType
TrueDarts,
UnionDetails,
Group,
Rotation,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};
@ -110,6 +111,7 @@ enum class Vis : ToolVisHolderType
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
GraphicsSimpleTextItem,
SimplePoint,
SimpleCurve,
Line,
Path,
ToolAlongLine,
@ -139,7 +141,8 @@ enum class Vis : ToolVisHolderType
ToolCutSplinePath,
ToolLineIntersectAxis,
ToolCurveIntersectAxis,
ToolTrueDarts
ToolTrueDarts,
ToolRotation
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,

View File

@ -91,7 +91,7 @@ void VLineAngle::SetValue(const VPointF *p1, const VPointF *p2)
SCASSERT(p1 != nullptr);
SCASSERT(p2 != nullptr);
//Correct angle. Try avoid results like 6,7563e-15.
const qreal angle = qFloor(QLineF(p1->toQPointF(), p2->toQPointF()).angle() * 100000.) / 100000.;
const qreal angle = qFloor(QLineF(*p1, *p2).angle() * 100000.) / 100000.;
VInternalVariable::SetValue(angle);
}

View File

@ -85,7 +85,7 @@ void VLengthLine::SetValue(const VPointF *p1, const VPointF *p2)
SCASSERT(p1 != nullptr);
SCASSERT(p2 != nullptr);
VInternalVariable::SetValue(FromPixel(QLineF(p1->toQPointF(), p2->toQPointF()).length(), d->patternUnit));
VInternalVariable::SetValue(FromPixel(QLineF(*p1, *p2).length(), d->patternUnit));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ Q_LOGGING_CATEGORY(vCon, "v.container")
quint32 VContainer::_id = NULL_ID;
qreal VContainer::_size = 50;
qreal VContainer::_height = 176;
QSet<const QString> VContainer::uniqueNames = QSet<const QString>();
QSet<QString> VContainer::uniqueNames = QSet<QString>();
//---------------------------------------------------------------------------------------------------------------------
/**
@ -557,6 +557,14 @@ bool VContainer::IsUnique(const QString &name)
return (!uniqueNames.contains(name) && !builInFunctions.contains(name));
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VContainer::AllUniqueNames()
{
QStringList names = builInFunctions;
names.append(uniqueNames.toList());
return names;
}
//---------------------------------------------------------------------------------------------------------------------
const Unit *VContainer::GetPatternUnit() const
{

View File

@ -167,6 +167,7 @@ public:
const QHash<QString, qreal *> PlainVariables() const;
static bool IsUnique(const QString &name);
static QStringList AllUniqueNames();
const Unit *GetPatternUnit() const;
const VTranslateVars *GetTrVars() const;
@ -178,7 +179,7 @@ private:
static quint32 _id;
static qreal _size;
static qreal _height;
static QSet<const QString> uniqueNames;
static QSet<QString> uniqueNames;
QSharedDataPointer<VContainerData> d;

View File

@ -371,7 +371,7 @@ QVector<QPointF> VDetail::ContourPoints(const VContainer *data) const
case (Tool::NodePoint):
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId());
points.append(point->toQPointF());
points.append(*point);
}
break;
case (Tool::NodeArc):
@ -412,7 +412,7 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
case (Tool::NodePoint):
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId());
QPointF pEkv = point->toQPointF();
QPointF pEkv = *point;
pEkv.setX(pEkv.x()+at(i).getMx());
pEkv.setY(pEkv.y()+at(i).getMy());
pointsEkv.append(pEkv);
@ -555,14 +555,14 @@ QPointF VDetail::StartSegment(const VContainer *data, const int &i, bool reverse
{
if (at(CountNode()-1).getTypeTool() == Tool::NodePoint)
{
begin = data->GeometricObject<VPointF>(at(CountNode()-1).getId())->toQPointF();
begin = *data->GeometricObject<VPointF>(at(CountNode()-1).getId());
}
}
else
{
if (at(i-1).getTypeTool() == Tool::NodePoint)
{
begin = data->GeometricObject<VPointF>(at(i-1).getId())->toQPointF();
begin = *data->GeometricObject<VPointF>(at(i-1).getId());
}
}
}
@ -592,14 +592,14 @@ QPointF VDetail::EndSegment(const VContainer *data, const int &i, bool reverse)
{
if (at(0).getTypeTool() == Tool::NodePoint)
{
end = data->GeometricObject<VPointF>(at(0).getId())->toQPointF();
end = *data->GeometricObject<VPointF>(at(0).getId());
}
}
else
{
if (at(i+1).getTypeTool() == Tool::NodePoint)
{
end = data->GeometricObject<VPointF>(at(i+1).getId())->toQPointF();
end = *data->GeometricObject<VPointF>(at(i+1).getId());
}
}
}

View File

@ -37,7 +37,8 @@ HEADERS += \
$$PWD/tools/dialogpointofintersectioncurves.h \
$$PWD/tools/dialogcubicbezier.h \
$$PWD/tools/dialogcubicbezierpath.h \
$$PWD/tools/dialoggroup.h
$$PWD/tools/dialoggroup.h \
$$PWD/tools/dialogrotation.h
SOURCES += \
$$PWD/tools/dialogalongline.cpp \
@ -74,7 +75,8 @@ SOURCES += \
$$PWD/tools/dialogpointofintersectioncurves.cpp \
$$PWD/tools/dialogcubicbezier.cpp \
$$PWD/tools/dialogcubicbezierpath.cpp \
$$PWD/tools/dialoggroup.cpp
$$PWD/tools/dialoggroup.cpp \
$$PWD/tools/dialogrotation.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -110,4 +112,5 @@ FORMS += \
$$PWD/tools/dialogpointofintersectioncurves.ui \
$$PWD/tools/dialogcubicbezier.ui \
$$PWD/tools/dialogcubicbezierpath.ui \
$$PWD/tools/dialoggroup.ui
$$PWD/tools/dialoggroup.ui \
$$PWD/tools/dialogrotation.ui

View File

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

View File

@ -181,7 +181,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
QLineF line = QLineF(*point, scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;

View File

@ -62,7 +62,6 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
CheckState();
FillComboBoxArcs(ui->comboBoxArc);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged);
@ -170,18 +169,6 @@ void DialogCutArc::setArcId(const quint32 &value)
path->setObject1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetColor() const
{
return GetComboBoxCurrentData(ui->comboBoxColor);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SetColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxColor, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFormula set string with formula length

View File

@ -54,9 +54,6 @@ public:
quint32 getArcId() const;
void setArcId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
/**

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>412</width>
<height>222</height>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
@ -246,16 +246,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout>
</item>
<item>

View File

@ -61,7 +61,6 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
CheckState();
FillComboBoxSplines(ui->comboBoxSpline);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
@ -126,18 +125,6 @@ void DialogCutSpline::setSplineId(const quint32 &value)
path->setObject1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSpline::GetColor() const
{
return GetComboBoxCurrentData(ui->comboBoxColor);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::SetColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxColor, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.

View File

@ -53,9 +53,6 @@ public:
quint32 getSplineId() const;
void setSplineId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
/**

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>412</width>
<height>222</height>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
@ -246,16 +246,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout>
</item>
<item>

View File

@ -61,7 +61,6 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
CheckState();
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged);
@ -126,18 +125,6 @@ void DialogCutSplinePath::setSplinePathId(const quint32 &value)
path->setObject1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetColor() const
{
return GetComboBoxCurrentData(ui->comboBoxColor);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SetColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxColor, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.

View File

@ -53,9 +53,6 @@ public:
quint32 getSplinePathId() const;
void setSplinePathId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
/**

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>412</width>
<height>222</height>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
@ -246,22 +246,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout>
</item>
<item>

View File

@ -283,7 +283,7 @@ void DialogEndLine::ShowDialog(bool click)
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
QLineF line = QLineF(*point, scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
const qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;

View File

@ -248,8 +248,7 @@ void DialogHeight::PointNameChanged()
const QSharedPointer<VPointF> p2Line = data->GeometricObject<VPointF>(p2LineId);
QColor color = okColor;
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()),
basePoint->toQPointF()) == QPointF())
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(*p1Line, *p2Line), *basePoint) == QPointF())
{
flagError = false;
color = errorColor;

View File

@ -215,8 +215,8 @@ void DialogLineIntersect::PointNameChanged()
const QSharedPointer<VPointF> p1Line2 = data->GeometricObject<VPointF>(p1Line2Id);
const QSharedPointer<VPointF> p2Line2 = data->GeometricObject<VPointF>(p2Line2Id);
QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF());
QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF());
QLineF line1(*p1Line1, *p2Line1);
QLineF line2(*p1Line2, *p2Line2);
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
@ -266,8 +266,8 @@ bool DialogLineIntersect::CheckIntersecion()
const QSharedPointer<VPointF> p1L2 = data->GeometricObject<VPointF>(GetP1Line2());
const QSharedPointer<VPointF> p2L2 = data->GeometricObject<VPointF>(GetP2Line2());
QLineF line1(p1L1->toQPointF(), p2L1->toQPointF());
QLineF line2(p1L2->toQPointF(), p2L2->toQPointF());
QLineF line1(*p1L1, *p2L1);
QLineF line2(*p1L2, *p2L2);
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)

View File

@ -206,7 +206,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
QLineF line = QLineF(*point, scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;

View File

@ -0,0 +1,373 @@
/************************************************************************
**
** @file dialogrotation.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 "dialogrotation.h"
#include "ui_dialogrotation.h"
#include <QTimer>
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../ifc/xml/vdomdocument.h"
#include "../../visualization/line/vistoolrotation.h"
#include "../support/dialogeditwrongformula.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogRotation),
flagAngle(false),
timerAngle(nullptr),
formulaAngle(),
formulaBaseHeightAngle(0),
objects(),
stage1(true)
{
ui->setupUi(this);
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
timerAngle = new QTimer(this);
connect(timerAngle, &QTimer::timeout, this, &DialogRotation::EvalAngle);
InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxOriginPoint);
flagName = true;
CheckState();
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogRotation::AngleChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogRotation::DeployAngleTextEdit);
connect(ui->comboBoxOriginPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogRotation::PointChanged);
vis = new VisToolRotation(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogRotation::~DialogRotation()
{
DeleteVisualization<VisToolRotation>();
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogRotation::GetOrigPointId() const
{
return getCurrentObjectId(ui->comboBoxOriginPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetOrigPointId(const quint32 &value)
{
ChangeCurrentData(ui->comboBoxOriginPoint, value);
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
operation->SetOriginPointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogRotation::GetAngle() const
{
return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetAngle(const QString &value)
{
formulaAngle = qApp->TrVars()->FormulaToUser(value);
// increase height if needed.
if (formulaAngle.length() > 80)
{
this->DeployAngleTextEdit();
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
operation->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogRotation::GetSuffix() const
{
return ui->lineEditSuffix->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetSuffix(const QString &value)
{
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogRotation::GetObjects() const
{
return objects.toVector();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
{
return;
}
stage1 = false;
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
scene->clearSelection();
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->VisualMode();
scene->ToggleArcSelection(false);
scene->ToggleSplineSelection(false);
scene->ToggleSplinePathSelection(false);
scene->ToggleArcHover(false);
scene->ToggleSplineHover(false);
scene->ToggleSplinePathHover(false);
emit ToolTip("Select origin point");
}
else if (not stage1 && prepare && click)
{
/*We will ignore click if pointer is in point circle*/
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId());
const QLineF line = QLineF(*point, scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
const qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
{
return;
}
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
SetAngle(operation->Angle());//Show in dialog angle that a user choose
setModal(true);
emit ToolTip("");
timerAngle->start();
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare)// After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
if (objects.contains(id))
{
return;
}
if (SetObject(id, ui->comboBoxOriginPoint, ""))
{
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
connect(operation, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip);
operation->SetOriginPointId(id);
operation->RefreshGeometry();
prepare = true;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
{
if (stage1)
{
if (selected)
{
if (not objects.contains(object))
{
objects.append(object);
}
}
else
{
objects.removeOne(object);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::DeployAngleTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::AngleChanged()
{
labelEditFormula = ui->labelEditAngle;
labelResultCalculation = ui->labelResultAngle;
ValFormulaChanged(flagAngle, ui->plainTextEditFormula, timerAngle, degreeSymbol);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::FXAngle()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetAngle(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SuffixChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString suffix = edit->text();
if (suffix.isEmpty())
{
flagName = false;
ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
}
else
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = data->AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i)
{
const QString name = uniqueNames.at(i) + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{
flagName = false;
ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
}
}
}
flagName = true;
ChangeColor(ui->labelSuffix, okColor);
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagAngle && flagName);
SCASSERT(bApply != nullptr);
bApply->setEnabled(bOk->isEnabled());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowVisualization()
{
AddVisualization<VisToolRotation>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SaveData()
{
formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " ");
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->SetOriginPointId(GetOrigPointId());
operation->SetAngle(formulaAngle);
operation->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::closeEvent(QCloseEvent *event)
{
ui->plainTextEditFormula->blockSignals(true);
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::PointChanged()
{
QColor color = okColor;
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelOriginPoint, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::EvalAngle()
{
labelEditFormula = ui->labelEditAngle;
Eval(ui->plainTextEditFormula->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
}

View File

@ -0,0 +1,104 @@
/************************************************************************
**
** @file dialogrotation.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 DIALOGROTATION_H
#define DIALOGROTATION_H
#include "dialogtool.h"
namespace Ui
{
class DialogRotation;
}
class DialogRotation : public DialogTool
{
Q_OBJECT
public:
explicit DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogRotation();
quint32 GetOrigPointId() const;
void SetOrigPointId(const quint32 &value);
QString GetAngle() const;
void SetAngle(const QString &value);
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE;
private slots:
/** @brief DeployAngleTextEdit grow or shrink formula input */
void DeployAngleTextEdit();
void AngleChanged();
void FXAngle();
void SuffixChanged();
protected:
virtual void CheckState() Q_DECL_OVERRIDE;
virtual void ShowVisualization() Q_DECL_OVERRIDE;
/** @brief SaveData Put dialog data in local variables */
virtual void SaveData() Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void PointChanged();
private:
Q_DISABLE_COPY(DialogRotation)
Ui::DialogRotation *ui;
/** @brief flagAngle true if value of angle is correct */
bool flagAngle;
/** @brief timerAngle timer of check formula of angle */
QTimer *timerAngle;
/** @brief angle formula of angle */
QString formulaAngle;
/** @brief formulaBaseHeightAngle base height defined by dialogui */
int formulaBaseHeightAngle;
QList<quint32> objects;
bool stage1;
void EvalAngle();
};
#endif // DIALOGROTATION_H

View File

@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogRotation</class>
<widget class="QDialog" name="DialogRotation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>309</width>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
<string>Rotation</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_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calulation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprAngle">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelOriginPoint">
<property name="text">
<string>Origin Point:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxOriginPoint"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSuffix">
<property name="text">
<string>Suffix:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|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>DialogRotation</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>DialogRotation</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

@ -58,5 +58,6 @@
#include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
#include "operation/vtoolrotation.h"
#endif // DRAWTOOLS_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,186 @@
/************************************************************************
**
** @file vtoolrotation.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 VTOOLROTATION_H
#define VTOOLROTATION_H
#include "../vdrawtool.h"
struct DestinationItem
{
quint32 id;
qreal mx;
qreal my;
};
class VAbstractSimple;
class VSimpleCurve;
class VFormula;
class VToolRotation : public VDrawTool, public QGraphicsItem
{
Q_OBJECT
// Fix warning "Class implements the interface QGraphicsItem but does not list it
// in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!"
Q_INTERFACES(QGraphicsItem)
public:
virtual ~VToolRotation();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolRotation* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolRotation* Create(const quint32 _id, const quint32 &origin, QString &formulaAngle, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
QVector<DestinationItem> &destination);
static const QString ToolType;
static const QString TagItem;
static const QString TagSource;
static const QString TagDestination;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Rotation)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
void SetEnabled(bool enabled);
VFormula GetFormulaAngle() const;
void SetFormulaAngle(const VFormula &value);
QString Suffix() const;
void SetSuffix(const QString &suffix);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowPointHover(bool enabled);
void AllowPointSelecting(bool enabled);
void AllowPointLabelHover(bool enabled);
void AllowPointLabelSelecting(bool enabled);
void AllowSplineHover(bool enabled);
void AllowSplineSelecting(bool enabled);
void AllowSplinePathHover(bool enabled);
void AllowSplinePathSelecting(bool enabled);
void AllowArcHover(bool enabled);
void AllowArcSelecting(bool enabled);
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void ObjectSelected(bool selected, quint32 objId);
void DeleteFromLabel();
void LabelChangePosition(const QPointF &pos, quint32 labelId);
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
private slots:
void DoChangePosition(quint32 id, qreal mx, qreal my);
private:
Q_DISABLE_COPY(VToolRotation)
quint32 origPointId;
QString formulaAngle;
QString suffix;
QVector<quint32> source;
QVector<DestinationItem> destination;
QMap<quint32, VAbstractSimple *> rObjects;
VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
const QString &formulaAngle, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
void UpdateNamePosition(quint32 id);
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <typename T>
void ShowToolVisualization(bool show);
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType);
template <typename T>
static void InitRotationToolConnections(VMainGraphicsScene *scene, T *tool);
void AllowCurveHover(bool enabled, GOType type);
void AllowCurveSelecting(bool enabled, GOType type);
static void AddSourceObject(VAbstractPattern *doc, QDomElement &domElement, quint32 objId);
};
#endif // VTOOLROTATION_H

View File

@ -32,8 +32,6 @@
#include <QKeyEvent>
const QString VAbstractSpline::TagName = QStringLiteral("spline");
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
@ -49,7 +47,7 @@ VAbstractSpline::~VAbstractSpline()
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::getTagName() const
{
return VAbstractSpline::TagName;
return VAbstractPattern::TagSpline;
}
//---------------------------------------------------------------------------------------------------------------------
@ -67,7 +65,8 @@ void VAbstractSpline::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled);
this->setPen(QPen(CorrectColor(lineColor),
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, Qt::SolidLine,
Qt::RoundCap));
emit setEnabledPoint(enabled);
@ -124,7 +123,8 @@ void VAbstractSpline::SetFactor(qreal factor)
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(CorrectColor(lineColor),
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor, Qt::SolidLine,
Qt::RoundCap));
this->setPath(ToolPath(PathDirection::Show));
@ -141,7 +141,8 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(CorrectColor(lineColor),
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
if (detailsMode)
{
@ -233,7 +234,7 @@ QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ReadToolAttributes(const QDomElement &domElement)
{
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
Q_UNUSED(domElement)
}
//---------------------------------------------------------------------------------------------------------------------
@ -241,7 +242,8 @@ void VAbstractSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
{
VDrawTool::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrColor, lineColor);
const QSharedPointer<VAbstractCurve> curve = qSharedPointerCast<VAbstractCurve>(obj);
doc->SetAttribute(tag, AttrColor, curve->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -251,7 +253,7 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
VSpline spl;
if (position == SplinePointPosition::FirstPoint)
{
QLineF line(spline.GetP1().toQPointF(), pos);
QLineF line(spline.GetP1(), pos);
qreal newAngle1 = line.angle();
QString newAngle1F = QString().setNum(newAngle1);
@ -277,7 +279,7 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
}
else
{
QLineF line(spline.GetP4().toQPointF(), pos);
QLineF line(spline.GetP4(), pos);
qreal newAngle2 = line.angle();
QString newAngle2F = QString().setNum(newAngle2);
@ -319,7 +321,8 @@ void VAbstractSpline::setEnabled(bool enabled)
QGraphicsPathItem::setEnabled(enabled);
if (enabled)
{
setPen(QPen(QColor(lineColor),
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
setPen(QPen(QColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
else
@ -329,6 +332,22 @@ void VAbstractSpline::setEnabled(bool enabled)
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::GetLineColor() const
{
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
return curve->GetColor();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::SetLineColor(const QString &value)
{
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
curve->SetColor(value);
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::name() const
{

View File

@ -42,8 +42,7 @@ class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
public:
VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VAbstractSpline() Q_DECL_OVERRIDE;
// cppcheck-suppress duplInheritedMember
static const QString TagName;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
@ -51,6 +50,9 @@ public:
void setEnabled(bool enabled);
QString GetLineColor() const;
void SetLineColor(const QString &value);
QString name() const;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;

View File

@ -36,7 +36,6 @@
#include <QKeyEvent>
const QString VToolArc::TagName = QStringLiteral("arc");
const QString VToolArc::ToolType = QStringLiteral("simple");
//---------------------------------------------------------------------------------------------------------------------
@ -48,13 +47,11 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
* @param typeCreation way we create this tool.
* @param parent parent object
*/
VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation,
VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent)
{
sceneType = SceneObject::Arc;
lineColor = color;
this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
@ -77,7 +74,7 @@ void VToolArc::setDialog()
dialogTool->SetF1(arc->GetFormulaF1());
dialogTool->SetF2(arc->GetFormulaF2());
dialogTool->SetRadius(arc->GetFormulaRadius());
dialogTool->SetColor(lineColor);
dialogTool->SetColor(arc->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -134,6 +131,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
const VPointF c = *data->GeometricObject<VPointF>(center);
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );
arc->SetColor(color);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
@ -152,7 +150,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
VDrawTool::AddRecord(id, Tool::Arc, doc);
if (parse == Document::FullParse)
{
VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation);
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc);
InitArcToolConnections(scene, toolArc);
doc->AddTool(id, toolArc);
@ -165,7 +163,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
//---------------------------------------------------------------------------------------------------------------------
QString VToolArc::getTagName() const
{
return VToolArc::TagName;
return VAbstractPattern::TagArc;
}
//---------------------------------------------------------------------------------------------------------------------
@ -365,7 +363,8 @@ void VToolArc::SetVisualization()
*/
void VToolArc::RefreshGeometry()
{
this->setPen(QPen(CorrectColor(lineColor),
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
this->setPen(QPen(CorrectColor(arc->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setPath(ToolPath());

View File

@ -40,14 +40,12 @@ class VToolArc :public VAbstractSpline
{
Q_OBJECT
public:
VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Arc)};
@ -73,6 +71,11 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolArc)
VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
};

View File

@ -36,16 +36,14 @@
#include <QKeyEvent>
const QString VToolArcWithLength::TagName = QStringLiteral("arc");
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
//---------------------------------------------------------------------------------------------------------------------
VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation, QGraphicsItem *parent)
VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent)
{
sceneType = SceneObject::Arc;
lineColor = color;
this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
@ -65,7 +63,7 @@ void VToolArcWithLength::setDialog()
dialogTool->SetF1(arc->GetFormulaF1());
dialogTool->SetLength(arc->GetFormulaLength());
dialogTool->SetRadius(arc->GetFormulaRadius());
dialogTool->SetColor(lineColor);
dialogTool->SetColor(arc->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -103,6 +101,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
const VPointF c = *data->GeometricObject<VPointF>(center);
VArc *arc = new VArc(calcLength, length, c, calcRadius, radius, calcF1, f1);
arc->SetColor(color);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
@ -121,7 +120,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
VDrawTool::AddRecord(id, Tool::ArcWithLength, doc);
if (parse == Document::FullParse)
{
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, color, typeCreation);
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, typeCreation);
scene->addItem(toolArc);
InitArcToolConnections(scene, toolArc);
doc->AddTool(id, toolArc);
@ -134,7 +133,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
//---------------------------------------------------------------------------------------------------------------------
QString VToolArcWithLength::getTagName() const
{
return VToolArcWithLength::TagName;
return VAbstractPattern::TagArc;
}
//---------------------------------------------------------------------------------------------------------------------
@ -318,7 +317,8 @@ void VToolArcWithLength::SetVisualization()
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::RefreshGeometry()
{
this->setPen(QPen(CorrectColor(lineColor),
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
this->setPen(QPen(CorrectColor(arc->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setPath(ToolPath());

View File

@ -37,18 +37,14 @@ class VToolArcWithLength : public VAbstractSpline
{
Q_OBJECT
public:
VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolArcWithLength* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolArcWithLength* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1,
QString &length, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString TagName;
QString &length, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::ArcWithLength)};
@ -74,6 +70,11 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolArcWithLength)
VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
};

View File

@ -35,12 +35,11 @@
const QString VToolCubicBezier::ToolType = QStringLiteral("cubicBezier");
//---------------------------------------------------------------------------------------------------------------------
VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id,
const Source &typeCreation, QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent)
{
sceneType = SceneObject::Spline;
lineColor = color;
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setPath(ToolPath());
@ -62,7 +61,7 @@ void VToolCubicBezier::setDialog()
SCASSERT(dialogTool != nullptr);
const auto spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
dialogTool->SetSpline(*spl);
dialogTool->SetColor(lineColor);
dialogTool->SetColor(spl->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -89,6 +88,7 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
const Document &parse, const Source &typeCreation)
{
quint32 id = _id;
spline->SetColor(color);
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(spline);
@ -106,7 +106,7 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
VDrawTool::AddRecord(id, Tool::CubicBezier, doc);
if (parse == Document::FullParse)
{
auto _spl = new VToolCubicBezier(doc, data, id, color, typeCreation);
auto _spl = new VToolCubicBezier(doc, data, id, typeCreation);
scene->addItem(_spl);
InitSplineToolConnections(scene, _spl);
doc->AddTool(id, _spl);
@ -209,7 +209,8 @@ void VToolCubicBezier::SetVisualization()
//---------------------------------------------------------------------------------------------------------------------
void VToolCubicBezier::RefreshGeometry()
{
this->setPen(QPen(CorrectColor(lineColor),
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
this->setPen(QPen(CorrectColor(spl->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
if (isHovered || detailsMode)
{

View File

@ -37,8 +37,6 @@ class VToolCubicBezier : public VAbstractSpline
{
Q_OBJECT
public:
VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolCubicBezier();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolCubicBezier *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
@ -63,6 +61,9 @@ protected:
private:
Q_DISABLE_COPY(VToolCubicBezier)
VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void SetSplineAttributes(QDomElement &domElement, const VCubicBezier &spl);
};

View File

@ -33,12 +33,11 @@
const QString VToolCubicBezierPath::ToolType = QStringLiteral("cubicBezierPath");
//---------------------------------------------------------------------------------------------------------------------
VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
const Source &typeCreation, QGraphicsItem *parent)
: VAbstractSpline(doc, data, id, parent)
{
sceneType = SceneObject::SplinePath;
lineColor = color;
this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
@ -60,7 +59,7 @@ void VToolCubicBezierPath::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
dialogTool->SetPath(*splPath);
dialogTool->SetColor(lineColor);
dialogTool->SetColor(splPath->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -90,6 +89,7 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi
const Document &parse, const Source &typeCreation)
{
quint32 id = _id;
path->SetColor(color);
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(path);
@ -107,7 +107,7 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi
VDrawTool::AddRecord(id, Tool::CubicBezierPath, doc);
if (parse == Document::FullParse)
{
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, color, typeCreation);
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, typeCreation);
scene->addItem(spl);
InitSplinePathToolConnections(scene, spl);
doc->AddTool(id, spl);
@ -214,7 +214,8 @@ void VToolCubicBezierPath::RefreshGeometry()
{
isHovered || detailsMode ? setPath(ToolPath(PathDirection::Show)) : setPath(ToolPath());
this->setPen(QPen(CorrectColor(lineColor),
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
this->setPen(QPen(CorrectColor(splPath->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
SetVisualization();

View File

@ -37,8 +37,6 @@ class VToolCubicBezierPath:public VAbstractSpline
{
Q_OBJECT
public:
VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolCubicBezierPath();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolCubicBezierPath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
@ -65,6 +63,9 @@ protected:
private:
Q_DISABLE_COPY(VToolCubicBezierPath)
VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VPointF &splPoint);
void SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path);

View File

@ -52,13 +52,11 @@ const QString VToolSpline::OldToolType = QStringLiteral("simple");
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation,
VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent), oldPosition()
{
sceneType = SceneObject::Spline;
lineColor = color;
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -71,7 +69,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
auto *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(),
spl->GetP1().toQPointF(), *data->GetPatternUnit(), freeAngle1,
spl->GetP1(), *data->GetPatternUnit(), freeAngle1,
freeLength1, this);
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
@ -83,7 +81,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl->GetC2LengthFormula());
auto *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(),
spl->GetP4().toQPointF(), *data->GetPatternUnit(), freeAngle2,
spl->GetP4(), *data->GetPatternUnit(), freeAngle2,
freeLength2, this);
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
@ -114,7 +112,7 @@ void VToolSpline::setDialog()
SCASSERT(dialogTool != nullptr);
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
dialogTool->SetSpline(*spl);
dialogTool->SetColor(lineColor);
dialogTool->SetColor(spl->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -132,8 +130,9 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
SCASSERT(dialogTool != nullptr);
auto spl = Create(0, new VSpline(dialogTool->GetSpline()), dialogTool->GetColor(), scene, doc, data,
Document::FullParse, Source::FromGui);
VSpline *spline = new VSpline(dialogTool->GetSpline());
auto spl = Create(0, spline, dialogTool->GetColor(), scene, doc, data, Document::FullParse, Source::FromGui);
if (spl != nullptr)
{
@ -147,7 +146,6 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param spline spline.
* @param color spline color.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
@ -160,6 +158,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri
const Source &typeCreation)
{
quint32 id = _id;
spline->SetColor(color);
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(spline);
@ -177,7 +176,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri
VDrawTool::AddRecord(id, Tool::Spline, doc);
if (parse == Document::FullParse)
{
auto _spl = new VToolSpline(doc, data, id, color, typeCreation);
auto _spl = new VToolSpline(doc, data, id, typeCreation);
scene->addItem(_spl);
InitSplineToolConnections(scene, _spl);
doc->AddTool(id, _spl);
@ -508,7 +507,9 @@ void VToolSpline::RefreshGeometry()
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
}
this->setPen(QPen(CorrectColor(lineColor),
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
this->setPen(QPen(CorrectColor(spl->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
if (isHovered || detailsMode)
{
@ -522,13 +523,11 @@ void VToolSpline::RefreshGeometry()
controlPoints[0]->blockSignals(true);
controlPoints[1]->blockSignals(true);
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
{
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
const QPointF splinePoint = VAbstractTool::data.GeometricObject<VPointF>(spl->GetP1().id())->toQPointF();
const QPointF splinePoint = *VAbstractTool::data.GeometricObject<VPointF>(spl->GetP1().id());
controlPoints[0]->RefreshCtrlPoint(1, SplinePointPosition::FirstPoint, spl->GetP2(), splinePoint, freeAngle1,
freeLength1);
}
@ -537,7 +536,7 @@ void VToolSpline::RefreshGeometry()
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl->GetEndAngleFormula());
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl->GetC2LengthFormula());
const QPointF splinePoint = VAbstractTool::data.GeometricObject<VPointF>(spl->GetP4().id())->toQPointF();
const QPointF splinePoint = *VAbstractTool::data.GeometricObject<VPointF>(spl->GetP4().id());
controlPoints[1]->RefreshCtrlPoint(1, SplinePointPosition::LastPoint, spl->GetP3(), splinePoint, freeAngle2,
freeLength2);
}

View File

@ -40,8 +40,6 @@ class VToolSpline:public VAbstractSpline
{
Q_OBJECT
public:
VToolSpline (VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation,
QGraphicsItem * parent = nullptr );
virtual ~VToolSpline() Q_DECL_OVERRIDE;
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
@ -80,6 +78,9 @@ private:
Q_DISABLE_COPY(VToolSpline)
QPointF oldPosition;
VToolSpline (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr );
bool IsMovable() const;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);

View File

@ -51,14 +51,13 @@ const QString VToolSplinePath::OldToolType = QStringLiteral("path");
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation, QGraphicsItem *parent)
VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
: VAbstractSpline(doc, data, id, parent),
oldPosition(),
splIndex(-1)
{
sceneType = SceneObject::SplinePath;
lineColor = color;
this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
@ -74,7 +73,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl.GetC1LengthFormula());
auto *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(),
spl.GetP1().toQPointF(), *data->GetPatternUnit(), freeAngle1,
spl.GetP1(), *data->GetPatternUnit(), freeAngle1,
freeLength1, this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
@ -85,7 +84,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(),
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4(),
*data->GetPatternUnit(), freeAngle2, freeLength2, this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
@ -117,7 +116,7 @@ void VToolSplinePath::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
dialogTool->SetPath(*splPath);
dialogTool->SetColor(lineColor);
dialogTool->SetColor(splPath->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -135,12 +134,12 @@ VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene
DialogSplinePath *dialogTool = qobject_cast<DialogSplinePath*>(dialog);
SCASSERT(dialogTool != nullptr);
VSplinePath *path = new VSplinePath(dialogTool->GetPath());
const QString color = dialogTool->GetColor();
for (qint32 i = 0; i < path->CountPoints(); ++i)
{
doc->IncrementReferens((*path)[i].P().getIdTool());
}
VToolSplinePath* spl = Create(0, path, color, scene, doc, data, Document::FullParse, Source::FromGui);
VToolSplinePath* spl = Create(0, path, dialogTool->GetColor(), scene, doc, data, Document::FullParse,
Source::FromGui);
if (spl != nullptr)
{
spl->dialog=dialogTool;
@ -164,6 +163,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
const Document &parse, const Source &typeCreation)
{
quint32 id = _id;
path->SetColor(color);
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(path);
@ -181,7 +181,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
VDrawTool::AddRecord(id, Tool::SplinePath, doc);
if (parse == Document::FullParse)
{
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, color, typeCreation);
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
scene->addItem(spl);
InitSplinePathToolConnections(scene, spl);
doc->AddTool(id, spl);
@ -631,10 +631,10 @@ void VToolSplinePath::RefreshGeometry()
this->setPath(ToolPath());
}
this->setPen(QPen(CorrectColor(lineColor),
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
this->setPen(QPen(CorrectColor(splPath->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
{
const qint32 j = i*2;
@ -648,7 +648,7 @@ void VToolSplinePath::RefreshGeometry()
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl.GetStartAngleFormula());
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl.GetC1LengthFormula());
const auto splinePoint = spl.GetP1().toQPointF();
const auto splinePoint = spl.GetP1();
controlPoints[j-2]->RefreshCtrlPoint(i, SplinePointPosition::FirstPoint, spl.GetP2(), splinePoint,
freeAngle1, freeLength1);
}
@ -657,7 +657,7 @@ void VToolSplinePath::RefreshGeometry()
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
const auto splinePoint = spl.GetP4().toQPointF();
const auto splinePoint = spl.GetP4();
controlPoints[j-1]->RefreshCtrlPoint(i, SplinePointPosition::LastPoint, spl.GetP3(), splinePoint,
freeAngle2, freeLength2);
}

View File

@ -42,18 +42,13 @@ class VToolSplinePath:public VAbstractSpline
{
Q_OBJECT
public:
VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual ~VToolSplinePath() Q_DECL_OVERRIDE;
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, const QString &color,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse,
const Source &typeCreation);
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolSplinePath *Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
@ -104,6 +99,9 @@ private:
QPointF oldPosition;
int splIndex;
VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
bool IsMovable(int index) const;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);

View File

@ -29,7 +29,7 @@
#include "vtooldoublepoint.h"
#include "../vwidgets/vsimplepoint.h"
#include "../vgeometry/vpointf.h"
#include "../../../../undocommands/movedoublelabel.h"
#include "../../../../undocommands/label/movedoublelabel.h"
#include <QKeyEvent>
@ -238,7 +238,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
{
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id, p1id, scene());
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id, p1id);
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}
@ -246,8 +246,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
{
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id, p2id,
scene());
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id, p2id);
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}

View File

@ -146,8 +146,7 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
QPointF fPoint1;
QPointF fPoint2;
VToolTrueDarts::FindPoint(baseLineP1->toQPointF(), baseLineP2->toQPointF(),
dartP1->toQPointF(), dartP2->toQPointF(), dartP3->toQPointF(), fPoint1, fPoint2);
VToolTrueDarts::FindPoint(*baseLineP1, *baseLineP2, *dartP1, *dartP2, *dartP3, fPoint1, fPoint2);
quint32 id = _id;
quint32 p1id = _p1id;
quint32 p2id = _p2id;

View File

@ -35,19 +35,6 @@ class VToolTrueDarts : public VToolDoublePoint
{
Q_OBJECT
public:
VToolTrueDarts(VAbstractPattern *doc,
VContainer *data,
const quint32 &id,
const quint32 &p1id,
const quint32 &p2id,
const quint32 &baseLineP1Id,
const quint32 &baseLineP2Id,
const quint32 &dartP1Id,
const quint32 &dartP2Id,
const quint32 &dartP3Id,
const Source &typeCreation,
QGraphicsItem * parent = nullptr);
static void FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1,
const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2);
virtual void setDialog() Q_DECL_OVERRIDE;
@ -100,6 +87,19 @@ private:
quint32 dartP1Id;
quint32 dartP2Id;
quint32 dartP3Id;
VToolTrueDarts(VAbstractPattern *doc,
VContainer *data,
const quint32 &id,
const quint32 &p1id,
const quint32 &p2id,
const quint32 &baseLineP1Id,
const quint32 &baseLineP2Id,
const quint32 &dartP1Id,
const quint32 &dartP2Id,
const quint32 &dartP3Id,
const Source &typeCreation,
QGraphicsItem * parent = nullptr);
};
#endif // VTOOLTRUEDARTS_H

View File

@ -32,12 +32,10 @@
//---------------------------------------------------------------------------------------------------------------------
VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &curveCutId, const QString &color, QGraphicsItem *parent)
const quint32 &curveCutId, QGraphicsItem *parent)
:VToolSinglePoint(doc, data, id, parent), formula(formula), curveCutId(curveCutId), detailsMode(false)
{
Q_ASSERT_X(curveCutId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712
lineColor = color;
}
//---------------------------------------------------------------------------------------------------------------------
@ -137,11 +135,3 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve)
curveCutId = domElement.attribute(attrCurve, "").toUInt();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VToolSinglePoint::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrColor, lineColor);
}

Some files were not shown because too many files have changed in this diff Show More