From 9eb385c7a21675b45c9e9c0408e8df1084d7cb99 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 19 Feb 2016 11:45:36 +0200 Subject: [PATCH] Added tests for VEllipticalArc --HG-- branch : feature --- src/test/ValentinaTest/ValentinaTest.pro | 664 +++++++++--------- src/test/ValentinaTest/qttestmainlambda.cpp | 2 + src/test/ValentinaTest/tst_vellipticalarc.cpp | 283 ++++++++ src/test/ValentinaTest/tst_vellipticalarc.h | 47 ++ 4 files changed, 665 insertions(+), 331 deletions(-) create mode 100644 src/test/ValentinaTest/tst_vellipticalarc.cpp create mode 100644 src/test/ValentinaTest/tst_vellipticalarc.h diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 9d1dd5c04..04210efa9 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -1,331 +1,333 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2015-03-31T17:27:03 -# -#------------------------------------------------- - -QT += testlib gui printsupport xml xmlpatterns - -TARGET = ValentinaTests - -# File with common stuff for whole project -include(../../../common.pri) - -# CONFIG += testcase adds a 'make check' which is great. But by default it also -# adds a 'make install' that installs the test cases, which we do not want. -# Can configure it not to do that with 'no_testcase_installs' -# We use C++11 standard -CONFIG += c++11 testcase no_testcase_installs - -# Use out-of-source builds (shadow builds) -CONFIG -= app_bundle debug_and_release debug_and_release_target - -TEMPLATE = app - -# directory for executable file -DESTDIR = bin - -# Directory for files created moc -MOC_DIR = moc - -# objecs files -OBJECTS_DIR = obj - -DEFINES += SRCDIR=\\\"$$PWD/\\\" - -SOURCES += \ - qttestmainlambda.cpp \ - tst_vposter.cpp \ - tst_vabstractdetail.cpp \ - tst_vspline.cpp \ - abstracttest.cpp \ - tst_nameregexp.cpp \ - tst_vlayoutdetail.cpp \ - tst_varc.cpp \ - stable.cpp \ - tst_measurementregexp.cpp \ - tst_tapecommandline.cpp \ - tst_valentinacommandline.cpp \ - tst_qmutokenparser.cpp \ - tst_vmeasurements.cpp \ - tst_qmuparsererrormsg.cpp \ - tst_vlockguard.cpp \ - tst_misc.cpp \ - tst_vcommandline.cpp \ - tst_tstranslation.cpp \ - tst_vdetail.cpp \ - tst_findpoint.cpp - -HEADERS += \ - tst_vposter.h \ - tst_vabstractdetail.h \ - tst_vspline.h \ - abstracttest.h \ - tst_nameregexp.h \ - tst_vlayoutdetail.h \ - tst_varc.h \ - stable.h \ - tst_measurementregexp.h \ - tst_tapecommandline.h \ - tst_valentinacommandline.h \ - tst_qmutokenparser.h \ - tst_vmeasurements.h \ - tst_qmuparsererrormsg.h \ - tst_vlockguard.h \ - tst_misc.h \ - tst_vcommandline.h \ - tst_tstranslation.h \ - tst_vdetail.h \ - tst_findpoint.h - -# Set using ccache. Function enable_ccache() defined in common.pri. -$$enable_ccache() - -DEFINES += TS_DIR=\\\"$${PWD}/../../../share/translations\\\" - -CONFIG(debug, debug|release){ - # Debug mode - unix { - #Turn on compilers warnings. - *-g++{ - QMAKE_CXXFLAGS += \ - # Key -isystem disable checking errors in system headers. - -isystem "$${OUT_PWD}/$${UI_DIR}" \ - -isystem "$${OUT_PWD}/$${MOC_DIR}" \ - -isystem "$${OUT_PWD}/$${RCC_DIR}" \ - $$GCC_DEBUG_CXXFLAGS # See common.pri for more details. - - noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer - # do nothing - } else { - #gcc’s 4.8.0 Address Sanitizer - #http://blog.qt.digia.com/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/ - QMAKE_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer - QMAKE_CFLAGS += -fsanitize=address -fno-omit-frame-pointer - QMAKE_LFLAGS += -fsanitize=address - } - } - clang*{ - QMAKE_CXXFLAGS += \ - # Key -isystem disable checking errors in system headers. - -isystem "$${OUT_PWD}/$${UI_DIR}" \ - -isystem "$${OUT_PWD}/$${MOC_DIR}" \ - -isystem "$${OUT_PWD}/$${RCC_DIR}" \ - $$CLANG_DEBUG_CXXFLAGS \ # See common.pri for more details. - -Wno-gnu-zero-variadic-macro-arguments\ # See macros QSKIP - } - *-icc-*{ - QMAKE_CXXFLAGS += \ - -isystem "$${OUT_PWD}/$${UI_DIR}" \ - -isystem "$${OUT_PWD}/$${MOC_DIR}" \ - -isystem "$${OUT_PWD}/$${RCC_DIR}" \ - $$ICC_DEBUG_CXXFLAGS - } - } else { - *-g++{ - QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See common.pri for more details. - } - } -}else{ - # Release mode - !win32-msvc*:CONFIG += silent - DEFINES += V_NO_ASSERT - !unix:*-g++{ - QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll - } - - noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols - # do nothing - } else { - # Turn on debug symbols in release mode on Unix systems. - # On Mac OS X temporarily disabled. Need find way how to strip binary file. - !macx:!win32-msvc*{ - QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 - QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 - QMAKE_LFLAGS_RELEASE = - } - } -} - -#VTools static library (depend on VWidgets, VMisc, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vtools/$${DESTDIR}/ -lvtools - -INCLUDEPATH += $$PWD/../../libs/vtools -DEPENDPATH += $$PWD/../../libs/vtools - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a - -#VWidgets static library -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets - -INCLUDEPATH += $$PWD/../../libs/vwidgets -DEPENDPATH += $$PWD/../../libs/vwidgets - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a - -# VFormat static library (depend on VPatternDB, IFC) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat - -INCLUDEPATH += $$PWD/../../libs/vformat -DEPENDPATH += $$PWD/../../libs/vformat - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a - -#VPatternDB static library (depend on vgeometry, vmisc, VLayout) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb - -INCLUDEPATH += $$PWD/../../libs/vpatterndb -DEPENDPATH += $$PWD/../../libs/vpatterndb - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a - -#VMisc static library -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc - -INCLUDEPATH += $$PWD/../../libs/vmisc -DEPENDPATH += $$PWD/../../libs/vmisc - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/vmisc.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/libvmisc.a - -# VGeometry static library (depend on ifc) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry - -INCLUDEPATH += $$PWD/../../libs/vgeometry -DEPENDPATH += $$PWD/../../libs/vgeometry - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a - -# IFC static library (depend on QMuParser) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/ifc/$${DESTDIR}/ -lifc - -INCLUDEPATH += $$PWD/../../libs/ifc -DEPENDPATH += $$PWD/../../libs/ifc - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/ifc.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/libifc.a - -# VLayout static library -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR} -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -# QMuParser library -win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 -else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 -else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser - -INCLUDEPATH += $${PWD}/../../libs/qmuparser -DEPENDPATH += $${PWD}/../../libs/qmuparser - -# Only for adding path to LD_LIBRARY_PATH -# VPropertyExplorer library -win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer -else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer -else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer - -INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer -DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer - -TAPE_TEST_FILES += \ - tst_tape/keiko.vit \ - tst_tape/empty.vit \ - tst_tape/all_measurements_v0.3.0.vit \ - tst_tape/all_measurements_v0.4.0.vst \ - tst_tape/GOST_man_ru_v0.3.0.vst \ - tst_tape/all_measurements_v0.3.3.vit \ - tst_tape/all_measurements_v0.4.2.vst \ - tst_tape/GOST_man_ru_v0.4.2.vst \ - tst_tape/broken1.vit \ - tst_tape/broken2.vit \ - tst_tape/broken3.vit \ - tst_tape/broken4.vit \ - tst_tape/text.vit \ - tst_tape/text.vst - -VALENTINA_TEST_FILES += \ - tst_valentina/empty.val \ - tst_valentina/issue_372.val \ - tst_valentina/wrong_obj_type.val \ - tst_valentina/text.val \ - tst_valentina/glimited_no_m.val \ - tst_valentina/glimited_vit.val \ - tst_valentina/glimited.vit \ - tst_valentina/glimited_vst.val \ - tst_valentina/glimited.vst \ - tst_valentina/issue_256.val \ - tst_valentina/issue_256_wrong_path.val \ - tst_valentina/issue_256_correct.vit \ - tst_valentina/issue_256_wrong.vit \ - tst_valentina/issue_256_correct.vst \ - tst_valentina/issue_256_wrong.vit \ - tst_valentina/wrong_formula.val - -COLLECTION_FILES += \ - $${PWD}/../../app/share/tables/standard/GOST_man_ru.vst \ - $${PWD}/../../app/share/collection/bra.val \ - $${PWD}/../../app/share/collection/bra.vit \ - $${PWD}/../../app/share/collection/jacketМ1_52-176.val \ - $${PWD}/../../app/share/collection/jacketМ2_40-146.val \ - $${PWD}/../../app/share/collection/jacketМ3_40-146.val \ - $${PWD}/../../app/share/collection/jacketМ4_40-146.val \ - $${PWD}/../../app/share/collection/jacketМ5_30-110.val \ - $${PWD}/../../app/share/collection/jacketМ6_30-110.val \ - $${PWD}/../../app/share/collection/pantsМ1_52-176.val \ - $${PWD}/../../app/share/collection/pantsМ2_40-146.val \ - $${PWD}/../../app/share/collection/pantsМ7.val \ - $${PWD}/../../app/share/collection/TShirt_test.val \ - $${PWD}/../../app/share/collection/TestDart.val \ - $${PWD}/../../app/share/collection/patrón_blusa.val \ - $${PWD}/../../app/share/collection/blusa.vit \ - $${PWD}/../../app/share/collection/PajamaTopWrap2.val \ - $${PWD}/../../app/share/collection/Susan.vit \ - $${PWD}/../../app/share/collection/Moulage_0.5_armhole_neckline.val \ - $${PWD}/../../app/share/collection/0.7_Armhole_adjustment_0.10.val \ - $${PWD}/../../app/share/collection/my_calculated_measurements_for_val.vit \ - $${PWD}/../../app/share/collection/Keiko_skirt.val \ - $${PWD}/../../app/share/collection/keiko.vit \ - $${PWD}/../../app/share/collection/medidas_eli2015.vit \ - $${PWD}/../../app/share/collection/pantalon_base_Eli.val \ - $${PWD}/../../app/share/collection/Razmernye_priznaki_dlya_zhenskogo_zhaketa.vit \ - $${PWD}/../../app/share/collection/IMK_Zhaketa_poluprilegayuschego_silueta.val - - -# Compilation will fail without this files after we added them to this section. -OTHER_FILES += \ - $$TAPE_TEST_FILES \ - $$VALENTINA_TEST_FILES \ - $$COLLECTION_FILES - -for(DIR, TAPE_TEST_FILES) { - #add these absolute paths to a variable which - #ends up as 'mkcommands = path1 path2 path3 ...' - tape_path += $${PWD}/$$DIR -} - -copyToDestdir($$tape_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_tape)) - -for(DIR, VALENTINA_TEST_FILES) { - #add these absolute paths to a variable which - #ends up as 'mkcommands = path1 path2 path3 ...' - valentina_path += $${PWD}/$$DIR -} - -copyToDestdir($$valentina_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_valentina)) - -for(DIR, COLLECTION_FILES) { - #add these absolute paths to a variable which - #ends up as 'mkcommands = path1 path2 path3 ...' - collection_path += $$DIR -} - -copyToDestdir($$collection_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_valentina_collection)) +#------------------------------------------------- +# +# Project created by QtCreator 2015-03-31T17:27:03 +# +#------------------------------------------------- + +QT += testlib gui printsupport xml xmlpatterns + +TARGET = ValentinaTests + +# File with common stuff for whole project +include(../../../common.pri) + +# CONFIG += testcase adds a 'make check' which is great. But by default it also +# adds a 'make install' that installs the test cases, which we do not want. +# Can configure it not to do that with 'no_testcase_installs' +# We use C++11 standard +CONFIG += c++11 testcase no_testcase_installs + +# Use out-of-source builds (shadow builds) +CONFIG -= app_bundle debug_and_release debug_and_release_target + +TEMPLATE = app + +# directory for executable file +DESTDIR = bin + +# Directory for files created moc +MOC_DIR = moc + +# objecs files +OBJECTS_DIR = obj + +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +SOURCES += \ + qttestmainlambda.cpp \ + tst_vposter.cpp \ + tst_vabstractdetail.cpp \ + tst_vspline.cpp \ + abstracttest.cpp \ + tst_nameregexp.cpp \ + tst_vlayoutdetail.cpp \ + tst_varc.cpp \ + stable.cpp \ + tst_measurementregexp.cpp \ + tst_tapecommandline.cpp \ + tst_valentinacommandline.cpp \ + tst_qmutokenparser.cpp \ + tst_vmeasurements.cpp \ + tst_qmuparsererrormsg.cpp \ + tst_vlockguard.cpp \ + tst_misc.cpp \ + tst_vcommandline.cpp \ + tst_tstranslation.cpp \ + tst_vdetail.cpp \ + tst_findpoint.cpp \ + tst_vellipticalarc.cpp + +HEADERS += \ + tst_vposter.h \ + tst_vabstractdetail.h \ + tst_vspline.h \ + abstracttest.h \ + tst_nameregexp.h \ + tst_vlayoutdetail.h \ + tst_varc.h \ + stable.h \ + tst_measurementregexp.h \ + tst_tapecommandline.h \ + tst_valentinacommandline.h \ + tst_qmutokenparser.h \ + tst_vmeasurements.h \ + tst_qmuparsererrormsg.h \ + tst_vlockguard.h \ + tst_misc.h \ + tst_vcommandline.h \ + tst_tstranslation.h \ + tst_vdetail.h \ + tst_findpoint.h \ + tst_vellipticalarc.h + +# Set using ccache. Function enable_ccache() defined in common.pri. +$$enable_ccache() + +DEFINES += TS_DIR=\\\"$${PWD}/../../../share/translations\\\" + +CONFIG(debug, debug|release){ + # Debug mode + unix { + #Turn on compilers warnings. + *-g++{ + QMAKE_CXXFLAGS += \ + # Key -isystem disable checking errors in system headers. + -isystem "$${OUT_PWD}/$${UI_DIR}" \ + -isystem "$${OUT_PWD}/$${MOC_DIR}" \ + -isystem "$${OUT_PWD}/$${RCC_DIR}" \ + $$GCC_DEBUG_CXXFLAGS # See common.pri for more details. + + noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer + # do nothing + } else { + #gcc’s 4.8.0 Address Sanitizer + #http://blog.qt.digia.com/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/ + QMAKE_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer + QMAKE_CFLAGS += -fsanitize=address -fno-omit-frame-pointer + QMAKE_LFLAGS += -fsanitize=address + } + } + clang*{ + QMAKE_CXXFLAGS += \ + # Key -isystem disable checking errors in system headers. + -isystem "$${OUT_PWD}/$${UI_DIR}" \ + -isystem "$${OUT_PWD}/$${MOC_DIR}" \ + -isystem "$${OUT_PWD}/$${RCC_DIR}" \ + $$CLANG_DEBUG_CXXFLAGS \ # See common.pri for more details. + -Wno-gnu-zero-variadic-macro-arguments\ # See macros QSKIP + } + *-icc-*{ + QMAKE_CXXFLAGS += \ + -isystem "$${OUT_PWD}/$${UI_DIR}" \ + -isystem "$${OUT_PWD}/$${MOC_DIR}" \ + -isystem "$${OUT_PWD}/$${RCC_DIR}" \ + $$ICC_DEBUG_CXXFLAGS + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See common.pri for more details. + } + } +}else{ + # Release mode + !win32-msvc*:CONFIG += silent + DEFINES += V_NO_ASSERT + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols + # do nothing + } else { + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. Need find way how to strip binary file. + !macx:!win32-msvc*{ + QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_LFLAGS_RELEASE = + } + } +} + +#VTools static library (depend on VWidgets, VMisc, VPatternDB) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vtools/$${DESTDIR}/ -lvtools + +INCLUDEPATH += $$PWD/../../libs/vtools +DEPENDPATH += $$PWD/../../libs/vtools + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a + +#VWidgets static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets + +INCLUDEPATH += $$PWD/../../libs/vwidgets +DEPENDPATH += $$PWD/../../libs/vwidgets + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a + +# VFormat static library (depend on VPatternDB, IFC) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat + +INCLUDEPATH += $$PWD/../../libs/vformat +DEPENDPATH += $$PWD/../../libs/vformat + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a + +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb + +INCLUDEPATH += $$PWD/../../libs/vpatterndb +DEPENDPATH += $$PWD/../../libs/vpatterndb + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a + +#VMisc static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc + +INCLUDEPATH += $$PWD/../../libs/vmisc +DEPENDPATH += $$PWD/../../libs/vmisc + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/vmisc.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/libvmisc.a + +# VGeometry static library (depend on ifc) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry + +INCLUDEPATH += $$PWD/../../libs/vgeometry +DEPENDPATH += $$PWD/../../libs/vgeometry + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a + +# IFC static library (depend on QMuParser) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/ifc/$${DESTDIR}/ -lifc + +INCLUDEPATH += $$PWD/../../libs/ifc +DEPENDPATH += $$PWD/../../libs/ifc + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/ifc.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/libifc.a + +# VLayout static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR} -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + +# QMuParser library +win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 +else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser + +INCLUDEPATH += $${PWD}/../../libs/qmuparser +DEPENDPATH += $${PWD}/../../libs/qmuparser + +# Only for adding path to LD_LIBRARY_PATH +# VPropertyExplorer library +win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer +else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer +else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer + +INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer +DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer + +TAPE_TEST_FILES += \ + tst_tape/keiko.vit \ + tst_tape/empty.vit \ + tst_tape/all_measurements_v0.3.0.vit \ + tst_tape/all_measurements_v0.4.0.vst \ + tst_tape/GOST_man_ru_v0.3.0.vst \ + tst_tape/all_measurements_v0.3.3.vit \ + tst_tape/all_measurements_v0.4.2.vst \ + tst_tape/GOST_man_ru_v0.4.2.vst \ + tst_tape/broken1.vit \ + tst_tape/broken2.vit \ + tst_tape/broken3.vit \ + tst_tape/broken4.vit \ + tst_tape/text.vit \ + tst_tape/text.vst + +VALENTINA_TEST_FILES += \ + tst_valentina/empty.val \ + tst_valentina/issue_372.val \ + tst_valentina/wrong_obj_type.val \ + tst_valentina/text.val \ + tst_valentina/glimited_no_m.val \ + tst_valentina/glimited_vit.val \ + tst_valentina/glimited.vit \ + tst_valentina/glimited_vst.val \ + tst_valentina/glimited.vst \ + tst_valentina/issue_256.val \ + tst_valentina/issue_256_wrong_path.val \ + tst_valentina/issue_256_correct.vit \ + tst_valentina/issue_256_wrong.vit \ + tst_valentina/issue_256_correct.vst \ + tst_valentina/issue_256_wrong.vit \ + tst_valentina/wrong_formula.val + +COLLECTION_FILES += \ + $${PWD}/../../app/share/tables/standard/GOST_man_ru.vst \ + $${PWD}/../../app/share/collection/bra.val \ + $${PWD}/../../app/share/collection/bra.vit \ + $${PWD}/../../app/share/collection/jacketМ1_52-176.val \ + $${PWD}/../../app/share/collection/jacketМ2_40-146.val \ + $${PWD}/../../app/share/collection/jacketМ3_40-146.val \ + $${PWD}/../../app/share/collection/jacketМ4_40-146.val \ + $${PWD}/../../app/share/collection/jacketМ5_30-110.val \ + $${PWD}/../../app/share/collection/jacketМ6_30-110.val \ + $${PWD}/../../app/share/collection/pantsМ1_52-176.val \ + $${PWD}/../../app/share/collection/pantsМ2_40-146.val \ + $${PWD}/../../app/share/collection/pantsМ7.val \ + $${PWD}/../../app/share/collection/TShirt_test.val \ + $${PWD}/../../app/share/collection/TestDart.val \ + $${PWD}/../../app/share/collection/patrón_blusa.val \ + $${PWD}/../../app/share/collection/blusa.vit \ + $${PWD}/../../app/share/collection/PajamaTopWrap2.val \ + $${PWD}/../../app/share/collection/Susan.vit \ + $${PWD}/../../app/share/collection/Moulage_0.5_armhole_neckline.val \ + $${PWD}/../../app/share/collection/0.7_Armhole_adjustment_0.10.val \ + $${PWD}/../../app/share/collection/my_calculated_measurements_for_val.vit \ + $${PWD}/../../app/share/collection/Keiko_skirt.val \ + $${PWD}/../../app/share/collection/keiko.vit \ + $${PWD}/../../app/share/collection/medidas_eli2015.vit \ + $${PWD}/../../app/share/collection/pantalon_base_Eli.val \ + $${PWD}/../../app/share/collection/Razmernye_priznaki_dlya_zhenskogo_zhaketa.vit \ + $${PWD}/../../app/share/collection/IMK_Zhaketa_poluprilegayuschego_silueta.val + + +# Compilation will fail without this files after we added them to this section. +OTHER_FILES += \ + $$TAPE_TEST_FILES \ + $$VALENTINA_TEST_FILES \ + $$COLLECTION_FILES + +for(DIR, TAPE_TEST_FILES) { + #add these absolute paths to a variable which + #ends up as 'mkcommands = path1 path2 path3 ...' + tape_path += $${PWD}/$$DIR +} + +copyToDestdir($$tape_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_tape)) + +for(DIR, VALENTINA_TEST_FILES) { + #add these absolute paths to a variable which + #ends up as 'mkcommands = path1 path2 path3 ...' + valentina_path += $${PWD}/$$DIR +} + +copyToDestdir($$valentina_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_valentina)) + +for(DIR, COLLECTION_FILES) { + #add these absolute paths to a variable which + #ends up as 'mkcommands = path1 path2 path3 ...' + collection_path += $$DIR +} + +copyToDestdir($$collection_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tst_valentina_collection)) diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index bad3060f0..b1a4f4e1d 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -34,6 +34,7 @@ #include "tst_nameregexp.h" #include "tst_vlayoutdetail.h" #include "tst_varc.h" +#include "tst_vellipticalarc.h" #include "tst_measurementregexp.h" #include "tst_tapecommandline.h" #include "tst_valentinacommandline.h" @@ -68,6 +69,7 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_NameRegExp()); ASSERT_TEST(new TST_VLayoutDetail()); ASSERT_TEST(new TST_VArc()); + ASSERT_TEST(new TST_VEllipticalArc()); ASSERT_TEST(new TST_MeasurementRegExp()); ASSERT_TEST(new TST_TapeCommandLine()); ASSERT_TEST(new TST_ValentinaCommandLine()); diff --git a/src/test/ValentinaTest/tst_vellipticalarc.cpp b/src/test/ValentinaTest/tst_vellipticalarc.cpp new file mode 100644 index 000000000..6ec4e2e37 --- /dev/null +++ b/src/test/ValentinaTest/tst_vellipticalarc.cpp @@ -0,0 +1,283 @@ +/************************************************************************ + ** + ** @file tst_vellipticalarc.cpp + ** @author Valentina Zhuravska + ** @date 12 2, 2016 + ** + ** @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) 2015 Valentina project + ** 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 . + ** + *************************************************************************/ + +#include "tst_vellipticalarc.h" +#include "../vgeometry/vellipticalarc.h" +#include "../vlayout/vabstractdetail.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent) : QObject(parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void TST_VEllipticalArc::CompareTwoWays() +{ + const VPointF center; + const qreal radius1 = 100; + const qreal radius2 = 200; + const qreal f1 = 0; + const qreal f2 = 90; + const qreal rotationAngle = 0; + + const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2)); + const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/4; + + VEllipticalArc arc1(center, radius1, radius2, f1, f2, rotationAngle); + VEllipticalArc arc2(length, center, radius1, radius2, f1); + + const qreal eps = length*0.5/100; // computing error + const QString errorMsg = + QString("Difference between real and computing lengthes bigger than eps = %1.").arg(eps); + QVERIFY2(qAbs(arc1.GetLength() - length) <= eps, qUtf8Printable(errorMsg)); + //QVERIFY2(arc2.GetLength() - length <= eps, qUtf8Printable(errorMsg)); + //QVERIFY2(arc1.GetLength() - arc2.GetEndAngle() <= eps, qUtf8Printable(errorMsg)); + + // compare angles + //QVERIFY2(arc1.GetEndAngle() - arc2.GetEndAngle() <= eps, qUtf8Printable(errorMsg)); + //QVERIFY2(arc1.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg)); + //QVERIFY2(arc1.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg)); +} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void TST_VEllipticalArc::NegativeArc() +{ + const VPointF center; + const qreal radius1 = 100; + const qreal radius2 = 200; + const qreal f1 = 1; + const qreal f2 = 181; + + const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2)); + const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/2; + VEllipticalArc arc(-length, center, radius1, radius2, f1); + + const qreal eps = 1; // computing error + const QString errorMsg = + QString("Difference between real and computing lengthes bigger than eps = %1.").arg(eps); + + //QVERIFY2(qAbs(arc.GetLength() - length) <= eps, qUtf8Printable(errorMsg)); + //QVERIFY2(arc.GetEndAngle() - f2 <= eps, qUtf8Printable(errorMsg)); +} + +// cppcheck-suppress unusedFunction +//--------------------------------------------------------------------------------------------------------------------- +void TST_VEllipticalArc::TestGetPoints_data() +{ + QTest::addColumn("radius1"); + QTest::addColumn("radius2"); + QTest::addColumn("startAngle"); + QTest::addColumn("endAngle"); + QTest::addColumn("rotationAngle"); + + QTest::newRow("Full circle: radiuses 10, 20") << 10.0 << 20.0 << 0.0 << 360.0 << 0.0; + QTest::newRow("Full circle: radiuses 150, 200") << 150.0 << 200.0 << 0.0 << 360.0 << 0.0; + QTest::newRow("Full circle: radiuses 1500, 1000") << 1500.0 << 1000.0 << 0.0 << 360.0 << 0.0; + QTest::newRow("Full circle: radiuses 50000, 10000") << 50000.0 << 10000.0 << 0.0 << 360.0 << 0.0; + QTest::newRow("Full circle: radiuses 90000, 80000") << 90000.0 << 80000.0 << 0.0 << 360.0 << 0.0; + + QTest::newRow("Arc less than 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 10.5 << 0.0; + QTest::newRow("Arc less than 45 degree, radiuses 150, 50") << 150.0 << 50.0 << 0.0 << 10.5 << 0.0; + QTest::newRow("Arc less than 45 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 10.5 << 0.0; + QTest::newRow("Arc less than 45 degree, radiuses 50000, 10000") << 50000.0 << 10000.0 << 0.0 << 10.5 << 0.0; + QTest::newRow("Arc less than 45 degree, radiuses 90000, 10000") << 90000.0 << 10000.0 << 0.0 << 10.5 << 0.0; + + QTest::newRow("Arc 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 45.0 << 0.0; + QTest::newRow("Arc 45 degree, radiuses 150, 15") << 150.0 << 15.0 << 0.0 << 45.0 << 0.0; + QTest::newRow("Arc 45 degree, radiuses 1500, 150") << 1500.0 << 150.0 << 0.0 << 45.0 << 0.0; + QTest::newRow("Arc 45 degree, radiuses 50000, 50000") << 50000.0 << 50000.0 << 0.0 << 45.0 << 0.0; + QTest::newRow("Arc 45 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 45.0 << 0.0; + + QTest::newRow("Arc less than 90 degree, radiuses 100, 400") << 100.0 << 400.0 << 0.0 << 75.0 << 0.0; + QTest::newRow("Arc less than 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 75.0 << 0.0; + QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000") << 1500.0 << 50000.0 << 0.0 << 75.0 << 0.0; + QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 75.0 << 0.0; + QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 75.0 << 0.0; + + QTest::newRow("Arc 90 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 90.0 << 0.0; + QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0; + QTest::newRow("Arc 90 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 90.0 << 0.0; + QTest::newRow("Arc 90 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 90.0 << 0.0; + QTest::newRow("Arc 90 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 90.0 << 0.0; + + QTest::newRow("Arc less than 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 110.6 << 0.0; + QTest::newRow("Arc less than 135 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 110.6 << 0.0; + QTest::newRow("Arc less than 135 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 110.6 << 0.0; + QTest::newRow("Arc less than 135 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 110.6 << 0.0; + QTest::newRow("Arc less than 135 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 110.6 << 0.0; + + QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0; + QTest::newRow("Arc 135 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 135.0 << 0.0; + QTest::newRow("Arc 135 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 135.0 << 0.0; + QTest::newRow("Arc 135 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 135.0 << 0.0; + QTest::newRow("Arc 135 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 135.0 << 0.0; + + QTest::newRow("Arc less than 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 160.7 << 0.0; + QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0; + QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0; + QTest::newRow("Arc less than 180 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 160.7 << 0.0; + QTest::newRow("Arc less than 180 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 160.7 << 0.0; + + QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0; + QTest::newRow("Arc 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 180.0 << 0.0; + QTest::newRow("Arc 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 180.0 << 0.0; + QTest::newRow("Arc 180 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 180.0 << 0.0; + QTest::newRow("Arc 180 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 180.0 << 0.0; + + QTest::newRow("Arc less than 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 150.3 << 0.0; + QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0; + QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0; + QTest::newRow("Arc less than 270 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 150.3 << 0.0; + QTest::newRow("Arc less than 270 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 150.3 << 0.0; + + QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0; + QTest::newRow("Arc 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 270.0 << 0.0; + QTest::newRow("Arc 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 270.0 << 0.0; + QTest::newRow("Arc 270 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 270.0 << 0.0; + QTest::newRow("Arc 270 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 270.0 << 0.0; + + QTest::newRow("Arc less than 360 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 340.0 << 0.0; + QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0; + QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0; + QTest::newRow("Arc less than 360 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 0.0 << 340.0 << 0.0; + QTest::newRow("Arc less than 360 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 0.0 << 340.0 << 0.0; + + QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0; + QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0; + QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 90.0 << 135.0 << 0.0; + QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 50000, 5000") << 50000.0 << 5000.0 << 90.0 << 135.0 << 0.0; + QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 90000, 50000") << 90000.0 << 50000.0 << 90.0 << 135.0 << 0.0; +} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void TST_VEllipticalArc::TestGetPoints() +{ + QFETCH(qreal, radius1); + QFETCH(qreal, radius2); + QFETCH(qreal, startAngle); + QFETCH(qreal, endAngle); + QFETCH(qreal, rotationAngle); + + const VPointF center; + VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle); + + QVector points = arc.GetPoints(); + { + qreal eps = 0.5; + const QString errorMsg = QString("Broken the first rule, part 1. Any point must satisfy the equation of ellipse."); + for (int i=0; i < points.size(); ++i) + { + QPointF p = points.at(i); + const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2); + const qreal diff = qAbs(equationRes - 1); + QVERIFY2( diff <= eps, qUtf8Printable(errorMsg)); + } + } + { + const qreal c = qSqrt(qAbs(radius2*radius2 - radius1*radius1)); + // distance from the center to the focus + + QPointF focus1 = center.toQPointF(); + QPointF focus2 = center.toQPointF(); + + if (radius1 < radius2) + { + focus1.setY(focus1.ry() + c); + QLineF line(center.toQPointF(), focus1); + line.setAngle(line.angle() + rotationAngle); + focus1 = line.p2(); + + focus2.setY(focus2.ry() - c); + line.setP2(focus2); + line.setAngle(line.angle() + rotationAngle); + focus2 = line.p2(); + } + else + { + focus1.setX(focus1.rx() + c); + QLineF line(center.toQPointF(), focus1); + line.setAngle(line.angle() + rotationAngle); + focus1 = line.p2(); + + focus2.setX(focus2.rx() - c); + line.setP2(focus2); + line.setAngle(line.angle() + rotationAngle); + focus2 = line.p2(); + } + + QPointF ellipsePoint(center.x() + radius1, center.y()); + QLineF line(center.toQPointF(), ellipsePoint); + line.setAngle(line.angle() + rotationAngle); + ellipsePoint = line.p2(); + + const QLineF distance1(focus1, ellipsePoint); + const QLineF distance2(focus2, ellipsePoint); + + const qreal distance = distance1.length() + distance2.length(); + const qreal eps = distance * 0.5/ 100; // computing error 0.5 % from origin distance + for (int i=0; i < points.size(); ++i) + { + const QLineF rLine1(focus1, points.at(i)); + const QLineF rLine2(focus2, points.at(i)); + const qreal resultingDistance = rLine1.length()+rLine2.length(); + const qreal diff = qAbs(resultingDistance - distance); + const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1 plus" + " distance from this point to the focus2 should be the same. Problem with point '%1'." + " The disired distance is '%2', but resulting distance is '%3'. Difference is '%4' and it" + " biggest than eps ('%5')").arg(i).arg(distance).arg(resultingDistance).arg(diff).arg(eps); + QVERIFY2( diff <= eps, qUtf8Printable(errorMsg)); + } + } + { + if (qFuzzyCompare(arc.AngleArc(), 360.0)) + {// calculated full ellipse square + const qreal ellipseSquare = M_PI * radius1 * radius2; + const qreal epsSquare = ellipseSquare * 0.24 / 100; // computing error 0.24 % from origin squere + const qreal arcSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0); + const qreal diffSquare = qAbs(ellipseSquare - arcSquare); + const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. " + "Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare); + QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1)); + + // calculated full ellipse length + const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2)); + const qreal ellipseLength = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h))); + const qreal epsLength = ellipseLength*0.5/100; // computing error + VEllipticalArc arc(center, radius1, radius2, 0, 360, 0); + const qreal arcLength = arc.GetLength(); + const qreal diffLength = qAbs(arcLength - ellipseLength); + const QString errorMsg2 = QString("Difference between real and computing lengthes " + "(diff = '%1') bigger than eps = '%2'.").arg(diffLength).arg(epsLength); + QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2)); + } + } +} diff --git a/src/test/ValentinaTest/tst_vellipticalarc.h b/src/test/ValentinaTest/tst_vellipticalarc.h new file mode 100644 index 000000000..21a0a408f --- /dev/null +++ b/src/test/ValentinaTest/tst_vellipticalarc.h @@ -0,0 +1,47 @@ +/************************************************************************ + ** + ** @file tst_vellipticalarc.h + ** @author Valentina Zhuravska + ** @date 12 2, 2016 + ** + ** @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) 2015 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef TST_VELLIPTICALARC_H +#define TST_VELLIPTICALARC_H + +#include + +class TST_VEllipticalArc : public QObject +{ + Q_OBJECT +public: + explicit TST_VEllipticalArc(QObject *parent = 0); + +private slots: + void CompareTwoWays(); + void NegativeArc(); + void TestGetPoints_data(); + void TestGetPoints(); +}; + +#endif // TST_VELLIPTICALARC_H