Refactoring. Prepare for showing tools options.

--HG--
branch : feature
This commit is contained in:
dismine 2014-08-30 22:58:31 +03:00
parent 87d32d9445
commit c412d0c51b
64 changed files with 610 additions and 920 deletions

View File

@ -255,6 +255,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
QCursor cur(pixmap, 2, 3);
ui->view->setCursor(cur);
helpLabel->setText(toolTip);
ui->view->setShowToolOptions(false);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
@ -292,6 +293,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
QPixmap pixmap(cursor);
QCursor cur(pixmap, 2, 3);
ui->view->setCursor(cur);
ui->view->setShowToolOptions(false);
helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
@ -321,7 +323,8 @@ void MainWindow::ClosedDialog(int result)
SCASSERT(dialogTool != nullptr);
if (result == QDialog::Accepted)
{
DrawTool::Create(dialogTool, currentScene, doc, pattern);
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(DrawTool::Create(dialogTool, currentScene, doc, pattern));
ui->view->itemClicked(tool);
}
ArrowTool();
}
@ -349,9 +352,11 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->FullUpdateFromGuiApply();
}
}
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool());
ui->view->itemClicked(tool);
if (dialogTool->GetAssociatedTool() != nullptr)
{
VDrawTool * vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
VDrawTool *vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->DialogLinkDestroy();
}
ArrowTool();
@ -1067,6 +1072,7 @@ void MainWindow::ArrowTool()
QCursor cur(Qt::ArrowCursor);
ui->view->setCursor(cur);
helpLabel->setText("");
ui->view->setShowToolOptions(true);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -52,6 +52,12 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QGraphicsPathItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::getTagName() const
{
return VAbstractSpline::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.

View File

@ -42,6 +42,7 @@ public:
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile ();
void Disable(bool disable);

View File

@ -148,6 +148,36 @@ void VDrawTool::SaveDialogChange()
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VDrawTool::AddToFile()
{
QDomElement domElement = doc->createElement(getTagName());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VDrawTool::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(domElement, obj);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DialogLinkDestroy removes dialog pointer

View File

@ -81,6 +81,8 @@ protected:
/** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement)=0;
void SaveDialogChange();
virtual void AddToFile();
virtual void RefreshDataInFile();
template <typename Dialog, typename Tool>
/**

View File

@ -31,7 +31,6 @@
#include "../../dialogs/tools/dialogalongline.h"
#include "../../geometry/vpointf.h"
#include "exception/vexceptionobjecterror.h"
#include "../undocommands/savetooloptions.h"
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
@ -114,38 +113,6 @@ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogAlongLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolAlongLine::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
SaveOptions(domElement, *point.data());
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolAlongLine::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
SaveOptions(domElement, *point.data());
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -173,13 +140,16 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::SaveOptions(QDomElement &tag, const VPointF &point)
void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point.name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my()));
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
@ -187,26 +157,6 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, const VPointF &point)
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::SaveOption(const VPointF &point)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveOptions(newDomElement, point);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolAlongLine::getSecondPointId() const
{
@ -218,46 +168,8 @@ void VToolAlongLine::setSecondPointId(const quint32 &value)
{
secondPointId = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setName(const QString &name)
{
VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id).data());
newPoint.setName(name);
SaveOption(newPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setTypeLine(const QString &value)
{
typeLine = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
formulaLength = value.getFormula(FormulaType::FromUser);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setFirstPointId(const quint32 &value)
{
basePointId = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -51,27 +51,22 @@ public:
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
void setFirstPointId(const quint32 &value);
quint32 getSecondPointId() const;
void setSecondPointId(const quint32 &value);
void setName(const QString &name);
void setTypeLine(const QString &value);
void setFormulaLength(const VFormula &value);
public slots:
virtual void FullUpdateFromFile();
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief secondPointId id second point of line. */
quint32 secondPointId;
void SaveOptions(QDomElement &tag, const VPointF &point);
void SaveOption(const VPointF &point);
};
#endif // VTOOLALONGLINE_H

View File

@ -164,6 +164,12 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolArc::getTagName() const
{
return VToolArc::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -183,42 +189,6 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolArc::AddToFile()
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2());
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolArc::RefreshDataInFile()
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -244,6 +214,20 @@ void VToolArc::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
SCASSERT(arc.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -48,14 +48,14 @@ public:
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Arc)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile();
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
void RefreshGeometry();
};

