From 2b1da2ac322e54129dc7c440d789003e0683a9b0 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 7 Oct 2013 18:34:14 +0300 Subject: [PATCH] Documentation for classes. --HG-- branch : feature --- container/calculator.cpp | 78 +++-------- container/calculator.h | 168 ++++++++++++----------- container/vcontainer.h | 285 ++++++++++++++++++++++----------------- docs/Doxyfile | 4 +- 4 files changed, 270 insertions(+), 265 deletions(-) diff --git a/container/calculator.cpp b/container/calculator.cpp index d161724bb..d60077f27 100644 --- a/container/calculator.cpp +++ b/container/calculator.cpp @@ -40,12 +40,12 @@ qreal Calculator::eval(QString prog, QString *errorMsg){ this->errorMsg->clear(); debugFormula.clear(); this->prog = prog; - //qDebug()<<"Формула: "<0; --t) -// *r = (*r) * ex; break; } } -/* Изменение знака */ void Calculator::unary(QChar o, qreal *r){ if(o=='-') *r = -(*r); } -/* Поиск значения переменной */ qreal Calculator::find_var(QString s){ bool ok = false; qreal value = data->FindVar(s, &ok); if(!ok){ qDebug()<clear(); *errorMsg = e[error]; - qDebug()</*%^=()",c) || c=='\n' || c=='\r' || c=='\0') return true; return false; } -/* Возвращает 1, если "с" пробел или табуляция */ bool Calculator::iswhite(QChar c){ if(c==' ' || c=='\t') return true; @@ -257,14 +225,14 @@ void Calculator::get_token(){ token.clear(); temp=&token; - if(prog[index]=='\0') { /* Конец файла */ + if(prog[index]=='\0') { /* end of file */ token="\0"; tok=FINISHED; token_type=DELIMITER; return; } - while(iswhite(prog[index])) ++index; /* пропуск пробелов */ + while(iswhite(prog[index])) ++index; /* skip spaces */ if(prog[index]=='\r') { /* crtl */ ++index; ++index; @@ -274,15 +242,15 @@ void Calculator::get_token(){ return; } - if(StrChr("+-*^/%=;(),><", prog[index])) { /* разделитель */ + if(StrChr("+-*^/%=;(),><", prog[index])) { /* delimiter */ *temp=prog[index]; - index++; /* переход на следующую позицию */ + index++; /* jump to the next position */ temp->append("\0"); token_type=DELIMITER; debugFormula.append(token); return; } - if(prog[index]=='"') { /* строка в кавычках */ + if(prog[index]=='"') { /* quoted string */ index++; while(prog[index] != '"' && prog[index] != '\r'){ temp->append(prog[index]); @@ -294,7 +262,7 @@ void Calculator::get_token(){ token_type=QUOTE; return; } - if(prog[index].isDigit()) { /* число */ + if(prog[index].isDigit()) { /* number */ while(!isdelim(prog[index])){ temp->append(prog[index]); index++; @@ -304,7 +272,7 @@ void Calculator::get_token(){ return; } - if(prog[index].isPrint()) { /* переменная или команда */ + if(prog[index].isPrint()) { /* variable or command */ while(!isdelim(prog[index])){ temp->append(prog[index]); index++; @@ -313,13 +281,12 @@ void Calculator::get_token(){ } temp->append("\0"); - /* Просматривается, если строка есть команда или переменная */ + /* Seen if there is a command line or a variable */ if(token_type==STRING) { - tok=look_up(token); /* преобразование во внутренний - формат */ + tok=look_up(token); if(!tok) token_type = VARIABLE; - else token_type = COMMAND; /* это команда */ + else token_type = COMMAND; /* It is command */ } return; } @@ -328,7 +295,6 @@ bool Calculator::StrChr(QString string, QChar c){ return string.contains(c, Qt::CaseInsensitive); } -/* Возвращает лексему обратно во входной поток */ void Calculator::putback(){ QString t; t = token; diff --git a/container/calculator.h b/container/calculator.h index ad16c7f65..c6be25745 100644 --- a/container/calculator.h +++ b/container/calculator.h @@ -26,142 +26,148 @@ #include "vcontainer.h" /** - * @brief The Calculator клас калькулятора формул лекал. Виконує розрахунок формул з підставлянням - * значеннь зміних. + * @brief The Calculator class calculate formulas of pattern. Support operation +,-,/,* and braces. + * Can replace name of variables her value. */ -class Calculator -{ +class Calculator{ public: /** - * @brief Calculator конструктор класу. Використовується при розрахунку лекала. - * @param data покажчик на контейнер змінних + * @brief Calculator class constructor. + * @param data pointer to a variable container. */ - explicit Calculator(const VContainer *data); + explicit Calculator(const VContainer *data); /** - * @brief eval виконує розрахунок формули. - * @param prog рядко в якому зберігається формула. - * @return значення формули. + * @brief eval calculate formula. + * @param prog string of formula. + * @return value of formula. */ - qreal eval(QString prog, QString *errorMsg); + qreal eval(QString prog, QString *errorMsg); private: Q_DISABLE_COPY(Calculator) - QString *errorMsg; /** - * @brief token теперішня лексема. + * @brief errorMsg keeps error message of calculation. */ - QString token; + QString *errorMsg; /** - * @brief tok внутрішне представлення лексеми. + * @brief token current token. */ - qint32 tok; + QString token; /** - * @brief token_type тип лексеми. + * @brief tok internal representation of token. */ - qint32 token_type; + qint32 tok; /** - * @brief prog рядок в якому зберігається формула. + * @brief token_type type of token. */ - QString prog; /* Содержит анализируемое выражение */ + qint32 token_type; /** - * @brief index номер символу в рядку формули. + * @brief prog string where keeps formula. */ - qint32 index; /* Индекс символа в строке*/ + QString prog; /** - * @brief data контейнер усіх змінних. + * @brief index number character in string of formula. + */ + qint32 index; + /** + * @brief data container of all variables. */ const VContainer *data; /** - * @brief debugFormula рядок розшифрованої формули. + * @brief debugFormula decoded string of formula. */ - QString debugFormula; + QString debugFormula; /** - * @brief get_exp виконує розрахунок формули. - * @return значення формули. + * @brief get_exp calculate formula. + * @return value of formula. */ - qreal get_exp(); + qreal get_exp(); /** - * @brief get_token повертає наступну лексему. + * @brief get_token return next token. */ - void get_token();/* Получить лексему */ + void get_token(); /** - * @brief StrChr перевіряє чи символ належить рядку. - * @param string рядок - * @param c символ. - * @return true - належить рядку, false - не належить рядку. + * @brief StrChr checks whether the character belongs to the line. + * @param string string with formula + * @param c character. + * @return true - belongs to the line, false - don't belongs to the line. */ - static bool StrChr(QString string, QChar c); + static bool StrChr(QString string, QChar c); /** - * @brief putback повертає зчитану лексему назад у потік. + * @brief putback returns the readout token back into the flow. */ - void putback(); + void putback(); /** - * @brief level2 метод додавання і віднімання двух термів. - * @param result результат операції. + * @brief level2 method of addition and subtraction of two terms. + * @param result result of operation. */ - void level2(qreal *result); + void level2(qreal *result); /** - * @brief level3 метод множення, ділення, знаходження процентів. - * @param result результат операції. + * @brief level3 method of multiplication, division, finding percent. + * @param result result of operation. */ - void level3(qreal *result); + void level3(qreal *result); /** - * @brief level4 метод знаходження степені двох чисел. - * @param result результат операції. + * @brief level4 method of degree two numbers. + * @param result result of operation. */ - void level4(qreal *result); + void level4(qreal *result); /** - * @brief level5 метод знаходження унарного плюса чи мінуса. - * @param result результат операції. + * @brief level5 method for finding unary plus or minus. + * @param result result of operation. */ - void level5(qreal *result); + void level5(qreal *result); /** - * @brief level6 метод обробки виразу в круглих лапках. - * @param result результат операції. + * @brief level6 processing method of the expression in brackets. + * @param result result of operation. */ - void level6(qreal *result); + void level6(qreal *result); /** - * @brief primitive метод визначення значення зміної по її імені. - * @param result результат операції. + * @brief primitive method of determining the value of a variable by its name. + * @param result result of operation. */ - void primitive(qreal *result); + void primitive(qreal *result); /** - * @brief arith виконання специфікованої арифметики. Результат записується в перший елемент. - * @param o знак операції. - * @param r перший елемент. - * @param h другий елемент. + * @brief arith perform the specified arithmetic. The result is written to the first element. + * @param o sign operation. + * @param r first element. + * @param h second element. */ - static void arith(QChar o, qreal *r, qreal *h); + static void arith(QChar o, qreal *r, qreal *h); /** - * @brief unary метод зміни знаку. - * @param o символ знаку. - * @param r елемент. + * @brief unary method changes the sign. + * @param o sign of symbol. + * @param r element. */ - static void unary(QChar o, qreal *r); + static void unary(QChar o, qreal *r); /** - * @brief find_var метод знаходить змінну за іменем. - * @param s ім'я змінної. - * @return значення зміної. + * @brief find_var method is finding variable by name. + * @param s name of variable. + * @return value of variable. */ - qreal find_var(QString s); - void serror(qint32 error); + qreal find_var(QString s); /** - * @brief look_up пошук відповідного внутрішнього формату для теперішньої лексеми в таблиці лексем. текущей лексемы в таблице лексем - * @param s ім'я лексеми. - * @return внутрішній номер лексеми. + * @brief serror report an error + * @param error error code */ - static char look_up(QString s); + void serror(qint32 error); /** - * @brief isdelim повертає "істино", якщо с розділювач. - * @param c символ. - * @return розділювач, або ні. + * @brief look_up Finding the internal format for the current token in the token table. + * @param s name of token. + * @return internal number of token. */ - static bool isdelim(QChar c); + static char look_up(QString s); /** - * @brief iswhite перевіряє чи с пробіл чи табуляція. - * @param c символ. - * @return так або ні. + * @brief isdelim return true if c delimiter. + * @param c character. + * @return true - delimiter, false - do not delimiter. */ - static bool iswhite(QChar c); + static bool isdelim(QChar c); + /** + * @brief iswhite checks whether c space or tab. + * @param c character. + * @return true - space or tab, false - don't space and don't tab. + */ + static bool iswhite(QChar c); }; #endif // CALCULATOR_H diff --git a/container/vcontainer.h b/container/vcontainer.h index c7582b89d..a1b836594 100644 --- a/container/vcontainer.h +++ b/container/vcontainer.h @@ -32,146 +32,179 @@ #include /** - * @brief The VContainer class + * @brief The VContainer class container of all variables. */ -class VContainer -{ +class VContainer{ Q_DECLARE_TR_FUNCTIONS(VContainer) public: + /** + * @brief VContainer create empty container + */ + VContainer(); + /** + * @brief operator = copy constructor + * @param data container + * @return copy container + */ + VContainer &operator=(const VContainer &data); + /** + * @brief VContainer create container from another container + * @param data container + */ + VContainer(const VContainer &data); + /** + * @brief setData copy data from container + * @param data container + */ + void setData(const VContainer &data); /** - * @brief VContainer - */ - VContainer(); - VContainer &operator=(const VContainer &data); - VContainer(const VContainer &data); - void setData(const VContainer &data); - /** - * @brief GetPoint - * @param id + * @brief GetPoint returns a point by id + * @param id id of point + * @return point + */ + VPointF GetPoint(qint64 id) const; + /** + * @brief GetModelingPoint return a modeling point by id + * @param id id of modeling point + * @return modeling point + */ + VPointF GetModelingPoint(qint64 id) const; + /** + * @brief GetStandartTableCell + * @param name * @return */ - VPointF GetPoint(qint64 id) const; - VPointF GetModelingPoint(qint64 id) const; - VStandartTableCell GetStandartTableCell(const QString& name) const; - VIncrementTableRow GetIncrementTableRow(const QString& name) const; - qreal GetLine(const QString &name) const; - qreal GetLineArc(const QString &name) const; - VSpline GetSpline(qint64 id) const; - VSpline GetModelingSpline(qint64 id) const; - VArc GetArc(qint64 id) const; - VArc GetModelingArc(qint64 id) const; - VSplinePath GetSplinePath(qint64 id) const; - VSplinePath GetModelingSplinePath(qint64 id) const; - VDetail GetDetail(qint64 id) const; - static qint64 getId(); - qint64 AddPoint(const VPointF& point); - qint64 AddModelingPoint(const VPointF& point); - qint64 AddDetail(const VDetail& detail); - void AddStandartTableCell(const QString& name, const VStandartTableCell& cell); - void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell); - void AddLengthLine(const QString &name, const qreal &value); - void AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId, - Draw::Draws mode = Draw::Calculation); - void AddLengthSpline(const QString &name, const qreal &value); - void AddLengthArc(const qint64 ¢er, const qint64 &id); - void AddLengthArc(const QString &name, const qreal &value); - void AddLineAngle(const QString &name, const qreal &value); - void AddLine(const qint64 &firstPointId, const qint64 &secondPointId, - Draw::Draws mode = Draw::Calculation); - qint64 AddSpline(const VSpline& spl); - qint64 AddModelingSpline(const VSpline& spl); - qint64 AddSplinePath(const VSplinePath& splPath); - qint64 AddModelingSplinePath(const VSplinePath& splPath); - qint64 AddArc(const VArc& arc); - qint64 AddModelingArc(const VArc& arc); - QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, - Draw::Draws mode = Draw::Calculation) const; - QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, - Draw::Draws mode = Draw::Calculation) const; - QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, - Draw::Draws mode = Draw::Calculation) const; - QString GetNameSplinePath(const VSplinePath &path, - Draw::Draws mode = Draw::Calculation) const; - QString GetNameArc(const qint64 ¢er, const qint64 &id, - Draw::Draws mode = Draw::Calculation) const; - void UpdatePoint(qint64 id, const VPointF& point); - void UpdateModelingPoint(qint64 id, const VPointF& point); - void UpdateDetail(qint64 id, const VDetail& detail); - void UpdateSpline(qint64 id, const VSpline& spl); - void UpdateModelingSpline(qint64 id, const VSpline& spl); - void UpdateSplinePath(qint64 id, const VSplinePath& splPath); - void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath); - void UpdateArc(qint64 id, const VArc& arc); - void UpdateModelingArc(qint64 id, const VArc& arc); - void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell); - void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell); - qreal GetValueStandartTableCell(const QString& name) const; - qreal GetValueIncrementTableRow(const QString& name) const; - void Clear(); - void ClearObject(); - void ClearIncrementTable(); - void ClearLengthLines(); - void ClearLengthSplines(); - void ClearLengthArcs(); - void ClearLineAngles(); - void SetSize(qint32 size); - void SetGrowth(qint32 growth); - qint32 size() const; - qint32 growth() const; - qreal FindVar(const QString& name, bool *ok)const; - bool IncrementTableContains(const QString& name); - static qint64 getNextId(); - void RemoveIncrementTableRow(const QString& name); - const QHash *DataPoints() const; - const QHash *DataModelingPoints() const; - const QHash *DataSplines() const; - const QHash *DataModelingSplines() const; - const QHash *DataArcs() const; - const QHash *DataModelingArcs() const; - const QHash *DataBase() const; + VStandartTableCell GetStandartTableCell(const QString& name) const; + VIncrementTableRow GetIncrementTableRow(const QString& name) const; + qreal GetLine(const QString &name) const; + qreal GetLineArc(const QString &name) const; + VSpline GetSpline(qint64 id) const; + VSpline GetModelingSpline(qint64 id) const; + VArc GetArc(qint64 id) const; + VArc GetModelingArc(qint64 id) const; + VSplinePath GetSplinePath(qint64 id) const; + VSplinePath GetModelingSplinePath(qint64 id) const; + VDetail GetDetail(qint64 id) const; + static qint64 getId(); + qint64 AddPoint(const VPointF& point); + qint64 AddModelingPoint(const VPointF& point); + qint64 AddDetail(const VDetail& detail); + void AddStandartTableCell(const QString& name, + const VStandartTableCell& cell); + void AddIncrementTableRow(const QString& name, + const VIncrementTableRow &cell); + void AddLengthLine(const QString &name, const qreal &value); + void AddLengthSpline(const qint64 &firstPointId, + const qint64 &secondPointId, + Draw::Draws mode = Draw::Calculation); + void AddLengthSpline(const QString &name, const qreal &value); + void AddLengthArc(const qint64 ¢er, const qint64 &id); + void AddLengthArc(const QString &name, const qreal &value); + void AddLineAngle(const QString &name, const qreal &value); + void AddLine(const qint64 &firstPointId, const qint64 &secondPointId, + Draw::Draws mode = Draw::Calculation); + qint64 AddSpline(const VSpline& spl); + qint64 AddModelingSpline(const VSpline& spl); + qint64 AddSplinePath(const VSplinePath& splPath); + qint64 AddModelingSplinePath(const VSplinePath& splPath); + qint64 AddArc(const VArc& arc); + qint64 AddModelingArc(const VArc& arc); + QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, + Draw::Draws mode = Draw::Calculation) const; + QString GetNameLineAngle(const qint64 &firstPoint, + const qint64 &secondPoint, + Draw::Draws mode = Draw::Calculation) const; + QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, + Draw::Draws mode = Draw::Calculation) const; + QString GetNameSplinePath(const VSplinePath &path, + Draw::Draws mode = Draw::Calculation) const; + QString GetNameArc(const qint64 ¢er, const qint64 &id, + Draw::Draws mode = Draw::Calculation) const; + void UpdatePoint(qint64 id, const VPointF& point); + void UpdateModelingPoint(qint64 id, const VPointF& point); + void UpdateDetail(qint64 id, const VDetail& detail); + void UpdateSpline(qint64 id, const VSpline& spl); + void UpdateModelingSpline(qint64 id, const VSpline& spl); + void UpdateSplinePath(qint64 id, const VSplinePath& splPath); + void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath); + void UpdateArc(qint64 id, const VArc& arc); + void UpdateModelingArc(qint64 id, const VArc& arc); + void UpdateStandartTableCell(const QString& name, + const VStandartTableCell& cell); + void UpdateIncrementTableRow(const QString& name, + const VIncrementTableRow& cell); + qreal GetValueStandartTableCell(const QString& name) const; + qreal GetValueIncrementTableRow(const QString& name) const; + void Clear(); + void ClearObject(); + void ClearIncrementTable(); + void ClearLengthLines(); + void ClearLengthSplines(); + void ClearLengthArcs(); + void ClearLineAngles(); + void SetSize(qint32 size); + void SetGrowth(qint32 growth); + qint32 size() const; + qint32 growth() const; + qreal FindVar(const QString& name, bool *ok)const; + bool IncrementTableContains(const QString& name); + static qint64 getNextId(); + void RemoveIncrementTableRow(const QString& name); + const QHash *DataPoints() const; + const QHash *DataModelingPoints() const; + const QHash *DataSplines() const; + const QHash *DataModelingSplines() const; + const QHash *DataArcs() const; + const QHash *DataModelingArcs() const; + const QHash *DataBase() const; const QHash *DataStandartTable() const; const QHash *DataIncrementTable() const; - const QHash *DataLengthLines() const; - const QHash *DataLengthSplines() const; - const QHash *DataLengthArcs() const; - const QHash *DataLineAngles() const; - const QHash *DataSplinePaths() const; - const QHash *DataModelingSplinePaths() const; - const QHash *DataDetails() const; - static void UpdateId(qint64 newId); - QPainterPath ContourPath(qint64 idDetail) const; - QPainterPath Equidistant(QVector points, const Detail::Equidistant &eqv, - const qreal &width)const; - static QLineF ParallelLine(const QLineF &line, qreal width ); - static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width); - QVector EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const; - QVector CheckLoops(const QVector &points) const; - void PrepareDetails(QVector & list)const; + const QHash *DataLengthLines() const; + const QHash *DataLengthSplines() const; + const QHash *DataLengthArcs() const; + const QHash *DataLineAngles() const; + const QHash *DataSplinePaths() const; + const QHash *DataModelingSplinePaths() const; + const QHash *DataDetails() const; + static void UpdateId(qint64 newId); + QPainterPath ContourPath(qint64 idDetail) const; + QPainterPath Equidistant(QVector points, + const Detail::Equidistant &eqv, + const qreal &width)const; + static QLineF ParallelLine(const QLineF &line, qreal width ); + static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, + const qreal &width); + QVector EkvPoint(const QLineF &line1, const QLineF &line2, + const qreal &width)const; + QVector CheckLoops(const QVector &points) const; + void PrepareDetails(QVector & list)const; private: - static qint64 _id; - QHash base; - QHash points; - QHash modelingPoints; + static qint64 _id; + QHash base; + QHash points; + QHash modelingPoints; QHash standartTable; QHash incrementTable; - QHash lengthLines; - QHash lineAngles; - QHash splines; - QHash modelingSplines; - QHash lengthSplines; - QHash arcs; - QHash modelingArcs; - QHash lengthArcs; - QHash splinePaths; - QHash modelingSplinePaths; - QHash details; + QHash lengthLines; + QHash lineAngles; + QHash splines; + QHash modelingSplines; + QHash lengthSplines; + QHash arcs; + QHash modelingArcs; + QHash lengthArcs; + QHash splinePaths; + QHash modelingSplinePaths; + QHash details; template static val GetObject(const QHash &obj, key id); template static void UpdateObject(QHash &obj, const qint64 &id, const val& point); - template static qint64 AddObject(QHash &obj, const val& value); - void CreateManTableIGroup (); - QVector GetReversePoint(const QVector &points)const; - qreal GetLengthContour(const QVector &contour, const QVector &newPoints)const; + template static qint64 AddObject(QHash &obj, + const val& value); + void CreateManTableIGroup (); + QVector GetReversePoint(const QVector &points)const; + qreal GetLengthContour(const QVector &contour, + const QVector &newPoints)const; }; #endif // VCONTAINER_H diff --git a/docs/Doxyfile b/docs/Doxyfile index f47ebdb2c..2bb9214ea 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -74,7 +74,7 @@ CREATE_SUBDIRS = NO # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. -OUTPUT_LANGUAGE = Ukrainian +OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in @@ -369,7 +369,7 @@ EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation.