New tool CutSpline (Modeling mode).

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-18 20:55:27 +02:00
parent 13bc690f67
commit 452aec26f1
27 changed files with 319 additions and 48 deletions

View File

@ -553,6 +553,21 @@ void VContainer::PrepareDetails(QVector<VItem *> &list) const
} }
} }
qint64 VContainer::PointConvertToModeling(qint64 id)
{
QHashIterator<qint64, VPointF> pModeling(pointsModeling);
while (pModeling.hasNext())
{
pModeling.next();
VPointF p = pModeling.value();
if(p.getIdObject() == id)
{
return pModeling.key();
}
}
return 0;
}
template <typename val> template <typename val>
void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point) void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point)
{ {

View File

@ -573,6 +573,7 @@ public:
* @param list list of details * @param list list of details
*/ */
void PrepareDetails(QVector<VItem *> & list) const; void PrepareDetails(QVector<VItem *> & list) const;
qint64 PointConvertToModeling(qint64 id);
private: private:
/** /**
* @brief _id current id. New object will have value +1. For full class equal 0. * @brief _id current id. New object will have value +1. For full class equal 0.

View File

@ -57,8 +57,11 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
ui->comboBoxLineType->setCurrentIndex(1); ui->comboBoxLineType->setCurrentIndex(1);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
}
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogAlongLine::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogAlongLine::PutVal);
@ -88,6 +91,8 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -52,7 +52,10 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogArc::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogArc::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
}
CheckState(); CheckState();
@ -124,6 +127,7 @@ void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
return; return;
} }
} }

View File

@ -55,9 +55,12 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxPoints(ui->comboBoxThirdPoint); FillComboBoxPoints(ui->comboBoxThirdPoint);
}
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere);
@ -88,6 +91,9 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxPoints(ui->comboBoxThirdPoint);
return; return;
} }
} }

View File

@ -53,7 +53,10 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, Draw::Draws mode, QWidg
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSpline::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogCutSpline::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxSplines(ui->comboBoxSpline); FillComboBoxSplines(ui->comboBoxSpline);
}
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal);
@ -100,6 +103,7 @@ void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxSplines(ui->comboBoxSpline);
return; return;
} }
} }

View File

@ -53,7 +53,10 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, Draw::Draws mod
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSplinePath::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogCutSplinePath::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxSplines(ui->comboBoxSplinePath); FillComboBoxSplines(ui->comboBoxSplinePath);
}
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal);
@ -100,6 +103,7 @@ void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxSplines(ui->comboBoxSplinePath);
return; return;
} }
} }

View File

@ -67,6 +67,7 @@ void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type)
{ {
if (CheckObject(id) == false) if (CheckObject(id) == false)
{ {
qDebug()<<"false";
return; return;
} }
} }

View File

@ -56,7 +56,10 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogEndLine::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogEndLine::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
}
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, connect(ui->toolButtonArrowDown, &QPushButton::clicked, this,
@ -98,6 +101,7 @@ void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
return; return;
} }
} }

View File

@ -43,9 +43,12 @@ DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *pa
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line); FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxPoints(ui->comboBoxP2Line);
}
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
} }
@ -92,6 +95,9 @@ void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
return; return;
} }
} }

View File

@ -39,8 +39,11 @@ DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
}
number = 0; number = 0;
} }
@ -88,6 +91,8 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -43,10 +43,13 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mod
flagName = false; flagName = false;
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogLineIntersect::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogLineIntersect::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1Line1); FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1); FillComboBoxPoints(ui->comboBoxP2Line1);
FillComboBoxPoints(ui->comboBoxP1Line2); FillComboBoxPoints(ui->comboBoxP1Line2);
FillComboBoxPoints(ui->comboBoxP2Line2); FillComboBoxPoints(ui->comboBoxP2Line2);
}
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
} }
@ -63,6 +66,10 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1);
FillComboBoxPoints(ui->comboBoxP1Line2);
FillComboBoxPoints(ui->comboBoxP2Line2);
return; return;
} }
} }

View File

@ -56,8 +56,11 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, connect(ui->toolButtonArrowDown, &QPushButton::clicked, this,
@ -104,6 +107,8 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -54,9 +54,12 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
CheckState(); CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui.comboBoxCenter); FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint); FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint); FillComboBoxPoints(ui.comboBoxSecondPoint);
}
connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere);
connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
@ -81,6 +84,9 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -43,8 +43,11 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Dra
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
}
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
} }
@ -66,6 +69,8 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -57,9 +57,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1Line); FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder); FillComboBoxPoints(ui->comboBoxPShoulder);
}
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal);
@ -89,6 +92,9 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder);
return; return;
} }
} }

View File

@ -41,7 +41,10 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWi
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSplinePath::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogSplinePath::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxPoint); FillComboBoxPoints(ui->comboBoxPoint);
}
path = VSplinePath(data->DataPoints()); path = VSplinePath(data->DataPoints());
@ -83,6 +86,7 @@ void DialogSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxPoint);
return; return;
} }
} }

View File

@ -43,10 +43,13 @@ DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget
CheckState(); CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxAxisP1); FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2); FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
}
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
} }
@ -62,6 +65,10 @@ void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
if (type == Scene::Detail) if (type == Scene::Detail)
{ {
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return; return;
} }
} }

View File

@ -271,6 +271,7 @@ template <typename T>
void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail) void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail)
{ {
QHash<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
Q_ASSERT(tools != 0);
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail)); VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
Q_ASSERT(det != 0); Q_ASSERT(det != 0);
det->AddTool(tool, id, typeTool); det->AddTool(tool, id, typeTool);

View File

@ -77,7 +77,9 @@ namespace Tool
NodeSplinePath, NodeSplinePath,
Height, Height,
Triangle, Triangle,
PointOfIntersection PointOfIntersection,
SimpleSpline,
SimpleSplinePath
}; };
Q_DECLARE_FLAGS(Tools, Tool) Q_DECLARE_FLAGS(Tools, Tool)

View File

@ -42,13 +42,13 @@ VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64
Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0"); Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0");
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0"); Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
firstSpline = new VSimpleSpline(spl1id, &factor, &currentColor); firstSpline = new VSimpleSpline(spl1id, &currentColor, &factor);
Q_ASSERT(firstSpline != 0); Q_ASSERT(firstSpline != 0);
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
firstSpline->setParentItem(this); firstSpline->setParentItem(this);
connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed);
secondSpline = new VSimpleSpline(spl2id, &factor, &currentColor); secondSpline = new VSimpleSpline(spl2id, &currentColor, &factor);
Q_ASSERT(secondSpline != 0); Q_ASSERT(secondSpline != 0);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
secondSpline->setParentItem(this); secondSpline->setParentItem(this);

View File

@ -27,17 +27,32 @@
*************************************************************************/ *************************************************************************/
#include "vmodelingcutspline.h" #include "vmodelingcutspline.h"
#include "../../container/calculator.h"
const QString VModelingCutSpline::ToolType = QStringLiteral("cutSpline"); const QString VModelingCutSpline::ToolType = QStringLiteral("cutSpline");
const QString VModelingCutSpline::AttrSpline = QStringLiteral("spline"); const QString VModelingCutSpline::AttrSpline = QStringLiteral("spline");
VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splineId, const QString &formula, const qint64 &splineId, const qint64 &spl1id,
const Tool::Sources &typeCreation, QGraphicsItem *parent) const qint64 &spl2id, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), formula(formula), splineId(splineId), :VModelingPoint(doc, data, id, parent), formula(formula), splineId(splineId),
dialogCutSpline(QSharedPointer<DialogCutSpline>()) dialogCutSpline(QSharedPointer<DialogCutSpline>()), firstSpline(), secondSpline(), spl1id(spl1id), spl2id(spl2id)
{ {
Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0"); Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0");
Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0");
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
firstSpline = new VSimpleSpline(spl1id, &currentColor);
Q_ASSERT(firstSpline != 0);
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
firstSpline->setParentItem(this);
connect(firstSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed);
secondSpline = new VSimpleSpline(spl2id, &currentColor);
Q_ASSERT(secondSpline != 0);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
secondSpline->setParentItem(this);
connect(secondSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed);
if (typeCreation == Tool::FromGui) if (typeCreation == Tool::FromGui)
{ {
AddToFile(); AddToFile();
@ -47,10 +62,10 @@ VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, cons
void VModelingCutSpline::setDialog() void VModelingCutSpline::setDialog()
{ {
Q_ASSERT(dialogCutSpline.isNull() == false); Q_ASSERT(dialogCutSpline.isNull() == false);
VSpline spl = VAbstractTool::data.GetSplineModeling(id); VPointF point = VAbstractTool::data.GetPointModeling(id);
dialogCutSpline->setFormula(formula); dialogCutSpline->setFormula(formula);
dialogCutSpline->setSplineId(splineId, id); dialogCutSpline->setSplineId(splineId, id);
dialogCutSpline->setPointName(spl.name()); dialogCutSpline->setPointName(point.name());
} }
VModelingCutSpline *VModelingCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog, VModelingCutSpline *VModelingCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog,
@ -67,7 +82,81 @@ VModelingCutSpline *VModelingCutSpline::Create(const qint64 _id, const QString &
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation) const Tool::Sources &typeCreation)
{ {
VModelingCutSpline *cutPoint = 0;
VSpline spl = data->GetSplineModeling(splineId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl.CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
qint64 splP1id, splP4id;
Draw::Draws typeObject = spl.getMode();
if (typeObject == Draw::Calculation)
{
splP1id = data->PointConvertToModeling(spl.GetP1());
splP4id = data->PointConvertToModeling(spl.GetP4());
if (parse == Document::FullParse)
{
doc->IncrementReferens(splP1id);
doc->IncrementReferens(splP4id);
}
}
else
{
splP1id = spl.GetP1();
splP4id = spl.GetP4();
}
qint64 id = _id;
qint64 spl1id = 0;
qint64 spl2id = 0;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(point.x(), point.y(), pointName, mx, my));
VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve());
spl1id = data->AddSplineModeling(spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve());
spl2id = data->AddSplineModeling(spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
}
else
{
data->UpdatePointModeling(id, VPointF(point.x(), point.y(), pointName, mx, my));
spl1id = id + 1;
spl2id = id + 2;
VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve());
data->UpdateSplineModeling(spl1id, spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve());
data->UpdateSplineModeling(spl2id, spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
//VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
if (parse == Document::FullParse)
{
cutPoint = new VModelingCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
doc->AddTool(id, cutPoint);
doc->AddTool(spl1id, cutPoint);
doc->AddTool(spl2id, cutPoint);
doc->IncrementReferens(splineId);
}
}
return cutPoint;
} }
void VModelingCutSpline::FullUpdateFromFile() void VModelingCutSpline::FullUpdateFromFile()
@ -97,6 +186,11 @@ void VModelingCutSpline::FullUpdateFromGui(int result)
dialogCutSpline.clear(); dialogCutSpline.clear();
} }
void VModelingCutSpline::SplineChoosed(qint64 id)
{
emit ChoosedTool(id, Scene::Spline);
}
void VModelingCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VModelingCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogCutSpline, this, event); ContextMenu(dialogCutSpline, this, event);
@ -108,6 +202,7 @@ void VModelingCutSpline::AddToFile()
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id); AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name()); AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx())); AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my())); AddAttribute(domElement, AttrMy, toMM(point.my()));
@ -120,5 +215,25 @@ void VModelingCutSpline::AddToFile()
void VModelingCutSpline::RefreshGeometry() void VModelingCutSpline::RefreshGeometry()
{ {
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id)); VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
} }
void VModelingCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr)
{
VSpline spl = VModelingTool::data.GetSplineModeling(splid);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
if(tr == SimpleSpline::FirstPoint)
{
path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y());
}
else
{
path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y());
}
spline->setPath(path);
}

