Documentation for VToolRecord, VDomDocument classes. Fixed issue #2.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-27 16:05:58 +02:00
parent b96f83f238
commit b4841c1f25
2 changed files with 196 additions and 176 deletions

View File

@ -41,7 +41,7 @@
namespace Document
{
/**
* @brief The Document enum
* @brief The Document enum types parse.
*/
enum Document { LiteParse, FullParse};
Q_DECLARE_FLAGS(Documents, Document)
@ -54,182 +54,195 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
#endif
/**
* @brief The VDomDocument class
* @brief The VDomDocument class working with pattern file.
*/
class VDomDocument : public QObject, public QDomDocument
{
Q_OBJECT
public:
/**
* @brief VDomDocument
* @param data container with variables
* @param comboBoxDraws
* @param mode
* @brief VDomDocument constructor.
* @param data container with variables.
* @param comboBoxDraws combobox for pattern peaces names.
* @param mode draw mode.
*/
VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent = 0);
/**
* @brief VDomDocument
* @param name
* @param data container with variables
* @param comboBoxDraws
* @param mode
* @brief VDomDocument constructor.
* @param name pattern peace name.
* @param data container with variables.
* @param comboBoxDraws combobox for pattern peaces names.
* @param mode draw mode.
*/
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode,
QObject *parent = 0);
/**
* @brief VDomDocument
* @param doc dom document containertype
* @param data container with variables
* @param comboBoxDraws
* @param mode
* @brief VDomDocument constructor.
* @param doc dom document container type.
* @param data container with variables.
* @param comboBoxDraws combobox for pattern peaces names.
* @param mode draw mode.
*/
VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode, QObject *parent = 0);
~VDomDocument(){}
/**
* @brief elementById
* @param id
* @return
* @brief elementById find element by id.
* @param id value id attribute.
* @return dom element.
*/
QDomElement elementById(const QString& id);
/**
* @brief removeAllChilds remove all tag childs.
* @param element tag.
*/
void removeAllChilds(QDomElement &element);
/**
* @brief CreateEmptyFile
* @brief CreateEmptyFile create minimal empty file.
*/
void CreateEmptyFile();
/**
* @brief ChangeActivDraw
* @param name
* @brief ChangeActivDraw set new pattern peace name.
* @param name new name.
* @param parse parser file mode.
*/
void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse);
/**
* @brief GetNameActivDraw
* @return
* @brief GetNameActivDraw return current pattern peace name.
* @return pattern peace name.
*/
inline QString GetNameActivDraw() const {return nameActivDraw;}
/**
* @brief GetActivDrawElement
* @param element
* @return
* @brief GetActivDrawElement return draw tag for current pattern peace.
* @param element draw tag.
* @return true if found.
*/
bool GetActivDrawElement(QDomElement &element);
/**
* @brief GetActivCalculationElement
* @param element
* @return
* @brief GetActivCalculationElement return calculation tag for current pattern peace.
* @param element calculation tag.
* @return true if found.
*/
bool GetActivCalculationElement(QDomElement &element);
/**
* @brief GetActivModelingElement
* @param element
* @return
* @brief GetActivModelingElement return modeling tag for current pattern peace.
* @param element modeling tag
* @return true if found.
*/
bool GetActivModelingElement(QDomElement &element);
/**
* @brief GetActivDetailsElement
* @param element
* @return
* @brief GetActivDetailsElement return details tag for current pattern peace.
* @param element details tag.
* @return true if found.
*/
bool GetActivDetailsElement(QDomElement &element);
/**
* @brief appendDraw
* @param name
* @return
* @brief appendDraw add new pattern peace structure to the file.
* @param name pattern peace name.
* @return true if success.
*/
bool appendDraw(const QString& name);
/**
* @brief SetNameDraw
* @param name
* @return
* @brief SetNameDraw change current pattern peace.
* @param name pattern peace name.
* @return true if success.
*/
bool SetNameDraw(const QString& name);
/**
* @brief Parse
* @brief Parse parse file.
* @param parse parser file mode.
* @param sceneDraw
* @param sceneDetail
* @param sceneDraw pointer to draw scene.
* @param sceneDetail pointer to details scene.
*/
void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail);
/**
* @brief getTools
* @return
* @brief getTools return list of tools pointers.
* @return list.
*/
inline QHash<qint64, VDataTool*>* getTools() {return &tools;}
/**
* @brief getTool return tool from tool list.
* @param id tool id.
* @return tool.
*/
VDataTool* getTool(const qint64 &id);
/**
* @brief getHistory
* @return
* @brief getHistory return list with list of history records.
* @return list of history records.
*/
inline QVector<VToolRecord> *getHistory() {return &history;}
/**
* @brief getCursor
* @return
* @brief getCursor return cursor.
* @return cursor.
*/
inline qint64 getCursor() const {return cursor;}
/**
* @brief setCursor
* @param value
* @brief setCursor set cursor.
* @param value cursor.
*/
void setCursor(const qint64 &value);
/**
* @brief setCurrentData
* @brief setCurrentData set current data set.
*/
void setCurrentData();
/**
* @brief AddTool
* @param id
* @param tool
* @brief AddTool add tool to list tools.
* @param id tool id.
* @param tool tool.
*/
void AddTool(const qint64 &id, VDataTool *tool);
/**
* @brief UpdateToolData
* @param id
* @param data container with variables
* @brief UpdateToolData update tool in list tools.
* @param id tool id.
* @param data container with variables.
*/
void UpdateToolData(const qint64 &id, VContainer *data);
/**
* @brief IncrementReferens
* @param id
* @brief IncrementReferens increment reference parent objects.
* @param id parent object id.
*/
void IncrementReferens(qint64 id) const;
/**
* @brief DecrementReferens
* @param id
* @brief DecrementReferens decrement reference parent objects.
* @param id parent object id.
*/
void DecrementReferens(qint64 id) const;
/**
* @brief TestUniqueId
* @brief TestUniqueId test exist unique id in pattern file. Each id must be unique.
*/
void TestUniqueId() const;
/**
* @brief GetParametrLongLong
* @param domElement
* @param name
* @return
* @brief GetParametrLongLong return long long value of attribute.
* @param domElement tag in xml tree.
* @param name attribute name.
* @return long long value.
*/
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name,
const QString &defValue) const;
/**
* @brief GetParametrString
* @param domElement
* @param name
* @return
* @brief GetParametrString return string value of attribute.
* @param domElement tag in xml tree.
* @param name attribute name.
* @return attribute value.
*/
QString GetParametrString(const QDomElement& domElement, const QString &name, const QString &defValue) const;
/**
* @brief GetParametrDouble
* @param domElement
* @param name
* @return
* @brief GetParametrDouble return double value of 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;
/**
* @brief SPointActiveDraw return id base point current pattern peace.
* @return id base point.
*/
qint64 SPointActiveDraw();
signals:
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName
* @brief ChangedActivDraw change active pattern peace.
* @param newName new pattern peace name.
*/
void ChangedActivDraw(const QString &newName);
/**
@ -243,187 +256,194 @@ signals:
*/
void FullUpdateFromFile();
/**
* @brief haveChange
* @brief haveChange emit if we have unsaved change.
*/
void haveChange();
/**
* @brief ShowTool highlight tool.
* @param id
* @param color
* @param enable
* @brief ShowTool highlight tool.
* @param id tool id.
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/**
* @brief ChangedCursor
* @param id
* @brief ChangedCursor change cursor position.
* @param id tool id.
*/
void ChangedCursor(qint64 id);
public slots:
/**
* @brief FullUpdateTree
* @brief FullUpdateTree lite parse file.
*/
void FullUpdateTree();
/**
* @brief haveLiteChange
* @brief haveLiteChange we have unsaved change.
*/
void haveLiteChange();
/**
* @brief ShowHistoryTool
* @param id
* @param color
* @param enable
* @brief ShowHistoryTool hightlight tool.
* @param id tool id.
* @param color hightlight color.
* @param enable enable or diasable hightlight.
*/
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
private:
Q_DISABLE_COPY(VDomDocument)
/**
* @brief map
* @brief map use for finding element by id.
*/
QHash<QString, QDomElement> map;
/**
* @brief nameActivDraw
* @brief nameActivDraw name current pattern peace.
*/
QString nameActivDraw;
/**
* @brief data container with data
* @brief data container with data.
*/
VContainer *data;
/**
* @brief tools
* @brief tools list with pointer on tools.
*/
QHash<qint64, VDataTool*> tools;
/**
* @brief history
* @brief history history records.
*/
QVector<VToolRecord> history;
/**
* @brief cursor
* @brief cursor cursor keep id tool after which we will add new tool in file.
*/
qint64 cursor;
/**
* @brief comboBoxDraws
* @brief comboBoxDraws combobox with pattern peace names.
*/
QComboBox *comboBoxDraws;
/**
* @brief mode
* @brief mode current draw mode.
*/
Draw::Draws *mode;
/**
* @brief find
* @param node
* @param id
* @return
* @brief find find element by id.
* @param node node.
* @param id id value.
* @return true if found.
*/
bool find(const QDomElement &node, const QString& id);
/**
* @brief CheckNameDraw
* @param name
* @return
* @brief CheckNameDraw check if exist pattern peace with this name.
* @param name pattern peace name.
* @return true if exist.
*/
bool CheckNameDraw(const QString& name) const;
/**
* @brief SetActivDraw
* @param name
* @brief SetActivDraw set current pattern peace.
* @param name pattern peace name.
*/
void SetActivDraw(const QString& name);
/**
* @brief GetActivNodeElement
* @param name
* @param element
* @return
* @brief GetActivNodeElement find element in current pattern peace by name.
* @param name name tag.
* @param element element.
* @return true if found.
*/
bool GetActivNodeElement(const QString& name, QDomElement& element);
/**
* @brief ParseDrawElement
* @param sceneDraw
* @param sceneDetail
* @param node
* @brief ParseDrawElement parse draw tag.
* @param sceneDraw draw scene.
* @param sceneDetail details scene.
* @param node node.
* @param parse parser file mode.
*/
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse);
/**
* @brief ParseDrawMode
* @param sceneDraw
* @param sceneDetail
* @param node
* @brief ParseDrawMode parse draw tag with draw mode.
* @param sceneDraw draw scene.
* @param sceneDetail details scene.
* @param node node.
* @param parse parser file mode.
* @param mode
* @param mode draw mode.
*/
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode);
/**
* @brief ParseDetailElement
* @param sceneDetail
* @param domElement
* @brief ParseDetailElement parse detail tag.
* @param sceneDetail detail scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
*/
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
/**
* @brief ParseDetails
* @param sceneDetail
* @param domElement
* @brief ParseDetails parse details tag.
* @param sceneDetail detail scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
*/
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
/**
* @brief ParsePointElement
* @param scene
* @param domElement
* @brief ParsePointElement parse point tag.
* @param scene scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
* @param type
* @param mode
* @param type type of point.
* @param mode draw mode.
*/
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString &type);
/**
* @brief ParseLineElement
* @param scene
* @param domElement
* @brief ParseLineElement parse line tag.
* @param scene scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
* @param mode
* @param mode draw mode.
*/
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse);
/**
* @brief ParseSplineElement
* @param scene
* @param domElement
* @brief ParseSplineElement parse spline tag.
* @param scene scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
* @param type
* @param mode
* @param type type of spline.
* @param mode draw mode.
*/
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseArcElement
* @param scene
* @param domElement
* @brief ParseArcElement parse arc tag.
* @param scene scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
* @param type
* @param mode
* @param type type of spline.
* @param mode draw mode.
*/
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseToolsElement parse tools tag.
* @param scene scene.
* @param domElement tag in xml tree.
* @param parse parser file mode.
* @param type type of spline.
*/
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseIncrementsElement
* @param node
* @brief ParseIncrementsElement parse increments tag.
* @param node tag in xml tree.
*/
void ParseIncrementsElement(const QDomNode& node);
/**
* @brief GetParametrId
* @param domElement
* @return
* @brief GetParametrId return value id attribute.
* @param domElement tag in xml tree.
* @return id value.
*/
qint64 GetParametrId(const QDomElement& domElement) const;
/**
* @brief CollectId
* @param node
* @param vector
* @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique.
* @param node tag in xml tree.
* @param vector list with ids.
*/
void CollectId(const QDomElement &node, QVector<qint64> &vector)const;
};