View File

@ -263,51 +263,6 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogBisector>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolBisector::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolBisector::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -335,3 +290,22 @@ void VToolBisector::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId()));
doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, basePointId);
doc->SetAttribute(tag, AttrThirdPoint, thirdPointId);
}

View File

@ -61,10 +61,9 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief firstPointId id first point of angle. */
quint32 firstPointId;

View File

@ -219,45 +219,6 @@ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutArc::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutArc::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -296,3 +257,19 @@ void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurve
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrArc, curveCutId);
}

View File

@ -56,11 +56,10 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutArc)
};

View File

@ -88,7 +88,7 @@ void VToolCutSpline::setDialog()
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -97,7 +97,13 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
const quint32 splineId = dialogTool->getSplineId();
Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
VToolCutSpline* point = nullptr;
point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
@ -115,9 +121,10 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(splineId);
@ -175,7 +182,9 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point);
doc->IncrementReferens(splineId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
@ -217,45 +226,6 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSpline::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSpline::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -294,3 +264,19 @@ void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCu
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSpline, curveCutId);
}

View File

@ -43,10 +43,10 @@ public:
const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString AttrSpline;
virtual int type() const {return Type;}
@ -57,11 +57,10 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutSpline)
};

View File

@ -91,7 +91,8 @@ void VToolCutSplinePath::setDialog()
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
@ -99,7 +100,13 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
const quint32 splinePathId = dialogTool->getSplinePathId();
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
VToolCutSplinePath* point = nullptr;
point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
@ -117,10 +124,10 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId);
SCASSERT(splPath != nullptr);
@ -230,7 +237,9 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point);
doc->IncrementReferens(splinePathId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
@ -272,45 +281,6 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutSplinePath>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSplinePath::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSplinePath::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -351,3 +321,19 @@ void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, Simp
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSplinePath, curveCutId);
}

View File

@ -44,10 +44,11 @@ public:
const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString AttrSplinePath;
virtual int type() const {return Type;}
@ -58,11 +59,10 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutSplinePath)
};

View File

@ -32,7 +32,6 @@
#include "../../dialogs/tools/dialogendline.h"
#include "../../dialogs/tools/dialogeditwrongformula.h"
#include "../../geometry/vpointf.h"
#include "../../undocommands/savetooloptions.h"
const QString VToolEndLine::ToolType = QStringLiteral("endLine");
@ -171,54 +170,6 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
return nullptr;
}
void VToolEndLine::SaveOption(const VPointF &point)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveOptions(newDomElement, point);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
void VToolEndLine::setName(const QString &name)
{
VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id).data());
newPoint.setName(name);
SaveOption(newPoint);
}
void VToolEndLine::setBasePointId(const quint32 &value)
{
if (value != NULL_ID)
{
basePointId = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
}
void VToolEndLine::setFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
formulaLength = value.getFormula(FormulaType::FromUser);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -256,38 +207,6 @@ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogEndLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolEndLine::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
SaveOptions(domElement, *point.data());
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolEndLine::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
SaveOptions(domElement, *point.data());
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -305,13 +224,16 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::SaveOptions(QDomElement &tag, const VPointF &point)
void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point.name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my()));
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
@ -336,16 +258,7 @@ void VToolEndLine::setFormulaAngle(const VFormula &value)
{
formulaAngle = value.getFormula(FormulaType::FromUser);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::setTypeLine(const QString &value)
{
typeLine = value;
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
SaveOption(*point.data());
}

View File

@ -51,24 +51,19 @@ public:
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::EndLine)};
void setName(const QString &name);
VFormula getFormulaAngle() const;
void setFormulaAngle(const VFormula &value);
void setTypeLine(const QString &value);
void setFormulaLength(const VFormula &value);
void setBasePointId(const quint32 &value);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
QString formulaAngle;
void SaveOptions(QDomElement &tag, const VPointF &point);
void SaveOption(const VPointF &point);
};
#endif // VTOOLENDLINE_H

