Improve Move tool. It should provide optional rotation origin point field.

ref #726.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-11-17 12:28:57 +02:00
parent e6c59de3ca
commit 604baa61d3
15 changed files with 1308 additions and 137 deletions

View File

@ -1852,6 +1852,8 @@ void VToolOptionsPropertyBrowser::ChangeDataToolMove(VPE::VProperty *property)
case 42: // AttrRotationAngle case 42: // AttrRotationAngle
i->SetFormulaRotationAngle(value.value<VFormula>()); i->SetFormulaRotationAngle(value.value<VFormula>());
break; break;
case 11: // AttrCenter (read only)
break;
default: default:
qWarning()<<"Unknown property type. id = "<<id; qWarning()<<"Unknown property type. id = "<<id;
break; break;
@ -2420,6 +2422,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolMove(QGraphicsItem *item)
AddPropertyFormula(tr("Angle:"), i->GetFormulaAngle(), AttrAngle); AddPropertyFormula(tr("Angle:"), i->GetFormulaAngle(), AttrAngle);
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength); AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle); AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle);
AddPropertyParentPointName(i->OriginPointName(), tr("Rotation origin point:"), AttrCenter);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3240,6 +3243,10 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolMove()
QVariant valueRotationAngle; QVariant valueRotationAngle;
valueRotationAngle.setValue(i->GetFormulaRotationAngle()); valueRotationAngle.setValue(i->GetFormulaRotationAngle());
idToProperty[AttrRotationAngle]->setValue(valueRotationAngle); idToProperty[AttrRotationAngle]->setValue(valueRotationAngle);
QVariant valueRotationOriginPoint;
valueRotationOriginPoint.setValue(i->OriginPointName());
idToProperty[AttrCenter]->setValue(valueRotationOriginPoint);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -3162,6 +3162,7 @@ void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement,
initData.formulaLength = GetParametrString(domElement, AttrLength, "0"); initData.formulaLength = GetParametrString(domElement, AttrLength, "0");
const QString len = initData.formulaLength;//need for saving fixed formula; const QString len = initData.formulaLength;//need for saving fixed formula;
initData.suffix = GetParametrString(domElement, AttrSuffix, ""); initData.suffix = GetParametrString(domElement, AttrSuffix, "");
initData.rotationOrigin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
VAbstractOperation::ExtractData(domElement, initData); VAbstractOperation::ExtractData(domElement, initData);

View File

