Merge with develop

--HG--
branch : feature
This commit is contained in:
dismine 2013-11-18 13:21:59 +02:00
commit 6ef16b51d0
235 changed files with 15957 additions and 9130 deletions

View File

@ -22,3 +22,6 @@ latex/
# Ignore file used QtCreator for user profile.
*.pro.user
# Ignore file Qt translation.
*.qm

5
AUTHORS Normal file
View File

@ -0,0 +1,5 @@
Author:
(*) Roman Telezhinsky <dismine@gmail.com>
Founder of the project.

3
ChangeLog Normal file
View File

@ -0,0 +1,3 @@
# Version 0.2.0 Released October 29, 2013

44
README Normal file
View File

@ -0,0 +1,44 @@
Valentina
==========
Open source project of creating a pattern making program, whose allow
create and modeling patterns of clothing.
Published under GNU GPL v3 license.
Supported Platforms
===================
The standalone binary packages support the following platforms:
Windows XP SP2 or later
Ubuntu Linux 11.10 (32-bit) or later
Building the sources requires Qt 5.0.0 or later.
Compiling Valentina
====================
Prerequisites:
* Qt 5.0.0 or later
* On Windows:
- MinGW or Visual Studio
The installed toolchains have to match the one Qt was compiled with.
You can build Valentina with
cd $SOURCE_DIRECTORY
qmake -r
make (or mingw32-make or nmake or jom, depending on your platform)
Installation ("make install") is not needed.
Note:In order to build and use Valentina, the PATH environment variable
needs to be extended:
PATH - to locate qmake, moc and other Qt tools
This is done by adding c:\Qt\%VERSION%\bin to the PATH variable.
For newer versions of Windows, PATH can be extended through the
Control Panel|System|Advanced|Environment variables menu.
You may also need to ensure that the locations of your compiler and
other build tools are listed in the PATH variable. This will depend on
your choice of software development environment.

33
TODO Normal file
View File

@ -0,0 +1,33 @@
Valentina TODO file.
For more information see https://bitbucket.org/dismine/valentina/issues
(c) Valentina Team 2013
* Rotate details.
* Reflection details.
* Theme with icon for windows version of program.
* Label on detail.
* Checking integrity of file.
* Description of pattern.
* Type of lines.
* New way create detail.
* Tuck transfer.
* Point on arc, curve and curve path.
* Union details.
* Сonditions.
* New format name.
* Standard table of measurements.
* Localization.
* Window "Option".
* Undo/redo functionality in applications.
* Checking file integrity.
* Sketch drawing.
* Graduation card.
* Individual mode of construction pattern.
* Description about pattern in SVG file.
* Visualization.

View File