View File

@ -224,50 +224,6 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogHeight>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolHeight::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
doc->SetAttribute(domElement, AttrP1Line, p1LineId);
doc->SetAttribute(domElement, AttrP2Line, p2LineId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolHeight::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
doc->SetAttribute(domElement, AttrP1Line, p1LineId);
doc->SetAttribute(domElement, AttrP2Line, p2LineId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -283,3 +239,21 @@ void VToolHeight::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrP1Line, p1LineId);
doc->SetAttribute(tag, AttrP2Line, p2LineId);
}

View File

@ -57,9 +57,8 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief p1LineId id first point of line. */
quint32 p1LineId;

View File

@ -176,6 +176,12 @@ void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QGraphicsLineItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolLine::getTagName() const
{
return VToolLine::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -254,11 +260,8 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
@ -271,9 +274,12 @@ void VToolLine::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
@ -366,6 +372,17 @@ void VToolLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
Q_UNUSED(obj)
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrFirstPoint, firstPoint);
doc->SetAttribute(tag, AttrSecondPoint, secondPoint);
doc->SetAttribute(tag, AttrTypeLine, typeLine);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -50,6 +50,7 @@ public:
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Line)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString &newName);
@ -66,6 +67,7 @@ protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief firstPoint id first line point. */
quint32 firstPoint;

View File

@ -234,49 +234,6 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogLineIntersect>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolLineIntersect::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
doc->SetAttribute(domElement, AttrP1Line2, p1Line2);
doc->SetAttribute(domElement, AttrP2Line2, p2Line2);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolLineIntersect::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
doc->SetAttribute(domElement, AttrP1Line2, p1Line2);
doc->SetAttribute(domElement, AttrP2Line2, p2Line2);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -304,3 +261,21 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2()));
doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrP1Line1, p1Line1);
doc->SetAttribute(tag, AttrP2Line1, p2Line1);
doc->SetAttribute(tag, AttrP1Line2, p1Line2);
doc->SetAttribute(tag, AttrP2Line2, p2Line2);
}

View File

@ -56,10 +56,9 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief p1Line1 id first point first line. */
quint32 p1Line1;

View File

@ -108,11 +108,25 @@ void VToolLinePoint::SetFactor(qreal factor)
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLinePoint::getBasePointId() const
{
return basePointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setBasePointId(const quint32 &value)
{
if (value != NULL_ID)
{
basePointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolLinePoint::getFormulaLength() const
{
VFormula fLength(formulaLength, this->getData());
@ -122,3 +136,15 @@ VFormula VToolLinePoint::getFormulaLength() const
return fLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
formulaLength = value.getFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}

View File

@ -44,10 +44,10 @@ public:
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
VFormula getFormulaLength() const;
//void setFormulaLength(const QString &value)=0;
void setFormulaLength(const VFormula &value);
quint32 getBasePointId() const;
//void setBasePointId(const quint32 &value)=0;
void setBasePointId(const quint32 &value);
public slots:
virtual void ChangedActivDraw(const QString &newName);

View File

@ -242,51 +242,6 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogNormal>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolNormal::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolNormal::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, angle);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -313,3 +268,22 @@ void VToolNormal::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, angle);
doc->SetAttribute(tag, AttrFirstPoint, basePointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}

View File

@ -58,10 +58,9 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief secondPointId id second line point. */
quint32 secondPointId;

View File

@ -78,6 +78,20 @@ QString VToolPoint::name() const
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::setName(const QString &name)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
obj->setName(name);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolPoint::getTagName() const
{
return VToolPoint::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NameChangePosition handle change posion point label.

View File

@ -44,10 +44,11 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
public:
VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VToolPoint(){}
static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
QString name() const;
//void setName(const QString &name)=0;
void setName(const QString &name);
virtual QString getTagName() const;
static const QString TagName;
public slots:
void NameChangePosition(const QPointF &pos);
virtual void ChangedActivDraw(const QString &newName);

View File

@ -260,49 +260,6 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event
ContextMenu<DialogPointOfContact>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolPointOfContact::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrRadius, arcRadius);
doc->SetAttribute(domElement, AttrCenter, center);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolPointOfContact::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrRadius, arcRadius);
doc->SetAttribute(domElement, AttrCenter, center);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -329,3 +286,21 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrRadius, arcRadius);
doc->SetAttribute(tag, AttrCenter, center);
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}

