Move documantation to cpp file.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-13 20:02:41 +03:00
parent 7fed35ad1c
commit a755089a99
90 changed files with 2802 additions and 2892 deletions

View File

@ -34,6 +34,10 @@
#include "widgets/vapplication.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief TableWindow constructor.
* @param parent parent widget.
*/
TableWindow::TableWindow(QWidget *parent)
:QMainWindow(parent), numberDetal(nullptr), colission(nullptr), ui(new Ui::TableWindow),
listDetails(QVector<VItem*>()), outItems(false), collidingItems(false), tableScene(nullptr),
@ -76,6 +80,9 @@ TableWindow::~TableWindow()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddPaper add to the scene paper and shadow.
*/
void TableWindow::AddPaper()
{
qreal x1, y1, x2, y2;
@ -91,6 +98,9 @@ void TableWindow::AddPaper()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddDetail show on scene next detail.
*/
void TableWindow::AddDetail()
{
if (indexDetail<listDetails.count())
@ -120,6 +130,11 @@ void TableWindow::AddDetail()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ModelChosen show window when user want create new layout.
* @param listDetails list of details.
* @param description pattern description.
*/
/*
* Get details for creation layout.
*/
@ -148,6 +163,10 @@ void TableWindow::ModelChosen(QVector<VItem*> listDetails, const QString &fileNa
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief closeEvent handle after close window.
* @param event close event.
*/
void TableWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
@ -155,6 +174,9 @@ void TableWindow::closeEvent(QCloseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief moveToCenter move screen to the center of window.
*/
void TableWindow::moveToCenter()
{
QRect rect = frameGeometry();
@ -163,6 +185,10 @@ void TableWindow::moveToCenter()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief showEvent handle after show window.
* @param event show event.
*/
void TableWindow::showEvent ( QShowEvent * event )
{
QMainWindow::showEvent(event);
@ -170,6 +196,9 @@ void TableWindow::showEvent ( QShowEvent * event )
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief StopTable stop creation layout.
*/
void TableWindow::StopTable()
{
hide();
@ -182,6 +211,9 @@ void TableWindow::StopTable()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief saveScene save created layout.
*/
void TableWindow::saveScene()
{
QMap<QString, QString> extByMessage;
@ -261,6 +293,10 @@ void TableWindow::saveScene()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChect turn off rotation button if don't selected detail.
* @param flag true - enable button.
*/
void TableWindow::itemChect(bool flag)
{
ui->actionTurn->setDisabled(flag);
@ -268,6 +304,9 @@ void TableWindow::itemChect(bool flag)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief checkNext disable next detail button if exist colission or out details.
*/
void TableWindow::checkNext()
{
if (outItems == true && collidingItems == true)
@ -293,6 +332,11 @@ void TableWindow::checkNext()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemOut handled if detail moved out paper sheet.
* @param number Number detail in list.
* @param flag set state of detail. True if detail moved out paper sheet.
*/
void TableWindow::itemOut(int number, bool flag)
{
listOutItems->setBit(number, flag);
@ -311,6 +355,11 @@ void TableWindow::itemOut(int number, bool flag)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemColliding handled if we have colission details.
* @param list list of colission details.
* @param number 0 - include to list of colission dcetails, 1 - exclude from list.
*/
void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
{
//qDebug()<<"number="<<number;
@ -378,12 +427,18 @@ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetNextDetail put next detail on table.
*/
void TableWindow::GetNextDetail()
{
AddDetail();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddLength Add length paper sheet.Збільшує довжину листа на певне значення за один раз.
*/
void TableWindow::AddLength()
{
QRectF rect = tableScene->sceneRect();
@ -400,6 +455,9 @@ void TableWindow::AddLength()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveLength reduce the length of paper sheet. You can reduce to the minimal value only.
*/
void TableWindow::RemoveLength()
{
if (sceneRect.height() <= tableScene->sceneRect().height() - 100)
@ -426,6 +484,10 @@ void TableWindow::RemoveLength()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyPressEvent handle key press events.
* @param event key event.
*/
void TableWindow::keyPressEvent ( QKeyEvent * event )
{
if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return )
@ -440,6 +502,10 @@ void TableWindow::keyPressEvent ( QKeyEvent * event )
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SvgFile save layout to svg file.
* @param name name layout file.
*/
void TableWindow::SvgFile(const QString &name) const
{
QSvgGenerator generator;
@ -460,6 +526,10 @@ void TableWindow::SvgFile(const QString &name) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PngFile save layout to png file.
* @param name name layout file.
*/
void TableWindow::PngFile(const QString &name) const
{
QRectF r = paper->rect();
@ -478,6 +548,10 @@ void TableWindow::PngFile(const QString &name) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PdfFile save layout to pdf file.
* @param name name layout file.
*/
void TableWindow::PdfFile(const QString &name) const
{
QPrinter printer;
@ -503,6 +577,10 @@ void TableWindow::PdfFile(const QString &name) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief EpsFile save layout to eps file.
* @param name name layout file.
*/
void TableWindow::EpsFile(const QString &name) const
{
QTemporaryFile tmp;
@ -515,6 +593,10 @@ void TableWindow::EpsFile(const QString &name) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PsFile save layout to ps file.
* @param name name layout file.
*/
void TableWindow::PsFile(const QString &name) const
{
QTemporaryFile tmp;
@ -527,6 +609,11 @@ void TableWindow::PsFile(const QString &name) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void TableWindow::PdfToPs(const QStringList &params) const
{
#ifndef QT_NO_CURSOR

View File

@ -45,63 +45,32 @@ class TableWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* @brief numberDetal show count details, what need placed.
*/
/** @brief numberDetal show count details, what need placed. */
QLabel* numberDetal;
/**
* @brief colission show if exist colissions.
*/
/** @brief colission show if exist colissions. */
QLabel* colission;
/**
* @brief TableWindow constructor.
* @param parent parent widget.
*/
explicit TableWindow(QWidget *parent = nullptr);
explicit TableWindow(QWidget *parent = nullptr);
~TableWindow();
public slots:
/**
* @brief ModelChosen show window when user want create new layout.
* @param listDetails list of details.
* @param description pattern description.
*/
void ModelChosen(QVector<VItem*> listDetails, const QString &fileName, const QString &description);
/**
* @brief StopTable stop creation layout.
*/
void StopTable();
/**
* @brief saveScene save created layout.
*/
void saveScene();
/**
* @brief GetNextDetail put next detail on table.
*/
void GetNextDetail();
/**
* @brief itemChect turn off rotation button if don't selected detail.
* @param flag true - enable button.
*/
void itemChect(bool flag);
/**
* @brief itemOut handled if detail moved out paper sheet.
* @param number Number detail in list.
* @param flag set state of detail. True if detail moved out paper sheet.
*/
void itemOut(int number, bool flag);
/**
* @brief itemColliding handled if we have colission details.
* @param list list of colission details.
* @param number 0 - include to list of colission dcetails, 1 - exclude from list.
*/
void itemColliding(QList<QGraphicsItem *> list, int number);
/**
* @brief AddLength Add length paper sheet.Збільшує довжину листа на певне значення за один раз.
*/
void AddLength();
/**
* @brief RemoveLength reduce the length of paper sheet. You can reduce to the minimal value only.
*/
void RemoveLength();
signals:
/**
@ -113,122 +82,64 @@ signals:
*/
void LengthChanged();
protected:
/**
* @brief closeEvent handle after close window.
* @param event close event.
*/
void closeEvent(QCloseEvent *event);
/**
* @brief moveToCenter move screen to the center of window.
*/
void moveToCenter();
/**
* @brief showEvent handle after show window.
* @param event show event.
*/
void showEvent ( QShowEvent * event );
/**
* @brief keyPressEvent handle key press events.
* @param event key event.
*/
void keyPressEvent ( QKeyEvent * event );
private:
Q_DISABLE_COPY(TableWindow)
/**
* @brief ui keeps information about user interface Змінна для доступу до об'єктів вікна.
*/
/** @brief ui keeps information about user interface */
Ui::TableWindow* ui;
/**
* @brief listDetails list of details.
*/
/** @brief listDetails list of details. */
QVector<VItem*> listDetails;
/**
* @brief outItems true if we have details out paper sheet.
*/
/** @brief outItems true if we have details out paper sheet. */
bool outItems;
/**
* @brief collidingItems true if we have colission details.
*/
/** @brief collidingItems true if we have colission details. */
bool collidingItems;
/**
* @brief currentScene pointer to scene.
*/
/** @brief currentScene pointer to scene. */
QGraphicsScene* tableScene;
/**
* @brief paper paper sheet.
*/
/** @brief paper paper sheet. */
QGraphicsRectItem* paper;
/**
* @brief shadowPaper paper sheet shadow.
*/
/** @brief shadowPaper paper sheet shadow. */
QGraphicsRectItem* shadowPaper;
/**
* @brief checkNext disable next detail button if exist colission or out details.
*/
void checkNext();
/**
* @brief listOutItems list state out each detail.
*/
/** @brief listOutItems list state out each detail. */
QBitArray* listOutItems;
/**
* @brief listCollidingItems list colissed details.
*/
/** @brief listCollidingItems list colissed details. */
QList<QGraphicsItem*> listCollidingItems;
/**
* @brief AddPaper add to the scene paper and shadow.
*/
void AddPaper();
/**
* @brief AddDetail show on scene next detail.
*/
void AddDetail();
/**
* @brief indexDetail index next detail in list what will be shown.
*/
/** @brief indexDetail index next detail in list what will be shown. */
qint32 indexDetail;
/**
* @brief sceneRect minimal size of a paper.
*/
/** @brief sceneRect minimal size of a paper. */
QRectF sceneRect;
/**
* @brief fileName keep name of pattern file.
*/
/** @brief fileName keep name of pattern file. */
QString fileName;
/**
* @brief description pattern description
*/
/** @brief description pattern description */
QString description;
/**
* @brief SvgFile save layout to svg file.
* @param name name layout file.
*/
void SvgFile(const QString &name)const;
/**
* @brief PngFile save layout to png file.
* @param name name layout file.
*/
void PngFile(const QString &name)const;
/**
* @brief PdfFile save layout to pdf file.
* @param name name layout file.
*/
void PdfFile(const QString &name)const;
/**
* @brief EpsFile save layout to eps file.
* @param name name layout file.
*/
void EpsFile(const QString &name)const;
/**
* @brief PsFile save layout to ps file.
* @param name name layout file.
*/
void PsFile(const QString &name)const;
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void PdfToPs(const QStringList &params)const;
void checkNext();
void AddPaper();
void AddDetail();
void SvgFile(const QString &name)const;
void PngFile(const QString &name)const;
void PdfFile(const QString &name)const;
void EpsFile(const QString &name)const;
void PsFile(const QString &name)const;
void PdfToPs(const QStringList &params)const;
};
#endif // TABLEWINDOW_H

View File

@ -39,12 +39,19 @@ VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QG
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VAbstractSpline::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VAbstractSpline::ChangedActivDraw(const QString &newName)
{
bool selectable = false;
@ -66,12 +73,22 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VAbstractSpline::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VAbstractSpline::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -79,6 +96,10 @@ void VAbstractSpline::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
// cppcheck-suppress unusedFunction
void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
@ -87,6 +108,10 @@ void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
// cppcheck-suppress unusedFunction
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
@ -95,6 +120,12 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange hadle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
@ -114,6 +145,10 @@ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, c
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())

View File

@ -40,9 +40,6 @@ public:
VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
static const QString TagName;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile ();
signals:
/**
@ -68,44 +65,12 @@ protected:
* @brief RefreshGeometry refresh item on scene.
*/
virtual void RefreshGeometry ()=0;
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw ( const QString &newName );
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief itemChange hadle item change.
* @param change change.
* @param value value.
* @return value.
*/
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
virtual void keyReleaseEvent(QKeyEvent * event);
};

View File

@ -147,6 +147,9 @@ void VDrawTool::SaveDialogChange()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DialogLinkDestroy removes dialog pointer
*/
void VDrawTool::DialogLinkDestroy()
{
this->dialog=nullptr;

View File

@ -50,11 +50,7 @@ public:
/** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {}
/**
* @brief DialogLinkDestroy removes dialog pointer
*/
virtual void DialogLinkDestroy();
void ignoreContextMenu(bool enable);
static qreal CheckFormula(QString &formula, VContainer *data);
public slots:

View File

@ -35,6 +35,18 @@
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolAlongLine constuctor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with length formula.
* @param firstPointId id first point of line.
* @param secondPointId id second point of line.
* @param typeLine line type. line type.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId,
const QString &typeLine, const Source &typeCreation,
@ -53,6 +65,9 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -67,6 +82,10 @@ void VToolAlongLine::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolAlongLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -74,6 +93,10 @@ void VToolAlongLine::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events. handle context menu event.
* @param event context menu event.
*/
//cppcheck-suppress unusedFunction
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
@ -81,12 +104,19 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu handle context menu event.
* @param event context menu event.
*/
void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogAlongLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolAlongLine::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -107,6 +137,9 @@ void VToolAlongLine::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolAlongLine::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -124,6 +157,9 @@ void VToolAlongLine::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolAlongLine::RemoveReferens()
{
doc->DecrementReferens(secondPointId);
@ -131,6 +167,9 @@ void VToolAlongLine::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolAlongLine::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -144,6 +183,9 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolAlongLine::setDialog()
{
SCASSERT(dialog != nullptr);
@ -158,6 +200,13 @@ void VToolAlongLine::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool form GUI.
* @param dialog dialog options.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -179,10 +228,26 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s
}
//---------------------------------------------------------------------------------------------------------------------
VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name. point name.
* @param typeLine line type.
* @param formula string with length formula.
* @param firstPointId id first point of line.
* @param secondPointId id second point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);

View File

@ -38,95 +38,29 @@ class VToolAlongLine : public VToolLinePoint
{
Q_OBJECT
public:
/**
* @brief VToolAlongLine constuctor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with length formula.
* @param firstPointId id first point of line.
* @param secondPointId id second point of line.
* @param typeLine line type. line type.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool form GUI.
* @param dialog dialog options.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name. point name.
* @param typeLine line type.
* @param formula string with length formula.
* @param firstPointId id first point of line.
* @param secondPointId id second point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu handle context menu event.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events. handle context menu event.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief secondPointId id second point of line.
*/
/** @brief secondPointId id second point of line. */
quint32 secondPointId;
};

View File

@ -36,6 +36,14 @@ const QString VToolArc::TagName = QStringLiteral("arc");
const QString VToolArc::ToolType = QStringLiteral("simple");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolArc constuctor.
* @param doc dom document container
* @param data container with variables
* @param id object id in container
* @param typeCreation way we create this tool.
* @param parent parent object
*/
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent)
@ -61,6 +69,9 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &ty
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolArc::setDialog()
{
SCASSERT(dialog != nullptr);
@ -74,6 +85,13 @@ void VToolArc::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool
* @param dialog dialog options.
* @param scene pointer to scene.
* @param doc dom document container
* @param data container with variables
*/
VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -93,6 +111,19 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool form GUI.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param center id arc center point.
* @param radius arc radius.
* @param f1 start angle of arc.
* @param f2 end angle of arc.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
@ -134,12 +165,19 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolArc::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolArc::ChangedActivDraw(const QString &newName)
{
bool selectable = false;
@ -160,12 +198,22 @@ void VToolArc::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VToolArc::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolArc::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -173,12 +221,19 @@ void VToolArc::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolArc::AddToFile()
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
@ -195,6 +250,9 @@ void VToolArc::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolArc::RefreshDataInFile()
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
@ -209,6 +267,10 @@ void VToolArc::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -219,6 +281,10 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
//cppcheck-suppress unusedFunction
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
@ -227,6 +293,10 @@ void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
//cppcheck-suppress unusedFunction
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
@ -235,6 +305,9 @@ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolArc::RemoveReferens()
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
@ -242,6 +315,12 @@ void VToolArc::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle tool change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
@ -261,6 +340,10 @@ QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QV
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
void VToolArc::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
@ -275,6 +358,9 @@ void VToolArc::keyReleaseEvent(QKeyEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolArc::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -287,6 +373,9 @@ void VToolArc::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolArc::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));

View File

@ -40,121 +40,31 @@ class VToolArc :public VDrawTool, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VToolArc constuctor.
* @param doc dom document container
* @param data container with variables
* @param id object id in container
* @param typeCreation way we create this tool.
* @param parent parent object
*/
VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool
* @param dialog dialog options.
* @param scene pointer to scene.
* @param doc dom document container
* @param data container with variables
*/
static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool form GUI.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param center id arc center point.
* @param radius arc radius.
* @param f1 start angle of arc.
* @param f2 end angle of arc.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief itemChange handle tool change.
* @param change change.
* @param value value.
* @return value.
*/
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
virtual void keyReleaseEvent(QKeyEvent * event);
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
};

View File

@ -34,6 +34,19 @@
const QString VToolBisector::ToolType = QStringLiteral("bisector");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolBisector constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length of bisector.
* @param firstPointId id first point of angle.
* @param secondPointId id second point of angle.
* @param thirdPointId id third point of angle.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem *parent)
@ -53,6 +66,14 @@ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint find bisector point.
* @param firstPoint first point of angle.
* @param secondPoint second point of angle.
* @param thirdPoint third point of angle.
* @param length bisector length.
* @return bisector point.
*/
QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const QPointF &thirdPoint, const qreal &length)
{
@ -73,6 +94,9 @@ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secon
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolBisector::setDialog()
{
SCASSERT(dialog != nullptr);
@ -88,6 +112,13 @@ void VToolBisector::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
@ -111,6 +142,23 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula.
* @param firstPointId id first point of angle.
* @param secondPointId id second point of angle.
* @param thirdPointId id third point of angle.
* @param typeLine line type.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
@ -158,6 +206,9 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolBisector::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -173,6 +224,10 @@ void VToolBisector::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolBisector::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -180,18 +235,29 @@ void VToolBisector::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogBisector>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogBisector>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolBisector::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -213,6 +279,9 @@ void VToolBisector::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolBisector::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -231,6 +300,9 @@ void VToolBisector::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolBisector::RemoveReferens()
{
doc->DecrementReferens(firstPointId);
@ -239,6 +311,9 @@ void VToolBisector::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolBisector::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -37,113 +37,35 @@
class VToolBisector : public VToolLinePoint
{
public:
/**
* @brief VToolBisector constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length of bisector.
* @param firstPointId id first point of angle.
* @param secondPointId id second point of angle.
* @param thirdPointId id third point of angle.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const quint32 &thirdPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief FindPoint find bisector point.
* @param firstPoint first point of angle.
* @param secondPoint second point of angle.
* @param thirdPoint third point of angle.
* @param length bisector length.
* @return bisector point.
*/
VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint,
const qreal& length);
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula.
* @param firstPointId id first point of angle.
* @param secondPointId id second point of angle.
* @param thirdPointId id third point of angle.
* @param typeLine line type.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RefreshDataInFile();
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief firstPointId id first point of angle.
*/
/** @brief firstPointId id first point of angle. */
quint32 firstPointId;
/**
* @brief thirdPointId id third point of angle.
*/
/** @brief thirdPointId id third point of angle. */
quint32 thirdPointId;
};

View File

@ -36,6 +36,18 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
const QString VToolCutArc::AttrArc = QStringLiteral("arc");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolCutArc constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first arc.
* @param arcId id arc in data container.
* @param arc1id id first cutting arc.
* @param arc2id id second cutting arc.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id,
const Source &typeCreation, QGraphicsItem * parent)
@ -67,6 +79,9 @@ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, con
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolCutArc::setDialog()
{
SCASSERT(dialog != nullptr);
@ -79,8 +94,14 @@ void VToolCutArc::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
@ -98,9 +119,23 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first arc.
* @param arcId id arc in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
@ -163,6 +198,9 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolCutArc::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -175,12 +213,20 @@ void VToolCutArc::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ArcChoosed send signal about selection from cutted arc.
* @param id object id in container.
*/
void VToolCutArc::ArcChoosed(quint32 id)
{
emit ChoosedTool(id, SceneObject::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolCutArc::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
@ -205,18 +251,29 @@ void VToolCutArc::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutArc::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -235,6 +292,9 @@ void VToolCutArc::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutArc::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -250,6 +310,9 @@ void VToolCutArc::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolCutArc::RefreshGeometry()
{
RefreshArc(firstArc, arc1id, SimpleArcPoint::ForthPoint);
@ -258,6 +321,9 @@ void VToolCutArc::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolCutArc::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -269,6 +335,12 @@ void VToolCutArc::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshArc refresh arc on scene.
* @param sArc arc.
* @param arcid arc id.
* @param tr arc type.
*/
void VToolCutArc::RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArcPoint tr)
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(arcid);

View File

@ -39,126 +39,47 @@ class VToolCutArc : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolCutArc constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first arc.
* @param arcId id arc in data container.
* @param arc1id id first cutting arc.
* @param arc2id id second cutting arc.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId,
const quint32 &arc1id, const quint32 &arc2id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first arc.
* @param arcId id arc in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
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 AttrArc;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ArcChoosed send signal about selection from cutted arc.
* @param id object id in container.
*/
void ArcChoosed(quint32 id);
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutArc)
/**
* @brief formula keep formula of length
*/
/** @brief formula keep formula of length */
QString formula;
/**
* @brief arcId keep id of arc
*/
/** @brief arcId keep id of arc */
quint32 arcId;
/**
* @brief firstArc first arc after cutting.
*/
/** @brief firstArc first arc after cutting. */
VSimpleArc *firstArc;
/**
* @brief secondArc second arc after cutting.
*/
/** @brief secondArc second arc after cutting. */
VSimpleArc *secondArc;
/**
* @brief arc1id id first arc after cutting.
*/
/** @brief arc1id id first arc after cutting. */
const quint32 arc1id;
/**
* @brief arc2id id second arc after cutting.
*/
/** @brief arc2id id second arc after cutting. */
const quint32 arc2id;
/**
* @brief RefreshArc refresh arc on scene.
* @param sArc arc.
* @param arcid arc id.
* @param tr arc type.
*/
void RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArcPoint tr);
};

View File

@ -37,6 +37,16 @@ const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline");
const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolCutSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first spline.
* @param splineId id spline in data container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id,
const Source &typeCreation, QGraphicsItem *parent)
@ -68,6 +78,9 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolCutSpline::setDialog()
{
SCASSERT(dialog != nullptr);
@ -80,6 +93,13 @@ void VToolCutSpline::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
{
@ -93,6 +113,20 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first spline.
* @param splineId id spline in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @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)
@ -156,6 +190,9 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolCutSpline::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -168,12 +205,20 @@ void VToolCutSpline::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SplineChoosed send signal about selection from spline.
* @param id object id in container.
*/
void VToolCutSpline::SplineChoosed(quint32 id)
{
emit ChoosedTool(id, SceneObject::Spline);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolCutSpline::ChangedActivDraw(const QString &newName)
{
bool flag = true;
@ -193,18 +238,29 @@ void VToolCutSpline::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSpline::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -223,6 +279,9 @@ void VToolCutSpline::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSpline::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -238,6 +297,9 @@ void VToolCutSpline::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolCutSpline::RefreshGeometry()
{
RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint);
@ -246,12 +308,18 @@ void VToolCutSpline::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement referens value for used objects.
*/
void VToolCutSpline::RemoveReferens()
{
doc->DecrementReferens(splineId);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolCutSpline::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -263,6 +331,12 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshSpline refresh spline on scene.
* @param spline spline.
* @param splid spline id.
* @param tr spline type.
*/
void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr)
{
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(splid);

View File

@ -39,128 +39,50 @@ class VToolCutSpline : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolCutSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first spline.
* @param splineId id spline in data container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first spline.
* @param splineId id spline in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
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 const QString ToolType;
static const QString AttrSpline;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SplineChoosed send signal about selection from spline.
* @param id object id in container.
*/
void SplineChoosed(quint32 id);
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
/**
* @brief RemoveReferens decrement referens value for used objects.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutSpline)
/**
* @brief formula keep formula of length.
*/
/** @brief formula keep formula of length. */
QString formula;
/**
* @brief splineId keep id of spline.
*/
/** @brief splineId keep id of spline. */
quint32 splineId;
/**
* @brief firstSpline first spline after cutting.
*/
/** @brief firstSpline first spline after cutting. */
VSimpleSpline *firstSpline;
/**
* @brief secondSpline second spline after cutting.
*/
/** @brief secondSpline second spline after cutting. */
VSimpleSpline *secondSpline;
/**
* @brief spl1id id first spline after cutting.
*/
/** @brief spl1id id first spline after cutting. */
const quint32 spl1id;
/**
* @brief spl2id id second spline after cutting.
*/
/** @brief spl2id id second spline after cutting. */
const quint32 spl2id;
/**
* @brief RefreshSpline refresh spline on scene.
* @param spline spline.
* @param splid spline id.
* @param tr spline type.
*/
void RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr);
};

View File

@ -37,6 +37,18 @@ const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolCutSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first splinePath.
* @param splinePathId id splinePath (we cut this splinePath) in data container.
* @param splPath1id id first splinePath after cutting.
* @param splPath2id id second splinePath after cutting.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id,
const QString &formula, const quint32 &splinePathId,
const quint32 &splPath1id, const quint32 &splPath2id,
@ -69,6 +81,9 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolCutSplinePath::setDialog()
{
SCASSERT(dialog != nullptr);
@ -81,6 +96,13 @@ void VToolCutSplinePath::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -93,10 +115,24 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first splinePath.
* @param splinePathId id of splinePath in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @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)
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
SCASSERT(splPath != nullptr);
@ -231,6 +267,9 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolCutSplinePath::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -243,12 +282,20 @@ void VToolCutSplinePath::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SplineChoosed send signal about selection splinePath.
* @param id object id in container.
*/
void VToolCutSplinePath::SplineChoosed(quint32 id)
{
emit ChoosedTool(id, SceneObject::SplinePath);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolCutSplinePath::ChangedActivDraw(const QString &newName)
{
bool flag = true;
@ -268,18 +315,29 @@ void VToolCutSplinePath::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutSplinePath>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogCutSplinePath>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSplinePath::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -298,6 +356,9 @@ void VToolCutSplinePath::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSplinePath::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -313,6 +374,9 @@ void VToolCutSplinePath::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolCutSplinePath::RefreshGeometry()
{
RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint);
@ -321,12 +385,18 @@ void VToolCutSplinePath::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement referens value for used objects.
*/
void VToolCutSplinePath::RemoveReferens()
{
doc->DecrementReferens(splinePathId);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -338,6 +408,12 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshSpline refresh splinePath on scene.
* @param spline splinePath.
* @param splPathid splinePath id.
* @param tr splineType type.
*/
void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr)
{
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(splPathid);

View File

@ -40,130 +40,50 @@ class VToolCutSplinePath : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolCutSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param formula string with formula length first splinePath.
* @param splinePathId id splinePath (we cut this splinePath) in data container.
* @param splPath1id id first splinePath after cutting.
* @param splPath2id id second splinePath after cutting.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param formula string with formula length first splinePath.
* @param splinePathId id of splinePath in data container.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
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 const QString ToolType;
static const QString AttrSplinePath;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SplineChoosed send signal about selection splinePath.
* @param id object id in container.
*/
void SplineChoosed(quint32 id);
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
/**
* @brief RemoveReferens decrement referens value for used objects.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutSplinePath)
/**
* @brief formula keep formula of length
*/
/** @brief formula keep formula of length */
QString formula;
/**
* @brief splineId keep id of spline.
*/
/** @brief splineId keep id of spline. */
quint32 splinePathId;
/**
* @brief firstSpline first splinePath after cutting.
*/
/** @brief firstSpline first splinePath after cutting. */
VSimpleSpline *firstSpline;
/**
* @brief secondSpline second splinePath after cutting.
*/
/** @brief secondSpline second splinePath after cutting. */
VSimpleSpline *secondSpline;
/**
* @brief splPath1id id first splinePath after cutting.
*/
/** @brief splPath1id id first splinePath after cutting. */
const quint32 splPath1id;
/**
* @brief splPath2id id second splinePath after cutting.
*/
/** @brief splPath2id id second splinePath after cutting. */
const quint32 splPath2id;
/**
* @brief RefreshSpline refresh splinePath on scene.
* @param spline splinePath.
* @param splPathid splinePath id.
* @param tr splineType type.
*/
void RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr);
};

View File

@ -36,6 +36,18 @@
const QString VToolEndLine::ToolType = QStringLiteral("endLine");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolEndLine constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param basePointId id first point of line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem *parent)
@ -53,6 +65,9 @@ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolEndLine::setDialog()
{
SCASSERT(dialog != nullptr);
@ -67,6 +82,14 @@ void VToolEndLine::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @return the created tool
*/
VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -89,6 +112,23 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param basePointId id first point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @return the created tool
*/
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const qreal &angle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
@ -130,6 +170,9 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolEndLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -144,18 +187,29 @@ void VToolEndLine::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogEndLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogEndLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolEndLine::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -176,6 +230,9 @@ void VToolEndLine::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolEndLine::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -193,6 +250,9 @@ void VToolEndLine::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolEndLine::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,83 +38,24 @@ class VToolEndLine : public VToolLinePoint
{
Q_OBJECT
public:
/**
* @brief VToolEndLine constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param basePointId id first point of line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const qreal &angle, const quint32 &basePointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @return the created tool
*/
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param typeLine line type.
* @param formula string with formula length of line.
* @param angle angle of line.
* @param basePointId id first point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @return the created tool
*/
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
};

View File

@ -33,6 +33,18 @@
const QString VToolHeight::ToolType = QStringLiteral("height");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolHeight constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param basePointId id base point of projection.
* @param p1LineId id first point of line.
* @param p2LineId id second point of line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
const Source &typeCreation, QGraphicsItem * parent)
@ -50,6 +62,9 @@ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, con
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolHeight::setDialog()
{
SCASSERT(dialog != nullptr);
@ -64,6 +79,13 @@ void VToolHeight::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
@ -81,6 +103,22 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param typeLine line type.
* @param basePointId id base point of projection.
* @param p1LineId id first point of line.
* @param p2LineId id second point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
@ -126,12 +164,21 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint find projection base point onto line.
* @param line line
* @param point base point.
* @return point onto line.
*/
QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point)
{
return VAbstractTool::ClosestPoint(line, point);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolHeight::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -147,18 +194,29 @@ void VToolHeight::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogHeight>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogHeight>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolHeight::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -180,6 +238,9 @@ void VToolHeight::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolHeight::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -197,6 +258,9 @@ void VToolHeight::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolHeight::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,97 +38,31 @@ class VToolHeight: public VToolLinePoint
{
Q_OBJECT
public:
/**
* @brief VToolHeight constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param basePointId id base point of projection.
* @param p1LineId id first point of line.
* @param p2LineId id second point of line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId,
const quint32 &p1LineId, const quint32 &p2LineId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param typeLine line type.
* @param basePointId id base point of projection.
* @param p1LineId id first point of line.
* @param p2LineId id second point of line.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
/**
* @brief FindPoint find projection base point onto line.
* @param line line
* @param point base point.
* @return point onto line.
*/
static QPointF FindPoint(const QLineF &line, const QPointF &point);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief p1LineId id first point of line.
*/
/** @brief p1LineId id first point of line. */
quint32 p1LineId;
/**
* @brief p2LineId id second point of line.
*/
/** @brief p2LineId id second point of line. */
quint32 p2LineId;
};

View File

@ -35,6 +35,17 @@
const QString VToolLine::TagName = QStringLiteral("line");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolLine constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
* @param typeLine line type.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
const QString &typeLine, const Source &typeCreation, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint)
@ -62,6 +73,9 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolLine::setDialog()
{
SCASSERT(dialog != nullptr);
@ -73,6 +87,13 @@ void VToolLine::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -85,6 +106,18 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
* @param typeLine line type.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
@ -121,18 +154,31 @@ void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quin
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolLine::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VToolLine::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -140,6 +186,10 @@ void VToolLine::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolLine::ChangedActivDraw(const QString &newName)
{
bool selectable = false;
@ -159,12 +209,19 @@ void VToolLine::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
@ -177,6 +234,9 @@ void VToolLine::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolLine::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -189,6 +249,10 @@ void VToolLine::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -196,6 +260,10 @@ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -203,6 +271,9 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolLine::RemoveReferens()
{
doc->DecrementReferens(firstPoint);
@ -210,6 +281,12 @@ void VToolLine::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
@ -229,6 +306,10 @@ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const Q
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyReleaseEvent handle key realse events.
* @param event key realse event.
*/
void VToolLine::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
@ -243,6 +324,9 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolLine::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -254,6 +338,9 @@ void VToolLine::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolLine::RefreshGeometry()
{
QDomElement domElement = doc->elementById(QString().setNum(id));

View File

@ -39,126 +39,36 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem
{
Q_OBJECT
public:
/**
* @brief VToolLine constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
* @param typeLine line type.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint,
quint32 secondPoint, const QString &typeLine, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool form GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
* @param typeLine line type.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString TagName;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief keyReleaseEvent handle key realse events.
* @param event key realse event.
*/
virtual void keyReleaseEvent(QKeyEvent * event);
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief firstPoint id first line point.
*/
/** @brief firstPoint id first line point. */
quint32 firstPoint;
/**
* @brief secondPoint id second line point.
*/
/** @brief secondPoint id second line point. */
quint32 secondPoint;
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
};

View File

@ -33,6 +33,18 @@
const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolLineIntersect constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param p1Line1 id first point first line.
* @param p2Line1 id second point first line.
* @param p1Line2 id first point second line.
* @param p2Line2 id second point second line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id,
const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2,
const quint32 &p2Line2, const Source &typeCreation,
@ -52,6 +64,9 @@ VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const qu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolLineIntersect::setDialog()
{
SCASSERT(dialog != nullptr);
@ -66,6 +81,13 @@ void VToolLineIntersect::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -81,6 +103,22 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param p1Line1Id id first point first line.
* @param p2Line1Id id second point first line.
* @param p1Line2Id id first point second line.
* @param p2Line2Id id second point second line.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
@ -137,6 +175,9 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolLineIntersect::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -151,6 +192,10 @@ void VToolLineIntersect::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLineIntersect::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -158,18 +203,29 @@ void VToolLineIntersect::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogLineIntersect>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogLineIntersect>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolLineIntersect::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -190,6 +246,9 @@ void VToolLineIntersect::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolLineIntersect::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -207,6 +266,9 @@ void VToolLineIntersect::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolLineIntersect::RemoveReferens()
{
doc->DecrementReferens(p1Line1);
@ -216,6 +278,9 @@ void VToolLineIntersect::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolLineIntersect::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,107 +38,37 @@ class VToolLineIntersect:public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolLineIntersect constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param p1Line1 id first point first line.
* @param p2Line1 id second point first line.
* @param p1Line2 id first point second line.
* @param p2Line2 id second point second line.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1,
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1,
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param p1Line1Id id first point first line.
* @param p2Line1Id id second point first line.
* @param p1Line2Id id first point second line.
* @param p2Line2Id id second point second line.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, const quint32 &p1Line2Id,
const quint32 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief p1Line1 id first point first line.
*/
/** @brief p1Line1 id first point first line. */
quint32 p1Line1;
/**
* @brief p2Line1 id second point first line.
*/
/** @brief p2Line1 id second point first line. */
quint32 p2Line1;
/**
* @brief p1Line2 id first point second line.
*/
/** @brief p1Line2 id first point second line. */
quint32 p1Line2;
/**
* @brief p2Line2 id second point second line.
*/
/** @brief p2Line2 id second point second line.*/
quint32 p2Line2;
};

View File

@ -30,6 +30,17 @@
#include "../../geometry/vpointf.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolLinePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with length formula.
* @param basePointId id base line point.
* @param angle line angle.
* @param parent parent object.
*/
VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id,
const QString &typeLine, const QString &formula, const quint32 &basePointId,
const qreal &angle, QGraphicsItem *parent)
@ -46,6 +57,10 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolLinePoint::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
@ -61,6 +76,9 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolLinePoint::RefreshGeometry()
{
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
@ -71,6 +89,19 @@ void VToolLinePoint::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolLinePoint::RemoveReferens()
{
doc->DecrementReferens(basePointId);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLinePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);

View File

@ -38,56 +38,26 @@ class VToolLinePoint : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolLinePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with length formula.
* @param basePointId id base line point.
* @param angle line angle.
* @param parent parent object.
*/
VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &basePointId, const qreal &angle,
QGraphicsItem * parent = nullptr);
VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
public slots:
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
protected:
/**
* @brief formula string with length formula.
*/
/** @brief formula string with length formula. */
QString formula;
/**
* @brief angle line angle.
*/
/** @brief angle line angle. */
qreal angle;
/**
* @brief basePointId id base line point.
*/
/** @brief basePointId id base line point. */
quint32 basePointId;
/**
* @brief mainLine line item.
*/
/** @brief mainLine line item. */
QGraphicsLineItem *mainLine;
/**
* @brief RefreshGeometry refresh item on scene.
*/
virtual void RefreshGeometry();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens() {doc->DecrementReferens(basePointId);}
virtual void RemoveReferens();
private:
Q_DISABLE_COPY(VToolLinePoint)
};

View File

@ -34,6 +34,19 @@
const QString VToolNormal::ToolType = QStringLiteral("normal");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolNormal constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula normal length.
* @param angle additional angle.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &firstPointId,
const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem *parent)
@ -52,6 +65,9 @@ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, con
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolNormal::setDialog()
{
SCASSERT(dialog != nullptr);
@ -67,6 +83,13 @@ void VToolNormal::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -89,6 +112,23 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula normal length.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeLine line type.
* @param pointName point name.
* @param angle additional angle.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
@ -134,6 +174,14 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint return normal point.
* @param firstPoint first line point.
* @param secondPoint second line point.
* @param length normal length.
* @param angle additional angle.
* @return normal point.
*/
QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
const qreal &angle)
{
@ -145,6 +193,9 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolNormal::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -160,6 +211,10 @@ void VToolNormal::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolNormal::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -167,18 +222,29 @@ void VToolNormal::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolNormal::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogNormal>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogNormal>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolNormal::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -200,6 +266,9 @@ void VToolNormal::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolNormal::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -218,6 +287,9 @@ void VToolNormal::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolNormal::RemoveReferens()
{
doc->DecrementReferens(secondPointId);
@ -225,6 +297,9 @@ void VToolNormal::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolNormal::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,110 +38,31 @@ class VToolNormal : public VToolLinePoint
{
Q_OBJECT
public:
/**
* @brief VToolNormal constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula normal length.
* @param angle additional angle.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &firstPointId,
const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula normal length.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeLine line type.
* @param pointName point name.
* @param angle additional angle.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
/**
* @brief FindPoint return normal point.
* @param firstPoint first line point.
* @param secondPoint second line point.
* @param length normal length.
* @param angle additional angle.
* @return normal point.
*/
static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
const qreal &angle = 0);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief secondPointId id second line point.
*/
quint32 secondPointId;
/** @brief secondPointId id second line point. */
quint32 secondPointId;
};
#endif // VTOOLNORMAL_H

View File

@ -36,6 +36,13 @@ const QString VToolPoint::TagName = QStringLiteral("point");
#define DefRadius 2.0//mm
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolPoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param parent parent object.
*/
VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsEllipseItem(parent), radius(DefRadius), namePoint(0), lineName(0)
{
@ -54,6 +61,10 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NameChangePosition handle change posion point label.
* @param pos new position.
*/
void VToolPoint::NameChangePosition(const QPointF &pos)
{
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
@ -66,6 +77,11 @@ void VToolPoint::NameChangePosition(const QPointF &pos)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdateNamePosition save new position label to the pattern file.
* @param mx label bias x axis.
* @param my label bias y axis.
*/
void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -78,6 +94,10 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolPoint::ChangedActivDraw(const QString &newName)
{
bool selectable = false;
@ -104,12 +124,22 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolPoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -117,12 +147,20 @@ void VToolPoint::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
Q_UNUSED(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -133,6 +171,10 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -140,6 +182,10 @@ void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -147,6 +193,10 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point.
*/
void VToolPoint::RefreshPointGeometry(const VPointF &point)
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
@ -166,6 +216,9 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh line to label on scene.
*/
void VToolPoint::RefreshLine()
{
QRectF nameRec = namePoint->sceneBoundingRect();
@ -192,6 +245,12 @@ void VToolPoint::RefreshLine()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange hadle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
@ -211,6 +270,10 @@ QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
void VToolPoint::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())

View File

@ -41,98 +41,32 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
{
Q_OBJECT
public:
/**
* @brief VToolPoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param parent parent object.
*/
VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VToolPoint(){}
VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VToolPoint(){}
static const QString TagName;
public slots:
/**
* @brief NameChangePosition handle change posion point label.
* @param pos new position.
*/
void NameChangePosition(const QPointF &pos);
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ShowTool highlight tool.
* @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight.
*/
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief radius radius circle.
*/
/** @brief radius radius circle. */
qreal radius;
/**
* @brief namePoint point label.
*/
/** @brief namePoint point label. */
VGraphicsSimpleTextItem *namePoint;
/**
* @brief lineName line what we see if label moved too away from point.
*/
/** @brief lineName line what we see if label moved too away from point. */
QGraphicsLineItem *lineName;
/**
* @brief UpdateNamePosition save new position label to the pattern file.
* @param mx label bias x axis.
* @param my label bias y axis.
*/
virtual void UpdateNamePosition(qreal mx, qreal my);
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point.
*/
virtual void RefreshPointGeometry(const VPointF &point);
/**
* @brief RefreshLine refresh line to label on scene.
*/
void RefreshLine();
/**
* @brief itemChange hadle item change.
* @param change change.
* @param value value.
* @return value.
*/
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
virtual void keyReleaseEvent(QKeyEvent * event);
private:
Q_DISABLE_COPY(VToolPoint)

View File

@ -34,6 +34,18 @@
const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolPointOfContact constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param arcRadius string with formula radius arc.
* @param center id center arc point.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id,
const QString &radius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId,
@ -52,6 +64,9 @@ VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolPointOfContact::setDialog()
{
SCASSERT(dialog != nullptr);
@ -66,6 +81,14 @@ void VToolPointOfContact::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint return point intersection line and arc.
* @param arcRadius string with formula radius arc.
* @param center center arc point.
* @param firstPoint first line point.
* @param secondPoint second line point.
* @return point intersection.
*/
QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint)
{
@ -93,7 +116,15 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &cente
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogPointOfContact *dialogTool = qobject_cast<DialogPointOfContact*>(dialog);
@ -114,10 +145,27 @@ VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphi
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 &center, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param arcRadius string with formula radius arc.
* @param center id center arc point.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const VPointF *centerP = data->GeometricObject<const VPointF *>(center);
const VPointF *firstP = data->GeometricObject<const VPointF *>(firstPointId);
@ -164,6 +212,9 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolPointOfContact::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -178,6 +229,10 @@ void VToolPointOfContact::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolPointOfContact::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -185,18 +240,29 @@ void VToolPointOfContact::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointOfContact>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointOfContact>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolPointOfContact::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -217,6 +283,9 @@ void VToolPointOfContact::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolPointOfContact::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -234,6 +303,9 @@ void VToolPointOfContact::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolPointOfContact::RemoveReferens()
{
doc->DecrementReferens(center);
@ -242,6 +314,9 @@ void VToolPointOfContact::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolPointOfContact::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -37,118 +37,40 @@
class VToolPointOfContact : public VToolPoint
{
public:
/**
* @brief VToolPointOfContact constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param arcRadius string with formula radius arc.
* @param center id center arc point.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id,
const QString &arcRadius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, const QString &arcRadius,
const quint32 &center, const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief FindPoint return point intersection line and arc.
* @param arcRadius string with formula radius arc.
* @param center center arc point.
* @param firstPoint first line point.
* @param secondPoint second line point.
* @return point intersection.
*/
static QPointF FindPoint(const qreal &arcRadius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint);
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param arcRadius string with formula radius arc.
* @param center id center arc point.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data);
static VToolPointOfContact* Create(const quint32 _id, QString &arcRadius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief radius string with formula radius arc.
*/
/** @brief radius string with formula radius arc. */
QString arcRadius;
/**
* @brief center id center arc point.
*/
/** @brief center id center arc point. */
quint32 center;
/**
* @brief firstPointId id first line point.
*/
/** @brief firstPointId id first line point. */
quint32 firstPointId;
/**
* @brief secondPointId id second line point.
*/
/** @brief secondPointId id second line point. */
quint32 secondPointId;
};

View File

@ -33,6 +33,16 @@
const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolPointOfIntersection constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id,
const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem *parent)
@ -50,6 +60,9 @@ VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *da
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolPointOfIntersection::setDialog()
{
SCASSERT(dialog != nullptr);
@ -62,6 +75,13 @@ void VToolPointOfIntersection::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
@ -75,6 +95,20 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@ -112,6 +146,9 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolPointOfIntersection::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -124,12 +161,19 @@ void VToolPointOfIntersection::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointOfIntersection>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolPointOfIntersection::RemoveReferens()
{
doc->DecrementReferens(firstPointId);
@ -137,12 +181,19 @@ void VToolPointOfIntersection::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointOfIntersection>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolPointOfIntersection::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -161,6 +212,9 @@ void VToolPointOfIntersection::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolPointOfIntersection::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -176,6 +230,9 @@ void VToolPointOfIntersection::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolPointOfIntersection::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,91 +38,31 @@ class VToolPointOfIntersection : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolPointOfIntersection constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id,
const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId,
const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param firstPointId id first line point.
* @param secondPointId id second line point.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolPointOfIntersection)
/**
* @brief firstPointId id first line point.
*/
/** @brief firstPointId id first line point. */
quint32 firstPointId;
/**
* @brief secondPointId id second line point.
*/
/** @brief secondPointId id second line point. */
quint32 secondPointId;
};

View File

@ -34,6 +34,19 @@
const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolShoulderPoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length.
* @param p1Line id first line point.
* @param p2Line id second line point.
* @param pShoulder id shoulder point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const Source &typeCreation,
@ -51,6 +64,9 @@ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const qu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolShoulderPoint::setDialog()
{
SCASSERT(dialog != nullptr);
@ -66,6 +82,14 @@ void VToolShoulderPoint::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint find point.
* @param p1Line first line point.
* @param p2Line second line point.
* @param pShoulder shoulder point.
* @param length length form shoulder point to our.
* @return point.
*/
//TODO find better way calculate point.
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length)
@ -95,7 +119,15 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
}
//---------------------------------------------------------------------------------------------------------------------
VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog);
@ -117,6 +149,23 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula length.
* @param p1Line id first line point.
* @param p2Line id second line point.
* @param pShoulder id shoulder point.
* @param typeLine line type.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
@ -167,6 +216,9 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolShoulderPoint::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -182,6 +234,10 @@ void VToolShoulderPoint::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolShoulderPoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -189,18 +245,29 @@ void VToolShoulderPoint::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogShoulderPoint>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogShoulderPoint>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolShoulderPoint::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -222,6 +289,9 @@ void VToolShoulderPoint::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolShoulderPoint::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -240,6 +310,9 @@ void VToolShoulderPoint::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolShoulderPoint::RemoveReferens()
{
doc->DecrementReferens(p2Line);
@ -248,6 +321,9 @@ void VToolShoulderPoint::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolShoulderPoint::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,112 +38,33 @@
class VToolShoulderPoint : public VToolLinePoint
{
public:
/**
* @brief VToolShoulderPoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeLine line type.
* @param formula string with formula length.
* @param p1Line id first line point.
* @param p2Line id second line point.
* @param pShoulder id shoulder point.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief FindPoint find point.
* @param p1Line first line point.
* @param p2Line second line point.
* @param pShoulder shoulder point.
* @param length length form shoulder point to our.
* @return point.
*/
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length);
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param formula string with formula length.
* @param p1Line id first line point.
* @param p2Line id second line point.
* @param pShoulder id shoulder point.
* @param typeLine line type.
* @param pointName point name.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const QString &typeLine, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief p2Line id second line point.
*/
/** @brief p2Line id second line point. */
quint32 p2Line;
/**
* @brief pShoulder id shoulder line point.
*/
/** @brief pShoulder id shoulder line point. */
quint32 pShoulder;
};

View File

@ -36,6 +36,14 @@
const QString VToolSinglePoint::ToolType = QStringLiteral("single");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolSinglePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
const QString &namePP, const QString &mPath, QGraphicsItem * parent )
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
@ -59,6 +67,9 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolSinglePoint::setDialog()
{
SCASSERT(dialog != nullptr);
@ -69,6 +80,9 @@ void VToolSinglePoint::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolSinglePoint::AddToFile()
{
Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty");
@ -103,6 +117,9 @@ void VToolSinglePoint::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolSinglePoint::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -118,6 +135,12 @@ void VToolSinglePoint::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle tool change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionChange && scene())
@ -147,6 +170,9 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief decrementReferens decrement referens parents objects.
*/
void VToolSinglePoint::decrementReferens()
{
if (_referens > 1)
@ -156,6 +182,9 @@ void VToolSinglePoint::decrementReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolSinglePoint::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -169,6 +198,10 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setColorLabel change color for label and label line.
* @param color new color.
*/
void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
{
namePoint->setBrush(color);
@ -176,12 +209,19 @@ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
{
ContextMenu<DialogSinglePoint>(this, event, false);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolSinglePoint::FullUpdateFromFile()
{
VPointF point = *VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -189,6 +229,10 @@ void VToolSinglePoint::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolSinglePoint::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
@ -206,6 +250,10 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolSinglePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
@ -213,6 +261,10 @@ void VToolSinglePoint::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogSinglePoint>(this, event, false);

View File

@ -39,41 +39,15 @@ class VToolSinglePoint : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolSinglePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
const QString &namePP = QString(), const QString &mPath = QString(),
QGraphicsItem * parent = nullptr );
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
const QString &namePP = QString(), const QString &mPath = QString(),
QGraphicsItem * parent = nullptr );
virtual void setDialog();
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
signals:
/**
@ -81,46 +55,20 @@ signals:
*/
void LiteUpdateTree();
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief itemChange handle tool change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief decrementReferens decrement referens parents objects.
*/
virtual void decrementReferens();
/**
* @brief DeleteTool delete tool from file and scene. This tool can't be deleted by now.
* @param tool tool what me delete.
*/
virtual void DeleteTool(QGraphicsItem *tool){Q_UNUSED(tool)}
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
private:
QString namePP;
QString mPath;
/**
* @brief setColorLabel change color for label and label line.
* @param color new color.
*/
void setColorLabel(const Qt::GlobalColor & color);
};

View File

@ -34,6 +34,14 @@
const QString VToolSpline::ToolType = QStringLiteral("simple");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent)
{
@ -74,6 +82,9 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Sour
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolSpline::setDialog()
{
SCASSERT(dialog != nullptr);
@ -90,8 +101,14 @@ void VToolSpline::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
@ -108,6 +125,22 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param p1 id first spline point.
* @param p4 id last spline point.
* @param kAsm1 coefficient of length first control line.
* @param kAsm2 coefficient of length second control line.
* @param angle1 angle from first point to first control point.
* @param angle2 angle from second point to second control point.
* @param kCurve coefficient of curvature spline.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@ -145,6 +178,12 @@ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ControlPointChangePosition handle change position control point.
* @param indexSpline position spline in spline list.
* @param position position point in spline.
* @param pos new position.
*/
void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos)
{
@ -166,11 +205,19 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolSpline::AddToFile()
{
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
@ -190,6 +237,9 @@ void VToolSpline::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolSpline::RefreshDataInFile()
{
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
@ -207,6 +257,10 @@ void VToolSpline::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event context menu event.
*/
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -217,6 +271,9 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolSpline::RemoveReferens()
{
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
@ -225,6 +282,9 @@ void VToolSpline::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolSpline::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -259,6 +319,9 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));

View File

@ -38,90 +38,28 @@ class VToolSpline:public VAbstractSpline
{
Q_OBJECT
public:
/**
* @brief VToolSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr );
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param p1 id first spline point.
* @param p4 id last spline point.
* @param kAsm1 coefficient of length first control line.
* @param kAsm2 coefficient of length second control line.
* @param angle1 angle from first point to first control point.
* @param angle2 angle from second point to second control point.
* @param kCurve coefficient of curvature spline.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
public slots:
/**
* @brief ControlPointChangePosition handle change position control point.
* @param indexSpline position spline in spline list.
* @param position position point in spline.
* @param pos new position.
*/
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile ();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event context menu event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile ();
virtual void RefreshDataInFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry ();
void RefreshGeometry ();
};
#endif // VTOOLSPLINE_H

View File

@ -33,6 +33,14 @@
const QString VToolSplinePath::ToolType = QStringLiteral("path");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent)
{
@ -57,7 +65,8 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint);
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(), this);
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(),
this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
@ -75,6 +84,9 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolSplinePath::setDialog()
{
SCASSERT(dialog != nullptr);
@ -85,6 +97,13 @@ void VToolSplinePath::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -99,9 +118,18 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param path spline path.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
quint32 id = _id;
if (typeCreation == Source::FromGui)
@ -130,6 +158,12 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ControlPointChangePosition handle change position control point.
* @param indexSpline position spline in spline list.
* @param position position point in spline.
* @param pos new position.
*/
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos)
{
@ -153,6 +187,12 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdateControlPoints update position points control points in file.
* @param spl spline what was changed.
* @param splPath spline path.
* @param indexSpline index spline in spline path.
*/
void VToolSplinePath::UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const
{
VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::FirstPoint);
@ -191,6 +231,12 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdatePathPoint update spline path in pattern file.
* @brief doc dom document container.
* @param node tag in file.
* @param path spline path.
*/
void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path)
{
SCASSERT(doc != nullptr)
@ -211,12 +257,19 @@ void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSpli
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
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<const VSplinePath *>(id);
@ -235,6 +288,9 @@ void VToolSplinePath::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolSplinePath::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -250,6 +306,11 @@ void VToolSplinePath::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddPathPoint write path point to pattern file.
* @param domElement dom element.
* @param splPoint spline path point.
*/
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint)
{
QDomElement pathPoint = doc->createElement(AttrPathPoint);
@ -263,6 +324,10 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -273,6 +338,9 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolSplinePath::RemoveReferens()
{
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
@ -283,6 +351,9 @@ void VToolSplinePath::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolSplinePath::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
@ -296,6 +367,9 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolSplinePath::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));

View File

@ -38,48 +38,13 @@ class VToolSplinePath:public VAbstractSpline
{
Q_OBJECT
public:
/**
* @brief VToolSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
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);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param path spline path.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
/**
* @brief UpdatePathPoint update spline path in pattern file.
* @brief doc dom document container.
* @param node tag in file.
* @param path spline path.
*/
static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path);
signals:
/**
@ -89,68 +54,29 @@ signals:
* @param controlPoint new position control point.
* @param splinePoint new position spline point.
*/
void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos,
const QPointF &controlPoint, const QPointF &splinePoint);
void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
const QPointF &splinePoint);
/**
* @brief setEnabledPoint disable control points.
* @param enable enable or diasable points.
*/
void setEnabledPoint(bool enable);
void setEnabledPoint(bool enable);
public slots:
/**
* @brief ControlPointChangePosition handle change position control point.
* @param indexSpline position spline in spline list.
* @param position position point in spline.
* @param pos new position.
*/
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
protected:
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
/**
* @brief AddPathPoint write path point to pattern file.
* @param domElement dom element.
* @param splPoint spline path point.
*/
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
/**
* @brief UpdateControlPoints update position points control points in file.
* @param spl spline what was changed.
* @param splPath spline path.
* @param indexSpline index spline in spline path.
*/
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
void RefreshSplinePath(VSplinePath &splPath);
void RefreshGeometry();
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
void RefreshSplinePath(VSplinePath &splPath);
};
#endif // VTOOLSPLINEPATH_H

View File

@ -33,6 +33,18 @@
const QString VToolTriangle::ToolType = QStringLiteral("triangle");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolTriangle constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param axisP1Id id first axis point.
* @param axisP2Id id second axis point.
* @param firstPointId id first triangle point, what lies on the hypotenuse.
* @param secondPointId id second triangle point, what lies on the hypotenuse.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem *parent)
@ -51,6 +63,9 @@ VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
*/
void VToolTriangle::setDialog()
{
SCASSERT(dialog != nullptr);
@ -65,8 +80,14 @@ void VToolTriangle::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogTriangle *dialogTool = qobject_cast<DialogTriangle*>(dialog);
@ -81,6 +102,22 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param axisP1Id id first axis point.
* @param axisP2Id id second axis point.
* @param firstPointId id first triangle point, what lies on the hypotenuse.
* @param secondPointId id second triangle point, what lies on the hypotenuse.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolTriangle::Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id,
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
@ -123,6 +160,14 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FindPoint find point intersection two foots right triangle.
* @param axisP1 first axis point.
* @param axisP2 second axis point.
* @param firstPoint first triangle point, what lies on the hypotenuse.
* @param secondPoint second triangle point, what lies on the hypotenuse.
* @return point intersection two foots right triangle.
*/
QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
const QPointF &secondPoint)
{
@ -165,6 +210,9 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolTriangle::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -179,12 +227,19 @@ void VToolTriangle::FullUpdateFromFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogTriangle>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolTriangle::RemoveReferens()
{
doc->DecrementReferens(axisP1Id);
@ -194,12 +249,19 @@ void VToolTriangle::RemoveReferens()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogTriangle>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolTriangle::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -220,6 +282,9 @@ void VToolTriangle::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolTriangle::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -237,6 +302,9 @@ void VToolTriangle::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
*/
void VToolTriangle::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);

View File

@ -38,114 +38,40 @@ class VToolTriangle : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolTriangle constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param axisP1Id id first axis point.
* @param axisP2Id id second axis point.
* @param firstPointId id first triangle point, what lies on the hypotenuse.
* @param secondPointId id second triangle point, what lies on the hypotenuse.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
/**
* @brief setDialog set dialog when user want change tool option.
*/
VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, const quint32 &axisP2Id,
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name.
* @param axisP1Id id first axis point.
* @param axisP2Id id second axis point.
* @param firstPointId id first triangle point, what lies on the hypotenuse.
* @param secondPointId id second triangle point, what lies on the hypotenuse.
* @param mx label bias x axis.
* @param my label bias y axis.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, const quint32 &axisP2Id,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
/**
* @brief FindPoint find point intersection two foots right triangle.
* @param axisP1 first axis point.
* @param axisP2 second axis point.
* @param firstPoint first triangle point, what lies on the hypotenuse.
* @param secondPoint second triangle point, what lies on the hypotenuse.
* @return point intersection two foots right triangle.
*/
static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
const QPointF &secondPoint);
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief ShowContextMenu show context menu.
* @param event context menu event.
*/
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens();
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief SaveDialog save options into file after change in dialog.
*/
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolTriangle)
/**
* @brief axisP1Id id first axis point.
*/
quint32 axisP1Id;
/**
* @brief axisP2Id id second axis point.
*/
quint32 axisP2Id;
/**
* @brief firstPointId id first triangle point, what lies on the hypotenuse.
*/
quint32 firstPointId;
/**
* @brief secondPointId id second triangle point, what lies on the hypotenuse.
*/
quint32 secondPointId;
/** @brief axisP1Id id first axis point. */
quint32 axisP1Id;
/** @brief axisP2Id id second axis point. */
quint32 axisP2Id;
/** @brief firstPointId id first triangle point, what lies on the hypotenuse. */
quint32 firstPointId;
/** @brief secondPointId id second triangle point, what lies on the hypotenuse. */
quint32 secondPointId;
};
#endif // VTOOLTRIANGLE_H

View File

@ -34,6 +34,15 @@ const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VAbstractNode constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idNode object id in containerNode.
* @param idTool id tool.
* @param parent parent object.
*/
VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
const quint32 &idTool, QObject *parent)
: VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool)
@ -59,6 +68,10 @@ void VAbstractNode::RestoreNode()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToModeling add tag to modeling tag current pattern peace.
* @param domElement tag.
*/
void VAbstractNode::AddToModeling(const QDomElement &domElement)
{
QDomElement modelingElement;
@ -75,6 +88,9 @@ void VAbstractNode::AddToModeling(const QDomElement &domElement)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief decrementReferens decrement reference for all parent objects.
*/
void VAbstractNode::decrementReferens()
{
if (_referens > 0)

View File

@ -38,39 +38,21 @@ class VAbstractNode : public VAbstractTool
{
Q_OBJECT
public:
/**
* @brief VAbstractNode constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idNode object id in containerNode.
* @param idTool id tool.
* @param parent parent object.
*/
VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
const quint32 &idTool, QObject *parent = nullptr);
VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
const quint32 &idTool, QObject *parent = nullptr);
virtual ~VAbstractNode() {}
static const QString AttrIdObject;
static const QString AttrIdTool;
virtual void DeleteNode();
virtual void RestoreNode();
protected:
/**
* @brief idNodenode id.
*/
/** @brief idNodenode id. */
quint32 idNode;
/**
* @brief idTool id tool.
*/
/** @brief idTool id tool. */
quint32 idTool;
/**
* @brief AddToModeling add tag to modeling tag current pattern peace.
* @param domElement tag.
*/
void AddToModeling(const QDomElement &domElement);
/**
* @brief decrementReferens decrement reference for all parent objects.
*/
virtual void decrementReferens();
virtual void RemoveReferens();
virtual void RestoreReferens();

View File

@ -35,6 +35,17 @@ const QString VNodeArc::TagName = QStringLiteral("arc");
const QString VNodeArc::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VNodeArc constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idArc object id in containerArc.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent
* @param parent parent object.
*/
VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent)
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
@ -53,6 +64,17 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idArc object id in containerArc.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent
*/
void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
{
@ -81,12 +103,16 @@ void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeArc::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::RestoreNode()
{
if (this->isVisible() == false)
@ -97,12 +123,18 @@ void VNodeArc::RestoreNode()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeArc::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VNodeArc::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
@ -119,6 +151,9 @@ void VNodeArc::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeArc::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -133,6 +168,10 @@ void VNodeArc::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -143,6 +182,10 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -150,6 +193,10 @@ void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -157,6 +204,9 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeArc::RefreshGeometry()
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);

View File

@ -40,73 +40,24 @@ class VNodeArc :public VAbstractNode, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VNodeArc constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idArc object id in containerArc.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent
* @param parent parent object.
*/
VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Source &typeCreation, const quint32 &idTool = 0,
QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idArc object id in containerArc.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent
*/
VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
/**
* @brief DeleteNode delete node from detail.
*/
virtual void DeleteNode();
virtual void RestoreNode();
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
protected:
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
};

View File

@ -36,9 +36,19 @@ const QString VNodePoint::TagName = QStringLiteral("point");
const QString VNodePoint::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------
VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint,
const Source &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem *parent)
/**
* @brief VNodePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idPoint object id in containerPoint.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent
* @param parent parent object.
*/
VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent)
:VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(0),
namePoint(nullptr), lineName(nullptr)
{
@ -63,9 +73,19 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint,
const Document &parse, const Source &typeCreation, const quint32 &idTool,
QObject *parent)
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idPoint object id in containerPoint.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent
*/
void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse)
@ -94,12 +114,16 @@ void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idP
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodePoint::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::RestoreNode()
{
if (this->isVisible() == false)
@ -110,12 +134,18 @@ void VNodePoint::RestoreNode()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodePoint::FullUpdateFromFile()
{
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VNodePoint::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -135,6 +165,9 @@ void VNodePoint::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodePoint::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
@ -152,6 +185,10 @@ void VNodePoint::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -162,6 +199,10 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -169,6 +210,10 @@ void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -176,6 +221,10 @@ void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NameChangePosition label change position.
* @param pos new position.
*/
void VNodePoint::NameChangePosition(const QPointF &pos)
{
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
@ -188,6 +237,11 @@ void VNodePoint::NameChangePosition(const QPointF &pos)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdateNamePosition update label position in file.
* @param mx label bias x axis.
* @param my label bias y axis.
*/
void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -200,6 +254,10 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point position.
*/
void VNodePoint::RefreshPointGeometry(const VPointF &point)
{
QRectF rec = QRectF(0, 0, radius*2, radius*2);
@ -217,6 +275,9 @@ void VNodePoint::RefreshPointGeometry(const VPointF &point)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh label line on scene.
*/
void VNodePoint::RefreshLine()
{
QRectF nameRec = namePoint->sceneBoundingRect();

View File

@ -45,99 +45,36 @@ class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem
{
Q_OBJECT
public:
/**
* @brief VNodePoint constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idPoint object id in containerPoint.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent
* @param parent parent object.
*/
VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr );
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idPoint object id in containerPoint.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent
*/
static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
/**
* @brief DeleteNode delete node from detail.
*/
virtual void DeleteNode();
virtual void RestoreNode();
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
/**
* @brief NameChangePosition label change position.
* @param pos new position.
*/
void NameChangePosition(const QPointF &pos);
protected:
/**
* @brief radius radius circle.
*/
/** @brief radius radius circle. */
qreal radius;
/**
* @brief namePoint label name.
*/
/** @brief namePoint label name. */
VGraphicsSimpleTextItem *namePoint;
/**
* @brief lineName pointer to label line.
*/
/** @brief lineName pointer to label line. */
QGraphicsLineItem *lineName;
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief UpdateNamePosition update label position in file.
* @param mx label bias x axis.
* @param my label bias y axis.
*/
virtual void UpdateNamePosition(qreal mx, qreal my);
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point position.
*/
virtual void RefreshPointGeometry(const VPointF &point);
/**
* @brief RefreshLine refresh label line on scene.
*/
void RefreshLine();
private:
Q_DISABLE_COPY(VNodePoint)

View File

@ -35,6 +35,17 @@ const QString VNodeSpline::TagName = QStringLiteral("spline");
const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VNodeSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param typeCreation way we create this tool.
* @param idTool id node.
* @param qoParent QObject parent.
* @param parent QGraphicsItem parent.
*/
VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Source &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem * parent)
@ -54,9 +65,19 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id
}
//---------------------------------------------------------------------------------------------------------------------
VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse, const Source &typeCreation,
const quint32 &idTool, QObject *parent)
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool id node.
* @return pointer to node.
*/
VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
VNodeSpline *spl = nullptr;
@ -85,12 +106,16 @@ VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, qu
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeSpline::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::RestoreNode()
{
if (this->isVisible() == false)
@ -101,12 +126,18 @@ void VNodeSpline::RestoreNode()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeSpline::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VNodeSpline::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
@ -123,6 +154,9 @@ void VNodeSpline::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeSpline::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -137,6 +171,10 @@ void VNodeSpline::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -147,6 +185,10 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -154,6 +196,10 @@ void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -161,6 +207,9 @@ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeSpline::RefreshGeometry()
{
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);

View File

@ -40,73 +40,24 @@ class VNodeSpline:public VAbstractNode, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VNodeSpline constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param typeCreation way we create this tool.
* @param idTool id node.
* @param qoParent QObject parent.
* @param parent QGraphicsItem parent.
*/
VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool id node.
* @return pointer to node.
*/
static VNodeSpline *Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse, const Source &typeCreation,
const quint32 &idTool = 0, QObject *parent = nullptr);
static VNodeSpline *Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
/**
* @brief DeleteNode delete node from detail.
*/
virtual void DeleteNode();
virtual void RestoreNode();
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile ();
protected:
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile ();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry ();
};

View File

@ -35,6 +35,17 @@ const QString VNodeSplinePath::TagName = QStringLiteral("spline");
const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VNodeSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent.
* @param parent parent object.
*/
VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Source &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem * parent)
@ -54,9 +65,19 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse, const Source &typeCreation,
const quint32 &idTool, QObject *parent)
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent.
*/
void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
if (parse == Document::FullParse)
@ -88,12 +109,16 @@ void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint3
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeSplinePath::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::RestoreNode()
{
if (this->isVisible() == false)
@ -104,12 +129,18 @@ void VNodeSplinePath::RestoreNode()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeSplinePath::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VNodeSplinePath::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
@ -126,6 +157,9 @@ void VNodeSplinePath::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeSplinePath::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -140,6 +174,10 @@ void VNodeSplinePath::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -150,6 +188,10 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -157,6 +199,10 @@ void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -164,6 +210,9 @@ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeSplinePath::RefreshGeometry()
{
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);

View File

@ -40,73 +40,23 @@ class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VNodeSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param qoParent QObject parent.
* @param parent parent object.
*/
VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Source &typeCreation, const quint32 &idTool = 0,
QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
/**
* @brief Create help create tool.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param idSpline object id in containerSpline.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @param idTool tool id.
* @param parent QObject parent.
*/
VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = 0);
static const QString TagName;
static const QString ToolType;
/**
* @brief DeleteNode delete node from detail.
*/
virtual void DeleteNode();
virtual void RestoreNode();
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
*/
virtual void FullUpdateFromFile();
protected:
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
/**
* @brief RefreshGeometry refresh item on scene.
*/
void RefreshGeometry();
};

View File

@ -72,6 +72,13 @@ const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLin
const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VAbstractTool container.
* @param doc dom document container.
* @param data container with data.
* @param id object id in container.
* @param parent parent object.
*/
VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent)
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine)
{
@ -82,6 +89,11 @@ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObjec
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
* @param sc scene.
* @param view view.
*/
void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
{
QRectF rect = sc->itemsBoundingRect();
@ -111,6 +123,12 @@ void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LineIntersectRect find point intersection line and rect.
* @param rec rect.
* @param line line.
* @return point intersection.
*/
QPointF VAbstractTool::LineIntersectRect(QRectF rec, QLineF line)
{
qreal x1, y1, x2, y2;
@ -141,6 +159,15 @@ QPointF VAbstractTool::LineIntersectRect(QRectF rec, QLineF line)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LineIntersectCircle find point intersection line and circle.
* @param center arc center.
* @param radius arc radius.
* @param line line
* @param p1 first intersection point.
* @param p2 second intersection point.
* @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points.
*/
qint32 VAbstractTool::LineIntersectCircle(const QPointF &center, qreal radius, const QLineF &line, QPointF &p1,
QPointF &p2)
{
@ -177,6 +204,11 @@ qint32 VAbstractTool::LineIntersectCircle(const QPointF &center, qreal radius, c
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ClosestPoint find point projection of point onto line.
* @param line line.
* @return point on line or extended line if origin size too small.
*/
QPointF VAbstractTool::ClosestPoint(const QLineF &line, const QPointF &point)
{
qreal a = 0, b = 0, c = 0;
@ -203,6 +235,10 @@ QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPoi
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteTool full delete object form scene and file.
* @param tool tool
*/
void VAbstractTool::DeleteTool(QGraphicsItem *tool)
{
if (_referens <= 1)
@ -254,6 +290,10 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LineStyle return pen style for current line style.
* @return pen style.
*/
Qt::PenStyle VAbstractTool::LineStyle()
{
QStringList styles = Styles();
@ -284,6 +324,13 @@ Qt::PenStyle VAbstractTool::LineStyle()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0.
* @param line line
* @param a a value
* @param b b value
* @param c c value
*/
void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
{
//coefficient for equation of segment
@ -294,6 +341,10 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Styles return list of all line styles.
* @return list of all line styles.
*/
const QStringList VAbstractTool::Styles()
{
//Keep synchronize with DialogTool lineStyles list!!!
@ -303,6 +354,12 @@ const QStringList VAbstractTool::Styles()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddRecord add record about tool in history.
* @param id object id in container
* @param toolType tool type
* @param doc dom document container
*/
void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VPattern *doc)
{
quint32 cursor = doc->getCursor();

View File

@ -33,6 +33,11 @@
class VPattern;
class QDomElement;
class QLineF;
class QPointF;
class QGraphicsScene;
class QGraphicsView;
class QRectF;
/**
* @brief The VAbstractTool abstract class for all tools.
@ -41,58 +46,15 @@ class VAbstractTool: public VDataTool
{
Q_OBJECT
public:
/**
* @brief VAbstractTool container.
* @param doc dom document container.
* @param data container with data.
* @param id object id in container.
* @param parent parent object.
*/
VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
virtual ~VAbstractTool(){}
/**
* @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
* @param sc scene.
* @param view view.
*/
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view);
/**
* @brief LineIntersectRect find point intersection line and rect.
* @param rec rect.
* @param line line.
* @return point intersection.
*/
static QPointF LineIntersectRect(QRectF rec, QLineF line);
/**
* @brief LineIntersectCircle find point intersection line and circle.
* @param center arc center.
* @param radius arc radius.
* @param line line
* @param p1 first intersection point.
* @param p2 second intersection point.
* @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points.
*/
static qint32 LineIntersectCircle(const QPointF &center, qreal radius, const QLineF &line, QPointF &p1,
QPointF &p2);
/**
* @brief ClosestPoint find point projection of point onto line.
* @param line line.
* @return point on line or extended line if origin size too small.
*/
static QPointF ClosestPoint(const QLineF &line, const QPointF &point);
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k);
/**
* @brief getId return object id.
* @return id.
*/
quint32 getId() const;
/**
* @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0.
* @param line line
* @param a a value
* @param b b value
* @param c c value
*/
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
static const QString AttrType;
static const QString AttrMx;
@ -133,18 +95,8 @@ public:
static const QString TypeLineDotLine;
static const QString TypeLineDashDotLine;
static const QString TypeLineDashDotDotLine;
/**
* @brief Styles return list of all line styles.
* @return list of all line styles.
*/
static const QStringList Styles();
/**
* @brief AddRecord add record about tool in history.
* @param id object id in container
* @param toolType tool type
* @param doc dom document container
*/
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
@ -166,25 +118,19 @@ signals:
*/
void LiteUpdateTree();
protected:
/**
* @brief doc dom document container
*/
/** @brief doc dom document container */
VPattern *doc;
/**
* @brief id object id.
*/
/** @brief id object id. */
const quint32 id;
/**
* @brief baseColor base color for tool.
*/
/** @brief baseColor base color for tool. */
Qt::GlobalColor baseColor;
/**
* @brief currentColor current tool color.
*/
/** @brief currentColor current tool color. */
Qt::GlobalColor currentColor;
/**
* @brief typeLine line type.
*/
/** @brief typeLine line type. */
QString typeLine;
/**
* @brief AddToFile add tag with informations about tool into file.
@ -194,34 +140,32 @@ protected:
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile()=0;
/**
* @brief getData return pointer to data container.
* @return container.
*/
const VContainer *getData() const;
/**
* @brief RemoveReferens decrement value of reference.
*/
virtual void RemoveReferens(){}
/**
* @brief DeleteTool full delete object form scene and file.
* @param tool tool
*/
virtual void DeleteTool(QGraphicsItem *tool);
/**
* @brief LineStyle return pen style for current line style.
* @return pen style.
*/
Qt::PenStyle LineStyle();
private:
Q_DISABLE_COPY(VAbstractTool)
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getId return object id.
* @return id.
*/
inline quint32 VAbstractTool::getId() const
{
return id;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getData return pointer to data container.
* @return container.
*/
inline const VContainer *VAbstractTool::getData() const
{
return &data;

View File

@ -29,12 +29,22 @@
#include "vdatatool.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VDataTool constructor.
* @param data container with variables
* @param parent parent object
*/
VDataTool::VDataTool(VContainer *data, QObject *parent): QObject(parent), data(*data), _referens(1)
{
SCASSERT(data != nullptr);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief operator = assignment operator.
* @param tool tool
* @return tool
*/
VDataTool &VDataTool::operator =(const VDataTool &tool)
{
data = tool.getData();
@ -43,6 +53,9 @@ VDataTool &VDataTool::operator =(const VDataTool &tool)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief decrementReferens decrement referens.
*/
void VDataTool::decrementReferens()
{
if (_referens > 0)

View File

@ -41,68 +41,56 @@ class VDataTool : public QObject
{
Q_OBJECT
public:
/**
* @brief VDataTool constructor.
* @param data container with variables
* @param parent parent object
*/
VDataTool(VContainer *data, QObject *parent = nullptr);
virtual ~VDataTool(){}
/**
* @brief operator = assignment operator.
* @param tool tool
* @return tool
*/
VDataTool &operator= (const VDataTool &tool);
/**
* @brief getData return data container.
* @return container.
*/
VContainer getData() const;
/**
* @brief setData set data container.
* @param value container.
*/
void setData(const VContainer *value);
/**
* @brief referens return count of referens.
* @return count count of referens.
*/
virtual quint32 referens() const;
/**
* @brief incrementReferens increment referens.
*/
virtual void incrementReferens();
/**
* @brief decrementReferens decrement referens.
*/
virtual void decrementReferens();
protected:
/**
* @brief data container with data
*/
/** @brief data container with data */
VContainer data;
/**
* @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool.
*/
/** @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. */
quint32 _referens;
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getData return data container.
* @return container.
*/
inline VContainer VDataTool::getData() const
{
return data;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setData set data container.
* @param value container.
*/
inline void VDataTool::setData(const VContainer *value)
{
data = *value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief referens return count of referens.
* @return count count of referens.
*/
inline quint32 VDataTool::referens() const
{
return _referens;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief incrementReferens increment referens.
*/
inline void VDataTool::incrementReferens()
{
++_referens;

View File

@ -46,6 +46,18 @@ const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour");
const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolUnionDetails costructor.
* @param doc dom document container.
* @param data dom document container.
* @param id object id in container.
* @param d1 first detail.
* @param d2 second detail.
* @param indexD1 index edge in first detail.
* @param indexD2 index edge in second detail.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1,
const VDetail &d2, const quint32 &indexD1, const quint32 &indexD2,
const Source &typeCreation, QObject *parent)
@ -62,6 +74,20 @@ VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quin
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToNewDetail create united detail adding one node per time.
* @param tool tool that make union.
* @param doc dom document container.
* @param data container with variables.
* @param newDetail united detail.
* @param det detail what we union.
* @param i index node in detail.
* @param idTool id tool union details.
* @param dx bias node x axis.
* @param dy bias node y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail,
const VDetail &det, const ptrdiff_t &i, const quint32 &idTool, const qreal &dx,
const qreal &dy, const quint32 &pRotate, const qreal &angle)
@ -250,6 +276,18 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdatePoints update data for united details.
* @param idDetail id united detail.
* @param data container with variables.
* @param det detail what we union.
* @param i index node in detail.
* @param idCount count updated or created objects.
* @param dx bias node x axis.
* @param dy bias node y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &i,
quint32 &idCount, const qreal &dx, const qreal &dy, const quint32 &pRotate,
const qreal &angle)
@ -419,6 +457,14 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief BiasRotatePoint bias and rotate point.
* @param point point.
* @param dx bias x axis.
* @param dy bias y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
const qreal angle)
{
@ -431,6 +477,12 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param doc dom document container.
* @param data container with variables.
*/
void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -445,6 +497,21 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param d1 first detail.
* @param d2 second detail.
* @param d1id id first detail.
* @param d2id id second detail.
* @param indexD1 index edge in first detail.
* @param indexD2 index edge in second detail.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @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,
@ -611,6 +678,12 @@ void VToolUnionDetails::FindJ(const qint32 &pointsD2, const VDetail &d2, const q
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetDetailFromFile parse detail from file.
* @param doc dom document container.
* @param domElement tag in xml tree.
* @return detail stored in file.
*/
QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomElement &domElement)
{
QVector<VDetail> vector;
@ -667,6 +740,9 @@ QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomE
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolUnionDetails::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
@ -683,6 +759,9 @@ void VToolUnionDetails::AddToFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolUnionDetails::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
@ -698,6 +777,11 @@ void VToolUnionDetails::RefreshDataInFile()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddDetail add detail to xml file.
* @param domElement tag in xml tree.
* @param d detail.
*/
void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d)
{
QDomElement det = doc->createElement(TagDetail);
@ -711,6 +795,11 @@ void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddNode add node to xml file.
* @param domElement tag in xml tree.
* @param node node.
*/
void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node)
{
QDomElement nod = doc->createElement(TagNode);
@ -769,6 +858,12 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdateDetail update detail in xml tree.
* @param domNode dom node.
* @param d detail.
* @return return next detail tag in xml tree if exist.
*/
QDomNode VToolUnionDetails::UpdateDetail(const QDomNode &domNode, const VDetail &d)
{
//QDomNode domNode = domElement.firstChild();
@ -795,6 +890,10 @@ QDomNode VToolUnionDetails::UpdateDetail(const QDomNode &domNode, const VDetail
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToModeling add tool to xml tree.
* @param domElement tag in xml tree.
*/
void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
{
QDomElement modelingElement;

View File

@ -43,18 +43,6 @@ class VToolUnionDetails : public VAbstractTool
{
Q_OBJECT
public:
/**
* @brief VToolUnionDetails costructor.
* @param doc dom document container.
* @param data dom document container.
* @param id object id in container.
* @param d1 first detail.
* @param d2 second detail.
* @param indexD1 index edge in first detail.
* @param indexD2 index edge in second detail.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2,
const quint32 &indexD1, const quint32 &indexD2, const Source &typeCreation,
QObject *parent = nullptr);
@ -62,40 +50,13 @@ public:
* @brief setDialog set dialog when user want change tool option.
*/
virtual void setDialog() {}
/**
* @brief Create help create tool from GUI.
* @param dialog dialog.
* @param doc dom document container.
* @param data container with variables.
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param d1 first detail.
* @param d2 second detail.
* @param d1id id first detail.
* @param d2id id second detail.
* @param indexD1 index edge in first detail.
* @param indexD2 index edge in second detail.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
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 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);
/**
* @brief GetDetailFromFile parse detail from file.
* @param doc dom document container.
* @param domElement tag in xml tree.
* @return detail stored in file.
*/
static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j);
static QVector<VDetail> GetDetailFromFile(VPattern *doc, const QDomElement &domElement);
static const QString TagName;
static const QString ToolType;
@ -107,46 +68,12 @@ public:
static const QString AttrNodeType;
static const QString NodeTypeContour;
static const QString NodeTypeModeling;
/**
* @brief AddToNewDetail create united detail adding one node per time.
* @param tool tool that make union.
* @param doc dom document container.
* @param data container with variables.
* @param newDetail united detail.
* @param det detail what we union.
* @param i index node in detail.
* @param idTool id tool union details.
* @param dx bias node x axis.
* @param dy bias node y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
static void AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail,
const VDetail &det, const ptrdiff_t &i, const quint32 &idTool, const qreal &dx = 0,
const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0);
/**
* @brief UpdatePoints update data for united details.
* @param idDetail id united detail.
* @param data container with variables.
* @param det detail what we union.
* @param i index node in detail.
* @param idCount count updated or created objects.
* @param dx bias node x axis.
* @param dy bias node y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
static void UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &i,
quint32 &idCount, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0,
const qreal &angle = 0);
/**
* @brief BiasRotatePoint bias and rotate point.
* @param point point.
* @param dx bias x axis.
* @param dy bias y axis.
* @param pRotate point rotation.
* @param angle angle rotation.
*/
static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
const qreal angle);
public slots:
@ -155,55 +82,25 @@ public slots:
*/
virtual void FullUpdateFromFile (){}
protected:
/**
* @brief AddToFile add tag with informations about tool into file.
*/
virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
private:
Q_DISABLE_COPY(VToolUnionDetails)
/**
* @brief d1 first detail.
*/
/** @brief d1 first detail. */
VDetail d1;
/**
* @brief d2 second detail.
*/
/** @brief d2 second detail. */
VDetail d2;
/**
* @brief indexD1 index edge in first detail.
*/
quint32 indexD1;
/**
* @brief indexD2 index edge in second detail.
*/
quint32 indexD2;
/**
* @brief AddDetail add detail to xml file.
* @param domElement tag in xml tree.
* @param d detail.
*/
/** @brief indexD1 index edge in first detail. */
quint32 indexD1;
/** @brief indexD2 index edge in second detail. */
quint32 indexD2;
void AddDetail(QDomElement &domElement, VDetail &d);
/**
* @brief AddNode add node to xml file.
* @param domElement tag in xml tree.
* @param node node.
*/
void AddNode(QDomElement &domElement, const VNodeDetail &node);
/**
* @brief UpdateDetail update detail in xml tree.
* @param domNode dom node.
* @param d detail.
* @return return next detail tag in xml tree if exist.
*/
QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d);
/**
* @brief AddToModeling add tool to xml tree.
* @param domElement tag in xml tree.
*/
void AddToModeling(const QDomElement &domElement);
};

View File

@ -31,6 +31,14 @@
#include "../options.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and
* style option are used to control how the editor widget appears.
* @param parent parent widget.
* @param option item options.
* @param index index of data item.
* @return editor to be used for editing the data item.
*/
//cppcheck-suppress unusedFunction
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
@ -45,6 +53,12 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by
* the model index.
* @param editor editor.
* @param index index of data item.
*/
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
@ -56,6 +70,12 @@ void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &in
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setModelData gets data from the editor widget and stores it in the specified model at the item index.
* @param editor editor.
* @param model model.
* @param index index of data item.
*/
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
@ -68,6 +88,13 @@ void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *mo
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief updateEditorGeometry updates the editor for the item specified by index according to the style option
* given.
* @param editor editor.
* @param option item options.
* @param index index of data item.
*/
//cppcheck-suppress unusedFunction
void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const
@ -77,6 +104,9 @@ void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOp
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief commitAndCloseEditor commit value if changed.
*/
void DoubleSpinBoxDelegate::commitAndCloseEditor()
{
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());

View File

@ -39,51 +39,19 @@ class DoubleSpinBoxDelegate : public QItemDelegate
{
Q_OBJECT
public:
/**
* @brief DoubleSpinBoxDelegate constructor.
* @param parent parent object.
*/
/**
* @brief DoubleSpinBoxDelegate constructor.
* @param parent parent object.
*/
DoubleSpinBoxDelegate(QObject *parent = nullptr): QItemDelegate(parent), lastValue(-10001.0){}
/**
* @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and
* style option are used to control how the editor widget appears.
* @param parent parent widget.
* @param option item options.
* @param index index of data item.
* @return editor to be used for editing the data item.
*/
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by
* the model index.
* @param editor editor.
* @param index index of data item.
*/
void setEditorData(QWidget *editor, const QModelIndex &index) const;
/**
* @brief setModelData gets data from the editor widget and stores it in the specified model at the item index.
* @param editor editor.
* @param model model.
* @param index index of data item.
*/
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
/**
* @brief updateEditorGeometry updates the editor for the item specified by index according to the style option
* given.
* @param editor editor.
* @param option item options.
* @param index index of data item.
*/
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
public slots:
/**
* @brief commitAndCloseEditor commit value if changed.
*/
void commitAndCloseEditor();
private:
/**
* @brief lastValue last saved value.
*/
/** @brief lastValue last saved value. */
qreal lastValue;
};

View File

@ -31,6 +31,10 @@
#include "../options.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief TextDelegate constructor.
* @param parent parent widget.
*/
TextDelegate::TextDelegate(const QString &regex, QObject *parent): QItemDelegate(parent), lastText(QString("Name_")),
regex(regex)
{
@ -39,6 +43,14 @@ TextDelegate::TextDelegate(const QString &regex, QObject *parent): QItemDelegate
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and
* style option are used to control how the editor widget appears.
* @param parent parent widget.
* @param option item options.
* @param index index of data item.
* @return editor to be used for editing the data item.
*/
QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
@ -51,6 +63,12 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by
* the model index.
* @param editor editor.
* @param index index of data item.
*/
void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QString text = index.model()->data(index, Qt::EditRole).toString();
@ -66,6 +84,12 @@ void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) cons
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setModelData gets data from the editor widget and stores it in the specified model at the item index.
* @param editor editor.
* @param model model.
* @param index index of data item.
*/
void TextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
@ -80,6 +104,13 @@ void TextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, cons
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief updateEditorGeometry updates the editor for the item specified by index according to the style option
* given.
* @param editor editor.
* @param option item options.
* @param index index of data item.
*/
void TextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
@ -88,6 +119,9 @@ void TextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewI
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief commitAndCloseEditor commit value if changed.
*/
void TextDelegate::commitAndCloseEditor()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender());
@ -107,6 +141,10 @@ void TextDelegate::commitAndCloseEditor()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief InitText initialize text.
* @param text text.
*/
void TextDelegate::InitText(const QString &text)
{
lastText = text;

View File

@ -39,41 +39,10 @@ class TextDelegate : public QItemDelegate
{
Q_OBJECT
public:
/**
* @brief TextDelegate constructor.
* @param parent parent widget.
*/
TextDelegate(const QString &regex, QObject *parent = nullptr);
/**
* @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and
* style option are used to control how the editor widget appears.
* @param parent parent widget.
* @param option item options.
* @param index index of data item.
* @return editor to be used for editing the data item.
*/
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by
* the model index.
* @param editor editor.
* @param index index of data item.
*/
void setEditorData(QWidget *editor, const QModelIndex &index) const;
/**
* @brief setModelData gets data from the editor widget and stores it in the specified model at the item index.
* @param editor editor.
* @param model model.
* @param index index of data item.
*/
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
/**
* @brief updateEditorGeometry updates the editor for the item specified by index according to the style option
* given.
* @param editor editor.
* @param option item options.
* @param index index of data item.
*/
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
/**
@ -82,21 +51,12 @@ signals:
*/
void SaveText(const QString &text) const;
public slots:
/**
* @brief commitAndCloseEditor commit value if changed.
*/
void commitAndCloseEditor();
/**
* @brief InitText initialize text.
* @param text text.
*/
void InitText(const QString &text);
private:
/**
* @brief lastValue last saved value.
*/
QString lastText;
QString regex;
/** @brief lastValue last saved value. */
QString lastText;
QString regex;
};
#endif // TEXTDELEGATE_H

View File

@ -49,6 +49,11 @@ const qreal VApplication::PrintDPI = 96.0;
#define DefWidth 1.2//mm
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VApplication constructor.
* @param argc number arguments.
* @param argv command line.
*/
VApplication::VApplication(int &argc, char **argv)
: QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual),
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
@ -66,6 +71,12 @@ VApplication::VApplication(int &argc, char **argv)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief notify Reimplemented from QApplication::notify().
* @param receiver receiver.
* @param event event.
* @return value that is returned from the receiver's event handler.
*/
// reimplemented from QApplication so we can throw exceptions in slots
bool VApplication::notify(QObject *receiver, QEvent *event)
{

View File

@ -49,75 +49,63 @@ class VApplication : public QApplication
{
Q_OBJECT
public:
/**
* @brief VApplication constructor.
* @param argc number arguments.
* @param argv command line.
*/
VApplication(int &argc, char ** argv);
virtual ~VApplication() {}
/**
* @brief notify Reimplemented from QApplication::notify().
* @param receiver receiver.
* @param event event.
* @return value that is returned from the receiver's event handler.
*/
virtual bool notify(QObject * receiver, QEvent * event);
Unit patternUnit() const;
void setPatternUnit(const Unit &patternUnit);
MeasurementsType patternType() const;
void setPatternType(const MeasurementsType &patternType);
double toPixel(double unit) const;
double fromPixel(double pix) const;
static const qreal PrintDPI;
QString translationsPath() const;
QString pathToTables() const;
qreal widthMainLine() const;
qreal widthHairLine() const;
QString VarToUser(const QString &var) const;
QString VarFromUser(const QString &var) const;
QString GuiText(const QString &measurement) const;
QString Description(const QString &measurement) const;
QString Variable(const QString &name) const;
QString Function(const QString &name) const;
QString PostfixOperator(const QString &name) const;
QString FormulaFromUser(const QString &formula);
QString FormulaToUser(const QString &formula);
QUndoStack *getUndoStack() const;
VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value);
QTimer *getAutoSaveTimer() const;
void setAutoSaveTimer(QTimer *value);
virtual bool notify(QObject * receiver, QEvent * event);
Unit patternUnit() const;
void setPatternUnit(const Unit &patternUnit);
MeasurementsType patternType() const;
void setPatternType(const MeasurementsType &patternType);
double toPixel(double unit) const;
double fromPixel(double pix) const;
static const qreal PrintDPI;
QString translationsPath() const;
QString pathToTables() const;
qreal widthMainLine() const;
qreal widthHairLine() const;
QString VarToUser(const QString &var) const;
QString VarFromUser(const QString &var) const;
QString GuiText(const QString &measurement) const;
QString Description(const QString &measurement) const;
QString Variable(const QString &name) const;
QString Function(const QString &name) const;
QString PostfixOperator(const QString &name) const;
QString FormulaFromUser(const QString &formula);
QString FormulaToUser(const QString &formula);
QUndoStack *getUndoStack() const;
VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value);
QTimer *getAutoSaveTimer() const;
void setAutoSaveTimer(QTimer *value);
private:
Q_DISABLE_COPY(VApplication)
Unit _patternUnit;
MeasurementsType _patternType;
qreal _widthMainLine;
qreal _widthHairLine;
Unit _patternUnit;
MeasurementsType _patternType;
qreal _widthMainLine;
qreal _widthHairLine;
QMap<QString, VTranslation> measurements;
QMap<QString, VTranslation> guiTexts;
QMap<QString, VTranslation> descriptions;
QMap<QString, VTranslation> variables;
QMap<QString, VTranslation> functions;
QMap<QString, VTranslation> postfixOperators;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
QTimer *autoSaveTimer;
void InitLineWidth();
void InitMeasurements();
void InitVariables();
void InitFunctions();
void InitPostfixOperators();
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token,
int &bias) const;
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token,
int &bias) const;
bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const;
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
QMap<int, QString> &numbers);
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
QTimer *autoSaveTimer;
void InitLineWidth();
void InitMeasurements();
void InitVariables();
void InitFunctions();
void InitPostfixOperators();
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token,
int &bias) const;
bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const;
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
QMap<int, QString> &numbers);
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -33,6 +33,14 @@
#include "../widgets/vapplication.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VControlPointSpline constructor.
* @param indexSpline index spline in list.
* @param position position point in spline.
* @param controlPoint control point.
* @param splinePoint spline point.
* @param parent parent object.
*/
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
const QPointF &controlPoint, const QPointF &splinePoint,
QGraphicsItem *parent)
@ -59,6 +67,10 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -73,6 +85,12 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionChange && scene())
@ -85,6 +103,13 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh line control point.
* @param indexSpline index spline in list.
* @param pos position point in spline.
* @param controlPoint control point.
* @param splinePoint spline point.
*/
void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePointPosition pos,
const QPointF &controlPoint, const QPointF &splinePoint)
{
@ -97,6 +122,10 @@ void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePointPosi
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setEnabledPoint disable or enable control point.
* @param enable true - enable.
*/
void VControlPointSpline::setEnabledPoint(bool enable)
{
if (enable == true)

View File

@ -40,17 +40,8 @@ class VControlPointSpline : public QObject, public QGraphicsEllipseItem
{
Q_OBJECT
public:
/**
* @brief VControlPointSpline constructor.
* @param indexSpline index spline in list.
* @param position position point in spline.
* @param controlPoint control point.
* @param splinePoint spline point.
* @param parent parent object.
*/
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
const QPointF &controlPoint, const QPointF &splinePoint,
QGraphicsItem * parent = nullptr);
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
const QPointF &splinePoint, QGraphicsItem * parent = nullptr);
signals:
/**
* @brief ControlPointChangePosition emit when control point change position.
@ -61,55 +52,25 @@ signals:
void ControlPointChangePosition(const qint32 &indexSpline, SplinePointPosition position,
const QPointF pos);
public slots:
/**
* @brief RefreshLine refresh line control point.
* @param indexSpline index spline in list.
* @param pos position point in spline.
* @param controlPoint control point.
* @param splinePoint spline point.
*/
void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
const QPointF &splinePoint);
/**
* @brief setEnabledPoint disable or enable control point.
* @param enable true - enable.
*/
void setEnabledPoint(bool enable);
protected:
/**
* @brief radius radius circle.
*/
/** @brief radius radius circle. */
qreal radius;
/**
* @brief controlLine pointer to line control point.
*/
/** @brief controlLine pointer to line control point. */
QGraphicsLineItem *controlLine;
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
private:
Q_DISABLE_COPY(VControlPointSpline)
/**
* @brief indexSpline index spline in list..
*/
/** @brief indexSpline index spline in list.. */
qint32 indexSpline;
/**
* @brief position position point in spline.
*/
/** @brief position position point in spline. */
SplinePointPosition position;
};

View File

@ -29,6 +29,10 @@
#include "vgraphicssimpletextitem.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VGraphicsSimpleTextItem default constructor.
* @param parent parent object.
*/
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
:QGraphicsSimpleTextItem(parent), fontSize(0)
{
@ -43,6 +47,11 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VGraphicsSimpleTextItem constructor.
* @param text text.
* @param parent parent object.
*/
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent )
:QGraphicsSimpleTextItem(text, parent), fontSize(0)
{
@ -53,6 +62,12 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionChange && scene())
@ -64,6 +79,10 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -71,6 +90,10 @@ void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -78,6 +101,10 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
emit ShowContextMenu(event);

View File

@ -39,16 +39,9 @@ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem
{
Q_OBJECT
public:
/**
* @brief VGraphicsSimpleTextItem default constructor.
* @param parent parent object.
*/
VGraphicsSimpleTextItem(QGraphicsItem * parent = nullptr);
/**
* @brief VGraphicsSimpleTextItem constructor.
* @param text text.
* @param parent parent object.
*/
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = nullptr );
/**
* @brief FontSize return label font size.
@ -67,32 +60,12 @@ signals:
*/
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief contextMenuEvent handle context menu events.
* @param event context menu event.
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
private:
/**
* @brief fontSize label font size.
*/
/** @brief fontSize label font size. */
qint32 fontSize;
};

View File

@ -33,20 +33,37 @@
#include "../widgets/vapplication.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VItem constructor.
* @param path detail path.
* @param numInList index in list of details.
* @param parent parent object.
*/
VItem::VItem (const QPainterPath & path, int numInList, QGraphicsItem * parent )
:QGraphicsPathItem ( path, parent ), numInOutList(numInList), paper(nullptr)
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VItem default constructor.
*/
VItem::VItem():numInOutList(0), paper(nullptr)
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VItem constructor.
* @param numInList index in list of details.
* @param parent parent object.
*/
VItem::VItem(int numInList, QGraphicsItem *parent):QGraphicsPathItem (parent), numInOutList(numInList),
paper(nullptr)
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief checkItemChange change item change. If detail create colission or moved out paper emit signal.
*/
void VItem::checkItemChange()
{
QRectF rect;
@ -87,6 +104,12 @@ void VItem::checkItemChange()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VItem::itemChange( GraphicsItemChange change, const QVariant &value )
{
if ( change == QGraphicsItem::ItemPositionHasChanged && scene() )
@ -103,6 +126,9 @@ QVariant VItem::itemChange( GraphicsItemChange change, const QVariant &value )
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief LengthChanged handle signal change paper length.
*/
void VItem::LengthChanged()
{
checkItemChange();

View File

@ -39,28 +39,9 @@ class VItem : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VItem default constructor.
*/
VItem ();
/**
* @brief VItem constructor.
* @param numInList index in list of details.
* @param parent parent object.
*/
VItem (int numInList, QGraphicsItem * parent = nullptr);
/**
* @brief VItem constructor.
* @param path detail path.
* @param numInList index in list of details.
* @param parent parent object.
*/
VItem ( const QPainterPath & path, int numInList, QGraphicsItem * parent = nullptr );
/**
* @brief Rotate rotate detail on angle in degree.
* @param angle angle in degree.
*/
void Rotate ( qreal angle );
VItem ();
VItem (int numInList, QGraphicsItem * parent = nullptr);
VItem ( const QPainterPath & path, int numInList, QGraphicsItem * parent = nullptr );
/**
* @brief getPaper return pointer to paper sheet.
* @return pointer to paper sheet.
@ -72,36 +53,17 @@ public:
*/
void setPaper(QGraphicsRectItem *value) {paper = value;}
public slots:
/**
* @brief LengthChanged handle signal change paper length.
*/
void LengthChanged();
/**
* @brief SetIndexInList set detail index in list.
* @param index index in list.
*/
void SetIndexInList( qint32 index );
protected:
/**
* @brief itemChange handle item change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief checkItemChange change item change. If detail create colission or moved out paper emit signal.
*/
void checkItemChange ();
private:
Q_DISABLE_COPY(VItem)
/**
* @brief numInOutList index in list.
*/
/** @brief numInOutList index in list. */
qint32 numInOutList;
/**
* @brief paper pointer to paper item.
*/
/** @brief paper pointer to paper item. */
QGraphicsRectItem* paper;
signals:
/**
@ -118,6 +80,11 @@ signals:
void itemColliding ( QList<QGraphicsItem *> list, int number );
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetIndexInList set detail index in list.
* @param index index in list.
*/
inline void VItem::SetIndexInList(qint32 index)
{
numInOutList = index;

View File

@ -29,16 +29,28 @@
#include "vmaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VMainGraphicsScene default constructor.
*/
VMainGraphicsScene::VMainGraphicsScene()
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VMainGraphicsScene constructor.
* @param sceneRect scene rect.
* @param parent parent object.
*/
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseMoveEvent handle mouse move events.
* @param event mouse move event.
*/
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
emit mouseMove(event->scenePos());
@ -46,6 +58,10 @@ void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mousePressEvent mouse press events.
* @param event mouse press event
*/
void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
emit mousePress(event->scenePos());
@ -53,24 +69,41 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief transform return view transformation.
* @return view transformation.
*/
QTransform VMainGraphicsScene::transform() const
{
return _transform;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setTransform set view transformation.
* @param transform view transformation.
*/
void VMainGraphicsScene::setTransform(const QTransform &transform)
{
_transform = transform;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedItem emit ChoosedObject signal.
* @param id object id.
* @param type object scene type.
*/
void VMainGraphicsScene::ChoosedItem(quint32 id, const SceneObject &type)
{
emit ChoosedObject(id, type);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor. scene scale factor.
*/
void VMainGraphicsScene::SetFactor(qreal factor)
{
scaleFactor=scaleFactor*factor;

View File

@ -39,68 +39,19 @@ class VMainGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
/**
* @brief VMainGraphicsScene default constructor.
*/
VMainGraphicsScene();
/**
* @brief VMainGraphicsScene constructor.
* @param sceneRect scene rect.
* @param parent parent object.
*/
VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr);
/**
* @brief getHorScrollBar return scene horizontal scrollbar.
* @return horizontal scrollbar.
*/
VMainGraphicsScene();
VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr);
qint32 getHorScrollBar() const;
/**
* @brief setHorScrollBar set scene horizontal scrollbar.
* @param value horizontal scrollbar.
*/
void setHorScrollBar(const qint32 &value);
/**
* @brief getVerScrollBar return scene vertical scrollbar.
* @return vertical scrollbar.
*/
qint32 getVerScrollBar() const;
/**
* @brief setVerScrollBar set scene vertical scrollbar.
* @param value vertical scrollbar.
*/
void setVerScrollBar(const qint32 &value);
/**
* @brief transform return view transformation.
* @return view transformation.
*/
QTransform transform() const;
/**
* @brief setTransform set view transformation.
* @param transform view transformation.
*/
void setTransform(const QTransform &transform);
public slots:
/**
* @brief ChoosedItem emit ChoosedObject signal.
* @param id object id.
* @param type object scene type.
*/
void ChoosedItem(quint32 id, const SceneObject &type);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor. scene scale factor.
*/
void SetFactor(qreal factor);
protected:
/**
* @brief mouseMoveEvent handle mouse move events.
* @param event mouse move event.
*/
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
/**
* @brief mousePressEvent mouse press events.
* @param event mouse press event
*/
void mousePressEvent(QGraphicsSceneMouseEvent *event);
signals:
/**
@ -125,39 +76,54 @@ signals:
*/
void NewFactor(qreal factor);
private:
/**
* @brief horScrollBar value horizontal scroll bar.
*/
/** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar;
/**
* @brief verScrollBar value vertical scroll bar.
*/
/** @brief verScrollBar value vertical scroll bar. */
qint32 verScrollBar;
/**
* @brief scaleFactor scale factor.
*/
/** @brief scaleFactor scale factor. */
qreal scaleFactor;
/**
* @brief _transform view transform value.
*/
/** @brief _transform view transform value. */
QTransform _transform;
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getHorScrollBar return scene horizontal scrollbar.
* @return horizontal scrollbar.
*/
inline qint32 VMainGraphicsScene::getHorScrollBar() const
{
return horScrollBar;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setHorScrollBar set scene horizontal scrollbar.
* @param value horizontal scrollbar.
*/
inline void VMainGraphicsScene::setHorScrollBar(const qint32 &value)
{
horScrollBar = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getVerScrollBar return scene vertical scrollbar.
* @return vertical scrollbar.
*/
inline qint32 VMainGraphicsScene::getVerScrollBar() const
{
return verScrollBar;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setVerScrollBar set scene vertical scrollbar.
* @param value vertical scrollbar.
*/
inline void VMainGraphicsScene::setVerScrollBar(const qint32 &value)
{
verScrollBar = value;

View File

@ -35,6 +35,10 @@
#include "../tools/vabstracttool.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VMainGraphicsView constructor.
* @param parent parent object.
*/
VMainGraphicsView::VMainGraphicsView(QWidget *parent)
:QGraphicsView(parent), _numScheduledScalings(0)
{
@ -44,6 +48,10 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief wheelEvent handle wheel events.
* @param event wheel event.
*/
//cppcheck-suppress unusedFunction
void VMainGraphicsView::wheelEvent(QWheelEvent *event)
{
@ -71,6 +79,10 @@ void VMainGraphicsView::wheelEvent(QWheelEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief scalingTime call each time when need handle scaling.
* @param x value from 0.0 to 1.0
*/
void VMainGraphicsView::scalingTime(qreal x)
{
Q_UNUSED(x);
@ -90,6 +102,10 @@ void VMainGraphicsView::scalingTime(qreal x)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief scrollingTime call each time when need handle scrolling.
* @param x value from 0.0 to 1.0
*/
void VMainGraphicsView::scrollingTime(qreal x)
{
Q_UNUSED(x);
@ -110,6 +126,9 @@ void VMainGraphicsView::scrollingTime(qreal x)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief animFinished
*/
void VMainGraphicsView::animFinished()
{
if (_numScheduledScalings > 0)
@ -140,6 +159,10 @@ void VMainGraphicsView::ZoomOut()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mousePressEvent handle mouse press events.
* @param mousePress mouse press event.
*/
void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
{
if (mousePress->button() & Qt::LeftButton)
@ -158,6 +181,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
QGraphicsView::mouseReleaseEvent ( event );

View File

@ -38,10 +38,7 @@ class VMainGraphicsView : public QGraphicsView
{
Q_OBJECT
public:
/**
* @brief VMainGraphicsView constructor.
* @param parent parent object.
*/
explicit VMainGraphicsView(QWidget *parent = nullptr);
signals:
/**
@ -50,42 +47,17 @@ signals:
*/
void NewFactor(qreal factor);
public slots:
/**
* @brief scalingTime call each time when need handle scaling.
* @param x value from 0.0 to 1.0
*/
void scalingTime(qreal x);
/**
* @brief scrollingTime call each time when need handle scrolling.
* @param x value from 0.0 to 1.0
*/
void scrollingTime(qreal x);
/**
* @brief animFinished
*/
void animFinished();
void ZoomIn();
void ZoomOut();
protected:
/**
* @brief wheelEvent handle wheel events.
* @param event wheel event.
*/
void wheelEvent ( QWheelEvent * event );
/**
* @brief mousePressEvent handle mouse press events.
* @param mousePress mouse press event.
*/
void mousePressEvent(QMouseEvent *mousePress);
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void mouseReleaseEvent(QMouseEvent *event);
private:
/**
* @brief _numScheduledScalings keep number scheduled scalings.
*/
/** @brief _numScheduledScalings keep number scheduled scalings. */
qint32 _numScheduledScalings;
};

View File

@ -32,8 +32,15 @@
#include <QGraphicsSceneMouseEvent>
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VSimpleArc constructor.
* @param id arc id.
* @param currentColor current color.
* @param factor scale factor.
* @param parent parent object.
*/
VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
if (factor == nullptr)
{
@ -48,6 +55,10 @@ VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VSimpleArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -58,6 +69,10 @@ void VSimpleArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -72,6 +87,10 @@ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VSimpleArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -40,13 +40,6 @@ class VSimpleArc : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VSimpleArc constructor.
* @param id arc id.
* @param currentColor current color.
* @param factor scale factor.
* @param parent parent object.
*/
VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = nullptr);
signals:
/**
@ -55,34 +48,18 @@ signals:
*/
void Choosed(quint32 id);
protected:
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
Q_DISABLE_COPY(VSimpleArc)
/**
* @brief id arc id.
*/
/** @brief id arc id. */
quint32 id;
/**
* @brief factor scale factor.
*/
/** @brief factor scale factor. */
qreal *factor;
/**
* @brief currentColor current color.
*/
/** @brief currentColor current color. */
Qt::GlobalColor *currentColor;
};

View File

@ -32,6 +32,13 @@
#include <QPen>
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VSimpleSpline constructor.
* @param id spline id.
* @param factor scene scale factor.
* @param currentColor current color.
* @param parent parent object.
*/
VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
@ -56,6 +63,10 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -66,6 +77,10 @@ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -80,6 +95,10 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -40,50 +40,27 @@ class VSimpleSpline : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VSimpleSpline constructor.
* @param id spline id.
* @param factor scene scale factor.
* @param currentColor current color.
* @param parent parent object.
*/
VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = 0);
void ChangedActivDraw(const bool &flag);
void ChangedActivDraw(const bool &flag);
signals:
/**
* @brief Choosed send id when clicked.
* @param id spline id.
*/
void Choosed(quint32 id);
void Choosed(quint32 id);
protected:
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
Q_DISABLE_COPY(VSimpleSpline)
/**
* @brief id spline id.
*/
quint32 id;
/**
* @brief factor scale factor.
*/
/** @brief id spline id. */
quint32 id;
/** @brief factor scale factor. */
qreal *factor;
/**
* @brief currentColor current color.
*/
/** @brief currentColor current color. */
Qt::GlobalColor *currentColor;
};

View File

@ -31,11 +31,22 @@
#include <QGraphicsSceneMouseEvent>
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VSimpleSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id spline path id.
* @param factor scale factor.
*/
VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor)
:VAbstractTool(doc, data, id), factor(factor)
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -46,6 +57,10 @@ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
@ -53,6 +68,10 @@ void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -40,35 +40,14 @@ class VSimpleSplinePath : public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VSimpleSplinePath constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id spline path id.
* @param factor scale factor.
*/
VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor);
protected:
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
Q_DISABLE_COPY(VSimpleSplinePath)
/**
* @brief factor scale factor.
*/
/** @brief factor scale factor. */
qreal *factor;
};

View File

@ -41,6 +41,9 @@ VTableGraphicsView::VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief selectionChanged handle selection change.
*/
void VTableGraphicsView::selectionChanged()
{
QList<QGraphicsItem *> listSelectedItems = scene()->selectedItems();
@ -57,6 +60,9 @@ void VTableGraphicsView::selectionChanged()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief MirrorItem mirror detail.
*/
void VTableGraphicsView::MirrorItem()
{
QList<QGraphicsItem *> list = scene()->selectedItems();
@ -98,6 +104,10 @@ void VTableGraphicsView::MirrorItem()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief wheelEvent handle wheel events.
* @param event wheel event.
*/
void VTableGraphicsView::wheelEvent(QWheelEvent *event)
{
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
@ -119,6 +129,10 @@ void VTableGraphicsView::wheelEvent(QWheelEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mousePressEvent handle mouse press events.
* @param mousePress mouse press event.
*/
void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress)
{
if (mousePress->button() & Qt::LeftButton)
@ -137,6 +151,10 @@ void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VTableGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
QGraphicsView::mouseReleaseEvent ( event );
@ -144,6 +162,10 @@ void VTableGraphicsView::mouseReleaseEvent(QMouseEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyPressEvent handle key press events.
* @param event key press event.
*/
void VTableGraphicsView::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
@ -170,6 +192,9 @@ void VTableGraphicsView::keyPressEvent(QKeyEvent *event)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief rotateIt rotate selected details on 180 degree.
*/
void VTableGraphicsView::rotateIt()
{
QList<QGraphicsItem *> list = scene()->selectedItems();
@ -186,6 +211,10 @@ void VTableGraphicsView::rotateIt()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief MoveItem move selected detail.
* @param move type of move.
*/
void VTableGraphicsView::MoveItem(VTableGraphicsView::typeMove_e move)
{
qreal dx = 0, dy = 0;

View File

@ -51,69 +51,42 @@ signals:
*/
void itemChect( bool flag );
public slots:
/**
* @brief selectionChanged handle selection change.
*/
void selectionChanged();
/**
* @brief rotateItems handle rotatation detail.
*/
void rotateItems();
/**
* @brief MirrorItem mirror detail.
*/
void MirrorItem();
/**
* @brief ZoomIn zoom in paper scale.
*/
void ZoomIn();
/**
* @brief ZoomOut zoom out paper scale.
*/
void ZoomOut();
protected:
/**
* @brief wheelEvent handle wheel events.
* @param event wheel event.
*/
void wheelEvent ( QWheelEvent * event );
/**
* @brief mousePressEvent handle mouse press events.
* @param mousePress mouse press event.
*/
void mousePressEvent(QMouseEvent *mousePress);
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void mouseReleaseEvent ( QMouseEvent * event );
/**
* @brief keyPressEvent handle key press events.
* @param event key press event.
*/
void keyPressEvent ( QKeyEvent * event );
/**
* @brief rotateIt rotate selected details on 180 degree.
*/
void rotateIt();
/**
* @brief MoveItem move selected detail.
* @param move type of move.
*/
void MoveItem( VTableGraphicsView::typeMove_e move );
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief rotateItems handle rotatation detail.
*/
inline void VTableGraphicsView::rotateItems()
{
rotateIt();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ZoomIn zoom in paper scale.
*/
inline void VTableGraphicsView::ZoomIn()
{
scale(1.1, 1.1);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ZoomOut zoom out paper scale.
*/
inline void VTableGraphicsView::ZoomOut()
{
scale(1/1.1, 1/1.1);

View File

@ -104,6 +104,11 @@ VDomDocument::~VDomDocument()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Finds an element by id.
* @param id value id attribute.
* @return dom element.
*/
QDomElement VDomDocument::elementById(const QString& id)
{
if (map.contains(id))
@ -125,6 +130,10 @@ QDomElement VDomDocument::elementById(const QString& id)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Removes all children of a given element tag. RENAME: removeAllChildren
* @param element tag
*/
void VDomDocument::removeAllChilds(QDomElement &element)
{
QDomNode domNode = element.firstChild();
@ -143,6 +152,12 @@ void VDomDocument::removeAllChilds(QDomElement &element)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Find element by id.
* @param node node
* @param id id value
* @return true if found
*/
bool VDomDocument::find(const QDomElement &node, const QString& id)
{
if (node.hasAttribute(AttrId))
@ -170,6 +185,12 @@ bool VDomDocument::find(const QDomElement &node, const QString& id)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
* @param domElement tag in xml tree
* @param name attribute name
* @return long long value
*/
quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue) const
{
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
@ -200,6 +221,13 @@ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QStri
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the string value of the given attribute. RENAME: see above
*
* if attribute empty return default value. If default value empty too throw exception.
* @return attribute value
* @throw VExceptionEmptyParameter when attribute is empty
*/
QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name,
const QString &defValue) const
{
@ -221,6 +249,12 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the double value of the given attribute.
* @param domElement tag in xml tree
* @param name attribute name
* @return double value
*/
qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) const
{
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
@ -272,6 +306,11 @@ QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVa
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValidateXML validate xml file by xsd schema.
* @param schema path to schema file.
* @param fileName name of xml file.
*/
void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
{
QFile pattern(fileName);

View File

@ -79,16 +79,7 @@ public:
*/
VDomDocument(VContainer *data);
virtual ~VDomDocument();
/**
* @brief Finds an element by id.
* @param id value id attribute.
* @return dom element.
*/
QDomElement elementById(const QString& id);
/**
* @brief Removes all children of a given element tag. RENAME: removeAllChildren
* @param element tag
*/
void removeAllChilds(QDomElement &element);
template <typename T>
/**
@ -108,36 +99,11 @@ public:
val = val.replace(",", ".");
domElement.setAttribute(name, val);
}
/**
* @brief Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
* @param domElement tag in xml tree
* @param name attribute name
* @return long long value
*/
quint32 GetParametrUInt(const QDomElement& domElement, const QString &name,
const QString &defValue) const;
/**
* @brief Returns the string value of the given attribute. RENAME: see above
*
* if attribute empty return default value. If default value empty too throw exception.
* @return attribute value
* @throw VExceptionEmptyParameter when attribute is empty
*/
quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue) const;
QString GetParametrString(const QDomElement& domElement, const QString &name,
const QString &defValue = QString()) const;
/**
* @brief Returns the double value of the given attribute.
* @param domElement tag in xml tree
* @param name attribute name
* @return double value
*/
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
/**
* @brief ValidateXML validate xml file by xsd schema.
* @param schema path to schema file.
* @param fileName name of xml file.
*/
static void ValidateXML(const QString &schema, const QString &fileName);
void setContent(const QString &fileName);
static Unit StrToUnits(const QString &unit);
@ -148,27 +114,19 @@ public:
QString Patch() const;
static void RemoveAllChild(QDomElement &domElement);
protected:
/**
* @brief data container with data.
*/
/** @brief data container with data. */
VContainer *data;
void setTagText(const QString &tag, const QString &text);
private:
Q_DISABLE_COPY(VDomDocument)
/**
* @brief Map used for finding element by id.
*/
/** @brief Map used for finding element by id. */
QHash<QString, QDomElement> map;
/**
* @brief Find element by id.
* @param node node
* @param id id value
* @return true if found
*/
bool find(const QDomElement &node, const QString& id);
};
//---------------------------------------------------------------------------------------------------------------------
template <>
inline void VDomDocument::SetAttribute<QString>(QDomElement &domElement, const QString &name,
const QString &value) const
@ -176,6 +134,7 @@ inline void VDomDocument::SetAttribute<QString>(QDomElement &domElement, const Q
domElement.setAttribute(name, value);
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
const MeasurementsType &value) const

View File

@ -29,11 +29,20 @@
#include "vtoolrecord.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolRecord default constructor.
*/
VToolRecord::VToolRecord()
:id(0), typeTool(Tool::ArrowTool), nameDraw(QString())
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolRecord constructor.
* @param id tool id.
* @param typeTool tool type.
* @param nameDraw pattern peace name.
*/
VToolRecord::VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw)
:id(id), typeTool(typeTool), nameDraw(nameDraw)
{}

View File

@ -39,87 +39,80 @@
class VToolRecord
{
public:
/**
* @brief VToolRecord default constructor.
*/
VToolRecord();
/**
* @brief VToolRecord constructor.
* @param id tool id.
* @param typeTool tool type.
* @param nameDraw pattern peace name.
*/
VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw);
/**
* @brief getId return tool id.
* @return id.
*/
quint32 getId() const;
/**
* @brief setId set tool id.
* @param value id.
*/
void setId(const quint32 &value);
/**
* @brief getTypeTool return tool type.
* @return tool type.
*/
Tool getTypeTool() const;
/**
* @brief setTypeTool set tool type.
* @param value tool type.
*/
void setTypeTool(const Tool &value);
/**
* @brief getNameDraw return pattern peace name.
* @return pattern peace name.
*/
QString getNameDraw() const;
/**
* @brief setNameDraw set pattern peace name.
* @param value pattern peace name.
*/
void setNameDraw(const QString &value);
quint32 getId() const;
void setId(const quint32 &value);
Tool getTypeTool() const;
void setTypeTool(const Tool &value);
QString getNameDraw() const;
void setNameDraw(const QString &value);
private:
/**
* @brief id tool id.
*/
quint32 id;
/**
* @brief typeTool tool type.
*/
Tool typeTool;
/**
* @brief nameDraw pattern peace name.
*/
QString nameDraw;
/** @brief id tool id. */
quint32 id;
/** @brief typeTool tool type. */
Tool typeTool;
/** @brief nameDraw pattern peace name. */
QString nameDraw;
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getId return tool id.
* @return id.
*/
inline quint32 VToolRecord::getId() const
{
return id;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId set tool id.
* @param value id.
*/
inline void VToolRecord::setId(const quint32 &value)
{
id = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getTypeTool return tool type.
* @return tool type.
*/
inline Tool VToolRecord::getTypeTool() const
{
return typeTool;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setTypeTool set tool type.
* @param value tool type.
*/
inline void VToolRecord::setTypeTool(const Tool &value)
{
typeTool = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getNameDraw return pattern peace name.
* @return pattern peace name.
*/
inline QString VToolRecord::getNameDraw() const
{
return nameDraw;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setNameDraw set pattern peace name.
* @param value pattern peace name.
*/
inline void VToolRecord::setNameDraw(const QString &value)
{
nameDraw = value;