@ -44,6 +44,7 @@
<file>schema/pattern/v0.7.0.xsd</file> <file>schema/pattern/v0.7.0.xsd</file>
<file>schema/pattern/v0.7.1.xsd</file> <file>schema/pattern/v0.7.1.xsd</file>
<file>schema/pattern/v0.7.2.xsd</file> <file>schema/pattern/v0.7.2.xsd</file>
<file>schema/pattern/v0.7.3.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file> <file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file> <file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file> <file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -58,8 +58,8 @@ class QDomElement;
*/ */
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.2"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.2.xsd"); const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.3.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -173,97 +173,61 @@ VPatternConverter::VPatternConverter(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPatternConverter::XSDSchema(int ver) const QString VPatternConverter::XSDSchema(int ver) const
{ {
switch (ver) QHash <int, QString> schemas =
{
std::make_pair(0x000100, QStringLiteral("://schema/pattern/v0.1.0.xsd")),
std::make_pair(0x000101, QStringLiteral("://schema/pattern/v0.1.1.xsd")),
std::make_pair(0x000102, QStringLiteral("://schema/pattern/v0.1.2.xsd")),
std::make_pair(0x000103, QStringLiteral("://schema/pattern/v0.1.3.xsd")),
std::make_pair(0x000104, QStringLiteral("://schema/pattern/v0.1.4.xsd")),
std::make_pair(0x000200, QStringLiteral("://schema/pattern/v0.2.0.xsd")),
std::make_pair(0x000201, QStringLiteral("://schema/pattern/v0.2.1.xsd")),
std::make_pair(0x000202, QStringLiteral("://schema/pattern/v0.2.2.xsd")),
std::make_pair(0x000203, QStringLiteral("://schema/pattern/v0.2.3.xsd")),
std::make_pair(0x000204, QStringLiteral("://schema/pattern/v0.2.4.xsd")),
std::make_pair(0x000205, QStringLiteral("://schema/pattern/v0.2.5.xsd")),
std::make_pair(0x000206, QStringLiteral("://schema/pattern/v0.2.6.xsd")),
std::make_pair(0x000207, QStringLiteral("://schema/pattern/v0.2.7.xsd")),
std::make_pair(0x000300, QStringLiteral("://schema/pattern/v0.3.0.xsd")),
std::make_pair(0x000301, QStringLiteral("://schema/pattern/v0.3.1.xsd")),
std::make_pair(0x000302, QStringLiteral("://schema/pattern/v0.3.2.xsd")),
std::make_pair(0x000303, QStringLiteral("://schema/pattern/v0.3.3.xsd")),
std::make_pair(0x000304, QStringLiteral("://schema/pattern/v0.3.4.xsd")),
std::make_pair(0x000305, QStringLiteral("://schema/pattern/v0.3.5.xsd")),
std::make_pair(0x000306, QStringLiteral("://schema/pattern/v0.3.6.xsd")),
std::make_pair(0x000307, QStringLiteral("://schema/pattern/v0.3.7.xsd")),
std::make_pair(0x000308, QStringLiteral("://schema/pattern/v0.3.8.xsd")),
std::make_pair(0x000309, QStringLiteral("://schema/pattern/v0.3.9.xsd")),
std::make_pair(0x000400, QStringLiteral("://schema/pattern/v0.4.0.xsd")),
std::make_pair(0x000401, QStringLiteral("://schema/pattern/v0.4.1.xsd")),
std::make_pair(0x000402, QStringLiteral("://schema/pattern/v0.4.2.xsd")),
std::make_pair(0x000403, QStringLiteral("://schema/pattern/v0.4.3.xsd")),
std::make_pair(0x000404, QStringLiteral("://schema/pattern/v0.4.4.xsd")),
std::make_pair(0x000405, QStringLiteral("://schema/pattern/v0.4.5.xsd")),
std::make_pair(0x000406, QStringLiteral("://schema/pattern/v0.4.6.xsd")),
std::make_pair(0x000407, QStringLiteral("://schema/pattern/v0.4.7.xsd")),
std::make_pair(0x000408, QStringLiteral("://schema/pattern/v0.4.8.xsd")),
std::make_pair(0x000500, QStringLiteral("://schema/pattern/v0.5.0.xsd")),
std::make_pair(0x000501, QStringLiteral("://schema/pattern/v0.5.1.xsd")),
std::make_pair(0x000600, QStringLiteral("://schema/pattern/v0.6.0.xsd")),
std::make_pair(0x000601, QStringLiteral("://schema/pattern/v0.6.1.xsd")),
std::make_pair(0x000602, QStringLiteral("://schema/pattern/v0.6.2.xsd")),
std::make_pair(0x000603, QStringLiteral("://schema/pattern/v0.6.3.xsd")),
std::make_pair(0x000604, QStringLiteral("://schema/pattern/v0.6.4.xsd")),
std::make_pair(0x000605, QStringLiteral("://schema/pattern/v0.6.5.xsd")),
std::make_pair(0x000606, QStringLiteral("://schema/pattern/v0.6.6.xsd")),
std::make_pair(0x000700, QStringLiteral("://schema/pattern/v0.7.0.xsd")),
std::make_pair(0x000701, QStringLiteral("://schema/pattern/v0.7.1.xsd")),
std::make_pair(0x000702, QStringLiteral("://schema/pattern/v0.7.2.xsd")),
std::make_pair(0x000703, CurrentSchema)
};
if (schemas.contains(ver))
{
return schemas.value(ver);
}
else
{ {
case (0x000100):
return QStringLiteral("://schema/pattern/v0.1.0.xsd");
case (0x000101):
return QStringLiteral("://schema/pattern/v0.1.1.xsd");
case (0x000102):
return QStringLiteral("://schema/pattern/v0.1.2.xsd");
case (0x000103):
return QStringLiteral("://schema/pattern/v0.1.3.xsd");
case (0x000104):
return QStringLiteral("://schema/pattern/v0.1.4.xsd");
case (0x000200):
return QStringLiteral("://schema/pattern/v0.2.0.xsd");
case (0x000201):
return QStringLiteral("://schema/pattern/v0.2.1.xsd");
case (0x000202):
return QStringLiteral("://schema/pattern/v0.2.2.xsd");
case (0x000203):
return QStringLiteral("://schema/pattern/v0.2.3.xsd");
case (0x000204):
return QStringLiteral("://schema/pattern/v0.2.4.xsd");
case (0x000205):
return QStringLiteral("://schema/pattern/v0.2.5.xsd");
case (0x000206):
return QStringLiteral("://schema/pattern/v0.2.6.xsd");
case (0x000207):
return QStringLiteral("://schema/pattern/v0.2.7.xsd");
case (0x000300):
return QStringLiteral("://schema/pattern/v0.3.0.xsd");
case (0x000301):
return QStringLiteral("://schema/pattern/v0.3.1.xsd");
case (0x000302):
return QStringLiteral("://schema/pattern/v0.3.2.xsd");
case (0x000303):
return QStringLiteral("://schema/pattern/v0.3.3.xsd");
case (0x000304):
return QStringLiteral("://schema/pattern/v0.3.4.xsd");
case (0x000305):
return QStringLiteral("://schema/pattern/v0.3.5.xsd");
case (0x000306):
return QStringLiteral("://schema/pattern/v0.3.6.xsd");
case (0x000307):
return QStringLiteral("://schema/pattern/v0.3.7.xsd");
case (0x000308):
return QStringLiteral("://schema/pattern/v0.3.8.xsd");
case (0x000309):
return QStringLiteral("://schema/pattern/v0.3.9.xsd");
case (0x000400):
return QStringLiteral("://schema/pattern/v0.4.0.xsd");
case (0x000401):
return QStringLiteral("://schema/pattern/v0.4.1.xsd");
case (0x000402):
return QStringLiteral("://schema/pattern/v0.4.2.xsd");
case (0x000403):
return QStringLiteral("://schema/pattern/v0.4.3.xsd");
case (0x000404):
return QStringLiteral("://schema/pattern/v0.4.4.xsd");
case (0x000405):
return QStringLiteral("://schema/pattern/v0.4.5.xsd");
case (0x000406):
return QStringLiteral("://schema/pattern/v0.4.6.xsd");
case (0x000407):
return QStringLiteral("://schema/pattern/v0.4.7.xsd");
case (0x000408):
return QStringLiteral("://schema/pattern/v0.4.8.xsd");
case (0x000500):
return QStringLiteral("://schema/pattern/v0.5.0.xsd");
case (0x000501):
return QStringLiteral("://schema/pattern/v0.5.1.xsd");
case (0x000600):
return QStringLiteral("://schema/pattern/v0.6.0.xsd");
case (0x000601):
return QStringLiteral("://schema/pattern/v0.6.1.xsd");
case (0x000602):
return QStringLiteral("://schema/pattern/v0.6.2.xsd");
case (0x000603):
return QStringLiteral("://schema/pattern/v0.6.3.xsd");
case (0x000604):
return QStringLiteral("://schema/pattern/v0.6.4.xsd");
case (0x000605):
return QStringLiteral("://schema/pattern/v0.6.5.xsd");
case (0x000606):
return QStringLiteral("://schema/pattern/v0.6.6.xsd");
case (0x000700):
return QStringLiteral("://schema/pattern/v0.7.0.xsd");
case (0x000701):
return QStringLiteral("://schema/pattern/v0.7.1.xsd");
case (0x000702):
return CurrentSchema;
default:
InvalidVersion(ver); InvalidVersion(ver);
} }
} }
@ -446,6 +410,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000702), m_convertedFileName); ValidateXML(XSDSchema(0x000702), m_convertedFileName);
V_FALLTHROUGH V_FALLTHROUGH
case (0x000702): case (0x000702):
ToV0_7_3();
ValidateXML(XSDSchema(0x000703), m_convertedFileName);
V_FALLTHROUGH
case (0x000703):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -463,7 +431,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const bool VPatternConverter::IsReadOnly() const
{ {
// Check if attribute readOnly was not changed in file format // Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 3),
"Check attribute readOnly."); "Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc. // Possibly in future attribute readOnly will change position etc.
@ -957,6 +925,16 @@ void VPatternConverter::ToV0_7_2()
Save(); Save();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_7_3()
{
// TODO. Delete if minimal supported version is 0.7.3
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 3),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.7.3"));
Save();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0() void VPatternConverter::TagUnitToV0_2_0()
{ {

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr; static const QString PatternMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 2); static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 3);
protected: protected:
virtual int MinVer() const Q_DECL_OVERRIDE; virtual int MinVer() const Q_DECL_OVERRIDE;
@ -115,6 +115,7 @@ private:
void ToV0_7_0(); void ToV0_7_0();
void ToV0_7_1(); void ToV0_7_1();
void ToV0_7_2(); void ToV0_7_2();
void ToV0_7_3();
void TagUnitToV0_2_0(); void TagUnitToV0_2_0();
void TagIncrementToV0_2_0(); void TagIncrementToV0_2_0();

View File

@ -81,7 +81,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
objects(), objects(),
stage1(true), stage1(true),
stage2(false), stage2(false),
m_suffix() m_suffix(),
optionalRotationOrigin(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -107,6 +108,12 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
InitOkCancelApply(ui); InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxRotationOriginPoint);
ui->comboBoxRotationOriginPoint->blockSignals(true);
ui->comboBoxRotationOriginPoint->addItem(tr("Center point"), NULL_ID);
ui->comboBoxRotationOriginPoint->blockSignals(false);
flagName = true; flagName = true;
CheckState(); CheckState();
@ -122,6 +129,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
vis = new VisToolMove(data); vis = new VisToolMove(data);
SetRotationOrigPointId(NULL_ID);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -215,6 +224,21 @@ void DialogMove::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value); ui->lineEditSuffix->setText(value);
} }
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogMove::GetRotationOrigPointId() const
{
return getCurrentObjectId(ui->comboBoxRotationOriginPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetRotationOrigPointId(const quint32 &value)
{
ChangeCurrentData(ui->comboBoxRotationOriginPoint, value);
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetRotationOriginPointId(value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogMove::GetObjects() const QVector<quint32> DialogMove::GetObjects() const
{ {
@ -278,6 +302,18 @@ void DialogMove::ShowDialog(bool click)
VisToolMove *operation = qobject_cast<VisToolMove *>(vis); VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
{
if (not optionalRotationOrigin)
{
operation->SetRotationOriginPointId(NULL_ID);
SetObject(NULL_ID, ui->comboBoxRotationOriginPoint, "");
operation->RefreshGeometry();
}
optionalRotationOrigin = false; // Handled, next click on empty filed will disable selection
}
else
{
SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator())); SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator())); SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator()));
SetRotationAngle(operation->RotationAngle()); SetRotationAngle(operation->RotationAngle());
@ -288,14 +324,27 @@ void DialogMove::ShowDialog(bool click)
timerLength->start(); timerLength->start();
show(); show();
} }
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMove::ChosenObject(quint32 id, const SceneObject &type) void DialogMove::ChosenObject(quint32 id, const SceneObject &type)
{ {
Q_UNUSED(id) if (not stage1 && stage2 && prepare)// After first choose we ignore all objects
Q_UNUSED(type) {
// do nothing if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
{
if (SetObject(id, ui->comboBoxRotationOriginPoint, ""))
{
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetRotationOriginPointId(id);
operation->RefreshGeometry();
optionalRotationOrigin = true;
}
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -478,6 +527,7 @@ void DialogMove::SaveData()
operation->SetAngle(formulaAngle); operation->SetAngle(formulaAngle);
operation->SetLength(formulaLength); operation->SetLength(formulaLength);
operation->SetRotationAngle(formulaRotationAngle); operation->SetRotationAngle(formulaRotationAngle);
operation->SetRotationOriginPointId(GetRotationOrigPointId());
operation->RefreshGeometry(); operation->RefreshGeometry();
} }

View File

@ -65,6 +65,9 @@ public:
QString GetSuffix() const; QString GetSuffix() const;
void SetSuffix(const QString &value); void SetSuffix(const QString &value);
quint32 GetRotationOrigPointId() const;
void SetRotationOrigPointId(const quint32 &value);
QVector<quint32> GetObjects() const; QVector<quint32> GetObjects() const;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
@ -128,6 +131,8 @@ private:
QString m_suffix; QString m_suffix;
bool optionalRotationOrigin;
void EvalAngle(); void EvalAngle();
void EvalRotationAngle(); void EvalRotationAngle();
void EvalLength(); void EvalLength();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>292</width> <width>292</width>
<height>301</height> <height>332</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -559,8 +559,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QFormLayout" name="formLayout">
<item> <property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelSuffix"> <widget class="QLabel" name="labelSuffix">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -573,9 +576,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/> <widget class="QLineEdit" name="lineEditSuffix"/>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Rotation origin point:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxRotationOriginPoint"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -1295,7 +1295,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
{ {
if (rule == FillComboBox::NoChildren) if (rule == FillComboBox::NoChildren)
{ {
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2) if (i.key() != toolId && i.value()->getIdTool() != toolId && i.key() != ch1 && i.key() != ch2)
{ {
QSharedPointer<VGObject> obj = i.value(); QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType) if (obj->getType() == gType)
@ -1306,7 +1306,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
} }
else else
{ {
if (i.key() != toolId) if (i.key() != toolId && i.value()->getIdTool() != toolId)
{ {
QSharedPointer<VGObject> obj = i.value(); QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation) if (obj->getType() == gType && obj->getMode() == Draw::Calculation)

View File

@ -138,6 +138,7 @@ void VToolMove::setDialog()
dialogTool->SetRotationAngle(formulaRotationAngle); dialogTool->SetRotationAngle(formulaRotationAngle);
dialogTool->SetLength(formulaLength); dialogTool->SetLength(formulaLength);
dialogTool->SetSuffix(suffix); dialogTool->SetSuffix(suffix);
dialogTool->SetRotationOrigPointId(origPointId);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -179,7 +180,18 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data); calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data);
calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)); calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
const QPointF rotationOrigin = GetOriginPoint(initData.source, initData.data, calcLength, calcAngle); QPointF rotationOrigin;
QSharedPointer<VPointF> originPoint;
if (initData.rotationOrigin == NULL_ID)
{
rotationOrigin = GetOriginPoint(initData.source, initData.data, calcLength, calcAngle);
}
else
{
originPoint = initData.data->GeometricObject<VPointF>(initData.rotationOrigin);
rotationOrigin = static_cast<QPointF>(*originPoint);
}
if (initData.typeCreation == Source::FromGui) if (initData.typeCreation == Source::FromGui)
{ {
@ -313,6 +325,12 @@ QT_WARNING_POP
initData.scene->addItem(tool); initData.scene->addItem(tool);
InitOperationToolConnections(initData.scene, tool); InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool); VAbstractPattern::AddTool(initData.id, tool);
if (not originPoint.isNull())
{
initData.doc->IncrementReferens(originPoint->getIdTool());
}
for (int i = 0; i < initData.source.size(); ++i) for (int i = 0; i < initData.source.size(); ++i)
{ {
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
@ -388,6 +406,19 @@ void VToolMove::SetFormulaLength(const VFormula &value)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolMove::OriginPointName() const
{
try
{
return VAbstractTool::data.GetGObject(origPointId)->name();
}
catch (const VExceptionBadId &)
{
return tr("Center point");
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolMove::ShowVisualization(bool show) void VToolMove::ShowVisualization(bool show)
{ {
@ -421,6 +452,7 @@ void VToolMove::SetVisualization()
visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle, visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle,
qApp->Settings()->GetOsSeparator())); qApp->Settings()->GetOsSeparator()));
visual->SetLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); visual->SetLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator()));
visual->SetRotationOriginPointId(origPointId);
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
@ -432,18 +464,19 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
QSharedPointer<DialogMove> dialogTool = m_dialog.objectCast<DialogMove>(); QSharedPointer<DialogMove> dialogTool = m_dialog.objectCast<DialogMove>();
SCASSERT(not dialogTool.isNull()) SCASSERT(not dialogTool.isNull())
Q_UNUSED(oldDependencies); AddDependence(oldDependencies, origPointId);
Q_UNUSED(newDependencies) AddDependence(newDependencies, dialogTool->GetRotationOrigPointId());
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
QString length = dialogTool->GetLength(); doc->SetAttribute(domElement, AttrLength, dialogTool->GetLength());
doc->SetAttribute(domElement, AttrLength, length);
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolMove::ReadToolAttributes(const QDomElement &domElement) void VToolMove::ReadToolAttributes(const QDomElement &domElement)
{ {
origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "0"); formulaAngle = doc->GetParametrString(domElement, AttrAngle, "0");
formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, "0"); formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, "0");
formulaLength = doc->GetParametrString(domElement, AttrLength, "0"); formulaLength = doc->GetParametrString(domElement, AttrLength, "0");
@ -460,6 +493,7 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle); doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle);
doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrSuffix, suffix); doc->SetAttribute(tag, AttrSuffix, suffix);
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
SaveSourceDestination(tag); SaveSourceDestination(tag);
} }
@ -468,12 +502,18 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
QString VToolMove::MakeToolTip() const QString VToolMove::MakeToolTip() const
{ {
const QString toolTip = QString("<tr> <td><b>%1:</b> %2°</td> </tr>" const QString toolTip = QString("<tr> <td><b>%1:</b> %2°</td> </tr>"
"<tr> <td><b>%3:</b> %4 %5</td> </tr>") "<tr> <td><b>%3:</b> %4 %5</td> </tr>"
.arg(tr("Rotation angle")) "<tr> <td><b>%6:</b> %7°</td> </tr>"
.arg(GetFormulaAngle().getDoubleValue()) "<tr> <td><b>%8:</b> %9</td> </tr>")
.arg(tr("Length")) .arg(tr("Angle")) // 1
.arg(GetFormulaLength().getDoubleValue()) .arg(GetFormulaAngle().getDoubleValue()) // 2
.arg(UnitsToStr(qApp->patternUnit(), true)); .arg(tr("Length")) // 3
.arg(GetFormulaLength().getDoubleValue()) // 4
.arg(UnitsToStr(qApp->patternUnit(), true)) // 5
.arg(tr("Rotation angle")) // 6
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
.arg(tr("Rotation origin point")) // 8
.arg(OriginPointName()); // 9
return toolTip; return toolTip;
} }
@ -483,7 +523,8 @@ VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
initData.destination, parent), initData.destination, parent),
formulaAngle(initData.formulaAngle), formulaAngle(initData.formulaAngle),
formulaRotationAngle(initData.formulaRotationAngle), formulaRotationAngle(initData.formulaRotationAngle),
formulaLength(initData.formulaLength) formulaLength(initData.formulaLength),
origPointId(initData.rotationOrigin)
{ {
InitOperatedObjects(); InitOperatedObjects();
ToolCreation(initData.typeCreation); ToolCreation(initData.typeCreation);

View File

@ -51,12 +51,14 @@ struct VToolMoveInitData : VAbstractOperationInitData
: VAbstractOperationInitData(), : VAbstractOperationInitData(),
formulaAngle(), formulaAngle(),
formulaRotationAngle(), formulaRotationAngle(),
formulaLength() formulaLength(),
rotationOrigin(NULL_ID)
{} {}
QString formulaAngle; QString formulaAngle;
QString formulaRotationAngle; QString formulaRotationAngle;
QString formulaLength; QString formulaLength;
quint32 rotationOrigin;
}; };
class VToolMove : public VAbstractOperation class VToolMove : public VAbstractOperation
@ -83,6 +85,8 @@ public:
VFormula GetFormulaLength() const; VFormula GetFormulaLength() const;
void SetFormulaLength(const VFormula &value); void SetFormulaLength(const VFormula &value);
QString OriginPointName() const;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
protected slots: protected slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
@ -98,6 +102,7 @@ private:
QString formulaAngle; QString formulaAngle;
QString formulaRotationAngle; QString formulaRotationAngle;
QString formulaLength; QString formulaLength;
quint32 origPointId;
VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr); VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr);