View File

@ -59,10 +59,9 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief radius string with formula radius arc. */
QString arcRadius;

View File

@ -203,45 +203,6 @@ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *
ContextMenu<DialogPointOfIntersection>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolPointOfIntersection::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolPointOfIntersection::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -255,3 +216,19 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}

View File

@ -57,9 +57,8 @@ public slots:
protected:
virtual void RemoveReferens();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolPointOfIntersection)
/** @brief firstPointId id first line point. */

View File

@ -267,51 +267,6 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogShoulderPoint>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolShoulderPoint::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrP1Line, basePointId);
doc->SetAttribute(domElement, AttrP2Line, p2Line);
doc->SetAttribute(domElement, AttrPShoulder, pShoulder);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolShoulderPoint::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrP1Line, basePointId);
doc->SetAttribute(domElement, AttrP2Line, p2Line);
doc->SetAttribute(domElement, AttrPShoulder, pShoulder);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -339,3 +294,22 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line()));
doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getPShoulder()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrP1Line, basePointId);
doc->SetAttribute(tag, AttrP2Line, p2Line);
doc->SetAttribute(tag, AttrPShoulder, pShoulder);
}

View File

@ -59,10 +59,9 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief p2Line id second line point. */
quint32 p2Line;

View File

@ -33,7 +33,6 @@
#include "../../undocommands/addpatternpiece.h"
#include "../../undocommands/deletepatternpiece.h"
#include "../../geometry/vpointf.h"
#include "../../undocommands/savetooloptions.h"
#include <QMessageBox>
@ -83,34 +82,6 @@ void VToolSinglePoint::setDialog()
dialogTool->setData(p->name(), p->toQPointF());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::setName(const QString &name)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id).data());
newPoint.setName(name);
SaveOptions(newDomElement, newPoint);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
int VToolSinglePoint::type() const
{
return Type;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
@ -119,11 +90,11 @@ void VToolSinglePoint::AddToFile()
{
Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty");
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement sPoint = doc->createElement(TagName);
// Create SPoint tag
SaveOptions(sPoint, *point.data());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(sPoint, obj);
//Create pattern piece structure
QDomElement patternPiece = doc->createElement(VPattern::TagDraw);
@ -142,24 +113,6 @@ void VToolSinglePoint::AddToFile()
qApp->getUndoStack()->push(addPP);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolSinglePoint::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
SaveOptions(domElement, *point.data());
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle tool change.
@ -298,15 +251,18 @@ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::SaveOptions(QDomElement &tag, const VPointF &point)
void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point.name());
doc->SetAttribute(tag, AttrX, qApp->fromPixel(point.x()));
doc->SetAttribute(tag, AttrY, qApp->fromPixel(point.y()));
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my()));
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrX, qApp->fromPixel(point->x()));
doc->SetAttribute(tag, AttrY, qApp->fromPixel(point->y()));
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -43,8 +43,7 @@ public:
const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr );
virtual void setDialog();
static const QString ToolType;
void setName(const QString &name);
virtual int type()const;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::SinglePoint)};
public slots:
virtual void FullUpdateFromFile();
@ -59,7 +58,6 @@ signals:
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void decrementReferens();
virtual void DeleteTool(bool ask = true);
@ -68,11 +66,12 @@ protected:
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
QString namePP;
QString mPath;
void setColorLabel(const Qt::GlobalColor & color);
void SaveOptions(QDomElement &tag, const VPointF &point);
};
#endif // VTOOLSINGLEPOINT_H