@ -8,208 +8,21 @@
QT += core gui widgets xml svg
TARGET = Valentina
TEMPLATE = app
DEBUG_TARGET = Valentinad
RELEASE_TARGET = Valentina
CONFIG -= debug_and_release debug_and_release_target
CONFIG += c++11
CONFIG += c++11 precompile_header
SOURCES += main.cpp\
mainwindow.cpp \
dialogs/dialogsinglepoint.cpp \
widgets/vgraphicssimpletextitem.cpp \
xml/vdomdocument.cpp \
container/vpointf.cpp \
container/vcontainer.cpp \
tools/drawTools/vtoolpoint.cpp \
container/calculator.cpp \
dialogs/dialogincrements.cpp \
container/vstandarttablecell.cpp \
container/vincrementtablerow.cpp \
widgets/doubledelegate.cpp \
dialogs/dialogendline.cpp \
tools/drawTools/vtoolendline.cpp \
tools/drawTools/vtoolline.cpp \
tools/vabstracttool.cpp \
dialogs/dialogline.cpp \
tools/drawTools/vtoolalongline.cpp \
dialogs/dialogtool.cpp \
dialogs/dialogalongline.cpp \
tools/drawTools/vtoolshoulderpoint.cpp \
dialogs/dialogshoulderpoint.cpp \
tools/drawTools/vtoolnormal.cpp \
dialogs/dialognormal.cpp \
tools/drawTools/vtoolbisector.cpp \
dialogs/dialogbisector.cpp \
tools/drawTools/vtoollinepoint.cpp \
tools/drawTools/vtoollineintersect.cpp \
dialogs/dialoglineintersect.cpp \
geometry/vspline.cpp \
tools/drawTools/vtoolsinglepoint.cpp \
geometry/varc.cpp \
widgets/vcontrolpointspline.cpp \
tools/drawTools/vtoolspline.cpp \
dialogs/dialogspline.cpp \
tools/drawTools/vtoolarc.cpp \
dialogs/dialogarc.cpp \
geometry/vsplinepoint.cpp \
geometry/vsplinepath.cpp \
tools/drawTools/vtoolsplinepath.cpp \
dialogs/dialogsplinepath.cpp \
widgets/vmaingraphicsscene.cpp \
widgets/vmaingraphicsview.cpp \
tools/vdatatool.cpp \
xml/vtoolrecord.cpp \
dialogs/dialoghistory.cpp \
tools/drawTools/vtoolpointofcontact.cpp \
dialogs/dialogpointofcontact.cpp \
geometry/vnodedetail.cpp \
geometry/vdetail.cpp \
dialogs/dialogdetail.cpp \
tools/vtooldetail.cpp \
widgets/vtablegraphicsview.cpp \
widgets/vitem.cpp \
tablewindow.cpp \
tools/nodeDetails/vnodearc.cpp \
tools/nodeDetails/vnodepoint.cpp \
tools/nodeDetails/vnodespline.cpp \
tools/nodeDetails/vnodesplinepath.cpp \
tools/drawTools/vdrawtool.cpp \
tools/nodeDetails/vabstractnode.cpp \
tools/modelingTools/vmodelingtool.cpp \
tools/modelingTools/vmodelingalongline.cpp \
tools/modelingTools/vmodelingarc.cpp \
tools/modelingTools/vmodelingbisector.cpp \
tools/modelingTools/vmodelingendline.cpp \
tools/modelingTools/vmodelingline.cpp \
tools/modelingTools/vmodelinglineintersect.cpp \
tools/modelingTools/vmodelinglinepoint.cpp \
tools/modelingTools/vmodelingnormal.cpp \
tools/modelingTools/vmodelingpoint.cpp \
tools/modelingTools/vmodelingpointofcontact.cpp \
tools/modelingTools/vmodelingshoulderpoint.cpp \
tools/modelingTools/vmodelingspline.cpp \
tools/modelingTools/vmodelingsplinepath.cpp \
exception/vexception.cpp \
exception/vexceptionbadid.cpp \
exception/vexceptionwrongparameterid.cpp \
exception/vexceptionconversionerror.cpp \
exception/vexceptionemptyparameter.cpp \
exception/vexceptionobjecterror.cpp \
widgets/vapplication.cpp \
exception/vexceptionuniqueid.cpp
#DEFINES += ...
HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \
dialogs/dialogsinglepoint.h \
options.h \
widgets/vgraphicssimpletextitem.h \
xml/vdomdocument.h \
container/vpointf.h \
container/vcontainer.h \
tools/drawTools/vtoolpoint.h \
container/calculator.h \
dialogs/dialogincrements.h \
container/vstandarttablecell.h \
container/vincrementtablerow.h \
widgets/doubledelegate.h \
dialogs/dialogendline.h \
tools/drawTools/vtoolendline.h \
tools/drawTools/vtoolline.h \
tools/vabstracttool.h \
dialogs/dialogline.h \
tools/drawTools/vtoolalongline.h \
dialogs/dialogtool.h \
dialogs/dialogalongline.h \
tools/drawTools/vtoolshoulderpoint.h \
dialogs/dialogshoulderpoint.h \
tools/drawTools/vtoolnormal.h \
dialogs/dialognormal.h \
tools/drawTools/vtoolbisector.h \
dialogs/dialogbisector.h \
tools/drawTools/vtoollinepoint.h \
tools/drawTools/vtoollineintersect.h \
dialogs/dialoglineintersect.h \
geometry/vspline.h \
tools/drawTools/vtoolsinglepoint.h \
geometry/varc.h \
widgets/vcontrolpointspline.h \
tools/drawTools/vtoolspline.h \
dialogs/dialogspline.h \
tools/drawTools/vtoolarc.h \
dialogs/dialogarc.h \
geometry/vsplinepoint.h \
geometry/vsplinepath.h \
tools/drawTools/vtoolsplinepath.h \
dialogs/dialogsplinepath.h \
widgets/vmaingraphicsview.h \
tools/vdatatool.h \
xml/vtoolrecord.h \
dialogs/dialoghistory.h \
tools/drawTools/vtoolpointofcontact.h \
dialogs/dialogpointofcontact.h \
geometry/vnodedetail.h \
geometry/vdetail.h \
dialogs/dialogdetail.h \
tools/vtooldetail.h \
widgets/vtablegraphicsview.h \
widgets/vitem.h \
tablewindow.h \
tools/tools.h \
tools/drawTools/drawtools.h \
tools/nodeDetails/nodedetails.h \
tools/nodeDetails/vnodearc.h \
tools/nodeDetails/vnodepoint.h \
tools/nodeDetails/vnodespline.h \
tools/nodeDetails/vnodesplinepath.h \
stable.h \
tools/drawTools/vdrawtool.h \
tools/nodeDetails/vabstractnode.h \
dialogs/dialogs.h \
tools/modelingTools/modelingtools.h \
tools/modelingTools/vmodelingtool.h \
tools/modelingTools/vmodelingalongline.h \
tools/modelingTools/vmodelingarc.h \
tools/modelingTools/vmodelingbisector.h \
tools/modelingTools/vmodelingendline.h \
tools/modelingTools/vmodelingline.h \
tools/modelingTools/vmodelinglineintersect.h \
tools/modelingTools/vmodelinglinepoint.h \
tools/modelingTools/vmodelingnormal.h \
tools/modelingTools/vmodelingpoint.h \
tools/modelingTools/vmodelingpointofcontact.h \
tools/modelingTools/vmodelingshoulderpoint.h \
tools/modelingTools/vmodelingspline.h \
tools/modelingTools/vmodelingsplinepath.h \
exception/vexception.h \
exception/vexceptionbadid.h \
exception/vexceptionwrongparameterid.h \
exception/vexceptionconversionerror.h \
exception/vexceptionemptyparameter.h \
exception/vexceptionobjecterror.h \
widgets/vapplication.h \
exception/vexceptionuniqueid.h
FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \
dialogs/dialogincrements.ui \
dialogs/dialogendline.ui \
dialogs/dialogline.ui \
dialogs/dialogalongline.ui \
dialogs/dialogshoulderpoint.ui \
dialogs/dialognormal.ui \
dialogs/dialogbisector.ui \
dialogs/dialoglineintersect.ui \
dialogs/dialogspline.ui \
dialogs/dialogarc.ui \
dialogs/dialogsplinepath.ui \
dialogs/dialoghistory.ui \
dialogs/dialogpointofcontact.ui \
dialogs/dialogdetail.ui \
tablewindow.ui
RESOURCES += \
icon.qrc \
cursor.qrc
# Precompiled headers (PCH)
PRECOMPILED_HEADER = stable.h
win32-msvc* {
PRECOMPILED_SOURCE = stable.cpp
}
# directory for executable file
DESTDIR = bin
@ -226,28 +39,65 @@ RCC_DIR = rcc
# files created uic
UI_DIR = uic
# Use Precompiled headers (PCH)
PRECOMPILED_HEADER = stable.h
include(container/container.pri)
include(dialogs/dialogs.pri)
include(exception/exception.pri)
include(geometry/geometry.pri)
include(tools/tools.pri)
include(widgets/widgets.pri)
include(xml/xml.pri)
SOURCES += main.cpp\
mainwindow.cpp \
tablewindow.cpp \
stable.cpp
HEADERS += mainwindow.h \
options.h \
tablewindow.h \
stable.h \
version.h
FORMS += mainwindow.ui \
tablewindow.ui
RESOURCES += \
icon.qrc \
cursor.qrc
TRANSLATIONS += translations/valentina_ru.ts \
translations/valentina_uk.ts
CONFIG(debug, debug|release){
# Debug
QMAKE_CXX = ccache g++
TARGET = $$DEBUG_TARGET
QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtWidgets" \
-isystem "/usr/include/qt5/QtXml" -isystem "/usr/include/qt5/QtGui" \
-isystem "/usr/include/qt5/QtCore" -isystem "$$OUT_PWD/uic" -isystem "$$OUT_PWD/moc/" \
-isystem "$$OUT_PWD/rcc/" \
-Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \
-Wunreachable-code
-Wunreachable-code -Wcast-align -Wcast-qual -Wdisabled-optimization -Wfloat-equal \
-Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k\
-Winvalid-pch -Wunsafe-loop-optimizations -Wlong-long -Wmissing-format-attribute \
-Wmissing-include-dirs -Wpacked -Wredundant-decls \
-Wswitch-default -Wswitch-enum -Wuninitialized -Wunused-parameter -Wvariadic-macros \
-Wlogical-op -Wnoexcept \
-Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -gdwarf-3
}else{
# Release
TARGET = $$RELEASE_TARGET
QMAKE_CXXFLAGS += -O1
DEFINES += QT_NO_DEBUG_OUTPUT
QMAKE_EXTRA_COMPILERS += lrelease
lrelease.input = TRANSLATIONS
lrelease.output = ${QMAKE_FILE_BASE}.qm
lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${DESTDIR}${QMAKE_FILE_BASE}.qm
lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm "bin/"${QMAKE_FILE_BASE}.qm
lrelease.CONFIG += no_link target_predeps
}
@ -263,5 +113,3 @@ message(Data files: $$[QT_INSTALL_DATA])
message(Translation files: $$[QT_INSTALL_TRANSLATIONS])
message(Settings: $$[QT_INSTALL_SETTINGS])
message(Examples: $$[QT_INSTALL_EXAMPLES])

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file calculator.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "calculator.h"
#include <QDebug>
@ -31,11 +38,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();
@ -49,10 +53,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;
}
@ -61,69 +67,86 @@ qreal Calculator::get_exp(){
return result;
}
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);
}
}
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);
@ -141,10 +164,12 @@ void Calculator::primitive(qreal *result){
}
}
void Calculator::arith(QChar o, qreal *r, qreal *h){
qreal t;
void Calculator::arith(QChar o, qreal *r, qreal *h)
{
qreal t;//, ex;
switch(o.toLatin1()) {
switch (o.toLatin1())
{
case '-':
*r = *r-*h;
break;
@ -163,19 +188,26 @@ void Calculator::arith(QChar o, qreal *r, qreal *h){
break;
case '^':
*r = pow(*r, *h);
break;
}
break;
default:
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); /* don't variable */
return 0;
@ -183,20 +215,23 @@ qreal Calculator::find_var(QString s){
return value;
}
void Calculator::serror(qint32 error){
QString e[]= {
tr("Syntax error"),
tr("Parentheses do not match"),
tr("This is not an expression"),
tr("It is assumed the equality symbol"),
tr("Do not variable")
};
void Calculator::serror(qint32 error)
{
QString e[]=
{
"Синтаксическая ошибка",
"Непарные круглые скобки",
"Это не выражение",
"Предполагается символ равенства",
"Не переменная"
};
errorMsg->clear();
*errorMsg = e[error];
qDebug()<<e[error];
}
char Calculator::look_up(QString s){
char Calculator::look_up(QString s)
{
QString p;
p = s;
@ -205,36 +240,50 @@ char Calculator::look_up(QString s){
return 0;
}
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;
}
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') { /* end of file */
if (prog[index]=='\0')
{ /* end of file */
token="\0";
tok=FINISHED;
token_type=DELIMITER;
return;
}
while(iswhite(prog[index])) ++index; /* skip spaces */
while (iswhite(prog[index]))
{
++index; /* skip spaces */
}
if(prog[index]=='\r') { /* crtl */
if (prog[index]=='\r')
{ /* crtl */
++index; ++index;
tok= EOL; token='\r';
token.append('\n');token.append("\0");
@ -242,7 +291,8 @@ void Calculator::get_token(){
return;
}
if(StrChr("+-*^/%=;(),><", prog[index])) { /* delimiter */
if (StrChr("+-*^/%=;(),><", prog[index]))
{ /* delimiter */
*temp=prog[index];
index++; /* jump to the next position */
temp->append("\0");
@ -250,20 +300,26 @@ void Calculator::get_token(){
debugFormula.append(token);
return;
}
if(prog[index]=='"') { /* quoted string */
if (prog[index]=='"')
{ /* quoted string */
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()) { /* number */
while(!isdelim(prog[index])){
if (prog[index].isDigit())
{ /* number */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]);
index++;
}
@ -272,8 +328,10 @@ void Calculator::get_token(){
return;
}
if(prog[index].isPrint()) { /* variable or command */
while(!isdelim(prog[index])){
if (prog[index].isPrint())
{ /* variable or command */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]);
index++;
}
@ -282,20 +340,28 @@ void Calculator::get_token(){
temp->append("\0");
/* Seen if there is a command line or a variable */
if(token_type==STRING) {
if (token_type==STRING)
{
tok=look_up(token);
if(!tok)
if (tok == false)
{
token_type = VARIABLE;
else token_type = COMMAND; /* It is command */
}
}
else
{
token_type = COMMAND; /* It is 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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file calculator.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,57 +24,58 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef CALCULATOR_H
#define CALCULATOR_H
#include <QString>
#include "vcontainer.h"
/**
* @brief The Calculator class calculate formulas of pattern. Support operation +,-,/,* and braces.
* Can replace name of variables her value.
*/
class Calculator{
class Calculator
{
public:
/**
* @brief Calculator class constructor.
* @param data pointer to a variable container.
*/
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 calculate formula.
* @param prog string of formula.
* @return value of formula.
*/
qreal eval(QString prog, QString *errorMsg);
qreal eval(QString prog, QString *errorMsg);
private:
Q_DISABLE_COPY(Calculator)
/**
* @brief errorMsg keeps error message of calculation.
*/
QString *errorMsg;
QString *errorMsg;
/**
* @brief token current token.
* @brief token теперішня лексема.
*/
QString token;
QString token;
/**
* @brief tok internal representation of token.
*/
qint32 tok;
qint32 tok;
/**
* @brief token_type type of token.
*/
qint32 token_type;
qint32 token_type;
/**
* @brief prog string where keeps formula.
*/
QString prog;
QString prog;
/**
* @brief index number character in string of formula.
*/
qint32 index;
qint32 index;
/**
* @brief data container of all variables.
*/
@ -75,99 +83,104 @@ private:
/**
* @brief debugFormula decoded string of formula.
*/
QString debugFormula;
QString debugFormula;
/**
* @brief get_exp calculate formula.
* @return value of formula.
*/
qreal get_exp();
qreal get_exp();
/**
* @brief get_token return next token.
*/
void get_token();
void get_token();
/**
* @brief StrChr checks whether the character belongs to the line.
* @param string string with formula
* @param c character.
* @return true - belongs to the line, false - don't belongs to the line.
*/
static bool StrChr(QString string, QChar c);
static bool StrChr(QString string, QChar c);
/**
* @brief putback returns the readout token back into the flow.
*/
void putback();
void putback();
/**
* @brief level2 method of addition and subtraction of two terms.
* @param result result of operation.
*/
void level2(qreal *result);
void level2(qreal *result);
/**
* @brief level3 method of multiplication, division, finding percent.
* @param result result of operation.
*/
void level3(qreal *result);
void level3(qreal *result);
/**
* @brief level4 method of degree two numbers.
* @param result result of operation.
*/
void level4(qreal *result);
void level4(qreal *result);
/**
* @brief level5 method for finding unary plus or minus.
* @param result result of operation.
*/
void level5(qreal *result);
void level5(qreal *result);
/**
* @brief level6 processing method of the expression in brackets.
* @param result result of operation.
*/
void level6(qreal *result);
void level6(qreal *result);
/**
* @brief primitive method of determining the value of a variable by its name.
* @param result result of operation.
*/
void primitive(qreal *result);
void primitive(qreal *result);
/**
* @brief arith perform the specified arithmetic. The result is written to the first element.
* @param o sign operation.
* @param o sign of operation.
* @param r first element.
* @param h second element.
*/
static void arith(QChar o, qreal *r, qreal *h);
static void arith(QChar o, qreal *r, qreal *h);
/**
* @brief unary method changes the sign.
* @param o sign of symbol.
* @param r element.
*/
static void unary(QChar o, qreal *r);
static void unary(QChar o, qreal *r);
/**
* @brief find_var method is finding variable by name.
* @param s name of variable.
* @return value of variable.
*/
qreal find_var(QString s);
qreal find_var(QString s);
/**
* @brief serror report an error
* @param error error code
*/
void serror(qint32 error);
void serror(qint32 error);
/**
* @brief look_up Finding the internal format for the current token in the token table.
* @brief look_up finding the internal format for the current token in the token table.
* @param s name of token.
* @return internal number of token.
*/
static char look_up(QString s);
static char look_up(QString s);
/**
* @brief isdelim return true if c delimiter.
* @param c character.
* @return true - delimiter, false - do not delimiter.
*/
static bool isdelim(QChar c);
static bool isdelim(QChar c);
/**
* @brief isdelim return true if c delimiter.
* @param c character.
* @return true - delimiter, false - do not delimiter.
*/
static bool iswhite(QChar c);
/**
* @brief iswhite checks whether c space or tab.
* @param c character.
* @return true - space or tab, false - don't space and don't tab.
*/
static bool iswhite(QChar c);
};
#endif // CALCULATOR_H

13
container/container.pri Normal file
View File

@ -0,0 +1,13 @@
SOURCES += \
container/vpointf.cpp \
container/vincrementtablerow.cpp \
container/vcontainer.cpp \
container/calculator.cpp \
container/vstandarttablecell.cpp
HEADERS += \
container/vstandarttablecell.h \
container/vpointf.h \
container/vincrementtablerow.h \
container/vcontainer.h \
container/calculator.h

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vcontainer.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,194 +24,179 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VCONTAINER_H
#define VCONTAINER_H
#include <QTableWidget>
#include "vstandarttablecell.h"
#include "vincrementtablerow.h"
#include "geometry/varc.h"
#include "geometry/vsplinepath.h"
#include "geometry/vdetail.h"
#include "widgets/vitem.h"
#include <QCoreApplication>
#include "../geometry/varc.h"
#include "../geometry/vsplinepath.h"
#include "../geometry/vdetail.h"
#include "../widgets/vitem.h"
/**
* @brief The VContainer class container of all variables.
*/
class VContainer{
class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer)
public:
/**
* @brief VContainer create empty container
*/
VContainer();
/**
* @brief operator = copy constructor
* @param data container
* @return copy container
*/
VContainer &operator=(const VContainer &data);
/**
* @brief VContainer create container from another container
* @param data container
*/
VContainer(const VContainer &data);
/**
* @brief VContainer create empty container
*/
VContainer();
/**
* @brief operator = copy constructor
* @param data container
* @return copy container
*/
VContainer &operator=(const VContainer &data);
/**
* @brief VContainer create container from another container
* @param data container
*/
VContainer(const VContainer &data);
/**
* @brief setData copy data from container
* @param data container
*/
void setData(const VContainer &data);
void setData(const VContainer &data);
/**
* @brief GetPoint returns a point by id
* @param id id of point
* @return point
*/
VPointF GetPoint(qint64 id) const;
VPointF GetPoint(qint64 id) const;
/**
* @brief GetModelingPoint return a modeling point by id
* @param id id of modeling point
* @return modeling point
*/
VPointF GetModelingPoint(qint64 id) const;
VPointF GetModelingPoint(qint64 id) const;
/**
* @brief GetStandartTableCell
* @param name
* @return
*/
VStandartTableCell GetStandartTableCell(const QString& name) const;
VIncrementTableRow GetIncrementTableRow(const QString& name) const;
qreal GetLine(const QString &name) const;
qreal GetLineArc(const QString &name) const;
VSpline GetSpline(qint64 id) const;
VSpline GetModelingSpline(qint64 id) const;
VArc GetArc(qint64 id) const;
VArc GetModelingArc(qint64 id) const;
VSplinePath GetSplinePath(qint64 id) const;
VSplinePath GetModelingSplinePath(qint64 id) const;
VDetail GetDetail(qint64 id) const;
static qint64 getId();
qint64 AddPoint(const VPointF& point);
qint64 AddModelingPoint(const VPointF& point);
qint64 AddDetail(const VDetail& detail);
void AddStandartTableCell(const QString& name,
const VStandartTableCell& cell);
void AddIncrementTableRow(const QString& name,
const VIncrementTableRow &cell);
void AddLengthLine(const QString &name, const qreal &value);
void AddLengthSpline(const qint64 &firstPointId,
const qint64 &secondPointId,
Draw::Draws mode = Draw::Calculation);
void AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 &center, const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value);
void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
Draw::Draws mode = Draw::Calculation);
qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath);
qint64 AddModelingSplinePath(const VSplinePath& splPath);
qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint,
const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameSplinePath(const VSplinePath &path,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameArc(const qint64 &center, const qint64 &id,
Draw::Draws mode = Draw::Calculation) const;
void UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail);
void UpdateSpline(qint64 id, const VSpline& spl);
void UpdateModelingSpline(qint64 id, const VSpline& spl);
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateArc(qint64 id, const VArc& arc);
void UpdateModelingArc(qint64 id, const VArc& arc);
void UpdateStandartTableCell(const QString& name,
const VStandartTableCell& cell);
void UpdateIncrementTableRow(const QString& name,
const VIncrementTableRow& cell);
qreal GetValueStandartTableCell(const QString& name) const;
qreal GetValueIncrementTableRow(const QString& name) const;
void Clear();
void ClearObject();
void ClearIncrementTable();
void ClearLengthLines();
void ClearLengthSplines();
void ClearLengthArcs();
void ClearLineAngles();
void SetSize(qint32 size);
void SetGrowth(qint32 growth);
qint32 size() const;
qint32 growth() const;
qreal FindVar(const QString& name, bool *ok)const;
bool IncrementTableContains(const QString& name);
static qint64 getNextId();
void RemoveIncrementTableRow(const QString& name);
const QHash<qint64, VPointF> *DataPoints() const;
const QHash<qint64, VPointF> *DataModelingPoints() const;
const QHash<qint64, VSpline> *DataSplines() const;
const QHash<qint64, VSpline> *DataModelingSplines() const;
const QHash<qint64, VArc> *DataArcs() const;
const QHash<qint64, VArc> *DataModelingArcs() const;
const QHash<QString, qint32> *DataBase() const;
const QHash<QString, VStandartTableCell> *DataStandartTable() const;
const QHash<QString, VIncrementTableRow> *DataIncrementTable() const;
const QHash<QString, qreal> *DataLengthLines() const;
const QHash<QString, qreal> *DataLengthSplines() const;
const QHash<QString, qreal> *DataLengthArcs() const;
const QHash<QString, qreal> *DataLineAngles() const;
const QHash<qint64, VSplinePath> *DataSplinePaths() const;
const QHash<qint64, VSplinePath> *DataModelingSplinePaths() const;
const QHash<qint64, VDetail> *DataDetails() const;
static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector<QPointF> points,
const Detail::Equidistant &eqv,
const qreal &width)const;
static QLineF ParallelLine(const QLineF &line, qreal width );
static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle,
const qreal &width);
QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2,
const qreal &width)const;
QVector<QPointF> CheckLoops(const QVector<QPointF> &points) const;
void PrepareDetails(QVector<VItem*> & list)const;
VStandartTableCell GetStandartTableCell(const QString& name) const;
VIncrementTableRow GetIncrementTableRow(const QString& name) const;
qreal GetLine(const QString &name) const;
qreal GetLengthArc(const QString &name) const;
qreal GetLengthSpline(const QString &name) const;
qreal GetLineAngle(const QString &name) const;
VSpline GetSpline(qint64 id) const;
VSpline GetModelingSpline(qint64 id) const;
VArc GetArc(qint64 id) const;
VArc GetModelingArc(qint64 id) const;
VSplinePath GetSplinePath(qint64 id) const;
VSplinePath GetModelingSplinePath(qint64 id) const;
VDetail GetDetail(qint64 id) const;
static qint64 getId() {return _id;}
qint64 AddPoint(const VPointF& point);
qint64 AddModelingPoint(const VPointF& point);
qint64 AddDetail(const VDetail& detail);
inline void AddStandartTableCell(const QString& name, const VStandartTableCell& cell)
{standartTable[name] = cell;}
inline void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell)
{incrementTable[name] = cell;}
void AddLengthLine(const QString &name, const qreal &value);
void AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value);
void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
const Draw::Draws &mode = Draw::Calculation);
qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath);
qint64 AddModelingSplinePath(const VSplinePath& splPath);
qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
const Draw::Draws &mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
const Draw::Draws &mode = Draw::Calculation) const;
void UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail);
void UpdateSpline(qint64 id, const VSpline& spl);
void UpdateModelingSpline(qint64 id, const VSpline& spl);
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateArc(qint64 id, const VArc& arc);
void UpdateModelingArc(qint64 id, const VArc& arc);
inline void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell)
{standartTable[name] = cell;}
inline void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell)
{incrementTable[name] = cell;}
qreal GetValueStandartTableCell(const QString& name) const;
qreal GetValueIncrementTableRow(const QString& name) const;
void Clear();
void ClearObject();
inline void ClearIncrementTable() {incrementTable.clear();}
inline void ClearLengthLines() {lengthLines.clear();}
inline void ClearLengthSplines() {lengthSplines.clear();}
inline void ClearLengthArcs() {lengthArcs.clear();}
inline void ClearLineAngles() {lineAngles.clear();}
inline void SetSize(qint32 size) {base["Сг"] = size;}
inline void SetGrowth(qint32 growth) {base["Р"] = growth;}
inline qint32 size() const {return base.value("Сг");}
inline qint32 growth() const {return base.value("Р");}
qreal FindVar(const QString& name, bool *ok)const;
inline bool IncrementTableContains(const QString& name) {return incrementTable.contains(name);}
static qint64 getNextId();
inline void RemoveIncrementTableRow(const QString& name) {incrementTable.remove(name);}
inline const QHash<qint64, VPointF> *DataPoints() const {return &points;}
inline const QHash<qint64, VPointF> *DataModelingPoints() const {return &modelingPoints;}
inline const QHash<qint64, VSpline> *DataSplines() const {return &splines;}
inline const QHash<qint64, VSpline> *DataModelingSplines() const {return &modelingSplines;}
inline const QHash<qint64, VArc> *DataArcs() const {return &arcs;}
inline const QHash<qint64, VArc> *DataModelingArcs() const {return &modelingArcs;}
inline const QHash<QString, qint32> *DataBase() const {return &base;}
inline const QHash<QString, VStandartTableCell> *DataStandartTable() const {return &standartTable;}
inline const QHash<QString, VIncrementTableRow> *DataIncrementTable() const {return &incrementTable;}
inline const QHash<QString, qreal> *DataLengthLines() const {return &lengthLines;}
inline const QHash<QString, qreal> *DataLengthSplines() const {return &lengthSplines;}
inline const QHash<QString, qreal> *DataLengthArcs() const {return &lengthArcs;}
inline const QHash<QString, qreal> *DataLineAngles() const {return &lineAngles;}
inline const QHash<qint64, VSplinePath> *DataSplinePaths() const {return &splinePaths;}
inline const QHash<qint64, VSplinePath> *DataModelingSplinePaths() const {return &modelingSplinePaths;}
inline const QHash<qint64, VDetail> *DataDetails() const {return &details;}
static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const;
QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const;
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width)const;
static QLineF ParallelLine(const QLineF &line, qreal width );
static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width);
QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const;
QVector<QPointF> CheckLoops(const QVector<QPointF> &points) const;
void PrepareDetails(QVector<VItem *> & list) const;
private:
static qint64 _id;
QHash<QString, qint32> base;
QHash<qint64, VPointF> points;
QHash<qint64, VPointF> modelingPoints;
static qint64 _id;
QHash<QString, qint32> base;
QHash<qint64, VPointF> points;
QHash<qint64, VPointF> modelingPoints;
QHash<QString, VStandartTableCell> standartTable;
QHash<QString, VIncrementTableRow> incrementTable;
QHash<QString, qreal> lengthLines;
QHash<QString, qreal> lineAngles;
QHash<qint64, VSpline> splines;
QHash<qint64, VSpline> modelingSplines;
QHash<QString, qreal> lengthSplines;
QHash<qint64, VArc> arcs;
QHash<qint64, VArc> modelingArcs;
QHash<QString, qreal> lengthArcs;
QHash<qint64, VSplinePath> splinePaths;
QHash<qint64, VSplinePath> modelingSplinePaths;
QHash<qint64, VDetail> details;
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);
void CreateManTableIGroup ();
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
qreal GetLengthContour(const QVector<QPointF> &contour,
const QVector<QPointF> &newPoints)const;
QHash<QString, qreal> lengthLines;
QHash<QString, qreal> lineAngles;
QHash<qint64, VSpline> splines;
QHash<qint64, VSpline> modelingSplines;
QHash<QString, qreal> lengthSplines;
QHash<qint64, VArc> arcs;
QHash<qint64, VArc> modelingArcs;
QHash<QString, qreal> lengthArcs;
QHash<qint64, VSplinePath> splinePaths;
QHash<qint64, VSplinePath> modelingSplinePaths;
QHash<qint64, VDetail> details;
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 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);
};
#endif // VCONTAINER_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vincrementtablerow.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,54 +24,12 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vincrementtablerow.h"
VIncrementTableRow::VIncrementTableRow():id(0), base(0), ksize(0), kgrowth(0), description(QString()){
}
VIncrementTableRow::VIncrementTableRow()
:id(0), base(0), ksize(0), kgrowth(0), description(QString()){}
VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,
QString description):id(id), base(base), ksize(ksize),
kgrowth(kgrowth), description(description){
}
QString VIncrementTableRow::getDescription() const{
return description;
}
void VIncrementTableRow::setDescription(const QString &value){
description = value;
}
qreal VIncrementTableRow::getKgrowth() const{
return kgrowth;
}
void VIncrementTableRow::setKgrowth(const qreal &value){
kgrowth = value;
}
qreal VIncrementTableRow::getKsize() const{
return ksize;
}
void VIncrementTableRow::setKsize(const qreal &value){
ksize = value;
}
qreal VIncrementTableRow::getBase() const{
return base;
}
void VIncrementTableRow::setBase(const qreal &value){
base = value;
}
qint64 VIncrementTableRow::getId() const{
return id;
}
void VIncrementTableRow::setId(const qint64 &value){
id = value;
}
VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, QString description)
:id(id), base(base), ksize(ksize), kgrowth(kgrowth), description(description){}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vincrementtablerow.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,40 +24,33 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VINCREMENTTABLEROW_H
#define VINCREMENTTABLEROW_H
#include <QString>
class VIncrementTableRow
{
public:
VIncrementTableRow();
VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,
QString description = QString());
qint64 getId() const;
void setId(const qint64 &value);
qreal getBase() const;
void setBase(const qreal &value);
qreal getKsize() const;
void setKsize(const qreal &value);
qreal getKgrowth() const;
void setKgrowth(const qreal &value);
QString getDescription() const;
void setDescription(const QString &value);
VIncrementTableRow();
VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,
QString description = QString());
inline qint64 getId() const {return id;}
inline void setId(const qint64 &value) {id = value;}
inline qreal getBase() const {return base;}
inline void setBase(const qreal &value) {base = value;}
inline qreal getKsize() const {return ksize;}
inline void setKsize(const qreal &value) {ksize = value;}
inline qreal getKgrowth() const {return kgrowth;}
inline void setKgrowth(const qreal &value) {kgrowth = value;}
inline QString getDescription() const {return description;}
inline void setDescription(const QString &value) {description = value;}
private:
qint64 id;
qreal base;
qreal ksize;
qreal kgrowth;
QString description;
qint64 id;
qreal base;
qreal ksize;
qreal kgrowth;
QString description;
};
#endif // VINCREMENTTABLEROW_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vpointf.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,11 +24,12 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vpointf.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,16 +24,13 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VPOINTF_H
#define VPOINTF_H
#include <QPointF>
#include <QString>
#include "options.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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vstandarttablecell.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,29 +24,12 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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){
}
qint32 VStandartTableCell::GetBase() const{
return base;
}
qreal VStandartTableCell::GetKsize() const{
return ksize;
}
qreal VStandartTableCell::GetKgrowth() const{
return kgrowth;
}
QString VStandartTableCell::GetDescription() const{
return description;
}
VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description)
:base(base), ksize(ksize), kgrowth(kgrowth), description(description){}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vstandarttablecell.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,27 +24,25 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VSTANDARTTABLECELL_H
#define VSTANDARTTABLECELL_H
#include <QString>
class VStandartTableCell
{
public:
VStandartTableCell();
VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString());
qint32 GetBase() const;
qreal GetKsize() const;
qreal GetKgrowth() const;
QString GetDescription() const;
VStandartTableCell();
VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString());
inline qint32 GetBase() const {return base;}
inline qreal GetKsize() const {return ksize;}
inline qreal GetKgrowth() const {return kgrowth;}
inline QString GetDescription() const {return description;}
private:
qint32 base;
qreal ksize;
qreal kgrowth;
QString description;
qint32 base;
qreal ksize;
qreal kgrowth;
QString description;
};
#endif // VSTANDARTTABLECELL_H