View File

@ -34,63 +34,63 @@
#include <QString>
/**
* @brief The VToolRecord class
* @brief The VToolRecord class record about tool in history.
*/
class VToolRecord
{
public:
/**
* @brief VToolRecord
* @brief VToolRecord default constructor.
*/
VToolRecord();
/**
* @brief VToolRecord
* @param id
* @param typeTool
* @param nameDraw
* @brief VToolRecord constructor.
* @param id tool id.
* @param typeTool tool type.
* @param nameDraw pattern peace name.
*/
VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw);
/**
* @brief getId
* @return
* @brief getId return tool id.
* @return id.
*/
inline qint64 getId() const {return id;}
/**
* @brief setId
* @param value
* @brief setId set tool id.
* @param value id.
*/
inline void setId(const qint64 &value) {id = value;}
/**
* @brief getTypeTool
* @return
* @brief getTypeTool return tool type.
* @return tool type.
*/
inline Tool::Tools getTypeTool() const {return typeTool;}
/**
* @brief setTypeTool
* @param value
* @brief setTypeTool set tool type.
* @param value tool type.
*/
inline void setTypeTool(const Tool::Tools &value) {typeTool = value;}
/**
* @brief getNameDraw
* @return
* @brief getNameDraw return pattern peace name.
* @return pattern peace name.
*/
inline QString getNameDraw() const {return nameDraw;}
/**
* @brief setNameDraw
* @param value
* @brief setNameDraw set pattern peace name.
* @param value pattern peace name.
*/
inline void setNameDraw(const QString &value) {nameDraw = value;}
private:
/**
* @brief id
* @brief id tool id.
*/
qint64 id;
/**
* @brief typeTool
* @brief typeTool tool type.
*/
Tool::Tools typeTool;
/**
* @brief nameDraw
* @brief nameDraw pattern peace name.
*/
QString nameDraw;
};