View File

@ -225,48 +225,6 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolSpline::AddToFile()
{
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
doc->SetAttribute(domElement, AttrAngle1, spl->GetAngle1());
doc->SetAttribute(domElement, AttrAngle2, spl->GetAngle2());
doc->SetAttribute(domElement, AttrKAsm1, spl->GetKasm1());
doc->SetAttribute(domElement, AttrKAsm2, spl->GetKasm2());
doc->SetAttribute(domElement, AttrKCurve, spl->GetKcurve());
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolSpline::RefreshDataInFile()
{
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
doc->SetAttribute(domElement, AttrAngle1, spl->GetAngle1());
doc->SetAttribute(domElement, AttrAngle2, spl->GetAngle2());
doc->SetAttribute(domElement, AttrKAsm1, spl->GetKasm1());
doc->SetAttribute(domElement, AttrKAsm2, spl->GetKasm2());
doc->SetAttribute(domElement, AttrKCurve, spl->GetKcurve());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -313,6 +271,23 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VSpline> spl = qSharedPointerDynamicCast<VSpline>(obj);
SCASSERT(spl.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrPoint1, spl->GetP1().id());
doc->SetAttribute(tag, AttrPoint4, spl->GetP4().id());
doc->SetAttribute(tag, AttrAngle1, spl->GetAngle1());
doc->SetAttribute(tag, AttrAngle2, spl->GetAngle2());
doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1());
doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2());
doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -55,10 +55,9 @@ public slots:
const QPointF &pos);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile ();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
void RefreshGeometry ();
};

View File

@ -104,7 +104,7 @@ void VToolSplinePath::setDialog()
* @param doc dom document container.
* @param data container with variables.
*/
void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogSplinePath *dialogTool = qobject_cast<DialogSplinePath*>(dialog);
@ -114,7 +114,13 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat
{
doc->IncrementReferens((*path)[i].P().id());
}
Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
VToolSplinePath* spl = nullptr;
spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
if (spl != nullptr)
{
spl->dialog=dialogTool;
}
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
@ -128,7 +134,7 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
quint32 id = _id;
@ -155,7 +161,9 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable);
doc->AddTool(id, spl);
return spl;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
@ -266,27 +274,6 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogSplinePath>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolSplinePath::AddToFile()
{
VSplinePath splPath = *VAbstractTool::data.GeometricObject<VSplinePath>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve());
for (qint32 i = 0; i < splPath.CountPoint(); ++i)
{
AddPathPoint(domElement, splPath.at(i));
}
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
@ -352,6 +339,22 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement)
UpdatePathPoint(doc, domElement, splPath);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VSplinePath> splPath = qSharedPointerDynamicCast<VSplinePath>(obj);
SCASSERT(splPath.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrKCurve, splPath->getKCurve());
for (qint32 i = 0; i < splPath->CountPoint(); ++i)
{
AddPathPoint(tag, splPath->at(i));
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -41,9 +41,9 @@ public:
VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path);
virtual int type() const {return Type;}
@ -69,10 +69,10 @@ public slots:
const QPointF &pos);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
void RefreshGeometry();
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);

View File

@ -263,49 +263,6 @@ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogTriangle>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolTriangle::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrAxisP1, axisP1Id);
doc->SetAttribute(domElement, AttrAxisP2, axisP2Id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolTriangle::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrAxisP1, axisP1Id);
doc->SetAttribute(domElement, AttrAxisP2, axisP2Id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -321,3 +278,21 @@ void VToolTriangle::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrAxisP1, axisP1Id);
doc->SetAttribute(tag, AttrAxisP2, axisP2Id);
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}