View File

@ -31,13 +31,15 @@
#include "vmodelingpoint.h" #include "vmodelingpoint.h"
#include "../../dialogs/dialogcutspline.h" #include "../../dialogs/dialogcutspline.h"
#include "../../widgets/vsimplespline.h"
class VModelingCutSpline: public VModelingPoint class VModelingCutSpline: public VModelingPoint
{ {
Q_OBJECT Q_OBJECT
public: public:
VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splineId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/** /**
* @brief setDialog * @brief setDialog
*/ */
@ -83,6 +85,11 @@ public slots:
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
/**
* @brief SplineChoosed
* @param id
*/
void SplineChoosed(qint64 id);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent
@ -107,6 +114,17 @@ private:
* @brief DialogCutSpline pointer to the tool's dialog * @brief DialogCutSpline pointer to the tool's dialog
*/ */
QSharedPointer<DialogCutSpline> dialogCutSpline; QSharedPointer<DialogCutSpline> dialogCutSpline;
/**
* @brief firstSpline
*/
VSimpleSpline *firstSpline;
/**
* @brief secondSpline
*/
VSimpleSpline *secondSpline;
const qint64 spl1id;
const qint64 spl2id;
void RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr);
}; };
#endif // VMODELINGCUTSPLINE_H #endif // VMODELINGCUTSPLINE_H

