New coding standart with Vera++.

--HG--
branch : develop
This commit is contained in:
dismine 2013-11-04 22:35:15 +02:00
parent 9ae8671ee4
commit 6de60a4644
187 changed files with 6296 additions and 3772 deletions

View File

@ -30,11 +30,8 @@
#define FINISHED 10 #define FINISHED 10
#define EOL 9 #define EOL 9
Calculator::Calculator(const VContainer *data):errorMsg(0), token(QString()), tok(0), token_type(0), qreal Calculator::eval(QString prog, QString *errorMsg)
prog(QString()), index(0), data(data), debugFormula(QString()){ {
}
qreal Calculator::eval(QString prog, QString *errorMsg){
this->errorMsg = errorMsg; this->errorMsg = errorMsg;
this->errorMsg->clear(); this->errorMsg->clear();
debugFormula.clear(); debugFormula.clear();
@ -48,10 +45,12 @@ qreal Calculator::eval(QString prog, QString *errorMsg){
return result; return result;
} }
qreal Calculator::get_exp(){ qreal Calculator::get_exp()
{
qreal result = 0; qreal result = 0;
get_token(); get_token();
if(token.isEmpty()) { if (token.isEmpty())
{
serror(2); serror(2);
return 0; return 0;
} }
@ -62,12 +61,14 @@ qreal Calculator::get_exp(){
} }
/* Сложение или вычитание двух термов */ /* Сложение или вычитание двух термов */
void Calculator::level2(qreal *result){ void Calculator::level2(qreal *result)
{
QChar op; QChar op;
qreal hold; qreal hold;
level3(result); level3(result);
while((op=token[0]) == '+' || op == '-') { while ((op=token[0]) == '+' || op == '-')
{
get_token(); get_token();
level3(&hold); level3(&hold);
arith(op, result, &hold); arith(op, result, &hold);
@ -75,13 +76,15 @@ void Calculator::level2(qreal *result){
} }
/* Вычисление произведения или частного двух фвкторов */ /* Вычисление произведения или частного двух фвкторов */
void Calculator::level3(qreal *result){ void Calculator::level3(qreal *result)
{
QChar op; QChar op;
qreal hold; qreal hold;
level4(result); level4(result);
while((op = token[0]) == '*' || op == '/' || op == '%') { while ((op = token[0]) == '*' || op == '/' || op == '%')
{
get_token(); get_token();
level4(&hold); level4(&hold);
arith(op, result, &hold); arith(op, result, &hold);
@ -89,11 +92,13 @@ void Calculator::level3(qreal *result){
} }
/* Обработка степени числа (целочисленной) */ /* Обработка степени числа (целочисленной) */
void Calculator::level4(qreal *result){ void Calculator::level4(qreal *result)
{
qreal hold; qreal hold;
level5(result); level5(result);
if(token[0] == '^') { if (token[0] == '^')
{
get_token(); get_token();
level4(&hold); level4(&hold);
arith('^', result, &hold); arith('^', result, &hold);
@ -101,35 +106,45 @@ void Calculator::level4(qreal *result){
} }
/* Унарный + или - */ /* Унарный + или - */
void Calculator::level5(qreal *result){ void Calculator::level5(qreal *result)
{
QChar op; QChar op;
op = '\0'; op = '\0';
if((token_type==DELIMITER) && (token[0]=='+' || token[0]=='-')) { if ((token_type==DELIMITER) && (token[0]=='+' || token[0]=='-'))
{
op = token[0]; op = token[0];
get_token(); get_token();
} }
level6(result); level6(result);
if (op != '\0') if (op != '\0')
{
unary(op, result); unary(op, result);
} }
}
/* Обработка выражения в круглых скобках */ /* Обработка выражения в круглых скобках */
void Calculator::level6(qreal *result){ void Calculator::level6(qreal *result)
if((token[0] == '(') && (token_type == DELIMITER)) { {
if ((token[0] == '(') && (token_type == DELIMITER))
{
get_token(); get_token();
level2(result); level2(result);
if (token[0] != ')') if (token[0] != ')')
{
serror(1); serror(1);
}
get_token(); get_token();
} else } else
primitive(result); primitive(result);
} }
/* Определение значения переменной по ее имени */ /* Определение значения переменной по ее имени */
void Calculator::primitive(qreal *result){ void Calculator::primitive(qreal *result)
{
QString str; QString str;
switch(token_type) { switch (token_type)
{
case VARIABLE: case VARIABLE:
*result = find_var(token); *result = find_var(token);
str = QString("%1").arg(*result, 0, 'f', 3); str = QString("%1").arg(*result, 0, 'f', 3);
@ -148,10 +163,12 @@ void Calculator::primitive(qreal *result){
} }
/* Выполнение специфицированной арифметики */ /* Выполнение специфицированной арифметики */
void Calculator::arith(QChar o, qreal *r, qreal *h){ void Calculator::arith(QChar o, qreal *r, qreal *h)
{
qreal t;//, ex; qreal t;//, ex;
switch(o.toLatin1()) { switch (o.toLatin1())
{
case '-': case '-':
*r = *r-*h; *r = *r-*h;
break; break;
@ -182,16 +199,21 @@ void Calculator::arith(QChar o, qreal *r, qreal *h){
} }
/* Изменение знака */ /* Изменение знака */
void Calculator::unary(QChar o, qreal *r){ void Calculator::unary(QChar o, qreal *r)
{
if (o=='-') if (o=='-')
{
*r = -(*r); *r = -(*r);
} }
}
/* Поиск значения переменной */ /* Поиск значения переменной */
qreal Calculator::find_var(QString s){ qreal Calculator::find_var(QString s)
{
bool ok = false; bool ok = false;
qreal value = data->FindVar(s, &ok); qreal value = data->FindVar(s, &ok);
if(!ok){ if (ok == false)
{
qDebug()<<s; qDebug()<<s;
serror(4); /* не переменная */ serror(4); /* не переменная */
return 0; return 0;
@ -200,8 +222,10 @@ qreal Calculator::find_var(QString s){
} }
/* выдать сообщение об ошибке */ /* выдать сообщение об ошибке */
void Calculator::serror(qint32 error){ void Calculator::serror(qint32 error)
QString e[]= { {
QString e[]=
{
"Синтаксическая ошибка", "Синтаксическая ошибка",
"Непарные круглые скобки", "Непарные круглые скобки",
"Это не выражение", "Это не выражение",
@ -216,7 +240,8 @@ void Calculator::serror(qint32 error){
/* Поиск соответствия внутреннего формата для /* Поиск соответствия внутреннего формата для
текущей лексемы в таблице лексем. текущей лексемы в таблице лексем.
*/ */
char Calculator::look_up(QString s){ char Calculator::look_up(QString s)
{
QString p; QString p;
/* преобразование к нижнему регистру */ /* преобразование к нижнему регистру */
@ -235,37 +260,51 @@ char Calculator::look_up(QString s){
} }
/* Возвращает "истину", если "c" разделитель */ /* Возвращает "истину", если "c" разделитель */
bool Calculator::isdelim(QChar c){ bool Calculator::isdelim(QChar c)
{
if (StrChr(" ;,+-<>/*%^=()", c) || c=='\n' || c=='\r' || c=='\0') if (StrChr(" ;,+-<>/*%^=()", c) || c=='\n' || c=='\r' || c=='\0')
{
return true; return true;
}
return false; return false;
} }
/* Возвращает 1, если "с" пробел или табуляция */ /* Возвращает 1, если "с" пробел или табуляция */
bool Calculator::iswhite(QChar c){ bool Calculator::iswhite(QChar c)
{
if (c==' ' || c=='\t') if (c==' ' || c=='\t')
{
return true; return true;
}
else else
{
return false; return false;
} }
}
void Calculator::get_token(){ void Calculator::get_token()
{
QString *temp; QString *temp;
token_type=0; tok=0; token_type=0; tok=0;
token.clear(); token.clear();
temp=&token; temp=&token;
if(prog[index]=='\0') { /* Конец файла */ if (prog[index]=='\0')
{ /* Конец файла */
token="\0"; token="\0";
tok=FINISHED; tok=FINISHED;
token_type=DELIMITER; token_type=DELIMITER;
return; return;
} }
while(iswhite(prog[index])) ++index; /* пропуск пробелов */ while (iswhite(prog[index]))
{
++index; /* пропуск пробелов */
}
if(prog[index]=='\r') { /* crtl */ if (prog[index]=='\r')
{ /* crtl */
++index; ++index; ++index; ++index;
tok= EOL; token='\r'; tok= EOL; token='\r';
token.append('\n');token.append("\0"); token.append('\n');token.append("\0");
@ -273,7 +312,8 @@ void Calculator::get_token(){
return; return;
} }
if(StrChr("+-*^/%=;(),><", prog[index])) { /* разделитель */ if (StrChr("+-*^/%=;(),><", prog[index]))
{ /* разделитель */
*temp=prog[index]; *temp=prog[index];
index++; /* переход на следующую позицию */ index++; /* переход на следующую позицию */
temp->append("\0"); temp->append("\0");
@ -281,20 +321,26 @@ void Calculator::get_token(){
debugFormula.append(token); debugFormula.append(token);
return; return;
} }
if(prog[index]=='"') { /* строка в кавычках */ if (prog[index]=='"')
{ /* строка в кавычках */
index++; index++;
while(prog[index] != '"' && prog[index] != '\r'){ while (prog[index] != '"' && prog[index] != '\r')
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
if (prog[index]=='\r') if (prog[index]=='\r')
{
serror(1); serror(1);
}
index++;temp->append("\0"); index++;temp->append("\0");
token_type=QUOTE; token_type=QUOTE;
return; return;
} }
if(prog[index].isDigit()) { /* число */ if (prog[index].isDigit())
while(!isdelim(prog[index])){ { /* число */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
@ -303,8 +349,10 @@ void Calculator::get_token(){
return; return;
} }
if(prog[index].isPrint()) { /* переменная или команда */ if (prog[index].isPrint())
while(!isdelim(prog[index])){ { /* переменная или команда */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
@ -313,22 +361,30 @@ void Calculator::get_token(){
temp->append("\0"); temp->append("\0");
/* Просматривается, если строка есть команда или переменная */ /* Просматривается, если строка есть команда или переменная */
if(token_type==STRING) { if (token_type==STRING)
{
tok=look_up(token); /* преобразование во внутренний tok=look_up(token); /* преобразование во внутренний
формат */ формат */
if(!tok) if (tok == false)
{
token_type = VARIABLE; token_type = VARIABLE;
else token_type = COMMAND; /* это команда */ }
else
{
token_type = COMMAND; /* это команда */
}
} }
return; return;
} }
bool Calculator::StrChr(QString string, QChar c){ bool Calculator::StrChr(QString string, QChar c)
{
return string.contains(c, Qt::CaseInsensitive); return string.contains(c, Qt::CaseInsensitive);
} }
/* Возвращает лексему обратно во входной поток */ /* Возвращает лексему обратно во входной поток */
void Calculator::putback(){ void Calculator::putback()
{
QString t; QString t;
t = token; t = token;
index = index - t.size(); index = index - t.size();

View File

@ -28,13 +28,15 @@
* @brief The Calculator клас калькулятора формул лекал. Виконує розрахунок формул з підставлянням * @brief The Calculator клас калькулятора формул лекал. Виконує розрахунок формул з підставлянням
* значеннь зміних. * значеннь зміних.
*/ */
class Calculator{ class Calculator
{
public: public:
/** /**
* @brief Calculator конструктор класу. Використовується при розрахунку лекала. * @brief Calculator конструктор класу. Використовується при розрахунку лекала.
* @param data покажчик на контейнер змінних * @param data покажчик на контейнер змінних
*/ */
explicit Calculator(const VContainer *data); explicit Calculator(const VContainer *data):errorMsg(0), token(QString()), tok(0), token_type(0), prog(QString()),
index(0), data(data), debugFormula(QString()){}
/** /**
* @brief eval виконує розрахунок формули. * @brief eval виконує розрахунок формули.
* @param prog рядко в якому зберігається формула. * @param prog рядко в якому зберігається формула.
@ -143,7 +145,7 @@ private:
qreal find_var(QString s); qreal find_var(QString s);
void serror(qint32 error); void serror(qint32 error);
/** /**
* @brief look_up пошук відповідного внутрішнього формату для теперішньої лексеми в таблиці лексем. текущей лексемы в таблице лексем * @brief look_up пошук відповідного внутрішнього формату для теперішньої лексеми в таблиці лексем.
* @param s ім'я лексеми. * @param s ім'я лексеми.
* @return внутрішній номер лексеми. * @return внутрішній номер лексеми.
*/ */

View File

@ -24,7 +24,8 @@
qint64 VContainer::_id = 0; qint64 VContainer::_id = 0;
VContainer::VContainer():base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()), VContainer::VContainer()
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
modelingPoints(QHash<qint64, VPointF>()), modelingPoints(QHash<qint64, VPointF>()),
standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()), standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
@ -32,18 +33,21 @@ VContainer::VContainer():base(QHash<QString, qint32>()), points(QHash<qint64, VP
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()), lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()),
lengthArcs(QHash<QString, qreal>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()), splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()),
details(QHash<qint64, VDetail>()){ details(QHash<qint64, VDetail>())
{
SetSize(500); SetSize(500);
SetGrowth(1760); SetGrowth(1760);
CreateManTableIGroup (); CreateManTableIGroup ();
} }
VContainer &VContainer::operator =(const VContainer &data){ VContainer &VContainer::operator =(const VContainer &data)
{
setData(data); setData(data);
return *this; return *this;
} }
VContainer::VContainer(const VContainer &data):base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()), VContainer::VContainer(const VContainer &data)
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
modelingPoints(QHash<qint64, VPointF>()), modelingPoints(QHash<qint64, VPointF>()),
standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()), standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
@ -51,11 +55,13 @@ VContainer::VContainer(const VContainer &data):base(QHash<QString, qint32>()), p
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()), lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()),
lengthArcs(QHash<QString, qreal>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()), splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()),
details(QHash<qint64, VDetail>()){ details(QHash<qint64, VDetail>())
{
setData(data); setData(data);
} }
void VContainer::setData(const VContainer &data){ void VContainer::setData(const VContainer &data)
{
base = *data.DataBase(); base = *data.DataBase();
points = *data.DataPoints(); points = *data.DataPoints();
modelingPoints = *data.DataModelingPoints(); modelingPoints = *data.DataModelingPoints();
@ -75,77 +81,98 @@ void VContainer::setData(const VContainer &data){
} }
template <typename key, typename val> template <typename key, typename val>
val VContainer::GetObject(const QHash<key, val> &obj, key id){ val VContainer::GetObject(const QHash<key, val> &obj, key id)
if(obj.contains(id)){ {
if (obj.contains(id))
{
return obj.value(id); return obj.value(id);
} else { }
else
{
throw VExceptionBadId(tr("Can't find object"), id); throw VExceptionBadId(tr("Can't find object"), id);
} }
} }
VStandartTableCell VContainer::GetStandartTableCell(const QString &name) const{ VStandartTableCell VContainer::GetStandartTableCell(const QString &name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(standartTable, name); return GetObject(standartTable, name);
} }
VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const{ VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(incrementTable, name); return GetObject(incrementTable, name);
} }
qreal VContainer::GetLine(const QString &name) const{ qreal VContainer::GetLine(const QString &name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(lengthLines, name); return GetObject(lengthLines, name);
} }
qreal VContainer::GetLengthArc(const QString &name) const{ qreal VContainer::GetLengthArc(const QString &name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(lengthArcs, name); return GetObject(lengthArcs, name);
} }
qreal VContainer::GetLengthSpline(const QString &name) const{ qreal VContainer::GetLengthSpline(const QString &name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(lengthSplines, name); return GetObject(lengthSplines, name);
} }
qreal VContainer::GetLineAngle(const QString &name) const{ qreal VContainer::GetLineAngle(const QString &name) const
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty()==false);
return GetObject(lineAngles, name); return GetObject(lineAngles, name);
} }
qint64 VContainer::AddPoint(const VPointF &point){ qint64 VContainer::AddPoint(const VPointF &point)
{
return AddObject(points, point); return AddObject(points, point);
} }
qint64 VContainer::AddModelingPoint(const VPointF &point){ qint64 VContainer::AddModelingPoint(const VPointF &point)
{
return AddObject(modelingPoints, point); return AddObject(modelingPoints, point);
} }
qint64 VContainer::AddDetail(const VDetail &detail){ qint64 VContainer::AddDetail(const VDetail &detail)
{
return AddObject(details, detail); return AddObject(details, detail);
} }
qint64 VContainer::getNextId(){ qint64 VContainer::getNextId()
{
_id++; _id++;
return _id; return _id;
} }
void VContainer::UpdateId(qint64 newId){ void VContainer::UpdateId(qint64 newId)
if(newId > _id){ {
if (newId > _id)
{
_id = newId; _id = newId;
} }
} }
QPainterPath VContainer::ContourPath(qint64 idDetail) const{ QPainterPath VContainer::ContourPath(qint64 idDetail) const
{
VDetail detail = GetDetail(idDetail); VDetail detail = GetDetail(idDetail);
QVector<QPointF> points; QVector<QPointF> points;
QVector<QPointF> pointsEkv; QVector<QPointF> pointsEkv;
for(qint32 i = 0; i< detail.CountNode(); ++i){ for (qint32 i = 0; i< detail.CountNode(); ++i)
switch(detail[i].getTypeTool()){ {
case(Tool::NodePoint):{ switch (detail[i].getTypeTool())
{
case (Tool::NodePoint):
{
VPointF point = GetModelingPoint(detail[i].getId()); VPointF point = GetModelingPoint(detail[i].getId());
points.append(point.toQPointF()); points.append(point.toQPointF());
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
QPointF pEkv = point.toQPointF(); QPointF pEkv = point.toQPointF();
pEkv.setX(pEkv.x()+detail[i].getMx()); pEkv.setX(pEkv.x()+detail[i].getMx());
pEkv.setY(pEkv.y()+detail[i].getMy()); pEkv.setY(pEkv.y()+detail[i].getMy());
@ -153,54 +180,71 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
} }
} }
break; break;
case(Tool::NodeArc):{ case (Tool::NodeArc):
{
VArc arc = GetModelingArc(detail[i].getId()); VArc arc = GetModelingArc(detail[i].getId());
qreal len1 = GetLengthContour(points, arc.GetPoints()); qreal len1 = GetLengthContour(points, arc.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
if(len1 <= lenReverse){ if (len1 <= lenReverse)
{
points << arc.GetPoints(); points << arc.GetPoints();
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy()); pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy());
} }
} else { }
else
{
points << GetReversePoint(arc.GetPoints()); points << GetReversePoint(arc.GetPoints());
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), {
detail[i].getMy()); pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), detail[i].getMy());
} }
} }
} }
break; break;
case(Tool::NodeSpline):{ case (Tool::NodeSpline):
{
VSpline spline = GetModelingSpline(detail[i].getId()); VSpline spline = GetModelingSpline(detail[i].getId());
qreal len1 = GetLengthContour(points, spline.GetPoints()); qreal len1 = GetLengthContour(points, spline.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
if(len1 <= lenReverse){ if (len1 <= lenReverse)
{
points << spline.GetPoints(); points << spline.GetPoints();
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy()); pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy());
} }
} else { }
else
{
points << GetReversePoint(spline.GetPoints()); points << GetReversePoint(spline.GetPoints());
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(), pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(),
detail[i].getMy()); detail[i].getMy());
} }
} }
} }
break; break;
case(Tool::NodeSplinePath):{ case (Tool::NodeSplinePath):
{
VSplinePath splinePath = GetModelingSplinePath(detail[i].getId()); VSplinePath splinePath = GetModelingSplinePath(detail[i].getId());
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints()); qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
if(len1 <= lenReverse){ if (len1 <= lenReverse)
{
points << splinePath.GetPathPoints(); points << splinePath.GetPathPoints();
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy()); pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy());
} }
} else { }
else
{
points << GetReversePoint(splinePath.GetPathPoints()); points << GetReversePoint(splinePath.GetPathPoints());
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(), pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(),
detail[i].getMy()); detail[i].getMy());
} }
@ -217,16 +261,21 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
QPainterPath path; QPainterPath path;
path.moveTo(points[0]); path.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){ for (qint32 i = 1; i < points.count(); ++i)
{
path.lineTo(points[i]); path.lineTo(points[i]);
} }
path.lineTo(points[0]); path.lineTo(points[0]);
if(detail.getSupplement() == true){ if (detail.getSupplement() == true)
{
QPainterPath ekv; QPainterPath ekv;
if(detail.getClosed() == true){ if (detail.getClosed() == true)
{
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth())); ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth()));
} else { }
else
{
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth())); ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth()));
} }
path.addPath(ekv); path.addPath(ekv);
@ -235,54 +284,71 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
return path; return path;
} }
QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const{ QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const
{
QVector<QPointF> p; QVector<QPointF> p;
for(qint32 i = 0; i < points.size(); ++i){ for (qint32 i = 0; i < points.size(); ++i)
{
QPointF point = points.at(i); QPointF point = points.at(i);
point.setX(point.x() + mx); point.setX(point.x() + mx);
point.setY(point.x() + my); point.setY(point.y() + my);
p.append(point); p.append(point);
} }
return p; return p;
} }
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width) const
const qreal &width) const{ {
QPainterPath ekv; QPainterPath ekv;
QVector<QPointF> ekvPoints; QVector<QPointF> ekvPoints;
if ( points.size() < 3 ){ if ( points.size() < 3 )
{
qDebug()<<"Not enough points for build equidistant.\n"; qDebug()<<"Not enough points for build equidistant.\n";
return ekv; return ekv;
} }
for (qint32 i = 0; i < points.size(); ++i ){ for (qint32 i = 0; i < points.size(); ++i )
if(i != points.size()-1){ {
if(points[i] == points[i+1]){ if (i != points.size()-1)
{
if (points[i] == points[i+1])
{
points.remove(i+1); points.remove(i+1);
} }
} else { }
if(points[i] == points[0]){ else
{
if (points[i] == points[0])
{
points.remove(i); points.remove(i);
} }
} }
} }
if(eqv == Detail::CloseEquidistant){ if (eqv == Detail::CloseEquidistant)
{
points.append(points.at(0)); points.append(points.at(0));
} }
for (qint32 i = 0; i < points.size(); ++i ){ for (qint32 i = 0; i < points.size(); ++i )
if ( i == 0 && eqv == Detail::CloseEquidistant){//перша точка, ламана замкнена {
ekvPoints<<EkvPoint(QLineF(points[points.size()-2], points[points.size()-1]), if ( i == 0 && eqv == Detail::CloseEquidistant)
QLineF(points[1], points[0]), width); {//перша точка, ламана замкнена
ekvPoints<<EkvPoint(QLineF(points[points.size()-2], points[points.size()-1]), QLineF(points[1], points[0]),
width);
continue; continue;
} else if(i == 0 && eqv == Detail::OpenEquidistant){//перша точка, ламана не замкнена }
else if (i == 0 && eqv == Detail::OpenEquidistant)
{//перша точка, ламана не замкнена
ekvPoints.append(SingleParallelPoint(QLineF(points[0], points[1]), 90, width)); ekvPoints.append(SingleParallelPoint(QLineF(points[0], points[1]), 90, width));
continue; continue;
} }
if(i == points.size()-1 && eqv == Detail::CloseEquidistant){//остання точка, ламана замкнена if (i == points.size()-1 && eqv == Detail::CloseEquidistant)
{//остання точка, ламана замкнена
ekvPoints.append(ekvPoints.at(0)); ekvPoints.append(ekvPoints.at(0));
continue; continue;
} else if(i == points.size()-1 && eqv == Detail::OpenEquidistant){//остання точка, ламана не замкнена }
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], else if (i == points.size()-1 && eqv == Detail::OpenEquidistant)
points[points.size()-2]), -90, width)); {//остання точка, ламана не замкнена
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], points[points.size()-2]), -90,
width));
continue; continue;
} }
//точка яка не лежить ні на початку ні в кінці //точка яка не лежить ні на початку ні в кінці
@ -290,54 +356,64 @@ QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equi
} }
ekvPoints = CheckLoops(ekvPoints); ekvPoints = CheckLoops(ekvPoints);
ekv.moveTo(ekvPoints[0]); ekv.moveTo(ekvPoints[0]);
for (qint32 i = 1; i < ekvPoints.count(); ++i){ for (qint32 i = 1; i < ekvPoints.count(); ++i)
{
ekv.lineTo(ekvPoints[i]); ekv.lineTo(ekvPoints[i]);
} }
return ekv; return ekv;
} }
QLineF VContainer::ParallelLine(const QLineF &line, qreal width){ QLineF VContainer::ParallelLine(const QLineF &line, qreal width)
{
Q_ASSERT(width > 0); Q_ASSERT(width > 0);
QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()),
SingleParallelPoint(QLineF(line.p2(), line.p1()), -90, width)); -90, width));
return paralel; return paralel;
} }
QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width){ QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width)
{
Q_ASSERT(width > 0); Q_ASSERT(width > 0);
QLineF l = line; QLineF pLine = line;
l.setAngle( l.angle() + angle ); pLine.setAngle( pLine.angle() + angle );
l.setLength( width ); pLine.setLength( width );
return l.p2(); return pLine.p2();
} }
QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const{ QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const
{
Q_ASSERT(width > 0); Q_ASSERT(width > 0);
QVector<QPointF> points; QVector<QPointF> points;
if(line1.p2() != line2.p2()){ if (line1.p2() != line2.p2())
{
qWarning()<<"Last point of two lines must be equal."; qWarning()<<"Last point of two lines must be equal.";
} }
QPointF CrosPoint; QPointF CrosPoint;
QLineF bigLine1 = ParallelLine(line1, width ); QLineF bigLine1 = ParallelLine(line1, width );
QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width ); QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width );
QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint ); QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
switch(type){ switch (type)
{
case (QLineF::BoundedIntersection): case (QLineF::BoundedIntersection):
points.append(CrosPoint); points.append(CrosPoint);
return points; return points;
break; break;
case(QLineF::UnboundedIntersection):{ case (QLineF::UnboundedIntersection):
{
QLineF line( line1.p2(), CrosPoint ); QLineF line( line1.p2(), CrosPoint );
if(line.length() > width + toPixel(8)){ if (line.length() > width + toPixel(8))
QLineF l; {
l = QLineF(bigLine1.p2(), CrosPoint); QLineF lineL;
l.setLength(width); lineL = QLineF(bigLine1.p2(), CrosPoint);
points.append(l.p2()); lineL.setLength(width);
points.append(lineL.p2());
l = QLineF(bigLine2.p1(), CrosPoint); lineL = QLineF(bigLine2.p1(), CrosPoint);
l.setLength(width); lineL.setLength(width);
points.append(l.p2()); points.append(lineL.p2());
} else { }
else
{
points.append(CrosPoint); points.append(CrosPoint);
return points; return points;
} }
@ -352,45 +428,58 @@ QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2,
return points; return points;
} }
QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const{ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
{
QVector<QPointF> ekvPoints; QVector<QPointF> ekvPoints;
/*If we got less than 4 points no need seek loops.*/ /*If we got less than 4 points no need seek loops.*/
if(points.size() < 4){ if (points.size() < 4)
{
return ekvPoints; return ekvPoints;
} }
bool closed = false; bool closed = false;
if(points.at(0) == points.at(points.size()-1)){ if (points.at(0) == points.at(points.size()-1))
{
closed = true; closed = true;
} }
qint32 i, j; qint32 i, j;
for(i = 0; i < points.size(); ++i){ for (i = 0; i < points.size(); ++i)
{
/*Last three points no need check.*/ /*Last three points no need check.*/
if(i >= points.size()-3){ if (i >= points.size()-3)
{
ekvPoints.append(points.at(i)); ekvPoints.append(points.at(i));
continue; continue;
} }
QPointF crosPoint; QPointF crosPoint;
QLineF::IntersectType intersect = QLineF::NoIntersection; QLineF::IntersectType intersect = QLineF::NoIntersection;
QLineF line1(points.at(i), points.at(i+1)); QLineF line1(points.at(i), points.at(i+1));
for(j = i+2; j < points.size()-1; ++j){ for (j = i+2; j < points.size()-1; ++j)
{
QLineF line2(points.at(j), points.at(j+1)); QLineF line2(points.at(j), points.at(j+1));
intersect = line1.intersect(line2, &crosPoint); intersect = line1.intersect(line2, &crosPoint);
if(intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::BoundedIntersection)
{
break; break;
} }
} }
if(intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::BoundedIntersection)
if(i == 0 && j+1 == points.size()-1 && closed){ {
if (i == 0 && j+1 == points.size()-1 && closed)
{
/*We got closed contour.*/ /*We got closed contour.*/
ekvPoints.append(points.at(i)); ekvPoints.append(points.at(i));
} else { }
else
{
/*We found loop.*/ /*We found loop.*/
ekvPoints.append(points.at(i)); ekvPoints.append(points.at(i));
ekvPoints.append(crosPoint); ekvPoints.append(crosPoint);
ekvPoints.append(points.at(j+1)); ekvPoints.append(points.at(j+1));
i = j + 2; i = j + 2;
} }
} else { }
else
{
/*We did not found loop.*/ /*We did not found loop.*/
ekvPoints.append(points.at(i)); ekvPoints.append(points.at(i));
} }
@ -398,41 +487,49 @@ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const{
return ekvPoints; return ekvPoints;
} }
void VContainer::PrepareDetails(QVector<VItem *> &list) const{ void VContainer::PrepareDetails(QVector<VItem *> &list) const
{
QHashIterator<qint64, VDetail> iDetail(details); QHashIterator<qint64, VDetail> iDetail(details);
while (iDetail.hasNext()) { while (iDetail.hasNext())
{
iDetail.next(); iDetail.next();
list.append(new VItem(ContourPath(iDetail.key()), list.size())); list.append(new VItem(ContourPath(iDetail.key()), list.size()));
} }
} }
template <typename val> template <typename val>
void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point){ void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point)
{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
obj[id] = point; obj[id] = point;
UpdateId(id); UpdateId(id);
} }
void VContainer::AddLengthSpline(const QString &name, const qreal &value){ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty() == false);
lengthSplines[name] = value; lengthSplines[name] = value;
} }
void VContainer::AddLengthArc(const qint64 &center, const qint64 &id){ void VContainer::AddLengthArc(const qint64 &center, const qint64 &id)
{
AddLengthArc(GetNameArc(center, id), toMM(GetArc(id).GetLength())); AddLengthArc(GetNameArc(center, id), toMM(GetArc(id).GetLength()));
} }
void VContainer::AddLengthArc(const QString &name, const qreal &value){ void VContainer::AddLengthArc(const QString &name, const qreal &value)
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty() == false);
lengthArcs[name] = value; lengthArcs[name] = value;
} }
void VContainer::AddLineAngle(const QString &name, const qreal &value){ void VContainer::AddLineAngle(const QString &name, const qreal &value)
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty() == false);
lineAngles[name] = value; lineAngles[name] = value;
} }
qreal VContainer::GetValueStandartTableCell(const QString& name) const{ qreal VContainer::GetValueStandartTableCell(const QString& name) const
{
VStandartTableCell cell = GetStandartTableCell(name); VStandartTableCell cell = GetStandartTableCell(name);
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0; qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0; qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
@ -440,7 +537,8 @@ qreal VContainer::GetValueStandartTableCell(const QString& name) const{
return value; return value;
} }
qreal VContainer::GetValueIncrementTableRow(const QString& name) const{ qreal VContainer::GetValueIncrementTableRow(const QString& name) const
{
VIncrementTableRow cell = GetIncrementTableRow(name); VIncrementTableRow cell = GetIncrementTableRow(name);
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0; qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0; qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
@ -448,7 +546,8 @@ qreal VContainer::GetValueIncrementTableRow(const QString& name) const{
return value; return value;
} }
void VContainer::Clear(){ void VContainer::Clear()
{
_id = 0; _id = 0;
standartTable.clear(); standartTable.clear();
incrementTable.clear(); incrementTable.clear();
@ -464,40 +563,49 @@ void VContainer::Clear(){
CreateManTableIGroup (); CreateManTableIGroup ();
} }
void VContainer::ClearObject(){ void VContainer::ClearObject()
{
points.clear(); points.clear();
splines.clear(); splines.clear();
arcs.clear(); arcs.clear();
splinePaths.clear(); splinePaths.clear();
} }
qreal VContainer::FindVar(const QString &name, bool *ok)const{ qreal VContainer::FindVar(const QString &name, bool *ok)const
if(base.contains(name)){ {
if (base.contains(name))
{
*ok = true; *ok = true;
return base.value(name); return base.value(name);
} }
if(standartTable.contains(name)){ if (standartTable.contains(name))
{
*ok = true; *ok = true;
return GetValueStandartTableCell(name); return GetValueStandartTableCell(name);
} }
if(incrementTable.contains(name)){ if (incrementTable.contains(name))
{
*ok = true; *ok = true;
return GetValueIncrementTableRow(name); return GetValueIncrementTableRow(name);
} }
if(lengthLines.contains(name)){ if (lengthLines.contains(name))
{
*ok = true; *ok = true;
return lengthLines.value(name); return lengthLines.value(name);
} }
if(lengthArcs.contains(name)){ if (lengthArcs.contains(name))
{
*ok = true; *ok = true;
return lengthArcs.value(name); return lengthArcs.value(name);
} }
if(lineAngles.contains(name)){ if (lineAngles.contains(name))
{
*ok = true; *ok = true;
return lineAngles.value(name); return lineAngles.value(name);
} }
if(lengthSplines.contains(name)){ if (lengthSplines.contains(name))
{
*ok = true; *ok = true;
return lengthSplines.value(name); return lengthSplines.value(name);
} }
@ -505,14 +613,18 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const{
return 0; return 0;
} }
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Draws mode){ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Draws mode)
{
QString nameLine = GetNameLine(firstPointId, secondPointId, mode); QString nameLine = GetNameLine(firstPointId, secondPointId, mode);
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
first = GetPoint(firstPointId); first = GetPoint(firstPointId);
second = GetPoint(secondPointId); second = GetPoint(secondPointId);
} else { }
else
{
first = GetModelingPoint(firstPointId); first = GetModelingPoint(firstPointId);
second = GetModelingPoint(secondPointId); second = GetModelingPoint(secondPointId);
} }
@ -521,91 +633,114 @@ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId
AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle()); AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
} }
qint64 VContainer::AddSpline(const VSpline &spl){ qint64 VContainer::AddSpline(const VSpline &spl)
{
return AddObject(splines, spl); return AddObject(splines, spl);
} }
qint64 VContainer::AddModelingSpline(const VSpline &spl){ qint64 VContainer::AddModelingSpline(const VSpline &spl)
{
return AddObject(modelingSplines, spl); return AddObject(modelingSplines, spl);
} }
qint64 VContainer::AddSplinePath(const VSplinePath &splPath){ qint64 VContainer::AddSplinePath(const VSplinePath &splPath)
{
return AddObject(splinePaths, splPath); return AddObject(splinePaths, splPath);
} }
qint64 VContainer::AddModelingSplinePath(const VSplinePath &splPath){ qint64 VContainer::AddModelingSplinePath(const VSplinePath &splPath)
{
return AddObject(modelingSplinePaths, splPath); return AddObject(modelingSplinePaths, splPath);
} }
qint64 VContainer::AddArc(const VArc &arc){ qint64 VContainer::AddArc(const VArc &arc)
{
return AddObject(arcs, arc); return AddObject(arcs, arc);
} }
qint64 VContainer::AddModelingArc(const VArc &arc){ qint64 VContainer::AddModelingArc(const VArc &arc)
{
return AddObject(modelingArcs, arc); return AddObject(modelingArcs, arc);
} }
template <typename key, typename val> template <typename key, typename val>
qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value){ qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value)
{
qint64 id = getNextId(); qint64 id = getNextId();
obj[id] = value; obj[id] = value;
return id; return id;
} }
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Draws mode) const{ QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Draws mode) const
{
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
first = GetPoint(firstPoint); first = GetPoint(firstPoint);
second = GetPoint(secondPoint); second = GetPoint(secondPoint);
} else { }
else
{
first = GetModelingPoint(firstPoint); first = GetModelingPoint(firstPoint);
second = GetModelingPoint(secondPoint); second = GetModelingPoint(secondPoint);
} }
return QString("Line_%1_%2").arg(first.name(), second.name()); return QString("Line_%1_%2").arg(first.name(), second.name());
} }
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Draws mode) const
Draw::Draws mode) const{ {
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
first = GetPoint(firstPoint); first = GetPoint(firstPoint);
second = GetPoint(secondPoint); second = GetPoint(secondPoint);
} else { }
else
{
first = GetModelingPoint(firstPoint); first = GetModelingPoint(firstPoint);
second = GetModelingPoint(secondPoint); second = GetModelingPoint(secondPoint);
} }
return QString("AngleLine_%1_%2").arg(first.name(), second.name()); return QString("AngleLine_%1_%2").arg(first.name(), second.name());
} }
QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Draws mode) const
Draw::Draws mode) const{ {
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
first = GetPoint(firstPoint); first = GetPoint(firstPoint);
second = GetPoint(secondPoint); second = GetPoint(secondPoint);
} else { }
else
{
first = GetModelingPoint(firstPoint); first = GetModelingPoint(firstPoint);
second = GetModelingPoint(secondPoint); second = GetModelingPoint(secondPoint);
} }
return QString("Spl_%1_%2").arg(first.name(), second.name()); return QString("Spl_%1_%2").arg(first.name(), second.name());
} }
QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Draws mode) const{ QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Draws mode) const
if(path.Count() == 0){ {
if (path.Count() == 0)
{
return QString(); return QString();
} }
QString name("SplPath"); QString name("SplPath");
for(qint32 i = 1; i <= path.Count(); ++i){ for (qint32 i = 1; i <= path.Count(); ++i)
{
VSpline spl = path.GetSpline(i); VSpline spl = path.GetSpline(i);
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
first = GetPoint(spl.GetP1()); first = GetPoint(spl.GetP1());
second = GetPoint(spl.GetP4()); second = GetPoint(spl.GetP4());
} else { }
else
{
first = GetModelingPoint(spl.GetP1()); first = GetModelingPoint(spl.GetP1());
second = GetModelingPoint(spl.GetP4()); second = GetModelingPoint(spl.GetP4());
} }
@ -615,58 +750,73 @@ QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Draws mode)
return name; return name;
} }
QString VContainer::GetNameArc(const qint64 &center, const qint64 &id, Draw::Draws mode) const{ QString VContainer::GetNameArc(const qint64 &center, const qint64 &id, Draw::Draws mode) const
{
VPointF centerPoint; VPointF centerPoint;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
centerPoint = GetPoint(center); centerPoint = GetPoint(center);
} else { }
else
{
centerPoint = GetModelingPoint(center); centerPoint = GetModelingPoint(center);
} }
return QString ("Arc_%1_%2").arg(centerPoint.name()).arg(id); return QString ("Arc_%1_%2").arg(centerPoint.name()).arg(id);
} }
void VContainer::UpdatePoint(qint64 id, const VPointF &point){ void VContainer::UpdatePoint(qint64 id, const VPointF &point)
{
UpdateObject(points, id, point); UpdateObject(points, id, point);
} }
void VContainer::UpdateModelingPoint(qint64 id, const VPointF &point){ void VContainer::UpdateModelingPoint(qint64 id, const VPointF &point)
{
UpdateObject(modelingPoints, id, point); UpdateObject(modelingPoints, id, point);
} }
void VContainer::UpdateDetail(qint64 id, const VDetail &detail){ void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
{
UpdateObject(details, id, detail); UpdateObject(details, id, detail);
} }
void VContainer::UpdateSpline(qint64 id, const VSpline &spl){ void VContainer::UpdateSpline(qint64 id, const VSpline &spl)
{
UpdateObject(splines, id, spl); UpdateObject(splines, id, spl);
} }
void VContainer::UpdateModelingSpline(qint64 id, const VSpline &spl){ void VContainer::UpdateModelingSpline(qint64 id, const VSpline &spl)
{
UpdateObject(modelingSplines, id, spl); UpdateObject(modelingSplines, id, spl);
} }
void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath){ void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath)
{
UpdateObject(splinePaths, id, splPath); UpdateObject(splinePaths, id, splPath);
} }
void VContainer::UpdateModelingSplinePath(qint64 id, const VSplinePath &splPath){ void VContainer::UpdateModelingSplinePath(qint64 id, const VSplinePath &splPath)
{
UpdateObject(modelingSplinePaths, id, splPath); UpdateObject(modelingSplinePaths, id, splPath);
} }
void VContainer::UpdateArc(qint64 id, const VArc &arc){ void VContainer::UpdateArc(qint64 id, const VArc &arc)
{
UpdateObject(arcs, id, arc); UpdateObject(arcs, id, arc);
} }
void VContainer::UpdateModelingArc(qint64 id, const VArc &arc){ void VContainer::UpdateModelingArc(qint64 id, const VArc &arc)
{
UpdateObject(modelingArcs, id, arc); UpdateObject(modelingArcs, id, arc);
} }
void VContainer::AddLengthLine(const QString &name, const qreal &value){ void VContainer::AddLengthLine(const QString &name, const qreal &value)
Q_ASSERT(!name.isEmpty()); {
Q_ASSERT(name.isEmpty() == false);
lengthLines[name] = value; lengthLines[name] = value;
} }
void VContainer::CreateManTableIGroup (){ void VContainer::CreateManTableIGroup ()
{
AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3)); AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3));
AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3)); AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3));
AddStandartTableCell("Vtos", VStandartTableCell(1450, 2, 51)); AddStandartTableCell("Vtos", VStandartTableCell(1450, 2, 51));
@ -723,20 +873,24 @@ void VContainer::CreateManTableIGroup (){
AddStandartTableCell("Sb", VStandartTableCell(504, 15, 4)); AddStandartTableCell("Sb", VStandartTableCell(504, 15, 4));
} }
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const{ QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const
{
Q_ASSERT(points.size() > 0); Q_ASSERT(points.size() > 0);
QVector<QPointF> reversePoints; QVector<QPointF> reversePoints;
for (qint32 i = points.size() - 1; i >= 0; --i) { for (qint32 i = points.size() - 1; i >= 0; --i)
{
reversePoints.append(points.at(i)); reversePoints.append(points.at(i));
} }
return reversePoints; return reversePoints;
} }
qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints) const{ qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints) const
{
qreal length = 0; qreal length = 0;
QVector<QPointF> points; QVector<QPointF> points;
points << contour << newPoints; points << contour << newPoints;
for (qint32 i = 0; i < points.size()-1; ++i) { for (qint32 i = 0; i < points.size()-1; ++i)
{
QLineF line(points.at(i), points.at(i+1)); QLineF line(points.at(i), points.at(i+1));
length += line.length(); length += line.length();
} }

View File

@ -32,7 +32,8 @@
/** /**
* @brief The VContainer class * @brief The VContainer class
*/ */
class VContainer{ class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer) Q_DECLARE_TR_FUNCTIONS(VContainer)
public: public:
/** /**

View File

@ -21,12 +21,8 @@
#include "vincrementtablerow.h" #include "vincrementtablerow.h"
VIncrementTableRow::VIncrementTableRow():id(0), base(0), ksize(0), kgrowth(0), description(QString()){ VIncrementTableRow::VIncrementTableRow()
} :id(0), base(0), ksize(0), kgrowth(0), description(QString()){}
VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,
QString description):id(id), base(base), ksize(ksize),
kgrowth(kgrowth), description(description){
}
VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, QString description)
:id(id), base(base), ksize(ksize), kgrowth(kgrowth), description(description){}

View File

@ -22,7 +22,8 @@
#ifndef VINCREMENTTABLEROW_H #ifndef VINCREMENTTABLEROW_H
#define VINCREMENTTABLEROW_H #define VINCREMENTTABLEROW_H
class VIncrementTableRow{ class VIncrementTableRow
{
public: public:
VIncrementTableRow(); VIncrementTableRow();
VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,

View File

@ -21,7 +21,8 @@
#include "vpointf.h" #include "vpointf.h"
VPointF &VPointF::operator =(const VPointF &point){ VPointF &VPointF::operator =(const VPointF &point)
{
_name = point.name(); _name = point.name();
_mx = point.mx(); _mx = point.mx();
_my = point.my(); _my = point.my();

View File

@ -22,7 +22,8 @@
#ifndef VPOINTF_H #ifndef VPOINTF_H
#define VPOINTF_H #define VPOINTF_H
class VPointF{ class VPointF
{
public: public:
inline VPointF () inline VPointF ()
:_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){} :_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){}

View File

@ -21,9 +21,8 @@
#include "vstandarttablecell.h" #include "vstandarttablecell.h"
VStandartTableCell::VStandartTableCell():base(0), ksize(0), kgrowth(0), description(QString()){ VStandartTableCell::VStandartTableCell()
} :base(0), ksize(0), kgrowth(0), description(QString()){}
VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description):base(base), VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description)
ksize(ksize), kgrowth(kgrowth), description(description){ :base(base), ksize(ksize), kgrowth(kgrowth), description(description){}
}

View File

@ -22,7 +22,8 @@
#ifndef VSTANDARTTABLECELL_H #ifndef VSTANDARTTABLECELL_H
#define VSTANDARTTABLECELL_H #define VSTANDARTTABLECELL_H
class VStandartTableCell{ class VStandartTableCell
{
public: public:
VStandartTableCell(); VStandartTableCell();
VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString()); VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString());

View File

@ -22,9 +22,10 @@
#include "dialogalongline.h" #include "dialogalongline.h"
#include "ui_dialogalongline.h" #include "ui_dialogalongline.h"
DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
listWidget = ui->listWidget; listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
@ -66,53 +67,69 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged);
} }
DialogAlongLine::~DialogAlongLine(){ DialogAlongLine::~DialogAlongLine()
{
delete ui; delete ui;
} }
void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogAlongLine::DialogAccepted(){ void DialogAlongLine::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -121,25 +138,30 @@ void DialogAlongLine::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id){ void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id){ void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
void DialogAlongLine::setFormula(const QString &value){ void DialogAlongLine::setFormula(const QString &value)
{
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
void DialogAlongLine::setTypeLine(const QString &value){ void DialogAlongLine::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogAlongLine::setPointName(const QString &value){ void DialogAlongLine::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -24,11 +24,13 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogAlongLine; class DialogAlongLine;
} }
class DialogAlongLine : public DialogTool{ class DialogAlongLine : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,

View File

@ -22,9 +22,10 @@
#include "dialogarc.h" #include "dialogarc.h"
#include "ui_dialogarc.h" #include "ui_dialogarc.h"
DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), :DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){ timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString())
{
ui->setupUi(this); ui->setupUi(this);
timerRadius = new QTimer(this); timerRadius = new QTimer(this);
@ -77,47 +78,61 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed); connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed);
} }
DialogArc::~DialogArc(){ DialogArc::~DialogArc()
{
delete ui; delete ui;
} }
void DialogArc::SetCenter(const qint64 &value){ void DialogArc::SetCenter(const qint64 &value)
{
center = value; center = value;
ChangeCurrentData(ui->comboBoxBasePoint, center); ChangeCurrentData(ui->comboBoxBasePoint, center);
} }
void DialogArc::SetF2(const QString &value){ void DialogArc::SetF2(const QString &value)
{
f2 = value; f2 = value;
ui->lineEditF2->setText(f2); ui->lineEditF2->setText(f2);
} }
void DialogArc::SetF1(const QString &value){ void DialogArc::SetF1(const QString &value)
{
f1 = value; f1 = value;
ui->lineEditF1->setText(f1); ui->lineEditF1->setText(f1);
} }
void DialogArc::SetRadius(const QString &value){ void DialogArc::SetRadius(const QString &value)
{
radius = value; radius = value;
ui->lineEditRadius->setText(radius); ui->lineEditRadius->setText(radius);
} }
void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id)==false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
ChangeCurrentText(ui->comboBoxBasePoint, point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
@ -126,7 +141,8 @@ void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogArc::DialogAccepted(){ void DialogArc::DialogAccepted()
{
radius = ui->lineEditRadius->text(); radius = ui->lineEditRadius->text();
f1 = ui->lineEditF1->text(); f1 = ui->lineEditF1->text();
f2 = ui->lineEditF2->text(); f2 = ui->lineEditF2->text();
@ -134,12 +150,15 @@ void DialogArc::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogArc::ValChenged(int row){ void DialogArc::ValChenged(int row)
if(ui->listWidget->count() == 0){ {
if (ui->listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
if(ui->radioButtonLineAngles->isChecked()){ if (ui->radioButtonLineAngles->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineAngle(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineAngle(item->text()))
.arg(tr("Value angle of line.")); .arg(tr("Value angle of line."));
ui->labelDescription->setText(desc); ui->labelDescription->setText(desc);
@ -148,65 +167,78 @@ void DialogArc::ValChenged(int row){
DialogTool::ValChenged(row); DialogTool::ValChenged(row);
} }
void DialogArc::PutRadius(){ void DialogArc::PutRadius()
{
PutValHere(ui->lineEditRadius, ui->listWidget); PutValHere(ui->lineEditRadius, ui->listWidget);
} }
void DialogArc::PutF1(){ void DialogArc::PutF1()
{
PutValHere(ui->lineEditF1, ui->listWidget); PutValHere(ui->lineEditF1, ui->listWidget);
} }
void DialogArc::PutF2(){ void DialogArc::PutF2()
{
PutValHere(ui->lineEditF2, ui->listWidget); PutValHere(ui->lineEditF2, ui->listWidget);
} }
void DialogArc::LineAngles(){ void DialogArc::LineAngles()
{
ShowLineAngles(); ShowLineAngles();
} }
void DialogArc::RadiusChanged(){ void DialogArc::RadiusChanged()
{
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius); ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius);
} }
void DialogArc::F1Changed(){ void DialogArc::F1Changed()
{
labelEditFormula = ui->labelEditF1; labelEditFormula = ui->labelEditF1;
ValFormulaChanged(flagF1, ui->lineEditF1, timerF1); ValFormulaChanged(flagF1, ui->lineEditF1, timerF1);
} }
void DialogArc::F2Changed(){ void DialogArc::F2Changed()
{
labelEditFormula = ui->labelEditF2; labelEditFormula = ui->labelEditF2;
ValFormulaChanged(flagF2, ui->lineEditF2, timerF2); ValFormulaChanged(flagF2, ui->lineEditF2, timerF2);
} }
void DialogArc::CheckState(){ void DialogArc::CheckState()
{
Q_ASSERT(bOk != 0); Q_ASSERT(bOk != 0);
bOk->setEnabled(flagRadius && flagF1 && flagF2); bOk->setEnabled(flagRadius && flagF1 && flagF2);
} }
void DialogArc::EvalRadius(){ void DialogArc::EvalRadius()
{
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius); Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius);
} }
void DialogArc::EvalF1(){ void DialogArc::EvalF1()
{
labelEditFormula = ui->labelEditF1; labelEditFormula = ui->labelEditF1;
Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1); Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1);
} }
void DialogArc::EvalF2(){ void DialogArc::EvalF2()
{
labelEditFormula = ui->labelEditF2; labelEditFormula = ui->labelEditF2;
Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2); Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2);
} }
void DialogArc::ShowLineAngles(){ void DialogArc::ShowLineAngles()
{
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ui->listWidget->clear(); ui->listWidget->clear();
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
const QHash<QString, qreal> *lineAnglesTable = data->DataLineAngles(); const QHash<QString, qreal> *lineAnglesTable = data->DataLineAngles();
Q_ASSERT(lineAnglesTable != 0); Q_ASSERT(lineAnglesTable != 0);
QHashIterator<QString, qreal> i(*lineAnglesTable); QHashIterator<QString, qreal> i(*lineAnglesTable);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
QListWidgetItem *item = new QListWidgetItem(i.key()); QListWidgetItem *item = new QListWidgetItem(i.key());

View File

@ -24,11 +24,13 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogArc; class DialogArc;
} }
class DialogArc : public DialogTool{ class DialogArc : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);

View File

@ -22,9 +22,10 @@
#include "dialogbisector.h" #include "dialogbisector.h"
#include "ui_dialogbisector.h" #include "ui_dialogbisector.h"
DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
listWidget = ui->listWidget; listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
@ -66,89 +67,113 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged);
} }
DialogBisector::~DialogBisector(){ DialogBisector::~DialogBisector()
{
delete ui; delete ui;
} }
void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of angle")); emit ToolTip(tr("Select second point of angle"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select third point of angle")); emit ToolTip(tr("Select third point of angle"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxThirdPoint->findText(point.name()); qint32 index = ui->comboBoxThirdPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxThirdPoint->setCurrentIndex(index); ui->comboBoxThirdPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogBisector::setPointName(const QString &value){ void DialogBisector::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
void DialogBisector::setTypeLine(const QString &value){ void DialogBisector::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogBisector::setFormula(const QString &value){ void DialogBisector::setFormula(const QString &value)
{
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id){ void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id){ void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
void DialogBisector::setThirdPointId(const qint64 &value, const qint64 &id){ void DialogBisector::setThirdPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxThirdPoint, thirdPointId, value, id); setCurrentPointId(ui->comboBoxThirdPoint, thirdPointId, value, id);
} }
void DialogBisector::DialogAccepted(){ void DialogBisector::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();

View File

@ -24,13 +24,14 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogBisector; class DialogBisector;
} }
class DialogBisector : public DialogTool{ class DialogBisector : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation, explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);

View File

@ -21,8 +21,9 @@
#include "dialogdetail.h" #include "dialogdetail.h"
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true){ :DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true)
{
ui.setupUi(this); ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail; labelEditNamePoint = ui.labelEditNameDetail;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok); bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
@ -42,20 +43,27 @@ DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *pa
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged); connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
} }
void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type != Scene::Line && type != Scene::Detail){ if (type != Scene::Line && type != Scene::Detail)
switch(type){ {
switch (type)
{
case (Scene::Arc): case (Scene::Arc):
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour); NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
break; break;
@ -76,9 +84,11 @@ void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogDetail::DialogAccepted(){ void DialogDetail::DialogAccepted()
{
details.Clear(); details.Clear();
for(qint32 i = 0; i < ui.listWidget->count(); ++i){ for (qint32 i = 0; i < ui.listWidget->count(); ++i)
{
QListWidgetItem *item = ui.listWidget->item(i); QListWidgetItem *item = ui.listWidget->item(i);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole))); details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
} }
@ -90,45 +100,63 @@ void DialogDetail::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, qreal mx, void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal my){ qreal mx, qreal my)
{
QString name; QString name;
switch(typeTool){ switch (typeTool)
case(Tool::NodePoint):{ {
case (Tool::NodePoint):
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
name = point.name(); name = point.name();
break; break;
} }
case(Tool::NodeArc):{ case (Tool::NodeArc):
{
VArc arc; VArc arc;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
arc = data->GetArc(id); arc = data->GetArc(id);
} else { }
else
{
arc = data->GetModelingArc(id); arc = data->GetModelingArc(id);
} }
name = data->GetNameArc(arc.GetCenter(), id, mode); name = data->GetNameArc(arc.GetCenter(), id, mode);
break; break;
} }
case(Tool::NodeSpline):{ case (Tool::NodeSpline):
{
VSpline spl; VSpline spl;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
spl = data->GetSpline(id); spl = data->GetSpline(id);
} else { }
else
{
spl = data->GetModelingSpline(id); spl = data->GetModelingSpline(id);
} }
name = spl.GetName(); name = spl.GetName();
break; break;
} }
case(Tool::NodeSplinePath):{ case (Tool::NodeSplinePath):
{
VSplinePath splPath; VSplinePath splPath;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id); splPath = data->GetSplinePath(id);
} else { }
else
{
splPath = data->GetModelingSplinePath(id); splPath = data->GetModelingSplinePath(id);
} }
name = data->GetNameSplinePath(splPath, mode); name = data->GetNameSplinePath(splPath, mode);
@ -156,12 +184,14 @@ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, No
this, &DialogDetail::BiasYChanged); this, &DialogDetail::BiasYChanged);
} }
void DialogDetail::setDetails(const VDetail &value){ void DialogDetail::setDetails(const VDetail &value)
{
details = value; details = value;
ui.listWidget->clear(); ui.listWidget->clear();
for(qint32 i = 0; i < details.CountNode(); ++i){ for (qint32 i = 0; i < details.CountNode(); ++i)
NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getMode(), details[i].getTypeNode(), details[i].getMx(), {
details[i].getMy()); NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getMode(), details[i].getTypeNode(),
details[i].getMx(), details[i].getMy());
} }
ui.lineEditNameDetail->setText(details.getName()); ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement()); ui.checkBoxSeams->setChecked(details.getSupplement());
@ -171,7 +201,8 @@ void DialogDetail::setDetails(const VDetail &value){
ui.listWidget->setFocus(Qt::OtherFocusReason); ui.listWidget->setFocus(Qt::OtherFocusReason);
} }
void DialogDetail::BiasXChanged(qreal d){ void DialogDetail::BiasXChanged(qreal d)
{
qint32 row = ui.listWidget->currentRow(); qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row ); QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)); VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
@ -179,7 +210,8 @@ void DialogDetail::BiasXChanged(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(node)); item->setData(Qt::UserRole, QVariant::fromValue(node));
} }
void DialogDetail::BiasYChanged(qreal d){ void DialogDetail::BiasYChanged(qreal d)
{
qint32 row = ui.listWidget->currentRow(); qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row ); QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)); VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
@ -187,18 +219,22 @@ void DialogDetail::BiasYChanged(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(node)); item->setData(Qt::UserRole, QVariant::fromValue(node));
} }
void DialogDetail::ClickedSeams(bool checked){ void DialogDetail::ClickedSeams(bool checked)
{
supplement = checked; supplement = checked;
ui.checkBoxClosed->setEnabled(checked); ui.checkBoxClosed->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked); ui.doubleSpinBoxSeams->setEnabled(checked);
} }
void DialogDetail::ClickedClosed(bool checked){ void DialogDetail::ClickedClosed(bool checked)
{
closed = checked; closed = checked;
} }
void DialogDetail::ObjectChanged(int row){ void DialogDetail::ObjectChanged(int row)
if(ui.listWidget->count() == 0){ {
if (ui.listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = ui.listWidget->item( row ); QListWidgetItem *item = ui.listWidget->item( row );

View File

@ -25,7 +25,8 @@
#include "ui_dialogdetail.h" #include "ui_dialogdetail.h"
#include "dialogtool.h" #include "dialogtool.h"
class DialogDetail : public DialogTool{ class DialogDetail : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0); DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
@ -44,8 +45,8 @@ private:
VDetail details; VDetail details;
bool supplement; bool supplement;
bool closed; bool closed;
void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, qreal mx = 0, void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal my = 0); qreal mx = 0, qreal my = 0);
}; };
#endif // DIALOGDETAIL_H #endif // DIALOGDETAIL_H

View File

@ -22,9 +22,10 @@
#include "dialogendline.h" #include "dialogendline.h"
#include "ui_dialogendline.h" #include "ui_dialogendline.h"
DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), basePointId(0){ formula(QString()), angle(0), basePointId(0)
{
ui->setupUi(this); ui->setupUi(this);
spinBoxAngle = ui->doubleSpinBoxAngle; spinBoxAngle = ui->doubleSpinBoxAngle;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -81,23 +82,32 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged);
} }
void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
ChangeCurrentText(ui->comboBoxBasePoint, point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
@ -106,31 +116,37 @@ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogEndLine::setPointName(const QString &value){ void DialogEndLine::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
void DialogEndLine::setTypeLine(const QString &value){ void DialogEndLine::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogEndLine::setFormula(const QString &value){ void DialogEndLine::setFormula(const QString &value)
{
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
void DialogEndLine::setAngle(const qreal &value){ void DialogEndLine::setAngle(const qreal &value)
{
angle = value; angle = value;
ui->doubleSpinBoxAngle->setValue(angle); ui->doubleSpinBoxAngle->setValue(angle);
} }
void DialogEndLine::setBasePointId(const qint64 &value, const qint64 &id){ void DialogEndLine::setBasePointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id); setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id);
} }
void DialogEndLine::DialogAccepted(){ void DialogEndLine::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -139,6 +155,7 @@ void DialogEndLine::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
DialogEndLine::~DialogEndLine(){ DialogEndLine::~DialogEndLine()
{
delete ui; delete ui;
} }

View File

@ -24,15 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogEndLine; class DialogEndLine;
} }
class DialogEndLine : public DialogTool{ class DialogEndLine : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogEndLine(); ~DialogEndLine();
inline QString getPointName() const {return pointName;} inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);

View File

@ -1,9 +1,10 @@
#include "dialogheight.h" #include "dialogheight.h"
#include "ui_dialogheight.h" #include "ui_dialogheight.h"
DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0){ typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0)
{
ui->setupUi(this); ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -19,55 +20,71 @@ DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *pa
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
} }
DialogHeight::~DialogHeight(){ DialogHeight::~DialogHeight()
{
delete ui; delete ui;
} }
void DialogHeight::setPointName(const QString &value){ void DialogHeight::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
void DialogHeight::setTypeLine(const QString &value){ void DialogHeight::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogHeight::setBasePointId(const qint64 &value, const qint64 &id){ void DialogHeight::setBasePointId(const qint64 &value, const qint64 &id)
{
basePointId = value; basePointId = value;
setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id); setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id);
} }
void DialogHeight::setP1LineId(const qint64 &value, const qint64 &id){ void DialogHeight::setP1LineId(const qint64 &value, const qint64 &id)
{
p1LineId = value; p1LineId = value;
setCurrentPointId(ui->comboBoxP1Line, p1LineId, value, id); setCurrentPointId(ui->comboBoxP1Line, p1LineId, value, id);
} }
void DialogHeight::setP2LineId(const qint64 &value, const qint64 &id){ void DialogHeight::setP2LineId(const qint64 &value, const qint64 &id)
{
p2LineId = value; p2LineId = value;
setCurrentPointId(ui->comboBoxP2Line, p2LineId, value, id); setCurrentPointId(ui->comboBoxP2Line, p2LineId, value, id);
} }
void DialogHeight::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogHeight::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
switch(number){ switch (number)
{
case (0): case (0):
ChangeCurrentText(ui->comboBoxBasePoint, point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
number++; number++;
@ -82,7 +99,8 @@ void DialogHeight::ChoosedObject(qint64 id, Scene::Scenes type){
ChangeCurrentText(ui->comboBoxP2Line, point.name()); ChangeCurrentText(ui->comboBoxP2Line, point.name());
number = 0; number = 0;
emit ToolTip(tr("")); emit ToolTip(tr(""));
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
break; break;
@ -90,7 +108,8 @@ void DialogHeight::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogHeight::DialogAccepted(){ void DialogHeight::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
basePointId = getCurrentPointId(ui->comboBoxBasePoint); basePointId = getCurrentPointId(ui->comboBoxBasePoint);
@ -98,4 +117,3 @@ void DialogHeight::DialogAccepted(){
p2LineId = getCurrentPointId(ui->comboBoxP2Line); p2LineId = getCurrentPointId(ui->comboBoxP2Line);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }

View File

@ -24,14 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogHeight; class DialogHeight;
} }
class DialogHeight : public DialogTool{ class DialogHeight : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogHeight(); ~DialogHeight();
inline QString getPointName() const {return pointName;} inline QString getPointName() const {return pointName;}

View File

@ -26,9 +26,10 @@
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
#include <QDebug> #include <QDebug>
DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) : DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
cursorToolRecordRow(0){ cursorToolRecordRow(0)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);
@ -42,19 +43,23 @@ DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *paren
ShowPoint(); ShowPoint();
} }
DialogHistory::~DialogHistory(){ DialogHistory::~DialogHistory()
{
delete ui; delete ui;
} }
void DialogHistory::DialogAccepted(){ void DialogHistory::DialogAccepted()
{
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogHistory::cellClicked(int row, int column){ void DialogHistory::cellClicked(int row, int column)
if(column == 0){ {
if (column == 0)
{
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
item->setIcon(QIcon()); item->setIcon(QIcon());
@ -65,7 +70,9 @@ void DialogHistory::cellClicked(int row, int column){
disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor);
doc->setCursor(id); doc->setCursor(id);
connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor);
} else { }
else
{
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);
@ -77,11 +84,14 @@ void DialogHistory::cellClicked(int row, int column){
} }
} }
void DialogHistory::ChangedCursor(qint64 id){ void DialogHistory::ChangedCursor(qint64 id)
for(qint32 i = 0; i< ui->tableWidget->rowCount(); ++i){ {
for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 0); QTableWidgetItem *item = ui->tableWidget->item(i, 0);
qint64 rId = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 rId = qvariant_cast<qint64>(item->data(Qt::UserRole));
if(rId == id){ if (rId == id)
{
QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0);
oldCursorItem->setIcon(QIcon()); oldCursorItem->setIcon(QIcon());
cursorRow = i; cursorRow = i;
@ -90,20 +100,24 @@ void DialogHistory::ChangedCursor(qint64 id){
} }
} }
void DialogHistory::UpdateHistory(){ void DialogHistory::UpdateHistory()
{
FillTable(); FillTable();
InitialTable(); InitialTable();
} }
void DialogHistory::FillTable(){ void DialogHistory::FillTable()
{
ui->tableWidget->clear(); ui->tableWidget->clear();
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
qint32 currentRow = -1; qint32 currentRow = -1;
qint32 count = 0; qint32 count = 0;
ui->tableWidget->setRowCount(history->size()); ui->tableWidget->setRowCount(history->size());
for(qint32 i = 0; i< history->size(); ++i){ for (qint32 i = 0; i< history->size(); ++i)
{
VToolRecord tool = history->at(i); VToolRecord tool = history->at(i);
if(tool.getNameDraw() != doc->GetNameActivDraw()){ if (tool.getNameDraw() != doc->GetNameActivDraw())
{
continue; continue;
} }
currentRow++; currentRow++;
@ -121,7 +135,8 @@ void DialogHistory::FillTable(){
++count; ++count;
} }
ui->tableWidget->setRowCount(count); ui->tableWidget->setRowCount(count);
if(history->size()>0){ if (history->size()>0)
{
cursorRow = currentRow; cursorRow = currentRow;
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
item->setIcon(QIcon("://icon/32x32/put_after.png")); item->setIcon(QIcon("://icon/32x32/put_after.png"));
@ -131,7 +146,8 @@ void DialogHistory::FillTable(){
ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); ui->tableWidget->verticalHeader()->setDefaultSectionSize(20);
} }
QString DialogHistory::Record(const VToolRecord &tool){ QString DialogHistory::Record(const VToolRecord &tool)
{
QString record = QString(); QString record = QString();
qint64 basePointId = 0; qint64 basePointId = 0;
qint64 secondPointId = 0; qint64 secondPointId = 0;
@ -143,7 +159,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
qint64 p2Line2 = 0; qint64 p2Line2 = 0;
qint64 center = 0; qint64 center = 0;
QDomElement domElement; QDomElement domElement;
switch( tool.getTypeTool() ){ switch ( tool.getTypeTool() )
{
case Tool::ArrowTool: case Tool::ArrowTool:
break; break;
case Tool::SinglePointTool: case Tool::SinglePointTool:
@ -151,7 +168,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::EndLineTool: case Tool::EndLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = domElement.attribute("basePoint", "").toLongLong();
} }
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(), record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(),
@ -159,7 +177,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::LineTool: case Tool::LineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -168,7 +187,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::AlongLineTool: case Tool::AlongLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -181,7 +201,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::NormalTool: case Tool::NormalTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -191,7 +212,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::BisectorTool: case Tool::BisectorTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
basePointId = domElement.attribute("secondPoint", "").toLongLong(); basePointId = domElement.attribute("secondPoint", "").toLongLong();
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
@ -203,7 +225,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::LineIntersectTool: case Tool::LineIntersectTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
p2Line1 = domElement.attribute("p2Line1", "").toLongLong(); p2Line1 = domElement.attribute("p2Line1", "").toLongLong();
p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
@ -215,23 +238,28 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(p2Line2).name(), data->GetPoint(p2Line2).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tool::SplineTool:{ case Tool::SplineTool:
{
VSpline spl = data->GetSpline(tool.getId()); VSpline spl = data->GetSpline(tool.getId());
record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(), record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(),
data->GetPoint(spl.GetP4()).name()); data->GetPoint(spl.GetP4()).name());
} }
break; break;
case Tool::ArcTool:{ case Tool::ArcTool:
{
VArc arc = data->GetArc(tool.getId()); VArc arc = data->GetArc(tool.getId());
record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name()); record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name());
} }
break; break;
case Tool::SplinePathTool:{ case Tool::SplinePathTool:
{
VSplinePath splPath = data->GetSplinePath(tool.getId()); VSplinePath splPath = data->GetSplinePath(tool.getId());
QVector<VSplinePoint> points = splPath.GetSplinePath(); QVector<VSplinePoint> points = splPath.GetSplinePath();
if(points.size() != 0 ){ if (points.size() != 0 )
{
record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name()); record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name());
for(qint32 i = 1; i< points.size(); ++i){ for (qint32 i = 1; i< points.size(); ++i)
{
QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name()); QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name());
record.append(name); record.append(name);
} }
@ -240,35 +268,39 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::PointOfContact: case Tool::PointOfContact:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
center = domElement.attribute("center", "").toLongLong(); center = domElement.attribute("center", "").toLongLong();
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg(data->GetPoint(center).name(), record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg(
data->GetPoint(firstPointId).name(), data->GetPoint(center).name(), data->GetPoint(firstPointId).name(),
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(), data->GetPoint(tool.getId()).name());
data->GetPoint(tool.getId()).name());
break; break;
case Tool::Height:{ case Tool::Height:
{
qint64 p1LineId = 0; qint64 p1LineId = 0;
qint64 p2LineId = 0; qint64 p2LineId = 0;
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = domElement.attribute("basePoint", "").toLongLong();
p1LineId = domElement.attribute("p1Line", "").toLongLong(); p1LineId = domElement.attribute("p1Line", "").toLongLong();
p2LineId = domElement.attribute("p2Line", "").toLongLong(); p2LineId = domElement.attribute("p2Line", "").toLongLong();
} }
record = QString(tr("Point of perpendical from point %1 to line %2_%3")).arg(data->GetPoint(basePointId).name(), record = QString(tr("Point of perpendical from point %1 to line %2_%3")).arg(
data->GetPoint(p1LineId).name(), data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(),
data->GetPoint(p2LineId).name()); data->GetPoint(p2LineId).name());
break; break;
} }
case Tool::Triangle:{ case Tool::Triangle:
{
qint64 axisP1Id = 0; qint64 axisP1Id = 0;
qint64 axisP2Id = 0; qint64 axisP2Id = 0;
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
axisP1Id = domElement.attribute("axisP1", "").toLongLong(); axisP1Id = domElement.attribute("axisP1", "").toLongLong();
axisP2Id = domElement.attribute("axisP2", "").toLongLong(); axisP2Id = domElement.attribute("axisP2", "").toLongLong();
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
@ -286,15 +318,18 @@ QString DialogHistory::Record(const VToolRecord &tool){
return record; return record;
} }
void DialogHistory::InitialTable(){ void DialogHistory::InitialTable()
{
ui->tableWidget->setSortingEnabled(false); ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" "));
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool"))); ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool")));
} }
void DialogHistory::ShowPoint(){ void DialogHistory::ShowPoint()
{
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
if(history->size()>0){ if (history->size()>0)
{
QTableWidgetItem *item = ui->tableWidget->item(0, 1); QTableWidgetItem *item = ui->tableWidget->item(0, 1);
item->setSelected(true); item->setSelected(true);
cursorToolRecordRow = 0; cursorToolRecordRow = 0;
@ -304,7 +339,8 @@ void DialogHistory::ShowPoint(){
} }
} }
void DialogHistory::closeEvent(QCloseEvent *event){ void DialogHistory::closeEvent(QCloseEvent *event)
{
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);

View File

@ -25,11 +25,13 @@
#include "dialogtool.h" #include "dialogtool.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
namespace Ui { namespace Ui
{
class DialogHistory; class DialogHistory;
} }
class DialogHistory : public DialogTool{ class DialogHistory : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0); DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0);

View File

@ -24,9 +24,9 @@
#include <widgets/doubledelegate.h> #include <widgets/doubledelegate.h>
#include <exception/vexception.h> #include <exception/vexception.h>
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) : DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0)
row(0), column(0){ {
ui->setupUi(this); ui->setupUi(this);
InitialStandartTable(); InitialStandartTable();
InitialIncrementTable(); InitialIncrementTable();
@ -58,12 +58,14 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
} }
void DialogIncrements::FillStandartTable(){ void DialogIncrements::FillStandartTable()
{
const QHash<QString, VStandartTableCell> *standartTable = data->DataStandartTable(); const QHash<QString, VStandartTableCell> *standartTable = data->DataStandartTable();
qint32 currentRow = -1; qint32 currentRow = -1;
QHashIterator<QString, VStandartTableCell> i(*standartTable); QHashIterator<QString, VStandartTableCell> i(*standartTable);
ui->tableWidgetStandart->setRowCount ( standartTable->size() ); ui->tableWidgetStandart->setRowCount ( standartTable->size() );
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
VStandartTableCell cell = i.value(); VStandartTableCell cell = i.value();
currentRow++; currentRow++;
@ -98,12 +100,14 @@ void DialogIncrements::FillStandartTable(){
ui->tableWidgetStandart->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetStandart->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillIncrementTable(){ void DialogIncrements::FillIncrementTable()
{
const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable(); const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable();
QHashIterator<QString, VIncrementTableRow> i(*incrementTable); QHashIterator<QString, VIncrementTableRow> i(*incrementTable);
QMap<qint64, QString> map; QMap<qint64, QString> map;
//Sorting QHash by id //Sorting QHash by id
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
VIncrementTableRow cell = i.value(); VIncrementTableRow cell = i.value();
map.insert(cell.getId(), i.key()); map.insert(cell.getId(), i.key());
@ -111,7 +115,8 @@ void DialogIncrements::FillIncrementTable(){
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<qint64, QString> iMap(map); QMapIterator<qint64, QString> iMap(map);
while (iMap.hasNext()) { while (iMap.hasNext())
{
iMap.next(); iMap.next();
VIncrementTableRow cell = incrementTable->value(iMap.value()); VIncrementTableRow cell = incrementTable->value(iMap.value());
currentRow++; currentRow++;
@ -147,7 +152,8 @@ void DialogIncrements::FillIncrementTable(){
item->setTextAlignment(Qt::AlignLeft); item->setTextAlignment(Qt::AlignLeft);
ui->tableWidgetIncrement->setItem(currentRow, 5, item); ui->tableWidgetIncrement->setItem(currentRow, 5, item);
} }
if(ui->tableWidgetIncrement->rowCount()>0){ if (ui->tableWidgetIncrement->rowCount()>0)
{
ui->toolButtonRemove->setEnabled(true); ui->toolButtonRemove->setEnabled(true);
} }
ui->tableWidgetIncrement->resizeColumnsToContents(); ui->tableWidgetIncrement->resizeColumnsToContents();
@ -155,19 +161,22 @@ void DialogIncrements::FillIncrementTable(){
ui->tableWidgetIncrement->setCurrentCell( row, column ); ui->tableWidgetIncrement->setCurrentCell( row, column );
} }
void DialogIncrements::FillLengthLines(){ void DialogIncrements::FillLengthLines()
{
const QHash<QString, qreal> *linesTable = data->DataLengthLines(); const QHash<QString, qreal> *linesTable = data->DataLengthLines();
QHashIterator<QString, qreal> iHash(*linesTable); QHashIterator<QString, qreal> iHash(*linesTable);
QMap<QString, qreal> map; QMap<QString, qreal> map;
//Sorting QHash by name //Sorting QHash by name
while (iHash.hasNext()) { while (iHash.hasNext())
{
iHash.next(); iHash.next();
map.insert(iHash.key(), iHash.value()); map.insert(iHash.key(), iHash.value());
} }
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(map); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
@ -187,19 +196,22 @@ void DialogIncrements::FillLengthLines(){
ui->tableWidgetLines->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetLines->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillLengthSplines(){ void DialogIncrements::FillLengthSplines()
{
const QHash<QString, qreal> *splinesTable = data->DataLengthSplines(); const QHash<QString, qreal> *splinesTable = data->DataLengthSplines();
QHashIterator<QString, qreal> iHash(*splinesTable); QHashIterator<QString, qreal> iHash(*splinesTable);
QMap<QString, qreal> map; QMap<QString, qreal> map;
//Sorting QHash by name //Sorting QHash by name
while (iHash.hasNext()) { while (iHash.hasNext())
{
iHash.next(); iHash.next();
map.insert(iHash.key(), iHash.value()); map.insert(iHash.key(), iHash.value());
} }
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(map); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
@ -219,19 +231,22 @@ void DialogIncrements::FillLengthSplines(){
ui->tableWidgetSplines->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetSplines->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillLengthArcs(){ void DialogIncrements::FillLengthArcs()
{
const QHash<QString, qreal> *arcsTable = data->DataLengthArcs(); const QHash<QString, qreal> *arcsTable = data->DataLengthArcs();
QHashIterator<QString, qreal> iHash(*arcsTable); QHashIterator<QString, qreal> iHash(*arcsTable);
QMap<QString, qreal> map; QMap<QString, qreal> map;
//Sorting QHash by name //Sorting QHash by name
while (iHash.hasNext()) { while (iHash.hasNext())
{
iHash.next(); iHash.next();
map.insert(iHash.key(), iHash.value()); map.insert(iHash.key(), iHash.value());
} }
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(map); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
@ -251,7 +266,8 @@ void DialogIncrements::FillLengthArcs(){
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FullUpdateFromFile(){ void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
@ -279,7 +295,8 @@ void DialogIncrements::FullUpdateFromFile(){
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
} }
void DialogIncrements::clickedToolButtonAdd(){ void DialogIncrements::clickedToolButtonAdd()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason); ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
@ -288,7 +305,8 @@ void DialogIncrements::clickedToolButtonAdd(){
qint32 num = 1; qint32 num = 1;
QString name; QString name;
do{ do
{
name = QString(tr("Denotation %1")).arg(num); name = QString(tr("Denotation %1")).arg(num);
num++; num++;
} while (data->IncrementTableContains(name)); } while (data->IncrementTableContains(name));
@ -340,7 +358,8 @@ void DialogIncrements::clickedToolButtonAdd(){
emit haveLiteChange(); emit haveLiteChange();
} }
void DialogIncrements::clickedToolButtonRemove(){ void DialogIncrements::clickedToolButtonRemove()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem(); QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
@ -349,12 +368,14 @@ void DialogIncrements::clickedToolButtonRemove(){
data->RemoveIncrementTableRow(itemName->text()); data->RemoveIncrementTableRow(itemName->text());
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
QDomNodeList list = doc->elementsByTagName("increments"); QDomNodeList list = doc->elementsByTagName("increments");
list.at(0).removeChild(domElement); list.at(0).removeChild(domElement);
} }
ui->tableWidgetIncrement->removeRow(row); ui->tableWidgetIncrement->removeRow(row);
if(ui->tableWidgetIncrement->rowCount() == 0){ if (ui->tableWidgetIncrement->rowCount() == 0)
{
ui->toolButtonRemove->setEnabled(false); ui->toolButtonRemove->setEnabled(false);
} }
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
@ -362,8 +383,9 @@ void DialogIncrements::clickedToolButtonRemove(){
emit haveLiteChange(); emit haveLiteChange();
} }
void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
qreal kgrowth, QString description){ QString description)
{
QDomNodeList list = doc->elementsByTagName("increments"); QDomNodeList list = doc->elementsByTagName("increments");
QDomElement element = doc->createElement("increment"); QDomElement element = doc->createElement("increment");
@ -394,18 +416,21 @@ void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, q
list.at(0).appendChild(element); list.at(0).appendChild(element);
} }
void DialogIncrements::cellChanged ( qint32 row, qint32 column ){ void DialogIncrements::cellChanged ( qint32 row, qint32 column )
{
QTableWidgetItem *item = 0; QTableWidgetItem *item = 0;
QTableWidgetItem *itemName = 0; QTableWidgetItem *itemName = 0;
qint64 id; qint64 id;
QDomElement domElement; QDomElement domElement;
this->row = row; this->row = row;
switch(column) { switch (column)
{
case 0: case 0:
item = ui->tableWidgetIncrement->item(row, 0); item = ui->tableWidgetIncrement->item(row, 0);
id = qvariant_cast<qint64>(item->data(Qt::UserRole)); id = qvariant_cast<qint64>(item->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("name", item->text()); domElement.setAttribute("name", item->text());
data->ClearIncrementTable(); data->ClearIncrementTable();
this->column = 2; this->column = 2;
@ -417,14 +442,18 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
bool ok = false; bool ok = false;
qreal value = item->text().toDouble(&ok); qreal value = item->text().toDouble(&ok);
if(ok){ if (ok)
{
domElement.setAttribute("base", value); domElement.setAttribute("base", value);
this->column = 3; this->column = 3;
emit FullUpdateTree(); emit FullUpdateTree();
} else { }
else
{
throw VException(tr("Can't convert toDouble value.")); throw VException(tr("Can't convert toDouble value."));
} }
} }
@ -434,7 +463,8 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("ksize", item->text().toDouble()); domElement.setAttribute("ksize", item->text().toDouble());
this->column = 4; this->column = 4;
emit FullUpdateTree(); emit FullUpdateTree();
@ -445,7 +475,8 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("kgrowth", item->text().toDouble()); domElement.setAttribute("kgrowth", item->text().toDouble());
this->column = 5; this->column = 5;
emit FullUpdateTree(); emit FullUpdateTree();
@ -456,7 +487,8 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("description", item->text()); domElement.setAttribute("description", item->text());
VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text()); VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text());
incr.setDescription(item->text()); incr.setDescription(item->text());
@ -470,7 +502,8 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
} }
} }
void DialogIncrements::InitialStandartTable(){ void DialogIncrements::InitialStandartTable()
{
ui->tableWidgetStandart->setSortingEnabled(false); ui->tableWidgetStandart->setSortingEnabled(false);
ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation")));
ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value")));
@ -480,7 +513,8 @@ void DialogIncrements::InitialStandartTable(){
ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description")));
} }
void DialogIncrements::InitialIncrementTable(){ void DialogIncrements::InitialIncrementTable()
{
ui->tableWidgetIncrement->setSortingEnabled(false); ui->tableWidgetIncrement->setSortingEnabled(false);
ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value")));
@ -491,25 +525,30 @@ void DialogIncrements::InitialIncrementTable(){
ui->tableWidgetIncrement->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetIncrement->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::InitialLinesTable(){ void DialogIncrements::InitialLinesTable()
{
ui->tableWidgetLines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Line"))); ui->tableWidgetLines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Line")));
ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::InitialSplinesTable(){ void DialogIncrements::InitialSplinesTable()
{
ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve"))); ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve")));
ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::InitialArcsTable(){ void DialogIncrements::InitialArcsTable()
{
ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc"))); ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc")));
ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::DialogAccepted(){ void DialogIncrements::DialogAccepted()
{
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
DialogIncrements::~DialogIncrements(){ DialogIncrements::~DialogIncrements()
{
delete ui; delete ui;
} }

View File

@ -25,11 +25,13 @@
#include "dialogtool.h" #include "dialogtool.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
namespace Ui { namespace Ui
{
class DialogIncrements; class DialogIncrements;
} }
class DialogIncrements : public DialogTool{ class DialogIncrements : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0); DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);

View File

@ -22,8 +22,9 @@
#include "dialogline.h" #include "dialogline.h"
#include "ui_dialogline.h" #include "ui_dialogline.h"
DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){ :DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
@ -34,30 +35,36 @@ DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent
number = 0; number = 0;
} }
DialogLine::~DialogLine(){ DialogLine::~DialogLine()
{
delete ui; delete ui;
} }
void DialogLine::setSecondPoint(const qint64 &value){ void DialogLine::setSecondPoint(const qint64 &value)
{
secondPoint = value; secondPoint = value;
VPointF point = data->GetPoint(value); VPointF point = data->GetPoint(value);
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if(index != -1){ if (index != -1)
{
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
} }
} }
void DialogLine::setFirstPoint(const qint64 &value){ void DialogLine::setFirstPoint(const qint64 &value)
{
firstPoint = value; firstPoint = value;
VPointF point = data->GetPoint(value); VPointF point = data->GetPoint(value);
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if(index != -1){ if (index != -1)
{
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
} }
} }
void DialogLine::DialogAccepted(){ void DialogLine::DialogAccepted()
{
qint32 index = ui->comboBoxFirstPoint->currentIndex(); qint32 index = ui->comboBoxFirstPoint->currentIndex();
firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index)); firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
index = ui->comboBoxSecondPoint->currentIndex(); index = ui->comboBoxSecondPoint->currentIndex();
@ -65,42 +72,56 @@ void DialogLine::DialogAccepted(){
DialogClosed(QDialog::Accepted); DialogClosed(QDialog::Accepted);
} }
void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point")); emit ToolTip(tr("Select second point"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }

View File

@ -24,15 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogLine; class DialogLine;
} }
class DialogLine : public DialogTool{ class DialogLine : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogLine(); ~DialogLine();
inline qint64 getFirstPoint() const {return firstPoint;} inline qint64 getFirstPoint() const {return firstPoint;}
void setFirstPoint(const qint64 &value); void setFirstPoint(const qint64 &value);

View File

@ -22,9 +22,10 @@
#include "dialoglineintersect.h" #include "dialoglineintersect.h"
#include "ui_dialoglineintersect.h" #include "ui_dialoglineintersect.h"
DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){ p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true)
{
ui->setupUi(this); ui->setupUi(this);
number = 0; number = 0;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -41,32 +42,44 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mod
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
} }
DialogLineIntersect::~DialogLineIntersect(){ DialogLineIntersect::~DialogLineIntersect()
{
delete ui; delete ui;
} }
void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1Line1->findText(point.name()); qint32 index = ui->comboBoxP1Line1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line1->setCurrentIndex(index); ui->comboBoxP1Line1->setCurrentIndex(index);
p1Line1 = id; p1Line1 = id;
number++; number++;
@ -74,9 +87,11 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP2Line1->findText(point.name()); qint32 index = ui->comboBoxP2Line1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line1->setCurrentIndex(index); ui->comboBoxP2Line1->setCurrentIndex(index);
p2Line1 = id; p2Line1 = id;
number++; number++;
@ -84,9 +99,11 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxP1Line2->findText(point.name()); qint32 index = ui->comboBoxP1Line2->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line2->setCurrentIndex(index); ui->comboBoxP1Line2->setCurrentIndex(index);
p1Line2 = id; p1Line2 = id;
number++; number++;
@ -94,15 +111,18 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 3){ if (number == 3)
{
qint32 index = ui->comboBoxP2Line2->findText(point.name()); qint32 index = ui->comboBoxP2Line2->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line2->setCurrentIndex(index); ui->comboBoxP2Line2->setCurrentIndex(index);
p2Line2 = id; p2Line2 = id;
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
this->show(); this->show();
@ -123,7 +143,8 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogLineIntersect::DialogAccepted(){ void DialogLineIntersect::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
p1Line1 = getCurrentPointId(ui->comboBoxP1Line1); p1Line1 = getCurrentPointId(ui->comboBoxP1Line1);
p2Line1 = getCurrentPointId(ui->comboBoxP2Line1); p2Line1 = getCurrentPointId(ui->comboBoxP2Line1);
@ -132,36 +153,42 @@ void DialogLineIntersect::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogLineIntersect::P1Line1Changed( int index){ void DialogLineIntersect::P1Line1Changed( int index)
{
p1Line1 = qvariant_cast<qint64>(ui->comboBoxP1Line1->itemData(index)); p1Line1 = qvariant_cast<qint64>(ui->comboBoxP1Line1->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P2Line1Changed(int index){ void DialogLineIntersect::P2Line1Changed(int index)
{
p2Line1 = qvariant_cast<qint64>(ui->comboBoxP2Line1->itemData(index)); p2Line1 = qvariant_cast<qint64>(ui->comboBoxP2Line1->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P1Line2Changed(int index){ void DialogLineIntersect::P1Line2Changed(int index)
{
p1Line2 = qvariant_cast<qint64>(ui->comboBoxP1Line2->itemData(index)); p1Line2 = qvariant_cast<qint64>(ui->comboBoxP1Line2->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P2Line2Changed(int index){ void DialogLineIntersect::P2Line2Changed(int index)
{
p2Line2 = qvariant_cast<qint64>(ui->comboBoxP2Line2->itemData(index)); p2Line2 = qvariant_cast<qint64>(ui->comboBoxP2Line2->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::CheckState(){ void DialogLineIntersect::CheckState()
{
Q_ASSERT(bOk != 0); Q_ASSERT(bOk != 0);
bOk->setEnabled(flagName && flagPoint); bOk->setEnabled(flagName && flagPoint);
} }
bool DialogLineIntersect::CheckIntersecion(){ bool DialogLineIntersect::CheckIntersecion()
{
VPointF p1L1 = data->GetPoint(p1Line1); VPointF p1L1 = data->GetPoint(p1Line1);
VPointF p2L1 = data->GetPoint(p2Line1); VPointF p2L1 = data->GetPoint(p2Line1);
VPointF p1L2 = data->GetPoint(p1Line2); VPointF p1L2 = data->GetPoint(p1Line2);
@ -171,34 +198,42 @@ bool DialogLineIntersect::CheckIntersecion(){
QLineF line2(p1L2.toQPointF(), p2L2.toQPointF()); QLineF line2(p1L2.toQPointF(), p2L2.toQPointF());
QPointF fPoint; QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
return true; return true;
} else { }
else
{
return false; return false;
} }
} }
void DialogLineIntersect::setP2Line2(const qint64 &value){ void DialogLineIntersect::setP2Line2(const qint64 &value)
{
p2Line2 = value; p2Line2 = value;
ChangeCurrentData(ui->comboBoxP2Line2, value); ChangeCurrentData(ui->comboBoxP2Line2, value);
} }
void DialogLineIntersect::setP1Line2(const qint64 &value){ void DialogLineIntersect::setP1Line2(const qint64 &value)
{
p1Line2 = value; p1Line2 = value;
ChangeCurrentData(ui->comboBoxP1Line2, value); ChangeCurrentData(ui->comboBoxP1Line2, value);
} }
void DialogLineIntersect::setP2Line1(const qint64 &value){ void DialogLineIntersect::setP2Line1(const qint64 &value)
{
p2Line1 = value; p2Line1 = value;
ChangeCurrentData(ui->comboBoxP2Line1, value); ChangeCurrentData(ui->comboBoxP2Line1, value);
} }
void DialogLineIntersect::setP1Line1(const qint64 &value){ void DialogLineIntersect::setP1Line1(const qint64 &value)
{
p1Line1 = value; p1Line1 = value;
ChangeCurrentData(ui->comboBoxP1Line1, value); ChangeCurrentData(ui->comboBoxP1Line1, value);
} }
void DialogLineIntersect::setPointName(const QString &value){ void DialogLineIntersect::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -24,14 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogLineIntersect; class DialogLineIntersect;
} }
class DialogLineIntersect : public DialogTool{ class DialogLineIntersect : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogLineIntersect(); ~DialogLineIntersect();
inline qint64 getP1Line1() const {return p1Line1;} inline qint64 getP1Line1() const {return p1Line1;}

View File

@ -22,9 +22,10 @@
#include "dialognormal.h" #include "dialognormal.h"
#include "ui_dialognormal.h" #include "ui_dialognormal.h"
DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
spinBoxAngle = ui->doubleSpinBoxAngle; spinBoxAngle = ui->doubleSpinBoxAngle;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -82,53 +83,69 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged);
} }
DialogNormal::~DialogNormal(){ DialogNormal::~DialogNormal()
{
delete ui; delete ui;
} }
void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogNormal::DialogAccepted(){ void DialogNormal::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -138,30 +155,36 @@ void DialogNormal::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id){ void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id){ void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
void DialogNormal::setAngle(const qreal &value){ void DialogNormal::setAngle(const qreal &value)
{
angle = value; angle = value;
ui->doubleSpinBoxAngle->setValue(angle); ui->doubleSpinBoxAngle->setValue(angle);
} }
void DialogNormal::setFormula(const QString &value){ void DialogNormal::setFormula(const QString &value)
{
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
void DialogNormal::setTypeLine(const QString &value){ void DialogNormal::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogNormal::setPointName(const QString &value){ void DialogNormal::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -24,15 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogNormal; class DialogNormal;
} }
class DialogNormal : public DialogTool{ class DialogNormal : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogNormal(); ~DialogNormal();
inline QString getPointName() const{return pointName;} inline QString getPointName() const{return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);

View File

@ -21,9 +21,10 @@
#include "dialogpointofcontact.h" #include "dialogpointofcontact.h"
DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0), :DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0){ firstPoint(0), secondPoint(0)
{
ui.setupUi(this); ui.setupUi(this);
listWidget = ui.listWidget; listWidget = ui.listWidget;
labelResultCalculation = ui.labelResultCalculation; labelResultCalculation = ui.labelResultCalculation;
@ -64,58 +65,75 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged);
} }
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui.comboBoxFirstPoint->findText(point.name()); qint32 index = ui.comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxFirstPoint->setCurrentIndex(index); ui.comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui.comboBoxSecondPoint->findText(point.name()); qint32 index = ui.comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxSecondPoint->setCurrentIndex(index); ui.comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point of center of arc")); emit ToolTip(tr("Select point of center of arc"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui.comboBoxCenter->findText(point.name()); qint32 index = ui.comboBoxCenter->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxCenter->setCurrentIndex(index); ui.comboBoxCenter->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogPointOfContact::DialogAccepted(){ void DialogPointOfContact::DialogAccepted()
{
pointName = ui.lineEditNamePoint->text(); pointName = ui.lineEditNamePoint->text();
radius = ui.lineEditFormula->text(); radius = ui.lineEditFormula->text();
center = getCurrentPointId(ui.comboBoxCenter); center = getCurrentPointId(ui.comboBoxCenter);
@ -124,25 +142,30 @@ void DialogPointOfContact::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id){ void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id); setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id);
} }
void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id){ void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id); setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id);
} }
void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id){ void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui.comboBoxCenter, center, value, id); setCurrentPointId(ui.comboBoxCenter, center, value, id);
center = value; center = value;
} }
void DialogPointOfContact::setRadius(const QString &value){ void DialogPointOfContact::setRadius(const QString &value)
{
radius = value; radius = value;
ui.lineEditFormula->setText(radius); ui.lineEditFormula->setText(radius);
} }
void DialogPointOfContact::setPointName(const QString &value){ void DialogPointOfContact::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui.lineEditNamePoint->setText(pointName); ui.lineEditNamePoint->setText(pointName);
} }

View File

@ -25,9 +25,9 @@
#include "ui_dialogpointofcontact.h" #include "ui_dialogpointofcontact.h"
#include "dialogtool.h" #include "dialogtool.h"
class DialogPointOfContact : public DialogTool{ class DialogPointOfContact : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);

View File

@ -1,9 +1,10 @@
#include "dialogpointofintersection.h" #include "dialogpointofintersection.h"
#include "ui_dialogpointofintersection.h" #include "ui_dialogpointofintersection.h"
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
firstPointId(0), secondPointId(0){ firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -17,70 +18,89 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Dra
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
} }
DialogPointOfIntersection::~DialogPointOfIntersection(){ DialogPointOfIntersection::~DialogPointOfIntersection()
{
delete ui; delete ui;
} }
void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint64 &id){ void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint64 &id)
{
secondPointId = value; secondPointId = value;
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
void DialogPointOfIntersection::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogPointOfIntersection::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point horizontally")); emit ToolTip(tr("Select point horizontally"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogPointOfIntersection::DialogAccepted(){ void DialogPointOfIntersection::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogPointOfIntersection::setFirstPointId(const qint64 &value, const qint64 &id){ void DialogPointOfIntersection::setFirstPointId(const qint64 &value, const qint64 &id)
{
firstPointId = value; firstPointId = value;
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
void DialogPointOfIntersection::setPointName(const QString &value){ void DialogPointOfIntersection::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -3,11 +3,13 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogPointOfIntersection; class DialogPointOfIntersection;
} }
class DialogPointOfIntersection : public DialogTool{ class DialogPointOfIntersection : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation,

View File

@ -22,9 +22,10 @@
#include "dialogshoulderpoint.h" #include "dialogshoulderpoint.h"
#include "ui_dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h"
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){ typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0)
{
ui->setupUi(this); ui->setupUi(this);
number = 0; number = 0;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -67,62 +68,80 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged);
} }
DialogShoulderPoint::~DialogShoulderPoint(){ DialogShoulderPoint::~DialogShoulderPoint()
{
delete ui; delete ui;
} }
void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1Line->findText(point.name()); qint32 index = ui->comboBoxP1Line->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line->setCurrentIndex(index); ui->comboBoxP1Line->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP2Line->findText(point.name()); qint32 index = ui->comboBoxP2Line->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index); ui->comboBoxP2Line->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point of shoulder")); emit ToolTip(tr("Select point of shoulder"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxPShoulder->findText(point.name()); qint32 index = ui->comboBoxPShoulder->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index); ui->comboBoxPShoulder->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogShoulderPoint::DialogAccepted(){ void DialogShoulderPoint::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -132,29 +151,35 @@ void DialogShoulderPoint::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id){ void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id); setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id);
} }
void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id){ void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id); setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id);
} }
void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id){ void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id); setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id);
} }
void DialogShoulderPoint::setFormula(const QString &value){ void DialogShoulderPoint::setFormula(const QString &value)
{
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
void DialogShoulderPoint::setTypeLine(const QString &value){ void DialogShoulderPoint::setTypeLine(const QString &value)
{
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
void DialogShoulderPoint::setPointName(const QString &value){ void DialogShoulderPoint::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -24,11 +24,13 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogShoulderPoint; class DialogShoulderPoint;
} }
class DialogShoulderPoint : public DialogTool{ class DialogShoulderPoint : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,

View File

@ -22,9 +22,10 @@
#include "dialogsinglepoint.h" #include "dialogsinglepoint.h"
#include "ui_dialogsinglepoint.h" #include "ui_dialogsinglepoint.h"
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) : DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()), :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF()){ point(QPointF())
{
ui->setupUi(this); ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0, toMM(PaperSize)); ui->doubleSpinBoxX->setRange(0, toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0, toMM(PaperSize)); ui->doubleSpinBoxY->setRange(0, toMM(PaperSize));
@ -38,24 +39,30 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged); connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged);
} }
void DialogSinglePoint::mousePress(QPointF scenePos){ void DialogSinglePoint::mousePress(QPointF scenePos)
if(isInitialized == false){ {
if (isInitialized == false)
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
this->show(); this->show();
} else { }
else
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
} }
} }
void DialogSinglePoint::DialogAccepted(){ void DialogSinglePoint::DialogAccepted()
{
point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value())); point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
name = ui->lineEditName->text(); name = ui->lineEditName->text();
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogSinglePoint::setData(const QString name, const QPointF point){ void DialogSinglePoint::setData(const QString name, const QPointF point)
{
this->name = name; this->name = name;
this->point = point; this->point = point;
isInitialized = true; isInitialized = true;
@ -64,7 +71,7 @@ void DialogSinglePoint::setData(const QString name, const QPointF point){
ui->doubleSpinBoxY->setValue(toMM(point.y())); ui->doubleSpinBoxY->setValue(toMM(point.y()));
} }
DialogSinglePoint::~DialogSinglePoint(){ DialogSinglePoint::~DialogSinglePoint()
{
delete ui; delete ui;
} }

View File

@ -24,11 +24,13 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogSinglePoint; class DialogSinglePoint;
} }
class DialogSinglePoint : public DialogTool{ class DialogSinglePoint : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogSinglePoint(const VContainer *data, QWidget *parent = 0); DialogSinglePoint(const VContainer *data, QWidget *parent = 0);

View File

@ -22,58 +22,74 @@
#include "dialogspline.h" #include "dialogspline.h"
#include "ui_dialogspline.h" #include "ui_dialogspline.h"
DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), :DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
kAsm1(1), kAsm2(1), kCurve(1){ kAsm1(1), kAsm2(1), kCurve(1)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4); FillComboBoxPoints(ui->comboBoxP4);
} }
} }
DialogSpline::~DialogSpline(){ DialogSpline::~DialogSpline()
{
delete ui; delete ui;
} }
void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4); FillComboBoxPoints(ui->comboBoxP4);
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1->findText(point.name()); qint32 index = ui->comboBoxP1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1->setCurrentIndex(index); ui->comboBoxP1->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select last point of curve")); emit ToolTip(tr("Select last point of curve"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP4->findText(point.name()); qint32 index = ui->comboBoxP4->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP4->setCurrentIndex(index); ui->comboBoxP4->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
@ -81,24 +97,29 @@ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index)); qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
QPointF p1; QPointF p1;
QPointF p4; QPointF p4;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
p1 = data->GetPoint(p1Id).toQPointF(); p1 = data->GetPoint(p1Id).toQPointF();
p4 = data->GetPoint(id).toQPointF(); p4 = data->GetPoint(id).toQPointF();
} else { }
else
{
p1 = data->GetModelingPoint(p1Id).toQPointF(); p1 = data->GetModelingPoint(p1Id).toQPointF();
p4 = data->GetModelingPoint(id).toQPointF(); p4 = data->GetModelingPoint(id).toQPointF();
} }
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle())); ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle())); ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogSpline::DialogAccepted(){ void DialogSpline::DialogAccepted()
{
p1 = getCurrentPointId(ui->comboBoxP1); p1 = getCurrentPointId(ui->comboBoxP1);
p4 = getCurrentPointId(ui->comboBoxP4); p4 = getCurrentPointId(ui->comboBoxP4);
angle1 = ui->spinBoxAngle1->value(); angle1 = ui->spinBoxAngle1->value();
@ -109,37 +130,44 @@ void DialogSpline::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogSpline::setKCurve(const qreal &value){ void DialogSpline::setKCurve(const qreal &value)
{
kCurve = value; kCurve = value;
ui->doubleSpinBoxKcurve->setValue(value); ui->doubleSpinBoxKcurve->setValue(value);
} }
void DialogSpline::setKAsm2(const qreal &value){ void DialogSpline::setKAsm2(const qreal &value)
{
kAsm2 = value; kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(value); ui->doubleSpinBoxKasm2->setValue(value);
} }
void DialogSpline::setKAsm1(const qreal &value){ void DialogSpline::setKAsm1(const qreal &value)
{
kAsm1 = value; kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(value); ui->doubleSpinBoxKasm1->setValue(value);
} }
void DialogSpline::setAngle2(const qreal &value){ void DialogSpline::setAngle2(const qreal &value)
{
angle2 = value; angle2 = value;
ui->spinBoxAngle2->setValue(static_cast<qint32>(value)); ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
} }
void DialogSpline::setAngle1(const qreal &value){ void DialogSpline::setAngle1(const qreal &value)
{
angle1 = value; angle1 = value;
ui->spinBoxAngle1->setValue(static_cast<qint32>(value)); ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
} }
void DialogSpline::setP4(const qint64 &value){ void DialogSpline::setP4(const qint64 &value)
{
p4 = value; p4 = value;
ChangeCurrentData(ui->comboBoxP4, value); ChangeCurrentData(ui->comboBoxP4, value);
} }
void DialogSpline::setP1(const qint64 &value){ void DialogSpline::setP1(const qint64 &value)
{
p1 = value; p1 = value;
ChangeCurrentData(ui->comboBoxP1, value); ChangeCurrentData(ui->comboBoxP1, value);
} }

View File

@ -24,15 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogSpline; class DialogSpline;
} }
class DialogSpline : public DialogTool{ class DialogSpline : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogSpline(); ~DialogSpline();
inline qint64 getP1() const {return p1;} inline qint64 getP1() const {return p1;}
void setP1(const qint64 &value); void setP1(const qint64 &value);

View File

@ -23,8 +23,9 @@
#include "ui_dialogsplinepath.h" #include "ui_dialogsplinepath.h"
#include "geometry/vsplinepoint.h" #include "geometry/vsplinepoint.h"
DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){ :DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted);
@ -48,14 +49,17 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWi
this, &DialogSplinePath::KAsm2Changed); this, &DialogSplinePath::KAsm2Changed);
} }
DialogSplinePath::~DialogSplinePath(){ DialogSplinePath::~DialogSplinePath()
{
delete ui; delete ui;
} }
void DialogSplinePath::SetPath(const VSplinePath &value){ void DialogSplinePath::SetPath(const VSplinePath &value)
{
this->path = value; this->path = value;
ui->listWidget->clear(); ui->listWidget->clear();
for(qint32 i = 0; i < path.CountPoint(); ++i){ for (qint32 i = 0; i < path.CountPoint(); ++i)
{
NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2()); NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
} }
ui->listWidget->setFocus(Qt::OtherFocusReason); ui->listWidget->setFocus(Qt::OtherFocusReason);
@ -63,28 +67,36 @@ void DialogSplinePath::SetPath(const VSplinePath &value){
} }
void DialogSplinePath::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogSplinePath::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
NewItem(id, 1, 0, 1); NewItem(id, 1, 0, 1);
emit ToolTip(tr("Select point of curve path")); emit ToolTip(tr("Select point of curve path"));
this->show(); this->show();
} }
} }
void DialogSplinePath::DialogAccepted(){ void DialogSplinePath::DialogAccepted()
{
path.Clear(); path.Clear();
for(qint32 i = 0; i < ui->listWidget->count(); ++i){ for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i); QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole))); path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
} }
@ -93,8 +105,10 @@ void DialogSplinePath::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogSplinePath::PointChenged(int row){ void DialogSplinePath::PointChenged(int row)
if(ui->listWidget->count() == 0){ {
if (ui->listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
@ -103,7 +117,8 @@ void DialogSplinePath::PointChenged(int row){
EnableFields(); EnableFields();
} }
void DialogSplinePath::currentPointChanged(int index){ void DialogSplinePath::currentPointChanged(int index)
{
qint64 id = qvariant_cast<qint64>(ui->comboBoxPoint->itemData(index)); qint64 id = qvariant_cast<qint64>(ui->comboBoxPoint->itemData(index));
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
@ -114,15 +129,18 @@ void DialogSplinePath::currentPointChanged(int index){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::Angle1Changed(int index){ void DialogSplinePath::Angle1Changed(int index)
{
SetAngle(index+180); SetAngle(index+180);
} }
void DialogSplinePath::Angle2Changed(int index){ void DialogSplinePath::Angle2Changed(int index)
{
SetAngle(index); SetAngle(index);
} }
void DialogSplinePath::KAsm1Changed(qreal d){ void DialogSplinePath::KAsm1Changed(qreal d)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
@ -130,7 +148,8 @@ void DialogSplinePath::KAsm1Changed(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::KAsm2Changed(qreal d){ void DialogSplinePath::KAsm2Changed(qreal d)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
@ -138,11 +157,15 @@ void DialogSplinePath::KAsm2Changed(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2){ void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
QListWidgetItem *item = new QListWidgetItem(point.name()); QListWidgetItem *item = new QListWidgetItem(point.name());
@ -154,7 +177,8 @@ void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
EnableFields(); EnableFields();
} }
void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2){ void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
{
disconnect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &DialogSplinePath::currentPointChanged); this, &DialogSplinePath::currentPointChanged);
disconnect(ui->spinBoxAngle1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), disconnect(ui->spinBoxAngle1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
@ -184,25 +208,29 @@ void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAs
this, &DialogSplinePath::KAsm2Changed); this, &DialogSplinePath::KAsm2Changed);
} }
void DialogSplinePath::EnableFields(){ void DialogSplinePath::EnableFields()
{
ui->doubleSpinBoxKasm1->setEnabled(true); ui->doubleSpinBoxKasm1->setEnabled(true);
ui->spinBoxAngle1->setEnabled(true); ui->spinBoxAngle1->setEnabled(true);
ui->doubleSpinBoxKasm2->setEnabled(true); ui->doubleSpinBoxKasm2->setEnabled(true);
ui->spinBoxAngle2->setEnabled(true); ui->spinBoxAngle2->setEnabled(true);
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
if(row == 0){ if (row == 0)
{
ui->doubleSpinBoxKasm1->setEnabled(false); ui->doubleSpinBoxKasm1->setEnabled(false);
ui->spinBoxAngle1->setEnabled(false); ui->spinBoxAngle1->setEnabled(false);
return; return;
} }
if(row == ui->listWidget->count()-1){ if (row == ui->listWidget->count()-1)
{
ui->doubleSpinBoxKasm2->setEnabled(false); ui->doubleSpinBoxKasm2->setEnabled(false);
ui->spinBoxAngle2->setEnabled(false); ui->spinBoxAngle2->setEnabled(false);
return; return;
} }
} }
void DialogSplinePath::SetAngle(qint32 angle){ void DialogSplinePath::SetAngle(qint32 angle)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));

View File

@ -25,11 +25,13 @@
#include "dialogtool.h" #include "dialogtool.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
namespace Ui { namespace Ui
{
class DialogSplinePath; class DialogSplinePath;
} }
class DialogSplinePath : public DialogTool{ class DialogSplinePath : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,

View File

@ -22,51 +22,65 @@
#include "dialogtool.h" #include "dialogtool.h"
#include <container/calculator.h> #include <container/calculator.h>
DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent):QDialog(parent), data(data), DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent)
isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0), :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0), labelEditNamePoint(0), spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0), radioButtonIncrements(0), labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0),
radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0), idDetail(0), mode(mode){ radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0),
idDetail(0), mode(mode)
{
Q_ASSERT(data != 0); Q_ASSERT(data != 0);
timerFormula = new QTimer(this); timerFormula = new QTimer(this);
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula); connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
} }
void DialogTool::closeEvent(QCloseEvent *event){ void DialogTool::closeEvent(QCloseEvent *event)
{
DialogClosed(QDialog::Rejected); DialogClosed(QDialog::Rejected);
event->accept(); event->accept();
} }
void DialogTool::showEvent(QShowEvent *event){ void DialogTool::showEvent(QShowEvent *event)
{
QDialog::showEvent( event ); QDialog::showEvent( event );
if( event->spontaneous() ){ if ( event->spontaneous() )
{
return; return;
} }
if(isInitialized){ if (isInitialized)
{
return; return;
} }
isInitialized = true;//first show windows are held isInitialized = true;//first show windows are held
} }
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
{
box->clear(); box->clear();
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
const QHash<qint64, VPointF> *points = data->DataPoints(); const QHash<qint64, VPointF> *points = data->DataPoints();
QHashIterator<qint64, VPointF> i(*points); QHashIterator<qint64, VPointF> i(*points);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
if(i.key() != id){ if (i.key() != id)
{
VPointF point = i.value(); VPointF point = i.value();
box->addItem(point.name(), i.key()); box->addItem(point.name(), i.key());
} }
} }
} else { }
if(idDetail <= 0){ else
{
if (idDetail <= 0)
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO; qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return; return;
} }
VDetail det = data->GetDetail(idDetail); VDetail det = data->GetDetail(idDetail);
for(qint32 i = 0; i< det.CountNode(); ++i){ for (qint32 i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::NodePoint || if (det[i].getTypeTool() == Tool::NodePoint ||
det[i].getTypeTool() == Tool::AlongLineTool || det[i].getTypeTool() == Tool::AlongLineTool ||
det[i].getTypeTool() == Tool::BisectorTool || det[i].getTypeTool() == Tool::BisectorTool ||
@ -74,8 +88,10 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
det[i].getTypeTool() == Tool::LineIntersectTool || det[i].getTypeTool() == Tool::LineIntersectTool ||
det[i].getTypeTool() == Tool::NormalTool || det[i].getTypeTool() == Tool::NormalTool ||
det[i].getTypeTool() == Tool::PointOfContact || det[i].getTypeTool() == Tool::PointOfContact ||
det[i].getTypeTool() == Tool::ShoulderPointTool){ det[i].getTypeTool() == Tool::ShoulderPointTool)
if(det[i].getId() != id){ {
if (det[i].getId() != id)
{
VPointF point = data->GetModelingPoint(det[i].getId()); VPointF point = data->GetModelingPoint(det[i].getId());
box->addItem(point.name(), det[i].getId()); box->addItem(point.name(), det[i].getId());
} }
@ -84,53 +100,70 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
} }
} }
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const{ void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
{
Q_ASSERT(box != 0); Q_ASSERT(box != 0);
QStringList list; QStringList list;
list<<tr("Line")<<tr("No line"); list<<tr("Line")<<tr("No line");
box->addItems(list); box->addItems(list);
} }
QString DialogTool::GetTypeLine(const QComboBox *box) const{ QString DialogTool::GetTypeLine(const QComboBox *box) const
if(box->currentText()==tr("Line")){ {
if (box->currentText()==tr("Line"))
{
return QString("hair"); return QString("hair");
} else { }
else
{
return QString("none"); return QString("none");
} }
} }
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value){ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
if(value == "hair"){ {
if (value == "hair")
{
qint32 index = box->findText(tr("Line")); qint32 index = box->findText(tr("Line"));
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
if(value == "none"){ if (value == "none")
{
qint32 index = box->findText(tr("No line")); qint32 index = box->findText(tr("No line"));
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
} }
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value){ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
{
qint32 index = box->findText(value); qint32 index = box->findText(value);
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} else { }
else
{
qWarning()<<tr("Can't find point by name")<<value; qWarning()<<tr("Can't find point by name")<<value;
} }
} }
void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value) const{ void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value) const
{
qint32 index = box->findData(value); qint32 index = box->findData(value);
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget){ void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
{
Q_ASSERT(lineEdit != 0); Q_ASSERT(lineEdit != 0);
Q_ASSERT(listWidget != 0); Q_ASSERT(listWidget != 0);
QListWidgetItem *item = listWidget->currentItem(); QListWidgetItem *item = listWidget->currentItem();
@ -140,11 +173,13 @@ void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget){
lineEdit->setCursorPosition(pos + item->text().size()); lineEdit->setCursorPosition(pos + item->text().size());
} }
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
{
Q_ASSERT(edit != 0); Q_ASSERT(edit != 0);
Q_ASSERT(timer != 0); Q_ASSERT(timer != 0);
Q_ASSERT(labelEditFormula != 0); Q_ASSERT(labelEditFormula != 0);
if(edit->text().isEmpty()){ if (edit->text().isEmpty())
{
flag = false; flag = false;
CheckState(); CheckState();
QPalette palette = labelEditFormula->palette(); QPalette palette = labelEditFormula->palette();
@ -155,24 +190,31 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){
timer->start(1000); timer->start(1000);
} }
void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label){ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
{
Q_ASSERT(edit != 0); Q_ASSERT(edit != 0);
Q_ASSERT(timer != 0); Q_ASSERT(timer != 0);
Q_ASSERT(label != 0); Q_ASSERT(label != 0);
Q_ASSERT(labelEditFormula != 0); Q_ASSERT(labelEditFormula != 0);
QPalette palette = labelEditFormula->palette(); QPalette palette = labelEditFormula->palette();
if(edit->text().isEmpty()){ if (edit->text().isEmpty())
{
flag = false; flag = false;
palette.setColor(labelEditFormula->foregroundRole(), Qt::red); palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
} else { }
else
{
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(edit->text(), &errorMsg); qreal result = cal.eval(edit->text(), &errorMsg);
if(!errorMsg.isEmpty()){ if (errorMsg.isEmpty() == false)
{
label->setText(tr("Error")); label->setText(tr("Error"));
flag = false; flag = false;
palette.setColor(labelEditFormula->foregroundRole(), Qt::red); palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
} else { }
else
{
label->setText(QString().setNum(result)); label->setText(QString().setNum(result));
flag = true; flag = true;
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
@ -183,46 +225,57 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
labelEditFormula->setPalette(palette); labelEditFormula->setPalette(palette);
} }
void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const
const qint64 &id) const{ {
Q_ASSERT(box != 0); Q_ASSERT(box != 0);
FillComboBoxPoints(box, id); FillComboBoxPoints(box, id);
pointId = value; pointId = value;
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
qint64 DialogTool::getCurrentPointId(QComboBox *box) const{ qint64 DialogTool::getCurrentPointId(QComboBox *box) const
{
Q_ASSERT(box != 0); Q_ASSERT(box != 0);
qint32 index = box->currentIndex(); qint32 index = box->currentIndex();
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index != -1){ if (index != -1)
{
return qvariant_cast<qint64>(box->itemData(index)); return qvariant_cast<qint64>(box->itemData(index));
} else { }
else
{
return -1; return -1;
} }
} }
void DialogTool::CheckState(){ void DialogTool::CheckState()
{
Q_ASSERT(bOk != 0); Q_ASSERT(bOk != 0);
bOk->setEnabled(flagFormula && flagName); bOk->setEnabled(flagFormula && flagName);
} }
void DialogTool::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogTool::ChoosedObject(qint64 id, Scene::Scenes type)
{
Q_UNUSED(id); Q_UNUSED(id);
Q_UNUSED(type); Q_UNUSED(type);
} }
void DialogTool::NamePointChanged(){ void DialogTool::NamePointChanged()
{
Q_ASSERT(labelEditNamePoint != 0); Q_ASSERT(labelEditNamePoint != 0);
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit){ if (edit)
{
QString name = edit->text(); QString name = edit->text();
if(name.isEmpty() || name.contains(" ")){ if (name.isEmpty() || name.contains(" "))
{
flagName = false; flagName = false;
QPalette palette = labelEditNamePoint->palette(); QPalette palette = labelEditNamePoint->palette();
palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red); palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red);
labelEditNamePoint->setPalette(palette); labelEditNamePoint->setPalette(palette);
} else { }
else
{
flagName = true; flagName = true;
QPalette palette = labelEditNamePoint->palette(); QPalette palette = labelEditNamePoint->palette();
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76)); palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
@ -232,96 +285,117 @@ void DialogTool::NamePointChanged(){
CheckState(); CheckState();
} }
void DialogTool::DialogAccepted(){ void DialogTool::DialogAccepted()
{
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogTool::DialogRejected(){ void DialogTool::DialogRejected()
{
emit DialogClosed(QDialog::Rejected); emit DialogClosed(QDialog::Rejected);
} }
void DialogTool::FormulaChanged(){ void DialogTool::FormulaChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if(edit){ if (edit)
{
ValFormulaChanged(flagFormula, edit, timerFormula); ValFormulaChanged(flagFormula, edit, timerFormula);
} }
} }
void DialogTool::ArrowUp(){ void DialogTool::ArrowUp()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(90); spinBoxAngle->setValue(90);
} }
void DialogTool::ArrowDown(){ void DialogTool::ArrowDown()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(270); spinBoxAngle->setValue(270);
} }
void DialogTool::ArrowLeft(){ void DialogTool::ArrowLeft()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(180); spinBoxAngle->setValue(180);
} }
void DialogTool::ArrowRight(){ void DialogTool::ArrowRight()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(0); spinBoxAngle->setValue(0);
} }
void DialogTool::ArrowLeftUp(){ void DialogTool::ArrowLeftUp()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(135); spinBoxAngle->setValue(135);
} }
void DialogTool::ArrowLeftDown(){ void DialogTool::ArrowLeftDown()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(225); spinBoxAngle->setValue(225);
} }
void DialogTool::ArrowRightUp(){ void DialogTool::ArrowRightUp()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(45); spinBoxAngle->setValue(45);
} }
void DialogTool::ArrowRightDown(){ void DialogTool::ArrowRightDown()
{
Q_ASSERT(spinBoxAngle != 0); Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(315); spinBoxAngle->setValue(315);
} }
void DialogTool::EvalFormula(){ void DialogTool::EvalFormula()
{
Q_ASSERT(lineEditFormula != 0); Q_ASSERT(lineEditFormula != 0);
Q_ASSERT(labelResultCalculation != 0); Q_ASSERT(labelResultCalculation != 0);
Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation);
} }
void DialogTool::SizeGrowth(){ void DialogTool::SizeGrowth()
{
ShowVariable(data->DataBase()); ShowVariable(data->DataBase());
} }
void DialogTool::StandartTable(){ void DialogTool::StandartTable()
{
ShowVariable(data->DataStandartTable()); ShowVariable(data->DataStandartTable());
} }
void DialogTool::LengthLines(){ void DialogTool::LengthLines()
{
ShowVariable(data->DataLengthLines()); ShowVariable(data->DataLengthLines());
} }
void DialogTool::LengthArcs(){ void DialogTool::LengthArcs()
{
ShowVariable(data->DataLengthArcs()); ShowVariable(data->DataLengthArcs());
} }
void DialogTool::LengthCurves(){ void DialogTool::LengthCurves()
{
ShowVariable(data->DataLengthSplines()); ShowVariable(data->DataLengthSplines());
} }
void DialogTool::Increments(){ void DialogTool::Increments()
{
ShowVariable(data->DataIncrementTable()); ShowVariable(data->DataIncrementTable());
} }
void DialogTool::PutHere(){ void DialogTool::PutHere()
{
PutValHere(lineEditFormula, listWidget); PutValHere(lineEditFormula, listWidget);
} }
void DialogTool::PutVal(QListWidgetItem *item){ void DialogTool::PutVal(QListWidgetItem *item)
{
Q_ASSERT(lineEditFormula != 0); Q_ASSERT(lineEditFormula != 0);
Q_ASSERT(item != 0); Q_ASSERT(item != 0);
int pos = lineEditFormula->cursorPosition(); int pos = lineEditFormula->cursorPosition();
@ -331,7 +405,8 @@ void DialogTool::PutVal(QListWidgetItem *item){
lineEditFormula->setCursorPosition(pos + item->text().size()); lineEditFormula->setCursorPosition(pos + item->text().size());
} }
void DialogTool::ValChenged(int row){ void DialogTool::ValChenged(int row)
{
Q_ASSERT(listWidget != 0); Q_ASSERT(listWidget != 0);
Q_ASSERT(labelDescription != 0); Q_ASSERT(labelDescription != 0);
Q_ASSERT(radioButtonSizeGrowth != 0); Q_ASSERT(radioButtonSizeGrowth != 0);
@ -340,48 +415,57 @@ void DialogTool::ValChenged(int row){
Q_ASSERT(radioButtonLengthLine != 0); Q_ASSERT(radioButtonLengthLine != 0);
Q_ASSERT(radioButtonLengthArc != 0); Q_ASSERT(radioButtonLengthArc != 0);
Q_ASSERT(radioButtonLengthCurve != 0); Q_ASSERT(radioButtonLengthCurve != 0);
if(listWidget->count() == 0){ if (listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = listWidget->item( row ); QListWidgetItem *item = listWidget->item( row );
if(radioButtonSizeGrowth->isChecked()){ if (radioButtonSizeGrowth->isChecked())
if(item->text()=="Р"){ {
if (item->text()=="Р")
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Growth")); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Growth"));
labelDescription->setText(desc); labelDescription->setText(desc);
} }
if(item->text()=="Сг"){ if (item->text()=="Сг")
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size")); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
labelDescription->setText(desc); labelDescription->setText(desc);
} }
return; return;
} }
if(radioButtonStandartTable->isChecked()){ if (radioButtonStandartTable->isChecked())
{
VStandartTableCell stable = data->GetStandartTableCell(item->text()); VStandartTableCell stable = data->GetStandartTableCell(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text()))
.arg(stable.GetDescription()); .arg(stable.GetDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonIncrements->isChecked()){ if (radioButtonIncrements->isChecked())
{
VIncrementTableRow itable = data->GetIncrementTableRow(item->text()); VIncrementTableRow itable = data->GetIncrementTableRow(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
.arg(itable.getDescription()); .arg(itable.getDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonLengthLine->isChecked()){ if (radioButtonLengthLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text()))
.arg(tr("Line length")); .arg(tr("Line length"));
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonLengthArc->isChecked()){ if (radioButtonLengthArc->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(item->text()))
.arg(tr("Arc length")); .arg(tr("Arc length"));
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonLengthCurve->isChecked()){ if (radioButtonLengthCurve->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text()))
.arg(tr("Curve length")); .arg(tr("Curve length"));
labelDescription->setText(desc); labelDescription->setText(desc);
@ -389,7 +473,8 @@ void DialogTool::ValChenged(int row){
} }
} }
void DialogTool::UpdateList(){ void DialogTool::UpdateList()
{
Q_ASSERT(radioButtonSizeGrowth != 0); Q_ASSERT(radioButtonSizeGrowth != 0);
Q_ASSERT(radioButtonStandartTable != 0); Q_ASSERT(radioButtonStandartTable != 0);
Q_ASSERT(radioButtonIncrements != 0); Q_ASSERT(radioButtonIncrements != 0);
@ -397,28 +482,36 @@ void DialogTool::UpdateList(){
Q_ASSERT(radioButtonLengthArc != 0); Q_ASSERT(radioButtonLengthArc != 0);
Q_ASSERT(radioButtonLengthCurve != 0); Q_ASSERT(radioButtonLengthCurve != 0);
if(radioButtonSizeGrowth->isChecked()){ if (radioButtonSizeGrowth->isChecked())
{
ShowVariable(data->DataBase()); ShowVariable(data->DataBase());
} }
if(radioButtonStandartTable->isChecked()){ if (radioButtonStandartTable->isChecked())
{
ShowVariable(data->DataStandartTable()); ShowVariable(data->DataStandartTable());
} }
if(radioButtonIncrements->isChecked()){ if (radioButtonIncrements->isChecked())
{
ShowVariable(data->DataIncrementTable()); ShowVariable(data->DataIncrementTable());
} }
if(radioButtonLengthLine->isChecked()){ if (radioButtonLengthLine->isChecked())
{
ShowVariable(data->DataLengthLines()); ShowVariable(data->DataLengthLines());
} }
if(radioButtonLengthArc->isChecked()){ if (radioButtonLengthArc->isChecked())
{
ShowVariable(data->DataLengthArcs()); ShowVariable(data->DataLengthArcs());
} }
if(radioButtonLengthCurve->isChecked()){ if (radioButtonLengthCurve->isChecked())
{
ShowVariable(data->DataLengthSplines()); ShowVariable(data->DataLengthSplines());
} }
} }
bool DialogTool::CheckObject(const qint64 &id){ bool DialogTool::CheckObject(const qint64 &id)
if(mode == Draw::Calculation || idDetail == 0){ {
if (mode == Draw::Calculation || idDetail == 0)
{
return false; return false;
} }
VDetail det = data->GetDetail(idDetail); VDetail det = data->GetDetail(idDetail);
@ -426,20 +519,23 @@ bool DialogTool::CheckObject(const qint64 &id){
} }
template <class key, class val> template <class key, class val>
void DialogTool::ShowVariable(const QHash<key, val> *var){ void DialogTool::ShowVariable(const QHash<key, val> *var)
{
Q_ASSERT(listWidget != 0); Q_ASSERT(listWidget != 0);
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->clear(); listWidget->clear();
QHashIterator<key, val> i(*var); QHashIterator<key, val> i(*var);
QMap<key, val> map; QMap<key, val> map;
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
map.insert(i.key(), i.value()); map.insert(i.key(), i.value());
} }
QMapIterator<key, val> iMap(map); QMapIterator<key, val> iMap(map);
while (iMap.hasNext()) { while (iMap.hasNext())
{
iMap.next(); iMap.next();
QListWidgetItem *item = new QListWidgetItem(iMap.key()); QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));

View File

@ -25,11 +25,11 @@
#include <QDialog> #include <QDialog>
#include <container/vcontainer.h> #include <container/vcontainer.h>
class DialogTool : public QDialog{ class DialogTool : public QDialog
{
Q_OBJECT Q_OBJECT
public: public:
DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
virtual ~DialogTool() {} virtual ~DialogTool() {}
inline qint64 getIdDetail() const {return idDetail;} inline qint64 getIdDetail() const {return idDetail;}
inline void setIdDetail(const qint64 &value) {idDetail = value;} inline void setIdDetail(const qint64 &value) {idDetail = value;}

View File

@ -1,9 +1,10 @@
#include "dialogtriangle.h" #include "dialogtriangle.h"
#include "ui_dialogtriangle.h" #include "ui_dialogtriangle.h"
DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0), :DialogTool(data, mode, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
axisP2Id(0), firstPointId(0), secondPointId(0){ axisP2Id(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -19,30 +20,41 @@ DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
} }
DialogTriangle::~DialogTriangle(){ DialogTriangle::~DialogTriangle()
{
delete ui; delete ui;
} }
void DialogTriangle::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogTriangle::ChoosedObject(qint64 id, Scene::Scenes type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
switch(number){ switch (number)
{
case (0): case (0):
ChangeCurrentText(ui->comboBoxAxisP1, point.name()); ChangeCurrentText(ui->comboBoxAxisP1, point.name());
number++; number++;
@ -62,7 +74,8 @@ void DialogTriangle::ChoosedObject(qint64 id, Scene::Scenes type){
ChangeCurrentText(ui->comboBoxSecondPoint, point.name()); ChangeCurrentText(ui->comboBoxSecondPoint, point.name());
number = 0; number = 0;
emit ToolTip(tr("")); emit ToolTip(tr(""));
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
break; break;
@ -70,7 +83,8 @@ void DialogTriangle::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogTriangle::DialogAccepted(){ void DialogTriangle::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
@ -79,28 +93,32 @@ void DialogTriangle::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogTriangle::setPointName(const QString &value){ void DialogTriangle::setPointName(const QString &value)
{
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
void DialogTriangle::setSecondPointId(const qint64 &value, const qint64 &id){ void DialogTriangle::setSecondPointId(const qint64 &value, const qint64 &id)
{
secondPointId = value; secondPointId = value;
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
void DialogTriangle::setFirstPointId(const qint64 &value, const qint64 &id){ void DialogTriangle::setFirstPointId(const qint64 &value, const qint64 &id)
{
firstPointId = value; firstPointId = value;
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
void DialogTriangle::setAxisP2Id(const qint64 &value, const qint64 &id){ void DialogTriangle::setAxisP2Id(const qint64 &value, const qint64 &id)
{
axisP2Id = value; axisP2Id = value;
setCurrentPointId(ui->comboBoxAxisP2, axisP2Id, value, id); setCurrentPointId(ui->comboBoxAxisP2, axisP2Id, value, id);
} }
void DialogTriangle::setAxisP1Id(const qint64 &value, const qint64 &id){ void DialogTriangle::setAxisP1Id(const qint64 &value, const qint64 &id)
{
axisP1Id = value; axisP1Id = value;
setCurrentPointId(ui->comboBoxAxisP1, axisP1Id, value, id); setCurrentPointId(ui->comboBoxAxisP1, axisP1Id, value, id);
} }

View File

@ -24,15 +24,16 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogTriangle; class DialogTriangle;
} }
class DialogTriangle : public DialogTool{ class DialogTriangle : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogTriangle(); ~DialogTriangle();
inline qint64 getAxisP1Id() const {return axisP1Id;} inline qint64 getAxisP1Id() const {return axisP1Id;}
void setAxisP1Id(const qint64 &value, const qint64 &id); void setAxisP1Id(const qint64 &value, const qint64 &id);

View File

@ -21,11 +21,13 @@
#include "vexception.h" #include "vexception.h"
VException::VException(const QString &what):QException(), what(what){ VException::VException(const QString &what):QException(), what(what)
Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty"); {
Q_ASSERT_X(what.isEmpty() == false, Q_FUNC_INFO, "Error message is empty");
} }
QString VException::ErrorMessage() const{ QString VException::ErrorMessage() const
{
QString error = QString("Exception: %1").arg(what); QString error = QString("Exception: %1").arg(what);
return error; return error;
} }

View File

@ -25,7 +25,8 @@
#include <QException> #include <QException>
class VException : public QException{ class VException : public QException
{
public: public:
VException(const QString &what); VException(const QString &what);
VException(const VException &e):what(e.What()){} VException(const VException &e):what(e.What()){}

View File

@ -21,13 +21,16 @@
#include "vexceptionbadid.h" #include "vexceptionbadid.h"
QString VExceptionBadId::ErrorMessage() const{ QString VExceptionBadId::ErrorMessage() const
{
QString error; QString error;
if(key.isEmpty()){ if (key.isEmpty())
{
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id); error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id);
} else { }
else
{
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key); error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key);
} }
return error; return error;
} }

View File

@ -24,12 +24,15 @@
#include "vexception.h" #include "vexception.h"
class VExceptionBadId : public VException{ class VExceptionBadId : public VException
{
public: public:
VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id), VExceptionBadId(const QString &what, const qint64 &id)
key(QString()){} :VException(what), id(id), key(QString()){}
VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key){} VExceptionBadId(const QString &what, const QString &key)
VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){} :VException(what), id(0), key(key){}
VExceptionBadId(const VExceptionBadId &e)
:VException(e), id(e.BadId()), key(e.BadKey()){}
virtual ~VExceptionBadId() noexcept(true){} virtual ~VExceptionBadId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
inline qint64 BadId() const {return id; } inline qint64 BadId() const {return id; }

View File

@ -22,11 +22,13 @@
#include "vexceptionconversionerror.h" #include "vexceptionconversionerror.h"
VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str) VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str)
:VException(what), str(str){ :VException(what), str(str)
Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty"); {
Q_ASSERT_X(str.isEmpty() == false, Q_FUNC_INFO, "Error converting string is empty");
} }
QString VExceptionConversionError::ErrorMessage() const{ QString VExceptionConversionError::ErrorMessage() const
{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str); QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
return error; return error;
} }

View File

@ -24,10 +24,12 @@
#include "vexception.h" #include "vexception.h"
class VExceptionConversionError : public VException{ class VExceptionConversionError : public VException
{
public: public:
VExceptionConversionError(const QString &what, const QString &str); VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e):VException(e), str(e.String()){} VExceptionConversionError(const VExceptionConversionError &e)
:VException(e), str(e.String()){}
virtual ~VExceptionConversionError() noexcept(true) {} virtual ~VExceptionConversionError() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
inline QString String() const {return str;} inline QString String() const {return str;}

View File

@ -22,22 +22,25 @@
#include "vexceptionemptyparameter.h" #include "vexceptionemptyparameter.h"
VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name, VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
const QDomElement &domElement): VException(what), const QDomElement &domElement)
name(name), tagText(QString()), tagName(QString()), lineNumber(-1){ : VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1)
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Parameter name is empty"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "Parameter name is empty");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
QString VExceptionEmptyParameter::ErrorMessage() const{ QString VExceptionEmptyParameter::ErrorMessage() const
{
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name); QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
return error; return error;
} }
QString VExceptionEmptyParameter::DetailedInformation() const{ QString VExceptionEmptyParameter::DetailedInformation() const
{
QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail; return detail;
} }

View File

@ -24,12 +24,13 @@
#include "vexception.h" #include "vexception.h"
class VExceptionEmptyParameter : public VException{ class VExceptionEmptyParameter : public VException
{
public: public:
VExceptionEmptyParameter(const QString &what, const QString &name, VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement);
const QDomElement &domElement); VExceptionEmptyParameter(const VExceptionEmptyParameter &e)
VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e), name(e.Name()), :VException(e), name(e.Name()), tagText(e.TagText()), tagName(e.TagName()),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){} lineNumber(e.LineNumber()){}
virtual ~VExceptionEmptyParameter() noexcept(true) {} virtual ~VExceptionEmptyParameter() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;

View File

@ -22,33 +22,41 @@
#include "vexceptionobjecterror.h" #include "vexceptionobjecterror.h"
#include <QDebug> #include <QDebug>
VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement): VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement)
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1), moreInfo(QString()){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1), moreInfo(QString())
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
QString VExceptionObjectError::ErrorMessage() const{ QString VExceptionObjectError::ErrorMessage() const
{
QString error = QString("ExceptionObjectError: %1").arg(what); QString error = QString("ExceptionObjectError: %1").arg(what);
return error; return error;
} }
QString VExceptionObjectError::DetailedInformation() const{ QString VExceptionObjectError::DetailedInformation() const
{
QString detail; QString detail;
if(!moreInfo.isEmpty()){ if (moreInfo.isEmpty() == false)
{
QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
detail = QString("%1\n%2").arg(moreInfo, i); detail = QString("%1\n%2").arg(moreInfo, i);
} else { }
else
{
detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
} }
return detail; return detail;
} }
void VExceptionObjectError::AddMoreInformation(const QString &info){ void VExceptionObjectError::AddMoreInformation(const QString &info)
if(info.isEmpty()){ {
if (info.isEmpty())
{
qWarning()<<"Error additional information is empty."<<Q_FUNC_INFO; qWarning()<<"Error additional information is empty."<<Q_FUNC_INFO;
} }
this->moreInfo.append(info); this->moreInfo.append(info);

View File

@ -24,11 +24,13 @@
#include "vexception.h" #include "vexception.h"
class VExceptionObjectError : public VException{ class VExceptionObjectError : public VException
{
public: public:
VExceptionObjectError(const QString &what, const QDomElement &domElement); VExceptionObjectError(const QString &what, const QDomElement &domElement);
VExceptionObjectError(const VExceptionObjectError &e):VException(e), tagText(e.TagText()), VExceptionObjectError(const VExceptionObjectError &e)
tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){} :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()),
moreInfo(e.MoreInformation()){}
virtual ~VExceptionObjectError() noexcept(true) {} virtual ~VExceptionObjectError() noexcept(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;

View File

@ -1,20 +1,23 @@
#include "vexceptionuniqueid.h" #include "vexceptionuniqueid.h"
VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement) VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement)
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
QString VExceptionUniqueId::ErrorMessage() const{ QString VExceptionUniqueId::ErrorMessage() const
{
QString error = QString("ExceptionUniqueId: %1").arg(what); QString error = QString("ExceptionUniqueId: %1").arg(what);
return error; return error;
} }
QString VExceptionUniqueId::DetailedInformation() const{ QString VExceptionUniqueId::DetailedInformation() const
{
QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail; return detail;
} }

View File

@ -3,11 +3,12 @@
#include "vexception.h" #include "vexception.h"
class VExceptionUniqueId : public VException{ class VExceptionUniqueId : public VException
{
public: public:
VExceptionUniqueId(const QString &what, const QDomElement &domElement); VExceptionUniqueId(const QString &what, const QDomElement &domElement);
VExceptionUniqueId(const VExceptionUniqueId &e):VException(e), tagText(e.TagText()), VExceptionUniqueId(const VExceptionUniqueId &e)
tagName(e.TagName()), lineNumber(e.LineNumber()){} :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionUniqueId() noexcept(true){} virtual ~VExceptionUniqueId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;

View File

@ -22,21 +22,24 @@
#include "vexceptionwrongparameterid.h" #include "vexceptionwrongparameterid.h"
#include <QDebug> #include <QDebug>
VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement): VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement)
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
QString VExceptionWrongParameterId::ErrorMessage() const{ QString VExceptionWrongParameterId::ErrorMessage() const
{
QString error = QString("ExceptionWrongParameterId: %1").arg(what); QString error = QString("ExceptionWrongParameterId: %1").arg(what);
return error; return error;
} }
QString VExceptionWrongParameterId::DetailedInformation() const{ QString VExceptionWrongParameterId::DetailedInformation() const
{
QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail; return detail;
} }

View File

@ -24,11 +24,12 @@
#include "vexception.h" #include "vexception.h"
class VExceptionWrongParameterId : public VException{ class VExceptionWrongParameterId : public VException
{
public: public:
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement); VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e),tagText(e.TagText()), VExceptionWrongParameterId(const VExceptionWrongParameterId &e)
tagName(e.TagName()), lineNumber(e.LineNumber()){} :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionWrongParameterId() noexcept(true){} virtual ~VExceptionWrongParameterId() noexcept(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;

View File

@ -22,23 +22,23 @@
#include "varc.h" #include "varc.h"
#include <exception/vexception.h> #include <exception/vexception.h>
VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), VArc::VArc ()
center(0), points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0){ : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
} center(0), points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0){}
VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(*points), mode(mode), idObject(idObject){ center(center), points(*points), mode(mode), idObject(idObject){}
}
VArc::VArc(const VArc &arc): f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()), VArc::VArc(const VArc &arc)
: f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()), formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()), center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()),
idObject(arc.getIdObject()){ idObject(arc.getIdObject()){}
}
VArc &VArc::operator =(const VArc &arc){ VArc &VArc::operator =(const VArc &arc)
{
this->points = arc.GetDataPoints(); this->points = arc.GetDataPoints();
this->f1 = arc.GetF1(); this->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1(); this->formulaF1 = arc.GetFormulaF1();
@ -52,35 +52,43 @@ VArc &VArc::operator =(const VArc &arc){
return *this; return *this;
} }
QPointF VArc::GetCenterPoint() const{ QPointF VArc::GetCenterPoint() const
if(points.contains(center)){ {
if (points.contains(center))
{
return points.value(center).toQPointF(); return points.value(center).toQPointF();
} else { }
else
{
QString error = QString(tr("Can't find id = %1 in table.")).arg(center); QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
throw VException(error); throw VException(error);
} }
return QPointF(); return QPointF();
} }
QPointF VArc::GetP1() const{ QPointF VArc::GetP1() const
{
QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP1(GetCenterPoint(), p1); QLineF centerP1(GetCenterPoint(), p1);
centerP1.setAngle(f1); centerP1.setAngle(f1);
return centerP1.p2(); return centerP1.p2();
} }
QPointF VArc::GetP2 () const{ QPointF VArc::GetP2 () const
{
QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP2(GetCenterPoint(), p2); QLineF centerP2(GetCenterPoint(), p2);
centerP2.setAngle(f2); centerP2.setAngle(f2);
return centerP2.p2(); return centerP2.p2();
} }
const QHash<qint64, VPointF> VArc::GetDataPoints() const{ const QHash<qint64, VPointF> VArc::GetDataPoints() const
{
return points; return points;
} }
QPainterPath VArc::GetPath() const{ QPainterPath VArc::GetPath() const
{
QPainterPath Path; QPainterPath Path;
QPointF center = GetCenterPoint(); QPointF center = GetCenterPoint();
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2); QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
@ -90,7 +98,8 @@ QPainterPath VArc::GetPath() const{
return Path; return Path;
} }
qreal VArc::AngleArc() const{ qreal VArc::AngleArc() const
{
QLineF l1(0, 0, 100, 100); QLineF l1(0, 0, 100, 100);
l1.setAngle(f1); l1.setAngle(f1);
QLineF l2(0, 0, 100, 100); QLineF l2(0, 0, 100, 100);
@ -98,10 +107,13 @@ qreal VArc::AngleArc() const{
return l1.angleTo(l2); return l1.angleTo(l2);
} }
qint32 VArc::NumberSplOfArc() const{ qint32 VArc::NumberSplOfArc() const
{
qint32 angArc = static_cast<qint32> (AngleArc ()); qint32 angArc = static_cast<qint32> (AngleArc ());
switch( angArc ){ switch ( angArc )
case 0:{ {
case 0:
{
QString error = QString(tr("Angle of arc can't be 0 degree.")); QString error = QString(tr("Angle of arc can't be 0 degree."));
throw VException(error); throw VException(error);
} }
@ -118,46 +130,64 @@ qint32 VArc::NumberSplOfArc() const{
} }
} }
QVector<QPointF> VArc::GetPoints() const{ QVector<QPointF> VArc::GetPoints() const
{
QVector<QPointF> points; QVector<QPointF> points;
qint32 numberSpl = NumberSplOfArc(); qint32 numberSpl = NumberSplOfArc();
for(qint32 i = 1; i <= numberSpl; ++i){ for (qint32 i = 1; i <= numberSpl; ++i)
{
points<<SplOfArc ( i ); points<<SplOfArc ( i );
} }
return points; return points;
} }
QVector<QPointF> VArc::SplOfArc(qint32 number) const{ QVector<QPointF> VArc::SplOfArc(qint32 number) const
{
qint32 n = NumberSplOfArc (); qint32 n = NumberSplOfArc ();
if( number > n ){ if ( number > n )
{
QString error = QString(tr("Arc have not this number of part.")); QString error = QString(tr("Arc have not this number of part."));
throw VException(error); throw VException(error);
} }
qreal f1 = GetF1 (); qreal f1 = GetF1 ();
qreal f2 = GetF2 (); qreal f2 = GetF2 ();
qint32 i; qint32 i;
for ( i = 0; i < n; ++i ){ for ( i = 0; i < n; ++i )
if ( i == n - 1 ){ {
if ( i == n - 1 )
{
f2 = GetF2 (); f2 = GetF2 ();
} else { }
if ( f1 + 90 > 360 ){ else
{
if ( f1 + 90 > 360 )
{
f2 = f1 + 90 - 360; f2 = f1 + 90 - 360;
} else { }
else
{
f2 = f1 + 90; f2 = f1 + 90;
} }
} }
qreal anglF1, anglF2; qreal anglF1, anglF2;
if ( f1 + 90 > 360 ){ if ( f1 + 90 > 360 )
{
anglF1 = f1 + 90 - 360; anglF1 = f1 + 90 - 360;
} else { }
else
{
anglF1 = f1 + 90; anglF1 = f1 + 90;
} }
if ( f2 - 90 < 0 ){ if ( f2 - 90 < 0 )
{
anglF2 = 360 + f2 - 90; anglF2 = 360 + f2 - 90;
} else { }
else
{
anglF2 = f2 - 90; anglF2 = f2 - 90;
} }
if ( i + 1 == number ){ if ( i + 1 == number )
{
f1 = f2; f1 = f2;
return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.); return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.);
} }

View File

@ -27,7 +27,8 @@
/** /**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою. * @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/ */
class VArc{ class VArc
{
Q_DECLARE_TR_FUNCTIONS(VArc) Q_DECLARE_TR_FUNCTIONS(VArc)
public: public:
/** /**

View File

@ -21,20 +21,21 @@
#include "vdetail.h" #include "vdetail.h"
VDetail::VDetail():nodes(QVector<VNodeDetail>()),name(QString()), mx(0), my(0), supplement(true), closed(true), VDetail::VDetail()
width(10){ :nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), supplement(true), closed(true), width(10){}
}
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes):nodes(QVector<VNodeDetail>()), VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
name(name), mx(0), my(0), supplement(true), closed(true), width(10){ :nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), supplement(true), closed(true), width(10)
{
this->nodes = nodes; this->nodes = nodes;
} }
VDetail::VDetail(const VDetail &detail):nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), VDetail::VDetail(const VDetail &detail)
my(detail.getMy()), supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){ :nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
} supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){}
VDetail &VDetail::operator =(const VDetail &detail){ VDetail &VDetail::operator =(const VDetail &detail)
{
nodes = detail.getNodes(); nodes = detail.getNodes();
name = detail.getName(); name = detail.getName();
mx = detail.getMx(); mx = detail.getMx();
@ -45,7 +46,8 @@ VDetail &VDetail::operator =(const VDetail &detail){
return *this; return *this;
} }
void VDetail::Clear(){ void VDetail::Clear()
{
nodes.clear(); nodes.clear();
name.clear(); name.clear();
mx = 0; mx = 0;
@ -55,17 +57,20 @@ void VDetail::Clear(){
width = 10; width = 10;
} }
bool VDetail::Containes(const qint64 &id) const{ bool VDetail::Containes(const qint64 &id) const
for(qint32 i = 0; i < nodes.size(); ++i){ {
for (qint32 i = 0; i < nodes.size(); ++i)
{
VNodeDetail node = nodes[i]; VNodeDetail node = nodes[i];
if(node.getId() == id){ if (node.getId() == id)
{
return true; return true;
} }
} }
return false; return false;
} }
VNodeDetail &VDetail::operator [](int indx){ VNodeDetail &VDetail::operator [](int indx)
{
return nodes[indx]; return nodes[indx];
} }

View File

@ -24,7 +24,8 @@
#include "vnodedetail.h" #include "vnodedetail.h"
namespace Detail { namespace Detail
{
enum Contour { OpenContour, CloseContour }; enum Contour { OpenContour, CloseContour };
Q_DECLARE_FLAGS(Contours, Contour) Q_DECLARE_FLAGS(Contours, Contour)
@ -34,7 +35,8 @@ namespace Detail {
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours)
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
class VDetail{ class VDetail
{
public: public:
VDetail(); VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);

View File

@ -21,20 +21,19 @@
#include "vnodedetail.h" #include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling), VNodeDetail::VNodeDetail()
typeNode(NodeDetail::Contour), mx(0), my(0){ :id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling), typeNode(NodeDetail::Contour), mx(0), my(0){}
}
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx, qreal my):id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), qreal mx, qreal my)
mx(mx), my(my){ :id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), mx(mx), my(my){}
}
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()), VNodeDetail::VNodeDetail(const VNodeDetail &node)
mode(node.getMode()), typeNode(node.getTypeNode()), mx(node.getMx()), my(node.getMy()){ :id(node.getId()), typeTool(node.getTypeTool()), mode(node.getMode()), typeNode(node.getTypeNode()),
} mx(node.getMx()), my(node.getMy()){}
VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node){ VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node)
{
id = node.getId(); id = node.getId();
typeTool = node.getTypeTool(); typeTool = node.getTypeTool();
mode = node.getMode(); mode = node.getMode();

View File

@ -25,13 +25,15 @@
#include <QMetaType> #include <QMetaType>
#include "options.h" #include "options.h"
namespace NodeDetail { namespace NodeDetail
{
enum NodeDetail { Contour, Modeling }; enum NodeDetail { Contour, Modeling };
Q_DECLARE_FLAGS(NodeDetails, NodeDetail) Q_DECLARE_FLAGS(NodeDetails, NodeDetail)
} }
Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails) Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails)
class VNodeDetail{ class VNodeDetail
{
public: public:
VNodeDetail(); VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,

View File

@ -21,31 +21,34 @@
#include "vspline.h" #include "vspline.h"
VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), VSpline::VSpline()
kCurve(1), points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0){ :p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1),
} points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0){}
VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), VSpline::VSpline ( const VSpline & spline )
p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), :p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()),
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()),
mode(spline.getMode()), idObject(spline.getIdObject()){ points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()){}
}
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject)
p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(*points), :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
mode(mode), idObject(idObject){ kCurve(kCurve), points(*points), mode(mode), idObject(idObject)
{
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
} }
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), qreal kCurve, Draw::Draws mode, qint64 idObject)
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode), idObject(idObject){ :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode),
idObject(idObject)
{
ModifiSpl ( p1, p2, p3, p4, kCurve); ModifiSpl ( p1, p2, p3, p4, kCurve);
} }
void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve){ qreal kAsm1, qreal kAsm2, qreal kCurve)
{
this->p1 = p1; this->p1 = p1;
this->p4 = p4; this->p4 = p4;
this->angle1 = angle1; this->angle1 = angle1;
@ -73,7 +76,8 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
this->p3 = p4p3.p2(); this->p3 = p4p3.p2();
} }
void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve){ void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve)
{
this->p1 = p1; this->p1 = p1;
this->p2 = p2; this->p2 = p2;
this->p3 = p3; this->p3 = p3;
@ -123,37 +127,48 @@ void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCu
// p4 = QPointF(p4.x()+mx, p4.y()+my); // p4 = QPointF(p4.x()+mx, p4.y()+my);
//} //}
VPointF VSpline::GetPointP1() const{ VPointF VSpline::GetPointP1() const
if(points.contains(p1)){ {
if (points.contains(p1))
{
return points.value(p1); return points.value(p1);
} else { }
else
{
qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці."; qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці.";
throw "Не можу знайти точку за id."; throw "Не можу знайти точку за id.";
} }
return VPointF(); return VPointF();
} }
VPointF VSpline::GetPointP4() const{ VPointF VSpline::GetPointP4() const
if(points.contains(p4)){ {
if (points.contains(p4))
{
return points.value(p4); return points.value(p4);
} else { }
else
{
qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці."; qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці.";
throw "Не можу знайти точку за id."; throw "Не можу знайти точку за id.";
} }
return VPointF(); return VPointF();
} }
qreal VSpline::GetLength () const{ qreal VSpline::GetLength () const
{
return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF()); return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF());
} }
QString VSpline::GetName() const{ QString VSpline::GetName() const
{
VPointF first = GetPointP1(); VPointF first = GetPointP1();
VPointF second = GetPointP4(); VPointF second = GetPointP4();
return QString("Spl_%1_%2").arg(first.name(), second.name()); return QString("Spl_%1_%2").arg(first.name(), second.name());
} }
QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) const{ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) const
{
QVector<qreal> px; QVector<qreal> px;
QVector<qreal> py; QVector<qreal> py;
px.append ( GetPointP1 ().x () ); px.append ( GetPointP1 ().x () );
@ -168,10 +183,12 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
qint32 i = 0; qint32 i = 0;
QPointF crosPoint; QPointF crosPoint;
QLineF::IntersectType type = QLineF::NoIntersection; QLineF::IntersectType type = QLineF::NoIntersection;
for ( i = 0; i < px.count()-1; ++i ){ for ( i = 0; i < px.count()-1; ++i )
{
type = line.intersect(QLineF ( QPointF ( px[i], py[i] ), type = line.intersect(QLineF ( QPointF ( px[i], py[i] ),
QPointF ( px[i+1], py[i+1] )), &crosPoint); QPointF ( px[i+1], py[i+1] )), &crosPoint);
if ( type == QLineF::BoundedIntersection ){ if ( type == QLineF::BoundedIntersection )
{
*intersectionPoint = crosPoint; *intersectionPoint = crosPoint;
return type; return type;
} }
@ -236,7 +253,8 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
// } // }
//} //}
QVector<QPointF> VSpline::GetPoints () const{ QVector<QPointF> VSpline::GetPoints () const
{
return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF()); return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint()); // QLineF line1(points.at(0).toPoint(), points.at(1).toPoint());
// line1.setLength(500); // line1.setLength(500);
@ -260,7 +278,8 @@ QVector<QPointF> VSpline::GetPoints () const{
// } // }
} }
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4){ QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4)
{
QVector<QPointF> pvector; QVector<QPointF> pvector;
QVector<qreal> x; QVector<qreal> x;
QVector<qreal> y; QVector<qreal> y;
@ -272,17 +291,20 @@ QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF
p3.x (), p3.y (), p4.x (), p4.y (), 0, wx, wy ); p3.x (), p3.y (), p4.x (), p4.y (), 0, wx, wy );
x.append ( p4.x () ); x.append ( p4.x () );
y.append ( p4.y () ); y.append ( p4.y () );
for ( qint32 i = 0; i < x.count(); ++i ){ for ( qint32 i = 0; i < x.count(); ++i )
{
pvector.append( QPointF ( x[i], y[i] ) ); pvector.append( QPointF ( x[i], y[i] ) );
} }
return pvector; return pvector;
} }
qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) const{ qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) const
{
QPainterPath splinePath; QPainterPath splinePath;
QVector<QPointF> points = GetPoints (p1, p2, p3, p4); QVector<QPointF> points = GetPoints (p1, p2, p3, p4);
splinePath.moveTo(points[0]); splinePath.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){ for (qint32 i = 1; i < points.count(); ++i)
{
splinePath.lineTo(points[i]); splinePath.lineTo(points[i]);
} }
return splinePath.length(); return splinePath.length();
@ -290,7 +312,8 @@ qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) c
void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
qreal x3, qreal y3, qreal x4, qreal y4, qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py){ qint16 level, QVector<qreal> &px, QVector<qreal> &py)
{
const double curve_collinearity_epsilon = 1e-30; const double curve_collinearity_epsilon = 1e-30;
const double curve_angle_tolerance_epsilon = 0.01; const double curve_angle_tolerance_epsilon = 0.01;
const double m_angle_tolerance = 0.0; const double m_angle_tolerance = 0.0;
@ -360,19 +383,31 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return; return;
} }
if (d2 <= 0) if (d2 <= 0)
{
d2 = CalcSqDistance(x2, y2, x1, y1); d2 = CalcSqDistance(x2, y2, x1, y1);
}
else if (d2 >= 1) else if (d2 >= 1)
{
d2 = CalcSqDistance(x2, y2, x4, y4); d2 = CalcSqDistance(x2, y2, x4, y4);
}
else else
{
d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy); d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy);
}
if (d3 <= 0) if (d3 <= 0)
{
d3 = CalcSqDistance(x3, y3, x1, y1); d3 = CalcSqDistance(x3, y3, x1, y1);
}
else if (d3 >= 1) else if (d3 >= 1)
{
d3 = CalcSqDistance(x3, y3, x4, y4); d3 = CalcSqDistance(x3, y3, x4, y4);
}
else else
{
d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy); d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy);
} }
}
if (d2 > d3) if (d2 > d3)
{ {
if (d2 < m_distance_tolerance_square) if (d2 < m_distance_tolerance_square)
@ -414,7 +449,9 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
//---------------------- //----------------------
da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2)); da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
if (da1 >= M_PI) if (da1 >= M_PI)
{
da1 = 2*M_PI - da1; da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance) if (da1 < m_angle_tolerance)
{ {
@ -460,7 +497,10 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
// Angle Condition // Angle Condition
//---------------------- //----------------------
da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
if(da1 >= M_PI) da1 = 2*M_PI - da1; if (da1 >= M_PI)
{
da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance) if (da1 < m_angle_tolerance)
{ {
@ -511,8 +551,14 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
k = atan2(y3 - y2, x3 - x2); k = atan2(y3 - y2, x3 - x2);
da1 = fabs(k - atan2(y2 - y1, x2 - x1)); da1 = fabs(k - atan2(y2 - y1, x2 - x1));
da2 = fabs(atan2(y4 - y3, x4 - x3) - k); da2 = fabs(atan2(y4 - y3, x4 - x3) - k);
if(da1 >= M_PI) da1 = 2*M_PI - da1; if (da1 >= M_PI)
if(da2 >= M_PI) da2 = 2*M_PI - da2; {
da1 = 2*M_PI - da1;
}
if (da2 >= M_PI)
{
da2 = 2*M_PI - da2;
}
if (da1 + da2 < m_angle_tolerance) if (da1 + da2 < m_angle_tolerance)
{ {
@ -551,28 +597,33 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast<qint16>(level + 1), px, py); PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast<qint16>(level + 1), px, py);
} }
qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2){ qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2)
{
qreal dx = x2 - x1; qreal dx = x2 - x1;
qreal dy = y2 - y1; qreal dy = y2 - y1;
return dx * dx + dy * dy; return dx * dx + dy * dy;
} }
QPainterPath VSpline::GetPath() const{ QPainterPath VSpline::GetPath() const
{
QPainterPath splinePath; QPainterPath splinePath;
QVector<QPointF> points = GetPoints (); QVector<QPointF> points = GetPoints ();
if(points.count() >= 2){ if (points.count() >= 2)
for (qint32 i = 0; i < points.count()-1; ++i){ {
for (qint32 i = 0; i < points.count()-1; ++i)
{
splinePath.moveTo(points[i]); splinePath.moveTo(points[i]);
splinePath.lineTo(points[i+1]); splinePath.lineTo(points[i+1]);
} }
} else { }
else
{
qWarning()<<"points.count() < 2"<<Q_FUNC_INFO; qWarning()<<"points.count() < 2"<<Q_FUNC_INFO;
} }
return splinePath; return splinePath;
} }
/* Cubic equation solution. Real coefficients case. /* Cubic equation solution. Real coefficients case.
int Cubic(double *x,double a,double b,double c); int Cubic(double *x,double a,double b,double c);
Parameters: Parameters:
x - solution array (size 3). On output: x - solution array (size 3). On output:
@ -588,7 +639,7 @@ QPainterPath VSpline::GetPath() const{
*/ */
//qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){ //qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// qreal q,r,r2,q3; // qreal q,r,r2,q3;
//
// q = (a*a - 3.*b)/9.; // q = (a*a - 3.*b)/9.;
// r = (a*(2.*a*a - 9.*b) + 27.*c)/54.; // r = (a*(2.*a*a - 9.*b) + 27.*c)/54.;
// r2 = r*r; // r2 = r*r;
@ -624,24 +675,24 @@ QPainterPath VSpline::GetPath() const{
// return(1); // return(1);
// } // }
//} //}
//
//qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, //qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3,
// qreal curve_coord4, qreal point_coord) const{ // qreal curve_coord4, qreal point_coord) const{
// qreal P1, P2, P3, P4, Bt; // qreal P1, P2, P3, P4, Bt;
// qreal a, b, c, d, ret_t; // qreal a, b, c, d, ret_t;
//
// qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal))); // qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal)));
// P1 = curve_coord1; // P1 = curve_coord1;
// P2 = curve_coord2; // P2 = curve_coord2;
// P3 = curve_coord3; // P3 = curve_coord3;
// P4 = curve_coord4; // P4 = curve_coord4;
// Bt = point_coord; // Bt = point_coord;
//
// a = -P1 + 3*P2 - 3*P3 + P4; // a = -P1 + 3*P2 - 3*P3 + P4;
// b = 3*P1 - 6*P2 + 3*P3; // b = 3*P1 - 6*P2 + 3*P3;
// c = -3*P1 + 3*P2; // c = -3*P1 + 3*P2;
// d = -Bt + P1; // d = -Bt + P1;
//
// if(Cubic(t, b/a, c/a, d/a) == 3){ // if(Cubic(t, b/a, c/a, d/a) == 3){
// ret_t = t[2]; // ret_t = t[2];
// } else { // } else {
@ -651,7 +702,7 @@ QPainterPath VSpline::GetPath() const{
// * Повертається три значення, але експереминтально знайдено що шукане // * Повертається три значення, але експереминтально знайдено що шукане
// * значення знаходиться в третьому. // * значення знаходиться в третьому.
// */ // */
//
// free(t); // free(t);
// if(ret_t<0 || ret_t>1){ // if(ret_t<0 || ret_t>1){
// qDebug()<<"Неправильне значення параметра. фунція calc_t"; // qDebug()<<"Неправильне значення параметра. фунція calc_t";
@ -675,7 +726,7 @@ QPainterPath VSpline::GetPath() const{
// else // else
// return t_y; // return t_y;
//} //}
//
//void VSpline::Mirror(const QPointF Pmirror){ //void VSpline::Mirror(const QPointF Pmirror){
// QPointF P1 = p1; // QPointF P1 = p1;
// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y()); // P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y());
@ -697,7 +748,8 @@ QPainterPath VSpline::GetPath() const{
//} //}
QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qreal angle2, qreal kAsm1, QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve){ qreal kAsm2, qreal kCurve)
{
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 ); p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90; qreal L = 0, radius = 0, angle = 90;
@ -712,7 +764,8 @@ QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qre
return GetPoints(p1, p2, p3, p4); return GetPoints(p1, p2, p3, p4);
} }
VSpline &VSpline::operator =(const VSpline &spline){ VSpline &VSpline::operator =(const VSpline &spline)
{
this->p1 = spline.GetP1 (); this->p1 = spline.GetP1 ();
this->p2 = spline.GetP2 (); this->p2 = spline.GetP2 ();
this->p3 = spline.GetP3 (); this->p3 = spline.GetP3 ();

View File

@ -29,7 +29,8 @@
/** /**
* @brief VSpline клас, що реалізує сплайн. * @brief VSpline клас, що реалізує сплайн.
*/ */
class VSpline{ class VSpline
{
public: public:
VSpline(); VSpline();
/** /**

View File

@ -22,36 +22,41 @@
#include "vsplinepath.h" #include "vsplinepath.h"
#include <exception/vexception.h> #include <exception/vexception.h>
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), VSplinePath::VSplinePath()
points(QHash<qint64, VPointF>()), idObject(0){ : path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(QHash<qint64, VPointF>()), idObject(0){}
}
VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector<VSplinePoint>()), VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject)
kCurve(kCurve), mode(mode), points(*points), idObject(idObject){ : path(QVector<VSplinePoint>()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject){}
}
VSplinePath::VSplinePath(const VSplinePath &splPath): path(*splPath.GetPoint()), VSplinePath::VSplinePath(const VSplinePath &splPath)
kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()), : path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()),
idObject(splPath.getIdObject()){ idObject(splPath.getIdObject()){}
}
void VSplinePath::append(VSplinePoint point){ void VSplinePath::append(VSplinePoint point)
{
path.append(point); path.append(point);
} }
qint32 VSplinePath::Count() const{ qint32 VSplinePath::Count() const
if(path.size() == 0){ {
if (path.size() == 0)
{
return 0; return 0;
} else { }
else
{
return path.size() - 1; return path.size() - 1;
} }
} }
VSpline VSplinePath::GetSpline(qint32 index) const{ VSpline VSplinePath::GetSpline(qint32 index) const
if(Count()<1){ {
if (Count()<1)
{
throw VException(tr("Not enough points to create the spline.")); throw VException(tr("Not enough points to create the spline."));
} }
if(index < 1 || index > Count()){ if (index < 1 || index > Count())
{
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
VSpline spl(&points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(), VSpline spl(&points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
@ -59,9 +64,11 @@ VSpline VSplinePath::GetSpline(qint32 index) const{
return spl; return spl;
} }
QPainterPath VSplinePath::GetPath() const{ QPainterPath VSplinePath::GetPath() const
{
QPainterPath painterPath; QPainterPath painterPath;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
{
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve);
painterPath.addPath(spl.GetPath()); painterPath.addPath(spl.GetPath());
@ -69,22 +76,27 @@ QPainterPath VSplinePath::GetPath() const{
return painterPath; return painterPath;
} }
QVector<QPointF> VSplinePath::GetPathPoints() const{ QVector<QPointF> VSplinePath::GetPathPoints() const
{
QVector<QPointF> pathPoints; QVector<QPointF> pathPoints;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
{
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve);
QVector<QPointF> splP = spl.GetPoints(); QVector<QPointF> splP = spl.GetPoints();
for(qint32 j = 0; j < splP.size(); ++j){ for (qint32 j = 0; j < splP.size(); ++j)
{
pathPoints.append(splP[j]); pathPoints.append(splP[j]);
} }
} }
return pathPoints; return pathPoints;
} }
qreal VSplinePath::GetLength() const{ qreal VSplinePath::GetLength() const
{
qreal length = 0; qreal length = 0;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
{
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), kCurve); path[i].KAsm1(), kCurve);
length += spl.GetLength(); length += spl.GetLength();
@ -92,29 +104,40 @@ qreal VSplinePath::GetLength() const{
return length; return length;
} }
void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point){ void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point)
if(indexSpline < 1 || indexSpline > Count()){ {
if (indexSpline < 1 || indexSpline > Count())
{
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if (pos == SplinePoint::FirstPoint)
{
path[indexSpline-1] = point; path[indexSpline-1] = point;
} else { }
else
{
path[indexSpline] = point; path[indexSpline] = point;
} }
} }
VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const{ VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const
if(indexSpline < 1 || indexSpline > Count()){ {
if (indexSpline < 1 || indexSpline > Count())
{
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if (pos == SplinePoint::FirstPoint)
{
return path.at(indexSpline-1); return path.at(indexSpline-1);
} else { }
else
{
return path.at(indexSpline); return path.at(indexSpline);
} }
} }
VSplinePath &VSplinePath::operator =(const VSplinePath &path){ VSplinePath &VSplinePath::operator =(const VSplinePath &path)
{
this->path = path.GetSplinePath(); this->path = path.GetSplinePath();
this->kCurve = path.getKCurve(); this->kCurve = path.getKCurve();
this->mode = path.getMode(); this->mode = path.getMode();
@ -123,6 +146,7 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path){
return *this; return *this;
} }
VSplinePoint & VSplinePath::operator[](int indx){ VSplinePoint & VSplinePath::operator[](int indx)
{
return path[indx]; return path[indx];
} }

View File

@ -27,7 +27,8 @@
#include "vspline.h" #include "vspline.h"
#include <QApplication> #include <QApplication>
namespace SplinePoint{ namespace SplinePoint
{
enum Position { FirstPoint, LastPoint }; enum Position { FirstPoint, LastPoint };
Q_DECLARE_FLAGS(Positions, Position) Q_DECLARE_FLAGS(Positions, Position)
} }
@ -36,7 +37,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
/** /**
* @brief The VSplinePath клас, що розраховує шлях сплайнів. * @brief The VSplinePath клас, що розраховує шлях сплайнів.
*/ */
class VSplinePath{ class VSplinePath
{
Q_DECLARE_TR_FUNCTIONS(VSplinePath) Q_DECLARE_TR_FUNCTIONS(VSplinePath)
public: public:
/** /**

View File

@ -21,19 +21,11 @@
#include "vsplinepoint.h" #include "vsplinepoint.h"
VSplinePoint::VSplinePoint():pSpline(0), angle(0), kAsm1(1), kAsm2(1){ VSplinePoint::VSplinePoint()
} :pSpline(0), angle(0), kAsm1(1), kAsm2(1){}
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle , qreal kAsm2):pSpline(pSpline),
angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){
}
VSplinePoint::VSplinePoint(const VSplinePoint &point):pSpline(point.P()), angle(point.Angle2()),
kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){
}
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2)
:pSpline(pSpline), angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){}
VSplinePoint::VSplinePoint(const VSplinePoint &point)
:pSpline(point.P()), angle(point.Angle2()), kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){}

View File

@ -27,7 +27,8 @@
/** /**
* @brief The VSplinePoint клас, що містить у собі інформацію про точки сплайну. * @brief The VSplinePoint клас, що містить у собі інформацію про точки сплайну.
*/ */
class VSplinePoint{ class VSplinePoint
{
public: public:
/** /**
* @brief VSplinePoint конструктор по замповчуванню. * @brief VSplinePoint конструктор по замповчуванню.

View File

@ -24,9 +24,11 @@
#include <QTextCodec> #include <QTextCodec>
#include "tablewindow.h" #include "tablewindow.h"
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg){ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit(); QByteArray localMsg = msg.toLocal8Bit();
switch (type) { switch (type)
{
case QtDebugMsg: case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function); context.function);
@ -46,7 +48,8 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
} }
} }
int main(int argc, char *argv[]){ int main(int argc, char *argv[])
{
qInstallMessageHandler(myMessageOutput); qInstallMessageHandler(myMessageOutput);
VApplication app(argc, argv); VApplication app(argc, argv);
@ -70,23 +73,31 @@ int main(int argc, char *argv[]){
QString fileName; QString fileName;
QRegExp rxArgOpenFile("-o");//parameter open file QRegExp rxArgOpenFile("-o");//parameter open file
if(args.size()>1){ if (args.size()>1)
for (int i = 1; i < args.size(); ++i) { {
if (rxArgOpenFile.indexIn(args.at(i)) != -1 ) { for (int i = 1; i < args.size(); ++i)
if(args.at(i+1).isEmpty() == false){ {
if (rxArgOpenFile.indexIn(args.at(i)) != -1 )
{
if (args.at(i+1).isEmpty() == false)
{
fileName = args.at(i+1); fileName = args.at(i+1);
qDebug() << args.at(i)<< ":" << fileName; qDebug() << args.at(i)<< ":" << fileName;
w.OpenPattern(fileName); w.OpenPattern(fileName);
} }
w.show(); w.show();
break; break;
} else { }
else
{
qDebug() << "Uknown arg:" << args.at(i); qDebug() << "Uknown arg:" << args.at(i);
w.show(); w.show();
break; break;
} }
} }
} else { }
else
{
w.show(); w.show();
} }
return app.exec(); return app.exec();

File diff suppressed because it is too large Load Diff

View File

@ -32,11 +32,13 @@
#include "tools/modelingTools/modelingtools.h" #include "tools/modelingTools/modelingtools.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
namespace Ui { namespace Ui
{
class MainWindow; class MainWindow;
} }
class MainWindow : public QMainWindow{ class MainWindow : public QMainWindow
{
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
@ -152,9 +154,8 @@ private:
void SetEnableWidgets(bool enable); void SetEnableWidgets(bool enable);
void SetEnableTool(bool enable); void SetEnableTool(bool enable);
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
void SetToolButton(bool checked, Tool::Tools t, const QString &cursor, void SetToolButton(bool checked, Tool::Tools t, const QString &cursor, const QString &toolTip,
const QString &toolTip,QSharedPointer<Dialog> &dialog, QSharedPointer<Dialog> &dialog, Func closeDialogSlot);
Func closeDialogSlot);
void MinimumScrollBar(); void MinimumScrollBar();
template <typename T> template <typename T>
void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,

View File

@ -31,14 +31,18 @@
#define widthMainLine toPixel(1.2) #define widthMainLine toPixel(1.2)
#define widthHairLine widthMainLine/3 #define widthHairLine widthMainLine/3
namespace Scene{ namespace Scene
{
enum Scene { Point, Line, Spline, Arc, SplinePath, Detail }; enum Scene { Point, Line, Spline, Arc, SplinePath, Detail };
Q_DECLARE_FLAGS(Scenes, Scene) Q_DECLARE_FLAGS(Scenes, Scene)
} }
Q_DECLARE_OPERATORS_FOR_FLAGS( Scene::Scenes ) Q_DECLARE_OPERATORS_FOR_FLAGS( Scene::Scenes )
namespace Tool{ namespace Tool
enum Tool {ArrowTool, {
enum Tool
{
ArrowTool,
SinglePointTool, SinglePointTool,
EndLineTool, EndLineTool,
LineTool, LineTool,
@ -68,7 +72,8 @@ Q_DECLARE_FLAGS(Sources, Source)
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools ) Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools )
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Sources ) Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Sources )
namespace Draw { namespace Draw
{
enum Draw { Calculation, Modeling }; enum Draw { Calculation, Modeling };
Q_DECLARE_FLAGS(Draws, Draw) Q_DECLARE_FLAGS(Draws, Draw)
} }

View File

@ -24,11 +24,12 @@
#include "widgets/vtablegraphicsview.h" #include "widgets/vtablegraphicsview.h"
#include "options.h" #include "options.h"
TableWindow::TableWindow(QWidget *parent) : TableWindow::TableWindow(QWidget *parent)
QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow), :QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow),
listDetails(QVector<VItem*>()), outItems(false), collidingItems(false), currentScene(0), listDetails(QVector<VItem*>()), outItems(false), collidingItems(false), currentScene(0),
paper(0), shadowPaper(0), listOutItems(0), listCollidingItems(QList<QGraphicsItem*>()), paper(0), shadowPaper(0), listOutItems(0), listCollidingItems(QList<QGraphicsItem*>()),
indexDetail(0), sceneRect(QRectF()){ indexDetail(0), sceneRect(QRectF())
{
ui->setupUi(this); ui->setupUi(this);
numberDetal = new QLabel("Залишилось 0 деталей.", this); numberDetal = new QLabel("Залишилось 0 деталей.", this);
colission = new QLabel("Колізій не знайдено.", this); colission = new QLabel("Колізій не знайдено.", this);
@ -57,11 +58,13 @@ TableWindow::TableWindow(QWidget *parent) :
connect(view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); connect(view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect);
} }
TableWindow::~TableWindow(){ TableWindow::~TableWindow()
{
delete ui; delete ui;
} }
void TableWindow::AddPaper(){ void TableWindow::AddPaper()
{
qreal x1, y1, x2, y2; qreal x1, y1, x2, y2;
sceneRect.getCoords(&x1, &y1, &x2, &y2); sceneRect.getCoords(&x1, &y1, &x2, &y2);
shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4));
@ -74,8 +77,10 @@ void TableWindow::AddPaper(){
qDebug()<<paper->rect().size().toSize(); qDebug()<<paper->rect().size().toSize();
} }
void TableWindow::AddDetail(){ void TableWindow::AddDetail()
if(indexDetail<listDetails.count()){ {
if (indexDetail<listDetails.count())
{
currentScene->clearSelection(); currentScene->clearSelection();
VItem* Detail = listDetails[indexDetail]; VItem* Detail = listDetails[indexDetail];
QObject::connect(Detail, SIGNAL(itemOut(int, bool)), this, SLOT(itemOut(int, bool))); QObject::connect(Detail, SIGNAL(itemOut(int, bool)), this, SLOT(itemOut(int, bool)));
@ -91,7 +96,8 @@ void TableWindow::AddDetail(){
Detail->setParentItem(paper); Detail->setParentItem(paper);
Detail->setSelected(true); Detail->setSelected(true);
indexDetail++; indexDetail++;
if(indexDetail==listDetails.count()){ if (indexDetail==listDetails.count())
{
ui->actionSave->setEnabled(true); ui->actionSave->setEnabled(true);
} }
} }
@ -101,7 +107,8 @@ void TableWindow::AddDetail(){
/* /*
* Отримуємо деталі розрахованої моделі для подальшого укладання. * Отримуємо деталі розрахованої моделі для подальшого укладання.
*/ */
void TableWindow::ModelChosen(QVector<VItem*> listDetails){ void TableWindow::ModelChosen(QVector<VItem*> listDetails)
{
this->listDetails = listDetails; this->listDetails = listDetails;
listOutItems = new QBitArray(this->listDetails.count()); listOutItems = new QBitArray(this->listDetails.count());
AddPaper(); AddPaper();
@ -110,23 +117,27 @@ void TableWindow::ModelChosen(QVector<VItem*> listDetails){
show(); show();
} }
void TableWindow::closeEvent(QCloseEvent *event){ void TableWindow::closeEvent(QCloseEvent *event)
{
event->ignore(); event->ignore();
StopTable(); StopTable();
} }
void TableWindow::moveToCenter(){ void TableWindow::moveToCenter()
{
QRect rect = frameGeometry(); QRect rect = frameGeometry();
rect.moveCenter(QDesktopWidget().availableGeometry().center()); rect.moveCenter(QDesktopWidget().availableGeometry().center());
move(rect.topLeft()); move(rect.topLeft());
} }
void TableWindow::showEvent ( QShowEvent * event ){ void TableWindow::showEvent ( QShowEvent * event )
{
QMainWindow::showEvent(event); QMainWindow::showEvent(event);
moveToCenter(); moveToCenter();
} }
void TableWindow::StopTable(){ void TableWindow::StopTable()
{
hide(); hide();
currentScene->clear(); currentScene->clear();
delete listOutItems; delete listOutItems;
@ -136,9 +147,11 @@ void TableWindow::StopTable(){
emit closed(); emit closed();
} }
void TableWindow::saveScene(){ void TableWindow::saveScene()
{
QString name = QFileDialog::getSaveFileName(0, tr("Save layout"), "", "Images (*.png);;Svg files (*.svg)"); QString name = QFileDialog::getSaveFileName(0, tr("Save layout"), "", "Images (*.png);;Svg files (*.svg)");
if(name.isNull()){ if (name.isNull())
{
return; return;
} }
@ -153,9 +166,12 @@ void TableWindow::saveScene(){
currentScene->setSceneRect(currentScene->itemsBoundingRect()); currentScene->setSceneRect(currentScene->itemsBoundingRect());
QFileInfo fi(name); QFileInfo fi(name);
if(fi.suffix() == "svg"){ if (fi.suffix() == "svg")
{
SvgFile(name); SvgFile(name);
} else if(fi.suffix() == "png"){ }
else if (fi.suffix() == "png")
{
PngFile(name); PngFile(name);
} }
@ -166,32 +182,43 @@ void TableWindow::saveScene(){
shadowPaper->setBrush(QBrush(Qt::black)); shadowPaper->setBrush(QBrush(Qt::black));
} }
void TableWindow::itemChect(bool flag){ void TableWindow::itemChect(bool flag)
{
ui->actionTurn->setDisabled(flag); ui->actionTurn->setDisabled(flag);
ui->actionMirror->setDisabled(flag); ui->actionMirror->setDisabled(flag);
} }
void TableWindow::checkNext(){ void TableWindow::checkNext()
if(outItems == true && collidingItems == true){ {
if (outItems == true && collidingItems == true)
{
colission->setText("Колізій не знайдено."); colission->setText("Колізій не знайдено.");
if(indexDetail==listDetails.count()){ if (indexDetail==listDetails.count())
{
ui->actionSave->setEnabled(true); ui->actionSave->setEnabled(true);
ui->actionNext->setDisabled(true); ui->actionNext->setDisabled(true);
} else { }
else
{
ui->actionNext->setDisabled(false); ui->actionNext->setDisabled(false);
ui->actionSave->setEnabled(false); ui->actionSave->setEnabled(false);
} }
} else { }
else
{
colission->setText("Знайдено колізії."); colission->setText("Знайдено колізії.");
ui->actionNext->setDisabled(true); ui->actionNext->setDisabled(true);
ui->actionSave->setEnabled(false); ui->actionSave->setEnabled(false);
} }
} }
void TableWindow::itemOut(int number, bool flag){ void TableWindow::itemOut(int number, bool flag)
{
listOutItems->setBit(number, flag); listOutItems->setBit(number, flag);
for( int i = 0; i < listOutItems->count(); ++i ){ for ( int i = 0; i < listOutItems->count(); ++i )
if(listOutItems->at(i)==true){ {
if (listOutItems->at(i)==true)
{
outItems=false; outItems=false;
qDebug()<<"itemOut::outItems="<<outItems<<"&& collidingItems"<<collidingItems; qDebug()<<"itemOut::outItems="<<outItems<<"&& collidingItems"<<collidingItems;
checkNext(); checkNext();
@ -202,50 +229,75 @@ void TableWindow::itemOut(int number, bool flag){
checkNext(); checkNext();
} }
void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number){ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
{
//qDebug()<<"number="<<number; //qDebug()<<"number="<<number;
if(number==0){ if (number==0)
if(listCollidingItems.isEmpty()==false){ {
if(listCollidingItems.contains(list.at(0))==true){ if (listCollidingItems.isEmpty()==false)
{
if (listCollidingItems.contains(list.at(0))==true)
{
listCollidingItems.removeAt(listCollidingItems.indexOf(list.at(0))); listCollidingItems.removeAt(listCollidingItems.indexOf(list.at(0)));
if(listCollidingItems.size()>1){ if (listCollidingItems.size()>1)
for( int i = 0; i < listCollidingItems.count(); ++i ){ {
QList<QGraphicsItem *> l = listCollidingItems.at(i)->collidingItems(); for ( int i = 0; i < listCollidingItems.count(); ++i )
if(l.size()-2 <= 0){ {
QList<QGraphicsItem *> lis = listCollidingItems.at(i)->collidingItems();
if (lis.size()-2 <= 0)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(i) ); VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(i) );
if (bitem == 0){ if (bitem == 0)
{
qDebug()<<"Не можу привести тип об'єкту"; qDebug()<<"Не можу привести тип об'єкту";
} else { }
else
{
bitem->setPen(QPen(Qt::black, toPixel(widthMainLine))); bitem->setPen(QPen(Qt::black, toPixel(widthMainLine)));
} }
listCollidingItems.removeAt(i); listCollidingItems.removeAt(i);
} }
} }
} else if(listCollidingItems.size()==1){ }
else if (listCollidingItems.size()==1)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(0) ); VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(0) );
if (bitem == 0){ if (bitem == 0)
{
qDebug()<<"Не можу привести тип об'єкту"; qDebug()<<"Не можу привести тип об'єкту";
} else { }
else
{
bitem->setPen(QPen(Qt::black, toPixel(widthMainLine))); bitem->setPen(QPen(Qt::black, toPixel(widthMainLine)));
} }
listCollidingItems.clear(); listCollidingItems.clear();
collidingItems = true; collidingItems = true;
} }
} else { }
else
{
collidingItems = true; collidingItems = true;
} }
} else { }
else
{
collidingItems = true; collidingItems = true;
} }
} else if(number==1){ }
if(list.contains(paper)==true){ else if (number==1)
{
if (list.contains(paper)==true)
{
list.removeAt(list.indexOf(paper)); list.removeAt(list.indexOf(paper));
} }
if(list.contains(shadowPaper)==true){ if (list.contains(shadowPaper)==true)
{
list.removeAt(list.indexOf(shadowPaper)); list.removeAt(list.indexOf(shadowPaper));
} }
for( int i = 0; i < list.count(); ++i ){ for ( int i = 0; i < list.count(); ++i )
if(listCollidingItems.contains(list.at(i))==false){ {
if (listCollidingItems.contains(list.at(i))==false)
{
listCollidingItems.append(list.at(i)); listCollidingItems.append(list.at(i));
} }
} }
@ -255,11 +307,13 @@ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number){
checkNext(); checkNext();
} }
void TableWindow::GetNextDetail(){ void TableWindow::GetNextDetail()
{
AddDetail(); AddDetail();
} }
void TableWindow::AddLength(){ void TableWindow::AddLength()
{
QRectF rect = currentScene->sceneRect(); QRectF rect = currentScene->sceneRect();
rect.setHeight(rect.height()+toPixel(279)); rect.setHeight(rect.height()+toPixel(279));
currentScene->setSceneRect(rect); currentScene->setSceneRect(rect);
@ -273,8 +327,10 @@ void TableWindow::AddLength(){
emit LengthChanged(); emit LengthChanged();
} }
void TableWindow::RemoveLength(){ void TableWindow::RemoveLength()
if(sceneRect.height()<=currentScene->sceneRect().height()-100){ {
if (sceneRect.height()<=currentScene->sceneRect().height()-100)
{
QRectF rect = currentScene->sceneRect(); QRectF rect = currentScene->sceneRect();
rect.setHeight(rect.height()-toPixel(279)); rect.setHeight(rect.height()-toPixel(279));
currentScene->setSceneRect(rect); currentScene->setSceneRect(rect);
@ -284,18 +340,24 @@ void TableWindow::RemoveLength(){
rect = paper->rect(); rect = paper->rect();
rect.setHeight(rect.height()-toPixel(279)); rect.setHeight(rect.height()-toPixel(279));
paper->setRect(rect); paper->setRect(rect);
if(sceneRect.height()==currentScene->sceneRect().height()){ if (sceneRect.height()==currentScene->sceneRect().height())
{
ui->actionRemove->setDisabled(true); ui->actionRemove->setDisabled(true);
} }
emit LengthChanged(); emit LengthChanged();
} else { }
else
{
ui->actionRemove->setDisabled(true); ui->actionRemove->setDisabled(true);
} }
} }
void TableWindow::keyPressEvent ( QKeyEvent * event ){ void TableWindow::keyPressEvent ( QKeyEvent * event )
if( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ){ {
if(ui->actionNext->isEnabled() == true ){ if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return )
{
if (ui->actionNext->isEnabled() == true )
{
AddDetail(); AddDetail();
qDebug()<<"Додали деталь."; qDebug()<<"Додали деталь.";
} }
@ -304,7 +366,8 @@ void TableWindow::keyPressEvent ( QKeyEvent * event ){
} }
void TableWindow::SvgFile(const QString &name) const{ void TableWindow::SvgFile(const QString &name) const
{
QSvgGenerator generator; QSvgGenerator generator;
generator.setFileName(name); generator.setFileName(name);
generator.setSize(paper->rect().size().toSize()); generator.setSize(paper->rect().size().toSize());
@ -322,11 +385,13 @@ void TableWindow::SvgFile(const QString &name) const{
painter.end(); painter.end();
} }
void TableWindow::PngFile(const QString &name) const{ void TableWindow::PngFile(const QString &name) const
{
QRectF r = paper->rect(); QRectF r = paper->rect();
qreal x=0, y=0, w=0, h=0; qreal x=0, y=0, w=0, h=0;
r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents
QImage image(QSize(static_cast<qint32>(w), static_cast<qint32>(h)), QImage::Format_ARGB32); // Create the image with the exact size of the shrunk scene // Create the image with the exact size of the shrunk scene
QImage image(QSize(static_cast<qint32>(w), static_cast<qint32>(h)), QImage::Format_ARGB32);
image.fill(Qt::transparent); // Start all pixels transparent image.fill(Qt::transparent); // Start all pixels transparent
QPainter painter(&image); QPainter painter(&image);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setFont( QFont( "Arial", 8, QFont::Normal ) );

View File

@ -25,14 +25,16 @@
#include <QMainWindow> #include <QMainWindow>
#include "widgets/vitem.h" #include "widgets/vitem.h"
namespace Ui { namespace Ui
{
class TableWindow; class TableWindow;
} }
/** /**
* @brief TableWindow клас вікна створення розкладки. * @brief TableWindow клас вікна створення розкладки.
*/ */
class TableWindow : public QMainWindow{ class TableWindow : public QMainWindow
{
Q_OBJECT Q_OBJECT
public: public:
/** /**

View File

@ -23,24 +23,31 @@
qreal VDrawTool::factor = 1; qreal VDrawTool::factor = 1;
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) : VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent)
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false), :VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw()){ nameActivDraw(doc->GetNameActivDraw())
{
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw);
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
connect(this->doc, &VDomDocument::ShowTool, this, &VDrawTool::ShowTool); connect(this->doc, &VDomDocument::ShowTool, this, &VDrawTool::ShowTool);
} }
void VDrawTool::AddRecord(const qint64 id, Tool::Tools toolType, VDomDocument *doc){ void VDrawTool::AddRecord(const qint64 id, Tool::Tools toolType, VDomDocument *doc)
{
qint64 cursor = doc->getCursor(); qint64 cursor = doc->getCursor();
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
if(cursor <= 0){ if (cursor <= 0)
{
history->append(VToolRecord(id, toolType, doc->GetNameActivDraw())); history->append(VToolRecord(id, toolType, doc->GetNameActivDraw()));
} else { }
else
{
qint32 index = 0; qint32 index = 0;
for(qint32 i = 0; i<history->size(); ++i){ for (qint32 i = 0; i<history->size(); ++i)
{
VToolRecord rec = history->at(i); VToolRecord rec = history->at(i);
if(rec.getId() == cursor){ if (rec.getId() == cursor)
{
index = i; index = i;
break; break;
} }
@ -49,49 +56,68 @@ void VDrawTool::AddRecord(const qint64 id, Tool::Tools toolType, VDomDocument *d
} }
} }
void VDrawTool::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VDrawTool::ShowTool(qint64 id, Qt::GlobalColor color, bool enable)
{
Q_UNUSED(id); Q_UNUSED(id);
Q_UNUSED(color); Q_UNUSED(color);
Q_UNUSED(enable); Q_UNUSED(enable);
} }
void VDrawTool::ChangedActivDraw(const QString newName){ void VDrawTool::ChangedActivDraw(const QString newName)
if(nameActivDraw == newName){ {
if (nameActivDraw == newName)
{
ignoreContextMenuEvent = false; ignoreContextMenuEvent = false;
} else { }
else
{
ignoreContextMenuEvent = true; ignoreContextMenuEvent = true;
} }
} }
void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName){ void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName)
if(nameActivDraw == oldName){ {
if (nameActivDraw == oldName)
{
nameActivDraw = newName; nameActivDraw = newName;
} }
} }
void VDrawTool::SetFactor(qreal factor){ void VDrawTool::SetFactor(qreal factor)
if(factor <= 2 && factor >= 0.5){ {
if (factor <= 2 && factor >= 0.5)
{
this->factor = factor; this->factor = factor;
} }
} }
void VDrawTool::AddToCalculation(const QDomElement &domElement){ void VDrawTool::AddToCalculation(const QDomElement &domElement)
{
QDomElement calcElement; QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement); bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){ if (ok)
{
qint64 id = doc->getCursor(); qint64 id = doc->getCursor();
if(id <= 0){ if (id <= 0)
{
calcElement.appendChild(domElement); calcElement.appendChild(domElement);
} else { }
else
{
QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor())); QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor()));
if(refElement.isElement()){ if (refElement.isElement())
{
calcElement.insertAfter(domElement, refElement); calcElement.insertAfter(domElement, refElement);
doc->setCursor(0); doc->setCursor(0);
} else { }
else
{
qCritical()<<tr("Can not find the element after which you want to insert.")<< Q_FUNC_INFO; qCritical()<<tr("Can not find the element after which you want to insert.")<< Q_FUNC_INFO;
} }
} }
} else { }
else
{
qCritical()<<tr("Can't find tag Calculation")<< Q_FUNC_INFO; qCritical()<<tr("Can't find tag Calculation")<< Q_FUNC_INFO;
} }
emit toolhaveChange(); emit toolhaveChange();

View File

@ -24,7 +24,8 @@
#include "../vabstracttool.h" #include "../vabstracttool.h"
class VDrawTool : public VAbstractTool{ class VDrawTool : public VAbstractTool
{
Q_OBJECT Q_OBJECT
public: public:
VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
@ -46,29 +47,37 @@ protected:
void AddToCalculation(const QDomElement &domElement); void AddToCalculation(const QDomElement &domElement);
template <typename Dialog, typename Tool> template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event, void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true){ bool showRemove = true)
{
Q_ASSERT(tool != 0); Q_ASSERT(tool != 0);
Q_ASSERT(event != 0); Q_ASSERT(event != 0);
if(!ignoreContextMenuEvent){ if (ignoreContextMenuEvent == false)
{
QMenu menu; QMenu menu;
QAction *actionOption = menu.addAction(tr("Options")); QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = 0; QAction *actionRemove = 0;
if(showRemove){ if (showRemove)
{
actionRemove = menu.addAction(tr("Delete")); actionRemove = menu.addAction(tr("Delete"));
if(_referens > 1){ if (_referens > 1)
{
actionRemove->setEnabled(false); actionRemove->setEnabled(false);
} else { }
else
{
actionRemove->setEnabled(true); actionRemove->setEnabled(true);
} }
} }
QAction *selectedAction = menu.exec(event->screenPos()); QAction *selectedAction = menu.exec(event->screenPos());
if(selectedAction == actionOption){ if (selectedAction == actionOption)
{
dialog = QSharedPointer<Dialog>(new Dialog(getData())); dialog = QSharedPointer<Dialog>(new Dialog(getData()));
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
&VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject); &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui); connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui);
if(!ignoreFullUpdate){ if (ignoreFullUpdate == false)
{
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList); connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
} }
@ -76,16 +85,20 @@ protected:
dialog->show(); dialog->show();
} }
if(showRemove){ if (showRemove)
if(selectedAction == actionRemove){ {
if (selectedAction == actionRemove)
{
//deincrement referens //deincrement referens
RemoveReferens(); RemoveReferens();
//remove form xml file //remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
QDomElement element; QDomElement element;
bool ok = doc->GetActivCalculationElement(element); bool ok = doc->GetActivCalculationElement(element);
if(ok){ if (ok)
{
element.removeChild(domElement); element.removeChild(domElement);
//update xml file //update xml file
emit FullUpdateTree(); emit FullUpdateTree();
@ -98,12 +111,17 @@ protected:
} }
} }
template <typename Item> template <typename Item>
void ShowItem(Item *item, qint64 id, Qt::GlobalColor color, bool enable){ void ShowItem(Item *item, qint64 id, Qt::GlobalColor color, bool enable)
{
Q_ASSERT(item != 0); Q_ASSERT(item != 0);
if(id == item->id){ if (id == item->id)
if(enable == false){ {
if (enable == false)
{
currentColor = baseColor; currentColor = baseColor;
} else { }
else
{
currentColor = color; currentColor = color;
} }
item->setPen(QPen(currentColor, widthHairLine/factor)); item->setPen(QPen(currentColor, widthHairLine/factor));

View File

@ -27,18 +27,22 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Sources typeCreation, const QString &typeLine, Tool::Sources typeCreation,
QGraphicsItem *parent): QGraphicsItem *parent)
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId), :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>()){ dialogAlongLine(QSharedPointer<DialogAlongLine>())
{
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolAlongLine::FullUpdateFromFile(){ void VToolAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, ""); typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, ""); formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
@ -47,10 +51,13 @@ void VToolAlongLine::FullUpdateFromFile(){
RefreshGeometry(); RefreshGeometry();
} }
void VToolAlongLine::FullUpdateFromGui(int result){ void VToolAlongLine::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogAlongLine->getPointName()); domElement.setAttribute(AttrName, dialogAlongLine->getPointName());
domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine()); domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine());
domElement.setAttribute(AttrLength, dialogAlongLine->getFormula()); domElement.setAttribute(AttrLength, dialogAlongLine->getFormula());
@ -62,16 +69,19 @@ void VToolAlongLine::FullUpdateFromGui(int result){
dialogAlongLine.clear(); dialogAlongLine.clear();
} }
void VToolAlongLine::SetFactor(qreal factor){ void VToolAlongLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogAlongLine, this, event); ContextMenu(dialogAlongLine, this, event);
} }
void VToolAlongLine::AddToFile(){ void VToolAlongLine::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -89,14 +99,15 @@ void VToolAlongLine::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolAlongLine::RemoveReferens(){ void VToolAlongLine::RemoveReferens()
{
doc->DecrementReferens(secondPointId); doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens(); VToolLinePoint::RemoveReferens();
} }
void VToolAlongLine::setDialog(){ void VToolAlongLine::setDialog()
Q_ASSERT(!dialogAlongLine.isNull()); {
if(!dialogAlongLine.isNull()){ Q_ASSERT(dialogAlongLine.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogAlongLine->setTypeLine(typeLine); dialogAlongLine->setTypeLine(typeLine);
dialogAlongLine->setFormula(formula); dialogAlongLine->setFormula(formula);
@ -104,10 +115,10 @@ void VToolAlongLine::setDialog(){
dialogAlongLine->setSecondPointId(secondPointId, id); dialogAlongLine->setSecondPointId(secondPointId, id);
dialogAlongLine->setPointName(p.name()); dialogAlongLine->setPointName(p.name());
} }
}
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){ VDomDocument *doc, VContainer *data)
{
QString formula = dialog->getFormula(); QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId(); qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId(); qint64 secondPointId = dialog->getSecondPointId();
@ -120,30 +131,37 @@ void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphi
void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation)
{
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()); QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
line.setLength(toPixel(result)); line.setLength(toPixel(result));
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
} else { }
else
{
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::AlongLineTool, doc); VDrawTool::AddRecord(id, Tool::AlongLineTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId,
secondPointId, typeLine, typeCreation); secondPointId, typeLine, typeCreation);
scene->addItem(point); scene->addItem(point);

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogalongline.h" #include "dialogs/dialogalongline.h"
class VToolAlongLine : public VToolLinePoint{ class VToolAlongLine : public VToolLinePoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,

View File

@ -26,8 +26,9 @@ const QString VToolArc::TagName = QStringLiteral("arc");
const QString VToolArc::ToolType = QStringLiteral("simple"); const QString VToolArc::ToolType = QStringLiteral("simple");
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation, VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent), QGraphicsItem *parent)
dialogArc(QSharedPointer<DialogArc>()){ :VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogArc(QSharedPointer<DialogArc>())
{
VArc arc = data->GetArc(id); VArc arc = data->GetArc(id);
QPainterPath path; QPainterPath path;
path.addPath(arc.GetPath()); path.addPath(arc.GetPath());
@ -37,24 +38,25 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolArc::setDialog(){ void VToolArc::setDialog()
Q_ASSERT(!dialogArc.isNull()); {
if(!dialogArc.isNull()){ Q_ASSERT(dialogArc.isNull() == false);
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
dialogArc->SetCenter(arc.GetCenter()); dialogArc->SetCenter(arc.GetCenter());
dialogArc->SetF1(arc.GetFormulaF1()); dialogArc->SetF1(arc.GetFormulaF1());
dialogArc->SetF2(arc.GetFormulaF2()); dialogArc->SetF2(arc.GetFormulaF2());
dialogArc->SetRadius(arc.GetFormulaRadius()); dialogArc->SetRadius(arc.GetFormulaRadius());
} }
}
void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){ VContainer *data)
{
qint64 center = dialog->GetCenter(); qint64 center = dialog->GetCenter();
QString radius = dialog->GetRadius(); QString radius = dialog->GetRadius();
QString f1 = dialog->GetF1(); QString f1 = dialog->GetF1();
@ -63,43 +65,52 @@ void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *sce
} }
void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1, void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation)
{
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(radius, &errorMsg); qreal result = cal.eval(radius, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
calcRadius = toPixel(result); calcRadius = toPixel(result);
} }
errorMsg.clear(); errorMsg.clear();
result = cal.eval(f1, &errorMsg); result = cal.eval(f1, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
calcF1 = result; calcF1 = result;
} }
errorMsg.clear(); errorMsg.clear();
result = cal.eval(f2, &errorMsg); result = cal.eval(f2, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
calcF2 = result; calcF2 = result;
} }
VArc arc = VArc(data->DataPoints(), center, calcRadius, radius, calcF1, f1, calcF2, f2 ); VArc arc = VArc(data->DataPoints(), center, calcRadius, radius, calcF1, f1, calcF2, f2 );
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddArc(arc); id = data->AddArc(arc);
data->AddLengthArc(data->GetNameArc(center, id), toMM(arc.GetLength())); data->AddLengthArc(data->GetNameArc(center, id), toMM(arc.GetLength()));
} else { }
else
{
data->UpdateArc(id, arc); data->UpdateArc(id, arc);
data->AddLengthArc(data->GetNameArc(center, id), toMM(arc.GetLength())); data->AddLengthArc(data->GetNameArc(center, id), toMM(arc.GetLength()));
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::ArcTool, doc); VDrawTool::AddRecord(id, Tool::ArcTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -109,14 +120,18 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
} }
} }
void VToolArc::FullUpdateFromFile(){ void VToolArc::FullUpdateFromFile()
{
RefreshGeometry(); RefreshGeometry();
} }
void VToolArc::FullUpdateFromGui(int result){ void VToolArc::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter())); domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter()));
domElement.setAttribute(AttrRadius, dialogArc->GetRadius()); domElement.setAttribute(AttrRadius, dialogArc->GetRadius());
domElement.setAttribute(AttrAngle1, dialogArc->GetF1()); domElement.setAttribute(AttrAngle1, dialogArc->GetF1());
@ -127,12 +142,16 @@ void VToolArc::FullUpdateFromGui(int result){
dialogArc.clear(); dialogArc.clear();
} }
void VToolArc::ChangedActivDraw(const QString newName){ void VToolArc::ChangedActivDraw(const QString newName)
{
bool selectable = false; bool selectable = false;
if(nameActivDraw == newName){ if (nameActivDraw == newName)
{
selectable = true; selectable = true;
currentColor = Qt::black; currentColor = Qt::black;
} else { }
else
{
selectable = false; selectable = false;
currentColor = Qt::gray; currentColor = Qt::gray;
} }
@ -142,20 +161,24 @@ void VToolArc::ChangedActivDraw(const QString newName){
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable); ShowItem(this, id, color, enable);
} }
void VToolArc::SetFactor(qreal factor){ void VToolArc::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogArc, this, event); ContextMenu(dialogArc, this, event);
} }
void VToolArc::AddToFile(){ void VToolArc::AddToFile()
{
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -169,29 +192,35 @@ void VToolArc::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if(event->button() == Qt::LeftButton){ {
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::Arc); emit ChoosedTool(id, Scene::Arc);
} }
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine/factor)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolArc::RemoveReferens(){ void VToolArc::RemoveReferens()
{
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
doc->DecrementReferens(arc.GetCenter()); doc->DecrementReferens(arc.GetCenter());
} }
void VToolArc::RefreshGeometry(){ void VToolArc::RefreshGeometry()
{
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
QPainterPath path; QPainterPath path;

View File

@ -27,7 +27,8 @@
#include "dialogs/dialogarc.h" #include "dialogs/dialogarc.h"
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
class VToolArc :public VDrawTool, public QGraphicsPathItem{ class VToolArc :public VDrawTool, public QGraphicsPathItem
{
Q_OBJECT Q_OBJECT
public: public:
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation, VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,

View File

@ -27,35 +27,41 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector");
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &firstPointId, const QString &typeLine, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation, const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation,
QGraphicsItem *parent): QGraphicsItem *parent)
VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0), :VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){ thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>())
{
this->firstPointId = firstPointId; this->firstPointId = firstPointId;
this->thirdPointId = thirdPointId; this->thirdPointId = thirdPointId;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const QPointF &thirdPoint, const qreal &length){ const QPointF &thirdPoint, const qreal &length)
{
QLineF line1(secondPoint, firstPoint); QLineF line1(secondPoint, firstPoint);
QLineF line2(secondPoint, thirdPoint); QLineF line2(secondPoint, thirdPoint);
qreal angle = line1.angleTo(line2); qreal angle = line1.angleTo(line2);
if(angle>180){ if (angle>180)
{
angle = 360 - angle; angle = 360 - angle;
line1.setAngle(line1.angle()-angle/2); line1.setAngle(line1.angle()-angle/2);
} else { }
else
{
line1.setAngle(line1.angle()+angle/2); line1.setAngle(line1.angle()+angle/2);
} }
line1.setLength(length); line1.setLength(length);
return line1.p2(); return line1.p2();
} }
void VToolBisector::setDialog(){ void VToolBisector::setDialog()
Q_ASSERT(!dialogBisector.isNull()); {
if(!dialogBisector.isNull()){ Q_ASSERT(dialogBisector.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogBisector->setTypeLine(typeLine); dialogBisector->setTypeLine(typeLine);
dialogBisector->setFormula(formula); dialogBisector->setFormula(formula);
@ -64,10 +70,10 @@ void VToolBisector::setDialog(){
dialogBisector->setThirdPointId(thirdPointId, id); dialogBisector->setThirdPointId(thirdPointId, id);
dialogBisector->setPointName(p.name()); dialogBisector->setPointName(p.name());
} }
}
void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VDomDocument *doc, VContainer *data){ VContainer *data)
{
QString formula = dialog->getFormula(); QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId(); qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId(); qint64 secondPointId = dialog->getSecondPointId();
@ -82,7 +88,8 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation)
{
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
VPointF thirdPoint = data->GetPoint(thirdPointId); VPointF thirdPoint = data->GetPoint(thirdPointId);
@ -90,22 +97,28 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
thirdPoint.toQPointF(), toPixel(result)); thirdPoint.toQPointF(), toPixel(result));
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
} else { }
else
{
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::BisectorTool, doc); VDrawTool::AddRecord(id, Tool::BisectorTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
thirdPointId, typeCreation); thirdPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
@ -120,9 +133,11 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
} }
} }
void VToolBisector::FullUpdateFromFile(){ void VToolBisector::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, ""); typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, ""); formula = domElement.attribute(AttrLength, "");
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
@ -132,10 +147,13 @@ void VToolBisector::FullUpdateFromFile(){
RefreshGeometry(); RefreshGeometry();
} }
void VToolBisector::FullUpdateFromGui(int result){ void VToolBisector::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogBisector->getPointName()); domElement.setAttribute(AttrName, dialogBisector->getPointName());
domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine()); domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine());
domElement.setAttribute(AttrLength, dialogBisector->getFormula()); domElement.setAttribute(AttrLength, dialogBisector->getFormula());
@ -148,16 +166,19 @@ void VToolBisector::FullUpdateFromGui(int result){
dialogBisector.clear(); dialogBisector.clear();
} }
void VToolBisector::SetFactor(qreal factor){ void VToolBisector::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogBisector, this, event); ContextMenu(dialogBisector, this, event);
} }
void VToolBisector::AddToFile(){ void VToolBisector::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -176,7 +197,8 @@ void VToolBisector::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolBisector::RemoveReferens(){ void VToolBisector::RemoveReferens()
{
doc->DecrementReferens(firstPointId); doc->DecrementReferens(firstPointId);
doc->DecrementReferens(thirdPointId); doc->DecrementReferens(thirdPointId);
VToolLinePoint::RemoveReferens(); VToolLinePoint::RemoveReferens();

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogbisector.h" #include "dialogs/dialogbisector.h"
class VToolBisector : public VToolLinePoint{ class VToolBisector : public VToolLinePoint
{
public: public:
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,

View File

@ -27,17 +27,20 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId, const QString &formula, const qreal &angle, const qint64 &basePointId,
Tool::Sources typeCreation, QGraphicsItem *parent): Tool::Sources typeCreation, QGraphicsItem *parent)
VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent), :VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
dialogEndLine(QSharedPointer<DialogEndLine>()){ dialogEndLine(QSharedPointer<DialogEndLine>())
{
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolEndLine::setDialog(){ void VToolEndLine::setDialog()
Q_ASSERT(!dialogEndLine.isNull()); {
Q_ASSERT(dialogEndLine.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogEndLine->setTypeLine(typeLine); dialogEndLine->setTypeLine(typeLine);
dialogEndLine->setFormula(formula); dialogEndLine->setFormula(formula);
@ -46,8 +49,9 @@ void VToolEndLine::setDialog(){
dialogEndLine->setPointName(p.name()); dialogEndLine->setPointName(p.name());
} }
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VDomDocument *doc, VContainer *data){ VContainer *data)
{
QString pointName = dialog->getPointName(); QString pointName = dialog->getPointName();
QString typeLine = dialog->getTypeLine(); QString typeLine = dialog->getTypeLine();
QString formula = dialog->getFormula(); QString formula = dialog->getFormula();
@ -60,29 +64,35 @@ void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsSc
void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId, const QString &formula, const qreal &angle, const qint64 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation)
{
VPointF basePoint = data->GetPoint(basePointId); VPointF basePoint = data->GetPoint(basePointId);
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y())); QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
line.setLength(toPixel(result)); line.setLength(toPixel(result));
line.setAngle(angle); line.setAngle(angle);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
} else { }
else
{
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::EndLineTool, doc); VDrawTool::AddRecord(id, Tool::EndLineTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle,
basePointId, typeCreation); basePointId, typeCreation);
scene->addItem(point); scene->addItem(point);
@ -95,9 +105,11 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
} }
} }
void VToolEndLine::FullUpdateFromFile(){ void VToolEndLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, ""); typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, ""); formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); basePointId = domElement.attribute(AttrBasePoint, "").toLongLong();
@ -106,14 +118,18 @@ void VToolEndLine::FullUpdateFromFile(){
RefreshGeometry(); RefreshGeometry();
} }
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogEndLine, this, event); ContextMenu(dialogEndLine, this, event);
} }
void VToolEndLine::FullUpdateFromGui(int result){ void VToolEndLine::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogEndLine->getPointName()); domElement.setAttribute(AttrName, dialogEndLine->getPointName());
domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine()); domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine());
domElement.setAttribute(AttrLength, dialogEndLine->getFormula()); domElement.setAttribute(AttrLength, dialogEndLine->getFormula());
@ -125,7 +141,8 @@ void VToolEndLine::FullUpdateFromGui(int result){
dialogEndLine.clear(); dialogEndLine.clear();
} }
void VToolEndLine::AddToFile(){ void VToolEndLine::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -142,4 +159,3 @@ void VToolEndLine::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogendline.h" #include "dialogs/dialogendline.h"
class VToolEndLine : public VToolLinePoint{ class VToolEndLine : public VToolLinePoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,

View File

@ -6,15 +6,18 @@ VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
Tool::Sources typeCreation, QGraphicsItem * parent) Tool::Sources typeCreation, QGraphicsItem * parent)
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent),
dialogHeight(QSharedPointer<DialogHeight>()), p1LineId(p1LineId), p2LineId(p2LineId){ dialogHeight(QSharedPointer<DialogHeight>()), p1LineId(p1LineId), p2LineId(p2LineId)
{
ignoreFullUpdate = true; ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolHeight::setDialog(){ void VToolHeight::setDialog()
Q_ASSERT(!dialogHeight.isNull()); {
Q_ASSERT(dialogHeight.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogHeight->setTypeLine(typeLine); dialogHeight->setTypeLine(typeLine);
dialogHeight->setBasePointId(basePointId, id); dialogHeight->setBasePointId(basePointId, id);
@ -24,7 +27,8 @@ void VToolHeight::setDialog(){
} }
void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){ VContainer *data)
{
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList); disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList);
QString pointName = dialog->getPointName(); QString pointName = dialog->getPointName();
QString typeLine = dialog->getTypeLine(); QString typeLine = dialog->getTypeLine();
@ -38,29 +42,35 @@ void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScen
void VToolHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine, void VToolHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation)
{
VPointF basePoint = data->GetPoint(basePointId); VPointF basePoint = data->GetPoint(basePointId);
VPointF p1Line = data->GetPoint(p1LineId); VPointF p1Line = data->GetPoint(p1LineId);
VPointF p2Line = data->GetPoint(p2LineId); VPointF p2Line = data->GetPoint(p2LineId);
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF()); QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
data->AddLine(p1LineId, id); data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id); data->AddLine(p2LineId, id);
} else { }
else
{
data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
data->AddLine(p1LineId, id); data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id); data->AddLine(p2LineId, id);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::Height, doc); VDrawTool::AddRecord(id, Tool::Height, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
@ -74,24 +84,30 @@ void VToolHeight::Create(const qint64 _id, const QString &pointName, const QStri
} }
} }
QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point){ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point)
{
qreal a = 0, b = 0, c = 0; qreal a = 0, b = 0, c = 0;
LineCoefficients(line, &a, &b, &c); LineCoefficients(line, &a, &b, &c);
qreal x = point.x() + a; qreal x = point.x() + a;
qreal y = b + point.y(); qreal y = b + point.y();
QLineF l (point, QPointF(x, y)); QLineF lin (point, QPointF(x, y));
QPointF p; QPointF p;
QLineF::IntersectType intersect = line.intersect(l, &p); QLineF::IntersectType intersect = line.intersect(lin, &p);
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
return p; return p;
} else { }
else
{
return QPointF(); return QPointF();
} }
} }
void VToolHeight::FullUpdateFromFile(){ void VToolHeight::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, ""); typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); basePointId = domElement.attribute(AttrBasePoint, "").toLongLong();
p1LineId = domElement.attribute(AttrP1Line, "").toLongLong(); p1LineId = domElement.attribute(AttrP1Line, "").toLongLong();
@ -101,10 +117,13 @@ void VToolHeight::FullUpdateFromFile(){
} }
void VToolHeight::FullUpdateFromGui(int result){ void VToolHeight::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogHeight->getPointName()); domElement.setAttribute(AttrName, dialogHeight->getPointName());
domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine()); domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine());
domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId())); domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId()));
@ -116,11 +135,13 @@ void VToolHeight::FullUpdateFromGui(int result){
dialogHeight.clear(); dialogHeight.clear();
} }
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogHeight, this, event); ContextMenu(dialogHeight, this, event);
} }
void VToolHeight::AddToFile(){ void VToolHeight::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogheight.h" #include "dialogs/dialogheight.h"
class VToolHeight: public VToolLinePoint{ class VToolHeight: public VToolLinePoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,

View File

@ -24,9 +24,10 @@
const QString VToolLine::TagName = QStringLiteral("line"); const QString VToolLine::TagName = QStringLiteral("line");
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
Tool::Sources typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id), Tool::Sources typeCreation, QGraphicsItem *parent)
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
dialogLine(QSharedPointer<DialogLine>()){ dialogLine(QSharedPointer<DialogLine>())
{
ignoreFullUpdate = true; ignoreFullUpdate = true;
//Лінія //Лінія
VPointF first = data->GetPoint(firstPoint); VPointF first = data->GetPoint(firstPoint);
@ -37,18 +38,21 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, widthHairLine/factor)); this->setPen(QPen(Qt::black, widthHairLine/factor));
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolLine::setDialog(){ void VToolLine::setDialog()
{
dialogLine->setFirstPoint(firstPoint); dialogLine->setFirstPoint(firstPoint);
dialogLine->setSecondPoint(secondPoint); dialogLine->setSecondPoint(secondPoint);
} }
void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){ VContainer *data)
{
qint64 firstPoint = dialog->getFirstPoint(); qint64 firstPoint = dialog->getFirstPoint();
qint64 secondPoint = dialog->getSecondPoint(); qint64 secondPoint = dialog->getSecondPoint();
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui); Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui);
@ -56,23 +60,29 @@ void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *s
void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation)
{
Q_ASSERT(scene != 0); Q_ASSERT(scene != 0);
Q_ASSERT(doc != 0); Q_ASSERT(doc != 0);
Q_ASSERT(data != 0); Q_ASSERT(data != 0);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->getNextId(); id = data->getNextId();
data->AddLine(firstPoint, secondPoint); data->AddLine(firstPoint, secondPoint);
} else { }
else
{
data->UpdateId(id); data->UpdateId(id);
data->AddLine(firstPoint, secondPoint); data->AddLine(firstPoint, secondPoint);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::LineTool, doc); VDrawTool::AddRecord(id, Tool::LineTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
Q_ASSERT(line != 0); Q_ASSERT(line != 0);
scene->addItem(line); scene->addItem(line);
@ -85,14 +95,18 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
} }
} }
void VToolLine::FullUpdateFromFile(){ void VToolLine::FullUpdateFromFile()
{
RefreshGeometry(); RefreshGeometry();
} }
void VToolLine::FullUpdateFromGui(int result){ void VToolLine::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint())); domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint())); domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint()));
emit FullUpdateTree(); emit FullUpdateTree();
@ -101,21 +115,27 @@ void VToolLine::FullUpdateFromGui(int result){
dialogLine.clear(); dialogLine.clear();
} }
void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable); ShowItem(this, id, color, enable);
} }
void VToolLine::SetFactor(qreal factor){ void VToolLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
void VToolLine::ChangedActivDraw(const QString newName){ void VToolLine::ChangedActivDraw(const QString newName)
{
bool selectable = false; bool selectable = false;
if(nameActivDraw == newName){ if (nameActivDraw == newName)
{
selectable = true; selectable = true;
currentColor = Qt::black; currentColor = Qt::black;
} else { }
else
{
selectable = false; selectable = false;
currentColor = Qt::gray; currentColor = Qt::gray;
} }
@ -124,11 +144,13 @@ void VToolLine::ChangedActivDraw(const QString newName){
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogLine, this, event); ContextMenu(dialogLine, this, event);
} }
void VToolLine::AddToFile(){ void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id); AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrFirstPoint, firstPoint); AddAttribute(domElement, AttrFirstPoint, firstPoint);
@ -137,24 +159,29 @@ void VToolLine::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine/factor)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolLine::RemoveReferens(){ void VToolLine::RemoveReferens()
{
doc->DecrementReferens(firstPoint); doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint); doc->DecrementReferens(secondPoint);
} }
void VToolLine::RefreshGeometry(){ void VToolLine::RefreshGeometry()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong(); firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong(); secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong();
} }
@ -163,4 +190,3 @@ void VToolLine::RefreshGeometry(){
this->setLine(QLineF(first.toQPointF(), second.toQPointF())); this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }

View File

@ -26,7 +26,8 @@
#include "QGraphicsLineItem" #include "QGraphicsLineItem"
#include "dialogs/dialogline.h" #include "dialogs/dialogline.h"
class VToolLine: public VDrawTool, public QGraphicsLineItem{ class VToolLine: public VDrawTool, public QGraphicsLineItem
{
Q_OBJECT Q_OBJECT
public: public:
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,

View File

@ -26,18 +26,20 @@ const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect");
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation, const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem *parent): QGraphicsItem *parent)
VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){ p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>())
{
ignoreFullUpdate = true; ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolLineIntersect::setDialog(){ void VToolLineIntersect::setDialog()
Q_ASSERT(!dialogLineIntersect.isNull()); {
if(!dialogLineIntersect.isNull()){ Q_ASSERT(dialogLineIntersect.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogLineIntersect->setP1Line1(p1Line1); dialogLineIntersect->setP1Line1(p1Line1);
dialogLineIntersect->setP2Line1(p2Line1); dialogLineIntersect->setP2Line1(p2Line1);
@ -45,10 +47,10 @@ void VToolLineIntersect::setDialog(){
dialogLineIntersect->setP2Line2(p2Line2); dialogLineIntersect->setP2Line2(p2Line2);
dialogLineIntersect->setPointName(p.name()); dialogLineIntersect->setPointName(p.name());
} }
}
void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene, void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){ VDomDocument *doc, VContainer *data)
{
qint64 p1Line1Id = dialog->getP1Line1(); qint64 p1Line1Id = dialog->getP1Line1();
qint64 p2Line1Id = dialog->getP2Line1(); qint64 p2Line1Id = dialog->getP2Line1();
qint64 p1Line2Id = dialog->getP1Line2(); qint64 p1Line2Id = dialog->getP1Line2();
@ -62,7 +64,8 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){ Tool::Sources typeCreation)
{
VPointF p1Line1 = data->GetPoint(p1Line1Id); VPointF p1Line1 = data->GetPoint(p1Line1Id);
VPointF p2Line1 = data->GetPoint(p2Line1Id); VPointF p2Line1 = data->GetPoint(p2Line1Id);
VPointF p1Line2 = data->GetPoint(p1Line2Id); VPointF p1Line2 = data->GetPoint(p1Line2Id);
@ -72,28 +75,33 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF()); QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF());
QPointF fPoint; QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(p1Line1Id, id); data->AddLine(p1Line1Id, id);
data->AddLine(id, p2Line1Id); data->AddLine(id, p2Line1Id);
data->AddLine(p1Line2Id, id); data->AddLine(p1Line2Id, id);
data->AddLine(id, p2Line2Id); data->AddLine(id, p2Line2Id);
} else { }
else
{
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(p1Line1Id, id); data->AddLine(p1Line1Id, id);
data->AddLine(id, p2Line1Id); data->AddLine(id, p2Line1Id);
data->AddLine(p1Line2Id, id); data->AddLine(p1Line2Id, id);
data->AddLine(id, p2Line2Id); data->AddLine(id, p2Line2Id);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::LineIntersectTool, doc); VDrawTool::AddRecord(id, Tool::LineIntersectTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, {
p2Line1Id, p1Line2Id, VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
p2Line2Id, typeCreation); p2Line2Id, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -108,9 +116,11 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
} }
} }
void VToolLineIntersect::FullUpdateFromFile(){ void VToolLineIntersect::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
p1Line1 = domElement.attribute(AttrP1Line1, "").toLongLong(); p1Line1 = domElement.attribute(AttrP1Line1, "").toLongLong();
p2Line1 = domElement.attribute(AttrP2Line1, "").toLongLong(); p2Line1 = domElement.attribute(AttrP2Line1, "").toLongLong();
p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong(); p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong();
@ -119,10 +129,13 @@ void VToolLineIntersect::FullUpdateFromFile(){
RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
} }
void VToolLineIntersect::FullUpdateFromGui(int result){ void VToolLineIntersect::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogLineIntersect->getPointName()); domElement.setAttribute(AttrName, dialogLineIntersect->getPointName());
domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1())); domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1()));
domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1())); domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1()));
@ -134,16 +147,19 @@ void VToolLineIntersect::FullUpdateFromGui(int result){
dialogLineIntersect.clear(); dialogLineIntersect.clear();
} }
void VToolLineIntersect::SetFactor(qreal factor){ void VToolLineIntersect::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
} }
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogLineIntersect, this, event); ContextMenu(dialogLineIntersect, this, event);
} }
void VToolLineIntersect::AddToFile(){ void VToolLineIntersect::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -161,7 +177,8 @@ void VToolLineIntersect::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolLineIntersect::RemoveReferens(){ void VToolLineIntersect::RemoveReferens()
{
doc->DecrementReferens(p1Line1); doc->DecrementReferens(p1Line1);
doc->DecrementReferens(p2Line1); doc->DecrementReferens(p2Line1);
doc->DecrementReferens(p1Line2); doc->DecrementReferens(p1Line2);

View File

@ -25,7 +25,8 @@
#include "vtoolpoint.h" #include "vtoolpoint.h"
#include "dialogs/dialoglineintersect.h" #include "dialogs/dialoglineintersect.h"
class VToolLineIntersect:public VToolPoint{ class VToolLineIntersect:public VToolPoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1, VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1,

View File

@ -23,8 +23,10 @@
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &basePointId, const QString &typeLine, const QString &formula, const qint64 &basePointId,
const qreal &angle, QGraphicsItem *parent):VToolPoint(doc, data, id, parent), const qreal &angle, QGraphicsItem *parent)
typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId), mainLine(0){ :VToolPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId),
mainLine(0)
{
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
//Лінія, що з'єднує дві точки //Лінія, що з'єднує дві точки
QPointF point1 = data->GetPoint(basePointId).toQPointF(); QPointF point1 = data->GetPoint(basePointId).toQPointF();
@ -32,37 +34,49 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
mainLine->setPen(QPen(Qt::black, widthHairLine/factor)); mainLine->setPen(QPen(Qt::black, widthHairLine/factor));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if(typeLine == TypeLineNone){ if (typeLine == TypeLineNone)
{
mainLine->setVisible(false); mainLine->setVisible(false);
} else { }
else
{
mainLine->setVisible(true); mainLine->setVisible(true);
} }
} }
void VToolLinePoint::ChangedActivDraw(const QString newName){ void VToolLinePoint::ChangedActivDraw(const QString newName)
if(nameActivDraw == newName){ {
if (nameActivDraw == newName)
{
currentColor = Qt::black; currentColor = Qt::black;
} else { }
else
{
currentColor = Qt::gray; currentColor = Qt::gray;
} }
mainLine->setPen(QPen(currentColor, widthHairLine/factor)); mainLine->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
} }
void VToolLinePoint::RefreshGeometry(){ void VToolLinePoint::RefreshGeometry()
{
mainLine->setPen(QPen(currentColor, widthHairLine/factor)); mainLine->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
QPointF point = VDrawTool::data.GetPoint(id).toQPointF(); QPointF point = VDrawTool::data.GetPoint(id).toQPointF();
QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF(); QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF();
mainLine->setLine(QLineF(basePoint - point, QPointF())); mainLine->setLine(QLineF(basePoint - point, QPointF()));
if(typeLine == TypeLineNone){ if (typeLine == TypeLineNone)
{
mainLine->setVisible(false); mainLine->setVisible(false);
} else { }
else
{
mainLine->setVisible(true); mainLine->setVisible(true);
} }
} }
void VToolLinePoint::SetFactor(qreal factor){ void VToolLinePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }

View File

@ -24,7 +24,8 @@
#include "vtoolpoint.h" #include "vtoolpoint.h"
class VToolLinePoint : public VToolPoint{ class VToolLinePoint : public VToolPoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,

View File

@ -26,19 +26,21 @@ const QString VToolNormal::ToolType = QStringLiteral("normal");
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId, const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent): const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent)
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){ secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>())
{
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
AddToFile(); AddToFile();
} }
} }
void VToolNormal::setDialog(){ void VToolNormal::setDialog()
Q_ASSERT(!dialogNormal.isNull()); {
if(!dialogNormal.isNull()){ Q_ASSERT(dialogNormal.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id); VPointF p = VAbstractTool::data.GetPoint(id);
dialogNormal->setTypeLine(typeLine); dialogNormal->setTypeLine(typeLine);
dialogNormal->setFormula(formula); dialogNormal->setFormula(formula);
@ -47,10 +49,10 @@ void VToolNormal::setDialog(){
dialogNormal->setSecondPointId(secondPointId, id); dialogNormal->setSecondPointId(secondPointId, id);
dialogNormal->setPointName(p.name()); dialogNormal->setPointName(p.name());
} }
}
void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){ VContainer *data)
{
QString formula = dialog->getFormula(); QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId(); qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId(); qint64 secondPointId = dialog->getSecondPointId();
@ -65,28 +67,35 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
const qint64 &secondPointId, const QString typeLine, const QString pointName, const qint64 &secondPointId, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){ Tool::Sources typeCreation)
{
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if (errorMsg.isEmpty())
{
QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
toPixel(result), angle); toPixel(result), angle);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
} else { }
else
{
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
if(parse != Document::FullParse){ if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::NormalTool, doc); VDrawTool::AddRecord(id, Tool::NormalTool, doc);
if(parse == Document::FullParse){ if (parse == Document::FullParse)
{
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle,
firstPointId, secondPointId, typeCreation); firstPointId, secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
@ -101,7 +110,8 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
} }
QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
const qreal &angle){ const qreal &angle)
{
QLineF line(firstPoint, secondPoint); QLineF line(firstPoint, secondPoint);
QLineF normal = line.normalVector(); QLineF normal = line.normalVector();
normal.setAngle(normal.angle()+angle); normal.setAngle(normal.angle()+angle);
@ -109,9 +119,11 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP
return normal.p2(); return normal.p2();
} }
void VToolNormal::FullUpdateFromFile(){ void VToolNormal::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, ""); typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, ""); formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
@ -121,10 +133,13 @@ void VToolNormal::FullUpdateFromFile(){
RefreshGeometry(); RefreshGeometry();
} }
void VToolNormal::FullUpdateFromGui(int result){ void VToolNormal::FullUpdateFromGui(int result)
if(result == QDialog::Accepted){ {
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogNormal->getPointName()); domElement.setAttribute(AttrName, dialogNormal->getPointName());
domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine()); domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine());
domElement.setAttribute(AttrLength, dialogNormal->getFormula()); domElement.setAttribute(AttrLength, dialogNormal->getFormula());
@ -137,16 +152,19 @@ void VToolNormal::FullUpdateFromGui(int result){
dialogNormal.clear(); dialogNormal.clear();
} }
void VToolNormal::SetFactor(qreal factor){ void VToolNormal::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshGeometry(); RefreshGeometry();
} }
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogNormal, this, event); ContextMenu(dialogNormal, this, event);
} }
void VToolNormal::AddToFile(){ void VToolNormal::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id); VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName); QDomElement domElement = doc->createElement(TagName);
@ -165,7 +183,8 @@ void VToolNormal::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolNormal::RemoveReferens(){ void VToolNormal::RemoveReferens()
{
doc->DecrementReferens(secondPointId); doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens(); VToolLinePoint::RemoveReferens();
} }

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialognormal.h" #include "dialogs/dialognormal.h"
class VToolNormal : public VToolLinePoint{ class VToolNormal : public VToolLinePoint
{
Q_OBJECT Q_OBJECT
public: public:
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,

Some files were not shown because too many files have changed in this diff Show More