View File

@ -237,8 +237,11 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDrawTool::AddDependence(QList<quint32> &list, quint32 objectId) const void VDrawTool::AddDependence(QList<quint32> &list, quint32 objectId) const
{ {
if (objectId != NULL_ID)
{
auto originPoint = VAbstractTool::data.GetGObject(objectId); auto originPoint = VAbstractTool::data.GetGObject(objectId);
list.append(originPoint->getIdTool()); list.append(originPoint->getIdTool());
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -64,12 +64,14 @@ VisToolMove::VisToolMove(const VContainer *data, QGraphicsItem *parent)
rotationAngle(INT_MIN), rotationAngle(INT_MIN),
length(0), length(0),
pointOrigin(nullptr), pointOrigin(nullptr),
pointRotationOrigin(nullptr),
pointFinish(nullptr), pointFinish(nullptr),
angleArc(nullptr), angleArc(nullptr),
rotationLine(nullptr), rotationLine(nullptr),
xAxis(nullptr) xAxis(nullptr)
{ {
pointOrigin = InitPoint(supportColor2, this); pointOrigin = InitPoint(supportColor2, this);
pointRotationOrigin = InitPoint(supportColor2, this);
pointFinish = InitPoint(supportColor, this); pointFinish = InitPoint(supportColor, this);
angleArc = InitItem<VCurvePathItem>(supportColor3, this); angleArc = InitItem<VCurvePathItem>(supportColor3, this);
rotationLine = InitItem<VScaledLine>(supportColor3, this); rotationLine = InitItem<VScaledLine>(supportColor3, this);
@ -89,7 +91,7 @@ void VisToolMove::RefreshGeometry()
const QVector<QGraphicsItem *> originObjects = CreateOriginObjects(iPoint, iCurve); const QVector<QGraphicsItem *> originObjects = CreateOriginObjects(iPoint, iCurve);
const QPointF origin = GetOriginPoint(originObjects); QPointF origin = GetOriginPoint(originObjects);
DrawPoint(pointOrigin, origin, supportColor2); DrawPoint(pointOrigin, origin, supportColor2);
qreal tempAngle = 0; qreal tempAngle = 0;
@ -118,10 +120,21 @@ void VisToolMove::RefreshGeometry()
tempAngle = angle; tempAngle = angle;
tempLength = length; tempLength = length;
if (object1Id != NULL_ID)
{
origin = Visualization::data->GeometricObject<VPointF>(object1Id)->toQPointF();
DrawPoint(pointRotationOrigin, origin, supportColor2);
}
else
{
origin = line.p2();
pointRotationOrigin->setVisible(false);
}
QLineF rLine; QLineF rLine;
if (VFuzzyComparePossibleNulls(rotationAngle, INT_MIN)) if (VFuzzyComparePossibleNulls(rotationAngle, INT_MIN))
{ {
rLine = QLineF(line.p2(), Visualization::scenePos); rLine = QLineF(origin, Visualization::scenePos);
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{ {
@ -129,7 +142,7 @@ void VisToolMove::RefreshGeometry()
} }
qreal cursorLength = rLine.length(); qreal cursorLength = rLine.length();
rLine.setP2(Ray(line.p2(), rLine.angle())); rLine.setP2(Ray(origin, rLine.angle()));
//Radius of point circle, but little bigger. Need handle with hover sizes. //Radius of point circle, but little bigger. Need handle with hover sizes.
qreal minL = ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5; qreal minL = ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5;
if (cursorLength > minL) if (cursorLength > minL)
@ -143,14 +156,14 @@ void VisToolMove::RefreshGeometry()
} }
else else
{ {
rLine = QLineF(line.p2(), Ray(line.p2(), rotationAngle)); rLine = QLineF(origin, Ray(origin, rotationAngle));
tempRoationAngle = rotationAngle; tempRoationAngle = rotationAngle;
} }
DrawLine(rotationLine, rLine, supportColor3, Qt::DashLine); DrawLine(rotationLine, rLine, supportColor3, Qt::DashLine);
DrawLine(xAxis, QLineF(line.p2(), Ray(line.p2(), 0)), supportColor3, Qt::DashLine); DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor3, Qt::DashLine);
VArc arc(VPointF(line.p2()), ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempRoationAngle); VArc arc(VPointF(origin), ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempRoationAngle);
DrawPath(angleArc, arc.GetPath(), supportColor3, Qt::SolidLine, Qt::RoundCap); DrawPath(angleArc, arc.GetPath(), supportColor3, Qt::SolidLine, Qt::RoundCap);
} }
DrawLine(this, line, supportColor2, Qt::DashLine); DrawLine(this, line, supportColor2, Qt::DashLine);
@ -169,7 +182,7 @@ void VisToolMove::RefreshGeometry()
else else
{ {
Visualization::toolTip = tr("Length = %1%2, angle = %3°, rotation angle = %4°, <b>Shift</b> - sticking angle, " Visualization::toolTip = tr("Length = %1%2, angle = %3°, rotation angle = %4°, <b>Shift</b> - sticking angle, "
"<b>Mouse click</b> - finish creating") "<b>Ctrl</b> - change rotation origin point, <b>Mouse click</b> - finish creating")
.arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)), .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)),
qApp->Settings()->GetOsSeparator())) qApp->Settings()->GetOsSeparator()))
.arg(prefix) .arg(prefix)
@ -177,7 +190,7 @@ void VisToolMove::RefreshGeometry()
.arg(tempRoationAngle); .arg(tempRoationAngle);
} }
CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, line.p2()); CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -222,6 +235,12 @@ void VisToolMove::SetLength(const QString &expression)
length = FindLengthFromUser(expression, Visualization::data->DataVariables()); length = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetRotationOriginPointId(quint32 value)
{
object1Id = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <class Item> template <class Item>
QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i) QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i)

View File

@ -62,6 +62,8 @@ public:
qreal LengthValue() const; qreal LengthValue() const;
void SetLength(const QString &expression); void SetLength(const QString &expression);
void SetRotationOriginPointId(quint32 value);
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolMove)}; enum { Type = UserType + static_cast<int>(Vis::ToolMove)};
private: private:
@ -70,6 +72,7 @@ private:
qreal rotationAngle; qreal rotationAngle;
qreal length; qreal length;
VScaledEllipse *pointOrigin; VScaledEllipse *pointOrigin;
VScaledEllipse *pointRotationOrigin;
VScaledEllipse *pointFinish; VScaledEllipse *pointFinish;
VCurvePathItem *angleArc; VCurvePathItem *angleArc;
VScaledLine *rotationLine; VScaledLine *rotationLine;