View File

@ -105,6 +105,15 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
case (Tool::PointOfIntersection): case (Tool::PointOfIntersection):
InitTool<VModelingPointOfIntersection>(scene, detail[i]); InitTool<VModelingPointOfIntersection>(scene, detail[i]);
break; break;
case (Tool::CutSplineTool):
InitTool<VModelingCutSpline>(scene, detail[i]);
break;
case (Tool::SimpleSpline):
//No need init this tool. See CutSplineTool.
break;
case (Tool::SimpleSplinePath):
//No need init this tool. See CutSplineTool.
break;
default: default:
qWarning()<<"Get wrong tool type. Ignore."; qWarning()<<"Get wrong tool type. Ignore.";
break; break;
@ -455,6 +464,9 @@ void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node)
case (Tool::PointOfIntersection): case (Tool::PointOfIntersection):
AddAttribute(nod, AttrType, QStringLiteral("PointOfIntersection")); AddAttribute(nod, AttrType, QStringLiteral("PointOfIntersection"));
break; break;
case (Tool::CutSplineTool):
AddAttribute(nod, AttrType, QStringLiteral("CutSplineTool"));
break;
default: default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO; qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break; break;

View File

@ -29,10 +29,17 @@
#include "vsimplespline.h" #include "vsimplespline.h"
#include "../options.h" #include "../options.h"
VSimpleSpline::VSimpleSpline(qint64 id, qreal *factor, Qt::GlobalColor *currentColor, QObject *parent) VSimpleSpline::VSimpleSpline(qint64 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor) :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
if(factor == 0)
{
setPen(QPen(Qt::black, widthHairLine));
}
else
{ {
setPen(QPen(Qt::black, widthHairLine/ *factor)); setPen(QPen(Qt::black, widthHairLine/ *factor));
}
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
} }
@ -49,11 +56,25 @@ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
if(factor == 0)
{
this->setPen(QPen(*currentColor, widthMainLine));
}
else
{
this->setPen(QPen(*currentColor, widthMainLine/ *factor)); this->setPen(QPen(*currentColor, widthMainLine/ *factor));
} }
}
void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
if(factor == 0)
{
this->setPen(QPen(*currentColor, widthHairLine));
}
else
{
this->setPen(QPen(*currentColor, widthHairLine/ *factor)); this->setPen(QPen(*currentColor, widthHairLine/ *factor));
} }
}

View File

@ -55,7 +55,7 @@ public:
* @param currentColor * @param currentColor
* @param parent * @param parent
*/ */
VSimpleSpline(qint64 id, qreal *factor, Qt::GlobalColor *currentColor, QObject *parent = 0); VSimpleSpline(qint64 id, Qt::GlobalColor *currentColor, qreal *factor = 0, QObject *parent = 0);
signals: signals:
/** /**
* @brief Choosed * @brief Choosed

View File

@ -671,6 +671,13 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
{ {
tool = Tool::PointOfIntersection; tool = Tool::PointOfIntersection;
} }
else if (t == "CutSplineTool")
{
tool = Tool::CutSplineTool;
nodeType = NodeDetail::Modeling;
detail.append(VNodeDetail(id + 1, Tool::SimpleSpline, Draw::Modeling, nodeType, mx, my));
detail.append(VNodeDetail(id + 2, Tool::SimpleSplinePath, Draw::Modeling, nodeType, mx, my));
}
detail.append(VNodeDetail(id, tool, Draw::Modeling, nodeType, mx, my)); detail.append(VNodeDetail(id, tool, Draw::Modeling, nodeType, mx, my));
} }
} }