View File

@ -12,5 +12,8 @@
<file>cursor/splinepath_cursor.png</file>
<file>cursor/pointcontact_cursor.png</file>
<file>cursor/new_detail_cursor.png</file>
<file>cursor/height_cursor.png</file>
<file>cursor/triangle_cursor.png</file>
<file>cursor/pointofintersect_cursor.png</file>
</qresource>
</RCC>

BIN
cursor/height_cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
cursor/triangle_cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogalongline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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;
@ -33,6 +41,8 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
@ -44,6 +54,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType);
ui->comboBoxLineType->setCurrentIndex(1);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
@ -56,58 +67,76 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogAlongLine::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogAlongLine::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogAlongLine::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogAlongLine::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogAlongLine::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogAlongLine::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged);
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, const 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();
@ -116,45 +145,30 @@ void DialogAlongLine::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogAlongLine::getSecondPointId() const{
return secondPointId;
}
void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id){
void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
}
qint64 DialogAlongLine::getFirstPointId() const{
return firstPointId;
}
void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id){
void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
QString DialogAlongLine::getFormula() const{
return formula;
}
void DialogAlongLine::setFormula(const QString &value){
void DialogAlongLine::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
QString DialogAlongLine::getTypeLine() const{
return typeLine;
}
void DialogAlongLine::setTypeLine(const QString &value){
void DialogAlongLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogAlongLine::getPointName() const{
return pointName;
}
void DialogAlongLine::setPointName(const QString &value){
void DialogAlongLine::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogalongline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,37 +24,37 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGALONGLINE_H
#define DIALOGALONGLINE_H
#include "dialogtool.h"
#include "container/calculator.h"
namespace Ui {
class DialogAlongLine;
namespace Ui
{
class DialogAlongLine;
}
class DialogAlongLine : public DialogTool
{
Q_OBJECT
Q_OBJECT
public:
explicit DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogAlongLine();
QString getPointName() const;
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
QString getTypeLine() const;
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
QString getFormula() const;
inline QString getFormula() const {return formula;}
void setFormula(const QString &value);
qint64 getFirstPointId() const;
inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id);
qint64 getSecondPointId() const;
inline qint64 getSecondPointId() const {return secondPointId;}
void setSecondPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogAlongLine)

View File

@ -302,7 +302,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
@ -312,7 +312,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogarc.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogarc.h"
#include "ui_dialogarc.h"
#include "../container/calculator.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);
@ -52,6 +59,8 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius);
connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1);
@ -63,7 +72,9 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines);
connect(ui->radioButtonLineAngles, &QRadioButton::clicked, this, &DialogArc::LineArcs);
connect(ui->radioButtonLineAngles, &QRadioButton::clicked, this, &DialogArc::LineAngles);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogArc::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogArc::LengthCurves);
connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius);
connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1);
@ -74,63 +85,61 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed);
}
qint64 DialogArc::GetCenter() const{
return center;
DialogArc::~DialogArc()
{
delete ui;
}
void DialogArc::SetCenter(const qint64 &value){
void DialogArc::SetCenter(const qint64 &value)
{
center = value;
ChangeCurrentData(ui->comboBoxBasePoint, center);
}
QString DialogArc::GetF2() const{
return f2;
}
void DialogArc::SetF2(const QString &value){
void DialogArc::SetF2(const QString &value)
{
f2 = value;
ui->lineEditF2->setText(f2);
}
QString DialogArc::GetF1() const{
return f1;
}
void DialogArc::SetF1(const QString &value){
void DialogArc::SetF1(const QString &value)
{
f1 = value;
ui->lineEditF1->setText(f1);
}
QString DialogArc::GetRadius() const{
return radius;
}
void DialogArc::SetRadius(const QString &value){
void DialogArc::SetRadius(const QString &value)
{
radius = value;
ui->lineEditRadius->setText(radius);
}
DialogArc::~DialogArc(){
delete ui;
}
void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){
void DialogArc::ChoosedObject(qint64 id, const 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());
@ -139,7 +148,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();
@ -147,13 +157,16 @@ 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()){
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text()))
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);
return;
@ -161,61 +174,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::LineArcs(){
ShowLineArcs();
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(){
Q_CHECK_PTR(bOk);
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::ShowLineArcs(){
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> *lineArcsTable = data->DataLineAngles();
QHashIterator<QString, qreal> i(*lineArcsTable);
while (i.hasNext()) {
const QHash<QString, qreal> *lineAnglesTable = data->DataLineAngles();
Q_ASSERT(lineAnglesTable != 0);
QHashIterator<QString, qreal> i(*lineAnglesTable);
while (i.hasNext())
{
i.next();
QListWidgetItem *item = new QListWidgetItem(i.key());

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogarc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,43 +24,40 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGARC_H
#define DIALOGARC_H
#include "dialogtool.h"
namespace Ui {
class DialogArc;
namespace Ui
{
class DialogArc;
}
class DialogArc : public DialogTool
{
Q_OBJECT
public:
explicit DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogArc();
qint64 GetCenter() const;
void SetCenter(const qint64 &value);
QString GetRadius() const;
void SetRadius(const QString &value);
QString GetF1() const;
void SetF1(const QString &value);
QString GetF2() const;
void SetF2(const QString &value);
DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogArc();
inline qint64 GetCenter() const {return center;}
void SetCenter(const qint64 &value);
inline QString GetRadius() const {return radius;}
void SetRadius(const QString &value);
inline QString GetF1() const {return f1;}
void SetF1(const QString &value);
inline QString GetF2() const {return f2;}
void SetF2(const QString &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
virtual void ValChenged(int row);
void PutRadius();
void PutF1();
void PutF2();
void LineArcs();
void LineAngles();
void RadiusChanged();
void F1Changed();
void F2Changed();
@ -75,7 +79,7 @@ private:
void EvalRadius();
void EvalF1();
void EvalF2();
void ShowLineArcs();
void ShowLineAngles();
};
#endif // DIALOGARC_H

View File

@ -495,7 +495,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
<string>Length of curves</string>
</property>
</widget>
</item>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogbisector.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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;
@ -33,6 +41,8 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
@ -57,118 +67,120 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogBisector::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogBisector::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogBisector::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogBisector::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogBisector::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogBisector::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged);
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, const 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();
}
}
}
}
QString DialogBisector::getPointName() const{
return pointName;
}
void DialogBisector::setPointName(const QString &value){
void DialogBisector::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
QString DialogBisector::getTypeLine() const{
return typeLine;
}
void DialogBisector::setTypeLine(const QString &value){
void DialogBisector::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogBisector::getFormula() const{
return formula;
}
void DialogBisector::setFormula(const QString &value){
void DialogBisector::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
qint64 DialogBisector::getFirstPointId() const{
return firstPointId;
}
void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id){
void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
qint64 DialogBisector::getSecondPointId() const{
return secondPointId;
}
void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id){
void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
}
qint64 DialogBisector::getThirdPointId() const{
return thirdPointId;
}
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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogbisector.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,41 +24,39 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGBISECTOR_H
#define DIALOGBISECTOR_H
#include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui {
class DialogBisector;
namespace Ui
{
class DialogBisector;
}
class DialogBisector : public DialogTool
{
Q_OBJECT
public:
explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogBisector();
QString getPointName() const;
~DialogBisector();
QString getPointName() const {return pointName;}
void setPointName(const QString &value);
QString getTypeLine() const;
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
QString getFormula() const;
inline QString getFormula() const {return formula;}
void setFormula(const QString &value);
qint64 getFirstPointId() const;
inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id);
qint64 getSecondPointId() const;
inline qint64 getSecondPointId() const {return secondPointId;}
void setSecondPointId(const qint64 &value, const qint64 &id);
qint64 getThirdPointId() const;
inline qint64 getThirdPointId() const {return thirdPointId;}
void setThirdPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogBisector)

View File

@ -344,7 +344,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
@ -354,7 +354,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogdetail.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,132 +24,228 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogdetail.h"
#include <QDebug>
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(), details(VDetail()){
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);
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
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, const 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)));
}
details.setWidth(ui.doubleSpinBoxSeams->value());
details.setName(ui.lineEditNameDetail->text());
details.setSupplement(supplement);
details.setClosed(closed);
emit ToolTip("");
emit DialogClosed(QDialog::Accepted);
}
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){
void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::Draws &mode,
const 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 = arc.name();
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 = splPath.name();
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);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, mode, typeNode);
VNodeDetail node(id, typeTool, mode, typeNode, mx, my);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
disconnect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
disconnect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy()));
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
}
VDetail DialogDetail::getDetails() const{
return details;
}
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());
for (ptrdiff_t 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());
}
details.setName(ui.lineEditNameDetail->text());
ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement());
ui.checkBoxClosed->setChecked(details.getClosed());
ui.doubleSpinBoxSeams->setValue(details.getWidth());
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus(Qt::OtherFocusReason);
}
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));
node.setMx(toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
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));
node.setMy(toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
void DialogDetail::ClickedSeams(bool checked)
{
supplement = checked;
ui.checkBoxClosed->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked);
}
void DialogDetail::ClickedClosed(bool checked)
{
closed = checked;
}
void DialogDetail::ObjectChanged(int row)
{
if (ui.listWidget->count() == 0)
{
return;
}
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy()));
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogdetail.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,29 +24,36 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGDETAIL_H
#define DIALOGDETAIL_H
#include "ui_dialogdetail.h"
#include "dialogtool.h"
#include "geometry/vdetail.h"
class DialogDetail : public DialogTool{
Q_OBJECT
class DialogDetail : public DialogTool
{
Q_OBJECT
public:
explicit DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
VDetail getDetails() const;
void setDetails(const VDetail &value);
DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
inline VDetail getDetails() const {return details;}
void setDetails(const VDetail &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
void BiasXChanged(qreal d);
void BiasYChanged(qreal d);
void ClickedSeams(bool checked);
void ClickedClosed(bool checked);
void ObjectChanged(int row);
private:
Ui::DialogDetail ui;
VDetail details;
void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
VDetail details;
bool supplement;
bool closed;
void NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::Draws &mode,
const NodeDetail::NodeDetails &typeNode, qreal mx = 0, qreal my = 0);
};
#endif // DIALOGDETAIL_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>298</height>
<width>544</width>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
@ -20,47 +20,196 @@
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelEditNameDetail">
<widget class="QLabel" name="label">
<property name="text">
<string>Bias X</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasX">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name detail</string>
<string>Bias Y</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail"/>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasY">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Option</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name of detail</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
<string>Supplement for seams</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
@ -83,7 +232,6 @@
</widget>
<tabstops>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogendline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,18 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogendline.h"
#include "ui_dialogendline.h"
#include <QCloseEvent>
#include <QString>
#include "container/vpointf.h"
#include "container/calculator.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;
@ -38,6 +42,8 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
@ -76,28 +82,39 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogEndLine::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEndLine::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEndLine::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogEndLine::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEndLine::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEndLine::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged);
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, const 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,51 +123,37 @@ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){
}
}
QString DialogEndLine::getPointName() const{
return pointName;
}
void DialogEndLine::setPointName(const QString &value){
void DialogEndLine::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
QString DialogEndLine::getTypeLine() const{
return typeLine;
}
void DialogEndLine::setTypeLine(const QString &value){
void DialogEndLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogEndLine::getFormula() const{
return formula;
}
void DialogEndLine::setFormula(const QString &value){
void DialogEndLine::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
qreal DialogEndLine::getAngle() const{
return angle;
}
void DialogEndLine::setAngle(const qreal &value){
void DialogEndLine::setAngle(const qreal &value)
{
angle = value;
ui->doubleSpinBoxAngle->setValue(angle);
}
qint64 DialogEndLine::getBasePointId() const{
return basePointId;
}
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();

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogendline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,38 +24,36 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGENDLINE_H
#define DIALOGENDLINE_H
#include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui {
class DialogEndLine;
namespace Ui
{
class DialogEndLine;
}
class DialogEndLine : public DialogTool
{
Q_OBJECT
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();
QString getPointName() const;
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
QString getTypeLine() const;
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
QString getFormula() const;
inline QString getFormula() const {return formula;}
void setFormula(const QString &value);
qreal getAngle() const;
inline qreal getAngle() const {return angle;}
void setAngle(const qreal &value);
qint64 getBasePointId() const;
inline qint64 getBasePointId() const {return basePointId;}
void setBasePointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogEndLine)

View File

@ -500,7 +500,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
@ -510,7 +510,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

149
dialogs/dialogheight.cpp Normal file
View File

@ -0,0 +1,149 @@
/************************************************************************
**
** @file dialogheight.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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)
{
ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogHeight::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected);
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
}
DialogHeight::~DialogHeight()
{
delete ui;
}
void DialogHeight::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
void DialogHeight::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
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)
{
p1LineId = value;
setCurrentPointId(ui->comboBoxP1Line, p1LineId, value, id);
}
void DialogHeight::setP2LineId(const qint64 &value, const qint64 &id)
{
p2LineId = value;
setCurrentPointId(ui->comboBoxP2Line, p2LineId, value, id);
}
void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
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 == false)
{
this->show();
}
break;
default:
break;
}
}
}
void DialogHeight::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
basePointId = getCurrentPointId(ui->comboBoxBasePoint);
p1LineId = getCurrentPointId(ui->comboBoxP1Line);
p2LineId = getCurrentPointId(ui->comboBoxP2Line);
emit DialogClosed(QDialog::Accepted);
}

70
dialogs/dialogheight.h Normal file
View File

@ -0,0 +1,70 @@
/************************************************************************
**
** @file dialogheight.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGHEIGHT_H
#define DIALOGHEIGHT_H
#include "dialogtool.h"
namespace Ui
{
class DialogHeight;
}
class DialogHeight : public DialogTool
{
Q_OBJECT
public:
DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogHeight();
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
inline qint64 getBasePointId() const {return basePointId;}
void setBasePointId(const qint64 &value, const qint64 &id);
inline qint64 getP1LineId() const {return p1LineId;}
void setP1LineId(const qint64 &value, const qint64 &id);
inline qint64 getP2LineId() const{return p2LineId;}
void setP2LineId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogHeight)
Ui::DialogHeight *ui;
qint32 number;
QString pointName;
QString typeLine;
qint64 basePointId;
qint64 p1LineId;
qint64 p2LineId;
};
#endif // DIALOGHEIGHT_H

214
dialogs/dialogheight.ui Normal file
View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogHeight</class>
<widget class="QDialog" name="DialogHeight">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>247</width>
<height>220</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Base point</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxBasePoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>First point of line</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxP1Line">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Second point of line</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxP2Line">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Type line</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxLineType">
<property name="toolTip">
<string>Show line from first point to our point</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogHeight</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogHeight</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialoghistory.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,18 +24,19 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialoghistory.h"
#include "ui_dialoghistory.h"
#include "geometry/varc.h"
#include "geometry/vspline.h"
#include "geometry/vsplinepath.h"
#include "../geometry/varc.h"
#include "../geometry/vspline.h"
#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 +50,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 +77,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 +91,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 +107,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 +142,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 +153,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 +166,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 +175,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 +184,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 +194,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 +208,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 +219,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 +232,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,43 +243,81 @@ 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:
{
qint64 p1LineId = 0;
qint64 p2LineId = 0;
domElement = doc->elementById(QString().setNum(tool.getId()));
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());
break;
}
case Tool::Triangle:
{
qint64 axisP1Id = 0;
qint64 axisP2Id = 0;
domElement = doc->elementById(QString().setNum(tool.getId()));
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(firstPointId).name(), data->GetPoint(secondPointId).name());
break;
}
default:
qWarning()<<tr("Get wrong tool type. Ignore.");
break;
@ -257,15 +325,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;
@ -275,8 +346,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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialoghistory.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,44 +24,44 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGHISTORY_H
#define DIALOGHISTORY_H
#include "dialogtool.h"
#include "xml/vdomdocument.h"
#include "../xml/vdomdocument.h"
namespace Ui {
class DialogHistory;
namespace Ui
{
class DialogHistory;
}
class DialogHistory : public DialogTool
{
Q_OBJECT
public:
explicit DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
virtual ~DialogHistory();
DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
virtual ~DialogHistory();
public slots:
virtual void DialogAccepted();
void cellClicked(int row, int column);
void ChangedCursor(qint64 id);
void UpdateHistory();
virtual void DialogAccepted();
void cellClicked(int row, int column);
void ChangedCursor(qint64 id);
void UpdateHistory();
signals:
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
protected:
virtual void closeEvent ( QCloseEvent * event );
virtual void closeEvent ( QCloseEvent * event );
private:
Q_DISABLE_COPY(DialogHistory)
Ui::DialogHistory *ui;
VDomDocument *doc;
qint32 cursorRow;
qint32 cursorToolRecordRow;
void FillTable();
QString Record(const VToolRecord &tool);
void InitialTable();
void ShowPoint();
VDomDocument *doc;
qint32 cursorRow;
qint32 cursorToolRecordRow;
void FillTable();
QString Record(const VToolRecord &tool);
void InitialTable();
void ShowPoint();
};
#endif // DIALOGHISTORY_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogincrements.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,22 +24,22 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogincrements.h"
#include "ui_dialogincrements.h"
#include <QHeaderView>
#include <QCloseEvent>
#include "widgets/doubledelegate.h"
#include "container/vincrementtablerow.h"
#include <QDebug>
#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){
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();
InitialLinesTable();
InitialSplinesTable();
InitialArcsTable();
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);
@ -40,7 +47,10 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
FillStandartTable();
FillIncrementTable();
FillLengthLines();
FillLengthSplines();
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::cellChanged);
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
connect(ui->toolButtonRemove, &QPushButton::clicked, this,
&DialogIncrements::clickedToolButtonRemove);
@ -52,14 +62,17 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted);
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++;
@ -94,12 +107,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());
@ -107,7 +122,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++;
@ -140,22 +156,34 @@ void DialogIncrements::FillIncrementTable(){
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
item = new QTableWidgetItem(cell.getDescription());
item->setTextAlignment(Qt::AlignHCenter);
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();
ui->tableWidgetIncrement->resizeRowsToContents();
ui->tableWidgetIncrement->verticalHeader()->setDefaultSectionSize(20);
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())
{
iHash.next();
map.insert(iHash.key(), iHash.value());
}
qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*linesTable);
while (i.hasNext()) {
QMapIterator<QString, qreal> i(map);
while (i.hasNext())
{
i.next();
qreal length = i.value();
currentRow++;
@ -175,18 +203,29 @@ 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())
{
iHash.next();
map.insert(iHash.key(), iHash.value());
}
qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*splinesTable);
while (i.hasNext()) {
QMapIterator<QString, qreal> i(map);
while (i.hasNext())
{
i.next();
qreal length = i.value();
currentRow++;
ui->tableWidgetSplines->setRowCount ( splinesTable->size() );
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
item->setTextAlignment(Qt::AlignHCenter);
item->setTextAlignment(Qt::AlignLeft);
item->setFont(QFont("Times", 12, QFont::Bold));
ui->tableWidgetSplines->setItem(currentRow, 0, item);
@ -199,11 +238,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())
{
iHash.next();
map.insert(iHash.key(), iHash.value());
}
qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*arcsTable);
while (i.hasNext()) {
QMapIterator<QString, qreal> i(map);
while (i.hasNext())
{
i.next();
qreal length = i.value();
currentRow++;
@ -223,7 +273,8 @@ void DialogIncrements::FillLengthArcs(){
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
}
void DialogIncrements::FullUpdateFromFile(){
void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
@ -251,7 +302,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);
@ -260,10 +312,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;
@ -309,9 +362,11 @@ void DialogIncrements::clickedToolButtonAdd(){
ui->toolButtonRemove->setEnabled(true);
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
emit haveLiteChange();
}
void DialogIncrements::clickedToolButtonRemove(){
void DialogIncrements::clickedToolButtonRemove()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
@ -320,20 +375,24 @@ 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,
&DialogIncrements::cellChanged);
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");
@ -364,19 +423,24 @@ void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, q
list.at(0).appendChild(element);
}
void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
QTableWidgetItem *item;
QTableWidgetItem *itemName;
void DialogIncrements::cellChanged ( qint32 row, qint32 column )
{
QTableWidgetItem *item = 0;
QTableWidgetItem *itemName = 0;
qint64 id;
QDomElement domElement;
switch(column) {
this->row = row;
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;
emit FullUpdateTree();
}
break;
@ -385,9 +449,20 @@ 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()){
domElement.setAttribute("base", item->text().toDouble());
emit FullUpdateTree();
if (domElement.isElement())
{
bool ok = false;
qreal value = item->text().toDouble(&ok);
if (ok)
{
domElement.setAttribute("base", value);
this->column = 3;
emit FullUpdateTree();
}
else
{
throw VException(tr("Can't convert toDouble value."));
}
}
break;
case 3:
@ -395,8 +470,10 @@ 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();
}
break;
@ -405,8 +482,10 @@ 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();
}
break;
@ -415,18 +494,25 @@ 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());
data->UpdateIncrementTableRow(itemName->text(), incr);
ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents();
ui->tableWidgetIncrement->setCurrentCell( row, 0 );
emit haveLiteChange();
}
break;
default:
break;
}
}
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")));
@ -436,7 +522,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")));
@ -444,27 +531,33 @@ void DialogIncrements::InitialIncrementTable(){
ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description")));
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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogincrements.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,50 +24,53 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGINCREMENTS_H
#define DIALOGINCREMENTS_H
#include "dialogtool.h"
#include "xml/vdomdocument.h"
#include "../xml/vdomdocument.h"
namespace Ui {
class DialogIncrements;
namespace Ui
{
class DialogIncrements;
}
class DialogIncrements : public DialogTool
{
Q_OBJECT
Q_OBJECT
public:
explicit DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
~DialogIncrements();
DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
~DialogIncrements();
public slots:
void clickedToolButtonAdd();
void clickedToolButtonRemove();
void cellChanged ( qint32 row, qint32 column );
void FullUpdateFromFile();
virtual void DialogAccepted();
void clickedToolButtonAdd();
void clickedToolButtonRemove();
void cellChanged ( qint32 row, qint32 column );
void FullUpdateFromFile();
virtual void DialogAccepted();
signals:
void FullUpdateTree();
void haveLiteChange();
void FullUpdateTree();
void haveLiteChange();
private:
Q_DISABLE_COPY(DialogIncrements)
Ui::DialogIncrements *ui;
VContainer *data; // need because we must change data
VDomDocument *doc;
void InitialStandartTable();
void InitialIncrementTable();
void InitialLinesTable();
void InitialSplinesTable();
void InitialArcsTable();
void FillStandartTable();
void FillIncrementTable();
void FillLengthLines();
void FillLengthSplines();
void FillLengthArcs();
void AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
QString description);
VContainer *data; // need because we must change data
VDomDocument *doc;
qint32 row;
qint32 column;
void InitialStandartTable();
void InitialIncrementTable();
void InitialLinesTable();
void InitialSplinesTable();
void InitialArcsTable();
void FillStandartTable();
void FillIncrementTable();
void FillLengthLines();
void FillLengthSplines();
void FillLengthArcs();
void AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
QString description);
};
#endif // DIALOGINCREMENTS_H

View File

@ -27,7 +27,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>4</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabStandart">
<attribute name="title">
@ -149,9 +149,15 @@
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>45</number>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Denotation</string>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,15 +24,14 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogline.h"
#include "ui_dialogline.h"
#include <QPushButton>
#include <QCloseEvent>
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);
@ -36,38 +42,36 @@ DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent
number = 0;
}
DialogLine::~DialogLine(){
DialogLine::~DialogLine()
{
delete ui;
}
qint64 DialogLine::getSecondPoint() const{
return secondPoint;
}
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);
}
}
qint64 DialogLine::getFirstPoint() const{
return firstPoint;
}
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();
@ -75,42 +79,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, const 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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,30 +24,30 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGLINE_H
#define DIALOGLINE_H
#include "dialogtool.h"
namespace Ui {
class DialogLine;
namespace Ui
{
class DialogLine;
}
class DialogLine : public DialogTool
{
Q_OBJECT
public:
explicit DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogLine();
qint64 getFirstPoint() const;
DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogLine();
inline qint64 getFirstPoint() const {return firstPoint;}
void setFirstPoint(const qint64 &value);
qint64 getSecondPoint() const;
inline qint64 getSecondPoint() const {return secondPoint;}
void setSecondPoint(const qint64 &value);
public slots:
void ChoosedObject(qint64 id, Scene::Scenes type);
void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogLine)

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialoglineintersect.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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);
@ -46,28 +54,39 @@ 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, const 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++;
@ -75,9 +94,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++;
@ -85,9 +106,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++;
@ -95,15 +118,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();
@ -124,7 +150,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);
@ -133,36 +160,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(){
Q_CHECK_PTR(bOk);
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);
@ -172,54 +205,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;
}
}
qint64 DialogLineIntersect::getP2Line2() const{
return p2Line2;
}
void DialogLineIntersect::setP2Line2(const qint64 &value){
void DialogLineIntersect::setP2Line2(const qint64 &value)
{
p2Line2 = value;
ChangeCurrentData(ui->comboBoxP2Line2, value);
}
qint64 DialogLineIntersect::getP1Line2() const{
return p1Line2;
}
void DialogLineIntersect::setP1Line2(const qint64 &value){
void DialogLineIntersect::setP1Line2(const qint64 &value)
{
p1Line2 = value;
ChangeCurrentData(ui->comboBoxP1Line2, value);
}
qint64 DialogLineIntersect::getP2Line1() const{
return p2Line1;
}
void DialogLineIntersect::setP2Line1(const qint64 &value){
void DialogLineIntersect::setP2Line1(const qint64 &value)
{
p2Line1 = value;
ChangeCurrentData(ui->comboBoxP2Line1, value);
}
qint64 DialogLineIntersect::getP1Line1() const{
return p1Line1;
}
void DialogLineIntersect::setP1Line1(const qint64 &value){
void DialogLineIntersect::setP1Line1(const qint64 &value)
{
p1Line1 = value;
ChangeCurrentData(ui->comboBoxP1Line1, value);
}
QString DialogLineIntersect::getPointName() const{
return pointName;
}
void DialogLineIntersect::setPointName(const QString &value){
void DialogLineIntersect::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialoglineintersect.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,36 +24,37 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGLINEINTERSECT_H
#define DIALOGLINEINTERSECT_H
#include "dialogtool.h"
namespace Ui {
class DialogLineIntersect;
namespace Ui
{
class DialogLineIntersect;
}
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();
qint64 getP1Line1() const;
inline qint64 getP1Line1() const {return p1Line1;}
void setP1Line1(const qint64 &value);
qint64 getP2Line1() const;
inline qint64 getP2Line1() const {return p2Line1;}
void setP2Line1(const qint64 &value);
qint64 getP1Line2() const;
inline qint64 getP1Line2() const {return p1Line2;}
void setP1Line2(const qint64 &value);
qint64 getP2Line2() const;
inline qint64 getP2Line2() const {return p2Line2;}
void setP2Line2(const qint64 &value);
QString getPointName() const;
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
void P1Line1Changed( int index);
void P2Line1Changed( int index);

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialognormal.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialognormal.h"
#include "ui_dialognormal.h"
#include <QMenu>
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;
@ -35,6 +42,8 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
@ -74,6 +83,8 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogNormal::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogNormal::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogNormal::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogNormal::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogNormal::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged);
@ -84,49 +95,64 @@ 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, const 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();
@ -136,54 +162,36 @@ void DialogNormal::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogNormal::getSecondPointId() const{
return secondPointId;
}
void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id){
void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
}
qint64 DialogNormal::getFirstPointId() const{
return firstPointId;
}
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id){
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
qreal DialogNormal::getAngle() const{
return angle;
}
void DialogNormal::setAngle(const qreal &value){
void DialogNormal::setAngle(const qreal &value)
{
angle = value;
ui->doubleSpinBoxAngle->setValue(angle);
}
QString DialogNormal::getFormula() const{
return formula;
}
void DialogNormal::setFormula(const QString &value){
void DialogNormal::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
QString DialogNormal::getTypeLine() const{
return typeLine;
}
void DialogNormal::setTypeLine(const QString &value){
void DialogNormal::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogNormal::getPointName() const{
return pointName;
}
void DialogNormal::setPointName(const QString &value){
void DialogNormal::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialognormal.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,40 +24,38 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGNORMAL_H
#define DIALOGNORMAL_H
#include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui {
class DialogNormal;
namespace Ui
{
class DialogNormal;
}
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();
QString getPointName() const;
inline QString getPointName() const{return pointName;}
void setPointName(const QString &value);
QString getTypeLine() const;
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
QString getFormula() const;
inline QString getFormula() const {return formula;}
void setFormula(const QString &value);
qreal getAngle() const;
inline qreal getAngle() const {return angle;}
void setAngle(const qreal &value);
qint64 getFirstPointId() const;
inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id);
qint64 getSecondPointId() const;
inline qint64 getSecondPointId() const {return secondPointId;}
void setSecondPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogNormal)

View File

@ -519,7 +519,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
@ -529,7 +529,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogpointofcontact.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,13 +24,14 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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;
@ -32,6 +40,8 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
radioButtonStandartTable = ui.radioButtonStandartTable;
radioButtonIncrements = ui.radioButtonIncrements;
radioButtonLengthLine = ui.radioButtonLengthLine;
radioButtonLengthArc = ui.radioButtonLengthArc;
radioButtonLengthCurve = ui.radioButtonLengthSpline;
lineEditFormula = ui.lineEditFormula;
labelEditFormula = ui.labelEditFormula;
labelEditNamePoint = ui.labelEditNamePoint;
@ -55,64 +65,82 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
connect(ui.radioButtonStandartTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandartTable);
connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments);
connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines);
connect(ui.radioButtonLengthArc, &QRadioButton::clicked, this, &DialogPointOfContact::LengthArcs);
connect(ui.radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogPointOfContact::LengthCurves);
connect(ui.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula);
connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
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, const 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);
@ -121,45 +149,30 @@ void DialogPointOfContact::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogPointOfContact::getSecondPoint() const{
return secondPoint;
}
void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id){
void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id);
}
qint64 DialogPointOfContact::getFirstPoint() const{
return firstPoint;
}
void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id){
void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id);
}
qint64 DialogPointOfContact::getCenter() const{
return center;
}
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;
}
QString DialogPointOfContact::getRadius() const{
return radius;
}
void DialogPointOfContact::setRadius(const QString &value){
void DialogPointOfContact::setRadius(const QString &value)
{
radius = value;
ui.lineEditFormula->setText(radius);
}
QString DialogPointOfContact::getPointName() const{
return pointName;
}
void DialogPointOfContact::setPointName(const QString &value){
void DialogPointOfContact::setPointName(const QString &value)
{
pointName = value;
ui.lineEditNamePoint->setText(pointName);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogpointofcontact.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,49 +24,42 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGPOINTOFCONTACT_H
#define DIALOGPOINTOFCONTACT_H
#include "ui_dialogpointofcontact.h"
#include "dialogtool.h"
#include "container/calculator.h"
class DialogPointOfContact : public DialogTool
{
Q_OBJECT
public:
explicit DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
QString getPointName() const;
void setPointName(const QString &value);
QString getRadius() const;
void setRadius(const QString &value);
qint64 getCenter() const;
void setCenter(const qint64 &value, const qint64 &id);
qint64 getFirstPoint() const;
void setFirstPoint(const qint64 &value, const qint64 &id);
qint64 getSecondPoint() const;
void setSecondPoint(const qint64 &value, const qint64 &id);
DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
inline QString getRadius() const {return radius;}
void setRadius(const QString &value);
inline qint64 getCenter() const {return center;}
void setCenter(const qint64 &value, const qint64 &id);
inline qint64 getFirstPoint() const {return firstPoint;}
void setFirstPoint(const qint64 &value, const qint64 &id);
inline qint64 getSecondPoint() const {return secondPoint;}
void setSecondPoint(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogPointOfContact)
Ui::DialogPointOfContact ui;
qint32 number;
QString pointName;
QString radius;
qint64 center;
qint64 firstPoint;
qint64 secondPoint;
qint32 number;
QString pointName;
QString radius;
qint64 center;
qint64 firstPoint;
qint64 secondPoint;
};
#endif // DIALOGPOINTOFCONTACT_H

View File

@ -359,7 +359,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
@ -369,7 +369,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

View File

@ -0,0 +1,134 @@
/************************************************************************
**
** @file dialogpointofintersection.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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)
{
ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
}
DialogPointOfIntersection::~DialogPointOfIntersection()
{
delete ui;
}
void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint64 &id)
{
secondPointId = value;
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
}
void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetModelingPoint(id);
}
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++;
emit ToolTip(tr("Select point horizontally"));
return;
}
}
if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0;
emit ToolTip("");
}
if (isInitialized == false)
{
this->show();
}
}
}
}
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)
{
firstPointId = value;
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
void DialogPointOfIntersection::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -0,0 +1,64 @@
/************************************************************************
**
** @file dialogpointofintersection.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGPOINTOFINTERSECTION_H
#define DIALOGPOINTOFINTERSECTION_H
#include "dialogtool.h"
namespace Ui
{
class DialogPointOfIntersection;
}
class DialogPointOfIntersection : public DialogTool
{
Q_OBJECT
public:
DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogPointOfIntersection();
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id);
inline qint64 getSecondPointId() const {return secondPointId;}
void setSecondPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogPointOfIntersection)
Ui::DialogPointOfIntersection *ui;
qint32 number;
QString pointName;
qint64 firstPointId;
qint64 secondPointId;
};
#endif // DIALOGPOINTOFINTERSECTION_H

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPointOfIntersection</class>
<widget class="QDialog" name="DialogPointOfIntersection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>293</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point vertically</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFirstPoint">
<property name="toolTip">
<string>First point of angle</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point horizontally</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="toolTip">
<string>Second point of angle</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPointOfIntersection</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPointOfIntersection</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogs.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGS_H
#define DIALOGS_H
@ -37,5 +44,6 @@
#include "dialogsinglepoint.h"
#include "dialogspline.h"
#include "dialogsplinepath.h"
#include "dialogheight.h"
#endif // DIALOGS_H

62
dialogs/dialogs.pri Normal file
View File

@ -0,0 +1,62 @@
HEADERS += \
dialogs/dialogtriangle.h \
dialogs/dialogtool.h \
dialogs/dialogsplinepath.h \
dialogs/dialogspline.h \
dialogs/dialogsinglepoint.h \
dialogs/dialogshoulderpoint.h \
dialogs/dialogs.h \
dialogs/dialogpointofintersection.h \
dialogs/dialogpointofcontact.h \
dialogs/dialognormal.h \
dialogs/dialoglineintersect.h \
dialogs/dialogline.h \
dialogs/dialogincrements.h \
dialogs/dialoghistory.h \
dialogs/dialogheight.h \
dialogs/dialogendline.h \
dialogs/dialogdetail.h \
dialogs/dialogbisector.h \
dialogs/dialogarc.h \
dialogs/dialogalongline.h
SOURCES += \
dialogs/dialogtriangle.cpp \
dialogs/dialogtool.cpp \
dialogs/dialogsplinepath.cpp \
dialogs/dialogspline.cpp \
dialogs/dialogsinglepoint.cpp \
dialogs/dialogshoulderpoint.cpp \
dialogs/dialogpointofintersection.cpp \
dialogs/dialogpointofcontact.cpp \
dialogs/dialognormal.cpp \
dialogs/dialoglineintersect.cpp \
dialogs/dialogline.cpp \
dialogs/dialogincrements.cpp \
dialogs/dialoghistory.cpp \
dialogs/dialogheight.cpp \
dialogs/dialogendline.cpp \
dialogs/dialogdetail.cpp \
dialogs/dialogbisector.cpp \
dialogs/dialogarc.cpp \
dialogs/dialogalongline.cpp
FORMS += \
dialogs/dialogtriangle.ui \
dialogs/dialogsplinepath.ui \
dialogs/dialogspline.ui \
dialogs/dialogsinglepoint.ui \
dialogs/dialogshoulderpoint.ui \
dialogs/dialogpointofintersection.ui \
dialogs/dialogpointofcontact.ui \
dialogs/dialognormal.ui \
dialogs/dialoglineintersect.ui \
dialogs/dialogline.ui \
dialogs/dialogincrements.ui \
dialogs/dialoghistory.ui \
dialogs/dialogheight.ui \
dialogs/dialogendline.ui \
dialogs/dialogdetail.ui \
dialogs/dialogbisector.ui \
dialogs/dialogarc.ui \
dialogs/dialogalongline.ui

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogshoulderpoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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;
@ -34,6 +42,8 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
@ -58,6 +68,8 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogShoulderPoint::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogShoulderPoint::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogShoulderPoint::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged);
@ -68,58 +80,75 @@ 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, const 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();
@ -129,53 +158,35 @@ void DialogShoulderPoint::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogShoulderPoint::getPShoulder() const{
return pShoulder;
}
void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id){
void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id);
}
qint64 DialogShoulderPoint::getP2Line() const{
return p2Line;
}
void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id){
void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id);
}
qint64 DialogShoulderPoint::getP1Line() const{
return p1Line;
}
void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id){
void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id)
{
setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id);
}
QString DialogShoulderPoint::getFormula() const{
return formula;
}
void DialogShoulderPoint::setFormula(const QString &value){
void DialogShoulderPoint::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
QString DialogShoulderPoint::getTypeLine() const{
return typeLine;
}
void DialogShoulderPoint::setTypeLine(const QString &value){
void DialogShoulderPoint::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogShoulderPoint::getPointName() const{
return pointName;
}
void DialogShoulderPoint::setPointName(const QString &value){
void DialogShoulderPoint::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogshoulderpoint.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,50 +24,50 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGSHOULDERPOINT_H
#define DIALOGSHOULDERPOINT_H
#include "dialogtool.h"
#include "container/calculator.h"
namespace Ui {
class DialogShoulderPoint;
namespace Ui
{
class DialogShoulderPoint;
}
class DialogShoulderPoint : public DialogTool
{
Q_OBJECT
public:
explicit DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogShoulderPoint();
QString getPointName() const;
void setPointName(const QString &value);
QString getTypeLine() const;
void setTypeLine(const QString &value);
QString getFormula() const;
void setFormula(const QString &value);
qint64 getP1Line() const;
void setP1Line(const qint64 &value, const qint64 &id);
qint64 getP2Line() const;
void setP2Line(const qint64 &value, const qint64 &id);
qint64 getPShoulder() const;
void setPShoulder(const qint64 &value, const qint64 &id);
DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogShoulderPoint();
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value);
inline QString getFormula() const {return formula;}
void setFormula(const QString &value);
inline qint64 getP1Line() const {return p1Line;}
void setP1Line(const qint64 &value, const qint64 &id);
inline qint64 getP2Line() const {return p2Line;}
void setP2Line(const qint64 &value, const qint64 &id);
inline qint64 getPShoulder() const {return pShoulder;}
void setPShoulder(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogShoulderPoint)
Ui::DialogShoulderPoint *ui;
qint32 number;
QString pointName;
QString typeLine;
QString formula;
qint64 p1Line;
qint64 p2Line;
qint64 pShoulder;
qint32 number;
QString pointName;
QString typeLine;
QString formula;
qint64 p1Line;
qint64 p2Line;
qint64 pShoulder;
};
#endif // DIALOGSHOULDERPOINT_H

View File

@ -380,7 +380,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of lines</string>
@ -390,7 +390,7 @@
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogsinglepoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,21 +24,18 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogsinglepoint.h"
#include "ui_dialogsinglepoint.h"
#include <QShowEvent>
#include <QPushButton>
#include <QDebug>
#include "options.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,PaperSize/PrintDPI*25.4);
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4);
ui->doubleSpinBoxX->setRange(0, toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0, toMM(PaperSize));
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
labelEditNamePoint = ui->labelEditName;
flagName = false;
@ -39,45 +43,42 @@ 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){
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
void DialogSinglePoint::mousePress(const QPointF &scenePos)
{
if (isInitialized == false)
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
this->show();
} else {
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
}
else
{
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
}
}
void DialogSinglePoint::DialogAccepted(){
point = QPointF(ui->doubleSpinBoxX->value()*PrintDPI/25.4,
ui->doubleSpinBoxY->value()*PrintDPI/25.4);
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;
ui->lineEditName->setText(name);
ui->doubleSpinBoxX->setValue(point.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(point.y()/PrintDPI*25.4);
ui->doubleSpinBoxX->setValue(toMM(point.x()));
ui->doubleSpinBoxY->setValue(toMM(point.y()));
}
QString DialogSinglePoint::getName()const{
return name;
}
QPointF DialogSinglePoint::getPoint()const{
return point;
}
DialogSinglePoint::~DialogSinglePoint(){
DialogSinglePoint::~DialogSinglePoint()
{
delete ui;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogsinglepoint.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,34 +24,35 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGSINGLEPOINT_H
#define DIALOGSINGLEPOINT_H
#include "dialogtool.h"
namespace Ui {
class DialogSinglePoint;
namespace Ui
{
class DialogSinglePoint;
}
class DialogSinglePoint : public DialogTool
{
Q_OBJECT
Q_OBJECT
public:
explicit DialogSinglePoint(const VContainer *data, QWidget *parent = 0);
void setData(const QString name, const QPointF point);
QString getName()const;
QPointF getPoint()const;
~DialogSinglePoint();
DialogSinglePoint(const VContainer *data, QWidget *parent = 0);
void setData(const QString &name, const QPointF &point);
inline QString getName()const {return name;}
inline QPointF getPoint()const {return point;}
~DialogSinglePoint();
public slots:
void mousePress(QPointF scenePos);
virtual void DialogAccepted();
void mousePress(const QPointF &scenePos);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogSinglePoint)
Ui::DialogSinglePoint *ui;
QString name;
QPointF point;
QString name;
QPointF point;
};
#endif // DIALOGSINGLEPOINT_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,63 +24,79 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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, const 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 +104,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,65 +137,44 @@ void DialogSpline::DialogAccepted(){
emit DialogClosed(QDialog::Accepted);
}
qreal DialogSpline::getKCurve() const{
return kCurve;
}
void DialogSpline::setKCurve(const qreal &value){
void DialogSpline::setKCurve(const qreal &value)
{
kCurve = value;
ui->doubleSpinBoxKcurve->setValue(value);
}
qreal DialogSpline::getKAsm2() const{
return kAsm2;
}
void DialogSpline::setKAsm2(const qreal &value){
void DialogSpline::setKAsm2(const qreal &value)
{
kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(value);
}
qreal DialogSpline::getKAsm1() const{
return kAsm1;
}
void DialogSpline::setKAsm1(const qreal &value){
void DialogSpline::setKAsm1(const qreal &value)
{
kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(value);
}
qreal DialogSpline::getAngle2() const{
return angle2;
}
void DialogSpline::setAngle2(const qreal &value){
void DialogSpline::setAngle2(const qreal &value)
{
angle2 = value;
ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
}
qreal DialogSpline::getAngle1() const{
return angle1;
}
void DialogSpline::setAngle1(const qreal &value){
void DialogSpline::setAngle1(const qreal &value)
{
angle1 = value;
ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
}
qint64 DialogSpline::getP4() const{
return p4;
}
void DialogSpline::setP4(const qint64 &value){
void DialogSpline::setP4(const qint64 &value)
{
p4 = value;
ChangeCurrentData(ui->comboBoxP4, value);
}
qint64 DialogSpline::getP1() const{
return p1;
}
void DialogSpline::setP1(const qint64 &value){
void DialogSpline::setP1(const qint64 &value)
{
p1 = value;
ChangeCurrentData(ui->comboBoxP1, value);
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,52 +24,52 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGSPLINE_H
#define DIALOGSPLINE_H
#include "dialogtool.h"
namespace Ui {
class DialogSpline;
namespace Ui
{
class DialogSpline;
}
class DialogSpline : public DialogTool
{
Q_OBJECT
Q_OBJECT
public:
explicit DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogSpline();
qint64 getP1() const;
void setP1(const qint64 &value);
qint64 getP4() const;
void setP4(const qint64 &value);
qreal getAngle1() const;
void setAngle1(const qreal &value);
qreal getAngle2() const;
void setAngle2(const qreal &value);
qreal getKAsm1() const;
void setKAsm1(const qreal &value);
qreal getKAsm2() const;
void setKAsm2(const qreal &value);
qreal getKCurve() const;
void setKCurve(const qreal &value);
DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogSpline();
inline qint64 getP1() const {return p1;}
void setP1(const qint64 &value);
inline qint64 getP4() const {return p4;}
void setP4(const qint64 &value);
inline qreal getAngle1() const {return angle1;}
void setAngle1(const qreal &value);
inline qreal getAngle2() const {return angle2;}
void setAngle2(const qreal &value);
inline qreal getKAsm1() const {return kAsm1;}
void setKAsm1(const qreal &value);
inline qreal getKAsm2() const {return kAsm2;}
void setKAsm2(const qreal &value);
inline qreal getKCurve() const {return kCurve;}
void setKCurve(const qreal &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogSpline)
Ui::DialogSpline *ui;
qint32 number;
qint64 p1; // перша точка
qint64 p4; // четверта точка
qreal angle1; // кут нахилу дотичної в першій точці
qreal angle2; // кут нахилу дотичної в другій точці
qreal kAsm1;
qreal kAsm2;
qreal kCurve;
qint32 number;
qint64 p1; // перша точка
qint64 p4; // четверта точка
qreal angle1; // кут нахилу дотичної в першій точці
qreal angle2; // кут нахилу дотичної в другій точці
qreal kAsm1;
qreal kAsm2;
qreal kCurve;
};
#endif // DIALOGSPLINE_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogsplinepath.h"
#include "ui_dialogsplinepath.h"
#include "geometry/vsplinepoint.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);
@ -53,14 +61,12 @@ DialogSplinePath::~DialogSplinePath()
delete ui;
}
VSplinePath DialogSplinePath::GetPath() const{
return path;
}
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);
@ -68,28 +74,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, const 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)));
}
@ -98,8 +112,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 );
@ -108,7 +124,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 );
@ -119,15 +136,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));
@ -135,7 +155,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));
@ -143,11 +164,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());
@ -159,7 +184,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),
@ -189,25 +215,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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,44 +24,45 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGSPLINEPATH_H
#define DIALOGSPLINEPATH_H
#include "dialogtool.h"
#include "geometry/vsplinepath.h"
#include "../geometry/vsplinepath.h"
namespace Ui {
class DialogSplinePath;
namespace Ui
{
class DialogSplinePath;
}
class DialogSplinePath : public DialogTool
{
Q_OBJECT
public:
explicit DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogSplinePath();
VSplinePath GetPath() const;
void SetPath(const VSplinePath &value);
DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogSplinePath();
inline VSplinePath GetPath() const {return path;}
void SetPath(const VSplinePath &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
void PointChenged(int row);
void currentPointChanged( int index );
void Angle1Changed( int index );
void Angle2Changed( int index );
void KAsm1Changed(qreal d);
void KAsm2Changed(qreal d);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
void PointChenged(int row);
void currentPointChanged( int index );
void Angle1Changed( int index );
void Angle2Changed( int index );
void KAsm1Changed(qreal d);
void KAsm2Changed(qreal d);
private:
Q_DISABLE_COPY(DialogSplinePath)
Ui::DialogSplinePath *ui;
VSplinePath path;
void NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2);
void DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields();
void SetAngle(qint32 angle);
VSplinePath path;
void NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2);
void DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields();
void SetAngle(qint32 angle);
};
#endif // DIALOGSPLINEPATH_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogtool.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,72 +24,81 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "dialogtool.h"
#include <QListWidgetItem>
#include <QCloseEvent>
#include "container/calculator.h"
#include "geometry/vdetail.h"
#include <QDebug>
#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), idDetail(0), mode(mode){
Q_CHECK_PTR(data);
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);
}
DialogTool::~DialogTool(){
}
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 (ptrdiff_t 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());
}
@ -91,63 +107,86 @@ 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
{
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){
Q_CHECK_PTR(lineEdit);
Q_CHECK_PTR(listWidget);
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
{
Q_ASSERT(lineEdit != 0);
Q_ASSERT(listWidget != 0);
QListWidgetItem *item = listWidget->currentItem();
QString val = item->text();
lineEdit->setText(lineEdit->text().append(val));
int pos = lineEdit->cursorPosition();
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
lineEdit->setFocus();
lineEdit->setCursorPosition(pos + item->text().size());
}
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){
Q_CHECK_PTR(edit);
Q_CHECK_PTR(timer);
Q_CHECK_PTR(labelEditFormula);
if(edit->text().isEmpty()){
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())
{
flag = false;
CheckState();
QPalette palette = labelEditFormula->palette();
@ -158,27 +197,34 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){
timer->start(1000);
}
void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label){
Q_CHECK_PTR(edit);
Q_CHECK_PTR(timer);
Q_CHECK_PTR(label);
Q_CHECK_PTR(labelEditFormula);
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();
@ -186,205 +232,293 @@ 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{
Q_CHECK_PTR(box);
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{
Q_CHECK_PTR(box);
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(){
Q_CHECK_PTR(bOk);
void DialogTool::CheckState()
{
Q_ASSERT(bOk != 0);
bOk->setEnabled(flagFormula && flagName);
}
void DialogTool::ChoosedObject(qint64 id, Scene::Scenes type){
void DialogTool::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
Q_UNUSED(id);
Q_UNUSED(type);
}
void DialogTool::NamePointChanged(){
Q_CHECK_PTR(labelEditNamePoint);
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(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowUp()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(90);
}
void DialogTool::ArrowDown(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowDown()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(270);
}
void DialogTool::ArrowLeft(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowLeft()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(180);
}
void DialogTool::ArrowRight(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowRight()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(0);
}
void DialogTool::ArrowLeftUp(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowLeftUp()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(135);
}
void DialogTool::ArrowLeftDown(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowLeftDown()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(225);
}
void DialogTool::ArrowRightUp(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowRightUp()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(45);
}
void DialogTool::ArrowRightDown(){
Q_CHECK_PTR(spinBoxAngle);
void DialogTool::ArrowRightDown()
{
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(315);
}
void DialogTool::EvalFormula(){
Q_CHECK_PTR(lineEditFormula);
Q_CHECK_PTR(labelResultCalculation);
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::Increments(){
void DialogTool::LengthArcs()
{
ShowVariable(data->DataLengthArcs());
}
void DialogTool::LengthCurves()
{
ShowVariable(data->DataLengthSplines());
}
void DialogTool::Increments()
{
ShowVariable(data->DataIncrementTable());
}
void DialogTool::PutHere(){
void DialogTool::PutHere()
{
PutValHere(lineEditFormula, listWidget);
}
void DialogTool::PutVal(QListWidgetItem *item){
Q_CHECK_PTR(lineEditFormula);
QString val = item->text();
lineEditFormula->setText(lineEditFormula->text().append(val));
void DialogTool::PutVal(QListWidgetItem *item)
{
Q_ASSERT(lineEditFormula != 0);
Q_ASSERT(item != 0);
int pos = lineEditFormula->cursorPosition();
lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(),
item->text()));
lineEditFormula->setFocus();
lineEditFormula->setCursorPosition(pos + item->text().size());
}
void DialogTool::ValChenged(int row){
Q_CHECK_PTR(listWidget);
Q_CHECK_PTR(labelDescription);
Q_CHECK_PTR(radioButtonSizeGrowth);
Q_CHECK_PTR(radioButtonStandartTable);
Q_CHECK_PTR(radioButtonIncrements);
Q_CHECK_PTR(radioButtonLengthLine);
if(listWidget->count() == 0){
void DialogTool::ValChenged(int row)
{
Q_ASSERT(listWidget != 0);
Q_ASSERT(labelDescription != 0);
Q_ASSERT(radioButtonSizeGrowth != 0);
Q_ASSERT(radioButtonStandartTable != 0);
Q_ASSERT(radioButtonIncrements != 0);
Q_ASSERT(radioButtonLengthLine != 0);
Q_ASSERT(radioButtonLengthArc != 0);
Q_ASSERT(radioButtonLengthCurve != 0);
if (listWidget->count() == 0)
{
return;
}
QListWidgetItem *item = listWidget->item( row );
if(radioButtonSizeGrowth->isChecked()){
if(item->text()=="Р"){
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg("Зріст");
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()=="Сг"){
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg("Розмір");
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;
}
}
void DialogTool::UpdateList(){
if(radioButtonSizeGrowth == 0 || radioButtonStandartTable == 0 || radioButtonIncrements == 0){
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(radioButtonSizeGrowth->isChecked()){
ShowVariable(data->DataBase());
}
if(radioButtonStandartTable->isChecked()){
ShowVariable(data->DataStandartTable());
}
if(radioButtonIncrements->isChecked()){
ShowVariable(data->DataIncrementTable());
if (radioButtonLengthCurve->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text()))
.arg(tr("Curve length"));
labelDescription->setText(desc);
return;
}
}
bool DialogTool::CheckObject(const qint64 &id){
if(mode == Draw::Calculation || idDetail == 0){
void DialogTool::UpdateList()
{
Q_ASSERT(radioButtonSizeGrowth != 0);
Q_ASSERT(radioButtonStandartTable != 0);
Q_ASSERT(radioButtonIncrements != 0);
Q_ASSERT(radioButtonLengthLine != 0);
Q_ASSERT(radioButtonLengthArc != 0);
Q_ASSERT(radioButtonLengthCurve != 0);
if (radioButtonSizeGrowth->isChecked())
{
ShowVariable(data->DataBase());
}
if (radioButtonStandartTable->isChecked())
{
ShowVariable(data->DataStandartTable());
}
if (radioButtonIncrements->isChecked())
{
ShowVariable(data->DataIncrementTable());
}
if (radioButtonLengthLine->isChecked())
{
ShowVariable(data->DataLengthLines());
}
if (radioButtonLengthArc->isChecked())
{
ShowVariable(data->DataLengthArcs());
}
if (radioButtonLengthCurve->isChecked())
{
ShowVariable(data->DataLengthSplines());
}
}
bool DialogTool::CheckObject(const qint64 &id)
{
if (mode == Draw::Calculation || idDetail == 0)
{
return false;
}
VDetail det = data->GetDetail(idDetail);
@ -392,25 +526,28 @@ bool DialogTool::CheckObject(const qint64 &id){
}
template <class key, class val>
void DialogTool::ShowVariable(const QHash<key, val> *var){
Q_CHECK_PTR(listWidget);
void DialogTool::ShowVariable(const QHash<key, val> *var)
{
Q_ASSERT(listWidget != 0);
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->clear();
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
QHashIterator<key, val> i(*var);
while (i.hasNext()) {
QMap<key, val> map;
while (i.hasNext())
{
i.next();
QListWidgetItem *item = new QListWidgetItem(i.key());
map.insert(i.key(), i.value());
}
QMapIterator<key, val> iMap(map);
while (iMap.hasNext())
{
iMap.next();
QListWidgetItem *item = new QListWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item);
}
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->setCurrentRow (0);
}
qint64 DialogTool::getIdDetail() const{
return idDetail;
}
void DialogTool::setIdDetail(const qint64 &value){
idDetail = value;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file dialogtool.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,35 +24,27 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef DIALOGTOOL_H
#define DIALOGTOOL_H
#include <QDialog>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QLineEdit>
#include <QListWidget>
#include <QLabel>
#include <QRadioButton>
#include <QTimer>
#include "container/vcontainer.h"
#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);
virtual ~DialogTool();
qint64 getIdDetail() const;
void setIdDetail(const qint64 &value);
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;}
signals:
void DialogClosed(int result);
void ToolTip(const QString &toolTip);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
void NamePointChanged();
virtual void DialogAccepted();
virtual void DialogRejected();
@ -62,6 +61,8 @@ public slots:
void SizeGrowth();
void StandartTable();
void LengthLines();
void LengthArcs();
void LengthCurves();
void Increments();
void PutHere();
void PutVal(QListWidgetItem * item);
@ -86,8 +87,10 @@ protected:
QRadioButton *radioButtonStandartTable;
QRadioButton *radioButtonIncrements;
QRadioButton *radioButtonLengthLine;
QRadioButton *radioButtonLengthArc;
QRadioButton *radioButtonLengthCurve;
qint64 idDetail;
Draw::Draws mode;
Draw::Draws mode;
bool CheckObject(const qint64 &id);
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );

154
dialogs/dialogtriangle.cpp Normal file
View File

@ -0,0 +1,154 @@
/************************************************************************
**
** @file dialogtriangle.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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)
{
ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogTriangle::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected);
FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
}
DialogTriangle::~DialogTriangle()
{
delete ui;
}
void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
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 == false)
{
this->show();
}
break;
default:
break;
}
}
}
void DialogTriangle::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
axisP1Id = getCurrentPointId(ui->comboBoxAxisP1);
axisP2Id = getCurrentPointId(ui->comboBoxAxisP2);
emit DialogClosed(QDialog::Accepted);
}
void DialogTriangle::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
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)
{
firstPointId = value;
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, 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)
{
axisP1Id = value;
setCurrentPointId(ui->comboBoxAxisP1, axisP1Id, value, id);
}

69
dialogs/dialogtriangle.h Normal file
View File

@ -0,0 +1,69 @@
/************************************************************************
**
** @file dialogtriangle.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGTRIANGLE_H
#define DIALOGTRIANGLE_H
#include "dialogtool.h"
namespace Ui
{
class DialogTriangle;
}
class DialogTriangle : public DialogTool
{
Q_OBJECT
public:
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);
inline qint64 getAxisP2Id() const {return axisP2Id;}
void setAxisP2Id(const qint64 &value, const qint64 &id);
inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id);
inline qint64 getSecondPointId() const {return secondPointId;}
void setSecondPointId(const qint64 &value, const qint64 &id);
inline QString getPointName() const {return pointName;}
void setPointName(const QString &value);
public slots:
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogTriangle)
Ui::DialogTriangle *ui;
qint32 number;
QString pointName;
qint64 axisP1Id;
qint64 axisP2Id;
qint64 firstPointId;
qint64 secondPointId;
};
#endif // DIALOGTRIANGLE_H

196
dialogs/dialogtriangle.ui Normal file
View File

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogTriangle</class>
<widget class="QDialog" name="DialogTriangle">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>267</width>
<height>220</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>First point of axis</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxAxisP1">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Second point of axis</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxAxisP2">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>First point</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFirstPoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Second point</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="toolTip">
<string>First point of line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogTriangle</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogTriangle</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

17
exception/exception.pri Normal file
View File

@ -0,0 +1,17 @@
HEADERS += \
exception/vexceptionwrongparameterid.h \
exception/vexceptionuniqueid.h \
exception/vexceptionobjecterror.h \
exception/vexceptionemptyparameter.h \
exception/vexceptionconversionerror.h \
exception/vexceptionbadid.h \
exception/vexception.h
SOURCES += \
exception/vexceptionwrongparameterid.cpp \
exception/vexceptionuniqueid.cpp \
exception/vexceptionobjecterror.cpp \
exception/vexceptionemptyparameter.cpp \
exception/vexceptionconversionerror.cpp \
exception/vexceptionbadid.cpp \
exception/vexception.cpp

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexception.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,18 +24,17 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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");
}
VException::VException(const VException &e):what(e.What()){
}
QString VException::ErrorMessage() const{
QString VException::ErrorMessage() const
{
QString error = QString("Exception: %1").arg(what);
return error;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexception.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,28 +24,27 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTION_H
#define VEXCEPTION_H
#include <QException>
#include <QString>
class VException : public QException
{
public:
VException(const QString &what);
VException(const VException &e);
virtual ~VException() noexcept(true){}
void raise() const { throw *this; }
VException *clone() const { return new VException(*this); }
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const { return QString(); }
QString What() const {return what;}
VException(const QString &what);
VException(const VException &e):what(e.What()){}
virtual ~VException() Q_DECL_NOEXCEPT_EXPR(true){}
inline void raise() const { throw *this; }
inline VException *clone() const { return new VException(*this); }
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const { return QString(); }
inline QString What() const {return what;}
protected:
QString what;
QString what;
};
#endif // VEXCEPTION_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionbadid.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,28 +24,20 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vexceptionbadid.h"
VExceptionBadId::VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id),
key(QString()){
}
VExceptionBadId::VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key)
QString VExceptionBadId::ErrorMessage() const
{
}
VExceptionBadId::VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){
}
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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionbadid.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTIONBADID_H
#define VEXCEPTIONBADID_H
@ -27,16 +34,19 @@
class VExceptionBadId : public VException
{
public:
VExceptionBadId(const QString &what, const qint64 &id);
VExceptionBadId(const QString &what, const QString &key);
VExceptionBadId(const VExceptionBadId &e);
virtual ~VExceptionBadId() noexcept(true){}
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() Q_DECL_NOEXCEPT_EXPR(true){}
virtual QString ErrorMessage() const;
qint64 BadId() const {return id; }
QString BadKey() const {return key; }
inline qint64 BadId() const {return id; }
inline QString BadKey() const {return key; }
protected:
qint64 id;
QString key;
qint64 id;
QString key;
};
#endif // VEXCEPTIONBADID_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionconversionerror.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,20 +24,18 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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");
}
VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e):
VException(e), str(e.String()){
}
QString VExceptionConversionError::ErrorMessage() const{
QString VExceptionConversionError::ErrorMessage() const
{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
return error;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionconversionerror.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTIONCONVERSIONERROR_H
#define VEXCEPTIONCONVERSIONERROR_H
@ -27,13 +34,14 @@
class VExceptionConversionError : public VException
{
public:
VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e);
virtual ~VExceptionConversionError() noexcept(true) {}
VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e)
:VException(e), str(e.String()){}
virtual ~VExceptionConversionError() Q_DECL_NOEXCEPT_EXPR(true) {}
virtual QString ErrorMessage() const;
QString String() const {return str;}
inline QString String() const {return str;}
protected:
QString str;
QString str;
};
#endif // VEXCEPTIONCONVERSIONERROR_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionemptyparameter.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,32 +24,30 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vexceptionemptyparameter.h"
#include <QDebug>
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();
}
VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e),
name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionemptyparameter.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,31 +24,32 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTIONEMPTYPARAMETER_H
#define VEXCEPTIONEMPTYPARAMETER_H
#include "vexception.h"
#include <QDomElement>
class VExceptionEmptyParameter : public VException
{
public:
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement);
VExceptionEmptyParameter(const VExceptionEmptyParameter &e);
virtual ~VExceptionEmptyParameter() noexcept(true) {}
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() Q_DECL_NOEXCEPT_EXPR(true) {}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString Name() const {return name;}
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
inline QString Name() const {return name;}
inline QString TagText() const {return tagText;}
inline QString TagName() const {return tagName;}
inline qint32 LineNumber() const {return lineNumber;}
protected:
QString name;
QString tagText;
QString tagName;
qint32 lineNumber;
QString name;
QString tagText;
QString tagName;
qint32 lineNumber;
};
#endif // VEXCEPTIONEMPTYPARAMETER_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionobjecterror.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,42 +24,46 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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();
}
VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){
}
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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionobjecterror.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,32 +24,33 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTIONOBJECTERROR_H
#define VEXCEPTIONOBJECTERROR_H
#include "vexception.h"
#include <QDomElement>
class VExceptionObjectError : public VException
{
public:
VExceptionObjectError(const QString &what, const QDomElement &domElement);
VExceptionObjectError(const VExceptionObjectError &e);
virtual ~VExceptionObjectError() noexcept(true) {}
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()){}
virtual ~VExceptionObjectError() Q_DECL_NOEXCEPT_EXPR(true) {}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
void AddMoreInformation(const QString &info);
QString MoreInformation() const {return moreInfo;}
inline QString TagText() const {return tagText;}
inline QString TagName() const {return tagName;}
inline qint32 LineNumber() const {return lineNumber;}
void AddMoreInformation(const QString &info);
inline QString MoreInformation() const {return moreInfo;}
protected:
QString tagText;
QString tagName;
qint32 lineNumber;
QString moreInfo;
QString tagText;
QString tagName;
qint32 lineNumber;
QString moreInfo;
};
#endif // VEXCEPTIONOBJECTERROR_H

View File

@ -1,21 +1,51 @@
/************************************************************************
**
** @file vexceptionuniqueid.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vexceptionuniqueid.h"
#include <QTextStream>
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

@ -1,24 +1,52 @@
/************************************************************************
**
** @file vexceptionuniqueid.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VEXCEPTIONUNIQUEID_H
#define VEXCEPTIONUNIQUEID_H
#include "vexception.h"
#include <QDomElement>
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()){}
virtual ~VExceptionUniqueId() noexcept(true){}
VExceptionUniqueId(const QString &what, const QDomElement &domElement);
VExceptionUniqueId(const VExceptionUniqueId &e)
:VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionUniqueId() Q_DECL_NOEXCEPT_EXPR(true){}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
inline QString TagText() const {return tagText;}
inline QString TagName() const {return tagName;}
inline qint32 LineNumber() const {return lineNumber;}
protected:
QString tagText;
QString tagName;
qint32 lineNumber;
QString tagText;
QString tagName;
qint32 lineNumber;
};
#endif // VEXCEPTIONUNIQUEID_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionwrongparameterid.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,30 +24,29 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#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();
}
VExceptionWrongParameterId::VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.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

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vexceptionwrongparameterid.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,29 +24,29 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VEXCEPTIONWRONGPARAMETERID_H
#define VEXCEPTIONWRONGPARAMETERID_H
#include "vexception.h"
#include <QDomElement>
class VExceptionWrongParameterId : public VException
{
public:
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e);
virtual ~VExceptionWrongParameterId() noexcept(true){}
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e)
:VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionWrongParameterId() Q_DECL_NOEXCEPT_EXPR(true){}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
inline QString TagText() const {return tagText;}
inline QString TagName() const {return tagName;}
inline qint32 LineNumber() const {return lineNumber;}
protected:
QString tagText;
QString tagName;
qint32 lineNumber;
QString tagText;
QString tagName;
qint32 lineNumber;
};
#endif // VEXCEPTIONWRONGPARAMETERID_H

15
geometry/geometry.pri Normal file
View File

@ -0,0 +1,15 @@
HEADERS += \
geometry/vsplinepoint.h \
geometry/vsplinepath.h \
geometry/vspline.h \
geometry/vnodedetail.h \
geometry/vdetail.h \
geometry/varc.h
SOURCES += \
geometry/vsplinepoint.cpp \
geometry/vsplinepath.cpp \
geometry/vspline.cpp \
geometry/vnodedetail.cpp \
geometry/vdetail.cpp \
geometry/varc.cpp

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file varc.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,28 +24,33 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "varc.h"
#include <QDebug>
#include "../exception/vexception.h"
VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(0), points(0), mode(Draw::Calculation), idObject(0){
}
class QRectF;
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), _name(QString()){}
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), _name(QString())
{
_name = QString ("Arc_%1_%2").arg(this->GetCenterVPoint().name()).arg(radius);
}
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()), _name(arc.name()){}
VArc &VArc::operator =(const VArc &arc){
VArc &VArc::operator =(const VArc &arc)
{
this->points = arc.GetDataPoints();
this->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1();
@ -49,70 +61,52 @@ VArc &VArc::operator =(const VArc &arc){
this->center = arc.GetCenter();
this->mode = arc.getMode();
this->idObject = arc.getIdObject();
this->_name = arc.name();
return *this;
}
qreal VArc::GetF1() const{
return f1;
QPointF VArc::GetCenterPoint() const
{
return GetCenterVPoint().toQPointF();
}
QString VArc::GetFormulaF1() const{
return formulaF1;
}
qreal VArc::GetF2() const{
return f2;
}
QString VArc::GetFormulaF2() const{
return formulaF2;
}
qreal VArc::GetLength () const{
return M_PI * radius/180 * (f2-f1);
}
qreal VArc::GetRadius() const{
return radius;
}
QString VArc::GetFormulaRadius() const{
return formulaRadius;
}
qint64 VArc::GetCenter() const{
return center;
}
QPointF VArc::GetCenterPoint() const{
if(points->contains(center)){
return points->value(center).toQPointF();
} else {
qCritical()<<"Не можу знайти id = "<<center<<" в таблиці.";
throw"Не можу знайти точку за id.";
VPointF VArc::GetCenterVPoint() const
{
if (points.contains(center))
{
return points.value(center);
}
return QPointF();
else
{
QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
throw VException(error);
}
return VPointF();
}
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);
@ -122,91 +116,99 @@ 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:
throw "Кут дуги не може бути 0 градусів.";
break;
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 ){
throw "Дуга не складається з такої кількості сплайнів.";
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.);
}
}
return QVector<QPointF>();
}
Draw::Draws VArc::getMode() const{
return mode;
}
void VArc::setMode(const Draw::Draws &value){
mode = value;
}
qint64 VArc::getIdObject() const{
return idObject;
}
void VArc::setIdObject(const qint64 &value){
idObject = value;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file varc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,22 +24,28 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VARC_H
#define VARC_H
#include "vspline.h"
class QString;
class QLineF;
class QPainterPath;
class QPointF;
/**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/
class VArc{
class VArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public:
/**
* @brief VArc конструктор по замовчуванню.
*/
VArc ();
VArc ();
/**
* @brief VArc конструктор.
* @param center точка центру.
@ -40,88 +53,91 @@ public:
* @param f1 початковий кут в градусах.
* @param f2 кінцевий кут в градусах.
*/
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
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);
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
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);
/**
* @brief GetF1 повертає початковий кут дуги.
* @return повертає кут в градусах.
*/
QString GetFormulaF1 () const;
qreal GetF1 () const;
inline QString GetFormulaF1 () const {return formulaF1;}
inline qreal GetF1 () const {return f1;}
/**
* @brief GetF2 повертає кінцевий кут дуги.
* @return повертає кут в градусах.
*/
QString GetFormulaF2 () const;\
qreal GetF2 () const;
inline QString GetFormulaF2 () const {return formulaF2;}
inline qreal GetF2 () const {return f2;}
/**
* @brief GetLength повертає довжину дуги.
* @return повертає довжину дуги.
*/
qreal GetLength () const;
inline qreal GetLength () const {return M_PI * radius/180 * (f2-f1);}
/**
* @brief GetRadius повертає радіус дуги.
* @return повертає радіус дуги.
*/
QString GetFormulaRadius () const;
qreal GetRadius () const;
inline QString GetFormulaRadius () const {return formulaRadius;}
inline qreal GetRadius () const {return radius;}
/**
* @brief GetCenter повертає точку центра дуги.
* @return повертає точку центра дуги.
*/
qint64 GetCenter () const;
QPointF GetCenterPoint() const;
inline qint64 GetCenter () const {return center;}
QPointF GetCenterPoint() const;
VPointF GetCenterVPoint() const;
/**
* @brief GetP1 повертає першу точку з якої починається дуга.
* @return точку початку дуги.
*/
QPointF GetP1 () const;
QPointF GetP1 () const;
/**
* @brief GetP2 повертає другу точку в якій закінчується дуга.
* @return точку кінця дуги.
*/
QPointF GetP2 () const;
const QHash<qint64, VPointF> *GetDataPoints() const;
QPointF GetP2 () const;
const QHash<qint64, VPointF> GetDataPoints() const;
/**
* @brief GetPath будує шлях по даній дузі.
* @return повертає шлях.
*/
QPainterPath GetPath() const;
qreal AngleArc()const;
qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const;
Draw::Draws getMode() const;
void setMode(const Draw::Draws &value);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
QPainterPath GetPath() const;
qreal AngleArc() const;
qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const;
inline Draw::Draws getMode() const {return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
inline qint64 getIdObject() const {return idObject;}
inline void setIdObject(const qint64 &value) {idObject = value;}
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
private:
/**
* @brief f1 початковий кут в градусах
*/
qreal f1; // початковий кут нахилу дуги (градуси)
QString formulaF1;
qreal f1; // початковий кут нахилу дуги (градуси)
QString formulaF1;
/**
* @brief f2 кінцевий кут в градусах
*/
qreal f2; // кінцевий кут нахилу дуги (градуси)
QString formulaF2;
qreal f2; // кінцевий кут нахилу дуги (градуси)
QString formulaF2;
/**
* @brief radius радіус дуги.
*/
qreal radius;
QString formulaRadius;
qreal radius;
QString formulaRadius;
/**
* @brief center центральна точка дуги.
*/
qint64 center;
const QHash<qint64, VPointF> *points;
Draw::Draws mode;
qint64 idObject;
qint64 center;
QHash<qint64, VPointF> points;
Draw::Draws mode;
qint64 idObject;
QString _name;
};
#endif // VARC_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vdetail.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,67 +24,60 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vdetail.h"
VDetail::VDetail():nodes(QVector<VNodeDetail>()),name(QString()), mx(0), my(0){
}
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){
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;
}
void VDetail::append(const VNodeDetail &node){
nodes.append(node);
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)
{
nodes = detail.getNodes();
name = detail.getName();
mx = detail.getMx();
my = detail.getMy();
supplement = detail.getSupplement();
closed = detail.getClosed();
width = detail.getWidth();
return *this;
}
void VDetail::Clear(){
void VDetail::Clear()
{
nodes.clear();
name.clear();
mx = 0;
my = 0;
supplement = true;
closed = true;
width = 10;
}
qint32 VDetail::CountNode() const{
return nodes.size();
}
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 [](ptrdiff_t indx)
{
return nodes[indx];
}
qreal VDetail::getMy() const{
return my;
}
void VDetail::setMy(const qreal &value){
my = value;
}
qreal VDetail::getMx() const{
return mx;
}
void VDetail::setMx(const qreal &value){
mx = value;
}
QString VDetail::getName() const{
return name;
}
void VDetail::setName(const QString &value){
name = value;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vdetail.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,17 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VDETAIL_H
#define VDETAIL_H
#include "vnodedetail.h"
#include <QVector>
#include <QString>
#include <QPainterPath>
namespace Detail {
namespace Detail
{
enum Contour { OpenContour, CloseContour };
Q_DECLARE_FLAGS(Contours, Contour)
@ -37,26 +42,40 @@ 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);
void append(const VNodeDetail &node);
void Clear();
qint32 CountNode() const;
bool Containes(const qint64 &id)const;
VNodeDetail & operator[](int indx);
QString getName() const;
void setName(const QString &value);
qreal getMx() const;
void setMx(const qreal &value);
qreal getMy() const;
void setMy(const qreal &value);
VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
VDetail(const VDetail &detail);
VDetail &operator=(const VDetail &detail);
inline void append(const VNodeDetail &node) {nodes.append(node);}
void Clear();
inline qint32 CountNode() const {return nodes.size();}
bool Containes(const qint64 &id)const;
VNodeDetail & operator[](ptrdiff_t indx);
inline QString getName() const {return name;}
inline void setName(const QString &value) {name = value;}
inline qreal getMx() const {return mx;}
inline void setMx(const qreal &value) {mx = value;}
inline qreal getMy() const {return my;}
inline void setMy(const qreal &value) {my = value;}
inline bool getSupplement() const {return supplement;}
inline void setSupplement(bool value) {supplement = value;}
inline bool getClosed() const {return closed;}
inline void setClosed(bool value) {closed = value;}
inline qreal getWidth() const {return width;}
inline void setWidth(const qreal &value) {width = value;}
inline QVector<VNodeDetail> getNodes() const {return nodes;}
inline void setNodes(const QVector<VNodeDetail> &value) {nodes = value;}
private:
QVector<VNodeDetail> nodes;
QString name;
qreal mx;
qreal my;
QString name;
qreal mx;
qreal my;
bool supplement;
bool closed;
qreal width;
};
#endif // VDETAIL_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vnodedetail.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,50 +24,28 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Calculation),
typeNode(NodeDetail::Contour){
}
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):id(id),
typeTool(typeTool), mode(mode), typeNode(typeNode){
}
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx, qreal my)
:id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), mx(mx), my(my){}
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
mode(node.getMode()), typeNode(node.getTypeNode()){
}
VNodeDetail::VNodeDetail(const VNodeDetail &node)
:id(node.getId()), typeTool(node.getTypeTool()), mode(node.getMode()), typeNode(node.getTypeNode()),
mx(node.getMx()), my(node.getMy()){}
Tool::Tools VNodeDetail::getTypeTool() const{
return typeTool;
}
void VNodeDetail::setTypeTool(const Tool::Tools &value){
typeTool = value;
}
qint64 VNodeDetail::getId() const{
return id;
}
void VNodeDetail::setId(const qint64 &value){
id = value;
}
Draw::Draws VNodeDetail::getMode() const{
return mode;
}
void VNodeDetail::setMode(const Draw::Draws &value){
mode = value;
}
NodeDetail::NodeDetails VNodeDetail::getTypeNode() const{
return typeNode;
}
void VNodeDetail::setTypeNode(const NodeDetail::NodeDetails &value){
typeNode = value;
VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node)
{
id = node.getId();
typeTool = node.getTypeTool();
mode = node.getMode();
typeNode = node.getTypeNode();
mx = node.getMx();
my = node.getMy();
return *this;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vnodedetail.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,15 +24,16 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VNODEDETAIL_H
#define VNODEDETAIL_H
#include <QMetaType>
#include "options.h"
#include "../options.h"
namespace NodeDetail {
namespace NodeDetail
{
enum NodeDetail { Contour, Modeling };
Q_DECLARE_FLAGS(NodeDetails, NodeDetail)
}
@ -34,23 +42,30 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails)
class VNodeDetail
{
public:
VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
VNodeDetail(const VNodeDetail &node);
qint64 getId() const;
void setId(const qint64 &value);
Tool::Tools getTypeTool() const;
void setTypeTool(const Tool::Tools &value);
Draw::Draws getMode() const;
void setMode(const Draw::Draws &value);
NodeDetail::NodeDetails getTypeNode() const;
void setTypeNode(const NodeDetail::NodeDetails &value);
VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx = 0, qreal my = 0);
VNodeDetail(const VNodeDetail &node);
VNodeDetail &operator=(const VNodeDetail &node);
inline qint64 getId() const {return id;}
inline void setId(const qint64 &value) {id = value;}
inline Tool::Tools getTypeTool() const {return typeTool;}
inline void setTypeTool(const Tool::Tools &value) {typeTool = value;}
inline Draw::Draws getMode() const {return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
inline NodeDetail::NodeDetails getTypeNode() const {return typeNode;}
inline void setTypeNode(const NodeDetail::NodeDetails &value) {typeNode = value;}
inline qreal getMx() const {return mx;}
inline void setMx(const qreal &value) {mx = value;}
inline qreal getMy() const {return my;}
inline void setMy(const qreal &value) {my = value;}
private:
qint64 id;
Tool::Tools typeTool;
Draw::Draws mode;
qint64 id;
Tool::Tools typeTool;
Draw::Draws mode;
NodeDetail::NodeDetails typeNode;
qreal mx;
qreal my;
};
Q_DECLARE_METATYPE(VNodeDetail)

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,36 +24,40 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vspline.h"
#include <QDebug>
VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
kCurve(1), points(0), 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), _name(QString()){}
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()), _name(spline.name()){}
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), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
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), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
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;
@ -63,7 +74,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());
@ -74,7 +85,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 (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, const qreal &kCurve)
{
this->p1 = p1;
this->p2 = p2;
this->p3 = p3;
@ -91,7 +103,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 );
@ -124,77 +136,48 @@ void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCu
// p4 = QPointF(p4.x()+mx, p4.y()+my);
//}
qint64 VSpline::GetP1 () const{
return p1;
}
VPointF VSpline::GetPointP1() const{
if(points->contains(p1)){
return points->value(p1);
} else {
VPointF VSpline::GetPointP1() const
{
if (points.contains(p1))
{
return points.value(p1);
}
else
{
qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці.";
throw"Не можу знайти точку за id.";
throw "Не можу знайти точку за id.";
}
return VPointF();
}
QPointF VSpline::GetP2 () const{
return p2;
}
QPointF VSpline::GetP3 () const{
return p3;
}
qint64 VSpline::GetP4() const{
return p4;
}
VPointF VSpline::GetPointP4() const{
if(points->contains(p4)){
return points->value(p4);
} else {
VPointF VSpline::GetPointP4() const
{
if (points.contains(p4))
{
return points.value(p4);
}
else
{
qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці.";
throw"Не можу знайти точку за id.";
throw "Не можу знайти точку за id.";
}
return VPointF();
}
qreal VSpline::GetAngle1() const{
return angle1;
}
qreal VSpline::GetAngle2 () const{
return angle2;
}
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());
}
qreal VSpline::GetKasm1() const{
return kAsm1;
}
qreal VSpline::GetKasm2() const{
return kAsm2;
}
qreal VSpline::GetKcurve() const{
return kCurve;
}
const QHash<qint64, VPointF> *VSpline::GetDataPoints() const{
return points;
}
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 () );
@ -209,10 +192,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;
}
@ -277,7 +262,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);
@ -301,7 +287,8 @@ QVector<QPointF> VSpline::GetPoints () const{
// }
}
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4){
QVector<QPointF> VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
{
QVector<QPointF> pvector;
QVector<qreal> x;
QVector<qreal> y;
@ -313,36 +300,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{
/*QVector<qreal> px;
QVector<qreal> py;
QVector<qreal>& wpx = px;
QVector<qreal>& wpy = py;
px.append ( p1.x () );
py.append ( p1.y () );
PointBezier_r ( p1.x (), p1.y (), p2.x (), p2.y (),
p3.x (), p3.y (), p4.x (), p4.y (), 0, wpx, wpy);
px.append ( p4.x () );
py.append ( p4.y () );
qint32 i = 0;
qreal length = 0.0;
*
* Наприклад маємо 10 точок. Від 0 до 9 і останню точку не опрацьовуємо.
* Тому від 0 до 8(<10-1).
*
for ( i = 0; i < px.count() - 1; ++i ){
length += QLineF ( QPointF ( px[i], py[i] ), QPointF ( px[i+1], py[i+1] ) ).length ();
}*/
qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPointF &p3, const 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();
@ -350,9 +321,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;
@ -362,7 +334,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;
}
@ -388,221 +360,246 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
double dx = x4-x1;
double dy = y4-y1;
double d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx));
double d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx));
double d2 = fabs((x2 - x4) * dy - (y2 - y4) * dx);
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.000000001)
{
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 || 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 || 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 || 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;
default:
break;
}
// Continue subdivision
@ -611,24 +608,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 ();
splinePath.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){
splinePath.lineTo(points[i]);
if (points.count() >= 2)
{
for (qint32 i = 0; i < points.count()-1; ++i)
{
splinePath.moveTo(points[i]);
splinePath.lineTo(points[i+1]);
}
}
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:
@ -642,62 +648,62 @@ QPainterPath VSpline::GetPath() const{
2 - 1 real root + complex roots imaginary part is zero
(i.e. 2 real roots).
*/
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;
q3 = pow(q,3);
if(r2<q3) {
qreal t = acos(r/sqrt(q3));
a/=3.;
q = -2.*sqrt(q);
x[0] = q*cos(t/3.)-a;
x[1] = q*cos((t + M_2PI)/3.) - a;
x[2] = q*cos((t - M_2PI)/3.) - a;
return(3);
} else {
qreal aa,bb;
if(r<=0.){
r=-r;
}
aa = -pow(r + sqrt(r2-q3),1./3.);
if(aa!=0.){
bb=q/aa;
} else {
bb=0.;
}
a/=3.;
q = aa+bb;
r = aa-bb;
x[0] = q-a;
x[1] = (-0.5)*q-a;
x[2] = (sqrt(3.)*0.5)*fabs(r);
if(x[2]==0.){
return(2);
}
return(1);
}
}
//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;
// q3 = pow(q,3);
// if(r2<q3) {
// qreal t = acos(r/sqrt(q3));
// a/=3.;
// q = -2.*sqrt(q);
// x[0] = q*cos(t/3.)-a;
// x[1] = q*cos((t + M_2PI)/3.) - a;
// x[2] = q*cos((t - M_2PI)/3.) - a;
// return(3);
// } else {
// qreal aa,bb;
// if(r<=0.){
// r=-r;
// }
// aa = -pow(r + sqrt(r2-q3),1./3.);
// if(aa!=0.){
// bb=q/aa;
// } else {
// bb=0.;
// }
// a/=3.;
// q = aa+bb;
// r = aa-bb;
// x[0] = q-a;
// x[1] = (-0.5)*q-a;
// x[2] = (sqrt(3.)*0.5)*fabs(r);
// if(x[2]==0.){
// return(2);
// }
// 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 {
@ -707,7 +713,7 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// * Повертається три значення, але експереминтально знайдено що шукане
// * значення знаходиться в третьому.
// */
//
// free(t);
// if(ret_t<0 || ret_t>1){
// qDebug()<<"Неправильне значення параметра. фунція calc_t";
@ -731,7 +737,7 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// else
// return t_y;
//}
//
//void VSpline::Mirror(const QPointF Pmirror){
// QPointF P1 = p1;
// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y());
@ -752,20 +758,13 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// this->ModifiSpl(P1, P2, P3, P4);
//}
Draw::Draws VSpline::getMode() const{
return mode;
}
void VSpline::setMode(const Draw::Draws &value){
mode = value;
}
QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve){
QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
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);
@ -776,15 +775,8 @@ QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qre
return GetPoints(p1, p2, p3, p4);
}
qint64 VSpline::getIdObject() const{
return idObject;
}
void VSpline::setIdObject(const qint64 &value){
idObject = value;
}
VSpline &VSpline::operator =(const VSpline &spline){
VSpline &VSpline::operator =(const VSpline &spline)
{
this->p1 = spline.GetP1 ();
this->p2 = spline.GetP2 ();
this->p3 = spline.GetP3 ();
@ -797,5 +789,6 @@ VSpline &VSpline::operator =(const VSpline &spline){
this->points = spline.GetDataPoints();
this->mode = spline.getMode();
this->idObject = spline.getIdObject();
this->_name = spline.name();
return *this;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,29 +24,29 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VSPLINE_H
#define VSPLINE_H
#define M_2PI 6.28318530717958647692528676655900576
#include "../container/vpointf.h"
#include <QPainterPath>
#include <QVector>
#include <QHash>
#include "container/vpointf.h"
class QString;
#define M_2PI 6.28318530717958647692528676655900576
/**
* @brief VSpline клас, що реалізує сплайн.
*/
class VSpline{
class VSpline
{
public:
VSpline();
VSpline();
/**
* @brief VSpline конструктор.
* @param spline сплайн з якого копіюємо.
*/
VSpline (const VSpline &spline );
VSpline (const VSpline &spline );
/**
* @brief VSpline конструктор.
* @param p1 початкова точка сплайна.
@ -50,9 +57,9 @@ public:
* @param kAsm1 коефіцієнт довжини першої напрямної.
* @param kAsm2 коефіцієнт довжини другої напрямної.
*/
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation,
qint64 idObject = 0);
/**
* @brief VSpline конструктор.
* @param p1 початкова точка сплайну.
@ -60,9 +67,8 @@ public:
* @param p3 друга контролююча точка сплайну.
* @param p4 кінцева точка сплайну.
*/
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3,
qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation,
qint64 idObject = 0);
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
/**
* @brief ModifiSpl модифікує сплайн.
* @param p1 початкова точка сплайну.
@ -73,7 +79,7 @@ public:
* @param kAsm1 коефіцієнт довжини першої напрямної.
* @param kAsm2 коефіцієнт довжини другої напрямної.
*/
void ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
void ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kCurve);
/**
* @brief ModifiSpl модифікує сплайн.
@ -82,61 +88,62 @@ public:
* @param p3 друга контролююча точка сплайну.
* @param p4 кінцева точка сплайну.
*/
void ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve);
void ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4,
const qreal &kCurve);
/**
* @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки.
* @param pRotate точка навколо якої повертаємо.
* @param angle кут в градусах.
*/
// void RotationSpl ( QPointF pRotate, qreal angle );
// void RotationSpl ( QPointF pRotate, qreal angle );
/**
* @brief BiasSpl зміщує сплайн.
* @param mx зміщення по х координаті.
* @param my зміщення по у координаті.
*/
// void BiasSpl ( qreal mx, qreal my );
// void BiasSpl ( qreal mx, qreal my );
/**
* @brief GetP1 повертає першу точку сплайну.
* @return перша точка сплайну.
*/
qint64 GetP1 () const;
VPointF GetPointP1() const;
qint64 GetP1 () const {return p1;}
VPointF GetPointP1() const;
/**
* @brief GetP2 повертує першу контрольну точку сплайну.
* @return перша контрольна точка сплайну.
*/
QPointF GetP2 () const;
inline QPointF GetP2 () const {return p2;}
/**
* @brief GetP3 повертає другу контрольну точку сплайну.
* @return друга контрольна точка сплайну.
*/
QPointF GetP3 () const;
inline QPointF GetP3 () const {return p3;}
/**
* @brief GetP4 повертає останню точку сплайну.
* @return остання точка сплайну.
*/
qint64 GetP4 () const;
VPointF GetPointP4 () const;
inline qint64 GetP4 () const {return p4;}
VPointF GetPointP4 () const;
/**
* @brief GetAngle1 повертає кут першої напрямної.
* @return кут в градусах.
*/
qreal GetAngle1 () const;
inline qreal GetAngle1 () const {return angle1;}
/**
* @brief GetAngle2 повертає кут другої напрямної.
* @return кут в градусах.
*/
qreal GetAngle2() const;
inline qreal GetAngle2() const {return angle2;}
/**
* @brief GetLength повертає довжину сплайну.
* @return довжина сплайну.
*/
qreal GetLength () const;
QString GetName () const;
qreal GetKasm1() const;
qreal GetKasm2() const;
qreal GetKcurve() const;
const QHash<qint64, VPointF> *GetDataPoints() const;
qreal GetLength () const;
QString GetName () const;
inline qreal GetKasm1() const {return kAsm1;}
inline qreal GetKasm2() const {return kAsm2;}
inline qreal GetKcurve() const {return kCurve;}
inline const QHash<qint64, VPointF> GetDataPoints() const {return points;}
/**
* @brief CrossingSplLine перевіряє перетин сплайну з лінією.
* @param line лінія з якою перевіряється перетин.
@ -150,20 +157,20 @@ public:
* @param curFir перший сплайн.
* @param curSec другий сплайн.
*/
// void CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const;
// void CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const;
/**
* @brief CutSpline розрізає сплайн.
* @param point точка що ділить сплайн.
* @param curFir перший сплайн.
* @param curSec другий сплайн.
*/
// void CutSpline (QPointF point, VSpline* curFir, VSpline* curSec ) const;
// void CutSpline (QPointF point, VSpline* curFir, VSpline* curSec ) const;
/**
* @brief PutAlongSpl розміщає точку на сплайні.
* @param moveP точка яка розміщується на сплайні.
* @param move довжина від початку сплайну.
*/
// void PutAlongSpl ( QPointF &moveP, qreal move ) const;
// void PutAlongSpl ( QPointF &moveP, qreal move ) const;
/**
* @brief GetPoints повертає точки з яких складається сплайн.
* @return список точок.
@ -173,19 +180,21 @@ public:
* @brief GetPath повертає шлях сплайну.
* @return шлях.
*/
QPainterPath GetPath() const;
QPainterPath GetPath() const;
/**
* @brief Mirror вертикальне дзеркалення сплайну відносно точки.
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/
// void Mirror(const QPointF Pmirror);
Draw::Draws getMode() const;
void setMode(const Draw::Draws &value);
static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
VSpline &operator=(const VSpline &spl);
// void Mirror(const QPointF Pmirror);
inline Draw::Draws getMode() const {return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve);
inline qint64 getIdObject() const {return idObject;}
inline void setIdObject(const qint64 &value) {idObject = value;}
VSpline &operator=(const VSpline &spl);
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
protected:
/**
* @brief GetPoints повертає точки з яких складається сплайн.
@ -195,38 +204,39 @@ protected:
* @param p4 кінцева точка сплайну.
* @return список точок.
*/
static QVector<QPointF> GetPoints ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 );
static QVector<QPointF> GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 );
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 kAsm1;
qreal kAsm2;
qreal kCurve;
const QHash<qint64, VPointF> *points;
Draw::Draws mode;
qint64 idObject;
qreal angle2; // кут нахилу дотичної в другій точці
qreal kAsm1;
qreal kAsm2;
qreal kCurve;
QHash<qint64, VPointF> points;
Draw::Draws mode;
qint64 idObject;
QString _name;
/**
* @brief LengthBezier повертає дожину сплайну за його чотирьма точками.
* @param p1 початкова точка сплайну.
@ -235,7 +245,7 @@ private:
* @param p4 кінцева точка сплайну.
* @return дожина сплайну.
*/
qreal LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) const;
qreal LengthBezier (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ) const;
/**
* @brief PointBezier_r знаходить точки сплайну по його чотирьом точках.
* @param x1 х координата першої точки сплайну.
@ -250,9 +260,8 @@ private:
* @param px список х координат точок сплайну.
* @param py список у коодринат сплайну.
*/
static void 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);
static void 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);
/**
* @brief CalcSqDistance розраховує довжину між точками.
* @param x1 х координата першої точки.
@ -261,16 +270,16 @@ private:
* @param y2 у координата другої точки.
* @return довжину.
*/
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
/**
* @brief Cubic знаходить розв'язок кубічного рівняння.
* @param x коефіцієнт.
* @param a коефіцієнт.
* @param b коефіцієнт.
* @param c коефіцієнт.
* @return повертає корені рівняння.
*/
static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c);
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
// /**
// * @brief Cubic знаходить розв'язок кубічного рівняння.
// * @param x коефіцієнт.
// * @param a коефіцієнт.
// * @param b коефіцієнт.
// * @param c коефіцієнт.
// * @return повертає корені рівняння.
// */
// static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c);
/**
* @brief calc_t знаходить параметр t якому відповідає точка на сплайні.
* @param curve_coord1 координата Х або У кривої.
@ -280,14 +289,14 @@ private:
* @param point_coord координата Х або У точки на кривій.
* @return
*/
// static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3,
// qreal curve_coord4, qreal point_coord)const;
// static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, qreal curve_coord4,
// qreal point_coord)const;
/**
* @brief param_t знаходить підходяще значення параметра t якому відповідає точка на сплайні
* @param pBt точка для якої шукається значення параметра t.
* @return підходяще значення t.
*/
// qreal param_t (QPointF pBt)const;
// qreal param_t (QPointF pBt)const;
};
#endif // VSPLINE_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,156 +24,148 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vsplinepath.h"
#include "exception/vexception.h"
#include "../exception/vexception.h"
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(0),
idObject(0){
}
VSplinePath::VSplinePath()
: path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(QHash<qint64, VPointF>()), idObject(0),
_name(QString()){}
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), _name(QString())
{}
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()), _name(splPath.name()){}
Draw::Draws VSplinePath::getMode() const{
return mode;
}
void VSplinePath::setMode(const Draw::Draws &value){
mode = value;
}
void VSplinePath::append(VSplinePoint point){
void VSplinePath::append(const VSplinePoint &point)
{
path.append(point);
_name = QString("SplPath");
for (qint32 i = 1; i <= this->Count(); ++i)
{
VSpline spl = this->GetSpline(i);
VPointF first = spl.GetPointP1();
VPointF second = spl.GetPointP4();
QString splName = QString("_%1_%2").arg(first.name(), second.name());
_name.append(splName);
}
}
qint32 VSplinePath::Count() const{
if(path.size() == 0){
qint32 VSplinePath::Count() const
{
if (path.size() == 0)
{
return 0;
} else {
}
else
{
return path.size() - 1;
}
}
qint32 VSplinePath::CountPoint() const{
return path.size();
}
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(),
VSpline spl(&points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
return spl;
}
QPainterPath VSplinePath::GetPath() const{
QPainterPath VSplinePath::GetPath() const
{
QPainterPath painterPath;
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);
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());
}
return painterPath;
}
QVector<QPointF> VSplinePath::GetPathPoints() const{
QVector<QPointF> VSplinePath::GetPathPoints() const
{
QVector<QPointF> pathPoints;
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);
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;
}
QVector<VSplinePoint> VSplinePath::GetSplinePath() const{
return path;
}
qreal VSplinePath::GetLength() const{
qreal VSplinePath::GetLength() const
{
qreal length = 0;
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(),
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();
}
return length;
}
const QHash<qint64, VPointF> *VSplinePath::GetDataPoints() const{
return points;
}
void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point){
if(indexSpline < 1 || indexSpline > Count()){
void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const 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);
}
}
void VSplinePath::Clear(){
path.clear();
}
qreal VSplinePath::getKCurve() const{
return kCurve;
}
void VSplinePath::setKCurve(const qreal &value){
kCurve = value;
}
const QVector<VSplinePoint> *VSplinePath::GetPoint() const{
return &path;
}
VSplinePath &VSplinePath::operator =(const VSplinePath &path){
VSplinePath &VSplinePath::operator =(const VSplinePath &path)
{
this->path = path.GetSplinePath();
this->kCurve = path.getKCurve();
this->mode = path.getMode();
this->points = path.GetDataPoints();
this->idObject = path.getIdObject();
this->_name = path.name();
return *this;
}
VSplinePoint & VSplinePath::operator[](int indx){
VSplinePoint & VSplinePath::operator[](ptrdiff_t indx)
{
return path[indx];
}
qint64 VSplinePath::getIdObject() const{
return idObject;
}
void VSplinePath::setIdObject(const qint64 &value){
idObject = value;
}

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,76 +24,81 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#ifndef VSPLINEPATH_H
#define VSPLINEPATH_H
#include "vsplinepoint.h"
#include "../container/vpointf.h"
#include "vspline.h"
#include <QCoreApplication>
#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:
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
VSplinePath();
VSplinePath();
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const VSplinePath& splPath);
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const VSplinePath& splPath);
/**
* @brief append додає точку сплайну до шляху.
* @param point точка.
*/
void append(VSplinePoint point);
qint32 Count() const;
qint32 CountPoint() const;
VSpline GetSpline(qint32 index) const;
QPainterPath GetPath() const;
QVector<QPointF> GetPathPoints() const;
QVector<VSplinePoint> GetSplinePath() const;
qreal GetLength() const;
const QHash<qint64, VPointF> *GetDataPoints() const;
void UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point);
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const;
void append(const VSplinePoint &point);
qint32 Count() const;
inline qint32 CountPoint() const {return path.size();}
VSpline GetSpline(qint32 index) const;
QPainterPath GetPath() const;
QVector<QPointF> GetPathPoints() const;
inline QVector<VSplinePoint> GetSplinePath() const {return path;}
qreal GetLength() const;
inline QHash<qint64, VPointF> GetDataPoints() const {return points;}
void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point);
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const;
/**
* @brief Clear очищає шлях сплайнів.
*/
void Clear();
qreal getKCurve() const;
void setKCurve(const qreal &value);
const QVector<VSplinePoint> *GetPoint() const;
VSplinePath& operator=(const VSplinePath &path);
VSplinePoint & operator[](int indx);
Draw::Draws getMode() const;
void setMode(const Draw::Draws &value);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
inline void Clear() {path.clear();}
inline qreal getKCurve() const {return kCurve;}
inline void setKCurve(const qreal &value) {kCurve = value;}
inline const QVector<VSplinePoint> *GetPoint() const {return &path;}
VSplinePath &operator=(const VSplinePath &path);
VSplinePoint &operator[](ptrdiff_t indx);
inline Draw::Draws getMode() const {return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
inline qint64 getIdObject() const {return idObject;}
inline void setIdObject(const qint64 &value) {idObject = value;}
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
protected:
/**
* @brief path вектор з точок сплайна.
*/
QVector<VSplinePoint> path;
qreal kCurve;
Draw::Draws mode;
const QHash<qint64, VPointF> *points;
qint64 idObject;
qreal kCurve;
Draw::Draws mode;
QHash<qint64, VPointF> points;
qint64 idObject;
QString _name;
};
#endif // VSPLINEPATH_H