View File

@ -59,9 +59,8 @@ public slots:
protected:
virtual void RemoveReferens();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolTriangle)
/** @brief axisP1Id id first axis point. */

View File

@ -130,3 +130,9 @@ void VAbstractNode::RestoreReferens()
doc->IncrementReferens(idNode);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
}

View File

@ -56,6 +56,7 @@ protected:
virtual void decrementReferens();
virtual void RemoveReferens();
virtual void RestoreReferens();
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
};
#endif // VABSTRACTNODE_H

View File

@ -124,6 +124,12 @@ void VNodeArc::RestoreNode()
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeArc::getTagName() const
{
return VNodeArc::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -144,7 +150,7 @@ void VNodeArc::AddToFile()
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
@ -162,7 +168,7 @@ void VNodeArc::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}

View File

@ -51,6 +51,7 @@ public:
virtual void RestoreNode();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeArc)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile();
protected:

View File

@ -136,6 +136,12 @@ void VNodePoint::RestoreNode()
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodePoint::getTagName() const
{
return VNodePoint::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -159,7 +165,7 @@ void VNodePoint::AddToFile()
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
@ -180,7 +186,7 @@ void VNodePoint::RefreshDataInFile()
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}

View File

@ -57,6 +57,7 @@ public:
virtual void RestoreNode();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile();
void NameChangePosition(const QPointF &pos);

View File

@ -127,6 +127,12 @@ void VNodeSpline::RestoreNode()
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSpline::getTagName() const
{
return VNodeSpline::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -147,7 +153,7 @@ void VNodeSpline::AddToFile()
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
@ -165,7 +171,7 @@ void VNodeSpline::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode));
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}

View File

@ -51,6 +51,7 @@ public:
virtual void RestoreNode();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeSpline)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile ();
protected:

View File

@ -130,6 +130,12 @@ void VNodeSplinePath::RestoreNode()
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSplinePath::getTagName() const
{
return VNodeSplinePath::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.

View File

@ -50,6 +50,7 @@ public:
virtual void RestoreNode();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::SplinePath)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile();
protected:

View File

@ -32,6 +32,7 @@
#include "../undocommands/deltool.h"
#include "../widgets/vapplication.h"
#include "../geometry/vpointf.h"
#include "../undocommands/savetooloptions.h"
const QString VAbstractTool::AttrType = QStringLiteral("type");
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
@ -289,11 +290,23 @@ Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine)
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractTool::getLineType() const
{
return typeLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::setTypeLine(const QString &value)
{
typeLine = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, quint32> VAbstractTool::PointsList() const
{
const QHash<quint32, QSharedPointer<VGObject> > *objs = data.DataGObjects();
@ -314,7 +327,6 @@ QMap<QString, quint32> VAbstractTool::PointsList() const
return list;
}
//---------------------------------------------------------------------------------------------------------------------
int VAbstractTool::ConfirmDeletion()
{
@ -327,6 +339,26 @@ int VAbstractTool::ConfirmDeletion()
return msgBox.exec();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::SaveOption(QSharedPointer<VGObject> &obj)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveOptions(newDomElement, obj);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0.

View File

@ -102,8 +102,10 @@ public:
const VContainer *getData() const;
QString getLineType() const;
//void setTypeLine(const QString &value)=0;
void setTypeLine(const QString &value);
QMap<QString, quint32> PointsList() const;
virtual QString getTagName() const =0;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
@ -139,6 +141,7 @@ protected:
/** @brief typeLine line type. */
QString typeLine;
/**
* @brief AddToFile add tag with informations about tool into file.
*/
@ -153,6 +156,8 @@ protected:
virtual void RemoveReferens(){}
virtual void DeleteTool(bool ask = true);
static int ConfirmDeletion();
void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)=0;
private:
Q_DISABLE_COPY(VAbstractTool)
};

View File

@ -370,6 +370,12 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
QGraphicsItem::keyReleaseEvent ( event );
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
@ -475,6 +481,12 @@ void VToolDetail::AddNode(VPattern *doc, QDomElement &domElement, const VNodeDet
domElement.appendChild(nod);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolDetail::getTagName() const
{
return VToolDetail::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -84,6 +84,7 @@ public:
static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Detail)};
virtual QString getTagName() const;
public slots:
virtual void FullUpdateFromFile ();
virtual void FullUpdateFromGuiOk(int result);
@ -95,6 +96,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void RemoveReferens();
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolDetail)
/** @brief dialog dialog options. */

