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. # Ignore file used QtCreator for user profile.
*.pro.user *.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 QT += core gui widgets xml svg
TARGET = Valentina
TEMPLATE = app TEMPLATE = app
DEBUG_TARGET = Valentinad
RELEASE_TARGET = Valentina
CONFIG -= debug_and_release debug_and_release_target CONFIG -= debug_and_release debug_and_release_target
CONFIG += c++11 CONFIG += c++11 precompile_header
SOURCES += main.cpp\ #DEFINES += ...
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
HEADERS += mainwindow.h \ # Precompiled headers (PCH)
widgets/vmaingraphicsscene.h \ PRECOMPILED_HEADER = stable.h
dialogs/dialogsinglepoint.h \ win32-msvc* {
options.h \ PRECOMPILED_SOURCE = stable.cpp
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
# directory for executable file # directory for executable file
DESTDIR = bin DESTDIR = bin
@ -226,28 +39,65 @@ RCC_DIR = rcc
# files created uic # files created uic
UI_DIR = uic UI_DIR = uic
# Use Precompiled headers (PCH) include(container/container.pri)
PRECOMPILED_HEADER = stable.h 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 += translations/valentina_ru.ts \
translations/valentina_uk.ts translations/valentina_uk.ts
CONFIG(debug, debug|release){ CONFIG(debug, debug|release){
# Debug # Debug
QMAKE_CXX = ccache g++
TARGET = $$DEBUG_TARGET
QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtWidgets" \ 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/QtXml" -isystem "/usr/include/qt5/QtGui" \
-isystem "/usr/include/qt5/QtCore" -isystem "$$OUT_PWD/uic" -isystem "$$OUT_PWD/moc/" \ -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 \ -Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \ -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{ }else{
# Release # Release
TARGET = $$RELEASE_TARGET
QMAKE_CXXFLAGS += -O1 QMAKE_CXXFLAGS += -O1
DEFINES += QT_NO_DEBUG_OUTPUT
QMAKE_EXTRA_COMPILERS += lrelease QMAKE_EXTRA_COMPILERS += lrelease
lrelease.input = TRANSLATIONS lrelease.input = TRANSLATIONS
lrelease.output = ${QMAKE_FILE_BASE}.qm 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 lrelease.CONFIG += no_link target_predeps
} }
@ -263,5 +113,3 @@ message(Data files: $$[QT_INSTALL_DATA])
message(Translation files: $$[QT_INSTALL_TRANSLATIONS]) message(Translation files: $$[QT_INSTALL_TRANSLATIONS])
message(Settings: $$[QT_INSTALL_SETTINGS]) message(Settings: $$[QT_INSTALL_SETTINGS])
message(Examples: $$[QT_INSTALL_EXAMPLES]) 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "calculator.h" #include "calculator.h"
#include <QDebug> #include <QDebug>
@ -31,11 +38,8 @@
#define FINISHED 10 #define FINISHED 10
#define EOL 9 #define EOL 9
Calculator::Calculator(const VContainer *data):errorMsg(0), token(QString()), tok(0), token_type(0), qreal Calculator::eval(QString prog, QString *errorMsg)
prog(QString()), index(0), data(data), debugFormula(QString()){ {
}
qreal Calculator::eval(QString prog, QString *errorMsg){
this->errorMsg = errorMsg; this->errorMsg = errorMsg;
this->errorMsg->clear(); this->errorMsg->clear();
debugFormula.clear(); debugFormula.clear();
@ -49,10 +53,12 @@ qreal Calculator::eval(QString prog, QString *errorMsg){
return result; return result;
} }
qreal Calculator::get_exp(){ qreal Calculator::get_exp()
{
qreal result = 0; qreal result = 0;
get_token(); get_token();
if(token.isEmpty()) { if (token.isEmpty())
{
serror(2); serror(2);
return 0; return 0;
} }
@ -61,69 +67,86 @@ qreal Calculator::get_exp(){
return result; return result;
} }
void Calculator::level2(qreal *result){
void Calculator::level2(qreal *result)
{
QChar op; QChar op;
qreal hold; qreal hold;
level3(result); level3(result);
while((op=token[0]) == '+' || op == '-') { while ((op=token[0]) == '+' || op == '-')
{
get_token(); get_token();
level3(&hold); level3(&hold);
arith(op, result, &hold); arith(op, result, &hold);
} }
} }
void Calculator::level3(qreal *result){ void Calculator::level3(qreal *result)
{
QChar op; QChar op;
qreal hold; qreal hold;
level4(result); level4(result);
while((op = token[0]) == '*' || op == '/' || op == '%') { while ((op = token[0]) == '*' || op == '/' || op == '%')
{
get_token(); get_token();
level4(&hold); level4(&hold);
arith(op, result, &hold); arith(op, result, &hold);
} }
} }
void Calculator::level4(qreal *result){ void Calculator::level4(qreal *result)
{
qreal hold; qreal hold;
level5(result); level5(result);
if(token[0] == '^') { if (token[0] == '^')
{
get_token(); get_token();
level4(&hold); level4(&hold);
arith('^', result, &hold); arith('^', result, &hold);
} }
} }
void Calculator::level5(qreal *result){ void Calculator::level5(qreal *result)
{
QChar op; QChar op;
op = '\0'; op = '\0';
if((token_type==DELIMITER) && (token[0]=='+' || token[0]=='-')) { if ((token_type==DELIMITER) && (token[0]=='+' || token[0]=='-'))
{
op = token[0]; op = token[0];
get_token(); get_token();
} }
level6(result); level6(result);
if (op != '\0') if (op != '\0')
{
unary(op, result); unary(op, result);
} }
}
void Calculator::level6(qreal *result){ void Calculator::level6(qreal *result)
if((token[0] == '(') && (token_type == DELIMITER)) { {
if ((token[0] == '(') && (token_type == DELIMITER))
{
get_token(); get_token();
level2(result); level2(result);
if (token[0] != ')') if (token[0] != ')')
{
serror(1); serror(1);
}
get_token(); get_token();
} else } else
primitive(result); primitive(result);
} }
void Calculator::primitive(qreal *result){ void Calculator::primitive(qreal *result)
{
QString str; QString str;
switch(token_type) { switch (token_type)
{
case VARIABLE: case VARIABLE:
*result = find_var(token); *result = find_var(token);
str = QString("%1").arg(*result, 0, 'f', 3); str = QString("%1").arg(*result, 0, 'f', 3);
@ -141,10 +164,12 @@ void Calculator::primitive(qreal *result){
} }
} }
void Calculator::arith(QChar o, qreal *r, qreal *h){ void Calculator::arith(QChar o, qreal *r, qreal *h)
qreal t; {
qreal t;//, ex;
switch(o.toLatin1()) { switch (o.toLatin1())
{
case '-': case '-':
*r = *r-*h; *r = *r-*h;
break; break;
@ -164,18 +189,25 @@ void Calculator::arith(QChar o, qreal *r, qreal *h){
case '^': case '^':
*r = pow(*r, *h); *r = pow(*r, *h);
break; break;
default:
break;
} }
} }
void Calculator::unary(QChar o, qreal *r){ void Calculator::unary(QChar o, qreal *r)
{
if (o=='-') if (o=='-')
{
*r = -(*r); *r = -(*r);
} }
}
qreal Calculator::find_var(QString s){ qreal Calculator::find_var(QString s)
{
bool ok = false; bool ok = false;
qreal value = data->FindVar(s, &ok); qreal value = data->FindVar(s, &ok);
if(!ok){ if (ok == false)
{
qDebug()<<s; qDebug()<<s;
serror(4); /* don't variable */ serror(4); /* don't variable */
return 0; return 0;
@ -183,20 +215,23 @@ qreal Calculator::find_var(QString s){
return value; return value;
} }
void Calculator::serror(qint32 error){ void Calculator::serror(qint32 error)
QString e[]= { {
tr("Syntax error"), QString e[]=
tr("Parentheses do not match"), {
tr("This is not an expression"), "Синтаксическая ошибка",
tr("It is assumed the equality symbol"), "Непарные круглые скобки",
tr("Do not variable") "Это не выражение",
"Предполагается символ равенства",
"Не переменная"
}; };
errorMsg->clear(); errorMsg->clear();
*errorMsg = e[error]; *errorMsg = e[error];
qDebug()<<e[error]; qDebug()<<e[error];
} }
char Calculator::look_up(QString s){ char Calculator::look_up(QString s)
{
QString p; QString p;
p = s; p = s;
@ -205,36 +240,50 @@ char Calculator::look_up(QString s){
return 0; return 0;
} }
bool Calculator::isdelim(QChar c){ bool Calculator::isdelim(QChar c)
{
if (StrChr(" ;,+-<>/*%^=()", c) || c=='\n' || c=='\r' || c=='\0') if (StrChr(" ;,+-<>/*%^=()", c) || c=='\n' || c=='\r' || c=='\0')
{
return true; return true;
}
return false; return false;
} }
bool Calculator::iswhite(QChar c){ bool Calculator::iswhite(QChar c)
{
if (c==' ' || c=='\t') if (c==' ' || c=='\t')
{
return true; return true;
}
else else
{
return false; return false;
} }
}
void Calculator::get_token(){ void Calculator::get_token()
{
QString *temp; QString *temp;
token_type=0; tok=0; token_type=0; tok=0;
token.clear(); token.clear();
temp=&token; temp=&token;
if(prog[index]=='\0') { /* end of file */ if (prog[index]=='\0')
{ /* end of file */
token="\0"; token="\0";
tok=FINISHED; tok=FINISHED;
token_type=DELIMITER; token_type=DELIMITER;
return; 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; ++index; ++index;
tok= EOL; token='\r'; tok= EOL; token='\r';
token.append('\n');token.append("\0"); token.append('\n');token.append("\0");
@ -242,7 +291,8 @@ void Calculator::get_token(){
return; return;
} }
if(StrChr("+-*^/%=;(),><", prog[index])) { /* delimiter */ if (StrChr("+-*^/%=;(),><", prog[index]))
{ /* delimiter */
*temp=prog[index]; *temp=prog[index];
index++; /* jump to the next position */ index++; /* jump to the next position */
temp->append("\0"); temp->append("\0");
@ -250,20 +300,26 @@ void Calculator::get_token(){
debugFormula.append(token); debugFormula.append(token);
return; return;
} }
if(prog[index]=='"') { /* quoted string */ if (prog[index]=='"')
{ /* quoted string */
index++; index++;
while(prog[index] != '"' && prog[index] != '\r'){ while (prog[index] != '"' && prog[index] != '\r')
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
if (prog[index]=='\r') if (prog[index]=='\r')
{
serror(1); serror(1);
}
index++;temp->append("\0"); index++;temp->append("\0");
token_type=QUOTE; token_type=QUOTE;
return; return;
} }
if(prog[index].isDigit()) { /* number */ if (prog[index].isDigit())
while(!isdelim(prog[index])){ { /* number */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
@ -272,8 +328,10 @@ void Calculator::get_token(){
return; return;
} }
if(prog[index].isPrint()) { /* variable or command */ if (prog[index].isPrint())
while(!isdelim(prog[index])){ { /* variable or command */
while (isdelim(prog[index]) == false)
{
temp->append(prog[index]); temp->append(prog[index]);
index++; index++;
} }
@ -282,20 +340,28 @@ void Calculator::get_token(){
temp->append("\0"); temp->append("\0");
/* Seen if there is a command line or a variable */ /* Seen if there is a command line or a variable */
if(token_type==STRING) { if (token_type==STRING)
{
tok=look_up(token); tok=look_up(token);
if(!tok) if (tok == false)
{
token_type = VARIABLE; token_type = VARIABLE;
else token_type = COMMAND; /* It is command */ }
else
{
token_type = COMMAND; /* It is command */
}
} }
return; return;
} }
bool Calculator::StrChr(QString string, QChar c){ bool Calculator::StrChr(QString string, QChar c)
{
return string.contains(c, Qt::CaseInsensitive); return string.contains(c, Qt::CaseInsensitive);
} }
void Calculator::putback(){ void Calculator::putback()
{
QString t; QString t;
t = token; t = token;
index = index - t.size(); index = index - t.size();

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,25 +24,26 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef CALCULATOR_H #ifndef CALCULATOR_H
#define CALCULATOR_H #define CALCULATOR_H
#include <QString>
#include "vcontainer.h" #include "vcontainer.h"
/** /**
* @brief The Calculator class calculate formulas of pattern. Support operation +,-,/,* and braces. * @brief The Calculator class calculate formulas of pattern. Support operation +,-,/,* and braces.
* Can replace name of variables her value. * Can replace name of variables her value.
*/ */
class Calculator{ class Calculator
{
public: public:
/** /**
* @brief Calculator class constructor. * @brief Calculator class constructor.
* @param data pointer to a variable container. * @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. * @brief eval calculate formula.
* @param prog string of formula. * @param prog string of formula.
@ -49,7 +57,7 @@ private:
*/ */
QString *errorMsg; QString *errorMsg;
/** /**
* @brief token current token. * @brief token теперішня лексема.
*/ */
QString token; QString token;
/** /**
@ -128,7 +136,7 @@ private:
void primitive(qreal *result); void primitive(qreal *result);
/** /**
* @brief arith perform the specified arithmetic. The result is written to the first element. * @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 r first element.
* @param h second element. * @param h second element.
*/ */
@ -151,7 +159,7 @@ private:
*/ */
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. * @param s name of token.
* @return internal number of token. * @return internal number of token.
*/ */
@ -162,12 +170,17 @@ private:
* @return true - delimiter, false - do not delimiter. * @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. * @brief iswhite checks whether c space or tab.
* @param c character. * @param c character.
* @return true - space or tab, false - don't space and don't tab. * @return true - space or tab, false - don't space and don't tab.
*/ */
static bool iswhite(QChar c);
}; };
#endif // CALCULATOR_H #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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,24 +24,23 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VCONTAINER_H #ifndef VCONTAINER_H
#define VCONTAINER_H #define VCONTAINER_H
#include <QTableWidget>
#include "vstandarttablecell.h" #include "vstandarttablecell.h"
#include "vincrementtablerow.h" #include "vincrementtablerow.h"
#include "geometry/varc.h" #include "../geometry/varc.h"
#include "geometry/vsplinepath.h" #include "../geometry/vsplinepath.h"
#include "geometry/vdetail.h" #include "../geometry/vdetail.h"
#include "widgets/vitem.h" #include "../widgets/vitem.h"
#include <QCoreApplication>
/** /**
* @brief The VContainer class container of all variables. * @brief The VContainer class container of all variables.
*/ */
class VContainer{ class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer) Q_DECLARE_TR_FUNCTIONS(VContainer)
public: public:
/** /**
@ -77,7 +83,9 @@ public:
VStandartTableCell GetStandartTableCell(const QString& name) const; VStandartTableCell GetStandartTableCell(const QString& name) const;
VIncrementTableRow GetIncrementTableRow(const QString& name) const; VIncrementTableRow GetIncrementTableRow(const QString& name) const;
qreal GetLine(const QString &name) const; qreal GetLine(const QString &name) const;
qreal GetLineArc(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 GetSpline(qint64 id) const;
VSpline GetModelingSpline(qint64 id) const; VSpline GetModelingSpline(qint64 id) const;
VArc GetArc(qint64 id) const; VArc GetArc(qint64 id) const;
@ -85,24 +93,21 @@ public:
VSplinePath GetSplinePath(qint64 id) const; VSplinePath GetSplinePath(qint64 id) const;
VSplinePath GetModelingSplinePath(qint64 id) const; VSplinePath GetModelingSplinePath(qint64 id) const;
VDetail GetDetail(qint64 id) const; VDetail GetDetail(qint64 id) const;
static qint64 getId(); static qint64 getId() {return _id;}
qint64 AddPoint(const VPointF& point); qint64 AddPoint(const VPointF& point);
qint64 AddModelingPoint(const VPointF& point); qint64 AddModelingPoint(const VPointF& point);
qint64 AddDetail(const VDetail& detail); qint64 AddDetail(const VDetail& detail);
void AddStandartTableCell(const QString& name, inline void AddStandartTableCell(const QString& name, const VStandartTableCell& cell)
const VStandartTableCell& cell); {standartTable[name] = cell;}
void AddIncrementTableRow(const QString& name, inline void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell)
const VIncrementTableRow &cell); {incrementTable[name] = cell;}
void AddLengthLine(const QString &name, const qreal &value); 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 AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 &center, const qint64 &id); void AddLengthArc(const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value); void AddLengthArc(const QString &name, const qreal &value);
void AddLineAngle(const QString &name, const qreal &value); void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId, void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
Draw::Draws mode = Draw::Calculation); const Draw::Draws &mode = Draw::Calculation);
qint64 AddSpline(const VSpline& spl); qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl); qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath); qint64 AddSplinePath(const VSplinePath& splPath);
@ -110,16 +115,9 @@ public:
qint64 AddArc(const VArc& arc); qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc); qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const; const Draw::Draws &mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint, QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
const qint64 &secondPoint, const Draw::Draws &mode = Draw::Calculation) const;
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 UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point); void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail); void UpdateDetail(qint64 id, const VDetail& detail);
@ -129,53 +127,50 @@ public:
void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath); void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateArc(qint64 id, const VArc& arc); void UpdateArc(qint64 id, const VArc& arc);
void UpdateModelingArc(qint64 id, const VArc& arc); void UpdateModelingArc(qint64 id, const VArc& arc);
void UpdateStandartTableCell(const QString& name, inline void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell)
const VStandartTableCell& cell); {standartTable[name] = cell;}
void UpdateIncrementTableRow(const QString& name, inline void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell)
const VIncrementTableRow& cell); {incrementTable[name] = cell;}
qreal GetValueStandartTableCell(const QString& name) const; qreal GetValueStandartTableCell(const QString& name) const;
qreal GetValueIncrementTableRow(const QString& name) const; qreal GetValueIncrementTableRow(const QString& name) const;
void Clear(); void Clear();
void ClearObject(); void ClearObject();
void ClearIncrementTable(); inline void ClearIncrementTable() {incrementTable.clear();}
void ClearLengthLines(); inline void ClearLengthLines() {lengthLines.clear();}
void ClearLengthSplines(); inline void ClearLengthSplines() {lengthSplines.clear();}
void ClearLengthArcs(); inline void ClearLengthArcs() {lengthArcs.clear();}
void ClearLineAngles(); inline void ClearLineAngles() {lineAngles.clear();}
void SetSize(qint32 size); inline void SetSize(qint32 size) {base["Сг"] = size;}
void SetGrowth(qint32 growth); inline void SetGrowth(qint32 growth) {base["Р"] = growth;}
qint32 size() const; inline qint32 size() const {return base.value("Сг");}
qint32 growth() const; inline qint32 growth() const {return base.value("Р");}
qreal FindVar(const QString& name, bool *ok)const; qreal FindVar(const QString& name, bool *ok)const;
bool IncrementTableContains(const QString& name); inline bool IncrementTableContains(const QString& name) {return incrementTable.contains(name);}
static qint64 getNextId(); static qint64 getNextId();
void RemoveIncrementTableRow(const QString& name); inline void RemoveIncrementTableRow(const QString& name) {incrementTable.remove(name);}
const QHash<qint64, VPointF> *DataPoints() const; inline const QHash<qint64, VPointF> *DataPoints() const {return &points;}
const QHash<qint64, VPointF> *DataModelingPoints() const; inline const QHash<qint64, VPointF> *DataModelingPoints() const {return &modelingPoints;}
const QHash<qint64, VSpline> *DataSplines() const; inline const QHash<qint64, VSpline> *DataSplines() const {return &splines;}
const QHash<qint64, VSpline> *DataModelingSplines() const; inline const QHash<qint64, VSpline> *DataModelingSplines() const {return &modelingSplines;}
const QHash<qint64, VArc> *DataArcs() const; inline const QHash<qint64, VArc> *DataArcs() const {return &arcs;}
const QHash<qint64, VArc> *DataModelingArcs() const; inline const QHash<qint64, VArc> *DataModelingArcs() const {return &modelingArcs;}
const QHash<QString, qint32> *DataBase() const; inline const QHash<QString, qint32> *DataBase() const {return &base;}
const QHash<QString, VStandartTableCell> *DataStandartTable() const; inline const QHash<QString, VStandartTableCell> *DataStandartTable() const {return &standartTable;}
const QHash<QString, VIncrementTableRow> *DataIncrementTable() const; inline const QHash<QString, VIncrementTableRow> *DataIncrementTable() const {return &incrementTable;}
const QHash<QString, qreal> *DataLengthLines() const; inline const QHash<QString, qreal> *DataLengthLines() const {return &lengthLines;}
const QHash<QString, qreal> *DataLengthSplines() const; inline const QHash<QString, qreal> *DataLengthSplines() const {return &lengthSplines;}
const QHash<QString, qreal> *DataLengthArcs() const; inline const QHash<QString, qreal> *DataLengthArcs() const {return &lengthArcs;}
const QHash<QString, qreal> *DataLineAngles() const; inline const QHash<QString, qreal> *DataLineAngles() const {return &lineAngles;}
const QHash<qint64, VSplinePath> *DataSplinePaths() const; inline const QHash<qint64, VSplinePath> *DataSplinePaths() const {return &splinePaths;}
const QHash<qint64, VSplinePath> *DataModelingSplinePaths() const; inline const QHash<qint64, VSplinePath> *DataModelingSplinePaths() const {return &modelingSplinePaths;}
const QHash<qint64, VDetail> *DataDetails() const; inline const QHash<qint64, VDetail> *DataDetails() const {return &details;}
static void UpdateId(qint64 newId); static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const; QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector<QPointF> points, QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const;
const Detail::Equidistant &eqv, QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width)const;
const qreal &width)const;
static QLineF ParallelLine(const QLineF &line, qreal width ); static QLineF ParallelLine(const QLineF &line, qreal width );
static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width);
const qreal &width); QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const;
QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2,
const qreal &width)const;
QVector<QPointF> CheckLoops(const QVector<QPointF> &points) const; QVector<QPointF> CheckLoops(const QVector<QPointF> &points) const;
void PrepareDetails(QVector<VItem *> & list) const; void PrepareDetails(QVector<VItem *> & list) const;
private: private:
@ -196,15 +191,12 @@ private:
QHash<qint64, VSplinePath> splinePaths; QHash<qint64, VSplinePath> splinePaths;
QHash<qint64, VSplinePath> modelingSplinePaths; QHash<qint64, VSplinePath> modelingSplinePaths;
QHash<qint64, VDetail> details; 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 (); void CreateManTableIGroup ();
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const; QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
qreal GetLengthContour(const QVector<QPointF> &contour, qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const;
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 #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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,54 +24,12 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vincrementtablerow.h" #include "vincrementtablerow.h"
VIncrementTableRow::VIncrementTableRow():id(0), base(0), ksize(0), kgrowth(0), description(QString()){ VIncrementTableRow::VIncrementTableRow()
} :id(0), base(0), ksize(0), kgrowth(0), description(QString()){}
VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, QString description)
QString description):id(id), base(base), ksize(ksize), :id(id), base(base), ksize(ksize), kgrowth(kgrowth), description(description){}
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;
}

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,34 +24,27 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VINCREMENTTABLEROW_H #ifndef VINCREMENTTABLEROW_H
#define VINCREMENTTABLEROW_H #define VINCREMENTTABLEROW_H
#include <QString>
class VIncrementTableRow class VIncrementTableRow
{ {
public: public:
VIncrementTableRow(); VIncrementTableRow();
VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth,
QString description = QString()); QString description = QString());
qint64 getId() const; inline qint64 getId() const {return id;}
void setId(const qint64 &value); inline void setId(const qint64 &value) {id = value;}
inline qreal getBase() const {return base;}
qreal getBase() const; inline void setBase(const qreal &value) {base = value;}
void setBase(const qreal &value); inline qreal getKsize() const {return ksize;}
inline void setKsize(const qreal &value) {ksize = value;}
qreal getKsize() const; inline qreal getKgrowth() const {return kgrowth;}
void setKsize(const qreal &value); inline void setKgrowth(const qreal &value) {kgrowth = value;}
inline QString getDescription() const {return description;}
qreal getKgrowth() const; inline void setDescription(const QString &value) {description = value;}
void setKgrowth(const qreal &value);
QString getDescription() const;
void setDescription(const QString &value);
private: private:
qint64 id; qint64 id;
qreal base; qreal base;

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,11 +24,12 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vpointf.h" #include "vpointf.h"
VPointF &VPointF::operator =(const VPointF &point){ VPointF &VPointF::operator =(const VPointF &point)
{
_name = point.name(); _name = point.name();
_mx = point.mx(); _mx = point.mx();
_my = point.my(); _my = point.my();

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,16 +24,13 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VPOINTF_H #ifndef VPOINTF_H
#define VPOINTF_H #define VPOINTF_H
#include <QPointF> class VPointF
#include <QString> {
#include "options.h"
class VPointF{
public: public:
inline VPointF () inline VPointF ()
:_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){} :_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){}

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,29 +24,12 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vstandarttablecell.h" #include "vstandarttablecell.h"
VStandartTableCell::VStandartTableCell():base(0), ksize(0), kgrowth(0), description(QString()){ VStandartTableCell::VStandartTableCell()
} :base(0), ksize(0), kgrowth(0), description(QString()){}
VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description):base(base), VStandartTableCell::VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description)
ksize(ksize), kgrowth(kgrowth), description(description){ :base(base), ksize(ksize), kgrowth(kgrowth), description(description){}
}
qint32 VStandartTableCell::GetBase() const{
return base;
}
qreal VStandartTableCell::GetKsize() const{
return ksize;
}
qreal VStandartTableCell::GetKgrowth() const{
return kgrowth;
}
QString VStandartTableCell::GetDescription() const{
return 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,22 +24,20 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VSTANDARTTABLECELL_H #ifndef VSTANDARTTABLECELL_H
#define VSTANDARTTABLECELL_H #define VSTANDARTTABLECELL_H
#include <QString>
class VStandartTableCell class VStandartTableCell
{ {
public: public:
VStandartTableCell(); VStandartTableCell();
VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString()); VStandartTableCell(qint32 base, qreal ksize, qreal kgrowth, QString description = QString());
qint32 GetBase() const; inline qint32 GetBase() const {return base;}
qreal GetKsize() const; inline qreal GetKsize() const {return ksize;}
qreal GetKgrowth() const; inline qreal GetKgrowth() const {return kgrowth;}
QString GetDescription() const; inline QString GetDescription() const {return description;}
private: private:
qint32 base; qint32 base;
qreal ksize; qreal ksize;

View File

@ -12,5 +12,8 @@
<file>cursor/splinepath_cursor.png</file> <file>cursor/splinepath_cursor.png</file>
<file>cursor/pointcontact_cursor.png</file> <file>cursor/pointcontact_cursor.png</file>
<file>cursor/new_detail_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> </qresource>
</RCC> </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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogalongline.h" #include "dialogalongline.h"
#include "ui_dialogalongline.h" #include "ui_dialogalongline.h"
DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
listWidget = ui->listWidget; listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
@ -33,6 +41,8 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula; lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
@ -44,6 +54,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);
ui->comboBoxLineType->setCurrentIndex(1);
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogAlongLine::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogAlongLine::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogAlongLine::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogAlongLine::LengthLines); 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->toolButtonEqual, &QPushButton::clicked, this, &DialogAlongLine::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged);
} }
DialogAlongLine::~DialogAlongLine(){ DialogAlongLine::~DialogAlongLine()
{
delete ui; delete ui;
} }
void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogAlongLine::DialogAccepted(){ void DialogAlongLine::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -116,45 +145,30 @@ void DialogAlongLine::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
qint64 DialogAlongLine::getSecondPointId() const{ void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id)
return secondPointId; {
}
void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
qint64 DialogAlongLine::getFirstPointId() const{ void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id)
return firstPointId; {
}
void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
QString DialogAlongLine::getFormula() const{ void DialogAlongLine::setFormula(const QString &value)
return formula; {
}
void DialogAlongLine::setFormula(const QString &value){
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
QString DialogAlongLine::getTypeLine() const{ void DialogAlongLine::setTypeLine(const QString &value)
return typeLine; {
}
void DialogAlongLine::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
QString DialogAlongLine::getPointName() const{ void DialogAlongLine::setPointName(const QString &value)
return pointName; {
}
void DialogAlongLine::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGALONGLINE_H #ifndef DIALOGALONGLINE_H
#define DIALOGALONGLINE_H #define DIALOGALONGLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/calculator.h"
namespace Ui { namespace Ui
{
class DialogAlongLine; class DialogAlongLine;
} }
@ -33,21 +40,21 @@ class DialogAlongLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogAlongLine(); ~DialogAlongLine();
QString getPointName() const; inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
QString getTypeLine() const; inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value); void setTypeLine(const QString &value);
QString getFormula() const; inline QString getFormula() const {return formula;}
void setFormula(const QString &value); void setFormula(const QString &value);
qint64 getFirstPointId() const; inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id); 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); void setSecondPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogAlongLine) Q_DISABLE_COPY(DialogAlongLine)

View File

@ -302,7 +302,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of arcs</string>
@ -312,7 +312,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogarc.h" #include "dialogarc.h"
#include "ui_dialogarc.h" #include "ui_dialogarc.h"
#include "../container/calculator.h"
DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), :DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){ timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString())
{
ui->setupUi(this); ui->setupUi(this);
timerRadius = new QTimer(this); timerRadius = new QTimer(this);
@ -52,6 +59,8 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius);
connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines); 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->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius);
connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); 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); connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed);
} }
qint64 DialogArc::GetCenter() const{ DialogArc::~DialogArc()
return center; {
delete ui;
} }
void DialogArc::SetCenter(const qint64 &value){ void DialogArc::SetCenter(const qint64 &value)
{
center = value; center = value;
ChangeCurrentData(ui->comboBoxBasePoint, center); ChangeCurrentData(ui->comboBoxBasePoint, center);
} }
QString DialogArc::GetF2() const{ void DialogArc::SetF2(const QString &value)
return f2; {
}
void DialogArc::SetF2(const QString &value){
f2 = value; f2 = value;
ui->lineEditF2->setText(f2); ui->lineEditF2->setText(f2);
} }
QString DialogArc::GetF1() const{ void DialogArc::SetF1(const QString &value)
return f1; {
}
void DialogArc::SetF1(const QString &value){
f1 = value; f1 = value;
ui->lineEditF1->setText(f1); ui->lineEditF1->setText(f1);
} }
QString DialogArc::GetRadius() const{ void DialogArc::SetRadius(const QString &value)
return radius; {
}
void DialogArc::SetRadius(const QString &value){
radius = value; radius = value;
ui->lineEditRadius->setText(radius); ui->lineEditRadius->setText(radius);
} }
DialogArc::~DialogArc(){ void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
delete ui; {
} if (idDetail == 0 && mode == Draw::Modeling)
{
void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){ if (type == Scene::Detail)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id)==false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
ChangeCurrentText(ui->comboBoxBasePoint, point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
@ -139,7 +148,8 @@ void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogArc::DialogAccepted(){ void DialogArc::DialogAccepted()
{
radius = ui->lineEditRadius->text(); radius = ui->lineEditRadius->text();
f1 = ui->lineEditF1->text(); f1 = ui->lineEditF1->text();
f2 = ui->lineEditF2->text(); f2 = ui->lineEditF2->text();
@ -147,13 +157,16 @@ void DialogArc::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogArc::ValChenged(int row){ void DialogArc::ValChenged(int row)
if(ui->listWidget->count() == 0){ {
if (ui->listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
if(ui->radioButtonLineAngles->isChecked()){ if (ui->radioButtonLineAngles->isChecked())
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text())) {
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineAngle(item->text()))
.arg(tr("Value angle of line.")); .arg(tr("Value angle of line."));
ui->labelDescription->setText(desc); ui->labelDescription->setText(desc);
return; return;
@ -161,61 +174,78 @@ void DialogArc::ValChenged(int row){
DialogTool::ValChenged(row); DialogTool::ValChenged(row);
} }
void DialogArc::PutRadius(){ void DialogArc::PutRadius()
{
PutValHere(ui->lineEditRadius, ui->listWidget); PutValHere(ui->lineEditRadius, ui->listWidget);
} }
void DialogArc::PutF1(){ void DialogArc::PutF1()
{
PutValHere(ui->lineEditF1, ui->listWidget); PutValHere(ui->lineEditF1, ui->listWidget);
} }
void DialogArc::PutF2(){ void DialogArc::PutF2()
{
PutValHere(ui->lineEditF2, ui->listWidget); PutValHere(ui->lineEditF2, ui->listWidget);
} }
void DialogArc::LineArcs(){ void DialogArc::LineAngles()
ShowLineArcs(); {
ShowLineAngles();
} }
void DialogArc::RadiusChanged(){ void DialogArc::RadiusChanged()
{
labelEditFormula = ui->labelEditRadius;
ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius); ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius);
} }
void DialogArc::F1Changed(){ void DialogArc::F1Changed()
{
labelEditFormula = ui->labelEditF1;
ValFormulaChanged(flagF1, ui->lineEditF1, timerF1); ValFormulaChanged(flagF1, ui->lineEditF1, timerF1);
} }
void DialogArc::F2Changed(){ void DialogArc::F2Changed()
{
labelEditFormula = ui->labelEditF2;
ValFormulaChanged(flagF2, ui->lineEditF2, timerF2); ValFormulaChanged(flagF2, ui->lineEditF2, timerF2);
} }
void DialogArc::CheckState(){ void DialogArc::CheckState()
Q_CHECK_PTR(bOk); {
Q_ASSERT(bOk != 0);
bOk->setEnabled(flagRadius && flagF1 && flagF2); bOk->setEnabled(flagRadius && flagF1 && flagF2);
} }
void DialogArc::EvalRadius(){ void DialogArc::EvalRadius()
{
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius); Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius);
} }
void DialogArc::EvalF1(){ void DialogArc::EvalF1()
{
labelEditFormula = ui->labelEditF1; labelEditFormula = ui->labelEditF1;
Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1); Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1);
} }
void DialogArc::EvalF2(){ void DialogArc::EvalF2()
{
labelEditFormula = ui->labelEditF2; labelEditFormula = ui->labelEditF2;
Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2); Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2);
} }
void DialogArc::ShowLineArcs(){ void DialogArc::ShowLineAngles()
{
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ui->listWidget->clear(); ui->listWidget->clear();
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
const QHash<QString, qreal> *lineArcsTable = data->DataLineAngles(); const QHash<QString, qreal> *lineAnglesTable = data->DataLineAngles();
QHashIterator<QString, qreal> i(*lineArcsTable); Q_ASSERT(lineAnglesTable != 0);
while (i.hasNext()) { QHashIterator<QString, qreal> i(*lineAnglesTable);
while (i.hasNext())
{
i.next(); i.next();
QListWidgetItem *item = new QListWidgetItem(i.key()); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGARC_H #ifndef DIALOGARC_H
#define DIALOGARC_H #define DIALOGARC_H
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogArc; class DialogArc;
} }
@ -32,28 +40,24 @@ class DialogArc : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogArc(); ~DialogArc();
qint64 GetCenter() const; inline qint64 GetCenter() const {return center;}
void SetCenter(const qint64 &value); void SetCenter(const qint64 &value);
inline QString GetRadius() const {return radius;}
QString GetRadius() const;
void SetRadius(const QString &value); void SetRadius(const QString &value);
inline QString GetF1() const {return f1;}
QString GetF1() const;
void SetF1(const QString &value); void SetF1(const QString &value);
inline QString GetF2() const {return f2;}
QString GetF2() const;
void SetF2(const QString &value); void SetF2(const QString &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
virtual void ValChenged(int row); virtual void ValChenged(int row);
void PutRadius(); void PutRadius();
void PutF1(); void PutF1();
void PutF2(); void PutF2();
void LineArcs(); void LineAngles();
void RadiusChanged(); void RadiusChanged();
void F1Changed(); void F1Changed();
void F2Changed(); void F2Changed();
@ -75,7 +79,7 @@ private:
void EvalRadius(); void EvalRadius();
void EvalF1(); void EvalF1();
void EvalF2(); void EvalF2();
void ShowLineArcs(); void ShowLineAngles();
}; };
#endif // DIALOGARC_H #endif // DIALOGARC_H

View File

@ -495,7 +495,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of curves</string>
</property> </property>
</widget> </widget>
</item> </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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogbisector.h" #include "dialogbisector.h"
#include "ui_dialogbisector.h" #include "ui_dialogbisector.h"
DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
listWidget = ui->listWidget; listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation; labelResultCalculation = ui->labelResultCalculation;
@ -33,6 +41,8 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula; lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogBisector::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogBisector::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogBisector::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogBisector::LengthLines); 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->toolButtonEqual, &QPushButton::clicked, this, &DialogBisector::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged);
} }
DialogBisector::~DialogBisector(){ DialogBisector::~DialogBisector()
{
delete ui; delete ui;
} }
void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of angle")); emit ToolTip(tr("Select second point of angle"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select third point of angle")); emit ToolTip(tr("Select third point of angle"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxThirdPoint->findText(point.name()); qint32 index = ui->comboBoxThirdPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxThirdPoint->setCurrentIndex(index); ui->comboBoxThirdPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
QString DialogBisector::getPointName() const{ void DialogBisector::setPointName(const QString &value)
return pointName; {
}
void DialogBisector::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
QString DialogBisector::getTypeLine() const{ void DialogBisector::setTypeLine(const QString &value)
return typeLine; {
}
void DialogBisector::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
QString DialogBisector::getFormula() const{ void DialogBisector::setFormula(const QString &value)
return formula; {
}
void DialogBisector::setFormula(const QString &value){
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
qint64 DialogBisector::getFirstPointId() const{ void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id)
return firstPointId; {
}
void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
qint64 DialogBisector::getSecondPointId() const{ void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id)
return secondPointId; {
}
void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
qint64 DialogBisector::getThirdPointId() const{ void DialogBisector::setThirdPointId(const qint64 &value, const qint64 &id)
return thirdPointId; {
}
void DialogBisector::setThirdPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxThirdPoint, thirdPointId, value, id); setCurrentPointId(ui->comboBoxThirdPoint, thirdPointId, value, id);
} }
void DialogBisector::DialogAccepted(){ void DialogBisector::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,41 +24,39 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGBISECTOR_H #ifndef DIALOGBISECTOR_H
#define DIALOGBISECTOR_H #define DIALOGBISECTOR_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui { namespace Ui
{
class DialogBisector; class DialogBisector;
} }
class DialogBisector : public DialogTool class DialogBisector : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation, explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogBisector(); ~DialogBisector();
QString getPointName() const; QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
QString getTypeLine() const; inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value); void setTypeLine(const QString &value);
QString getFormula() const; inline QString getFormula() const {return formula;}
void setFormula(const QString &value); void setFormula(const QString &value);
qint64 getFirstPointId() const; inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id); 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); 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); void setThirdPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogBisector) Q_DISABLE_COPY(DialogBisector)

View File

@ -344,7 +344,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of arcs</string>
@ -354,7 +354,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,35 +24,53 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogdetail.h" #include "dialogdetail.h"
#include <QDebug>
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(), details(VDetail()){ :DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true)
{
ui.setupUi(this); ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok); bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected); 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){ void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type != Scene::Line && type != Scene::Detail){ if (type != Scene::Line && type != Scene::Detail)
switch(type){ {
switch (type)
{
case (Scene::Arc): case (Scene::Arc):
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour); NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
break; break;
@ -66,58 +91,82 @@ void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogDetail::DialogAccepted(){ void DialogDetail::DialogAccepted()
{
details.Clear(); details.Clear();
for(qint32 i = 0; i < ui.listWidget->count(); ++i){ for (qint32 i = 0; i < ui.listWidget->count(); ++i)
{
QListWidgetItem *item = ui.listWidget->item(i); QListWidgetItem *item = ui.listWidget->item(i);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole))); details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
} }
details.setWidth(ui.doubleSpinBoxSeams->value());
details.setName(ui.lineEditNameDetail->text()); details.setName(ui.lineEditNameDetail->text());
details.setSupplement(supplement);
details.setClosed(closed);
emit ToolTip(""); emit ToolTip("");
emit DialogClosed(QDialog::Accepted); 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; QString name;
switch(typeTool){ switch (typeTool)
case(Tool::NodePoint):{ {
case (Tool::NodePoint):
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
name = point.name(); name = point.name();
break; break;
} }
case(Tool::NodeArc):{ case (Tool::NodeArc):
{
VArc arc; VArc arc;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
arc = data->GetArc(id); arc = data->GetArc(id);
} else { }
else
{
arc = data->GetModelingArc(id); arc = data->GetModelingArc(id);
} }
name = data->GetNameArc(arc.GetCenter(), id, mode); name = arc.name();
break; break;
} }
case(Tool::NodeSpline):{ case (Tool::NodeSpline):
{
VSpline spl; VSpline spl;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
spl = data->GetSpline(id); spl = data->GetSpline(id);
} else { }
else
{
spl = data->GetModelingSpline(id); spl = data->GetModelingSpline(id);
} }
name = spl.GetName(); name = spl.GetName();
break; break;
} }
case(Tool::NodeSplinePath):{ case (Tool::NodeSplinePath):
{
VSplinePath splPath; VSplinePath splPath;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id); splPath = data->GetSplinePath(id);
} else { }
else
{
splPath = data->GetModelingSplinePath(id); splPath = data->GetModelingSplinePath(id);
} }
name = data->GetNameSplinePath(splPath, mode); name = splPath.name();
break; break;
} }
default: default:
@ -127,22 +176,76 @@ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, No
QListWidgetItem *item = new QListWidgetItem(name); QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold)); 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)); item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item); 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{ void DialogDetail::setDetails(const VDetail &value)
return details; {
}
void DialogDetail::setDetails(const VDetail &value){
details = value; details = value;
ui.listWidget->clear(); ui.listWidget->clear();
for(qint32 i = 0; i < details.CountNode(); ++i){ for (ptrdiff_t i = 0; i < details.CountNode(); ++i)
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode(), details[i].getTypeNode()); {
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); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,29 +24,36 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGDETAIL_H #ifndef DIALOGDETAIL_H
#define DIALOGDETAIL_H #define DIALOGDETAIL_H
#include "ui_dialogdetail.h" #include "ui_dialogdetail.h"
#include "dialogtool.h" #include "dialogtool.h"
#include "geometry/vdetail.h"
class DialogDetail : public DialogTool{ class DialogDetail : public DialogTool
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0); DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
VDetail getDetails() const; inline VDetail getDetails() const {return details;}
void setDetails(const VDetail &value); void setDetails(const VDetail &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
void BiasXChanged(qreal d);
void BiasYChanged(qreal d);
void ClickedSeams(bool checked);
void ClickedClosed(bool checked);
void ObjectChanged(int row);
private: private:
Ui::DialogDetail ui; Ui::DialogDetail ui;
VDetail details; VDetail details;
void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode); 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 #endif // DIALOGDETAIL_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>340</width> <width>544</width>
<height>298</height> <height>327</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -20,15 +20,158 @@
<property name="locale"> <property name="locale">
<locale language="English" country="UnitedStates"/> <locale language="English" country="UnitedStates"/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<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="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="text">
<string>Bias Y</string>
</property>
</widget>
</item>
<item>
<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>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Option</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLabel" name="labelEditNameDetail"> <widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -39,17 +182,22 @@
<locale language="English" country="UnitedStates"/> <locale language="English" country="UnitedStates"/>
</property> </property>
<property name="text"> <property name="text">
<string>Name detail</string> <string>Width</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditNameDetail"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QCheckBox" name="checkBoxClosed"> <widget class="QCheckBox" name="checkBoxClosed">
<property name="text"> <property name="text">
@ -61,6 +209,7 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -83,7 +232,6 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lineEditNameDetail</tabstop> <tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>listWidget</tabstop> <tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,18 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogendline.h" #include "dialogendline.h"
#include "ui_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) : DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), basePointId(0){ formula(QString()), angle(0), basePointId(0)
{
ui->setupUi(this); ui->setupUi(this);
spinBoxAngle = ui->doubleSpinBoxAngle; spinBoxAngle = ui->doubleSpinBoxAngle;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -38,6 +42,8 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula; lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogEndLine::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEndLine::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEndLine::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEndLine::LengthLines); 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->toolButtonEqual, &QPushButton::clicked, this, &DialogEndLine::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged);
} }
void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
ChangeCurrentText(ui->comboBoxBasePoint, point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
@ -106,51 +123,37 @@ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
QString DialogEndLine::getPointName() const{ void DialogEndLine::setPointName(const QString &value)
return pointName; {
}
void DialogEndLine::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }
QString DialogEndLine::getTypeLine() const{ void DialogEndLine::setTypeLine(const QString &value)
return typeLine; {
}
void DialogEndLine::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
QString DialogEndLine::getFormula() const{ void DialogEndLine::setFormula(const QString &value)
return formula; {
}
void DialogEndLine::setFormula(const QString &value){
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
qreal DialogEndLine::getAngle() const{ void DialogEndLine::setAngle(const qreal &value)
return angle; {
}
void DialogEndLine::setAngle(const qreal &value){
angle = value; angle = value;
ui->doubleSpinBoxAngle->setValue(angle); ui->doubleSpinBoxAngle->setValue(angle);
} }
qint64 DialogEndLine::getBasePointId() const{ void DialogEndLine::setBasePointId(const qint64 &value, const qint64 &id)
return basePointId; {
}
void DialogEndLine::setBasePointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id); setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id);
} }
void DialogEndLine::DialogAccepted(){ void DialogEndLine::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,16 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGENDLINE_H #ifndef DIALOGENDLINE_H
#define DIALOGENDLINE_H #define DIALOGENDLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui { namespace Ui
{
class DialogEndLine; class DialogEndLine;
} }
@ -34,21 +40,20 @@ class DialogEndLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogEndLine(); ~DialogEndLine();
QString getPointName() const; inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
QString getTypeLine() const; inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value); void setTypeLine(const QString &value);
QString getFormula() const; inline QString getFormula() const {return formula;}
void setFormula(const QString &value); void setFormula(const QString &value);
qreal getAngle() const; inline qreal getAngle() const {return angle;}
void setAngle(const qreal &value); void setAngle(const qreal &value);
qint64 getBasePointId() const; inline qint64 getBasePointId() const {return basePointId;}
void setBasePointId(const qint64 &value, const qint64 &id); void setBasePointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogEndLine) Q_DISABLE_COPY(DialogEndLine)

View File

@ -500,7 +500,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of arcs</string>
@ -510,7 +510,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,18 +24,19 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialoghistory.h" #include "dialoghistory.h"
#include "ui_dialoghistory.h" #include "ui_dialoghistory.h"
#include "geometry/varc.h" #include "../geometry/varc.h"
#include "geometry/vspline.h" #include "../geometry/vspline.h"
#include "geometry/vsplinepath.h" #include "../geometry/vsplinepath.h"
#include <QDebug> #include <QDebug>
DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) : DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
cursorToolRecordRow(0){ cursorToolRecordRow(0)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);
@ -42,19 +50,23 @@ DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *paren
ShowPoint(); ShowPoint();
} }
DialogHistory::~DialogHistory(){ DialogHistory::~DialogHistory()
{
delete ui; delete ui;
} }
void DialogHistory::DialogAccepted(){ void DialogHistory::DialogAccepted()
{
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogHistory::cellClicked(int row, int column){ void DialogHistory::cellClicked(int row, int column)
if(column == 0){ {
if (column == 0)
{
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
item->setIcon(QIcon()); item->setIcon(QIcon());
@ -65,7 +77,9 @@ void DialogHistory::cellClicked(int row, int column){
disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor);
doc->setCursor(id); doc->setCursor(id);
connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor);
} else { }
else
{
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);
@ -77,11 +91,14 @@ void DialogHistory::cellClicked(int row, int column){
} }
} }
void DialogHistory::ChangedCursor(qint64 id){ void DialogHistory::ChangedCursor(qint64 id)
for(qint32 i = 0; i< ui->tableWidget->rowCount(); ++i){ {
for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 0); QTableWidgetItem *item = ui->tableWidget->item(i, 0);
qint64 rId = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 rId = qvariant_cast<qint64>(item->data(Qt::UserRole));
if(rId == id){ if (rId == id)
{
QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0);
oldCursorItem->setIcon(QIcon()); oldCursorItem->setIcon(QIcon());
cursorRow = i; cursorRow = i;
@ -90,20 +107,24 @@ void DialogHistory::ChangedCursor(qint64 id){
} }
} }
void DialogHistory::UpdateHistory(){ void DialogHistory::UpdateHistory()
{
FillTable(); FillTable();
InitialTable(); InitialTable();
} }
void DialogHistory::FillTable(){ void DialogHistory::FillTable()
{
ui->tableWidget->clear(); ui->tableWidget->clear();
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
qint32 currentRow = -1; qint32 currentRow = -1;
qint32 count = 0; qint32 count = 0;
ui->tableWidget->setRowCount(history->size()); ui->tableWidget->setRowCount(history->size());
for(qint32 i = 0; i< history->size(); ++i){ for (qint32 i = 0; i< history->size(); ++i)
{
VToolRecord tool = history->at(i); VToolRecord tool = history->at(i);
if(tool.getNameDraw() != doc->GetNameActivDraw()){ if (tool.getNameDraw() != doc->GetNameActivDraw())
{
continue; continue;
} }
currentRow++; currentRow++;
@ -121,7 +142,8 @@ void DialogHistory::FillTable(){
++count; ++count;
} }
ui->tableWidget->setRowCount(count); ui->tableWidget->setRowCount(count);
if(history->size()>0){ if (history->size()>0)
{
cursorRow = currentRow; cursorRow = currentRow;
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
item->setIcon(QIcon("://icon/32x32/put_after.png")); item->setIcon(QIcon("://icon/32x32/put_after.png"));
@ -131,7 +153,8 @@ void DialogHistory::FillTable(){
ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); ui->tableWidget->verticalHeader()->setDefaultSectionSize(20);
} }
QString DialogHistory::Record(const VToolRecord &tool){ QString DialogHistory::Record(const VToolRecord &tool)
{
QString record = QString(); QString record = QString();
qint64 basePointId = 0; qint64 basePointId = 0;
qint64 secondPointId = 0; qint64 secondPointId = 0;
@ -143,7 +166,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
qint64 p2Line2 = 0; qint64 p2Line2 = 0;
qint64 center = 0; qint64 center = 0;
QDomElement domElement; QDomElement domElement;
switch( tool.getTypeTool() ){ switch ( tool.getTypeTool() )
{
case Tool::ArrowTool: case Tool::ArrowTool:
break; break;
case Tool::SinglePointTool: case Tool::SinglePointTool:
@ -151,7 +175,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::EndLineTool: case Tool::EndLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = domElement.attribute("basePoint", "").toLongLong();
} }
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(), record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(),
@ -159,7 +184,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::LineTool: case Tool::LineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -168,7 +194,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::AlongLineTool: case Tool::AlongLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -181,7 +208,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::NormalTool: case Tool::NormalTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
@ -191,7 +219,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::BisectorTool: case Tool::BisectorTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
basePointId = domElement.attribute("secondPoint", "").toLongLong(); basePointId = domElement.attribute("secondPoint", "").toLongLong();
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
@ -203,7 +232,8 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::LineIntersectTool: case Tool::LineIntersectTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
p2Line1 = domElement.attribute("p2Line1", "").toLongLong(); p2Line1 = domElement.attribute("p2Line1", "").toLongLong();
p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
@ -215,23 +245,28 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(p2Line2).name(), data->GetPoint(p2Line2).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tool::SplineTool:{ case Tool::SplineTool:
{
VSpline spl = data->GetSpline(tool.getId()); VSpline spl = data->GetSpline(tool.getId());
record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(), record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(),
data->GetPoint(spl.GetP4()).name()); data->GetPoint(spl.GetP4()).name());
} }
break; break;
case Tool::ArcTool:{ case Tool::ArcTool:
{
VArc arc = data->GetArc(tool.getId()); VArc arc = data->GetArc(tool.getId());
record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name()); record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name());
} }
break; break;
case Tool::SplinePathTool:{ case Tool::SplinePathTool:
{
VSplinePath splPath = data->GetSplinePath(tool.getId()); VSplinePath splPath = data->GetSplinePath(tool.getId());
QVector<VSplinePoint> points = splPath.GetSplinePath(); QVector<VSplinePoint> points = splPath.GetSplinePath();
if(points.size() != 0 ){ if (points.size() != 0 )
{
record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name()); record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name());
for(qint32 i = 1; i< points.size(); ++i){ for (qint32 i = 1; i< points.size(); ++i)
{
QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name()); QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name());
record.append(name); record.append(name);
} }
@ -240,16 +275,49 @@ QString DialogHistory::Record(const VToolRecord &tool){
break; break;
case Tool::PointOfContact: case Tool::PointOfContact:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if (domElement.isElement())
{
center = domElement.attribute("center", "").toLongLong(); center = domElement.attribute("center", "").toLongLong();
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
} }
record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg(data->GetPoint(center).name(), record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg(
data->GetPoint(firstPointId).name(), data->GetPoint(center).name(), data->GetPoint(firstPointId).name(),
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(), data->GetPoint(tool.getId()).name());
data->GetPoint(tool.getId()).name());
break; break;
case Tool::Height:
{
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: default:
qWarning()<<tr("Get wrong tool type. Ignore."); qWarning()<<tr("Get wrong tool type. Ignore.");
break; break;
@ -257,15 +325,18 @@ QString DialogHistory::Record(const VToolRecord &tool){
return record; return record;
} }
void DialogHistory::InitialTable(){ void DialogHistory::InitialTable()
{
ui->tableWidget->setSortingEnabled(false); ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" "));
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool"))); ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool")));
} }
void DialogHistory::ShowPoint(){ void DialogHistory::ShowPoint()
{
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
if(history->size()>0){ if (history->size()>0)
{
QTableWidgetItem *item = ui->tableWidget->item(0, 1); QTableWidgetItem *item = ui->tableWidget->item(0, 1);
item->setSelected(true); item->setSelected(true);
cursorToolRecordRow = 0; cursorToolRecordRow = 0;
@ -275,8 +346,8 @@ void DialogHistory::ShowPoint(){
} }
} }
void DialogHistory::closeEvent(QCloseEvent *event)
void DialogHistory::closeEvent(QCloseEvent *event){ {
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, Qt::green, false);

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,24 +24,24 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGHISTORY_H #ifndef DIALOGHISTORY_H
#define DIALOGHISTORY_H #define DIALOGHISTORY_H
#include "dialogtool.h" #include "dialogtool.h"
#include "xml/vdomdocument.h" #include "../xml/vdomdocument.h"
namespace Ui { namespace Ui
{
class DialogHistory; class DialogHistory;
} }
class DialogHistory : public DialogTool class DialogHistory : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0); DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
virtual ~DialogHistory(); virtual ~DialogHistory();
public slots: public slots:
virtual void DialogAccepted(); virtual void DialogAccepted();

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,22 +24,22 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogincrements.h" #include "dialogincrements.h"
#include "ui_dialogincrements.h" #include "ui_dialogincrements.h"
#include <QHeaderView> #include "../widgets/doubledelegate.h"
#include <QCloseEvent> #include "../exception/vexception.h"
#include "widgets/doubledelegate.h"
#include "container/vincrementtablerow.h"
#include <QDebug>
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) : DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc){ :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0)
{
ui->setupUi(this); ui->setupUi(this);
InitialStandartTable(); InitialStandartTable();
InitialIncrementTable(); InitialIncrementTable();
InitialLinesTable(); InitialLinesTable();
InitialSplinesTable();
InitialArcsTable();
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement); DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate); ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate); ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);
@ -40,7 +47,10 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
FillStandartTable(); FillStandartTable();
FillIncrementTable(); FillIncrementTable();
FillLengthLines(); FillLengthLines();
FillLengthSplines();
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::cellChanged);
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd); connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
connect(ui->toolButtonRemove, &QPushButton::clicked, this, connect(ui->toolButtonRemove, &QPushButton::clicked, this,
&DialogIncrements::clickedToolButtonRemove); &DialogIncrements::clickedToolButtonRemove);
@ -52,14 +62,17 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted);
ui->tabWidget->setCurrentIndex(0);
} }
void DialogIncrements::FillStandartTable(){ void DialogIncrements::FillStandartTable()
{
const QHash<QString, VStandartTableCell> *standartTable = data->DataStandartTable(); const QHash<QString, VStandartTableCell> *standartTable = data->DataStandartTable();
qint32 currentRow = -1; qint32 currentRow = -1;
QHashIterator<QString, VStandartTableCell> i(*standartTable); QHashIterator<QString, VStandartTableCell> i(*standartTable);
ui->tableWidgetStandart->setRowCount ( standartTable->size() ); ui->tableWidgetStandart->setRowCount ( standartTable->size() );
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
VStandartTableCell cell = i.value(); VStandartTableCell cell = i.value();
currentRow++; currentRow++;
@ -94,12 +107,14 @@ void DialogIncrements::FillStandartTable(){
ui->tableWidgetStandart->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetStandart->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillIncrementTable(){ void DialogIncrements::FillIncrementTable()
{
const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable(); const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable();
QHashIterator<QString, VIncrementTableRow> i(*incrementTable); QHashIterator<QString, VIncrementTableRow> i(*incrementTable);
QMap<qint64, QString> map; QMap<qint64, QString> map;
//Sorting QHash by id //Sorting QHash by id
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
VIncrementTableRow cell = i.value(); VIncrementTableRow cell = i.value();
map.insert(cell.getId(), i.key()); map.insert(cell.getId(), i.key());
@ -107,7 +122,8 @@ void DialogIncrements::FillIncrementTable(){
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<qint64, QString> iMap(map); QMapIterator<qint64, QString> iMap(map);
while (iMap.hasNext()) { while (iMap.hasNext())
{
iMap.next(); iMap.next();
VIncrementTableRow cell = incrementTable->value(iMap.value()); VIncrementTableRow cell = incrementTable->value(iMap.value());
currentRow++; currentRow++;
@ -140,22 +156,34 @@ void DialogIncrements::FillIncrementTable(){
ui->tableWidgetIncrement->setItem(currentRow, 4, item); ui->tableWidgetIncrement->setItem(currentRow, 4, item);
item = new QTableWidgetItem(cell.getDescription()); item = new QTableWidgetItem(cell.getDescription());
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignLeft);
ui->tableWidgetIncrement->setItem(currentRow, 5, item); ui->tableWidgetIncrement->setItem(currentRow, 5, item);
} }
if(ui->tableWidgetIncrement->rowCount()>0){ if (ui->tableWidgetIncrement->rowCount()>0)
{
ui->toolButtonRemove->setEnabled(true); ui->toolButtonRemove->setEnabled(true);
} }
ui->tableWidgetIncrement->resizeColumnsToContents(); ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents(); 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(); 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; qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*linesTable); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
@ -175,18 +203,29 @@ void DialogIncrements::FillLengthLines(){
ui->tableWidgetLines->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetLines->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillLengthSplines(){ void DialogIncrements::FillLengthSplines()
{
const QHash<QString, qreal> *splinesTable = data->DataLengthSplines(); const QHash<QString, qreal> *splinesTable = data->DataLengthSplines();
QHashIterator<QString, qreal> iHash(*splinesTable);
QMap<QString, qreal> map;
//Sorting QHash by name
while (iHash.hasNext())
{
iHash.next();
map.insert(iHash.key(), iHash.value());
}
qint32 currentRow = -1; qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*splinesTable); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
ui->tableWidgetSplines->setRowCount ( splinesTable->size() ); ui->tableWidgetSplines->setRowCount ( splinesTable->size() );
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignLeft);
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
ui->tableWidgetSplines->setItem(currentRow, 0, item); ui->tableWidgetSplines->setItem(currentRow, 0, item);
@ -199,11 +238,22 @@ void DialogIncrements::FillLengthSplines(){
ui->tableWidgetSplines->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetSplines->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FillLengthArcs(){ void DialogIncrements::FillLengthArcs()
{
const QHash<QString, qreal> *arcsTable = data->DataLengthArcs(); const QHash<QString, qreal> *arcsTable = data->DataLengthArcs();
QHashIterator<QString, qreal> iHash(*arcsTable);
QMap<QString, qreal> map;
//Sorting QHash by name
while (iHash.hasNext())
{
iHash.next();
map.insert(iHash.key(), iHash.value());
}
qint32 currentRow = -1; qint32 currentRow = -1;
QHashIterator<QString, qreal> i(*arcsTable); QMapIterator<QString, qreal> i(map);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
currentRow++; currentRow++;
@ -223,7 +273,8 @@ void DialogIncrements::FillLengthArcs(){
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20); ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
} }
void DialogIncrements::FullUpdateFromFile(){ void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
@ -251,7 +302,8 @@ void DialogIncrements::FullUpdateFromFile(){
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
} }
void DialogIncrements::clickedToolButtonAdd(){ void DialogIncrements::clickedToolButtonAdd()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason); ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
@ -260,7 +312,8 @@ void DialogIncrements::clickedToolButtonAdd(){
qint32 num = 1; qint32 num = 1;
QString name; QString name;
do{ do
{
name = QString(tr("Denotation %1")).arg(num); name = QString(tr("Denotation %1")).arg(num);
num++; num++;
} while (data->IncrementTableContains(name)); } while (data->IncrementTableContains(name));
@ -309,9 +362,11 @@ void DialogIncrements::clickedToolButtonAdd(){
ui->toolButtonRemove->setEnabled(true); ui->toolButtonRemove->setEnabled(true);
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
emit haveLiteChange();
} }
void DialogIncrements::clickedToolButtonRemove(){ void DialogIncrements::clickedToolButtonRemove()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem(); QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
@ -320,20 +375,24 @@ void DialogIncrements::clickedToolButtonRemove(){
data->RemoveIncrementTableRow(itemName->text()); data->RemoveIncrementTableRow(itemName->text());
qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole)); qint64 id = qvariant_cast<qint64>(item->data(Qt::UserRole));
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
QDomNodeList list = doc->elementsByTagName("increments"); QDomNodeList list = doc->elementsByTagName("increments");
list.at(0).removeChild(domElement); list.at(0).removeChild(domElement);
} }
ui->tableWidgetIncrement->removeRow(row); ui->tableWidgetIncrement->removeRow(row);
if(ui->tableWidgetIncrement->rowCount() == 0){ if (ui->tableWidgetIncrement->rowCount() == 0)
{
ui->toolButtonRemove->setEnabled(false); ui->toolButtonRemove->setEnabled(false);
} }
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged); &DialogIncrements::cellChanged);
emit haveLiteChange();
} }
void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth,
qreal kgrowth, QString description){ QString description)
{
QDomNodeList list = doc->elementsByTagName("increments"); QDomNodeList list = doc->elementsByTagName("increments");
QDomElement element = doc->createElement("increment"); QDomElement element = doc->createElement("increment");
@ -364,19 +423,24 @@ void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, q
list.at(0).appendChild(element); list.at(0).appendChild(element);
} }
void DialogIncrements::cellChanged ( qint32 row, qint32 column ){ void DialogIncrements::cellChanged ( qint32 row, qint32 column )
QTableWidgetItem *item; {
QTableWidgetItem *itemName; QTableWidgetItem *item = 0;
QTableWidgetItem *itemName = 0;
qint64 id; qint64 id;
QDomElement domElement; QDomElement domElement;
switch(column) { this->row = row;
switch (column)
{
case 0: case 0:
item = ui->tableWidgetIncrement->item(row, 0); item = ui->tableWidgetIncrement->item(row, 0);
id = qvariant_cast<qint64>(item->data(Qt::UserRole)); id = qvariant_cast<qint64>(item->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("name", item->text()); domElement.setAttribute("name", item->text());
data->ClearIncrementTable(); data->ClearIncrementTable();
this->column = 2;
emit FullUpdateTree(); emit FullUpdateTree();
} }
break; break;
@ -385,18 +449,31 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
domElement.setAttribute("base", item->text().toDouble()); {
bool ok = false;
qreal value = item->text().toDouble(&ok);
if (ok)
{
domElement.setAttribute("base", value);
this->column = 3;
emit FullUpdateTree(); emit FullUpdateTree();
} }
else
{
throw VException(tr("Can't convert toDouble value."));
}
}
break; break;
case 3: case 3:
itemName = ui->tableWidgetIncrement->item(row, 0); itemName = ui->tableWidgetIncrement->item(row, 0);
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("ksize", item->text().toDouble()); domElement.setAttribute("ksize", item->text().toDouble());
this->column = 4;
emit FullUpdateTree(); emit FullUpdateTree();
} }
break; break;
@ -405,8 +482,10 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("kgrowth", item->text().toDouble()); domElement.setAttribute("kgrowth", item->text().toDouble());
this->column = 5;
emit FullUpdateTree(); emit FullUpdateTree();
} }
break; break;
@ -415,18 +494,25 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ){
item = ui->tableWidgetIncrement->item(row, column); item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<qint64>(itemName->data(Qt::UserRole)); id = qvariant_cast<qint64>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id)); domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if (domElement.isElement())
{
domElement.setAttribute("description", item->text()); domElement.setAttribute("description", item->text());
VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text()); VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text());
incr.setDescription(item->text()); incr.setDescription(item->text());
data->UpdateIncrementTableRow(itemName->text(), incr); data->UpdateIncrementTableRow(itemName->text(), incr);
ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents();
ui->tableWidgetIncrement->setCurrentCell( row, 0 );
emit haveLiteChange(); emit haveLiteChange();
} }
break; break;
default:
break;
} }
} }
void DialogIncrements::InitialStandartTable(){ void DialogIncrements::InitialStandartTable()
{
ui->tableWidgetStandart->setSortingEnabled(false); ui->tableWidgetStandart->setSortingEnabled(false);
ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation")));
ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value")));
@ -436,7 +522,8 @@ void DialogIncrements::InitialStandartTable(){
ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description")));
} }
void DialogIncrements::InitialIncrementTable(){ void DialogIncrements::InitialIncrementTable()
{
ui->tableWidgetIncrement->setSortingEnabled(false); ui->tableWidgetIncrement->setSortingEnabled(false);
ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value")));
@ -444,27 +531,33 @@ void DialogIncrements::InitialIncrementTable(){
ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth"))); ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth")));
ui->tableWidgetIncrement->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); 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(0, new QTableWidgetItem(tr("Line")));
ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::InitialSplinesTable(){ void DialogIncrements::InitialSplinesTable()
{
ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve"))); ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve")));
ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::InitialArcsTable(){ void DialogIncrements::InitialArcsTable()
{
ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc"))); ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc")));
ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length")));
} }
void DialogIncrements::DialogAccepted(){ void DialogIncrements::DialogAccepted()
{
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
DialogIncrements::~DialogIncrements(){ DialogIncrements::~DialogIncrements()
{
delete ui; delete ui;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,16 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGINCREMENTS_H #ifndef DIALOGINCREMENTS_H
#define DIALOGINCREMENTS_H #define DIALOGINCREMENTS_H
#include "dialogtool.h" #include "dialogtool.h"
#include "xml/vdomdocument.h" #include "../xml/vdomdocument.h"
namespace Ui { namespace Ui
{
class DialogIncrements; class DialogIncrements;
} }
@ -33,7 +41,7 @@ class DialogIncrements : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0); DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0);
~DialogIncrements(); ~DialogIncrements();
public slots: public slots:
void clickedToolButtonAdd(); void clickedToolButtonAdd();
@ -49,6 +57,8 @@ private:
Ui::DialogIncrements *ui; Ui::DialogIncrements *ui;
VContainer *data; // need because we must change data VContainer *data; // need because we must change data
VDomDocument *doc; VDomDocument *doc;
qint32 row;
qint32 column;
void InitialStandartTable(); void InitialStandartTable();
void InitialIncrementTable(); void InitialIncrementTable();
void InitialLinesTable(); void InitialLinesTable();

View File

@ -27,7 +27,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabStandart"> <widget class="QWidget" name="tabStandart">
<attribute name="title"> <attribute name="title">
@ -149,9 +149,15 @@
<attribute name="verticalHeaderVisible"> <attribute name="verticalHeaderVisible">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize"> <attribute name="verticalHeaderDefaultSectionSize">
<number>45</number> <number>45</number>
</attribute> </attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column> <column>
<property name="text"> <property name="text">
<string>Denotation</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,14 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogline.h" #include "dialogline.h"
#include "ui_dialogline.h" #include "ui_dialogline.h"
#include <QPushButton>
#include <QCloseEvent>
DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){ :DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
@ -36,38 +42,36 @@ DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent
number = 0; number = 0;
} }
DialogLine::~DialogLine(){ DialogLine::~DialogLine()
{
delete ui; delete ui;
} }
qint64 DialogLine::getSecondPoint() const{ void DialogLine::setSecondPoint(const qint64 &value)
return secondPoint; {
}
void DialogLine::setSecondPoint(const qint64 &value){
secondPoint = value; secondPoint = value;
VPointF point = data->GetPoint(value); VPointF point = data->GetPoint(value);
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if(index != -1){ if (index != -1)
{
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
} }
} }
qint64 DialogLine::getFirstPoint() const{ void DialogLine::setFirstPoint(const qint64 &value)
return firstPoint; {
}
void DialogLine::setFirstPoint(const qint64 &value){
firstPoint = value; firstPoint = value;
VPointF point = data->GetPoint(value); VPointF point = data->GetPoint(value);
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if(index != -1){ if (index != -1)
{
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
} }
} }
void DialogLine::DialogAccepted(){ void DialogLine::DialogAccepted()
{
qint32 index = ui->comboBoxFirstPoint->currentIndex(); qint32 index = ui->comboBoxFirstPoint->currentIndex();
firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index)); firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
index = ui->comboBoxSecondPoint->currentIndex(); index = ui->comboBoxSecondPoint->currentIndex();
@ -75,42 +79,56 @@ void DialogLine::DialogAccepted(){
DialogClosed(QDialog::Accepted); DialogClosed(QDialog::Accepted);
} }
void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point")); emit ToolTip(tr("Select second point"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGLINE_H #ifndef DIALOGLINE_H
#define DIALOGLINE_H #define DIALOGLINE_H
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogLine; class DialogLine;
} }
@ -32,15 +40,14 @@ class DialogLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogLine(); ~DialogLine();
qint64 getFirstPoint() const; inline qint64 getFirstPoint() const {return firstPoint;}
void setFirstPoint(const qint64 &value); void setFirstPoint(const qint64 &value);
qint64 getSecondPoint() const; inline qint64 getSecondPoint() const {return secondPoint;}
void setSecondPoint(const qint64 &value); void setSecondPoint(const qint64 &value);
public slots: public slots:
void ChoosedObject(qint64 id, Scene::Scenes type); void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogLine) 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialoglineintersect.h" #include "dialoglineintersect.h"
#include "ui_dialoglineintersect.h" #include "ui_dialoglineintersect.h"
DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){ p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true)
{
ui->setupUi(this); ui->setupUi(this);
number = 0; number = 0;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -46,28 +54,39 @@ DialogLineIntersect::~DialogLineIntersect()
delete ui; delete ui;
} }
void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1Line1->findText(point.name()); qint32 index = ui->comboBoxP1Line1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line1->setCurrentIndex(index); ui->comboBoxP1Line1->setCurrentIndex(index);
p1Line1 = id; p1Line1 = id;
number++; number++;
@ -75,9 +94,11 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP2Line1->findText(point.name()); qint32 index = ui->comboBoxP2Line1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line1->setCurrentIndex(index); ui->comboBoxP2Line1->setCurrentIndex(index);
p2Line1 = id; p2Line1 = id;
number++; number++;
@ -85,9 +106,11 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxP1Line2->findText(point.name()); qint32 index = ui->comboBoxP1Line2->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line2->setCurrentIndex(index); ui->comboBoxP1Line2->setCurrentIndex(index);
p1Line2 = id; p1Line2 = id;
number++; number++;
@ -95,15 +118,18 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
return; return;
} }
} }
if(number == 3){ if (number == 3)
{
qint32 index = ui->comboBoxP2Line2->findText(point.name()); qint32 index = ui->comboBoxP2Line2->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line2->setCurrentIndex(index); ui->comboBoxP2Line2->setCurrentIndex(index);
p2Line2 = id; p2Line2 = id;
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
this->show(); this->show();
@ -124,7 +150,8 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
} }
} }
void DialogLineIntersect::DialogAccepted(){ void DialogLineIntersect::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
p1Line1 = getCurrentPointId(ui->comboBoxP1Line1); p1Line1 = getCurrentPointId(ui->comboBoxP1Line1);
p2Line1 = getCurrentPointId(ui->comboBoxP2Line1); p2Line1 = getCurrentPointId(ui->comboBoxP2Line1);
@ -133,36 +160,42 @@ void DialogLineIntersect::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogLineIntersect::P1Line1Changed( int index){ void DialogLineIntersect::P1Line1Changed( int index)
{
p1Line1 = qvariant_cast<qint64>(ui->comboBoxP1Line1->itemData(index)); p1Line1 = qvariant_cast<qint64>(ui->comboBoxP1Line1->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P2Line1Changed(int index){ void DialogLineIntersect::P2Line1Changed(int index)
{
p2Line1 = qvariant_cast<qint64>(ui->comboBoxP2Line1->itemData(index)); p2Line1 = qvariant_cast<qint64>(ui->comboBoxP2Line1->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P1Line2Changed(int index){ void DialogLineIntersect::P1Line2Changed(int index)
{
p1Line2 = qvariant_cast<qint64>(ui->comboBoxP1Line2->itemData(index)); p1Line2 = qvariant_cast<qint64>(ui->comboBoxP1Line2->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::P2Line2Changed(int index){ void DialogLineIntersect::P2Line2Changed(int index)
{
p2Line2 = qvariant_cast<qint64>(ui->comboBoxP2Line2->itemData(index)); p2Line2 = qvariant_cast<qint64>(ui->comboBoxP2Line2->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); CheckState();
} }
void DialogLineIntersect::CheckState(){ void DialogLineIntersect::CheckState()
Q_CHECK_PTR(bOk); {
Q_ASSERT(bOk != 0);
bOk->setEnabled(flagName && flagPoint); bOk->setEnabled(flagName && flagPoint);
} }
bool DialogLineIntersect::CheckIntersecion(){ bool DialogLineIntersect::CheckIntersecion()
{
VPointF p1L1 = data->GetPoint(p1Line1); VPointF p1L1 = data->GetPoint(p1Line1);
VPointF p2L1 = data->GetPoint(p2Line1); VPointF p2L1 = data->GetPoint(p2Line1);
VPointF p1L2 = data->GetPoint(p1Line2); VPointF p1L2 = data->GetPoint(p1Line2);
@ -172,54 +205,42 @@ bool DialogLineIntersect::CheckIntersecion(){
QLineF line2(p1L2.toQPointF(), p2L2.toQPointF()); QLineF line2(p1L2.toQPointF(), p2L2.toQPointF());
QPointF fPoint; QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){ if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
return true; return true;
} else { }
else
{
return false; return false;
} }
} }
qint64 DialogLineIntersect::getP2Line2() const{ void DialogLineIntersect::setP2Line2(const qint64 &value)
return p2Line2; {
}
void DialogLineIntersect::setP2Line2(const qint64 &value){
p2Line2 = value; p2Line2 = value;
ChangeCurrentData(ui->comboBoxP2Line2, value); ChangeCurrentData(ui->comboBoxP2Line2, value);
} }
qint64 DialogLineIntersect::getP1Line2() const{ void DialogLineIntersect::setP1Line2(const qint64 &value)
return p1Line2; {
}
void DialogLineIntersect::setP1Line2(const qint64 &value){
p1Line2 = value; p1Line2 = value;
ChangeCurrentData(ui->comboBoxP1Line2, value); ChangeCurrentData(ui->comboBoxP1Line2, value);
} }
qint64 DialogLineIntersect::getP2Line1() const{ void DialogLineIntersect::setP2Line1(const qint64 &value)
return p2Line1; {
}
void DialogLineIntersect::setP2Line1(const qint64 &value){
p2Line1 = value; p2Line1 = value;
ChangeCurrentData(ui->comboBoxP2Line1, value); ChangeCurrentData(ui->comboBoxP2Line1, value);
} }
qint64 DialogLineIntersect::getP1Line1() const{ void DialogLineIntersect::setP1Line1(const qint64 &value)
return p1Line1; {
}
void DialogLineIntersect::setP1Line1(const qint64 &value){
p1Line1 = value; p1Line1 = value;
ChangeCurrentData(ui->comboBoxP1Line1, value); ChangeCurrentData(ui->comboBoxP1Line1, value);
} }
QString DialogLineIntersect::getPointName() const{ void DialogLineIntersect::setPointName(const QString &value)
return pointName; {
}
void DialogLineIntersect::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGLINEINTERSECT_H #ifndef DIALOGLINEINTERSECT_H
#define DIALOGLINEINTERSECT_H #define DIALOGLINEINTERSECT_H
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogLineIntersect; class DialogLineIntersect;
} }
@ -32,21 +40,21 @@ class DialogLineIntersect : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogLineIntersect(); ~DialogLineIntersect();
qint64 getP1Line1() const; inline qint64 getP1Line1() const {return p1Line1;}
void setP1Line1(const qint64 &value); void setP1Line1(const qint64 &value);
qint64 getP2Line1() const; inline qint64 getP2Line1() const {return p2Line1;}
void setP2Line1(const qint64 &value); void setP2Line1(const qint64 &value);
qint64 getP1Line2() const; inline qint64 getP1Line2() const {return p1Line2;}
void setP1Line2(const qint64 &value); void setP1Line2(const qint64 &value);
qint64 getP2Line2() const; inline qint64 getP2Line2() const {return p2Line2;}
void setP2Line2(const qint64 &value); void setP2Line2(const qint64 &value);
QString getPointName() const; inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
void P1Line1Changed( int index); void P1Line1Changed( int index);
void P2Line1Changed( 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialognormal.h" #include "dialognormal.h"
#include "ui_dialognormal.h" #include "ui_dialognormal.h"
#include <QMenu>
DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this); ui->setupUi(this);
spinBoxAngle = ui->doubleSpinBoxAngle; spinBoxAngle = ui->doubleSpinBoxAngle;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -35,6 +42,8 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula; lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogNormal::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogNormal::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogNormal::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogNormal::LengthLines); 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->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged);
@ -84,49 +95,64 @@ DialogNormal::~DialogNormal()
delete ui; delete ui;
} }
void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name()); qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxSecondPoint->findText(point.name()); qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogNormal::DialogAccepted(){ void DialogNormal::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -136,54 +162,36 @@ void DialogNormal::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
qint64 DialogNormal::getSecondPointId() const{ void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id)
return secondPointId; {
}
void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
} }
qint64 DialogNormal::getFirstPointId() const{ void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id)
return firstPointId; {
}
void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
} }
qreal DialogNormal::getAngle() const{ void DialogNormal::setAngle(const qreal &value)
return angle; {
}
void DialogNormal::setAngle(const qreal &value){
angle = value; angle = value;
ui->doubleSpinBoxAngle->setValue(angle); ui->doubleSpinBoxAngle->setValue(angle);
} }
QString DialogNormal::getFormula() const{ void DialogNormal::setFormula(const QString &value)
return formula; {
}
void DialogNormal::setFormula(const QString &value){
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
QString DialogNormal::getTypeLine() const{ void DialogNormal::setTypeLine(const QString &value)
return typeLine; {
}
void DialogNormal::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
QString DialogNormal::getPointName() const{ void DialogNormal::setPointName(const QString &value)
return pointName; {
}
void DialogNormal::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,16 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGNORMAL_H #ifndef DIALOGNORMAL_H
#define DIALOGNORMAL_H #define DIALOGNORMAL_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QListWidgetItem>
#include "container/calculator.h"
namespace Ui { namespace Ui
{
class DialogNormal; class DialogNormal;
} }
@ -34,23 +40,22 @@ class DialogNormal : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogNormal(); ~DialogNormal();
QString getPointName() const; inline QString getPointName() const{return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
QString getTypeLine() const; inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value); void setTypeLine(const QString &value);
QString getFormula() const; inline QString getFormula() const {return formula;}
void setFormula(const QString &value); void setFormula(const QString &value);
qreal getAngle() const; inline qreal getAngle() const {return angle;}
void setAngle(const qreal &value); void setAngle(const qreal &value);
qint64 getFirstPointId() const; inline qint64 getFirstPointId() const {return firstPointId;}
void setFirstPointId(const qint64 &value, const qint64 &id); 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); void setSecondPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogNormal) Q_DISABLE_COPY(DialogNormal)

View File

@ -519,7 +519,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of arcs</string>
@ -529,7 +529,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,13 +24,14 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogpointofcontact.h" #include "dialogpointofcontact.h"
DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0), :DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0){ firstPoint(0), secondPoint(0)
{
ui.setupUi(this); ui.setupUi(this);
listWidget = ui.listWidget; listWidget = ui.listWidget;
labelResultCalculation = ui.labelResultCalculation; labelResultCalculation = ui.labelResultCalculation;
@ -32,6 +40,8 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
radioButtonStandartTable = ui.radioButtonStandartTable; radioButtonStandartTable = ui.radioButtonStandartTable;
radioButtonIncrements = ui.radioButtonIncrements; radioButtonIncrements = ui.radioButtonIncrements;
radioButtonLengthLine = ui.radioButtonLengthLine; radioButtonLengthLine = ui.radioButtonLengthLine;
radioButtonLengthArc = ui.radioButtonLengthArc;
radioButtonLengthCurve = ui.radioButtonLengthSpline;
lineEditFormula = ui.lineEditFormula; lineEditFormula = ui.lineEditFormula;
labelEditFormula = ui.labelEditFormula; labelEditFormula = ui.labelEditFormula;
labelEditNamePoint = ui.labelEditNamePoint; 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.radioButtonStandartTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandartTable);
connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments);
connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); 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.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula);
connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged);
} }
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui.comboBoxFirstPoint->findText(point.name()); qint32 index = ui.comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxFirstPoint->setCurrentIndex(index); ui.comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui.comboBoxSecondPoint->findText(point.name()); qint32 index = ui.comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxSecondPoint->setCurrentIndex(index); ui.comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point of center of arc")); emit ToolTip(tr("Select point of center of arc"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui.comboBoxCenter->findText(point.name()); qint32 index = ui.comboBoxCenter->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui.comboBoxCenter->setCurrentIndex(index); ui.comboBoxCenter->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogPointOfContact::DialogAccepted()
void DialogPointOfContact::DialogAccepted(){ {
pointName = ui.lineEditNamePoint->text(); pointName = ui.lineEditNamePoint->text();
radius = ui.lineEditFormula->text(); radius = ui.lineEditFormula->text();
center = getCurrentPointId(ui.comboBoxCenter); center = getCurrentPointId(ui.comboBoxCenter);
@ -121,45 +149,30 @@ void DialogPointOfContact::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
qint64 DialogPointOfContact::getSecondPoint() const{ void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id)
return secondPoint; {
}
void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id); setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id);
} }
qint64 DialogPointOfContact::getFirstPoint() const{ void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id)
return firstPoint; {
}
void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id); setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id);
} }
qint64 DialogPointOfContact::getCenter() const{ void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id)
return center; {
}
void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxCenter, center, value, id); setCurrentPointId(ui.comboBoxCenter, center, value, id);
center = value; center = value;
} }
QString DialogPointOfContact::getRadius() const{ void DialogPointOfContact::setRadius(const QString &value)
return radius; {
}
void DialogPointOfContact::setRadius(const QString &value){
radius = value; radius = value;
ui.lineEditFormula->setText(radius); ui.lineEditFormula->setText(radius);
} }
QString DialogPointOfContact::getPointName() const{ void DialogPointOfContact::setPointName(const QString &value)
return pointName; {
}
void DialogPointOfContact::setPointName(const QString &value){
pointName = value; pointName = value;
ui.lineEditNamePoint->setText(pointName); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,39 +24,32 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGPOINTOFCONTACT_H #ifndef DIALOGPOINTOFCONTACT_H
#define DIALOGPOINTOFCONTACT_H #define DIALOGPOINTOFCONTACT_H
#include "ui_dialogpointofcontact.h" #include "ui_dialogpointofcontact.h"
#include "dialogtool.h" #include "dialogtool.h"
#include "container/calculator.h"
class DialogPointOfContact : public DialogTool class DialogPointOfContact : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
QString getPointName() const; inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
inline QString getRadius() const {return radius;}
QString getRadius() const;
void setRadius(const QString &value); void setRadius(const QString &value);
inline qint64 getCenter() const {return center;}
qint64 getCenter() const;
void setCenter(const qint64 &value, const qint64 &id); void setCenter(const qint64 &value, const qint64 &id);
inline qint64 getFirstPoint() const {return firstPoint;}
qint64 getFirstPoint() const;
void setFirstPoint(const qint64 &value, const qint64 &id); void setFirstPoint(const qint64 &value, const qint64 &id);
inline qint64 getSecondPoint() const {return secondPoint;}
qint64 getSecondPoint() const;
void setSecondPoint(const qint64 &value, const qint64 &id); void setSecondPoint(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogPointOfContact) Q_DISABLE_COPY(DialogPointOfContact)

View File

@ -359,7 +359,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of arcs</string> <string>Length of arcs</string>
@ -369,7 +369,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGS_H #ifndef DIALOGS_H
#define DIALOGS_H #define DIALOGS_H
@ -37,5 +44,6 @@
#include "dialogsinglepoint.h" #include "dialogsinglepoint.h"
#include "dialogspline.h" #include "dialogspline.h"
#include "dialogsplinepath.h" #include "dialogsplinepath.h"
#include "dialogheight.h"
#endif // DIALOGS_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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogshoulderpoint.h" #include "dialogshoulderpoint.h"
#include "ui_dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h"
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), :DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){ typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0)
{
ui->setupUi(this); ui->setupUi(this);
number = 0; number = 0;
listWidget = ui->listWidget; listWidget = ui->listWidget;
@ -34,6 +42,8 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
radioButtonStandartTable = ui->radioButtonStandartTable; radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula; lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; 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->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogShoulderPoint::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogShoulderPoint::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogShoulderPoint::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthLines); 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->toolButtonEqual, &QPushButton::clicked, this, &DialogShoulderPoint::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged);
@ -68,58 +80,75 @@ DialogShoulderPoint::~DialogShoulderPoint()
delete ui; delete ui;
} }
void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1Line->findText(point.name()); qint32 index = ui->comboBoxP1Line->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line->setCurrentIndex(index); ui->comboBoxP1Line->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP2Line->findText(point.name()); qint32 index = ui->comboBoxP2Line->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index); ui->comboBoxP2Line->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point of shoulder")); emit ToolTip(tr("Select point of shoulder"));
return; return;
} }
} }
if(number == 2){ if (number == 2)
{
qint32 index = ui->comboBoxPShoulder->findText(point.name()); qint32 index = ui->comboBoxPShoulder->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index); ui->comboBoxPShoulder->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogShoulderPoint::DialogAccepted(){ void DialogShoulderPoint::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType); typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text(); formula = ui->lineEditFormula->text();
@ -129,53 +158,35 @@ void DialogShoulderPoint::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
qint64 DialogShoulderPoint::getPShoulder() const{ void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id)
return pShoulder; {
}
void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id); setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id);
} }
qint64 DialogShoulderPoint::getP2Line() const{ void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id)
return p2Line; {
}
void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id); setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id);
} }
qint64 DialogShoulderPoint::getP1Line() const{ void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id)
return p1Line; {
}
void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id){
setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id); setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id);
} }
QString DialogShoulderPoint::getFormula() const{ void DialogShoulderPoint::setFormula(const QString &value)
return formula; {
}
void DialogShoulderPoint::setFormula(const QString &value){
formula = value; formula = value;
ui->lineEditFormula->setText(formula); ui->lineEditFormula->setText(formula);
} }
QString DialogShoulderPoint::getTypeLine() const{ void DialogShoulderPoint::setTypeLine(const QString &value)
return typeLine; {
}
void DialogShoulderPoint::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value); SetupTypeLine(ui->comboBoxLineType, value);
} }
QString DialogShoulderPoint::getPointName() const{ void DialogShoulderPoint::setPointName(const QString &value)
return pointName; {
}
void DialogShoulderPoint::setPointName(const QString &value){
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGSHOULDERPOINT_H #ifndef DIALOGSHOULDERPOINT_H
#define DIALOGSHOULDERPOINT_H #define DIALOGSHOULDERPOINT_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/calculator.h"
namespace Ui { namespace Ui
{
class DialogShoulderPoint; class DialogShoulderPoint;
} }
@ -33,23 +40,23 @@ class DialogShoulderPoint : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogShoulderPoint(); ~DialogShoulderPoint();
QString getPointName() const; inline QString getPointName() const {return pointName;}
void setPointName(const QString &value); void setPointName(const QString &value);
QString getTypeLine() const; inline QString getTypeLine() const {return typeLine;}
void setTypeLine(const QString &value); void setTypeLine(const QString &value);
QString getFormula() const; inline QString getFormula() const {return formula;}
void setFormula(const QString &value); void setFormula(const QString &value);
qint64 getP1Line() const; inline qint64 getP1Line() const {return p1Line;}
void setP1Line(const qint64 &value, const qint64 &id); void setP1Line(const qint64 &value, const qint64 &id);
qint64 getP2Line() const; inline qint64 getP2Line() const {return p2Line;}
void setP2Line(const qint64 &value, const qint64 &id); void setP2Line(const qint64 &value, const qint64 &id);
qint64 getPShoulder() const; inline qint64 getPShoulder() const {return pShoulder;}
void setPShoulder(const qint64 &value, const qint64 &id); void setPShoulder(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogShoulderPoint) Q_DISABLE_COPY(DialogShoulderPoint)

View File

@ -380,7 +380,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthArc"> <widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of lines</string> <string>Length of lines</string>
@ -390,7 +390,7 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonLengthSpline"> <widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Length of curves</string> <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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,21 +24,18 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogsinglepoint.h" #include "dialogsinglepoint.h"
#include "ui_dialogsinglepoint.h" #include "ui_dialogsinglepoint.h"
#include <QShowEvent>
#include <QPushButton>
#include <QDebug>
#include "options.h"
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) : DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()), :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF()){ point(QPointF())
{
ui->setupUi(this); ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0,PaperSize/PrintDPI*25.4); ui->doubleSpinBoxX->setRange(0, toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4); ui->doubleSpinBoxY->setRange(0, toMM(PaperSize));
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
labelEditNamePoint = ui->labelEditName; labelEditNamePoint = ui->labelEditName;
flagName = false; flagName = false;
@ -42,42 +46,39 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged); connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged);
} }
void DialogSinglePoint::mousePress(QPointF scenePos){ void DialogSinglePoint::mousePress(const QPointF &scenePos)
if(isInitialized == false){ {
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4); if (isInitialized == false)
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4); {
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
this->show(); this->show();
} else { }
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4); else
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4); {
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
} }
} }
void DialogSinglePoint::DialogAccepted(){ void DialogSinglePoint::DialogAccepted()
point = QPointF(ui->doubleSpinBoxX->value()*PrintDPI/25.4, {
ui->doubleSpinBoxY->value()*PrintDPI/25.4); point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
name = ui->lineEditName->text(); name = ui->lineEditName->text();
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogSinglePoint::setData(const QString name, const QPointF point){ void DialogSinglePoint::setData(const QString &name, const QPointF &point)
{
this->name = name; this->name = name;
this->point = point; this->point = point;
isInitialized = true; isInitialized = true;
ui->lineEditName->setText(name); ui->lineEditName->setText(name);
ui->doubleSpinBoxX->setValue(point.x()/PrintDPI*25.4); ui->doubleSpinBoxX->setValue(toMM(point.x()));
ui->doubleSpinBoxY->setValue(point.y()/PrintDPI*25.4); ui->doubleSpinBoxY->setValue(toMM(point.y()));
} }
QString DialogSinglePoint::getName()const{ DialogSinglePoint::~DialogSinglePoint()
return name; {
}
QPointF DialogSinglePoint::getPoint()const{
return point;
}
DialogSinglePoint::~DialogSinglePoint(){
delete ui; 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGSINGLEPOINT_H #ifndef DIALOGSINGLEPOINT_H
#define DIALOGSINGLEPOINT_H #define DIALOGSINGLEPOINT_H
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogSinglePoint; class DialogSinglePoint;
} }
@ -32,13 +40,13 @@ class DialogSinglePoint : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSinglePoint(const VContainer *data, QWidget *parent = 0); DialogSinglePoint(const VContainer *data, QWidget *parent = 0);
void setData(const QString name, const QPointF point); void setData(const QString &name, const QPointF &point);
QString getName()const; inline QString getName()const {return name;}
QPointF getPoint()const; inline QPointF getPoint()const {return point;}
~DialogSinglePoint(); ~DialogSinglePoint();
public slots: public slots:
void mousePress(QPointF scenePos); void mousePress(const QPointF &scenePos);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogSinglePoint) Q_DISABLE_COPY(DialogSinglePoint)

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,63 +24,79 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogspline.h" #include "dialogspline.h"
#include "ui_dialogspline.h" #include "ui_dialogspline.h"
DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), :DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
kAsm1(1), kAsm2(1), kCurve(1){ kAsm1(1), kAsm2(1), kCurve(1)
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4); FillComboBoxPoints(ui->comboBoxP4);
} }
} }
DialogSpline::~DialogSpline(){ DialogSpline::~DialogSpline()
{
delete ui; delete ui;
} }
void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4); FillComboBoxPoints(ui->comboBoxP4);
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
if(number == 0){ if (number == 0)
{
qint32 index = ui->comboBoxP1->findText(point.name()); qint32 index = ui->comboBoxP1->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1->setCurrentIndex(index); ui->comboBoxP1->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select last point of curve")); emit ToolTip(tr("Select last point of curve"));
return; return;
} }
} }
if(number == 1){ if (number == 1)
{
qint32 index = ui->comboBoxP4->findText(point.name()); qint32 index = ui->comboBoxP4->findText(point.name());
if ( index != -1 ) { // -1 for not found if ( index != -1 )
{ // -1 for not found
ui->comboBoxP4->setCurrentIndex(index); ui->comboBoxP4->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
@ -81,24 +104,29 @@ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index)); qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
QPointF p1; QPointF p1;
QPointF p4; QPointF p4;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
p1 = data->GetPoint(p1Id).toQPointF(); p1 = data->GetPoint(p1Id).toQPointF();
p4 = data->GetPoint(id).toQPointF(); p4 = data->GetPoint(id).toQPointF();
} else { }
else
{
p1 = data->GetModelingPoint(p1Id).toQPointF(); p1 = data->GetModelingPoint(p1Id).toQPointF();
p4 = data->GetModelingPoint(id).toQPointF(); p4 = data->GetModelingPoint(id).toQPointF();
} }
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle())); ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle())); ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
} }
if(!isInitialized){ if (isInitialized == false)
{
this->show(); this->show();
} }
} }
} }
} }
void DialogSpline::DialogAccepted(){ void DialogSpline::DialogAccepted()
{
p1 = getCurrentPointId(ui->comboBoxP1); p1 = getCurrentPointId(ui->comboBoxP1);
p4 = getCurrentPointId(ui->comboBoxP4); p4 = getCurrentPointId(ui->comboBoxP4);
angle1 = ui->spinBoxAngle1->value(); angle1 = ui->spinBoxAngle1->value();
@ -109,65 +137,44 @@ void DialogSpline::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
qreal DialogSpline::getKCurve() const{ void DialogSpline::setKCurve(const qreal &value)
return kCurve; {
}
void DialogSpline::setKCurve(const qreal &value){
kCurve = value; kCurve = value;
ui->doubleSpinBoxKcurve->setValue(value); ui->doubleSpinBoxKcurve->setValue(value);
} }
qreal DialogSpline::getKAsm2() const{ void DialogSpline::setKAsm2(const qreal &value)
return kAsm2; {
}
void DialogSpline::setKAsm2(const qreal &value){
kAsm2 = value; kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(value); ui->doubleSpinBoxKasm2->setValue(value);
} }
qreal DialogSpline::getKAsm1() const{ void DialogSpline::setKAsm1(const qreal &value)
return kAsm1; {
}
void DialogSpline::setKAsm1(const qreal &value){
kAsm1 = value; kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(value); ui->doubleSpinBoxKasm1->setValue(value);
} }
qreal DialogSpline::getAngle2() const{ void DialogSpline::setAngle2(const qreal &value)
return angle2; {
}
void DialogSpline::setAngle2(const qreal &value){
angle2 = value; angle2 = value;
ui->spinBoxAngle2->setValue(static_cast<qint32>(value)); ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
} }
qreal DialogSpline::getAngle1() const{ void DialogSpline::setAngle1(const qreal &value)
return angle1; {
}
void DialogSpline::setAngle1(const qreal &value){
angle1 = value; angle1 = value;
ui->spinBoxAngle1->setValue(static_cast<qint32>(value)); ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
} }
qint64 DialogSpline::getP4() const{ void DialogSpline::setP4(const qint64 &value)
return p4; {
}
void DialogSpline::setP4(const qint64 &value){
p4 = value; p4 = value;
ChangeCurrentData(ui->comboBoxP4, value); ChangeCurrentData(ui->comboBoxP4, value);
} }
qint64 DialogSpline::getP1() const{ void DialogSpline::setP1(const qint64 &value)
return p1; {
}
void DialogSpline::setP1(const qint64 &value){
p1 = value; p1 = value;
ChangeCurrentData(ui->comboBoxP1, 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGSPLINE_H #ifndef DIALOGSPLINE_H
#define DIALOGSPLINE_H #define DIALOGSPLINE_H
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
{
class DialogSpline; class DialogSpline;
} }
@ -32,25 +40,24 @@ class DialogSpline : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0);
~DialogSpline(); ~DialogSpline();
qint64 getP1() const; inline qint64 getP1() const {return p1;}
void setP1(const qint64 &value); void setP1(const qint64 &value);
qint64 getP4() const; inline qint64 getP4() const {return p4;}
void setP4(const qint64 &value); void setP4(const qint64 &value);
qreal getAngle1() const; inline qreal getAngle1() const {return angle1;}
void setAngle1(const qreal &value); void setAngle1(const qreal &value);
qreal getAngle2() const; inline qreal getAngle2() const {return angle2;}
void setAngle2(const qreal &value); void setAngle2(const qreal &value);
qreal getKAsm1() const; inline qreal getKAsm1() const {return kAsm1;}
void setKAsm1(const qreal &value); void setKAsm1(const qreal &value);
qreal getKAsm2() const; inline qreal getKAsm2() const {return kAsm2;}
void setKAsm2(const qreal &value); void setKAsm2(const qreal &value);
qreal getKCurve() const; inline qreal getKCurve() const {return kCurve;}
void setKCurve(const qreal &value); void setKCurve(const qreal &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogSpline) Q_DISABLE_COPY(DialogSpline)

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,14 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogsplinepath.h" #include "dialogsplinepath.h"
#include "ui_dialogsplinepath.h" #include "ui_dialogsplinepath.h"
#include "geometry/vsplinepoint.h" #include "../geometry/vsplinepoint.h"
DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent) : DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){ :DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
{
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted);
@ -53,14 +61,12 @@ DialogSplinePath::~DialogSplinePath()
delete ui; delete ui;
} }
VSplinePath DialogSplinePath::GetPath() const{ void DialogSplinePath::SetPath(const VSplinePath &value)
return path; {
}
void DialogSplinePath::SetPath(const VSplinePath &value){
this->path = value; this->path = value;
ui->listWidget->clear(); ui->listWidget->clear();
for(qint32 i = 0; i < path.CountPoint(); ++i){ for (qint32 i = 0; i < path.CountPoint(); ++i)
{
NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2()); NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
} }
ui->listWidget->setFocus(Qt::OtherFocusReason); ui->listWidget->setFocus(Qt::OtherFocusReason);
@ -68,28 +74,36 @@ void DialogSplinePath::SetPath(const VSplinePath &value){
} }
void DialogSplinePath::ChoosedObject(qint64 id, Scene::Scenes type){ void DialogSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
if(idDetail == 0 && mode == Draw::Modeling){ {
if(type == Scene::Detail){ if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id; idDetail = id;
return; return;
} }
} }
if(mode == Draw::Modeling){ if (mode == Draw::Modeling)
if(!CheckObject(id)){ {
if (CheckObject(id) == false)
{
return; return;
} }
} }
if(type == Scene::Point){ if (type == Scene::Point)
{
NewItem(id, 1, 0, 1); NewItem(id, 1, 0, 1);
emit ToolTip(tr("Select point of curve path")); emit ToolTip(tr("Select point of curve path"));
this->show(); this->show();
} }
} }
void DialogSplinePath::DialogAccepted(){ void DialogSplinePath::DialogAccepted()
{
path.Clear(); path.Clear();
for(qint32 i = 0; i < ui->listWidget->count(); ++i){ for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i); QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole))); path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
} }
@ -98,8 +112,10 @@ void DialogSplinePath::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogSplinePath::PointChenged(int row){ void DialogSplinePath::PointChenged(int row)
if(ui->listWidget->count() == 0){ {
if (ui->listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
@ -108,7 +124,8 @@ void DialogSplinePath::PointChenged(int row){
EnableFields(); EnableFields();
} }
void DialogSplinePath::currentPointChanged(int index){ void DialogSplinePath::currentPointChanged(int index)
{
qint64 id = qvariant_cast<qint64>(ui->comboBoxPoint->itemData(index)); qint64 id = qvariant_cast<qint64>(ui->comboBoxPoint->itemData(index));
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
@ -119,15 +136,18 @@ void DialogSplinePath::currentPointChanged(int index){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::Angle1Changed(int index){ void DialogSplinePath::Angle1Changed(int index)
{
SetAngle(index+180); SetAngle(index+180);
} }
void DialogSplinePath::Angle2Changed(int index){ void DialogSplinePath::Angle2Changed(int index)
{
SetAngle(index); SetAngle(index);
} }
void DialogSplinePath::KAsm1Changed(qreal d){ void DialogSplinePath::KAsm1Changed(qreal d)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
@ -135,7 +155,8 @@ void DialogSplinePath::KAsm1Changed(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::KAsm2Changed(qreal d){ void DialogSplinePath::KAsm2Changed(qreal d)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
@ -143,11 +164,15 @@ void DialogSplinePath::KAsm2Changed(qreal d){
item->setData(Qt::UserRole, QVariant::fromValue(p)); item->setData(Qt::UserRole, QVariant::fromValue(p));
} }
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2){ void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
point = data->GetPoint(id); point = data->GetPoint(id);
} else { }
else
{
point = data->GetModelingPoint(id); point = data->GetModelingPoint(id);
} }
QListWidgetItem *item = new QListWidgetItem(point.name()); QListWidgetItem *item = new QListWidgetItem(point.name());
@ -159,7 +184,8 @@ void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
EnableFields(); EnableFields();
} }
void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2){ void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
{
disconnect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &DialogSplinePath::currentPointChanged); this, &DialogSplinePath::currentPointChanged);
disconnect(ui->spinBoxAngle1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), disconnect(ui->spinBoxAngle1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
@ -189,25 +215,29 @@ void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAs
this, &DialogSplinePath::KAsm2Changed); this, &DialogSplinePath::KAsm2Changed);
} }
void DialogSplinePath::EnableFields(){ void DialogSplinePath::EnableFields()
{
ui->doubleSpinBoxKasm1->setEnabled(true); ui->doubleSpinBoxKasm1->setEnabled(true);
ui->spinBoxAngle1->setEnabled(true); ui->spinBoxAngle1->setEnabled(true);
ui->doubleSpinBoxKasm2->setEnabled(true); ui->doubleSpinBoxKasm2->setEnabled(true);
ui->spinBoxAngle2->setEnabled(true); ui->spinBoxAngle2->setEnabled(true);
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
if(row == 0){ if (row == 0)
{
ui->doubleSpinBoxKasm1->setEnabled(false); ui->doubleSpinBoxKasm1->setEnabled(false);
ui->spinBoxAngle1->setEnabled(false); ui->spinBoxAngle1->setEnabled(false);
return; return;
} }
if(row == ui->listWidget->count()-1){ if (row == ui->listWidget->count()-1)
{
ui->doubleSpinBoxKasm2->setEnabled(false); ui->doubleSpinBoxKasm2->setEnabled(false);
ui->spinBoxAngle2->setEnabled(false); ui->spinBoxAngle2->setEnabled(false);
return; return;
} }
} }
void DialogSplinePath::SetAngle(qint32 angle){ void DialogSplinePath::SetAngle(qint32 angle)
{
qint32 row = ui->listWidget->currentRow(); qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)); VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,16 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGSPLINEPATH_H #ifndef DIALOGSPLINEPATH_H
#define DIALOGSPLINEPATH_H #define DIALOGSPLINEPATH_H
#include "dialogtool.h" #include "dialogtool.h"
#include "geometry/vsplinepath.h" #include "../geometry/vsplinepath.h"
namespace Ui { namespace Ui
{
class DialogSplinePath; class DialogSplinePath;
} }
@ -33,13 +41,13 @@ class DialogSplinePath : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogSplinePath(); ~DialogSplinePath();
VSplinePath GetPath() const; inline VSplinePath GetPath() const {return path;}
void SetPath(const VSplinePath &value); void SetPath(const VSplinePath &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
virtual void DialogAccepted(); virtual void DialogAccepted();
void PointChenged(int row); void PointChenged(int row);
void currentPointChanged( int index ); void currentPointChanged( int index );

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,63 +24,70 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "dialogtool.h" #include "dialogtool.h"
#include <QListWidgetItem> #include "../container/calculator.h"
#include <QCloseEvent>
#include "container/calculator.h"
#include "geometry/vdetail.h"
#include <QDebug>
DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent):QDialog(parent), data(data), DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent)
isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0), :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0), labelEditNamePoint(0), spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0), radioButtonIncrements(0), labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0),
radioButtonLengthLine(0), idDetail(0), mode(mode){ radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0),
Q_CHECK_PTR(data); idDetail(0), mode(mode)
{
Q_ASSERT(data != 0);
timerFormula = new QTimer(this); timerFormula = new QTimer(this);
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula); connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
} }
DialogTool::~DialogTool(){ void DialogTool::closeEvent(QCloseEvent *event)
} {
void DialogTool::closeEvent(QCloseEvent *event){
DialogClosed(QDialog::Rejected); DialogClosed(QDialog::Rejected);
event->accept(); event->accept();
} }
void DialogTool::showEvent(QShowEvent *event){ void DialogTool::showEvent(QShowEvent *event)
{
QDialog::showEvent( event ); QDialog::showEvent( event );
if( event->spontaneous() ){ if ( event->spontaneous() )
{
return; return;
} }
if(isInitialized){ if (isInitialized)
{
return; return;
} }
isInitialized = true;//first show windows are held isInitialized = true;//first show windows are held
} }
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
{
box->clear(); box->clear();
if(mode == Draw::Calculation){ if (mode == Draw::Calculation)
{
const QHash<qint64, VPointF> *points = data->DataPoints(); const QHash<qint64, VPointF> *points = data->DataPoints();
QHashIterator<qint64, VPointF> i(*points); QHashIterator<qint64, VPointF> i(*points);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
if(i.key() != id){ if (i.key() != id)
{
VPointF point = i.value(); VPointF point = i.value();
box->addItem(point.name(), i.key()); box->addItem(point.name(), i.key());
} }
} }
} else { }
if(idDetail <= 0){ else
{
if (idDetail <= 0)
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO; qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return; return;
} }
VDetail det = data->GetDetail(idDetail); VDetail det = data->GetDetail(idDetail);
for(qint32 i = 0; i< det.CountNode(); ++i){ for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::NodePoint || if (det[i].getTypeTool() == Tool::NodePoint ||
det[i].getTypeTool() == Tool::AlongLineTool || det[i].getTypeTool() == Tool::AlongLineTool ||
det[i].getTypeTool() == Tool::BisectorTool || det[i].getTypeTool() == Tool::BisectorTool ||
@ -81,8 +95,10 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
det[i].getTypeTool() == Tool::LineIntersectTool || det[i].getTypeTool() == Tool::LineIntersectTool ||
det[i].getTypeTool() == Tool::NormalTool || det[i].getTypeTool() == Tool::NormalTool ||
det[i].getTypeTool() == Tool::PointOfContact || det[i].getTypeTool() == Tool::PointOfContact ||
det[i].getTypeTool() == Tool::ShoulderPointTool){ det[i].getTypeTool() == Tool::ShoulderPointTool)
if(det[i].getId() != id){ {
if (det[i].getId() != id)
{
VPointF point = data->GetModelingPoint(det[i].getId()); VPointF point = data->GetModelingPoint(det[i].getId());
box->addItem(point.name(), det[i].getId()); box->addItem(point.name(), det[i].getId());
} }
@ -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; QStringList list;
list<<tr("Line")<<tr("No line"); list<<tr("Line")<<tr("No line");
box->addItems(list); box->addItems(list);
} }
QString DialogTool::GetTypeLine(const QComboBox *box) const{ QString DialogTool::GetTypeLine(const QComboBox *box) const
if(box->currentText()==tr("Line")){ {
if (box->currentText()==tr("Line"))
{
return QString("hair"); return QString("hair");
} else { }
else
{
return QString("none"); return QString("none");
} }
} }
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value){ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
if(value == "hair"){ {
if (value == "hair")
{
qint32 index = box->findText(tr("Line")); qint32 index = box->findText(tr("Line"));
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
if(value == "none"){ if (value == "none")
{
qint32 index = box->findText(tr("No line")); qint32 index = box->findText(tr("No line"));
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
} }
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value){ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
{
qint32 index = box->findText(value); qint32 index = box->findText(value);
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
else
{
qWarning()<<tr("Can't find point by name")<<value;
}
} }
void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value) const{ void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value) const
{
qint32 index = box->findData(value); qint32 index = box->findData(value);
if(index != -1){ if (index != -1)
{
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
} }
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget){ void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
Q_CHECK_PTR(lineEdit); {
Q_CHECK_PTR(listWidget); Q_ASSERT(lineEdit != 0);
Q_ASSERT(listWidget != 0);
QListWidgetItem *item = listWidget->currentItem(); QListWidgetItem *item = listWidget->currentItem();
QString val = item->text(); int pos = lineEdit->cursorPosition();
lineEdit->setText(lineEdit->text().append(val)); lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
lineEdit->setFocus(); lineEdit->setFocus();
lineEdit->setCursorPosition(pos + item->text().size());
} }
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
Q_CHECK_PTR(edit); {
Q_CHECK_PTR(timer); Q_ASSERT(edit != 0);
Q_CHECK_PTR(labelEditFormula); Q_ASSERT(timer != 0);
if(edit->text().isEmpty()){ Q_ASSERT(labelEditFormula != 0);
if (edit->text().isEmpty())
{
flag = false; flag = false;
CheckState(); CheckState();
QPalette palette = labelEditFormula->palette(); QPalette palette = labelEditFormula->palette();
@ -158,24 +197,31 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer){
timer->start(1000); timer->start(1000);
} }
void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label){ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
Q_CHECK_PTR(edit); {
Q_CHECK_PTR(timer); Q_ASSERT(edit != 0);
Q_CHECK_PTR(label); Q_ASSERT(timer != 0);
Q_CHECK_PTR(labelEditFormula); Q_ASSERT(label != 0);
Q_ASSERT(labelEditFormula != 0);
QPalette palette = labelEditFormula->palette(); QPalette palette = labelEditFormula->palette();
if(edit->text().isEmpty()){ if (edit->text().isEmpty())
{
flag = false; flag = false;
palette.setColor(labelEditFormula->foregroundRole(), Qt::red); palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
} else { }
else
{
Calculator cal(data); Calculator cal(data);
QString errorMsg; QString errorMsg;
qreal result = cal.eval(edit->text(), &errorMsg); qreal result = cal.eval(edit->text(), &errorMsg);
if(!errorMsg.isEmpty()){ if (errorMsg.isEmpty() == false)
{
label->setText(tr("Error")); label->setText(tr("Error"));
flag = false; flag = false;
palette.setColor(labelEditFormula->foregroundRole(), Qt::red); palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
} else { }
else
{
label->setText(QString().setNum(result)); label->setText(QString().setNum(result));
flag = true; flag = true;
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
@ -186,47 +232,57 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
labelEditFormula->setPalette(palette); labelEditFormula->setPalette(palette);
} }
void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const
const qint64 &id) const{ {
Q_CHECK_PTR(box); Q_ASSERT(box != 0);
FillComboBoxPoints(box, id); FillComboBoxPoints(box, id);
pointId = value; pointId = value;
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
qint64 DialogTool::getCurrentPointId(QComboBox *box) const{ qint64 DialogTool::getCurrentPointId(QComboBox *box) const
Q_CHECK_PTR(box); {
Q_ASSERT(box != 0);
qint32 index = box->currentIndex(); qint32 index = box->currentIndex();
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if(index != -1){ if (index != -1)
{
return qvariant_cast<qint64>(box->itemData(index)); return qvariant_cast<qint64>(box->itemData(index));
} else { }
else
{
return -1; return -1;
} }
} }
void DialogTool::CheckState(){ void DialogTool::CheckState()
Q_CHECK_PTR(bOk); {
Q_ASSERT(bOk != 0);
bOk->setEnabled(flagFormula && flagName); bOk->setEnabled(flagFormula && flagName);
} }
void DialogTool::ChoosedObject(qint64 id, const Scene::Scenes &type)
void DialogTool::ChoosedObject(qint64 id, Scene::Scenes type){ {
Q_UNUSED(id); Q_UNUSED(id);
Q_UNUSED(type); Q_UNUSED(type);
} }
void DialogTool::NamePointChanged(){ void DialogTool::NamePointChanged()
Q_CHECK_PTR(labelEditNamePoint); {
Q_ASSERT(labelEditNamePoint != 0);
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit){ if (edit)
{
QString name = edit->text(); QString name = edit->text();
if(name.isEmpty() || name.contains(" ")){ if (name.isEmpty() || name.contains(" "))
{
flagName = false; flagName = false;
QPalette palette = labelEditNamePoint->palette(); QPalette palette = labelEditNamePoint->palette();
palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red); palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red);
labelEditNamePoint->setPalette(palette); labelEditNamePoint->setPalette(palette);
} else { }
else
{
flagName = true; flagName = true;
QPalette palette = labelEditNamePoint->palette(); QPalette palette = labelEditNamePoint->palette();
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76)); palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
@ -236,155 +292,233 @@ void DialogTool::NamePointChanged(){
CheckState(); CheckState();
} }
void DialogTool::DialogAccepted(){ void DialogTool::DialogAccepted()
{
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogTool::DialogRejected(){ void DialogTool::DialogRejected()
{
emit DialogClosed(QDialog::Rejected); emit DialogClosed(QDialog::Rejected);
} }
void DialogTool::FormulaChanged(){ void DialogTool::FormulaChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if(edit){ if (edit)
{
ValFormulaChanged(flagFormula, edit, timerFormula); ValFormulaChanged(flagFormula, edit, timerFormula);
} }
} }
void DialogTool::ArrowUp(){ void DialogTool::ArrowUp()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(90); spinBoxAngle->setValue(90);
} }
void DialogTool::ArrowDown(){ void DialogTool::ArrowDown()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(270); spinBoxAngle->setValue(270);
} }
void DialogTool::ArrowLeft(){ void DialogTool::ArrowLeft()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(180); spinBoxAngle->setValue(180);
} }
void DialogTool::ArrowRight(){ void DialogTool::ArrowRight()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(0); spinBoxAngle->setValue(0);
} }
void DialogTool::ArrowLeftUp(){ void DialogTool::ArrowLeftUp()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(135); spinBoxAngle->setValue(135);
} }
void DialogTool::ArrowLeftDown(){ void DialogTool::ArrowLeftDown()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(225); spinBoxAngle->setValue(225);
} }
void DialogTool::ArrowRightUp(){ void DialogTool::ArrowRightUp()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(45); spinBoxAngle->setValue(45);
} }
void DialogTool::ArrowRightDown(){ void DialogTool::ArrowRightDown()
Q_CHECK_PTR(spinBoxAngle); {
Q_ASSERT(spinBoxAngle != 0);
spinBoxAngle->setValue(315); spinBoxAngle->setValue(315);
} }
void DialogTool::EvalFormula(){ void DialogTool::EvalFormula()
Q_CHECK_PTR(lineEditFormula); {
Q_CHECK_PTR(labelResultCalculation); Q_ASSERT(lineEditFormula != 0);
Q_ASSERT(labelResultCalculation != 0);
Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation);
} }
void DialogTool::SizeGrowth(){ void DialogTool::SizeGrowth()
{
ShowVariable(data->DataBase()); ShowVariable(data->DataBase());
} }
void DialogTool::StandartTable(){ void DialogTool::StandartTable()
{
ShowVariable(data->DataStandartTable()); ShowVariable(data->DataStandartTable());
} }
void DialogTool::LengthLines(){ void DialogTool::LengthLines()
{
ShowVariable(data->DataLengthLines()); ShowVariable(data->DataLengthLines());
} }
void DialogTool::Increments(){ void DialogTool::LengthArcs()
{
ShowVariable(data->DataLengthArcs());
}
void DialogTool::LengthCurves()
{
ShowVariable(data->DataLengthSplines());
}
void DialogTool::Increments()
{
ShowVariable(data->DataIncrementTable()); ShowVariable(data->DataIncrementTable());
} }
void DialogTool::PutHere(){ void DialogTool::PutHere()
{
PutValHere(lineEditFormula, listWidget); PutValHere(lineEditFormula, listWidget);
} }
void DialogTool::PutVal(QListWidgetItem *item){ void DialogTool::PutVal(QListWidgetItem *item)
Q_CHECK_PTR(lineEditFormula); {
QString val = item->text(); Q_ASSERT(lineEditFormula != 0);
lineEditFormula->setText(lineEditFormula->text().append(val)); Q_ASSERT(item != 0);
int pos = lineEditFormula->cursorPosition();
lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(),
item->text()));
lineEditFormula->setFocus(); lineEditFormula->setFocus();
lineEditFormula->setCursorPosition(pos + item->text().size());
} }
void DialogTool::ValChenged(int row){ void DialogTool::ValChenged(int row)
Q_CHECK_PTR(listWidget); {
Q_CHECK_PTR(labelDescription); Q_ASSERT(listWidget != 0);
Q_CHECK_PTR(radioButtonSizeGrowth); Q_ASSERT(labelDescription != 0);
Q_CHECK_PTR(radioButtonStandartTable); Q_ASSERT(radioButtonSizeGrowth != 0);
Q_CHECK_PTR(radioButtonIncrements); Q_ASSERT(radioButtonStandartTable != 0);
Q_CHECK_PTR(radioButtonLengthLine); Q_ASSERT(radioButtonIncrements != 0);
if(listWidget->count() == 0){ Q_ASSERT(radioButtonLengthLine != 0);
Q_ASSERT(radioButtonLengthArc != 0);
Q_ASSERT(radioButtonLengthCurve != 0);
if (listWidget->count() == 0)
{
return; return;
} }
QListWidgetItem *item = listWidget->item( row ); QListWidgetItem *item = listWidget->item( row );
if(radioButtonSizeGrowth->isChecked()){ if (radioButtonSizeGrowth->isChecked())
if(item->text()=="Р"){ {
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg("Зріст"); if (item->text()=="Р")
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Growth"));
labelDescription->setText(desc); labelDescription->setText(desc);
} }
if(item->text()=="Сг"){ if (item->text()=="Сг")
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg("Розмір"); {
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
labelDescription->setText(desc); labelDescription->setText(desc);
} }
return; return;
} }
if(radioButtonStandartTable->isChecked()){ if (radioButtonStandartTable->isChecked())
{
VStandartTableCell stable = data->GetStandartTableCell(item->text()); VStandartTableCell stable = data->GetStandartTableCell(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text()))
.arg(stable.GetDescription()); .arg(stable.GetDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonIncrements->isChecked()){ if (radioButtonIncrements->isChecked())
{
VIncrementTableRow itable = data->GetIncrementTableRow(item->text()); VIncrementTableRow itable = data->GetIncrementTableRow(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
.arg(itable.getDescription()); .arg(itable.getDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
if(radioButtonLengthLine->isChecked()){ if (radioButtonLengthLine->isChecked())
{
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text()))
.arg(tr("Line length")); .arg(tr("Line length"));
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
} }
} if (radioButtonLengthArc->isChecked())
{
void DialogTool::UpdateList(){ QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(item->text()))
if(radioButtonSizeGrowth == 0 || radioButtonStandartTable == 0 || radioButtonIncrements == 0){ .arg(tr("Arc length"));
labelDescription->setText(desc);
return; return;
} }
if(radioButtonSizeGrowth->isChecked()){ if (radioButtonLengthCurve->isChecked())
ShowVariable(data->DataBase()); {
} QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text()))
if(radioButtonStandartTable->isChecked()){ .arg(tr("Curve length"));
ShowVariable(data->DataStandartTable()); labelDescription->setText(desc);
} return;
if(radioButtonIncrements->isChecked()){
ShowVariable(data->DataIncrementTable());
} }
} }
bool DialogTool::CheckObject(const qint64 &id){ void DialogTool::UpdateList()
if(mode == Draw::Calculation || idDetail == 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 (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; return false;
} }
VDetail det = data->GetDetail(idDetail); VDetail det = data->GetDetail(idDetail);
@ -392,25 +526,28 @@ bool DialogTool::CheckObject(const qint64 &id){
} }
template <class key, class val> template <class key, class val>
void DialogTool::ShowVariable(const QHash<key, val> *var){ void DialogTool::ShowVariable(const QHash<key, val> *var)
Q_CHECK_PTR(listWidget); {
Q_ASSERT(listWidget != 0);
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->clear(); listWidget->clear();
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
QHashIterator<key, val> i(*var); QHashIterator<key, val> i(*var);
while (i.hasNext()) { QMap<key, val> map;
while (i.hasNext())
{
i.next(); 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)); item->setFont(QFont("Times", 12, QFont::Bold));
listWidget->addItem(item); listWidget->addItem(item);
} }
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->setCurrentRow (0); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,35 +24,27 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef DIALOGTOOL_H #ifndef DIALOGTOOL_H
#define DIALOGTOOL_H #define DIALOGTOOL_H
#include <QDialog> #include <QDialog>
#include <QComboBox> #include "../container/vcontainer.h"
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QLineEdit>
#include <QListWidget>
#include <QLabel>
#include <QRadioButton>
#include <QTimer>
#include "container/vcontainer.h"
class DialogTool : public QDialog{ class DialogTool : public QDialog
{
Q_OBJECT Q_OBJECT
public: public:
DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
QWidget *parent = 0); virtual ~DialogTool() {}
virtual ~DialogTool(); inline qint64 getIdDetail() const {return idDetail;}
qint64 getIdDetail() const; inline void setIdDetail(const qint64 &value) {idDetail = value;}
void setIdDetail(const qint64 &value);
signals: signals:
void DialogClosed(int result); void DialogClosed(int result);
void ToolTip(const QString &toolTip); void ToolTip(const QString &toolTip);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type); virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
void NamePointChanged(); void NamePointChanged();
virtual void DialogAccepted(); virtual void DialogAccepted();
virtual void DialogRejected(); virtual void DialogRejected();
@ -62,6 +61,8 @@ public slots:
void SizeGrowth(); void SizeGrowth();
void StandartTable(); void StandartTable();
void LengthLines(); void LengthLines();
void LengthArcs();
void LengthCurves();
void Increments(); void Increments();
void PutHere(); void PutHere();
void PutVal(QListWidgetItem * item); void PutVal(QListWidgetItem * item);
@ -86,6 +87,8 @@ protected:
QRadioButton *radioButtonStandartTable; QRadioButton *radioButtonStandartTable;
QRadioButton *radioButtonIncrements; QRadioButton *radioButtonIncrements;
QRadioButton *radioButtonLengthLine; QRadioButton *radioButtonLengthLine;
QRadioButton *radioButtonLengthArc;
QRadioButton *radioButtonLengthCurve;
qint64 idDetail; qint64 idDetail;
Draw::Draws mode; Draw::Draws mode;
bool CheckObject(const qint64 &id); bool CheckObject(const qint64 &id);

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,18 +24,17 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexception.h" #include "vexception.h"
VException::VException(const QString &what):QException(), what(what){ VException::VException(const QString &what):QException(), what(what)
Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty"); {
Q_ASSERT_X(what.isEmpty() == false, Q_FUNC_INFO, "Error message is empty");
} }
VException::VException(const VException &e):what(e.What()){ QString VException::ErrorMessage() const
} {
QString VException::ErrorMessage() const{
QString error = QString("Exception: %1").arg(what); QString error = QString("Exception: %1").arg(what);
return error; return error;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,26 +24,25 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTION_H #ifndef VEXCEPTION_H
#define VEXCEPTION_H #define VEXCEPTION_H
#include <QException> #include <QException>
#include <QString>
class VException : public QException class VException : public QException
{ {
public: public:
VException(const QString &what); VException(const QString &what);
VException(const VException &e); VException(const VException &e):what(e.What()){}
virtual ~VException() noexcept(true){} virtual ~VException() Q_DECL_NOEXCEPT_EXPR(true){}
void raise() const { throw *this; } inline void raise() const { throw *this; }
VException *clone() const { return new VException(*this); } inline VException *clone() const { return new VException(*this); }
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const { return QString(); } virtual QString DetailedInformation() const { return QString(); }
QString What() const {return what;} inline QString What() const {return what;}
protected: protected:
QString what; QString what;
}; };

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,28 +24,20 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexceptionbadid.h" #include "vexceptionbadid.h"
VExceptionBadId::VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id), QString VExceptionBadId::ErrorMessage() const
key(QString()){
}
VExceptionBadId::VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key)
{ {
}
VExceptionBadId::VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){
}
QString VExceptionBadId::ErrorMessage() const{
QString error; QString error;
if(key.isEmpty()){ if (key.isEmpty())
{
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id); error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id);
} else { }
else
{
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key); error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key);
} }
return error; return error;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTIONBADID_H #ifndef VEXCEPTIONBADID_H
#define VEXCEPTIONBADID_H #define VEXCEPTIONBADID_H
@ -27,13 +34,16 @@
class VExceptionBadId : public VException class VExceptionBadId : public VException
{ {
public: public:
VExceptionBadId(const QString &what, const qint64 &id); VExceptionBadId(const QString &what, const qint64 &id)
VExceptionBadId(const QString &what, const QString &key); :VException(what), id(id), key(QString()){}
VExceptionBadId(const VExceptionBadId &e); VExceptionBadId(const QString &what, const QString &key)
virtual ~VExceptionBadId() noexcept(true){} :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; virtual QString ErrorMessage() const;
qint64 BadId() const {return id; } inline qint64 BadId() const {return id; }
QString BadKey() const {return key; } inline QString BadKey() const {return key; }
protected: protected:
qint64 id; qint64 id;
QString key; QString key;

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,20 +24,18 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexceptionconversionerror.h" #include "vexceptionconversionerror.h"
VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str) VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str)
:VException(what), str(str){ :VException(what), str(str)
Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty"); {
Q_ASSERT_X(str.isEmpty() == false, Q_FUNC_INFO, "Error converting string is empty");
} }
VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e): QString VExceptionConversionError::ErrorMessage() const
VException(e), str(e.String()){ {
}
QString VExceptionConversionError::ErrorMessage() const{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str); QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
return error; return error;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,7 +24,7 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTIONCONVERSIONERROR_H #ifndef VEXCEPTIONCONVERSIONERROR_H
#define VEXCEPTIONCONVERSIONERROR_H #define VEXCEPTIONCONVERSIONERROR_H
@ -28,10 +35,11 @@ class VExceptionConversionError : public VException
{ {
public: public:
VExceptionConversionError(const QString &what, const QString &str); VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e); VExceptionConversionError(const VExceptionConversionError &e)
virtual ~VExceptionConversionError() noexcept(true) {} :VException(e), str(e.String()){}
virtual ~VExceptionConversionError() Q_DECL_NOEXCEPT_EXPR(true) {}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
QString String() const {return str;} inline QString String() const {return str;}
protected: protected:
QString str; QString str;
}; };

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,32 +24,30 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexceptionemptyparameter.h" #include "vexceptionemptyparameter.h"
#include <QDebug>
VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name, VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
const QDomElement &domElement): VException(what), const QDomElement &domElement)
name(name), tagText(QString()), tagName(QString()), lineNumber(-1){ : VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1)
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Parameter name is empty"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "Parameter name is empty");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e), QString VExceptionEmptyParameter::ErrorMessage() const
name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){ {
}
QString VExceptionEmptyParameter::ErrorMessage() const{
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name); QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
return error; return error;
} }
QString VExceptionEmptyParameter::DetailedInformation() const{ QString VExceptionEmptyParameter::DetailedInformation() const
{
QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail; return detail;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,26 +24,27 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTIONEMPTYPARAMETER_H #ifndef VEXCEPTIONEMPTYPARAMETER_H
#define VEXCEPTIONEMPTYPARAMETER_H #define VEXCEPTIONEMPTYPARAMETER_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionEmptyParameter : public VException class VExceptionEmptyParameter : public VException
{ {
public: public:
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement); VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement);
VExceptionEmptyParameter(const VExceptionEmptyParameter &e); VExceptionEmptyParameter(const VExceptionEmptyParameter &e)
virtual ~VExceptionEmptyParameter() noexcept(true) {} :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 ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString Name() const {return name;} inline QString Name() const {return name;}
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString name; QString name;
QString tagText; QString tagText;

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,42 +24,46 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexceptionobjecterror.h" #include "vexceptionobjecterror.h"
#include <QDebug> #include <QDebug>
VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement): VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement)
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1), moreInfo(QString()){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1), moreInfo(QString())
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e):VException(e), QString VExceptionObjectError::ErrorMessage() const
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){ {
}
QString VExceptionObjectError::ErrorMessage() const{
QString error = QString("ExceptionObjectError: %1").arg(what); QString error = QString("ExceptionObjectError: %1").arg(what);
return error; return error;
} }
QString VExceptionObjectError::DetailedInformation() const{ QString VExceptionObjectError::DetailedInformation() const
{
QString detail; QString detail;
if(!moreInfo.isEmpty()){ if (moreInfo.isEmpty() == false)
{
QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
detail = QString("%1\n%2").arg(moreInfo, i); detail = QString("%1\n%2").arg(moreInfo, i);
} else { }
else
{
detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
} }
return detail; return detail;
} }
void VExceptionObjectError::AddMoreInformation(const QString &info){ void VExceptionObjectError::AddMoreInformation(const QString &info)
if(info.isEmpty()){ {
if (info.isEmpty())
{
qWarning()<<"Error additional information is empty."<<Q_FUNC_INFO; qWarning()<<"Error additional information is empty."<<Q_FUNC_INFO;
} }
this->moreInfo.append(info); this->moreInfo.append(info);

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,27 +24,28 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTIONOBJECTERROR_H #ifndef VEXCEPTIONOBJECTERROR_H
#define VEXCEPTIONOBJECTERROR_H #define VEXCEPTIONOBJECTERROR_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionObjectError : public VException class VExceptionObjectError : public VException
{ {
public: public:
VExceptionObjectError(const QString &what, const QDomElement &domElement); VExceptionObjectError(const QString &what, const QDomElement &domElement);
VExceptionObjectError(const VExceptionObjectError &e); VExceptionObjectError(const VExceptionObjectError &e)
virtual ~VExceptionObjectError() noexcept(true) {} :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 ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
void AddMoreInformation(const QString &info); void AddMoreInformation(const QString &info);
QString MoreInformation() const {return moreInfo;} inline QString MoreInformation() const {return moreInfo;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;

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

View File

@ -1,20 +1,48 @@
/************************************************************************
**
** @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 #ifndef VEXCEPTIONUNIQUEID_H
#define VEXCEPTIONUNIQUEID_H #define VEXCEPTIONUNIQUEID_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionUniqueId : public VException{ class VExceptionUniqueId : public VException
{
public: public:
VExceptionUniqueId(const QString &what, const QDomElement &domElement); VExceptionUniqueId(const QString &what, const QDomElement &domElement);
VExceptionUniqueId(const VExceptionUniqueId &e):VException(e), tagText(e.TagText()), VExceptionUniqueId(const VExceptionUniqueId &e)
tagName(e.TagName()), lineNumber(e.LineNumber()){} :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionUniqueId() noexcept(true){} virtual ~VExceptionUniqueId() Q_DECL_NOEXCEPT_EXPR(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,30 +24,29 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vexceptionwrongparameterid.h" #include "vexceptionwrongparameterid.h"
#include <QDebug> #include <QDebug>
VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement): VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement)
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){ :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); {
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
QTextStream stream(&tagText); QTextStream stream(&tagText);
domElement.save(stream, 4); domElement.save(stream, 4);
tagName = domElement.tagName(); tagName = domElement.tagName();
lineNumber = domElement.lineNumber(); lineNumber = domElement.lineNumber();
} }
VExceptionWrongParameterId::VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e), QString VExceptionWrongParameterId::ErrorMessage() const
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){ {
}
QString VExceptionWrongParameterId::ErrorMessage() const{
QString error = QString("ExceptionWrongParameterId: %1").arg(what); QString error = QString("ExceptionWrongParameterId: %1").arg(what);
return error; return error;
} }
QString VExceptionWrongParameterId::DetailedInformation() const{ QString VExceptionWrongParameterId::DetailedInformation() const
{
QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail; return detail;
} }

View File

@ -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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,25 +24,25 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VEXCEPTIONWRONGPARAMETERID_H #ifndef VEXCEPTIONWRONGPARAMETERID_H
#define VEXCEPTIONWRONGPARAMETERID_H #define VEXCEPTIONWRONGPARAMETERID_H
#include "vexception.h" #include "vexception.h"
#include <QDomElement>
class VExceptionWrongParameterId : public VException class VExceptionWrongParameterId : public VException
{ {
public: public:
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement); VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e); VExceptionWrongParameterId(const VExceptionWrongParameterId &e)
virtual ~VExceptionWrongParameterId() noexcept(true){} :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){}
virtual ~VExceptionWrongParameterId() Q_DECL_NOEXCEPT_EXPR(true){}
virtual QString ErrorMessage() const; virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const; virtual QString DetailedInformation() const;
QString TagText() const {return tagText;} inline QString TagText() const {return tagText;}
QString TagName() const {return tagName;} inline QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;} inline qint32 LineNumber() const {return lineNumber;}
protected: protected:
QString tagText; QString tagText;
QString tagName; QString tagName;

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,28 +24,33 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "varc.h" #include "varc.h"
#include <QDebug> #include "../exception/vexception.h"
VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), class QRectF;
center(0), points(0), mode(Draw::Calculation), idObject(0){
} VArc::VArc ()
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(0), points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0), _name(QString()){}
VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(points), mode(mode), idObject(idObject){ center(center), points(*points), mode(mode), idObject(idObject), _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()), formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()), center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()),
idObject(arc.getIdObject()){ idObject(arc.getIdObject()), _name(arc.name()){}
}
VArc &VArc::operator =(const VArc &arc){ VArc &VArc::operator =(const VArc &arc)
{
this->points = arc.GetDataPoints(); this->points = arc.GetDataPoints();
this->f1 = arc.GetF1(); this->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1(); this->formulaF1 = arc.GetFormulaF1();
@ -49,70 +61,52 @@ VArc &VArc::operator =(const VArc &arc){
this->center = arc.GetCenter(); this->center = arc.GetCenter();
this->mode = arc.getMode(); this->mode = arc.getMode();
this->idObject = arc.getIdObject(); this->idObject = arc.getIdObject();
this->_name = arc.name();
return *this; return *this;
} }
qreal VArc::GetF1() const{ QPointF VArc::GetCenterPoint() const
return f1; {
return GetCenterVPoint().toQPointF();
} }
QString VArc::GetFormulaF1() const{ VPointF VArc::GetCenterVPoint() const
return formulaF1; {
if (points.contains(center))
{
return points.value(center);
}
else
{
QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
throw VException(error);
}
return VPointF();
} }
qreal VArc::GetF2() const{ QPointF VArc::GetP1() 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.";
}
return QPointF();
}
QPointF VArc::GetP1() const{
QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP1(GetCenterPoint(), p1); QLineF centerP1(GetCenterPoint(), p1);
centerP1.setAngle(f1); centerP1.setAngle(f1);
return centerP1.p2(); return centerP1.p2();
} }
QPointF VArc::GetP2 () const{ QPointF VArc::GetP2 () const
{
QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
QLineF centerP2(GetCenterPoint(), p2); QLineF centerP2(GetCenterPoint(), p2);
centerP2.setAngle(f2); centerP2.setAngle(f2);
return centerP2.p2(); return centerP2.p2();
} }
const QHash<qint64, VPointF> *VArc::GetDataPoints() const{ const QHash<qint64, VPointF> VArc::GetDataPoints() const
{
return points; return points;
} }
QPainterPath VArc::GetPath() const{ QPainterPath VArc::GetPath() const
{
QPainterPath Path; QPainterPath Path;
QPointF center = GetCenterPoint(); QPointF center = GetCenterPoint();
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2); QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
@ -122,7 +116,8 @@ QPainterPath VArc::GetPath() const{
return Path; return Path;
} }
qreal VArc::AngleArc() const{ qreal VArc::AngleArc() const
{
QLineF l1(0, 0, 100, 100); QLineF l1(0, 0, 100, 100);
l1.setAngle(f1); l1.setAngle(f1);
QLineF l2(0, 0, 100, 100); QLineF l2(0, 0, 100, 100);
@ -130,12 +125,16 @@ qreal VArc::AngleArc() const{
return l1.angleTo(l2); return l1.angleTo(l2);
} }
qint32 VArc::NumberSplOfArc() const{ qint32 VArc::NumberSplOfArc() const
{
qint32 angArc = static_cast<qint32> (AngleArc ()); qint32 angArc = static_cast<qint32> (AngleArc ());
switch( angArc ){ switch ( angArc )
{
case 0: case 0:
throw "Кут дуги не може бути 0 градусів."; {
break; QString error = QString(tr("Angle of arc can't be 0 degree."));
throw VException(error);
}
case 90: case 90:
return 1; return 1;
case 180: case 180:
@ -149,64 +148,67 @@ qint32 VArc::NumberSplOfArc() const{
} }
} }
QVector<QPointF> VArc::GetPoints() const{ QVector<QPointF> VArc::GetPoints() const
{
QVector<QPointF> points; QVector<QPointF> points;
qint32 numberSpl = NumberSplOfArc(); qint32 numberSpl = NumberSplOfArc();
for(qint32 i = 1; i <= numberSpl; ++i){ for (qint32 i = 1; i <= numberSpl; ++i)
{
points<<SplOfArc ( i ); points<<SplOfArc ( i );
} }
return points; return points;
} }
QVector<QPointF> VArc::SplOfArc(qint32 number) const{ QVector<QPointF> VArc::SplOfArc(qint32 number) const
{
qint32 n = NumberSplOfArc (); qint32 n = NumberSplOfArc ();
if( number > n ){ if ( number > n )
throw "Дуга не складається з такої кількості сплайнів."; {
QString error = QString(tr("Arc have not this number of part."));
throw VException(error);
} }
qreal f1 = GetF1 (); qreal f1 = GetF1 ();
qreal f2 = GetF2 (); qreal f2 = GetF2 ();
qint32 i; qint32 i;
for ( i = 0; i < n; ++i ){ for ( i = 0; i < n; ++i )
if ( i == n - 1 ){ {
if ( i == n - 1 )
{
f2 = GetF2 (); f2 = GetF2 ();
} else { }
if ( f1 + 90 > 360 ){ else
{
if ( f1 + 90 > 360 )
{
f2 = f1 + 90 - 360; f2 = f1 + 90 - 360;
} else { }
else
{
f2 = f1 + 90; f2 = f1 + 90;
} }
} }
qreal anglF1, anglF2; qreal anglF1, anglF2;
if ( f1 + 90 > 360 ){ if ( f1 + 90 > 360 )
{
anglF1 = f1 + 90 - 360; anglF1 = f1 + 90 - 360;
} else { }
else
{
anglF1 = f1 + 90; anglF1 = f1 + 90;
} }
if ( f2 - 90 < 0 ){ if ( f2 - 90 < 0 )
{
anglF2 = 360 + f2 - 90; anglF2 = 360 + f2 - 90;
} else { }
else
{
anglF2 = f2 - 90; anglF2 = f2 - 90;
} }
if ( i + 1 == number ){ if ( i + 1 == number )
{
f1 = f2; f1 = f2;
return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.); return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.);
} }
} }
return QVector<QPointF>(); 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,17 +24,23 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VARC_H #ifndef VARC_H
#define VARC_H #define VARC_H
#include "vspline.h" #include "vspline.h"
class QString;
class QLineF;
class QPainterPath;
class QPointF;
/** /**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою. * @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/ */
class VArc{ class VArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public: public:
/** /**
* @brief VArc конструктор по замовчуванню. * @brief VArc конструктор по замовчуванню.
@ -49,31 +62,32 @@ public:
* @brief GetF1 повертає початковий кут дуги. * @brief GetF1 повертає початковий кут дуги.
* @return повертає кут в градусах. * @return повертає кут в градусах.
*/ */
QString GetFormulaF1 () const; inline QString GetFormulaF1 () const {return formulaF1;}
qreal GetF1 () const; inline qreal GetF1 () const {return f1;}
/** /**
* @brief GetF2 повертає кінцевий кут дуги. * @brief GetF2 повертає кінцевий кут дуги.
* @return повертає кут в градусах. * @return повертає кут в градусах.
*/ */
QString GetFormulaF2 () const;\ inline QString GetFormulaF2 () const {return formulaF2;}
qreal GetF2 () const; inline qreal GetF2 () const {return f2;}
/** /**
* @brief GetLength повертає довжину дуги. * @brief GetLength повертає довжину дуги.
* @return повертає довжину дуги. * @return повертає довжину дуги.
*/ */
qreal GetLength () const; inline qreal GetLength () const {return M_PI * radius/180 * (f2-f1);}
/** /**
* @brief GetRadius повертає радіус дуги. * @brief GetRadius повертає радіус дуги.
* @return повертає радіус дуги. * @return повертає радіус дуги.
*/ */
QString GetFormulaRadius () const; inline QString GetFormulaRadius () const {return formulaRadius;}
qreal GetRadius () const; inline qreal GetRadius () const {return radius;}
/** /**
* @brief GetCenter повертає точку центра дуги. * @brief GetCenter повертає точку центра дуги.
* @return повертає точку центра дуги. * @return повертає точку центра дуги.
*/ */
qint64 GetCenter () const; inline qint64 GetCenter () const {return center;}
QPointF GetCenterPoint() const; QPointF GetCenterPoint() const;
VPointF GetCenterVPoint() const;
/** /**
* @brief GetP1 повертає першу точку з якої починається дуга. * @brief GetP1 повертає першу точку з якої починається дуга.
* @return точку початку дуги. * @return точку початку дуги.
@ -84,7 +98,7 @@ public:
* @return точку кінця дуги. * @return точку кінця дуги.
*/ */
QPointF GetP2 () const; QPointF GetP2 () const;
const QHash<qint64, VPointF> *GetDataPoints() const; const QHash<qint64, VPointF> GetDataPoints() const;
/** /**
* @brief GetPath будує шлях по даній дузі. * @brief GetPath будує шлях по даній дузі.
* @return повертає шлях. * @return повертає шлях.
@ -94,11 +108,12 @@ public:
qint32 NumberSplOfArc () const; qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const; QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const; QVector<QPointF> SplOfArc( qint32 number ) const;
Draw::Draws getMode() const; inline Draw::Draws getMode() const {return mode;}
void setMode(const Draw::Draws &value); inline void setMode(const Draw::Draws &value) {mode = value;}
qint64 getIdObject() const; inline qint64 getIdObject() const {return idObject;}
void setIdObject(const qint64 &value); inline void setIdObject(const qint64 &value) {idObject = value;}
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
private: private:
/** /**
* @brief f1 початковий кут в градусах * @brief f1 початковий кут в градусах
@ -119,9 +134,10 @@ private:
* @brief center центральна точка дуги. * @brief center центральна точка дуги.
*/ */
qint64 center; qint64 center;
const QHash<qint64, VPointF> *points; QHash<qint64, VPointF> points;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
QString _name;
}; };
#endif // VARC_H #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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,67 +24,60 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vdetail.h" #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>()), VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
name(name), mx(0), my(0){ :nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), supplement(true), closed(true), width(10)
{
this->nodes = nodes; this->nodes = nodes;
} }
void VDetail::append(const VNodeDetail &node){ VDetail::VDetail(const VDetail &detail)
nodes.append(node); :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(); nodes.clear();
name.clear(); name.clear();
mx = 0; mx = 0;
my = 0; my = 0;
supplement = true;
closed = true;
width = 10;
} }
qint32 VDetail::CountNode() const{ bool VDetail::Containes(const qint64 &id) const
return nodes.size(); {
} 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]; VNodeDetail node = nodes[i];
if(node.getId() == id){ if (node.getId() == id)
{
return true; return true;
} }
} }
return false; return false;
} }
VNodeDetail &VDetail::operator [](int indx){ VNodeDetail &VDetail::operator [](ptrdiff_t indx)
{
return nodes[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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,17 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VDETAIL_H #ifndef VDETAIL_H
#define VDETAIL_H #define VDETAIL_H
#include "vnodedetail.h" #include "vnodedetail.h"
#include <QVector>
#include <QString>
#include <QPainterPath>
namespace Detail { namespace Detail
{
enum Contour { OpenContour, CloseContour }; enum Contour { OpenContour, CloseContour };
Q_DECLARE_FLAGS(Contours, Contour) Q_DECLARE_FLAGS(Contours, Contour)
@ -37,26 +42,40 @@ namespace Detail {
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours)
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
class VDetail{ class VDetail
{
public: public:
VDetail(); VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
void append(const VNodeDetail &node); VDetail(const VDetail &detail);
VDetail &operator=(const VDetail &detail);
inline void append(const VNodeDetail &node) {nodes.append(node);}
void Clear(); void Clear();
qint32 CountNode() const; inline qint32 CountNode() const {return nodes.size();}
bool Containes(const qint64 &id)const; bool Containes(const qint64 &id)const;
VNodeDetail & operator[](int indx); VNodeDetail & operator[](ptrdiff_t indx);
QString getName() const; inline QString getName() const {return name;}
void setName(const QString &value); inline void setName(const QString &value) {name = value;}
qreal getMx() const; inline qreal getMx() const {return mx;}
void setMx(const qreal &value); inline void setMx(const qreal &value) {mx = value;}
qreal getMy() const; inline qreal getMy() const {return my;}
void setMy(const qreal &value); 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: private:
QVector<VNodeDetail> nodes; QVector<VNodeDetail> nodes;
QString name; QString name;
qreal mx; qreal mx;
qreal my; qreal my;
bool supplement;
bool closed;
qreal width;
}; };
#endif // VDETAIL_H #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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,50 +24,28 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vnodedetail.h" #include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Calculation), VNodeDetail::VNodeDetail()
typeNode(NodeDetail::Contour){ :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), VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
typeTool(typeTool), mode(mode), typeNode(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()), VNodeDetail::VNodeDetail(const VNodeDetail &node)
mode(node.getMode()), typeNode(node.getTypeNode()){ :id(node.getId()), typeTool(node.getTypeTool()), mode(node.getMode()), typeNode(node.getTypeNode()),
} mx(node.getMx()), my(node.getMy()){}
Tool::Tools VNodeDetail::getTypeTool() const{ VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node)
return typeTool; {
} id = node.getId();
typeTool = node.getTypeTool();
void VNodeDetail::setTypeTool(const Tool::Tools &value){ mode = node.getMode();
typeTool = value; typeNode = node.getTypeNode();
} mx = node.getMx();
my = node.getMy();
qint64 VNodeDetail::getId() const{ return *this;
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;
} }

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,15 +24,16 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VNODEDETAIL_H #ifndef VNODEDETAIL_H
#define VNODEDETAIL_H #define VNODEDETAIL_H
#include <QMetaType> #include <QMetaType>
#include "options.h" #include "../options.h"
namespace NodeDetail { namespace NodeDetail
{
enum NodeDetail { Contour, Modeling }; enum NodeDetail { Contour, Modeling };
Q_DECLARE_FLAGS(NodeDetails, NodeDetail) Q_DECLARE_FLAGS(NodeDetails, NodeDetail)
} }
@ -35,22 +43,29 @@ class VNodeDetail
{ {
public: public:
VNodeDetail(); VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode); VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx = 0, qreal my = 0);
VNodeDetail(const VNodeDetail &node); VNodeDetail(const VNodeDetail &node);
qint64 getId() const; VNodeDetail &operator=(const VNodeDetail &node);
void setId(const qint64 &value); inline qint64 getId() const {return id;}
Tool::Tools getTypeTool() const; inline void setId(const qint64 &value) {id = value;}
void setTypeTool(const Tool::Tools &value); inline Tool::Tools getTypeTool() const {return typeTool;}
Draw::Draws getMode() const; inline void setTypeTool(const Tool::Tools &value) {typeTool = value;}
void setMode(const Draw::Draws &value); inline Draw::Draws getMode() const {return mode;}
NodeDetail::NodeDetails getTypeNode() const; inline void setMode(const Draw::Draws &value) {mode = value;}
void setTypeNode(const NodeDetail::NodeDetails &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: private:
qint64 id; qint64 id;
Tool::Tools typeTool; Tool::Tools typeTool;
Draw::Draws mode; Draw::Draws mode;
NodeDetail::NodeDetails typeNode; NodeDetail::NodeDetails typeNode;
qreal mx;
qreal my;
}; };
Q_DECLARE_METATYPE(VNodeDetail) 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,36 +24,40 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vspline.h" #include "vspline.h"
#include <QDebug>
VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), VSpline::VSpline()
kCurve(1), points(0), mode(Draw::Calculation), idObject(0){ :p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1),
} points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0), _name(QString()){}
VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), VSpline::VSpline ( const VSpline & spline )
p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), :p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()),
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()),
mode(spline.getMode()), idObject(spline.getIdObject()){ points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()), _name(spline.name()){}
}
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()), qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject)
p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points), :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
mode(mode), idObject(idObject){ kCurve(kCurve), points(*points), mode(mode), idObject(idObject), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
} }
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), qreal kCurve, Draw::Draws mode, qint64 idObject)
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){ :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode),
idObject(idObject), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
ModifiSpl ( p1, p2, p3, p4, kCurve); ModifiSpl ( p1, p2, p3, p4, kCurve);
} }
void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve){ qreal kAsm1, qreal kAsm2, qreal kCurve)
{
this->p1 = p1; this->p1 = p1;
this->p4 = p4; this->p4 = p4;
this->angle1 = angle1; this->angle1 = angle1;
@ -74,7 +85,8 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
this->p3 = p4p3.p2(); this->p3 = p4p3.p2();
} }
void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve){ void VSpline::ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, const qreal &kCurve)
{
this->p1 = p1; this->p1 = p1;
this->p2 = p2; this->p2 = p2;
this->p3 = p3; this->p3 = p3;
@ -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); // p4 = QPointF(p4.x()+mx, p4.y()+my);
//} //}
qint64 VSpline::GetP1 () const{ VPointF VSpline::GetPointP1() const
return p1; {
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<<" в таблиці."; qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці.";
throw "Не можу знайти точку за id."; throw "Не можу знайти точку за id.";
} }
return VPointF(); return VPointF();
} }
QPointF VSpline::GetP2 () const{ VPointF VSpline::GetPointP4() const
return p2; {
if (points.contains(p4))
{
return points.value(p4);
} }
else
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 {
qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці."; qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці.";
throw "Не можу знайти точку за id."; throw "Не можу знайти точку за id.";
} }
return VPointF(); return VPointF();
} }
qreal VSpline::GetAngle1() const{ qreal VSpline::GetLength () const
return angle1; {
}
qreal VSpline::GetAngle2 () const{
return angle2;
}
qreal VSpline::GetLength () const{
return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF()); return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF());
} }
QString VSpline::GetName() const{ QString VSpline::GetName() const
{
VPointF first = GetPointP1(); VPointF first = GetPointP1();
VPointF second = GetPointP4(); VPointF second = GetPointP4();
return QString("Spl_%1_%2").arg(first.name(), second.name()); return QString("Spl_%1_%2").arg(first.name(), second.name());
} }
qreal VSpline::GetKasm1() const{ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) 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{
QVector<qreal> px; QVector<qreal> px;
QVector<qreal> py; QVector<qreal> py;
px.append ( GetPointP1 ().x () ); px.append ( GetPointP1 ().x () );
@ -209,10 +192,12 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
qint32 i = 0; qint32 i = 0;
QPointF crosPoint; QPointF crosPoint;
QLineF::IntersectType type = QLineF::NoIntersection; QLineF::IntersectType type = QLineF::NoIntersection;
for ( i = 0; i < px.count()-1; ++i ){ for ( i = 0; i < px.count()-1; ++i )
{
type = line.intersect(QLineF ( QPointF ( px[i], py[i] ), type = line.intersect(QLineF ( QPointF ( px[i], py[i] ),
QPointF ( px[i+1], py[i+1] )), &crosPoint); QPointF ( px[i+1], py[i+1] )), &crosPoint);
if ( type == QLineF::BoundedIntersection ){ if ( type == QLineF::BoundedIntersection )
{
*intersectionPoint = crosPoint; *intersectionPoint = crosPoint;
return type; return type;
} }
@ -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()); return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint()); // QLineF line1(points.at(0).toPoint(), points.at(1).toPoint());
// line1.setLength(500); // line1.setLength(500);
@ -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<QPointF> pvector;
QVector<qreal> x; QVector<qreal> x;
QVector<qreal> y; 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 ); p3.x (), p3.y (), p4.x (), p4.y (), 0, wx, wy );
x.append ( p4.x () ); x.append ( p4.x () );
y.append ( p4.y () ); y.append ( p4.y () );
for ( qint32 i = 0; i < x.count(); ++i ){ for ( qint32 i = 0; i < x.count(); ++i )
{
pvector.append( QPointF ( x[i], y[i] ) ); pvector.append( QPointF ( x[i], y[i] ) );
} }
return pvector; return pvector;
} }
qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) const{ qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPointF &p3, const 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 ();
}*/
QPainterPath splinePath; QPainterPath splinePath;
QVector<QPointF> points = GetPoints (p1, p2, p3, p4); QVector<QPointF> points = GetPoints (p1, p2, p3, p4);
splinePath.moveTo(points[0]); splinePath.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){ for (qint32 i = 1; i < points.count(); ++i)
{
splinePath.lineTo(points[i]); splinePath.lineTo(points[i]);
} }
return splinePath.length(); return splinePath.length();
@ -350,7 +321,8 @@ qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) c
void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
qreal x3, qreal y3, qreal x4, qreal y4, qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py){ qint16 level, QVector<qreal> &px, QVector<qreal> &py)
{
const double curve_collinearity_epsilon = 1e-30; const double curve_collinearity_epsilon = 1e-30;
const double curve_angle_tolerance_epsilon = 0.01; const double curve_angle_tolerance_epsilon = 0.01;
const double m_angle_tolerance = 0.0; const double m_angle_tolerance = 0.0;
@ -388,8 +360,8 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
double dx = x4-x1; double dx = x4-x1;
double dy = y4-y1; double dy = y4-y1;
double d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx)); double d2 = fabs((x2 - x4) * dy - (y2 - y4) * dx);
double d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx)); double d3 = fabs((x3 - x4) * dy - (y3 - y4) * dx);
double da1, da2, k; double da1, da2, k;
switch ((static_cast<int>(d2 > curve_collinearity_epsilon) << 1) + switch ((static_cast<int>(d2 > curve_collinearity_epsilon) << 1) +
@ -399,7 +371,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
// All collinear OR p1==p4 // All collinear OR p1==p4
//---------------------- //----------------------
k = dx*dx + dy*dy; k = dx*dx + dy*dy;
if(k == 0) if (k < 0.000000001)
{ {
d2 = CalcSqDistance(x1, y1, x2, y2); d2 = CalcSqDistance(x1, y1, x2, y2);
d3 = CalcSqDistance(x4, y4, x3, y3); d3 = CalcSqDistance(x4, y4, x3, y3);
@ -420,19 +392,31 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return; return;
} }
if (d2 <= 0) if (d2 <= 0)
{
d2 = CalcSqDistance(x2, y2, x1, y1); d2 = CalcSqDistance(x2, y2, x1, y1);
}
else if (d2 >= 1) else if (d2 >= 1)
{
d2 = CalcSqDistance(x2, y2, x4, y4); d2 = CalcSqDistance(x2, y2, x4, y4);
}
else else
{
d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy); d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy);
}
if (d3 <= 0) if (d3 <= 0)
{
d3 = CalcSqDistance(x3, y3, x1, y1); d3 = CalcSqDistance(x3, y3, x1, y1);
}
else if (d3 >= 1) else if (d3 >= 1)
{
d3 = CalcSqDistance(x3, y3, x4, y4); d3 = CalcSqDistance(x3, y3, x4, y4);
}
else else
{
d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy); d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy);
} }
}
if (d2 > d3) if (d2 > d3)
{ {
if (d2 < m_distance_tolerance_square) if (d2 < m_distance_tolerance_square)
@ -474,7 +458,9 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
//---------------------- //----------------------
da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2)); da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
if (da1 >= M_PI) if (da1 >= M_PI)
{
da1 = 2*M_PI - da1; da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance) if (da1 < m_angle_tolerance)
{ {
@ -489,7 +475,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return; return;
} }
if(m_cusp_limit != 0.0) if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0)
{ {
if (da1 > m_cusp_limit) if (da1 > m_cusp_limit)
{ {
@ -520,7 +506,10 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
// Angle Condition // Angle Condition
//---------------------- //----------------------
da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
if(da1 >= M_PI) da1 = 2*M_PI - da1; if (da1 >= M_PI)
{
da1 = 2*M_PI - da1;
}
if (da1 < m_angle_tolerance) if (da1 < m_angle_tolerance)
{ {
@ -535,7 +524,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return; return;
} }
if(m_cusp_limit != 0.0) if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0)
{ {
if (da1 > m_cusp_limit) if (da1 > m_cusp_limit)
{ {
@ -571,8 +560,14 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
k = atan2(y3 - y2, x3 - x2); k = atan2(y3 - y2, x3 - x2);
da1 = fabs(k - atan2(y2 - y1, x2 - x1)); da1 = fabs(k - atan2(y2 - y1, x2 - x1));
da2 = fabs(atan2(y4 - y3, x4 - x3) - k); da2 = fabs(atan2(y4 - y3, x4 - x3) - k);
if(da1 >= M_PI) da1 = 2*M_PI - da1; if (da1 >= M_PI)
if(da2 >= M_PI) da2 = 2*M_PI - da2; {
da1 = 2*M_PI - da1;
}
if (da2 >= M_PI)
{
da2 = 2*M_PI - da2;
}
if (da1 + da2 < m_angle_tolerance) if (da1 + da2 < m_angle_tolerance)
{ {
@ -585,7 +580,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return; return;
} }
if(m_cusp_limit != 0.0) if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0)
{ {
if (da1 > m_cusp_limit) if (da1 > m_cusp_limit)
{ {
@ -603,6 +598,8 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
} }
} }
break; break;
default:
break;
} }
// Continue subdivision // 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); PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast<qint16>(level + 1), px, py);
} }
qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2){ qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2)
{
qreal dx = x2 - x1; qreal dx = x2 - x1;
qreal dy = y2 - y1; qreal dy = y2 - y1;
return dx * dx + dy * dy; return dx * dx + dy * dy;
} }
QPainterPath VSpline::GetPath() const{ QPainterPath VSpline::GetPath() const
{
QPainterPath splinePath; QPainterPath splinePath;
QVector<QPointF> points = GetPoints (); QVector<QPointF> points = GetPoints ();
splinePath.moveTo(points[0]); if (points.count() >= 2)
for (qint32 i = 1; i < points.count(); ++i){ {
splinePath.lineTo(points[i]); 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; return splinePath;
} }
/* Cubic equation solution. Real coefficients case. /* Cubic equation solution. Real coefficients case.
int Cubic(double *x,double a,double b,double c); int Cubic(double *x,double a,double b,double c);
Parameters: Parameters:
x - solution array (size 3). On output: x - solution array (size 3). On output:
@ -642,62 +648,62 @@ QPainterPath VSpline::GetPath() const{
2 - 1 real root + complex roots imaginary part is zero 2 - 1 real root + complex roots imaginary part is zero
(i.e. 2 real roots). (i.e. 2 real roots).
*/ */
qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){ //qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
qreal q,r,r2,q3; // qreal q,r,r2,q3;
//
q = (a*a - 3.*b)/9.; // q = (a*a - 3.*b)/9.;
r = (a*(2.*a*a - 9.*b) + 27.*c)/54.; // r = (a*(2.*a*a - 9.*b) + 27.*c)/54.;
r2 = r*r; // r2 = r*r;
q3 = pow(q,3); // q3 = pow(q,3);
if(r2<q3) { // if(r2<q3) {
qreal t = acos(r/sqrt(q3)); // qreal t = acos(r/sqrt(q3));
a/=3.; // a/=3.;
q = -2.*sqrt(q); // q = -2.*sqrt(q);
x[0] = q*cos(t/3.)-a; // x[0] = q*cos(t/3.)-a;
x[1] = q*cos((t + M_2PI)/3.) - a; // x[1] = q*cos((t + M_2PI)/3.) - a;
x[2] = q*cos((t - M_2PI)/3.) - a; // x[2] = q*cos((t - M_2PI)/3.) - a;
return(3); // return(3);
} else { // } else {
qreal aa,bb; // qreal aa,bb;
if(r<=0.){ // if(r<=0.){
r=-r; // r=-r;
} // }
aa = -pow(r + sqrt(r2-q3),1./3.); // aa = -pow(r + sqrt(r2-q3),1./3.);
if(aa!=0.){ // if(aa!=0.){
bb=q/aa; // bb=q/aa;
} else { // } else {
bb=0.; // bb=0.;
} // }
a/=3.; // a/=3.;
q = aa+bb; // q = aa+bb;
r = aa-bb; // r = aa-bb;
x[0] = q-a; // x[0] = q-a;
x[1] = (-0.5)*q-a; // x[1] = (-0.5)*q-a;
x[2] = (sqrt(3.)*0.5)*fabs(r); // x[2] = (sqrt(3.)*0.5)*fabs(r);
if(x[2]==0.){ // if(x[2]==0.){
return(2); // return(2);
} // }
return(1); // return(1);
} // }
} //}
//
//qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, //qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3,
// qreal curve_coord4, qreal point_coord) const{ // qreal curve_coord4, qreal point_coord) const{
// qreal P1, P2, P3, P4, Bt; // qreal P1, P2, P3, P4, Bt;
// qreal a, b, c, d, ret_t; // qreal a, b, c, d, ret_t;
//
// qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal))); // qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal)));
// P1 = curve_coord1; // P1 = curve_coord1;
// P2 = curve_coord2; // P2 = curve_coord2;
// P3 = curve_coord3; // P3 = curve_coord3;
// P4 = curve_coord4; // P4 = curve_coord4;
// Bt = point_coord; // Bt = point_coord;
//
// a = -P1 + 3*P2 - 3*P3 + P4; // a = -P1 + 3*P2 - 3*P3 + P4;
// b = 3*P1 - 6*P2 + 3*P3; // b = 3*P1 - 6*P2 + 3*P3;
// c = -3*P1 + 3*P2; // c = -3*P1 + 3*P2;
// d = -Bt + P1; // d = -Bt + P1;
//
// if(Cubic(t, b/a, c/a, d/a) == 3){ // if(Cubic(t, b/a, c/a, d/a) == 3){
// ret_t = t[2]; // ret_t = t[2];
// } else { // } else {
@ -707,7 +713,7 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// * Повертається три значення, але експереминтально знайдено що шукане // * Повертається три значення, але експереминтально знайдено що шукане
// * значення знаходиться в третьому. // * значення знаходиться в третьому.
// */ // */
//
// free(t); // free(t);
// if(ret_t<0 || ret_t>1){ // if(ret_t<0 || ret_t>1){
// qDebug()<<"Неправильне значення параметра. фунція calc_t"; // qDebug()<<"Неправильне значення параметра. фунція calc_t";
@ -731,7 +737,7 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// else // else
// return t_y; // return t_y;
//} //}
//
//void VSpline::Mirror(const QPointF Pmirror){ //void VSpline::Mirror(const QPointF Pmirror){
// QPointF P1 = p1; // QPointF P1 = p1;
// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y()); // P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y());
@ -752,16 +758,9 @@ qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
// this->ModifiSpl(P1, P2, P3, P4); // this->ModifiSpl(P1, P2, P3, P4);
//} //}
Draw::Draws VSpline::getMode() const{ QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
return mode; qreal kAsm2, qreal kCurve)
} {
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){
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 ); p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90; qreal L = 0, radius = 0, angle = 90;
@ -776,15 +775,8 @@ QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qre
return GetPoints(p1, p2, p3, p4); return GetPoints(p1, p2, p3, p4);
} }
qint64 VSpline::getIdObject() const{ VSpline &VSpline::operator =(const VSpline &spline)
return idObject; {
}
void VSpline::setIdObject(const qint64 &value){
idObject = value;
}
VSpline &VSpline::operator =(const VSpline &spline){
this->p1 = spline.GetP1 (); this->p1 = spline.GetP1 ();
this->p2 = spline.GetP2 (); this->p2 = spline.GetP2 ();
this->p3 = spline.GetP3 (); this->p3 = spline.GetP3 ();
@ -797,5 +789,6 @@ VSpline &VSpline::operator =(const VSpline &spline){
this->points = spline.GetDataPoints(); this->points = spline.GetDataPoints();
this->mode = spline.getMode(); this->mode = spline.getMode();
this->idObject = spline.getIdObject(); this->idObject = spline.getIdObject();
this->_name = spline.name();
return *this; 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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,22 +24,22 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VSPLINE_H #ifndef VSPLINE_H
#define VSPLINE_H #define VSPLINE_H
#define M_2PI 6.28318530717958647692528676655900576 #include "../container/vpointf.h"
#include <QPainterPath> class QString;
#include <QVector>
#include <QHash> #define M_2PI 6.28318530717958647692528676655900576
#include "container/vpointf.h"
/** /**
* @brief VSpline клас, що реалізує сплайн. * @brief VSpline клас, що реалізує сплайн.
*/ */
class VSpline{ class VSpline
{
public: public:
VSpline(); VSpline();
/** /**
@ -50,9 +57,9 @@ public:
* @param kAsm1 коефіцієнт довжини першої напрямної. * @param kAsm1 коефіцієнт довжини першої напрямної.
* @param kAsm2 коефіцієнт довжини другої напрямної. * @param kAsm2 коефіцієнт довжини другої напрямної.
*/ */
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); qint64 idObject = 0);
/** /**
* @brief VSpline конструктор. * @brief VSpline конструктор.
* @param p1 початкова точка сплайну. * @param p1 початкова точка сплайну.
@ -60,9 +67,8 @@ public:
* @param p3 друга контролююча точка сплайну. * @param p3 друга контролююча точка сплайну.
* @param p4 кінцева точка сплайну. * @param p4 кінцева точка сплайну.
*/ */
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
qint64 idObject = 0);
/** /**
* @brief ModifiSpl модифікує сплайн. * @brief ModifiSpl модифікує сплайн.
* @param p1 початкова точка сплайну. * @param p1 початкова точка сплайну.
@ -82,7 +88,8 @@ public:
* @param p3 друга контролююча точка сплайну. * @param p3 друга контролююча точка сплайну.
* @param p4 кінцева точка сплайну. * @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 поворот сплайна навколо точки на кут в градусах проти годиникової стрілки. * @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки.
* @param pRotate точка навколо якої повертаємо. * @param pRotate точка навколо якої повертаємо.
@ -99,44 +106,44 @@ public:
* @brief GetP1 повертає першу точку сплайну. * @brief GetP1 повертає першу точку сплайну.
* @return перша точка сплайну. * @return перша точка сплайну.
*/ */
qint64 GetP1 () const; qint64 GetP1 () const {return p1;}
VPointF GetPointP1() const; VPointF GetPointP1() const;
/** /**
* @brief GetP2 повертує першу контрольну точку сплайну. * @brief GetP2 повертує першу контрольну точку сплайну.
* @return перша контрольна точка сплайну. * @return перша контрольна точка сплайну.
*/ */
QPointF GetP2 () const; inline QPointF GetP2 () const {return p2;}
/** /**
* @brief GetP3 повертає другу контрольну точку сплайну. * @brief GetP3 повертає другу контрольну точку сплайну.
* @return друга контрольна точка сплайну. * @return друга контрольна точка сплайну.
*/ */
QPointF GetP3 () const; inline QPointF GetP3 () const {return p3;}
/** /**
* @brief GetP4 повертає останню точку сплайну. * @brief GetP4 повертає останню точку сплайну.
* @return остання точка сплайну. * @return остання точка сплайну.
*/ */
qint64 GetP4 () const; inline qint64 GetP4 () const {return p4;}
VPointF GetPointP4 () const; VPointF GetPointP4 () const;
/** /**
* @brief GetAngle1 повертає кут першої напрямної. * @brief GetAngle1 повертає кут першої напрямної.
* @return кут в градусах. * @return кут в градусах.
*/ */
qreal GetAngle1 () const; inline qreal GetAngle1 () const {return angle1;}
/** /**
* @brief GetAngle2 повертає кут другої напрямної. * @brief GetAngle2 повертає кут другої напрямної.
* @return кут в градусах. * @return кут в градусах.
*/ */
qreal GetAngle2() const; inline qreal GetAngle2() const {return angle2;}
/** /**
* @brief GetLength повертає довжину сплайну. * @brief GetLength повертає довжину сплайну.
* @return довжина сплайну. * @return довжина сплайну.
*/ */
qreal GetLength () const; qreal GetLength () const;
QString GetName () const; QString GetName () const;
qreal GetKasm1() const; inline qreal GetKasm1() const {return kAsm1;}
qreal GetKasm2() const; inline qreal GetKasm2() const {return kAsm2;}
qreal GetKcurve() const; inline qreal GetKcurve() const {return kCurve;}
const QHash<qint64, VPointF> *GetDataPoints() const; inline const QHash<qint64, VPointF> GetDataPoints() const {return points;}
/** /**
* @brief CrossingSplLine перевіряє перетин сплайну з лінією. * @brief CrossingSplLine перевіряє перетин сплайну з лінією.
* @param line лінія з якою перевіряється перетин. * @param line лінія з якою перевіряється перетин.
@ -179,13 +186,15 @@ public:
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну. * @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/ */
// void Mirror(const QPointF Pmirror); // void Mirror(const QPointF Pmirror);
Draw::Draws getMode() const; inline Draw::Draws getMode() const {return mode;}
void setMode(const Draw::Draws &value); inline void setMode(const Draw::Draws &value) {mode = value;}
static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1, static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve); qreal kAsm2, qreal kCurve);
qint64 getIdObject() const; inline qint64 getIdObject() const {return idObject;}
void setIdObject(const qint64 &value); inline void setIdObject(const qint64 &value) {idObject = value;}
VSpline &operator=(const VSpline &spl); VSpline &operator=(const VSpline &spl);
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
protected: protected:
/** /**
* @brief GetPoints повертає точки з яких складається сплайн. * @brief GetPoints повертає точки з яких складається сплайн.
@ -195,7 +204,7 @@ protected:
* @param p4 кінцева точка сплайну. * @param p4 кінцева точка сплайну.
* @return список точок. * @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: private:
/** /**
* @brief p1 початкова точка сплайну * @brief p1 початкова точка сплайну
@ -224,9 +233,10 @@ private:
qreal kAsm1; qreal kAsm1;
qreal kAsm2; qreal kAsm2;
qreal kCurve; qreal kCurve;
const QHash<qint64, VPointF> *points; QHash<qint64, VPointF> points;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
QString _name;
/** /**
* @brief LengthBezier повертає дожину сплайну за його чотирьма точками. * @brief LengthBezier повертає дожину сплайну за його чотирьма точками.
* @param p1 початкова точка сплайну. * @param p1 початкова точка сплайну.
@ -235,7 +245,7 @@ private:
* @param p4 кінцева точка сплайну. * @param p4 кінцева точка сплайну.
* @return дожина сплайну. * @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 знаходить точки сплайну по його чотирьом точках. * @brief PointBezier_r знаходить точки сплайну по його чотирьом точках.
* @param x1 х координата першої точки сплайну. * @param x1 х координата першої точки сплайну.
@ -250,8 +260,7 @@ private:
* @param px список х координат точок сплайну. * @param px список х координат точок сплайну.
* @param py список у коодринат сплайну. * @param py список у коодринат сплайну.
*/ */
static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4,
qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py); qint16 level, QVector<qreal> &px, QVector<qreal> &py);
/** /**
* @brief CalcSqDistance розраховує довжину між точками. * @brief CalcSqDistance розраховує довжину між точками.
@ -262,15 +271,15 @@ private:
* @return довжину. * @return довжину.
*/ */
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2); static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
/** // /**
* @brief Cubic знаходить розв'язок кубічного рівняння. // * @brief Cubic знаходить розв'язок кубічного рівняння.
* @param x коефіцієнт. // * @param x коефіцієнт.
* @param a коефіцієнт. // * @param a коефіцієнт.
* @param b коефіцієнт. // * @param b коефіцієнт.
* @param c коефіцієнт. // * @param c коефіцієнт.
* @return повертає корені рівняння. // * @return повертає корені рівняння.
*/ // */
static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c); // static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c);
/** /**
* @brief calc_t знаходить параметр t якому відповідає точка на сплайні. * @brief calc_t знаходить параметр t якому відповідає точка на сплайні.
* @param curve_coord1 координата Х або У кривої. * @param curve_coord1 координата Х або У кривої.
@ -280,8 +289,8 @@ private:
* @param point_coord координата Х або У точки на кривій. * @param point_coord координата Х або У точки на кривій.
* @return * @return
*/ */
// static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, // static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, qreal curve_coord4,
// qreal curve_coord4, qreal point_coord)const; // qreal point_coord)const;
/** /**
* @brief param_t знаходить підходяще значення параметра t якому відповідає точка на сплайні * @brief param_t знаходить підходяще значення параметра t якому відповідає точка на сплайні
* @param pBt точка для якої шукається значення параметра t. * @param pBt точка для якої шукається значення параметра t.

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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,156 +24,148 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vsplinepath.h" #include "vsplinepath.h"
#include "exception/vexception.h" #include "../exception/vexception.h"
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(0), VSplinePath::VSplinePath()
idObject(0){ : 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>()), VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject)
kCurve(kCurve), mode(mode), points(points), idObject(idObject){ : path(QVector<VSplinePoint>()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject), _name(QString())
} {}
VSplinePath::VSplinePath(const VSplinePath &splPath): path(*splPath.GetPoint()), VSplinePath::VSplinePath(const VSplinePath &splPath)
kCurve(splPath.getKCurve()), mode(splPath.getMode()), points( splPath.GetDataPoints()), : path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()),
idObject(splPath.getIdObject()){ idObject(splPath.getIdObject()), _name(splPath.name()){}
}
Draw::Draws VSplinePath::getMode() const{ void VSplinePath::append(const VSplinePoint &point)
return mode; {
}
void VSplinePath::setMode(const Draw::Draws &value){
mode = value;
}
void VSplinePath::append(VSplinePoint point){
path.append(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{ qint32 VSplinePath::Count() const
if(path.size() == 0){ {
if (path.size() == 0)
{
return 0; return 0;
} else { }
else
{
return path.size() - 1; return path.size() - 1;
} }
} }
qint32 VSplinePath::CountPoint() const{ VSpline VSplinePath::GetSpline(qint32 index) const
return path.size(); {
} if (Count()<1)
{
VSpline VSplinePath::GetSpline(qint32 index) const{
if(Count()<1){
throw VException(tr("Not enough points to create the spline.")); throw VException(tr("Not enough points to create the spline."));
} }
if(index < 1 || index > Count()){ if (index < 1 || index > Count())
{
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
VSpline spl(points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(), VSpline spl(&points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve); path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
return spl; return spl;
} }
QPainterPath VSplinePath::GetPath() const{ QPainterPath VSplinePath::GetPath() const
{
QPainterPath painterPath; QPainterPath painterPath;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), {
path[i].KAsm1(), this->kCurve); 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()); painterPath.addPath(spl.GetPath());
} }
return painterPath; return painterPath;
} }
QVector<QPointF> VSplinePath::GetPathPoints() const{ QVector<QPointF> VSplinePath::GetPathPoints() const
{
QVector<QPointF> pathPoints; QVector<QPointF> pathPoints;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), {
path[i].KAsm1(), this->kCurve); 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(); QVector<QPointF> splP = spl.GetPoints();
for(qint32 j = 0; j < splP.size(); ++j){ for (qint32 j = 0; j < splP.size(); ++j)
{
pathPoints.append(splP[j]); pathPoints.append(splP[j]);
} }
} }
return pathPoints; return pathPoints;
} }
QVector<VSplinePoint> VSplinePath::GetSplinePath() const{ qreal VSplinePath::GetLength() const
return path; {
}
qreal VSplinePath::GetLength() const{
qreal length = 0; qreal length = 0;
for(qint32 i = 1; i <= Count(); ++i){ for (qint32 i = 1; i <= Count(); ++i)
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), {
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), kCurve); path[i].KAsm1(), kCurve);
length += spl.GetLength(); length += spl.GetLength();
} }
return length; return length;
} }
const QHash<qint64, VPointF> *VSplinePath::GetDataPoints() const{ void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point)
return points; {
} if (indexSpline < 1 || indexSpline > Count())
{
void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point){
if(indexSpline < 1 || indexSpline > Count()){
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if (pos == SplinePoint::FirstPoint)
{
path[indexSpline-1] = point; path[indexSpline-1] = point;
} else { }
else
{
path[indexSpline] = point; path[indexSpline] = point;
} }
} }
VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const{ VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const
if(indexSpline < 1 || indexSpline > Count()){ {
if (indexSpline < 1 || indexSpline > Count())
{
throw VException(tr("This spline is not exist.")); throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if (pos == SplinePoint::FirstPoint)
{
return path.at(indexSpline-1); return path.at(indexSpline-1);
} else { }
else
{
return path.at(indexSpline); return path.at(indexSpline);
} }
} }
void VSplinePath::Clear(){ VSplinePath &VSplinePath::operator =(const VSplinePath &path)
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){
this->path = path.GetSplinePath(); this->path = path.GetSplinePath();
this->kCurve = path.getKCurve(); this->kCurve = path.getKCurve();
this->mode = path.getMode(); this->mode = path.getMode();
this->points = path.GetDataPoints(); this->points = path.GetDataPoints();
this->idObject = path.getIdObject(); this->idObject = path.getIdObject();
this->_name = path.name();
return *this; return *this;
} }
VSplinePoint & VSplinePath::operator[](int indx){ VSplinePoint & VSplinePath::operator[](ptrdiff_t indx)
{
return path[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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,16 +24,18 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#ifndef VSPLINEPATH_H #ifndef VSPLINEPATH_H
#define VSPLINEPATH_H #define VSPLINEPATH_H
#include "vsplinepoint.h" #include "vsplinepoint.h"
#include "../container/vpointf.h"
#include "vspline.h" #include "vspline.h"
#include <QCoreApplication> #include <QApplication>
namespace SplinePoint{ namespace SplinePoint
{
enum Position { FirstPoint, LastPoint }; enum Position { FirstPoint, LastPoint };
Q_DECLARE_FLAGS(Positions, Position) Q_DECLARE_FLAGS(Positions, Position)
} }
@ -35,7 +44,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
/** /**
* @brief The VSplinePath клас, що розраховує шлях сплайнів. * @brief The VSplinePath клас, що розраховує шлях сплайнів.
*/ */
class VSplinePath{ class VSplinePath
{
Q_DECLARE_TR_FUNCTIONS(VSplinePath) Q_DECLARE_TR_FUNCTIONS(VSplinePath)
public: public:
/** /**
@ -52,32 +62,33 @@ public:
* @brief append додає точку сплайну до шляху. * @brief append додає точку сплайну до шляху.
* @param point точка. * @param point точка.
*/ */
void append(VSplinePoint point); void append(const VSplinePoint &point);
qint32 Count() const; qint32 Count() const;
qint32 CountPoint() const; inline qint32 CountPoint() const {return path.size();}
VSpline GetSpline(qint32 index) const; VSpline GetSpline(qint32 index) const;
QPainterPath GetPath() const; QPainterPath GetPath() const;
QVector<QPointF> GetPathPoints() const; QVector<QPointF> GetPathPoints() const;
QVector<VSplinePoint> GetSplinePath() const; inline QVector<VSplinePoint> GetSplinePath() const {return path;}
qreal GetLength() const; qreal GetLength() const;
const QHash<qint64, VPointF> *GetDataPoints() const; inline QHash<qint64, VPointF> GetDataPoints() const {return points;}
void UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point); void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point);
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const; VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const;
/** /**
* @brief Clear очищає шлях сплайнів. * @brief Clear очищає шлях сплайнів.
*/ */
void Clear(); inline void Clear() {path.clear();}
qreal getKCurve() const; inline qreal getKCurve() const {return kCurve;}
void setKCurve(const qreal &value); inline void setKCurve(const qreal &value) {kCurve = value;}
const QVector<VSplinePoint> *GetPoint() const; inline const QVector<VSplinePoint> *GetPoint() const {return &path;}
VSplinePath &operator=(const VSplinePath &path); VSplinePath &operator=(const VSplinePath &path);
VSplinePoint & operator[](int indx); VSplinePoint &operator[](ptrdiff_t indx);
Draw::Draws getMode() const; inline Draw::Draws getMode() const {return mode;}
void setMode(const Draw::Draws &value); inline void setMode(const Draw::Draws &value) {mode = value;}
qint64 getIdObject() const;
void setIdObject(const qint64 &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: protected:
/** /**
* @brief path вектор з точок сплайна. * @brief path вектор з точок сплайна.
@ -85,8 +96,9 @@ protected:
QVector<VSplinePoint> path; QVector<VSplinePoint> path;
qreal kCurve; qreal kCurve;
Draw::Draws mode; Draw::Draws mode;
const QHash<qint64, VPointF> *points; QHash<qint64, VPointF> points;
qint64 idObject; qint64 idObject;
QString _name;
}; };
#endif // VSPLINEPATH_H #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 ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (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 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
@ -17,56 +24,15 @@
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
****************************************************************************/ *************************************************************************/
#include "vsplinepoint.h" #include "vsplinepoint.h"
VSplinePoint::VSplinePoint():pSpline(0), angle(0), kAsm1(1), kAsm2(1){ VSplinePoint::VSplinePoint()
} :pSpline(0), angle(0), kAsm1(1), kAsm2(1){}
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle , qreal kAsm2):pSpline(pSpline), VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2)
angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){ :pSpline(pSpline), angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){}
}
VSplinePoint::VSplinePoint(const VSplinePoint &point):pSpline(point.P()), angle(point.Angle2()), VSplinePoint::VSplinePoint(const VSplinePoint &point)
kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){ :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;
}

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