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

View File

@ -28,13 +28,15 @@
* @brief The Calculator клас калькулятора формул лекал. Виконує розрахунок формул з підставлянням
* значеннь зміних.
*/
class Calculator{
class Calculator
{
public:
/**
* @brief Calculator конструктор класу. Використовується при розрахунку лекала.
* @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 виконує розрахунок формули.
* @param prog рядко в якому зберігається формула.
@ -143,7 +145,7 @@ private:
qreal find_var(QString s);
void serror(qint32 error);
/**
* @brief look_up пошук відповідного внутрішнього формату для теперішньої лексеми в таблиці лексем. текущей лексемы в таблице лексем
* @brief look_up пошук відповідного внутрішнього формату для теперішньої лексеми в таблиці лексем.
* @param s ім'я лексеми.
* @return внутрішній номер лексеми.
*/

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,8 @@
/**
* @brief The VContainer class
*/
class VContainer{
class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer)
public:
/**
@ -168,7 +169,7 @@ private:
void CreateManTableIGroup ();
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const;
template <typename key, typename val> static val GetObject(const QHash<key,val> &obj, key id);
template <typename key, typename val> static val GetObject(const QHash<key, val> &obj, key id);
template <typename val> static void UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point);
template <typename key, typename val> static qint64 AddObject(QHash<key, val> &obj, const val& value);
};

View File

@ -21,12 +21,8 @@
#include "vincrementtablerow.h"
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()
: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){}

View File

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

View File

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

View File

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

View File

@ -21,9 +21,8 @@
#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),
ksize(ksize), kgrowth(kgrowth), description(description){
}
VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description)
:base(base), ksize(ksize), kgrowth(kgrowth), description(description){}

View File

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

View File

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

View File

@ -24,12 +24,14 @@
#include "dialogtool.h"
namespace Ui {
class DialogAlongLine;
namespace Ui
{
class DialogAlongLine;
}
class DialogAlongLine : public DialogTool{
Q_OBJECT
class DialogAlongLine : public DialogTool
{
Q_OBJECT
public:
DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
@ -46,7 +48,7 @@ public:
void setSecondPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogAlongLine)
Ui::DialogAlongLine *ui;

View File

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

View File

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

View File

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

View File

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

View File

@ -21,8 +21,9 @@
#include "dialogdetail.h"
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true){
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true)
{
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
@ -42,43 +43,52 @@ DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *pa
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
}
void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){
void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if(mode == Draw::Modeling){
if(!CheckObject(id)){
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if(type != Scene::Line && type != Scene::Detail){
switch(type){
case(Scene::Arc):
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
break;
case(Scene::Point):
NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour);
break;
case(Scene::Spline):
NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour);
break;
case(Scene::SplinePath):
NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour);
break;
default:
qWarning()<<tr("Get wrong scene object. Ignore.");
break;
if (type != Scene::Line && type != Scene::Detail)
{
switch (type)
{
case (Scene::Arc):
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
break;
case (Scene::Point):
NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour);
break;
case (Scene::Spline):
NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour);
break;
case (Scene::SplinePath):
NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour);
break;
default:
qWarning()<<tr("Get wrong scene object. Ignore.");
break;
}
this->show();
}
}
void DialogDetail::DialogAccepted(){
void DialogDetail::DialogAccepted()
{
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);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
}
@ -90,53 +100,71 @@ void DialogDetail::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, qreal mx,
qreal my){
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx, qreal my)
{
QString name;
switch(typeTool){
case(Tool::NodePoint):{
VPointF point;
if(mode == Draw::Calculation){
point = data->GetPoint(id);
} else {
point = data->GetModelingPoint(id);
switch (typeTool)
{
case (Tool::NodePoint):
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetModelingPoint(id);
}
name = point.name();
break;
}
name = point.name();
break;
}
case(Tool::NodeArc):{
VArc arc;
if(mode == Draw::Calculation){
arc = data->GetArc(id);
} else {
arc = data->GetModelingArc(id);
case (Tool::NodeArc):
{
VArc arc;
if (mode == Draw::Calculation)
{
arc = data->GetArc(id);
}
else
{
arc = data->GetModelingArc(id);
}
name = data->GetNameArc(arc.GetCenter(), id, mode);
break;
}
name = data->GetNameArc(arc.GetCenter(), id, mode);
break;
}
case(Tool::NodeSpline):{
VSpline spl;
if(mode == Draw::Calculation){
spl = data->GetSpline(id);
} else {
spl = data->GetModelingSpline(id);
case (Tool::NodeSpline):
{
VSpline spl;
if (mode == Draw::Calculation)
{
spl = data->GetSpline(id);
}
else
{
spl = data->GetModelingSpline(id);
}
name = spl.GetName();
break;
}
name = spl.GetName();
break;
}
case(Tool::NodeSplinePath):{
VSplinePath splPath;
if(mode == Draw::Calculation){
splPath = data->GetSplinePath(id);
} else {
splPath = data->GetModelingSplinePath(id);
case (Tool::NodeSplinePath):
{
VSplinePath splPath;
if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id);
}
else
{
splPath = data->GetModelingSplinePath(id);
}
name = data->GetNameSplinePath(splPath, mode);
break;
}
name = data->GetNameSplinePath(splPath, mode);
break;
}
default:
qWarning()<<tr("Get wrong tools. Ignore.");
break;
default:
qWarning()<<tr("Get wrong tools. Ignore.");
break;
}
QListWidgetItem *item = new QListWidgetItem(name);
@ -156,12 +184,14 @@ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, No
this, &DialogDetail::BiasYChanged);
}
void DialogDetail::setDetails(const VDetail &value){
void DialogDetail::setDetails(const VDetail &value)
{
details = value;
ui.listWidget->clear();
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());
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());
}
ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement());
@ -171,7 +201,8 @@ void DialogDetail::setDetails(const VDetail &value){
ui.listWidget->setFocus(Qt::OtherFocusReason);
}
void DialogDetail::BiasXChanged(qreal d){
void DialogDetail::BiasXChanged(qreal d)
{
qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row );
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));
}
void DialogDetail::BiasYChanged(qreal d){
void DialogDetail::BiasYChanged(qreal d)
{
qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row );
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));
}
void DialogDetail::ClickedSeams(bool checked){
void DialogDetail::ClickedSeams(bool checked)
{
supplement = checked;
ui.checkBoxClosed->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked);
}
void DialogDetail::ClickedClosed(bool checked){
void DialogDetail::ClickedClosed(bool checked)
{
closed = checked;
}
void DialogDetail::ObjectChanged(int row){
if(ui.listWidget->count() == 0){
void DialogDetail::ObjectChanged(int row)
{
if (ui.listWidget->count() == 0)
{
return;
}
QListWidgetItem *item = ui.listWidget->item( row );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,9 +22,10 @@
#include "dialognormal.h"
#include "ui_dialognormal.h"
DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){
DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this);
spinBoxAngle = ui->doubleSpinBoxAngle;
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);
}
DialogNormal::~DialogNormal(){
DialogNormal::~DialogNormal()
{
delete ui;
}
void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){
void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if(mode == Draw::Modeling){
if(!CheckObject(id)){
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if(type == Scene::Point){
if (type == Scene::Point)
{
VPointF point;
if(mode == Draw::Calculation){
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
} else {
}
else
{
point = data->GetModelingPoint(id);
}
if(number == 0){
if (number == 0)
{
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);
number++;
emit ToolTip(tr("Select second point of line"));
return;
}
}
if(number == 1){
if (number == 1)
{
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);
number = 0;
emit ToolTip("");
}
if(!isInitialized){
if (isInitialized == false)
{
this->show();
}
}
}
}
void DialogNormal::DialogAccepted(){
void DialogNormal::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
@ -138,30 +155,36 @@ void DialogNormal::DialogAccepted(){
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);
}
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id){
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
void DialogNormal::setAngle(const qreal &value){
void DialogNormal::setAngle(const qreal &value)
{
angle = value;
ui->doubleSpinBoxAngle->setValue(angle);
}
void DialogNormal::setFormula(const QString &value){
void DialogNormal::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
void DialogNormal::setTypeLine(const QString &value){
void DialogNormal::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
void DialogNormal::setPointName(const QString &value){
void DialogNormal::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,12 +22,13 @@
#include "dialogsinglepoint.h"
#include "ui_dialogsinglepoint.h"
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF()){
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
:DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF())
{
ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0,toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0,toMM(PaperSize));
ui->doubleSpinBoxX->setRange(0, toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0, toMM(PaperSize));
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
labelEditNamePoint = ui->labelEditName;
flagName = false;
@ -35,27 +36,33 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
connect(bOk, &QPushButton::clicked, this, &DialogSinglePoint::DialogAccepted);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSinglePoint::DialogRejected);
connect(ui->lineEditName,&QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged);
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged);
}
void DialogSinglePoint::mousePress(QPointF scenePos){
if(isInitialized == false){
void DialogSinglePoint::mousePress(QPointF scenePos)
{
if (isInitialized == false)
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
this->show();
} else {
}
else
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
}
}
void DialogSinglePoint::DialogAccepted(){
void DialogSinglePoint::DialogAccepted()
{
point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
name = ui->lineEditName->text();
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->point = point;
isInitialized = true;
@ -64,7 +71,7 @@ void DialogSinglePoint::setData(const QString name, const QPointF point){
ui->doubleSpinBoxY->setValue(toMM(point.y()));
}
DialogSinglePoint::~DialogSinglePoint(){
DialogSinglePoint::~DialogSinglePoint()
{
delete ui;
}

View File

@ -24,12 +24,14 @@
#include "dialogtool.h"
namespace Ui {
class DialogSinglePoint;
namespace Ui
{
class DialogSinglePoint;
}
class DialogSinglePoint : public DialogTool{
Q_OBJECT
class DialogSinglePoint : public DialogTool
{
Q_OBJECT
public:
DialogSinglePoint(const VContainer *data, QWidget *parent = 0);
void setData(const QString name, const QPointF point);

View File

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

View File

@ -24,15 +24,16 @@
#include "dialogtool.h"
namespace Ui {
class DialogSpline;
namespace Ui
{
class DialogSpline;
}
class DialogSpline : public DialogTool{
Q_OBJECT
class DialogSpline : public DialogTool
{
Q_OBJECT
public:
explicit DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogSpline();
inline qint64 getP1() const {return p1;}
void setP1(const qint64 &value);
@ -55,10 +56,10 @@ private:
Q_DISABLE_COPY(DialogSpline)
Ui::DialogSpline *ui;
qint32 number;
qint64 p1; // перша точка
qint64 p4; // четверта точка
qreal angle1; // кут нахилу дотичної в першій точці
qreal angle2; // кут нахилу дотичної в другій точці
qint64 p1; // перша точка
qint64 p4; // четверта точка
qreal angle1; // кут нахилу дотичної в першій точці
qreal angle2; // кут нахилу дотичної в другій точці
qreal kAsm1;
qreal kAsm2;
qreal kCurve;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,11 +21,13 @@
#include "vexception.h"
VException::VException(const QString &what):QException(), what(what){
Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty");
VException::VException(const QString &what):QException(), what(what)
{
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);
return error;
}

View File

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

View File

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

View File

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

View File

@ -22,11 +22,13 @@
#include "vexceptionconversionerror.h"
VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str)
:VException(what), str(str){
Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty");
:VException(what), str(str)
{
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);
return error;
}

View File

@ -24,10 +24,12 @@
#include "vexception.h"
class VExceptionConversionError : public VException{
class VExceptionConversionError : public VException
{
public:
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 QString ErrorMessage() const;
inline QString String() const {return str;}

View File

@ -22,22 +22,25 @@
#include "vexceptionemptyparameter.h"
VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
const QDomElement &domElement): 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");
const QDomElement &domElement)
: VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1)
{
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);
domElement.save(stream, 4);
tagName = domElement.tagName();
lineNumber = domElement.lineNumber();
}
QString VExceptionEmptyParameter::ErrorMessage() const{
QString VExceptionEmptyParameter::ErrorMessage() const
{
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
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);
return detail;
}

View File

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

View File

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

View File

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

View File

@ -1,20 +1,23 @@
#include "vexceptionuniqueid.h"
VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement)
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
:VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
{
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText);
domElement.save(stream, 4);
tagName = domElement.tagName();
lineNumber = domElement.lineNumber();
}
QString VExceptionUniqueId::ErrorMessage() const{
QString VExceptionUniqueId::ErrorMessage() const
{
QString error = QString("ExceptionUniqueId: %1").arg(what);
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);
return detail;
}

View File

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

View File

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

View File

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

View File

@ -22,23 +22,23 @@
#include "varc.h"
#include <exception/vexception.h>
VArc::VArc () : 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 ()
: 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,
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),
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()),
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->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1();
@ -52,35 +52,43 @@ VArc &VArc::operator =(const VArc &arc){
return *this;
}
QPointF VArc::GetCenterPoint() const{
if(points.contains(center)){
QPointF VArc::GetCenterPoint() const
{
if (points.contains(center))
{
return points.value(center).toQPointF();
} else {
}
else
{
QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
throw VException(error);
}
return QPointF();
}
QPointF VArc::GetP1() const{
QPointF VArc::GetP1() const
{
QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP1(GetCenterPoint(), p1);
centerP1.setAngle(f1);
return centerP1.p2();
}
QPointF VArc::GetP2 () const{
QPointF VArc::GetP2 () const
{
QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP2(GetCenterPoint(), p2);
centerP2.setAngle(f2);
return centerP2.p2();
}
const QHash<qint64, VPointF> VArc::GetDataPoints() const{
const QHash<qint64, VPointF> VArc::GetDataPoints() const
{
return points;
}
QPainterPath VArc::GetPath() const{
QPainterPath VArc::GetPath() const
{
QPainterPath Path;
QPointF center = GetCenterPoint();
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
@ -90,74 +98,96 @@ QPainterPath VArc::GetPath() const{
return Path;
}
qreal VArc::AngleArc() const{
QLineF l1(0,0, 100, 100);
qreal VArc::AngleArc() const
{
QLineF l1(0, 0, 100, 100);
l1.setAngle(f1);
QLineF l2(0,0, 100, 100);
QLineF l2(0, 0, 100, 100);
l2.setAngle(f2);
return l1.angleTo(l2);
}
qint32 VArc::NumberSplOfArc() const{
qint32 VArc::NumberSplOfArc() const
{
qint32 angArc = static_cast<qint32> (AngleArc ());
switch( angArc ){
case 0:{
QString error = QString(tr("Angle of arc can't be 0 degree."));
throw VException(error);
}
case 90:
return 1;
case 180:
return 2;
case 270:
return 3;
case 360:
return 4;
default :
return static_cast<qint32> (AngleArc ( ) / 90 + 1);
switch ( angArc )
{
case 0:
{
QString error = QString(tr("Angle of arc can't be 0 degree."));
throw VException(error);
}
case 90:
return 1;
case 180:
return 2;
case 270:
return 3;
case 360:
return 4;
default:
return static_cast<qint32> (AngleArc ( ) / 90 + 1);
}
}
QVector<QPointF> VArc::GetPoints() const{
QVector<QPointF> VArc::GetPoints() const
{
QVector<QPointF> points;
qint32 numberSpl = NumberSplOfArc();
for(qint32 i = 1; i <= numberSpl; ++i){
for (qint32 i = 1; i <= numberSpl; ++i)
{
points<<SplOfArc ( i );
}
return points;
}
QVector<QPointF> VArc::SplOfArc(qint32 number) const{
QVector<QPointF> VArc::SplOfArc(qint32 number) const
{
qint32 n = NumberSplOfArc ();
if( number > n ){
if ( number > n )
{
QString error = QString(tr("Arc have not this number of part."));
throw VException(error);
}
qreal f1 = GetF1 ();
qreal f2 = GetF2 ();
qint32 i;
for ( i = 0; i < n; ++i ){
if ( i == n - 1 ){
for ( i = 0; i < n; ++i )
{
if ( i == n - 1 )
{
f2 = GetF2 ();
} else {
if ( f1 + 90 > 360 ){
}
else
{
if ( f1 + 90 > 360 )
{
f2 = f1 + 90 - 360;
} else {
}
else
{
f2 = f1 + 90;
}
}
qreal anglF1, anglF2;
if ( f1 + 90 > 360 ){
anglF1 = f1 + 90 - 360 ;
} else {
anglF1 = f1 + 90 ;
if ( f1 + 90 > 360 )
{
anglF1 = f1 + 90 - 360;
}
if ( f2 - 90 < 0 ){
anglF2 = 360 + f2 - 90 ;
} else {
anglF2 = f2 - 90 ;
else
{
anglF1 = f1 + 90;
}
if ( i + 1 == number ){
if ( f2 - 90 < 0 )
{
anglF2 = 360 + f2 - 90;
}
else
{
anglF2 = f2 - 90;
}
if ( i + 1 == number )
{
f1 = f2;
return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.);
}

View File

@ -27,7 +27,8 @@
/**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/
class VArc{
class VArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public:
/**
@ -42,7 +43,7 @@ public:
* @param f2 кінцевий кут в градусах.
*/
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2 , QString formulaF2,
qreal f1, QString formulaF1, qreal f2, QString formulaF2,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VArc(const VArc &arc);
VArc& operator= (const VArc &arc);
@ -103,12 +104,12 @@ private:
/**
* @brief f1 початковий кут в градусах
*/
qreal f1; // початковий кут нахилу дуги (градуси)
qreal f1; // початковий кут нахилу дуги (градуси)
QString formulaF1;
/**
* @brief f2 кінцевий кут в градусах
*/
qreal f2; // кінцевий кут нахилу дуги (градуси)
qreal f2; // кінцевий кут нахилу дуги (градуси)
QString formulaF2;
/**
* @brief radius радіус дуги.

View File

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

View File

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

View File

@ -21,20 +21,19 @@
#include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling),
typeNode(NodeDetail::Contour), mx(0), my(0){
}
VNodeDetail::VNodeDetail()
: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,
qreal mx, qreal my):id(id), typeTool(typeTool), mode(mode), typeNode(typeNode),
mx(mx), my(my){
}
qreal mx, qreal my)
:id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), mx(mx), my(my){}
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
mode(node.getMode()), typeNode(node.getTypeNode()), mx(node.getMx()), my(node.getMy()){
}
VNodeDetail::VNodeDetail(const VNodeDetail &node)
: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();
typeTool = node.getTypeTool();
mode = node.getMode();

View File

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

View File

@ -21,31 +21,34 @@
#include "vspline.h"
VSpline::VSpline():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()
: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 ()),
p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()),
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()),
mode(spline.getMode()), idObject(spline.getIdObject()){
}
VSpline::VSpline ( const VSpline & spline )
:p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()),
angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()),
points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()){}
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()),
p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(*points),
mode(mode), idObject(idObject){
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject)
:p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
kCurve(kCurve), points(*points), mode(mode), idObject(idObject)
{
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
}
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),
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode), idObject(idObject){
qreal kCurve, Draw::Draws mode, qint64 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);
}
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->p4 = p4;
this->angle1 = angle1;
@ -62,7 +65,7 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
// }
QPointF point1 = GetPointP1().toQPointF();
QPointF point4 = GetPointP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()),point4).length();
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
QLineF p1p2(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + L * kAsm1, GetPointP1().y());
@ -73,7 +76,8 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
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->p2 = p2;
this->p3 = p3;
@ -90,7 +94,7 @@ void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCu
// }
QPointF point1 = GetPointP1().toQPointF();
QPointF point4 = GetPointP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()),point4).length();
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
@ -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);
//}
VPointF VSpline::GetPointP1() const{
if(points.contains(p1)){
VPointF VSpline::GetPointP1() const
{
if (points.contains(p1))
{
return points.value(p1);
} else {
}
else
{
qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці.";
throw"Не можу знайти точку за id.";
throw "Не можу знайти точку за id.";
}
return VPointF();
}
VPointF VSpline::GetPointP4() const{
if(points.contains(p4)){
VPointF VSpline::GetPointP4() const
{
if (points.contains(p4))
{
return points.value(p4);
} else {
}
else
{
qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці.";
throw"Не можу знайти точку за id.";
throw "Не можу знайти точку за id.";
}
return VPointF();
}
qreal VSpline::GetLength () const{
qreal VSpline::GetLength () const
{
return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF());
}
QString VSpline::GetName() const{
QString VSpline::GetName() const
{
VPointF first = GetPointP1();
VPointF second = GetPointP4();
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> py;
px.append ( GetPointP1 ().x () );
@ -168,10 +183,12 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
qint32 i = 0;
QPointF crosPoint;
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] ),
QPointF ( px[i+1], py[i+1] )), &crosPoint);
if ( type == QLineF::BoundedIntersection ){
if ( type == QLineF::BoundedIntersection )
{
*intersectionPoint = crosPoint;
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());
// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint());
// 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<qreal> x;
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 );
x.append ( p4.x () );
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] ) );
}
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;
QVector<QPointF> points = GetPoints (p1, p2, p3, p4);
splinePath.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){
for (qint32 i = 1; i < points.count(); ++i)
{
splinePath.lineTo(points[i]);
}
return splinePath.length();
@ -290,9 +312,10 @@ qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) c
void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py){
const double curve_collinearity_epsilon = 1e-30;
const double curve_angle_tolerance_epsilon = 0.01;
qint16 level, QVector<qreal> &px, QVector<qreal> &py)
{
const double curve_collinearity_epsilon = 1e-30;
const double curve_angle_tolerance_epsilon = 0.01;
const double m_angle_tolerance = 0.0;
enum curve_recursion_limit_e { curve_recursion_limit = 32 };
const double m_cusp_limit = 0.0;
@ -302,7 +325,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
m_distance_tolerance_square = 0.5 / m_approximation_scale;
m_distance_tolerance_square *= m_distance_tolerance_square;
if(level > curve_recursion_limit)
if (level > curve_recursion_limit)
{
return;
}
@ -332,217 +355,240 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
double d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx));
double da1, da2, k;
switch((static_cast<int>(d2 > curve_collinearity_epsilon) << 1) +
static_cast<int>(d3 > curve_collinearity_epsilon))
switch ((static_cast<int>(d2 > curve_collinearity_epsilon) << 1) +
static_cast<int>(d3 > curve_collinearity_epsilon))
{
case 0:
// All collinear OR p1==p4
//----------------------
k = dx*dx + dy*dy;
if(k == 0)
{
d2 = CalcSqDistance(x1, y1, x2, y2);
d3 = CalcSqDistance(x4, y4, x3, y3);
}
else
{
k = 1 / k;
da1 = x2 - x1;
da2 = y2 - y1;
d2 = k * (da1*dx + da2*dy);
da1 = x3 - x1;
da2 = y3 - y1;
d3 = k * (da1*dx + da2*dy);
if(d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1)
{
// Simple collinear case, 1---2---3---4
// We can leave just two endpoints
return;
}
if(d2 <= 0)
d2 = CalcSqDistance(x2, y2, x1, y1);
else if(d2 >= 1)
d2 = CalcSqDistance(x2, y2, x4, y4);
else
d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy);
if(d3 <= 0)
d3 = CalcSqDistance(x3, y3, x1, y1);
else if(d3 >= 1)
d3 = CalcSqDistance(x3, y3, x4, y4);
else
d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy);
}
if(d2 > d3)
{
if(d2 < m_distance_tolerance_square)
{
px.append(x2);
py.append(y2);
//m_points.add(point_d(x2, y2));
return;
}
}
else
{
if(d3 < m_distance_tolerance_square)
{
px.append(x3);
py.append(y3);
//m_points.add(point_d(x3, y3));
return;
}
}
break;
case 1:
// p1,p2,p4 are collinear, p3 is significant
//----------------------
if(d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
if(m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
// Angle Condition
case 0:
// All collinear OR p1==p4
//----------------------
da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
if(da1 >= M_PI)
da1 = 2*M_PI - da1;
if(da1 < m_angle_tolerance)
k = dx*dx + dy*dy;
if (k == 0)
{
px.append(x2);
py.append(y2);
px.append(x3);
py.append(y3);
//m_points.add(point_d(x2, y2));
//m_points.add(point_d(x3, y3));
return;
d2 = CalcSqDistance(x1, y1, x2, y2);
d3 = CalcSqDistance(x4, y4, x3, y3);
}
if(m_cusp_limit != 0.0)
else
{
if(da1 > m_cusp_limit)
k = 1 / k;
da1 = x2 - x1;
da2 = y2 - y1;
d2 = k * (da1*dx + da2*dy);
da1 = x3 - x1;
da2 = y3 - y1;
d3 = k * (da1*dx + da2*dy);
if (d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1)
{
// Simple collinear case, 1---2---3---4
// We can leave just two endpoints
return;
}
if (d2 <= 0)
{
d2 = CalcSqDistance(x2, y2, x1, y1);
}
else if (d2 >= 1)
{
d2 = CalcSqDistance(x2, y2, x4, y4);
}
else
{
d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy);
}
if (d3 <= 0)
{
d3 = CalcSqDistance(x3, y3, x1, y1);
}
else if (d3 >= 1)
{
d3 = CalcSqDistance(x3, y3, x4, y4);
}
else
{
d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy);
}
}
if (d2 > d3)
{
if (d2 < m_distance_tolerance_square)
{
px.append(x2);
py.append(y2);
//m_points.add(point_d(x2, y2));
return;
}
}
else
{
if (d3 < m_distance_tolerance_square)
{
px.append(x3);
py.append(y3);
//m_points.add(point_d(x3, y3));
return;
}
}
}
break;
case 2:
// p1,p3,p4 are collinear, p2 is significant
//----------------------
if(d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
if(m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
// Angle Condition
break;
case 1:
// p1,p2,p4 are collinear, p3 is significant
//----------------------
da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
if(da1 >= M_PI) da1 = 2*M_PI - da1;
if(da1 < m_angle_tolerance)
if (d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
px.append(x2);
py.append(y2);
px.append(x3);
py.append(y3);
//m_points.add(point_d(x2, y2));
//m_points.add(point_d(x3, y3));
return;
}
if(m_cusp_limit != 0.0)
{
if(da1 > m_cusp_limit)
if (m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x2);
py.append(y2);
//m_points.add(point_d(x2, y2));
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
}
}
break;
case 3:
// Regular case
//-----------------
if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
// If the curvature doesn't exceed the distance_tolerance value
// we tend to finish subdivisions.
//----------------------
if(m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
// Angle & Cusp Condition
//----------------------
k = atan2(y3 - y2, x3 - x2);
da1 = fabs(k - atan2(y2 - y1, x2 - x1));
da2 = fabs(atan2(y4 - y3, x4 - x3) - k);
if(da1 >= M_PI) da1 = 2*M_PI - da1;
if(da2 >= M_PI) da2 = 2*M_PI - da2;
if(da1 + da2 < m_angle_tolerance)
{
// Finally we can stop the recursion
// Angle Condition
//----------------------
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
if(m_cusp_limit != 0.0)
{
if(da1 > m_cusp_limit)
da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
if (da1 >= M_PI)
{
da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance)
{
px.append(x2);
py.append(y2);
return;
}
if(da2 > m_cusp_limit)
{
px.append(x3);
py.append(y3);
//m_points.add(point_d(x2, y2));
//m_points.add(point_d(x3, y3));
return;
}
if (m_cusp_limit != 0.0)
{
if (da1 > m_cusp_limit)
{
px.append(x3);
py.append(y3);
//m_points.add(point_d(x3, y3));
return;
}
}
}
}
break;
break;
case 2:
// p1,p3,p4 are collinear, p2 is significant
//----------------------
if (d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
if (m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
// Angle Condition
//----------------------
da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
if (da1 >= M_PI)
{
da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance)
{
px.append(x2);
py.append(y2);
px.append(x3);
py.append(y3);
//m_points.add(point_d(x2, y2));
//m_points.add(point_d(x3, y3));
return;
}
if (m_cusp_limit != 0.0)
{
if (da1 > m_cusp_limit)
{
px.append(x2);
py.append(y2);
//m_points.add(point_d(x2, y2));
return;
}
}
}
break;
case 3:
// Regular case
//-----------------
if ((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy))
{
// If the curvature doesn't exceed the distance_tolerance value
// we tend to finish subdivisions.
//----------------------
if (m_angle_tolerance < curve_angle_tolerance_epsilon)
{
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
// Angle & Cusp Condition
//----------------------
k = atan2(y3 - y2, x3 - x2);
da1 = fabs(k - atan2(y2 - y1, x2 - x1));
da2 = fabs(atan2(y4 - y3, x4 - x3) - k);
if (da1 >= M_PI)
{
da1 = 2*M_PI - da1;
}
if (da2 >= M_PI)
{
da2 = 2*M_PI - da2;
}
if (da1 + da2 < m_angle_tolerance)
{
// Finally we can stop the recursion
//----------------------
px.append(x23);
py.append(y23);
//m_points.add(point_d(x23, y23));
return;
}
if (m_cusp_limit != 0.0)
{
if (da1 > m_cusp_limit)
{
px.append(x2);
py.append(y2);
return;
}
if (da2 > m_cusp_limit)
{
px.append(x3);
py.append(y3);
return;
}
}
}
break;
}
// Continue subdivision
@ -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);
}
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 dy = y2 - y1;
return dx * dx + dy * dy;
}
QPainterPath VSpline::GetPath() const{
QPainterPath VSpline::GetPath() const
{
QPainterPath splinePath;
QVector<QPointF> points = GetPoints ();
if(points.count() >= 2){
for (qint32 i = 0; i < points.count()-1; ++i){
if (points.count() >= 2)
{
for (qint32 i = 0; i < points.count()-1; ++i)
{
splinePath.moveTo(points[i]);
splinePath.lineTo(points[i+1]);
}
} else {
}
else
{
qWarning()<<"points.count() < 2"<<Q_FUNC_INFO;
}
return splinePath;
}
/* Cubic equation solution. Real coefficients case.
int Cubic(double *x,double a,double b,double c);
Parameters:
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){
// qreal q,r,r2,q3;
//
// q = (a*a - 3.*b)/9.;
// r = (a*(2.*a*a - 9.*b) + 27.*c)/54.;
// r2 = r*r;
@ -624,24 +675,24 @@ QPainterPath VSpline::GetPath() const{
// return(1);
// }
//}
//
//qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3,
// qreal curve_coord4, qreal point_coord) const{
// qreal P1, P2, P3, P4, Bt;
// qreal a, b, c, d, ret_t;
//
// qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal)));
// P1 = curve_coord1;
// P2 = curve_coord2;
// P3 = curve_coord3;
// P4 = curve_coord4;
// Bt = point_coord;
//
// a = -P1 + 3*P2 - 3*P3 + P4;
// b = 3*P1 - 6*P2 + 3*P3;
// c = -3*P1 + 3*P2;
// d = -Bt + P1;
//
// if(Cubic(t, b/a, c/a, d/a) == 3){
// ret_t = t[2];
// } else {
@ -651,7 +702,7 @@ QPainterPath VSpline::GetPath() const{
// * Повертається три значення, але експереминтально знайдено що шукане
// * значення знаходиться в третьому.
// */
//
// free(t);
// if(ret_t<0 || ret_t>1){
// qDebug()<<"Неправильне значення параметра. фунція calc_t";
@ -675,7 +726,7 @@ QPainterPath VSpline::GetPath() const{
// else
// return t_y;
//}
//
//void VSpline::Mirror(const QPointF Pmirror){
// QPointF P1 = p1;
// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y());
@ -697,11 +748,12 @@ QPainterPath VSpline::GetPath() const{
//}
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());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
radius = QLineF(QPointF(p1.x(), p4.y()),p4).length();
radius = QLineF(QPointF(p1.x(), p4.y()), p4).length();
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
p1p2.setAngle(angle1);
@ -712,7 +764,8 @@ QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qre
return GetPoints(p1, p2, p3, p4);
}
VSpline &VSpline::operator =(const VSpline &spline){
VSpline &VSpline::operator =(const VSpline &spline)
{
this->p1 = spline.GetP1 ();
this->p2 = spline.GetP2 ();
this->p3 = spline.GetP3 ();

View File

@ -29,7 +29,8 @@
/**
* @brief VSpline клас, що реалізує сплайн.
*/
class VSpline{
class VSpline
{
public:
VSpline();
/**
@ -196,27 +197,27 @@ private:
/**
* @brief p1 початкова точка сплайну
*/
qint64 p1; // перша точка
qint64 p1; // перша точка
/**
* @brief p2 перша контрольна точка сплайну.
*/
QPointF p2; // друга точка
QPointF p2; // друга точка
/**
* @brief p3 друга контрольна точка сплайну.
*/
QPointF p3; // третя точка
QPointF p3; // третя точка
/**
* @brief p4 кінцеві точка сплайну.
*/
qint64 p4; // четверта точка
qint64 p4; // четверта точка
/**
* @brief angle1 кут в градусах першої напрямної.
*/
qreal angle1; // кут нахилу дотичної в першій точці
qreal angle1; // кут нахилу дотичної в першій точці
/**
* @brief angle2 кут в градусах другої напрямної.
*/
qreal angle2; // кут нахилу дотичної в другій точці
qreal angle2; // кут нахилу дотичної в другій точці
qreal kAsm1;
qreal kAsm2;
qreal kCurve;

View File

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

View File

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

View File

@ -21,19 +21,11 @@
#include "vsplinepoint.h"
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()
: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()){}

View File

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

View File

@ -24,29 +24,32 @@
#include <QTextCodec>
#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();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
abort();
switch (type)
{
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
abort();
}
}
int main(int argc, char *argv[]){
int main(int argc, char *argv[])
{
qInstallMessageHandler(myMessageOutput);
VApplication app(argc, argv);
@ -56,7 +59,7 @@ int main(int argc, char *argv[]){
app.installTranslator(&qtTranslator);
QTranslator appTranslator;
appTranslator.load("valentina_" + QLocale::system().name(),".");
appTranslator.load("valentina_" + QLocale::system().name(), ".");
app.installTranslator(&appTranslator);
MainWindow w;
@ -70,23 +73,31 @@ int main(int argc, char *argv[]){
QString fileName;
QRegExp rxArgOpenFile("-o");//parameter open file
if(args.size()>1){
for (int i = 1; i < args.size(); ++i) {
if (rxArgOpenFile.indexIn(args.at(i)) != -1 ) {
if(args.at(i+1).isEmpty() == false){
if (args.size()>1)
{
for (int i = 1; i < args.size(); ++i)
{
if (rxArgOpenFile.indexIn(args.at(i)) != -1 )
{
if (args.at(i+1).isEmpty() == false)
{
fileName = args.at(i+1);
qDebug() << args.at(i)<< ":" << fileName;
w.OpenPattern(fileName);
}
w.show();
break;
} else {
}
else
{
qDebug() << "Uknown arg:" << args.at(i);
w.show();
break;
}
}
} else {
}
else
{
w.show();
}
return app.exec();

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -31,44 +31,49 @@
#define widthMainLine toPixel(1.2)
#define widthHairLine widthMainLine/3
namespace Scene{
enum Scene { Point, Line, Spline, Arc, SplinePath, Detail };
Q_DECLARE_FLAGS(Scenes, Scene)
namespace Scene
{
enum Scene { Point, Line, Spline, Arc, SplinePath, Detail };
Q_DECLARE_FLAGS(Scenes, Scene)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Scene::Scenes )
namespace Tool{
enum Tool {ArrowTool,
SinglePointTool,
EndLineTool,
LineTool,
AlongLineTool,
ShoulderPointTool,
NormalTool,
BisectorTool,
LineIntersectTool,
SplineTool,
ArcTool,
SplinePathTool,
PointOfContact,
Detail,
NodePoint,
NodeArc,
NodeSpline,
NodeSplinePath,
Height,
Triangle,
PointOfIntersection
};
Q_DECLARE_FLAGS(Tools, Tool)
namespace Tool
{
enum Tool
{
ArrowTool,
SinglePointTool,
EndLineTool,
LineTool,
AlongLineTool,
ShoulderPointTool,
NormalTool,
BisectorTool,
LineIntersectTool,
SplineTool,
ArcTool,
SplinePathTool,
PointOfContact,
Detail,
NodePoint,
NodeArc,
NodeSpline,
NodeSplinePath,
Height,
Triangle,
PointOfIntersection
};
Q_DECLARE_FLAGS(Tools, Tool)
enum Source { FromGui, FromFile };
Q_DECLARE_FLAGS(Sources, Source)
enum Source { FromGui, FromFile };
Q_DECLARE_FLAGS(Sources, Source)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools )
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Sources )
namespace Draw {
namespace Draw
{
enum Draw { Calculation, Modeling };
Q_DECLARE_FLAGS(Draws, Draw)
}

View File

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

View File

@ -25,14 +25,16 @@
#include <QMainWindow>
#include "widgets/vitem.h"
namespace Ui {
namespace Ui
{
class TableWindow;
}
/**
* @brief TableWindow клас вікна створення розкладки.
*/
class TableWindow : public QMainWindow{
class TableWindow : public QMainWindow
{
Q_OBJECT
public:
/**
@ -47,7 +49,7 @@ public:
* @brief TableWindow Конструктор класу вікна створення розкладки.
* @param parent Батько об'єкту. За замовчуванням = 0.
*/
explicit TableWindow(QWidget *parent = 0);
explicit TableWindow(QWidget *parent = 0);
/**
* @brief ~TableWindow Деструктор класу вікна.
*/

View File

@ -23,24 +23,31 @@
qreal VDrawTool::factor = 1;
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw()){
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent)
:VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw())
{
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw);
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
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();
QVector<VToolRecord> *history = doc->getHistory();
if(cursor <= 0){
if (cursor <= 0)
{
history->append(VToolRecord(id, toolType, doc->GetNameActivDraw()));
} else {
}
else
{
qint32 index = 0;
for(qint32 i = 0; i<history->size(); ++i){
for (qint32 i = 0; i<history->size(); ++i)
{
VToolRecord rec = history->at(i);
if(rec.getId() == cursor){
if (rec.getId() == cursor)
{
index = i;
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(color);
Q_UNUSED(enable);
}
void VDrawTool::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){
void VDrawTool::ChangedActivDraw(const QString newName)
{
if (nameActivDraw == newName)
{
ignoreContextMenuEvent = false;
} else {
}
else
{
ignoreContextMenuEvent = true;
}
}
void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName){
if(nameActivDraw == oldName){
void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName)
{
if (nameActivDraw == oldName)
{
nameActivDraw = newName;
}
}
void VDrawTool::SetFactor(qreal factor){
if(factor <= 2 && factor >= 0.5){
void VDrawTool::SetFactor(qreal factor)
{
if (factor <= 2 && factor >= 0.5)
{
this->factor = factor;
}
}
void VDrawTool::AddToCalculation(const QDomElement &domElement){
void VDrawTool::AddToCalculation(const QDomElement &domElement)
{
QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
if (ok)
{
qint64 id = doc->getCursor();
if(id <= 0){
if (id <= 0)
{
calcElement.appendChild(domElement);
} else {
}
else
{
QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor()));
if(refElement.isElement()){
calcElement.insertAfter(domElement,refElement);
if (refElement.isElement())
{
calcElement.insertAfter(domElement, refElement);
doc->setCursor(0);
} else {
}
else
{
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;
}
emit toolhaveChange();

View File

@ -24,7 +24,8 @@
#include "../vabstracttool.h"
class VDrawTool : public VAbstractTool{
class VDrawTool : public VAbstractTool
{
Q_OBJECT
public:
VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
@ -46,29 +47,37 @@ protected:
void AddToCalculation(const QDomElement &domElement);
template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true){
bool showRemove = true)
{
Q_ASSERT(tool != 0);
Q_ASSERT(event != 0);
if(!ignoreContextMenuEvent){
if (ignoreContextMenuEvent == false)
{
QMenu menu;
QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = 0;
if(showRemove){
if (showRemove)
{
actionRemove = menu.addAction(tr("Delete"));
if(_referens > 1){
if (_referens > 1)
{
actionRemove->setEnabled(false);
} else {
}
else
{
actionRemove->setEnabled(true);
}
}
QAction *selectedAction = menu.exec(event->screenPos());
if(selectedAction == actionOption){
if (selectedAction == actionOption)
{
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
&VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui);
if(!ignoreFullUpdate){
if (ignoreFullUpdate == false)
{
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
}
@ -76,16 +85,20 @@ protected:
dialog->show();
}
if(showRemove){
if(selectedAction == actionRemove){
if (showRemove)
{
if (selectedAction == actionRemove)
{
//deincrement referens
RemoveReferens();
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
if (domElement.isElement())
{
QDomElement element;
bool ok = doc->GetActivCalculationElement(element);
if(ok){
if (ok)
{
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
@ -98,12 +111,17 @@ protected:
}
}
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);
if(id == item->id){
if(enable == false){
if (id == item->id)
{
if (enable == false)
{
currentColor = baseColor;
} else {
}
else
{
currentColor = color;
}
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,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Sources typeCreation,
QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>()){
QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>())
{
if(typeCreation == Tool::FromGui){
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VToolAlongLine::FullUpdateFromFile(){
void VToolAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
@ -47,10 +51,13 @@ void VToolAlongLine::FullUpdateFromFile(){
RefreshGeometry();
}
void VToolAlongLine::FullUpdateFromGui(int result){
if(result == QDialog::Accepted){
void VToolAlongLine::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogAlongLine->getPointName());
domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine());
domElement.setAttribute(AttrLength, dialogAlongLine->getFormula());
@ -62,16 +69,19 @@ void VToolAlongLine::FullUpdateFromGui(int result){
dialogAlongLine.clear();
}
void VToolAlongLine::SetFactor(qreal factor){
void VToolAlongLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogAlongLine, this, event);
}
void VToolAlongLine::AddToFile(){
void VToolAlongLine::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);
@ -89,25 +99,26 @@ void VToolAlongLine::AddToFile(){
AddToCalculation(domElement);
}
void VToolAlongLine::RemoveReferens(){
void VToolAlongLine::RemoveReferens()
{
doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens();
}
void VToolAlongLine::setDialog(){
Q_ASSERT(!dialogAlongLine.isNull());
if(!dialogAlongLine.isNull()){
VPointF p = VAbstractTool::data.GetPoint(id);
dialogAlongLine->setTypeLine(typeLine);
dialogAlongLine->setFormula(formula);
dialogAlongLine->setFirstPointId(basePointId, id);
dialogAlongLine->setSecondPointId(secondPointId, id);
dialogAlongLine->setPointName(p.name());
}
void VToolAlongLine::setDialog()
{
Q_ASSERT(dialogAlongLine.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id);
dialogAlongLine->setTypeLine(typeLine);
dialogAlongLine->setFormula(formula);
dialogAlongLine->setFirstPointId(basePointId, id);
dialogAlongLine->setSecondPointId(secondPointId, id);
dialogAlongLine->setPointName(p.name());
}
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data)
{
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
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,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
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 secondPoint = data->GetPoint(secondPointId);
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
if (errorMsg.isEmpty())
{
line.setLength(toPixel(result));
qint64 id = _id;
if(typeCreation == Tool::FromGui){
if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
} else {
}
else
{
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
if(parse != Document::FullParse){
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::AlongLineTool, doc);
if(parse == Document::FullParse){
if (parse == Document::FullParse)
{
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId,
secondPointId, typeLine, typeCreation);
scene->addItem(point);

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h"
#include "dialogs/dialogalongline.h"
class VToolAlongLine : public VToolLinePoint{
class VToolAlongLine : public VToolLinePoint
{
Q_OBJECT
public:
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
@ -49,7 +50,7 @@ protected:
virtual void RemoveReferens();
private:
qint64 secondPointId;
QSharedPointer<DialogAlongLine> dialogAlongLine;
QSharedPointer<DialogAlongLine> dialogAlongLine;
};
#endif // VTOOLALONGLINE_H

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h"
#include "dialogs/dialogendline.h"
class VToolEndLine : public VToolLinePoint{
class VToolEndLine : public VToolLinePoint
{
Q_OBJECT
public:
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,
Tool::Sources typeCreation, QGraphicsItem * 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;
if(typeCreation == Tool::FromGui){
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VToolHeight::setDialog(){
Q_ASSERT(!dialogHeight.isNull());
void VToolHeight::setDialog()
{
Q_ASSERT(dialogHeight.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id);
dialogHeight->setTypeLine(typeLine);
dialogHeight->setBasePointId(basePointId, id);
@ -24,7 +27,8 @@ void VToolHeight::setDialog(){
}
void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data)
{
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList);
QString pointName = dialog->getPointName();
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,
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
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 p1Line = data->GetPoint(p1LineId);
VPointF p2Line = data->GetPoint(p2LineId);
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
qint64 id = _id;
if(typeCreation == Tool::FromGui){
if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
data->AddLine(basePointId, id);
data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id);
} else {
}
else
{
data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
data->AddLine(basePointId, id);
data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id);
if(parse != Document::FullParse){
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
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,
typeCreation);
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;
LineCoefficients(line, &a, &b, &c);
qreal x = point.x() + a;
qreal y = b + point.y();
QLineF l (point, QPointF(x, y));
QLineF lin (point, QPointF(x, y));
QPointF p;
QLineF::IntersectType intersect = line.intersect(l, &p);
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
QLineF::IntersectType intersect = line.intersect(lin, &p);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
return p;
} else {
}
else
{
return QPointF();
}
}
void VToolHeight::FullUpdateFromFile(){
void VToolHeight::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toLongLong();
p1LineId = domElement.attribute(AttrP1Line, "").toLongLong();
@ -101,10 +117,13 @@ void VToolHeight::FullUpdateFromFile(){
}
void VToolHeight::FullUpdateFromGui(int result){
if(result == QDialog::Accepted){
void VToolHeight::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogHeight->getPointName());
domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine());
domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId()));
@ -116,11 +135,13 @@ void VToolHeight::FullUpdateFromGui(int result){
dialogHeight.clear();
}
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogHeight, this, event);
}
void VToolHeight::AddToFile(){
void VToolHeight::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,8 @@
#include "vtoolpoint.h"
#include "dialogs/dialoglineintersect.h"
class VToolLineIntersect:public VToolPoint{
class VToolLineIntersect:public VToolPoint
{
Q_OBJECT
public:
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,
const QString &typeLine, const QString &formula, const qint64 &basePointId,
const qreal &angle, QGraphicsItem *parent):VToolPoint(doc, data, id, parent),
typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId), mainLine(0){
const qreal &angle, QGraphicsItem *parent)
: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");
//Лінія, що з'єднує дві точки
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->setPen(QPen(Qt::black, widthHairLine/factor));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if(typeLine == TypeLineNone){
if (typeLine == TypeLineNone)
{
mainLine->setVisible(false);
} else {
}
else
{
mainLine->setVisible(true);
}
}
void VToolLinePoint::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){
void VToolLinePoint::ChangedActivDraw(const QString newName)
{
if (nameActivDraw == newName)
{
currentColor = Qt::black;
} else {
}
else
{
currentColor = Qt::gray;
}
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::ChangedActivDraw(newName);
}
void VToolLinePoint::RefreshGeometry(){
void VToolLinePoint::RefreshGeometry()
{
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
QPointF point = VDrawTool::data.GetPoint(id).toQPointF();
QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF();
mainLine->setLine(QLineF(basePoint - point, QPointF()));
if(typeLine == TypeLineNone){
if (typeLine == TypeLineNone)
{
mainLine->setVisible(false);
} else {
}
else
{
mainLine->setVisible(true);
}
}
void VToolLinePoint::SetFactor(qreal factor){
void VToolLinePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}

View File

@ -24,14 +24,15 @@
#include "vtoolpoint.h"
class VToolLinePoint : public VToolPoint{
class VToolLinePoint : public VToolPoint
{
Q_OBJECT
public:
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &basePointId, const qreal &angle,
QGraphicsItem * parent = 0);
public slots:
virtual void ChangedActivDraw(const QString newName);
virtual void ChangedActivDraw(const QString newName);
virtual void SetFactor(qreal factor);
protected:
QString typeLine;

View File

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

View File

@ -25,7 +25,8 @@
#include "vtoollinepoint.h"
#include "dialogs/dialognormal.h"
class VToolNormal : public VToolLinePoint{
class VToolNormal : public VToolLinePoint
{
Q_OBJECT
public:
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