View File

@ -435,6 +435,12 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q
point->setY(line.p2().y());
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolUnionDetails::getTagName() const
{
return VToolUnionDetails::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
@ -442,7 +448,8 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q
* @param doc dom document container.
* @param data container with variables.
*/
void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogUnionDetails *dialogTool = qobject_cast<DialogUnionDetails*>(dialog);
@ -452,9 +459,11 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP
quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1());
quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2());
qApp->getUndoStack()->beginMacro("union details");
Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse,
Source::FromGui);
VToolUnionDetails* tool = nullptr;
tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data,
Document::FullParse, Source::FromGui);
qApp->getUndoStack()->endMacro();
return tool;
}
//---------------------------------------------------------------------------------------------------------------------
@ -473,10 +482,10 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id,
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2,
const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1,
const quint32 &indexD2, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
VToolUnionDetails *unionDetails = 0;
quint32 id = _id;
@ -609,6 +618,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
}
} while (i<d1.RemoveEdge(indexD1).CountNode());
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
@ -740,6 +750,12 @@ void VToolUnionDetails::RefreshDataInFile()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolUnionDetails::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddDetail add detail to xml file.

View File

@ -50,11 +50,11 @@ public:
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog() {}
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id,
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolUnionDetails *Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id,
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data);
static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j);
static QVector<VDetail> GetDetailFromFile(VPattern *doc, const QDomElement &domElement);
@ -76,6 +76,7 @@ public:
const qreal &angle = 0);
static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
const qreal &angle);
virtual QString getTagName() const;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
@ -84,6 +85,7 @@ public slots:
protected:
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolUnionDetails)
/** @brief d1 first detail. */

View File

@ -157,7 +157,7 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event)
* @param parent parent object.
*/
VMainGraphicsView::VMainGraphicsView(QWidget *parent)
:QGraphicsView(parent), zoom(nullptr)
:QGraphicsView(parent), zoom(nullptr), showToolOptions(true)
{
zoom = new GraphicsViewZoom(this);
this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
@ -221,7 +221,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
break;
case Qt::NoModifier:
emit itemClicked(itemAt(mousePress->pos()));
if (showToolOptions)
{
emit itemClicked(itemAt(mousePress->pos()));
}
break;
default:
break;
@ -244,3 +247,10 @@ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
emit MouseRelease();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::setShowToolOptions(bool value)
{
showToolOptions = value;
}

View File

@ -97,6 +97,8 @@ class VMainGraphicsView : public QGraphicsView
public:
explicit VMainGraphicsView(QWidget *parent = nullptr);
void setShowToolOptions(bool value);
signals:
/**
* @brief NewFactor send new scale factor.
@ -120,6 +122,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
private:
GraphicsViewZoom* zoom;
bool showToolOptions;
};
#endif // VMAINGRAPHICSVIEW_H

View File

@ -390,7 +390,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolAlongLine(VProperty *property)
SetPointName<VToolEndLine>(value.toString());
break;
case 6: // VAbstractTool::AttrFirstPoint
i->setFirstPointId(value.toUInt());
i->setBasePointId(value.toUInt());
break;
case 7: // VAbstractTool::AttrSecondPoint
i->setSecondPointId(value.toUInt());