View File

@ -1,15 +1,22 @@
/****************************************************************************
/************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
** @file vsplinepoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** This file is part of Valentina.
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Tox is free software: you can redistribute it and/or modify
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
@ -17,56 +24,15 @@
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
*************************************************************************/
#include "vsplinepoint.h"
VSplinePoint::VSplinePoint():pSpline(0), angle(0), kAsm1(1), kAsm2(1){
}
VSplinePoint::VSplinePoint()
:pSpline(0), angle(0), kAsm1(1), kAsm2(1){}
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle , qreal kAsm2):pSpline(pSpline),
angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){
}
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2)
:pSpline(pSpline), angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){}
VSplinePoint::VSplinePoint(const VSplinePoint &point):pSpline(point.P()), angle(point.Angle2()),
kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){
}
VSplinePoint::~VSplinePoint(){
}
qint64 VSplinePoint::P() const{
return pSpline;
}
void VSplinePoint::SetP(const qint64 &value){
pSpline = value;
}
qreal VSplinePoint::Angle1() const{
return angle+180;
}
void VSplinePoint::SetAngle(const qreal &value){
angle = value;
}
qreal VSplinePoint::Angle2() const{
return angle;
}
qreal VSplinePoint::KAsm1() const{
return kAsm1;
}
void VSplinePoint::SetKAsm1(const qreal &value){
kAsm1 = value;
}
qreal VSplinePoint::KAsm2() const{
return kAsm2;
}
void VSplinePoint::SetKAsm2(const qreal &value){
kAsm2 = value;
}
VSplinePoint::VSplinePoint(const VSplinePoint &point)
:pSpline(point.P()), angle(point.Angle2()), kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){}

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