diff --git a/.hgignore b/.hgignore index 2e058acbc..305d6889b 100644 --- a/.hgignore +++ b/.hgignore @@ -19,9 +19,68 @@ syntax: glob # Ignore this directory. html/ latex/ +bin/ +moc/ +obj/ +uic/ +rcc/ +man/ -# Ignore file used QtCreator for user profile. +# Ignore Coverity Scan Build Tool +cov-int/ + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Qt-es +/.qmake.cache +/.qmake.stash *.pro.user +*.pro.user.* +*.moc +moc_*.cpp +qrc_*.cpp +ui_*.h +Makefile* +*-build-* -# Ignore file Qt translation. +# Ignore Qt translation file . *.qm + +# QtCreator +*.autosave + +# Ignore Mercurial .orig files +*.orig + +*.rej + +# QtCtreator Qml +*.qmlproject.user +*.qmlproject.user.* diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index dd9952069..000000000 --- a/AUTHORS +++ /dev/null @@ -1,5 +0,0 @@ -Author: - - (*) Roman Telezhinsky - Founder of the project. - diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 000000000..f3123fad8 --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,14 @@ +Our Team: + + (*) Roman Telezhynskyi + Maintainer and founder of the project. + + (*) Christine Neupert + Testing, translation. + + (*) Patrick Proy + Developing. + + (*) Lindsay Williams + Design logo. + diff --git a/ChangeLog b/ChangeLog.txt similarity index 100% rename from ChangeLog rename to ChangeLog.txt diff --git a/LICENSE b/LICENSE_GPL.txt similarity index 100% rename from LICENSE rename to LICENSE_GPL.txt diff --git a/README b/README deleted file mode 100644 index ae3363403..000000000 --- a/README +++ /dev/null @@ -1,63 +0,0 @@ -Pattern making program -Copyright (C) 2013 Roman Telezhinsky -https://dismine@bitbucket.org/dismine/valentina - -Valentina -========== -Open source project of creating a pattern making program, whose allow -create and modeling patterns of clothing. - -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 Unix development packages needed) - * mercurial - * On Unix: - - ccache - - g++ (at least GCC 4.6 is needed and GCC 4.8 is recommended) - * 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) - -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. - -LICENSING -========== -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. - -See LICENSE file for further information diff --git a/README.txt b/README.txt new file mode 100644 index 000000000..33c10eee0 --- /dev/null +++ b/README.txt @@ -0,0 +1,84 @@ +Pattern making program +Copyright (C) 2013-2014 Roman Telezhynskyi +Valentina Web page: http://www.valentina-project.org/ +Valentina user manual https://bitbucket.org/dismine/valentina/wiki/manual/Content +Valentina main repository: https://bitbucket.org/dismine/valentina/overview +Valentina mail list (forum) https://groups.google.com/forum/#!forum/valentina-project-list +PPA for Ubuntu (develop): https://launchpad.net/~dismine/+archive/valentina-dev +Help translate https://www.transifex.com/organization/valentina + +Valentina +========== +Valentina is a cross-platform patternmaking program which allows designers +to create and model patterns of clothing. This software allows pattern +creation, using either standard sizing tables or an individual’s set of +measurements. It blends new technologies with traditional methods to create +a unique pattern making tool. + +Supported Platforms +=================== +The standalone binary packages support the following platforms: + +Windows XP SP2 or later +Ubuntu Linux 14.04 (32-bit) or later + +Building the sources requires Qt 5.2.1 or later. + +Compiling Valentina +==================== +Prerequisites: + * Qt 5.2.1 or later (On Unix development packages needed) + * mercurial + * On Unix: + - ccache + - g++ (at least GCC 4.6 is needed and GCC 4.8 is recommended) or + clang (clang 3.4 recommended) + - xpdf package (tool pdftops). + * On Windows: + - MinGW + - Xpdf is an open source viewer for Portable Document Format (PDF) + files. Website http://www.foolabs.com/xpdf/. Put tool pdftops.exe + in the same directory with Valentina's binary file. + +The installed toolchains have to match the one Qt was compiled with. + +You can build Valentina with + + cd $SOURCE_DIRECTORY + qmake Valentina.pro -r (or qmake-qt5, depending on your platform) + make (or mingw32-make or nmake or jom, depending on your platform) + +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. + +Unix systems: +Default prefix for command "make install" is /usr. For using another +prefix build with qmake command: + +qmake PREFIX=/usr/local Valentina.pro -r + +where /usr/local is a new prefix for installation. + +LICENSING +========== +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. + +See LICENSE file for further information diff --git a/TODO b/TODO deleted file mode 100644 index 1499e59a6..000000000 --- a/TODO +++ /dev/null @@ -1,33 +0,0 @@ -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. - - - - - diff --git a/Valentina.pri b/Valentina.pri new file mode 100644 index 000000000..ae716f1e0 --- /dev/null +++ b/Valentina.pri @@ -0,0 +1,541 @@ +defineTest(minQtVersion) { + maj = $$1 + min = $$2 + patch = $$3 + isEqual(QT_MAJOR_VERSION, $$maj) { + isEqual(QT_MINOR_VERSION, $$min) { + isEqual(QT_PATCH_VERSION, $$patch) { + return(true) + } + greaterThan(QT_PATCH_VERSION, $$patch) { + return(true) + } + } + greaterThan(QT_MINOR_VERSION, $$min) { + return(true) + } + } + greaterThan(QT_MAJOR_VERSION, $$maj) { + return(true) + } + return(false) +} + +# Copies the given files to the destination directory +defineTest(copyToDestdir) { + files = $$1 + DDIR = $$2 + mkpath($$DDIR) + + message("----------------------------------------------begin------------------------------------------------") + message("Copy to" $$DDIR "after link") + for(FILE, files) { + + # Replace slashes in paths with backslashes for Windows + win32{ + FILE ~= s,/,\\,g + DDIR ~= s,/,\\,g + } + QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) + message("Command:" $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR)) + } + + export(QMAKE_POST_LINK) + message("----------------------------------------------end---------------------------------------------------") +} + +# We use precompiled headers for more fast compilation source code. +defineReplace(set_PCH){ + macx:clang*{ + # Precompiled headers don't work with clang on macx. + } else { + CONFIG += precompile_header # Turn on creation precompiled headers (PCH). + export(CONFIG) # export value to global variable. + + PRECOMPILED_HEADER = stable.h # Header file with all all static headers: libraries, static local headers. + export(PRECOMPILED_HEADER) # export value to global variable + + win32-msvc* { + PRECOMPILED_SOURCE = stable.cpp # MSVC need also cpp file. + export(PRECOMPILED_SOURCE) # export value to global variable. + } + } + return(true) +} + +defineReplace(enable_ccache){ + # ccache support only Unix systems. + unix:{ + # This need for turn on ccache. + *-g++{ + QMAKE_CC = ccache gcc + export(QMAKE_CC) # export value to global variable. + + QMAKE_CXX = ccache g++ + export(QMAKE_CXX) # export value to global variable. + } + clang*{ + QMAKE_CC = ccache clang + export(QMAKE_CC) # export value to global variable. + + QMAKE_CXX = ccache clang++ + export(QMAKE_CXX) # export value to global variable. + } + } + return(true) +} + +# Default prefix. Use for creation install path. +DEFAULT_PREFIX = /usr + +# In debug mode on Unix system we use all usefull for us compilers keys for checking errors. +# Also trying make all possible for speed up build time. +unix { + +# Key -isystem disable checking errors in system headers. Mark ignore warnings Qt headers. +ISYSTEM += \ + -isystem "$$[QT_INSTALL_HEADERS]" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtWidgets" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtXml" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtGui" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtXmlPatterns" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtCore" + +# Usefull GCC warnings keys. +GCC_DEBUG_CXXFLAGS += \ + -O0 \ # Turn off oprimization. + $$ISYSTEM \ # Ignore warnings Qt headers. + # Last gdb doesn't show debug symbols with Qt Creator (issue with Python 3 and debug scripts that use Python 2.7). + # Solution to use older version gdb, that's why we use old standard of debug information. + -gdwarf-3 \ + -Wall \ + -Wextra \ + -pedantic \ + -Weffc++ \ + -Woverloaded-virtual \ + -Wctor-dtor-privacy \ + -Wnon-virtual-dtor \ + -Wold-style-cast \ + -Wconversion \ + -Winit-self \ + -Wstack-protector \ + -Wunreachable-code \ + -Wcast-align \ + -Wcast-qual \ + -Wdisabled-optimization \ + -Wfloat-equal \ + -Wformat=2 \ + -Wimport \ + -Wmissing-include-dirs \ + -Wpacked \ + -Wredundant-decls \ + -Winline \ + -Winvalid-pch \ + -Wunsafe-loop-optimizations \ + -Wlong-long \ + -Wmissing-format-attribute \ + -Wswitch-default \ + -Wuninitialized \ + -Wvariadic-macros \ + -Wlogical-op \ + -Wnoexcept \ + -Wmissing-noreturn \ + -Wpointer-arith \ + -Wstrict-null-sentinel \ + -Wstrict-overflow=5 \ + -Wundef \ + -Wno-unused \ + -ftrapv \ + -fsanitize=address #gcc’s 4.8.0 Address Sanitizer + +# Usefull Clang warnings keys. +CLANG_DEBUG_CXXFLAGS += \ + -O0 \ # Turn off oprimization. + $$ISYSTEM \ # Ignore warnings in Qt headers. + # Last gdb doesn't show debug symbols with Qt Creator (issue with Python 3 and debug scripts that use Python 2.7). + # Solution to use older version gdb, that's why we use old standard of debug information. + -gdwarf-3 \ + -fparse-all-comments \ + -Wabi \ + -Wabstract-final-class \ + -Wabstract-vbase-init \ + -Waddress \ + -Waddress-of-array-temporary \ + -Waddress-of-temporary \ + -Waggregate-return \ + -Wall \ + -Wambiguous-macro \ + -Wambiguous-member-template \ + -Wanalyzer-incompatible-plugin \ + -Wanonymous-pack-parens \ + -Warc \ + -Warc-abi \ + -Warc-bridge-casts-disallowed-in-nonarc \ + -Warc-maybe-repeated-use-of-weak \ + -Warc-non-pod-memaccess \ + -Warc-performSelector-leaks \ + -Warc-repeated-use-of-weak \ + -Warc-retain-cycles \ + -Warc-unsafe-retained-assign \ + -Warray-bounds \ + -Warray-bounds-pointer-arithmetic \ + -Wasm \ + -Wasm-operand-widths \ + -Wassign-enum \ + -Watomic-properties \ + -Watomic-property-with-user-defined-accessor \ + -Wattributes \ + -Wauto-import \ + -Wauto-storage-class \ + -Wauto-var-id \ + -Wavailability \ + -Wbackslash-newline-escape \ + -Wbad-array-new-length \ + -Wbad-function-cast \ + -Wbind-to-temporary-copy \ + -Wbitfield-constant-conversion \ + -Wbitwise-op-parentheses \ + -Wbool-conversion \ + -Wbool-conversions \ + -Wbuiltin-macro-redefined \ + -Wbuiltin-requires-header \ + -Wc++-compat \ + -Wc++0x-compat \ + -Wc++0x-extensions \ + -Wc++0x-narrowing \ + -Wc++11-compat \ + -Wc++11-compat-pedantic \ + -Wc++11-compat-reserved-user-defined-literal \ + -Wc++11-extensions \ + -Wc++11-extra-semi \ + -Wc++11-long-long \ + -Wc++11-narrowing \ + -Wc11-extensions \ + -Wcast-align \ + -Wcast-of-sel-type \ + -Wcast-qual \ + -WCFString-literal \ + -Wchar-align \ + -Wchar-subscripts \ + -Wcomment \ + -Wcomments \ + -Wcompare-distinct-pointer-types \ + -Wcomplex-component-init \ + -Wconditional-type-mismatch \ + -Wconditional-uninitialized \ + -Wconfig-macros \ + -Wconstant-conversion \ + -Wconstant-logical-operand \ + -Wconstexpr-not-const \ + -Wconversion \ + -Wconversion-null \ + -Wno-covered-switch-default \ + -Wctor-dtor-privacy \ + -Wcustom-atomic-properties \ + -Wdangling-else \ + -Wdangling-field \ + -Wdangling-initializer-list \ + -Wdeclaration-after-statement \ + -Wdelegating-ctor-cycles \ + -Wdelete-incomplete \ + -Wdelete-non-virtual-dtor \ + -Wdeprecated \ + -Wdeprecated-declarations \ + -Wdeprecated-implementations \ + -Wdeprecated-objc-isa-usage \ + -Wdeprecated-objc-pointer-introspection \ + -Wdeprecated-objc-pointer-introspection-performSelector \ + -Wdeprecated-register \ + -Wdeprecated-writable-strings \ + -Wdirect-ivar-access \ + -Wdisabled-macro-expansion \ + -Wdisabled-optimization \ + -Wdiscard-qual \ + -Wdistributed-object-modifiers \ + -Wdiv-by-zero \ + -Wdivision-by-zero \ + -Wdocumentation \ + -Wdocumentation-deprecated-sync \ + -Wdocumentation-html \ + -Wdollar-in-identifier-extension \ + -Wduplicate-decl-specifier \ + -Wduplicate-enum \ + -Wduplicate-method-arg \ + -Wduplicate-method-match \ + -Wdynamic-class-memaccess \ + -Weffc++ \ + -Wembedded-directive \ + -Wempty-body \ + -Wempty-translation-unit \ + -Wendif-labels \ + -Wenum-compare \ + -Wenum-conversion \ + -Wexplicit-ownership-type \ + -Wextended-offsetof \ + -Wextern-initializer \ + -Wextra \ + -Wextra-semi \ + -Wextra-tokens \ + -Wflexible-array-extensions \ + -Wfloat-equal \ + -Wformat \ + -Wformat-extra-args \ + -Wformat-invalid-specifier \ + -Wformat-non-iso \ + -Wformat-nonliteral \ + -Wformat-security \ + -Wformat-y2k \ + -Wformat-zero-length \ + -Wformat=2 \ + -Wfour-char-constants \ + -Wgcc-compat \ + -Wgnu \ + -Wgnu-array-member-paren-init \ + -Wgnu-designator \ + -Wgnu-static-float-init \ + -Wheader-guard \ + -Wheader-hygiene \ + -Widiomatic-parentheses \ + -Wignored-attributes \ + -Wignored-qualifiers \ + -Wimplicit \ + -Wimplicit-atomic-properties \ + -Wimplicit-conversion-floating-point-to-bool \ + -Wimplicit-exception-spec-mismatch \ + -Wimplicit-fallthrough \ + -Wimplicit-fallthrough-per-function \ + -Wimplicit-function-declaration \ + -Wimplicit-int \ + -Wimplicit-retain-self \ + -Wimport \ + -Wimport-preprocessor-directive-pedantic \ + -Wincompatible-library-redeclaration \ + -Wincompatible-pointer-types \ + -Wincompatible-pointer-types-discards-qualifiers \ + -Wincomplete-implementation \ + -Wincomplete-module \ + -Wincomplete-umbrella \ + -Winherited-variadic-ctor \ + -Winit-self \ + -Winitializer-overrides \ + -Winline \ + -Wint-conversion \ + -Wint-conversions \ + -Wint-to-pointer-cast \ + -Wint-to-void-pointer-cast \ + -Winteger-overflow \ + -Winvalid-constexpr \ + -Winvalid-iboutlet \ + -Winvalid-noreturn \ + -Winvalid-offsetof \ + -Winvalid-pch \ + -Winvalid-pp-token \ + -Winvalid-source-encoding \ + -Winvalid-token-paste \ + -Wknr-promoted-parameter \ + -Wlanguage-extension-token \ + -Wlarge-by-value-copy \ + -Wliteral-conversion \ + -Wliteral-range \ + -Wlocal-type-template-args \ + -Wlogical-not-parentheses \ + -Wlogical-op-parentheses \ + -Wlong-long \ + -Wloop-analysis \ + -Wmain \ + -Wmain-return-type \ + -Wmalformed-warning-check \ + -Wmethod-signatures \ + -Wmicrosoft \ + -Wmicrosoft-exists \ + -Wmismatched-parameter-types \ + -Wmismatched-return-types \ + -Wmismatched-tags \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-field-initializers \ + -Wmissing-format-attribute \ + -Wmissing-include-dirs \ + -Wmissing-method-return-type \ + -Wmissing-noreturn \ + -Wmissing-prototypes \ + -Wmissing-selector-name \ + -Wmissing-sysroot \ + -Wmissing-variable-declarations \ + -Wmodule-conflict \ + -Wmost \ + -Wmultichar \ + -Wnarrowing \ + -Wnested-externs \ + -Wnewline-eof \ + -Wnon-gcc \ + -Wnon-literal-null-conversion \ + -Wnon-pod-varargs \ + -Wnon-virtual-dtor \ + -Wnonnull \ + -Wnonportable-cfstrings \ + -WNSObject-attribute \ + -Wnull-arithmetic \ + -Wnull-character \ + -Wnull-conversion \ + -Wnull-dereference \ + -Wodr \ + -Wold-style-cast \ + -Wold-style-definition \ + -Wout-of-line-declaration \ + -Wover-aligned \ + -Woverflow \ + -Woverlength-strings \ + -Woverloaded-shift-op-parentheses \ + -Woverloaded-virtual \ + -Woverriding-method-mismatch \ + -Wpacked \ + -Wparentheses \ + -Wparentheses-equality \ + -Wpedantic \ + -Wpointer-arith \ + -Wpointer-sign \ + -Wpointer-to-int-cast \ + -Wpointer-type-mismatch \ + -Wpredefined-identifier-outside-function \ + -Wprivate-extern \ + -Wprotocol \ + -Wprotocol-property-synthesis-ambiguity \ + -Wreadonly-iboutlet-property \ + -Wreceiver-expr \ + -Wreceiver-forward-class \ + -Wreceiver-is-weak \ + -Wredundant-decls \ + -Wreinterpret-base-class \ + -Wreorder \ + -Wrequires-super-attribute \ + -Wreserved-user-defined-literal \ + -Wreturn-stack-address \ + -Wreturn-type \ + -Wreturn-type-c-linkage \ + -Wsection \ + -Wselector \ + -Wselector-type-mismatch \ + -Wself-assign \ + -Wself-assign-field \ + -Wsemicolon-before-method-body \ + -Wsentinel \ + -Wsequence-point \ + -Wserialized-diagnostics \ + -Wshadow-ivar \ + -Wshift-count-negative \ + -Wshift-count-overflow \ + -Wshift-op-parentheses \ + -Wshift-overflow \ + -Wshift-sign-overflow \ + -Wshorten-64-to-32 \ + -Wsign-compare \ + -Wsign-conversion \ + -Wsign-promo \ + -Wsizeof-array-argument \ + -Wsizeof-array-decay \ + -Wsizeof-pointer-memaccess \ + -Wsometimes-uninitialized \ + -Wsource-uses-openmp \ + -Wstack-protector \ + -Wstatic-float-init \ + -Wstatic-in-inline \ + -Wstatic-local-in-inline \ + -Wstatic-self-init \ + -Wstrict-aliasing \ + -Wstrict-aliasing=0 \ + -Wstrict-aliasing=1 \ + -Wstrict-aliasing=2 \ + -Wstrict-overflow \ + -Wstrict-overflow=0 \ + -Wstrict-overflow=1 \ + -Wstrict-overflow=2 \ + -Wstrict-overflow=3 \ + -Wstrict-overflow=4 \ + -Wstrict-overflow=5 \ + -Wstrict-prototypes \ + -Wstrict-selector-match \ + -Wstring-compare \ + -Wstring-conversion \ + -Wstring-plus-int \ + -Wstrlcpy-strlcat-size \ + -Wstrncat-size \ + -Wsuper-class-method-mismatch \ + -Wswitch \ + -Wswitch-default \ + -Wsynth \ + -Wtautological-compare \ + -Wtautological-constant-out-of-range-compare \ + -Wtentative-definition-incomplete-type \ + -Wthread-safety \ + -Wthread-safety-analysis \ + -Wthread-safety-attributes \ + -Wthread-safety-beta \ + -Wthread-safety-precise \ + -Wtrigraphs \ + -Wtype-limits \ + -Wtype-safety \ + -Wtypedef-redefinition \ + -Wtypename-missing \ + -Wundeclared-selector \ + -Wundef \ + -Wundefined-inline \ + -Wundefined-internal \ + -Wundefined-reinterpret-cast \ + -Wunicode \ + -Wunicode-whitespace \ + -Wuninitialized \ + -Wunknown-warning-option \ + -Wunnamed-type-template-args \ + -Wunneeded-internal-declaration \ + -Wunneeded-member-function \ + -Wunsequenced \ + -Wunsupported-visibility \ + -Wunused \ + -Wunused-argument \ + -Wunused-command-line-argument \ + -Wunused-comparison \ + -Wunused-exception-parameter \ + -Wunused-function \ + -Wunused-label \ + -Wunused-member-function \ + -Wunused-parameter \ + -Wunused-private-field \ + -Wunused-result \ + -Wunused-sanitize-argument \ + -Wunused-value \ + -Wunused-variable \ + -Wunused-volatile-lvalue \ + -Wuser-defined-literals \ + -Wvarargs \ + -Wvariadic-macros \ + -Wvector-conversion \ + -Wvector-conversions \ + -Wvexing-parse \ + -Wvisibility \ + -Wvla \ + -Wvla-extension \ + -Wvolatile-register-var \ + -Wweak-template-vtables \ + -Wweak-vtables \ + -Wwrite-strings \ + -Wzero-length-array \ + -Qunused-arguments \ + -fcolor-diagnostics +} else { +# Don't use additional GCC and Clang keys on Windows system. +# Can't find way mark ignore Qt header on Windows. +GCC_DEBUG_CXXFLAGS += \ + -O0 \ + -Wall \ + -Wextra \ + -pedantic \ + -fno-omit-frame-pointer # Need for exchndl.dll + +CLANG_DEBUG_CXXFLAGS += \ + -O0 \ + -Wall \ + -Wextra \ + -pedantic \ + -fno-omit-frame-pointer # Need for exchndl.dll +} diff --git a/Valentina.pro b/Valentina.pro index 9a86f63ea..900c5dd70 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -1,133 +1,10 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-06-18T12:36:43 -# -#------------------------------------------------- +include(Valentina.pri) -# Use out-of-source builds (shadow builds) - -QT += core gui widgets xml svg - -TEMPLATE = app - -TARGET = valentina - -CONFIG -= debug_and_release debug_and_release_target -CONFIG += c++11 - -#DEFINES += ... - -# directory for executable file -DESTDIR = bin - -# files created moc -MOC_DIR = moc - -# objecs files -OBJECTS_DIR = obj - -# files created rcc -RCC_DIR = rcc - -# files created uic -UI_DIR = uic - -include(src/src.pri) -include(src/container/container.pri) -include(src/dialogs/dialogs.pri) -include(src/exception/exception.pri) -include(src/geometry/geometry.pri) -include(src/tools/tools.pri) -include(src/widgets/widgets.pri) -include(src/xml/xml.pri) - -RESOURCES += \ - share/resources/icon.qrc \ - share/resources/cursor.qrc - -OTHER_FILES += share/resources/valentina.rc \ - share/resources/icon/64x64/icon64x64.ico - -TRANSLATIONS += share/translations/valentina_ru.ts \ - share/translations/valentina_uk.ts - -unix:QMAKE_CXX = ccache g++ - -CONFIG += precompile_header -# Precompiled headers (PCH) -PRECOMPILED_HEADER = src/stable.h -win32-msvc* { - PRECOMPILED_SOURCE = src/stable.cpp +#Check if Qt version >= 5.2.0 +!minQtVersion(5, 2, 0) { + message("Cannot build Valentina with Qt version $${QT_VERSION}.") + error("Use at least Qt 5.2.0.") } -CONFIG(debug, debug|release){ - # Debug - *-g++{ - QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtWidgets" \ - -isystem "/usr/include/qt5/QtXml" -isystem "/usr/include/qt5/QtGui" \ - -isystem "/usr/include/qt5/QtCore" -isystem "$${UI_DIR}" -isystem "$${MOC_DIR}" \ - -isystem "$${RCC_DIR}" \ - -Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \ - -Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \ - -Wunreachable-code -Wcast-align -Wcast-qual -Wdisabled-optimization -Wfloat-equal \ - -Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k \ - -Winvalid-pch -Wunsafe-loop-optimizations -Wlong-long -Wmissing-format-attribute \ - -Wmissing-include-dirs -Wpacked -Wredundant-decls \ - -Wswitch-default -Wswitch-enum -Wuninitialized -Wunused-parameter -Wvariadic-macros \ - -Wlogical-op -Wnoexcept \ - -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -gdwarf-3 - } -}else{ - # Release - *-g++{ - QMAKE_CXXFLAGS += -O1 - } - - DEFINES += QT_NO_DEBUG_OUTPUT -} - -message(Qt version: $$[QT_VERSION]) -message(Qt is installed in $$[QT_INSTALL_PREFIX]) -message(Qt resources can be found in the following locations:) -message(Documentation: $$[QT_INSTALL_DOCS]) -message(Header files: $$[QT_INSTALL_HEADERS]) -message(Libraries: $$[QT_INSTALL_LIBS]) -message(Binary files (executables): $$[QT_INSTALL_BINS]) -message(Plugins: $$[QT_INSTALL_PLUGINS]) -message(Data files: $$[QT_INSTALL_DATA]) -message(Translation files: $$[QT_INSTALL_TRANSLATIONS]) -message(Settings: $$[QT_INSTALL_SETTINGS]) -message(Examples: $$[QT_INSTALL_EXAMPLES]) - -win32:RC_FILE = share/resources/valentina.rc - -# Remove generated files at cleaning -QMAKE_DISTCLEAN += $${DESTDIR}/* \ - $${OBJECTS_DIR}/* \ - $${UI_DIR}/* \ - $${MOC_DIR}/* \ - $${RCC_DIR}/* - -unix { -#VARIABLES -isEmpty(PREFIX) { - PREFIX = /usr -} -BINDIR = $$PREFIX/bin -DATADIR =$$PREFIX/share -DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\" -#MAKE INSTALL -target.path = $$BINDIR -desktop.path = $$DATADIR/applications/ -desktop.files += dist/$${TARGET}.desktop -pixmaps.path = $$DATADIR/pixmaps/ -pixmaps.files += dist/$${TARGET}.png -INSTALL_TRANSLATIONS += share/translations/valentina_ru.qm \ - share/translations/valentina_uk.qm -translations.path = $$DATADIR/$${TARGET}/translations/ -translations.files = $$INSTALL_TRANSLATIONS -INSTALLS += target \ - desktop \ - pixmaps \ - translations -} +TEMPLATE = subdirs +SUBDIRS = src diff --git a/dist/Launchpad_README b/dist/Launchpad_README new file mode 100644 index 000000000..47dafa6cb --- /dev/null +++ b/dist/Launchpad_README @@ -0,0 +1,97 @@ +README (English) +################################################## +Launchpad Package tools +################################################## + +This file contains explanation how to publish +a package onto LaunchPad. +Some string useful for local testing creation recipe. +Here used technique when you have separate debian directory +and merge it with source using recipe file. + + +# This is standard command to work on DEB packaging: +# +# To install all packagers tools: +# sudo apt-get install bzr-builder bzr dpatch pbuilder debootstrap devscripts debhelper build-essential + +# Init local working env +- Create account on launchpad.org +- Create Project +- Import branch from git mirror +- Create new recipe +- Upload SSH public key onto account +- Upload you GPG sign key +- Run from command line: + bzr launchpad-login yourlogin + bzr whoami "Your Name " +- Create a file /.pbuilderrc with content (need for local testing creation recipe) + ## Overrides /etc/pbuilderrc + + # Default distribution + # Uncomment if you want different distribution system than you use now. + #DISTRIBUTION=saucy + COMPONENTS="main restricted universe multiverse" + + # Repositories + MIRRORSITE=http://archive.ubuntu.com/ubuntu + OTHERMIRROR="deb ${MIRRORSITE} ${DISTRIBUTION} ${COMPONENTS} | deb ${MIRRORSITE} ${DISTRIBUTION}-backports ${COMPONENTS} | deb ${MIRRORSITE} ${DISTRIBUTION}-security ${COMPONENTS} | deb ${MIRRORSITE} ${DISTRIBUTION}-updates ${COMPONENTS} | deb http://ppa.launchpad.net/ubuntu-sdk-team/ppa/ubuntu ${DISTRIBUTION} main" + # Last PPA is example how to add additional PPA to your local build system. Useful when you want use packages that don't exist in standard repository. + + # For build results (in this directory you will find deb packages. Don't forget this path!) + BUILDRESULT=${HOME}/pbuilder/result + + # Mount directories inside chroot environment + BINDMOUNTS=${BUILDRESULT} +- Make our pbuilder trust packages from our PPA +For example you added PPA ubuntu-sdk-team, now you need add public key for using this PPA. +First, we'll login to our pbuilder environment: + sudo pbuilder --login --save-after-login +Then, we'll give it the public key to our PPA, just like if we were adding it to our own keyring: + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys [YOUR PUBLIC KEY HERE] +If all goes well, you can leave your pbuilder environment by typing: + exit +- Tell the pbuilder environment that it is going to act just like the Launchpad build farm +Still in our terminal: + sudo pbuilder create --debootstrapopts --variant=buildd +- Update our environment with these new packages +Still in our terminal, type: + sudo pbuilder --update --override-config +- Edit file ~/.bashrc ti add +DEBFULLNAME="" +DEBEMAIL="" + +# Init package tools for launchpad +- Create a Bazaar directory + mkdir bzr +- Create debian directory and upload it onto bzr branch ~dismine/valentina/debian + cd bzr + mkdir debian + cd debian + bzr init + cp -pr valentina/debian bzr/debian + bzr add debian + bzr commit -m "Init" + bzr push lp:~dismine/valentina/debian + or download it from launchpad bazaar: + cd bzr + bzr branch lp:~dismine/valentina/debian +- To update this debian directory, edit files into the bzr dir and run + bzr commit -m "Description of change" + bzr push lp:~dismine/valentina/debian +- Create a file valentina.recipe with content + cd bzr + vi valentina.recipe + # bzr-builder format 0.3 deb-version {debupstream}+{revno}+{revno:packaging} + lp:valentina + merge packaging lp:~dismine/valentina/debian + + Next command usefull for local testing creation recipe. +- Run command + cd bzr + bzr dailydeb --allow-fallback-to-native valentina.recipe working-dir + This will create a directory "working-dir" with valentina sources and will add sources from ~dismine/valentina/debian +- Test package sources + sudo pbuilder build /_.dsc + Example: sudo pbuilder build working-dir/valentina_0.2.2.dsc + diff --git a/dist/Valentina.icns b/dist/Valentina.icns new file mode 100644 index 000000000..a803cf80b Binary files /dev/null and b/dist/Valentina.icns differ diff --git a/dist/application-x-valentina-pattern.png b/dist/application-x-valentina-pattern.png new file mode 100644 index 000000000..f695df140 Binary files /dev/null and b/dist/application-x-valentina-pattern.png differ diff --git a/dist/debian/changelog b/dist/debian/changelog index 06d0d7f98..c5c709e33 100644 --- a/dist/debian/changelog +++ b/dist/debian/changelog @@ -1,5 +1,5 @@ -valentina (0.2.2) saucy; urgency=low +valentina (0.2.8-alpha) trusty; urgency=low - * Add new dependions qttools5-dev-tools + * Auto build. - -- Roman Telezhinsky Tue, 26 Nov 2013 21:28:15 +0200 + -- dismine Fri, 27 Jun 2014 09:51:38 +0300 diff --git a/dist/debian/compat b/dist/debian/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/dist/debian/compat @@ -0,0 +1 @@ +9 diff --git a/dist/debian/control b/dist/debian/control index 3ca5aada7..ece4384bc 100644 --- a/dist/debian/control +++ b/dist/debian/control @@ -1,14 +1,26 @@ Source: valentina Section: graphics Priority: optional -Maintainer: Roman Telezhinsky -Build-Depends: debhelper (>= 8.0.0), qtbase5-dev (>= 5.0.0), libqt5svg5-dev (>= 5.0.0), ccache, g++ (>= 4.6.0), qt5-default (>= 5.0.0), qttools5-dev-tools (>= 5.0.0) -Standards-Version: 3.9.4 -Homepage: https://bitbucket.org/dismine/valentina +Maintainer: Roman Telezhynskyi +Build-Depends: debhelper (>= 8.0.0), + qtbase5-dev (>= 5.2.1), + libqt5svg5-dev (>= 5.2.1), + ccache, + g++ (>= 4.6.0), + qt5-default (>= 5.2.1), + qttools5-dev-tools (>= 5.2.1), + libqt5xmlpatterns5-dev (>= 5.2.1) +Standards-Version: 3.9.5 +Homepage: http://www.valentina-project.org/ +Vcs-Browser: https://bitbucket.org/dismine/valentina Package: valentina Architecture: i386 amd64 -Depends: ${shlibs:Depends}, ${misc:Depends} +Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libstdc++6 (>= 4.6), xpdf Description: Pattern making program. - Open source project of creating a pattern making program, whose allow - create and modeling patterns of clothing. + Valentina is a cross-platform patternmaking program which allows designers + to create and model patterns of clothing. This software allows pattern + creation, using either standard sizing tables or an individual’s set of + measurements. It blends new technologies with traditional methods to create + a unique pattern making tool. + Supported langugages: En, Ru, Uk, Cz, It, Fr, De, Nl diff --git a/dist/debian/copyright b/dist/debian/copyright index 3a6e44e72..0a67fc1ae 100644 --- a/dist/debian/copyright +++ b/dist/debian/copyright @@ -3,13 +3,21 @@ Upstream-Name: valentina Source: https://bitbucket.org/dismine/valentina Files: * -Copyright: 2013 Roman Telezhinsky +Copyright: 2013-2014 Roman Telezhynskyi License: GPL-3.0+ Files: debian/* -Copyright: 2013 Roman Telezhinsky +Copyright: 2013-2014 Roman Telezhynskyi License: GPL-3.0+ +Files: usr/lib/libqmuparser.so.* +Copyright: 2004-2014 Ingo Berg , 2014 Roman Telezhynskyi +License: MIT + +Files: usr/lib/libvpropertyexplorer.so.* +Copyright: hedgeware , 2014 Roman Telezhynskyi +License: LGPL-2.1 + License: GPL-3.0+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,3 +34,34 @@ License: GPL-3.0+ . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +License: LGPL-2.1 + All rights reserved. This program and the accompanying materials + are made available under the terms of the GNU Lesser General Public License + (LGPL) version 2.1 which accompanies this distribution, and is available at + http://www.gnu.org/licenses/lgpl-2.1.html + . + This library 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 + Lesser General Public License for more details. + diff --git a/dist/debian/docs b/dist/debian/docs index 724e08449..71dfd5bac 100644 --- a/dist/debian/docs +++ b/dist/debian/docs @@ -1,2 +1 @@ -README -TODO +README.txt diff --git a/dist/debian/files b/dist/debian/files new file mode 100644 index 000000000..80ab1d10f --- /dev/null +++ b/dist/debian/files @@ -0,0 +1 @@ +valentina_0.2.8+441+21+201406270651_i386.deb graphics optional diff --git a/dist/debian/rules b/dist/debian/rules index e9c14f409..67a7f677f 100755 --- a/dist/debian/rules +++ b/dist/debian/rules @@ -1,50 +1,67 @@ #!/usr/bin/make -f - APPNAME := valentina + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + APPNAME := Valentina + + DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) + ifeq ($(DEB_HOST_ARCH),amd64) + LIBPATH:= /debian/tmp/usr/lib/x86_64-linux-gnu + PREFIX_LIB:= /usr/lib/x86_64-linux-gnu + else + LIBPATH:= /debian/tmp/usr/lib/i386-linux-gnu + PREFIX_LIB:= /usr/lib/i386-linux-gnu + endif + builddir: - mkdir -p builddir + mkdir -p builddir builddir/Makefile: builddir - lrelease src/src.pro - cd builddir && qmake PREFIX=/usr ../$(APPNAME).pro -r + cd builddir && qmake PREFIX=/usr PREFIX_LIB=$(PREFIX_LIB) ../$(APPNAME).pro -r build: build-stamp build-stamp: builddir/Makefile - dh_testdir - # Add here commands to compile the package. - cd builddir && $(MAKE) - touch $@ + dh_testdir + # Add here commands to compile the package. + cd builddir && $(MAKE) + touch $@ clean: - dh_testdir - dh_testroot - rm -f build-stamp - # Add here commands to clean up after the build process. - rm -rf builddir - dh_clean + dh_testdir + dh_testroot + rm -f build-stamp + # Add here commands to clean up after the build process. + rm -rf builddir + dh_clean install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - # Add here commands to install the package into debian/your_appname - cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/tmp install + dh_testdir + dh_testroot + dh_prep + dh_installdirs + # Add here commands to install the package into debian/valentina + cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/tmp install # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install - dh_testdir - dh_testroot - dh_installdocs - dh_installchangelogs - dh_installexamples - dh_installman + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs dh_installmenu - dh_link - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb + dh_installmime + dh_install --sourcedir=$(CURDIR) -v + dh_installman + dh_installinfo + dh_link + dh_compress + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps -Llibqmuparser2 -l$(CURDIR)$(LIBPATH) -Llibvpropertyexplorer -l$(CURDIR)$(LIBPATH) + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure diff --git a/dist/debian/shlibs.local b/dist/debian/shlibs.local new file mode 100644 index 000000000..500b1cca8 --- /dev/null +++ b/dist/debian/shlibs.local @@ -0,0 +1,2 @@ +libqmuparser 2 libqmuparser2 +libvpropertyexplorer 1 libvpropertyexplorer diff --git a/dist/debian/source/format b/dist/debian/source/format index 163aaf8d8..89ae9db8f 100644 --- a/dist/debian/source/format +++ b/dist/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/dist/debian/source/include-binaries b/dist/debian/source/include-binaries index bb85f001a..90748a950 100644 --- a/dist/debian/source/include-binaries +++ b/dist/debian/source/include-binaries @@ -1,4 +1,10 @@ debian/usr/share/pixmaps/valentina.png debian/valentina/usr/bin/valentina -debian/valentina/usr/share/valentina/translations/valentina_ru.qm -debian/valentina/usr/share/valentina/translations/valentina_uk.qm +debian/valentina/usr/share/valentina/translations/valentina_ru_RU.qm +debian/valentina/usr/share/valentina/translations/valentina_uk_UA.qm +debian/valentina/usr/share/valentina/translations/valentina_de_DE.qm +debian/valentina/usr/share/valentina/translations/valentina_cs_CZ.qm +debian/valentina/usr/share/valentina/translations/valentina_he_IL.qm +debian/valentina/usr/share/valentina/translations/valentina_fr_FR.qm +debian/valentina/usr/share/valentina/translations/valentina_it_IT.qm +debian/valentina/usr/share/valentina/translations/valentina_nl_NL.qm diff --git a/dist/debian/substvars b/dist/debian/substvars new file mode 100644 index 000000000..abd3ebebc --- /dev/null +++ b/dist/debian/substvars @@ -0,0 +1 @@ +misc:Depends= diff --git a/dist/debian/valentina.1 b/dist/debian/valentina.1 index 488473b7f..786723695 100644 --- a/dist/debian/valentina.1 +++ b/dist/debian/valentina.1 @@ -1,13 +1,23 @@ .\" Manpage for valentina. .\" Contact dismine@gmail.com.in to correct errors. -.TH man 1 "25 Nov 2013" "1.0" "valentina man page" +.TH man 1 "29 May 2014" "valentina man page" .SH NAME valentina \- Pattern making program. .SH SYNOPSIS -valentina +valentina [options] file .SH DESCRIPTION -Open source project of creating a pattern making program, whose allow create and modeling patterns of clothing. +Valentina is a cross-platform patternmaking program which allows designers +to create and model patterns of clothing. This software allows pattern +creation, using either standard sizing tables or an individual’s set of +measurements. It blends new technologies with traditional methods to create +a unique pattern making tool. .SH OPTIONS -The valentina does not take any options. +-help Show summary of options. + +-version + Show version of program. + +file + Pattern file to load. .SH AUTHOR -Roman Telezhinsky (dismine@gmail.com) \ No newline at end of file +This manual page was written by Roman Telezhynskyi diff --git a/dist/debian/valentina.dirs b/dist/debian/valentina.dirs new file mode 100644 index 000000000..72ae9ab2e --- /dev/null +++ b/dist/debian/valentina.dirs @@ -0,0 +1,5 @@ +/usr/share/valentina/translations +/usr/share/valentina/tables/standard +/usr/share/mime/packages +/usr/share/applications + diff --git a/dist/debian/valentina.install b/dist/debian/valentina.install new file mode 100644 index 000000000..2964cffec --- /dev/null +++ b/dist/debian/valentina.install @@ -0,0 +1,6 @@ +usr/bin/* +usr/lib/* +usr/share/valentina/translations/* +usr/share/valentina/tables/standard/* +usr/share/pixmaps/* +usr/share/applications/* diff --git a/dist/debian/valentina.mime b/dist/debian/valentina.mime new file mode 100644 index 000000000..33c6a7c7b --- /dev/null +++ b/dist/debian/valentina.mime @@ -0,0 +1 @@ +application/x-valentina-pattern; valentina %s; nametemplate=%s.val; description="Valentina pattern format" edit=valentina '%s'; priority=6 diff --git a/dist/debian/postinst b/dist/debian/valentina.postinst old mode 100644 new mode 100755 similarity index 72% rename from dist/debian/postinst rename to dist/debian/valentina.postinst index a3d3eb81d..5e234d4d8 --- a/dist/debian/postinst +++ b/dist/debian/valentina.postinst @@ -17,23 +17,16 @@ set -e # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package +echo "ldconfig..." >&2 +ldconfig -case "$1" in - configure) - - if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then - update-menus - fi - ;; +if [ -x update-desktop-database ]; then + update-desktop-database +fi - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac +if [ -x update-mime-database ]; then + update-mime-database /usr/share/mime +fi # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. diff --git a/dist/debian/valentina.postrm b/dist/debian/valentina.postrm new file mode 100755 index 000000000..35b04fe38 --- /dev/null +++ b/dist/debian/valentina.postrm @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for valentina +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +echo "ldconfig..." >&2 +ldconfig + +if [ -x update-desktop-database ]; then + update-desktop-database +fi + +if [ -x update-mime-database ]; then + update-mime-database /usr/share/mime +fi + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/dist/debian/valentina.sharedmimeinfo b/dist/debian/valentina.sharedmimeinfo new file mode 100644 index 000000000..55242c69c --- /dev/null +++ b/dist/debian/valentina.sharedmimeinfo @@ -0,0 +1,96 @@ + + + + <_comment>Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina лекала + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + OValentina pattern format + OValentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina викрійки + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + Valentina pattern format + + + + diff --git a/dist/nsis/headers/fileassoc.nsh b/dist/nsis/headers/fileassoc.nsh new file mode 100644 index 000000000..02fc61c45 --- /dev/null +++ b/dist/nsis/headers/fileassoc.nsh @@ -0,0 +1,119 @@ +; fileassoc.nsh +; File association helper macros +; Written by Saivert +; +; Features automatic backup system and UPDATEFILEASSOC macro for +; shell change notification. +; +; |> How to use <| +; To associate a file with an application so you can double-click it in explorer, use +; the APP_ASSOCIATE macro like this: +; +; Example: +; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "Description of txt files" \ +; "$INSTDIR\myapp.exe,0" "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\"" +; +; Never insert the APP_ASSOCIATE macro multiple times, it is only ment +; to associate an application with a single file and using the +; the "open" verb as default. To add more verbs (actions) to a file +; use the APP_ASSOCIATE_ADDVERB macro. +; +; Example: +; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \ +; "$INSTDIR\myapp.exe /edit $\"%1$\"" +; +; To have access to more options when registering the file association use the +; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the +; standard action (default verb). +; +; And finally: To remove the association from the registry use the APP_UNASSOCIATE +; macro. Here is another example just to wrap it up: +; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile" +; +; |> Note <| +; When defining your file class string always use the short form of your application title +; then a period (dot) and the type of file. This keeps the file class sort of unique. +; Examples: +; Winamp.Playlist +; NSIS.Script +; Photoshop.JPEGFile +; +; |> Tech info <| +; The registry key layout for a file association is: +; HKEY_CLASSES_ROOT +; = <"description"> +; shell +; = <"menu-item text"> +; command = <"command string"> +; + +!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND + ; Backup the previously associated file class + ReadRegStr $R0 HKCR ".${EXT}" "" + WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0" + + WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}" + + WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}` + WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}` + WriteRegStr HKCR "${FILECLASS}\shell" "" "open" + WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}` + WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}` +!macroend + +!macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND + ; Backup the previously associated file class + ReadRegStr $R0 HKCR ".${EXT}" "" + WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0" + + WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}" + StrCmp "${SHELLNEW}" "0" +2 + WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" "" + + WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}` + WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}` + WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}` + WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}` + WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}` +!macroend + +!macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND + WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}` + WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}` +!macroend + +!macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB + DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}` +!macroend + + +!macro APP_UNASSOCIATE EXT FILECLASS + ; Backup the previously associated file class + ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup` + WriteRegStr HKCR ".${EXT}" "" "$R0" + + DeleteRegKey HKCR `${FILECLASS}` +!macroend + +!macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT + ReadRegStr ${OUTPUT} HKCR ".${EXT}" "" +!macroend + + +; !defines for use with SHChangeNotify +!ifdef SHCNE_ASSOCCHANGED +!undef SHCNE_ASSOCCHANGED +!endif +!define SHCNE_ASSOCCHANGED 0x08000000 +!ifdef SHCNF_FLUSH +!undef SHCNF_FLUSH +!endif +!define SHCNF_FLUSH 0x1000 + +!macro UPDATEFILEASSOC +; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we +; can update the shell. + System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)" +!macroend + +;EOF diff --git a/dist/nsis/headers/fileversion.nsh b/dist/nsis/headers/fileversion.nsh new file mode 100644 index 000000000..258e0d64d --- /dev/null +++ b/dist/nsis/headers/fileversion.nsh @@ -0,0 +1,30 @@ +; fileversion.nsh +; Source http://nsis.sourceforge.net/GetDLLVersionLocal_as_define +; +; GetDLLVersionLocal only gives you two packed 32bit numbers, but +; sometimes you might need the unpacked numbers at compile time. This is +; where this ugly thing comes in. +; +; Example usage +; !insertmacro GetPEVersionLocal "$%windir%\system32\kernel32.dll" myver +; Outfile "$%temp%\hello ${myver_1}.${myver_2}.${myver_3}.${myver_4}.exe" + +!macro GetPEVersionLocal file defbase +!verbose push +!verbose 2 +!tempfile GetPEVersionLocal_nsi +!tempfile GetPEVersionLocal_exe +!define GetPEVersionLocal_doll "$" +!appendfile "${GetPEVersionLocal_nsi}" 'SilentInstall silent$\nRequestExecutionLevel user$\nOutFile "${GetPEVersionLocal_exe}"$\nPage instfiles$\nSection' +!appendfile "${GetPEVersionLocal_nsi}" '$\nFileOpen $0 "${GetPEVersionLocal_nsi}" w$\nGetDllVersion "${file}" $R0 $R1$\nIntOp $R2 $R0 / 0x00010000$\nIntOp $R3 $R0 & 0x0000FFFF$\nIntOp $R4 $R1 / 0x00010000$\nIntOp $R5 $R1 & 0x0000FFFF' +!appendfile "${GetPEVersionLocal_nsi}" '$\nFileWrite $0 "!define ${defbase}_1 $R2${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_2 $R3${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_3 $R4${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_4 $R5${GetPEVersionLocal_doll}\n"$\nFileClose $0$\nSectionEnd' +!system '"${NSISDIR}\makensis" /V2 "${GetPEVersionLocal_nsi}"' = 0 +!system '"${GetPEVersionLocal_exe}"' = 0 +!include "${GetPEVersionLocal_nsi}" +!delfile "${GetPEVersionLocal_nsi}" +!delfile "${GetPEVersionLocal_exe}" +!undef GetPEVersionLocal_nsi +!undef GetPEVersionLocal_exe +!undef GetPEVersionLocal_doll +!verbose pop +!macroend diff --git a/dist/nsis/valentina.nsi b/dist/nsis/valentina.nsi new file mode 100644 index 000000000..09b811912 --- /dev/null +++ b/dist/nsis/valentina.nsi @@ -0,0 +1,267 @@ +; NSIS installer script for Valentina +; --------------- Headers -------------- +!include "MUI2.nsh" +!include "headers\fileassoc.nsh" +!include "headers\fileversion.nsh" +!include "FileFunc.nsh" + +; --------------- General -------------- +CRCCheck force +XPStyle on +SetCompressor /FINAL /SOLID lzma + +!define MUI_PRODUCT "Valentina" +!define MUI_FILE "valentina" + +!insertmacro GetPEVersionLocal "c:\pack\valentina\valentina.exe" ver +!define MUI_VERSION "${ver_1}.${ver_2}.${ver_3}-alpha" + +!define MUI_BRANDINGTEXT "Valentina ${MUI_VERSION}" +!define WEBSITE_LINK "http://www.valentina-project.org/" +!define PUBLISHER "Roman Telezhynskyi" + +InstallDir "$LOCALAPPDATA\${MUI_PRODUCT}" ; Default installation folder +Name "${MUI_BRANDINGTEXT}" ; Name displayed on installer +Icon "valentina\${MUI_FILE}.ico" +Caption "${MUI_BRANDINGTEXT}" + +!define /date MYTIMESTAMP "%Y%m%d%H%M%S" +OutFile "${MUI_FILE}_${MUI_VERSION}-${MYTIMESTAMP}_i386.exe" ; Resulting installer filename + +InstallDirRegKey HKCU "$LOCALAPPDATA\${MUI_PRODUCT}" "" ; Get installation folder from registry if available +LicenseData "valentina\LICENSE_GPL.txt" +RequestExecutionLevel user ; Request application privileges for Windows Vista + +ShowInstDetails show +ShowUninstDetails show + +; ----------- Icon and Bitmap --------- +!define MUI_ICON "valentina\${MUI_FILE}.ico" +!define MUI_UNICON "valentina\${MUI_FILE}.ico" +;!define MUI_SPECIALBITMAP "Bitmap.bmp" + +; ------------------------------------- +!define MUI_ABORTWARNING + +;------------- Language Selection Dialog Settings -------------- +;Remember the installer language +!define MUI_LANGDLL_REGISTRY_ROOT "HKCU" +!define MUI_LANGDLL_REGISTRY_KEY "Software\${MUI_PRODUCT}" +!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" +!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" +!define REGISTRY_ROOT "HKCU" + +;-------------- Install Pages ------------- + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "valentina\LICENSE_GPL.txt" +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + ; These indented statements modify settings for MUI_PAGE_FINISH + !define MUI_FINISHPAGE_NOAUTOCLOSE + !define MUI_FINISHPAGE_RUN "$INSTDIR\${MUI_FILE}.exe" + !define MUI_FINISHPAGE_RUN_CHECKED + !define MUI_FINISHPAGE_RUN_TEXT "Launch ${MUI_PRODUCT}" + !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED + !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt" +!insertmacro MUI_PAGE_FINISH + +;-------------- Uninstall Pages ------------- +!insertmacro MUI_UNPAGE_WELCOME +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + ; These indented statements modify settings for MUI_UNPAGE_FINISH + !define MUI_UNFINISHPAGE_NOAUTOCLOSE +!insertmacro MUI_UNPAGE_FINISH + +;--------------- Languages --------------- +!define MUI_LANGDLL_ALLLANGUAGES +!insertmacro MUI_LANGUAGE "English" ;first language is the default language +!insertmacro MUI_LANGUAGE "German" +!insertmacro MUI_LANGUAGE "French" +!insertmacro MUI_LANGUAGE "Russian" +!insertmacro MUI_LANGUAGE "Ukrainian" +!insertmacro MUI_LANGUAGE "Czech" +!insertmacro MUI_LANGUAGE "Hebrew" +!insertmacro MUI_LANGUAGE "Italian" +!insertmacro MUI_LANGUAGE "Dutch" +!insertmacro MUI_LANGUAGE "Spanish" +!insertmacro MUI_LANGUAGE "SpanishInternational" +!insertmacro MUI_LANGUAGE "SimpChinese" +!insertmacro MUI_LANGUAGE "TradChinese" +!insertmacro MUI_LANGUAGE "Japanese" +!insertmacro MUI_LANGUAGE "Korean" +!insertmacro MUI_LANGUAGE "Danish" +!insertmacro MUI_LANGUAGE "Swedish" +!insertmacro MUI_LANGUAGE "Norwegian" +!insertmacro MUI_LANGUAGE "NorwegianNynorsk" +!insertmacro MUI_LANGUAGE "Finnish" +!insertmacro MUI_LANGUAGE "Greek" +!insertmacro MUI_LANGUAGE "Portuguese" +!insertmacro MUI_LANGUAGE "PortugueseBR" +!insertmacro MUI_LANGUAGE "Polish" +!insertmacro MUI_LANGUAGE "Slovak" +!insertmacro MUI_LANGUAGE "Croatian" +!insertmacro MUI_LANGUAGE "Bulgarian" +!insertmacro MUI_LANGUAGE "Hungarian" +!insertmacro MUI_LANGUAGE "Thai" +!insertmacro MUI_LANGUAGE "Romanian" +!insertmacro MUI_LANGUAGE "Latvian" +!insertmacro MUI_LANGUAGE "Macedonian" +!insertmacro MUI_LANGUAGE "Estonian" +!insertmacro MUI_LANGUAGE "Turkish" +!insertmacro MUI_LANGUAGE "Lithuanian" +!insertmacro MUI_LANGUAGE "Slovenian" +!insertmacro MUI_LANGUAGE "Serbian" +!insertmacro MUI_LANGUAGE "SerbianLatin" +!insertmacro MUI_LANGUAGE "Arabic" +!insertmacro MUI_LANGUAGE "Farsi" +!insertmacro MUI_LANGUAGE "Indonesian" +!insertmacro MUI_LANGUAGE "Mongolian" +!insertmacro MUI_LANGUAGE "Luxembourgish" +!insertmacro MUI_LANGUAGE "Albanian" +!insertmacro MUI_LANGUAGE "Breton" +!insertmacro MUI_LANGUAGE "Belarusian" +!insertmacro MUI_LANGUAGE "Icelandic" +!insertmacro MUI_LANGUAGE "Malay" +!insertmacro MUI_LANGUAGE "Bosnian" +!insertmacro MUI_LANGUAGE "Kurdish" +!insertmacro MUI_LANGUAGE "Irish" +!insertmacro MUI_LANGUAGE "Uzbek" +!insertmacro MUI_LANGUAGE "Galician" +!insertmacro MUI_LANGUAGE "Afrikaans" +!insertmacro MUI_LANGUAGE "Catalan" +!insertmacro MUI_LANGUAGE "Esperanto" + +; ------------- Reserve Files --------------------- +;If you are using solid compression, files that are required before +;the actual installation should be stored first in the data block, +;because this will make your installer start faster. +!insertmacro MUI_RESERVEFILE_LANGDLL + +; ------------- Installer Functions --------------- +Function checkAlreadyInstalled + ; check for already installed instance + ClearErrors + ReadRegStr $R0 "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "UninstallString" + StrCmp $R0 "" done + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "${MUI_PRODUCT} is already installed. $\n$\nClick `OK` to remove the \ + previous version or `Cancel` to cancel this upgrade." \ + IDOK UnInstall + Abort + ;Run the uninstaller + UnInstall: + ClearErrors + ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file + + ;uninstall.exe is still here + ;Delete Files + RMDir /r "$INSTDIR\*.*" + ;Remove the installation directory + RMDir "$INSTDIR" + + IfErrors no_remove_uninstaller done + ;You can either use Delete /REBOOTOK in the uninstaller or add some code + ;here to remove the uninstaller. Use a registry key to check + ;whether the user has chosen to uninstall. If you are using an uninstaller + ;components page, make sure all sections are uninstalled. + no_remove_uninstaller: + MessageBox MB_OK|MB_ICONSTOP "Error while uninstalling \ + previously installed version. Please uninstall it manually \ + and start the installer again." + Quit + done: +FunctionEnd + +Function .onInit + !insertmacro MUI_LANGDLL_DISPLAY ;This has to come after the language macros + Call checkAlreadyInstalled +FunctionEnd + +;-------------- Uninstaller Functions ------------- +Function un.onInit + !insertmacro MUI_UNGETLANGUAGE +FunctionEnd + +;-------------- Installer ------------------------- +Section "Valentina (required)" +SectionIn RO ; define mandatory sections + +;Add files +SetOutPath "$INSTDIR" ; Set output path to the installation directory. +File /r "c:\pack\valentina\*.*" + +;create start-menu items +!define START_LINK_DIR "$SMPROGRAMS\${MUI_PRODUCT}" +!define START_LINK_RUN "$SMPROGRAMS\${MUI_PRODUCT}\${MUI_PRODUCT}.lnk" +!define START_LINK_UNINSTALLER "$SMPROGRAMS\${MUI_PRODUCT}\Uninstall ${MUI_PRODUCT}.lnk" + +# In your main installer section... +SetShellVarContext current +CreateDirectory "${START_LINK_DIR}" +CreateShortCut "${START_LINK_RUN}" "$INSTDIR\${MUI_FILE}.exe" +CreateShortCut "${START_LINK_UNINSTALLER}" "$INSTDIR\Uninstall.exe" + +;create desktop shortcut +CreateShortCut "$DESKTOP\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_FILE}.exe" "" + +;write uninstall information to the registry +!define UNINSTALLER_NAME "Uninstall.exe" + +; File associations +!insertmacro APP_ASSOCIATE "val" "valentina.pattern" "Valentina pattern file" "$INSTDIR\${MUI_FILE}.exe,0" "Open with Valentina" "$\"$INSTDIR\${MUI_FILE}.exe$\" $\"%1$\"" +; Example of association icon with file type +; !insertmacro APP_ASSOCIATE "osapp" "OSA.osapp" "Plugin Package" "$INSTDIR\PluginIcon.ico" "Open" "$INSTDIR\PluginInstaller.exe $\"%1$\"" +!insertmacro UPDATEFILEASSOC + +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "DisplayName" "${MUI_PRODUCT}" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\${MUI_FILE}.exe$\"" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "Publisher" "${PUBLISHER}" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "DisplayVersion" "${MUI_VERSION}" + +; Run GetSize after coping all files +${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 +IntFmt $0 "0x%08X" $0 +WriteRegDWord "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "EstimatedSize" "$0" + +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "HelpLink" "${WEBSITE_LINK}" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "URLInfoAbout" "${WEBSITE_LINK}" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\"" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "InstallSource" "$\"$EXEDIR$\"" +WriteRegDWord "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "NoModify" 1 +WriteRegDWord "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "NoRepair" 1 +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\${UNINSTALLER_NAME}$\"" +WriteRegStr "${REGISTRY_ROOT}" "${REG_UNINSTALL}" "Comments" "Uninstalls ${MUI_PRODUCT}." + +WriteUninstaller "$INSTDIR\${UNINSTALLER_NAME}" ; Location of the uninstaller + +SectionEnd + +;-------------------------------- +;Uninstaller Section +Section "Uninstall" + +;Delete Files +RMDir /r "$INSTDIR\*.*" + +;Remove the installation directory +RMDir "$INSTDIR" + +;Delete Start Menu Shortcuts +SetShellVarContext current +Delete "$DESKTOP\${MUI_PRODUCT}.lnk" +Delete "${START_LINK_DIR}\*.*" +RmDir "${START_LINK_DIR}" + +; Removing file associations +!insertmacro APP_UNASSOCIATE "val" "valentina.pattern" + +;Delete Uninstaller And Unistall Registry Entries +DeleteRegKey "${REGISTRY_ROOT}" "SOFTWARE\${MUI_PRODUCT}" +DeleteRegKey "${REGISTRY_ROOT}" "${REG_UNINSTALL}" + +SectionEnd + +;eof diff --git a/dist/rpm/_service b/dist/rpm/_service new file mode 100644 index 000000000..45285f7b6 --- /dev/null +++ b/dist/rpm/_service @@ -0,0 +1,14 @@ + + + https://github.com/dismine/Valentina.git + 0.2.8 + valentina + git + %at + + + *.tar + */dist/rpm/valentina.spec + + + diff --git a/dist/rpm/valentina.spec b/dist/rpm/valentina.spec index 39e13ab9e..633415889 100644 --- a/dist/rpm/valentina.spec +++ b/dist/rpm/valentina.spec @@ -2,67 +2,92 @@ Name:valentina # Fedora specifics %if 0%{?fedora_version} > 0 || 0%{?rhel_version} > 0 || 0%{?centos_version} > 0 -BuildRequires: pkgconfig(Qt5Core) libqt5-qttools >= 5.0.0 libQtSvg-devel >= 5.0.0 ccache +BuildRequires: pkgconfig(Qt5Core) +BuildRequires: pkgconfig(Qt5Gui) +BuildRequires: pkgconfig(Qt5Network) +BuildRequires: pkgconfig(Qt5PrintSupport) +BuildRequires: pkgconfig(Qt5Widgets) +BuildRequires: pkgconfig(Qt5Xml) +BuildRequires: qt5-qtxmlpatterns-devel >= 5.2.0 +BuildRequires: qt5-qtsvg-devel >= 5.2.0 +BuildRequires: qt5-qttools-devel >= 5.2.0 +BuildRequires: ccache %endif # SUSE Specifics %if 0%{?suse_version} > 0 -BuildRequires: libqt5-qtbase-devel >= 5.0.0 libqt5-qttools >= 5.0.0 libQt5Svg-devel >= 5.0.0 ccache update-desktop-files +BuildRequires: libqt5-qtbase-devel +BuildRequires: libqt5-qttools +BuildRequires: libQt5Svg-devel +BuildRequires: libqt5-qtxmlpatterns-devel +BuildRequires: libqt5-linguist-devel +BuildRequires: ccache +BuildRequires: update-desktop-files %endif -Version: 0.2.2 -Release: 1 +Version: 0.2.8 +Release: 0 URL: https://bitbucket.org/dismine/valentina License: GPL-3.0+ -Source0: %{name}-%{version}.tar.gz +Source0: %{name}-%{version}.tar +Requires: poppler-utils Group: Graphics Summary: Pattern Making Application -BuildRoot: %{_tmppath}/%{name}-%{version}-build -Packager: Roman Telezhinsky +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Packager: Roman Telezhinskyi %description -Open source project of creating a pattern making program, whose allow -create and modeling patterns of clothing. +Valentina is a cross-platform patternmaking program which allows designers +to create and model patterns of clothing. This software allows pattern +creation, using either standard sizing tables or an individual’s set of +measurements. It blends new technologies with traditional methods to create +a unique pattern making tool. %prep %setup -q -n %{name}-%{version} %build -qmake-qt5 +%if 0%{?suse_version} >= 1320 +qmake-qt5 PREFIX=%{buildroot}%{_prefix} LRELEASE=lrelease-qt5 Valentina.pro -r +%else +qmake-qt5 PREFIX=%{buildroot}%{_prefix} Valentina.pro -r +%endif %{__make} %{?jobs:-j %jobs} %install -mkdir -p $RPM_BUILD_ROOT/usr/{bin,share} -mkdir -p $RPM_BUILD_ROOT/usr/share/%{name}/translations -%{__install} -Dm 755 -s bin/%{name} %{buildroot}%{_bindir}/%{name} -%{__install} -Dm 644 dist/%{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop -%{__install} -Dm 644 dist/%{name}.png %{buildroot}%{_datadir}/pixmaps/%{name}.png -%{__install} -Dm 644 dist/%{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz -%{__install} -Dm 644 share/translations/valentina_uk.qm %{buildroot}%{_datadir}/%{name}/translations/valentina_uk.qm -%{__install} -Dm 644 share/translations/valentina_ru.qm %{buildroot}%{_datadir}/%{name}/translations/valentina_ru.qm +%{__make} install +gzip -9c dist/debian/%{name}.1 > dist/debian/%{name}.1.gz && +%{__install} -Dm 644 dist/debian/%{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz + %if 0%{?suse_version} > 0 %suse_update_desktop_file -r %{name} VectorGraphics %endif -%clean -[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot} - %files %defattr(-,root,root,-) -%doc README LICENSE +%doc README.txt LICENSE_GPL.txt %doc %{_mandir}/man1/%{name}.1.gz %{_bindir}/* +%{_libdir}/* %{_datadir}/applications/%{name}.desktop -%{_datadir}/pixmaps/%{name}.png -%{_datadir}/%{name}/translations/valentina_uk.qm -%{_datadir}/%{name}/translations/valentina_ru.qm +%{_datadir}/pixmaps/* %dir %{_datadir}/%{name} %dir %{_datadir}/%{name}/translations +%{_datadir}/%{name}/translations/*.qm +%dir %{_datadir}/%{name}/tables +%dir %{_datadir}/%{name}/tables/standard +%{_datadir}/%{name}/tables/standard/*.vst + +%clean +[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot} + +%post +ldconfig %changelog -* Mon Dec 9 2013 Roman Telezhinsky +* Mon Dec 22 2014 Roman Telezhinskyi - Initial build diff --git a/dist/valentina.desktop b/dist/valentina.desktop index 79f109d82..f136cecbc 100644 --- a/dist/valentina.desktop +++ b/dist/valentina.desktop @@ -1,10 +1,12 @@ [Desktop Entry] Type=Application Name=Valentina -GenericName=Pattern making program -Comment=Open source project of creating a pattern making program, whose allow create and modeling patterns of clothing -Icon=valentina -Exec=valentina -Categories=Graphics;VectorGraphics;2DGraphics; +Exec=valentina %U Version=1.0 -Name[uk]=valentina +Encoding=UTF-8 +GenericName=Pattern making program +Comment=Valentina is a cross-platform patternmaking program which allows designers to create and model patterns of clothing. This software allows pattern creation, using either standard sizing tables or an individual’s set of measurements. It blends new technologies with traditional methods to create a unique pattern making tool. +Icon=valentina +Terminal=false +MimeType=application/x-valentina-pattern; +Categories=Graphics;VectorGraphics;2DGraphics; diff --git a/dist/valentina.nsi b/dist/valentina.nsi deleted file mode 100644 index 657ee900c..000000000 --- a/dist/valentina.nsi +++ /dev/null @@ -1,149 +0,0 @@ -; ------------------------------- -; Start - - - !define MUI_PRODUCT "Valentina" - !define MUI_FILE "valentina" - !define MUI_VERSION "0.2.2" - !define MUI_BRANDINGTEXT "Valentina ${MUI_VERSION}" - CRCCheck On - - ; Bij deze moeten we waarschijnlijk een absoluut pad gaan gebruiken - ; dit moet effe uitgetest worden. - !include "${NSISDIR}\Contrib\Modern UI\System.nsh" - - -;-------------------------------- -;General - Name "${MUI_BRANDINGTEXT}" - Caption "${MUI_BRANDINGTEXT}" - SetCompressor bzip2 - OutFile "${MUI_FILE}-install-v.${MUI_VERSION}.exe" - - ; Request application privileges for Windows Vista - RequestExecutionLevel user - - ShowInstDetails show - ShowUninstDetails show - - !define MUI_ICON "valentina\${MUI_FILE}.ico" - !define MUI_UNICON "valentina\${MUI_FILE}.ico" - ;!define MUI_SPECIALBITMAP "Bitmap.bmp" - -;-------------------------------- -;Folder selection page - -InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" - - -;-------------------------------- -;Modern UI Configuration - - InstallColors 061C79 E5F0E2 - LicenseBkColor E5F0E2 - InstProgressFlags smooth colored - - !define MUI_WELCOMEPAGE - !define MUI_LICENSEPAGE - !define MUI_DIRECTORYPAGE - !define MUI_ABORTWARNING - !define MUI_UNINSTALLER - !define MUI_UNCONFIRMPAGE - !define MUI_FINISHPAGE - - -;-------------------------------- -;Page - - !insertmacro MUI_PAGE_WELCOME - !insertmacro MUI_PAGE_LICENSE "valentina\license" - !insertmacro MUI_PAGE_COMPONENTS - !insertmacro MUI_PAGE_DIRECTORY - !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_PAGE_FINISH - - !insertmacro MUI_UNPAGE_WELCOME - !insertmacro MUI_UNPAGE_CONFIRM - !insertmacro MUI_UNPAGE_INSTFILES - !insertmacro MUI_UNPAGE_FINISH - -;-------------------------------- -;Language - - !insertmacro MUI_LANGUAGE "English" - - -;-------------------------------- -;Modern UI System - - ;!insertmacro MUI_SYSTEM - !include "MUI2.nsh" - -;-------------------------------- -;Data - - LicenseData "valentina\LICENSE" - -;-------------------------------- -;Installer Sections -Section "Valentina (required)" - -;Add files - SetOutPath "$INSTDIR" - File /r "c:\pack\valentina\*.*" - -;create desktop shortcut - CreateShortCut "$DESKTOP\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_FILE}.exe" "" - -;create start-menu items - CreateDirectory "$SMPROGRAMS\${MUI_PRODUCT}" - CreateShortCut "$SMPROGRAMS\${MUI_PRODUCT}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${MUI_PRODUCT}\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_FILE}.exe" "" "$INSTDIR\${MUI_FILE}.exe" 0 - -;write uninstall information to the registry - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayName" "${MUI_PRODUCT} (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "UninstallString" "$INSTDIR\Uninstall.exe" - - WriteUninstaller "$INSTDIR\Uninstall.exe" - -SectionEnd - - -;-------------------------------- -;Uninstaller Section -Section "Uninstall" - -;Delete Files - RMDir /r "$INSTDIR\*.*" - -;Remove the installation directory - RMDir "$INSTDIR" - -;Delete Start Menu Shortcuts - Delete "$DESKTOP\${MUI_PRODUCT}.lnk" - Delete "$SMPROGRAMS\${MUI_PRODUCT}\*.*" - RmDir "$SMPROGRAMS\${MUI_PRODUCT}" - -;Delete Uninstaller And Unistall Registry Entries - DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${MUI_PRODUCT}" - DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" - -SectionEnd - - -;-------------------------------- -;MessageBox Section - - -;Function that calls a messagebox when installation finished correctly -Function .onInstSuccess - MessageBox MB_OK "You have successfully installed ${MUI_PRODUCT}. Use the desktop icon to start the program." -FunctionEnd - - -Function un.onUninstSuccess - MessageBox MB_OK "You have successfully uninstalled ${MUI_PRODUCT}." -FunctionEnd - - -;eof diff --git a/dist/valentina.png b/dist/valentina.png index d6cc04903..f695df140 100644 Binary files a/dist/valentina.png and b/dist/valentina.png differ diff --git a/dist/valentina.recipe b/dist/valentina.recipe new file mode 100644 index 000000000..85cfdc3bf --- /dev/null +++ b/dist/valentina.recipe @@ -0,0 +1,3 @@ +# bzr-builder format 0.3 deb-version {debupstream}+{revno}+{revno:packaging}+{time} +lp:valentina +merge packaging lp:~dismine/valentina/debian diff --git a/doc/doxygen/logo.png b/doc/doxygen/logo.png deleted file mode 100644 index 7614a27ea..000000000 Binary files a/doc/doxygen/logo.png and /dev/null differ diff --git a/scripts/alphabets.py b/scripts/alphabets.py new file mode 100755 index 000000000..32fd5f2ac --- /dev/null +++ b/scripts/alphabets.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import codecs +import sys +#Alphabets was taken from website http://www.alphabet-letters.com/ + +#Use this script if you want get all unique symbols from all alphabets. +#This unique symbols need for math parser. +#Example: +# ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆جگĮаҳѕεشԶиһνԾрυلՆӝшËՎҔPÓՖXӛӟŞӣզhëծpóӞնxßվāŁЃֆĉЋCŬđҐГΒęҘЛΚŘġҠУGاհЫدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփїІĈЎґĐΗЖҙĘȚ +# ΟОҡĠآΧЦتЮұİزηжԸغοоÁՀقχцÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحҮбưԳصδHйԻŇμӲӴсՃمτƠщՋєLQŹՓŕÖYśÞaգĽæiŽիӓîqճöyջþĂօЄӦĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќ +# αذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇčŃЏĕӯЗΖEțŮĝПΞأĥĹЧΦثÆӳЯIسŲԵзζԽпξكՅÄчφNMՍӌяӢՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکЪƯخγвŅԴŪضλкԼĴσтÅՄنъÍՌRӕ +# ՔZÝŜbåդﻩjíլļrӵմzýռپêЅքćچЍďӱҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝŻşҤӑâeէŐımկòuշÕúտŔ + +RUSSIAN_ALPHABET = set(u'абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ') #RUSSIAN ALPHABET +ENGLISH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #ENGLISH ALPHABET +AZERBAIJANI_ALPHABET = set(u'abcçdeəfgğhxıijkqlmnoöprsştuüvyzABCÇDEƏFGĞHXIİJKQLMNOÖPRSŞTUÜVYZ') #AZERBAIJANI ALPHABET +ALBANIAN_ALPHABET = set(u'abcçddheëfggjhijklllmnnjopqrrrsshtthuvxxhyzzhABCÇDDhEËFGGjHIJKLLlMNNjOPQRRrSShTThUVXXhYZZh') #ALBANIAN ALPHABET +ARABIC_ALPHABET = set(u'أبجدوﻩزحطيكلمنسعفصقرشتثخذضظغ') #ARABIC ALPHABET +ARMENIAN_ALPHABET = set(u'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքեւօֆԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔԵվևՕՖ') #ARMENIAN ALPHABET +AFRIKAANS_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #AFRIKAANS ALPHABET +BASQUE_ALPHABET = set(u'аbdefghijklmnñoprstuxzАBDEFGHIJKLMNÑOPRSTUXZ') #BASQUE ALPHABET +BASHKIR_ALPHABET = set(u'абвгғдҙеёжзийкҡлмнңоөпрсҫтуүфхһцчшщъыьэәюяАБВГҒДҘЕЁЖЗИЙКҠЛМНҢОӨПРСҪТУҮФХҺЦЧШЩЪЫЬЭӘЮЯ') #BASHKIR ALPHABET +BELORUSSIAN_ALPHABET = set(u'абвгддждзеёжзійклмнопрстуўфхцчшыьэюяАБВГДДжДзЕЁЖЗІЙКЛМНОПРСТУЎФХЦЧШЫЬЭЮЯ') #BELORUSSIAN ALPHABET +BULGARIAN_ALPHABET = set(u'абвгдежзийклмнопрстуфхцчшщъьюяАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ') #BULGARIAN ALPHABET +BURYATIAN_ALPHABET = set(u'абвгдеёжзийклмноөпрстуүфхһцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОӨПРСТУҮФХҺЦЧШЩЪЫЬЭЮЯ') #BURYATIAN ALPHABET +WELSH_ALPHABET = set(u'abcchdddefffgnghilllmnopphrrhstthuwyABCCHDDDEFFFGNGHILLLMNOPPHRRHSTTHUWY') #WELSH ALPHABET +HUNGARIAN_ALPHABET = set(u'aábccsddzdzseéfggyhiíjkllymnnyoóöőprsszttyuúüűvzzsqwxyAÁBCCsDDzDzsEÉFGGyHIÍJKLLyMNNyOÓÖŐPRSSzTTyUÚÜŰVZZsQWXY') #HUNGARIAN ALPHABET +VIETNAMESE_ALPHABET = set(u'aăâbcdđeêghiklmnoôơpqrstuưvxyAĂÂBCDĐEÊGHIKLMNOÔƠPQRSTUƯVXY') #VIETNAMESE ALPHABET +HAITIAN_ALPHABET = set(u'aanbchdeèenfghijklmnngoòonouounprstuivwyzAAnBChDEèEnFGHIJKLMNNgOòOnOuOunPRSTUiVWYZ') #HAITIAN ALPHABET +GALICIAN_ALPHABET = set(u'abcdefghilmnñopqrstuvxzABCDEFGHILMNÑOPQRSTUVXZ') #GALICIAN ALPHABET +DUTCH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxijyzABCDEFGHIJKLMNOPQRSTUVWXIJYZ') #DUTCH ALPHABET +GREEK_ALPHABET = set(u'αβγδεζηθικλμνξοπρσςτυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ') #GREEK ALPHABET +DANISH_ALPHABET = set(u'аbcdefghijklmnopqrstuvwxyzæøåАBCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ') #DANISH ALPHABET +INDONESIAN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #INDONESIAN ALPHABET +IRISH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #IRISH ALPHABET +ICELANDIC_ALPHABET = set(u'aábdðeéfghiíjklmnoóprstuúvxyýþæöAÁBDÐEÉFGHIÍJKLMNOÓPRSTUÚVXYÝÞÆÖ') #ICELANDIC ALPHABET +SPANISH_ALPHABET = set(u'abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ') #SPANISH ALPHABET +ITALIAN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #ITALIAN ALPHABET +KAZAKH_ALPHABET = set(u'аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюяАӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ') #KAZAKH ALPHABET +KALMYK_ALPHABET = set(u'аəбвгһдеёжҗзийклмнңоөпрстуүфхцчшщыьэюяАƏБВГҺДЕЁЖҖЗИЙКЛМНҢОӨПРСТУҮФХЦЧШЩЫЬЭЮЯ') #KALMYK ALPHABET +KARAKALPAK_ALPHABET = set(u'аәбвгғдеёжзийкқлмнңоөпрстуүўфхҳцчшщъыьэюяАӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҮЎФХҲЦЧШЩЪЫЬЭЮЯ') #KARAKALPAK ALPHABET +KARELIAN_ALPHABET = set(u'abčdefghijklmnoprsšzžtuvyäöABČDEFGHIJKLMNOPRSŠZŽTUVYÄÖ') #KARELIAN ALPHABET +CATALAN_ALPHABET = set(u'aàbcçdeéèfghiíïjklmnoóòpqrstuúüvwxyzAÀBCÇDEÉÈFGHIÍÏJKLMNOÓÒPQRSTUÚÜVWXYZ') #CATALAN ALPHABET +KYRGYZ_ALPHABET = set(u'абвгдеёжзийклмнңоөпрстуүфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНҢОӨПРСТУҮФХЦЧШЩЪЫЬЭЮЯ') #KYRGYZ ALPHABET +LATIN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #LATIN ALPHABET +LATVIAN_ALPHABET = set(u'aābcčdeēfgģhiījkķlļmnņoprsštuūvzžAĀBCČDEĒFGĢHIĪJKĶLĻMNŅOPRSŠTUŪVZŽ') #LATVIAN ALPHABET +LITHUANIAN_ALPHABET = set(u'aąbcčdeęėfghiįyjklmnoprsštuųūvzžAĄBCČDEĘĖFGHIĮYJKLMNOPRSŠTUŲŪVZŽ') #LITHUANIAN ALPHABET +MACEDONIAN_ALPHABET = set(u'абвгдѓеѐжзѕиѝјклљмнњопрстќуфхцчџшАБВГДЃЕЀЖЗЅИЍЈКЛЉМНЊОПРСТЌУФХЦЧЏШ') #MACEDONIAN ALPHABET +MALTESE_ALPHABET = set(u'abċdefġggħhħiiejklmnopqrstuvwxzżABĊDEFĠGGĦHĦIIEJKLMNOPQRSTUVWXZŻ') #MALTESE ALPHABET +MARI_ALPHABET = set(u'аӓбвгдеёжзийклмноӧпрстуӱфхцчшщъыӹьэюяАӒБВГДЕЁЖЗИЙКЛМНОӦПРСТУӰФХЦЧШЩЪЫӸЬЭЮЯ') #MARI ALPHABET +MOLDAVIAN_ALPHABET = set(u'aăâbcdefghiîjklmnopqrsștțuvwxyzAĂÂBCDEFGHIÎJKLMNOPQRSȘTȚUVWXYZ') #MOLDAVIAN ALPHABET +MONGOLIAN_ALPHABET = set(u'абвгдеёжзийклмноөпрстуүфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОӨПРСТУҮФХЦЧШЩЪЫЬЭЮЯ') #MONGOLIAN ALPHABET +GERMAN_ALPHABET = set(u'aäbcdefghijklmnoöpqrstuüvwxyzAÄBCDEFGHIJKLMNOÖPQRSßTUÜVWXYZ') #GERMAN ALPHABET +NORWEGIAN_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzæøåABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ') #NORWEGIAN ALPHABET +OSETIAN_ALPHABET = set(u'аӕбвггъддзджеёжзийккълмноппърсттъуфххъццъччъшщъыьэюяАӔБВГГъДДзДжЕЁЖЗИЙККъЛМНОППъРСТТъУФХХъЦЦъЧЧъШЩъЫьЭЮЯ') #OSETIAN ALPHABET +POLISH_ALPHABET = set(u'aąbcćdeęfghijklłmnńoóprsśtuwyzźżAĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ') #POLISH ALPHABET +PORTUGUESE_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #PORTUGUESE ALPHABET +ROMANIAN_ALPHABET = set(u'aăâbcdefghiîjklmnopqrsștțuvwxyzAĂÂBCDEFGHIÎJKLMNOPQRSȘTȚUVWXYZ') #ROMANIAN ALPHABET +SERBIAN_ALPHABET = set(u'абвгдђежзијклљмнњопрстћуфхцчџшАБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ') #SERBIAN ALPHABET +SLOVAK_ALPHABET = set(u'aáäbcčdďdzdžeéfghchiíjklĺľmnňoóôpqrŕsštťuúvwxyýzžAÁÄBCČDĎDzDžEÉFGHChIÍJKLĹĽMNŇOÓÔPQRŔSŠTŤUÚVWXYÝZŽ') #SLOVAK ALPHABET +SLOVENIAN_ALPHABET = set(u'abcčddžefghijklljmnnjoprsštuvzžABCČDDžEFGHIJKLLjMNNjOPRSŠTUVZŽ') #SLOVENIAN ALPHABET +TAJIK_ALPHABET = set(u'абвгғдеёжзийӣкқлмнопрстуӯфхҳчҷшъэюяАБВГҒДЕЁЖЗИЙӢКҚЛМНОПРСТУӮФХҲЧҶШЪЭЮЯ') #TAJIK ALPHABET +TATAR_ALPHABET = set(u'аәбвгдеёжҗзийклмнңоөпрстуүфхһцчшщъыьэюяАӘБВГДЕЁЖҖЗИЙКЛМНҢОӨПРСТУҮФХҺЦЧШЩЪЫЬЭЮ') #TATAR ALPHABET +TUVIN_ALPHABET = set(u'абвгдёжӝзийклмнңоӧпрстуӱхчшыАБВГДЁЖӜЗИЙКЛМНҢОӦПРСТУӰХЧШЫ') #TUVIN ALPHABET +TURKISH_ALPHABET = set(u'abcçdefgğhiıjklmnoöpqrsştuüvwxyzABCÇDEFGĞHIIJKLMNOÖPQRSŞTUÜVWXYZ') #TURKISH ALPHABET +UDMURT_ALPHABET = set(u'абвгдеёжӝзӟиӥйклмноӧпрстуфхцчӵшщъыьэюяАБВГДЕЁЖӜЗӞИӤЙКЛМНОӦПРСТУФХЦЧӴШЩЪЫЬЭЮЯ') #UDMURT ALPHABET +UZBEK_ALPHABET = set(u'абвгғдеёжзийкқлмнопрстуўфхҳцчшъьэюяАБВГҒДЕЁЖЗИЙКҚЛМНОПРСТУЎФХҲЦЧШЪЬЭЮЯ') #UZBEK ALPHABET +UKRAINIAN_ALPHABET = set(u'абвгґдежзіїийклмнопрстуфхцчшщьєюяАБВГҐДЕЖЗІЇИЙКЛМНОПРСТУФХЦЧШЩЬЄЮЯ') #UKRAINIAN ALPHABET +FARSI_ALPHABET = set(u'ءاآبپتثجچحخدذرزژسشصضطظعغفقكکگلمنوهيی') #FARSI ALPHABET +PHILIPPINES_ALPHABET = set(u'abcdefghijklmnñngoprstuvwxyzABCDEFGHIJKLMNÑNgOPRSTUVWXYZ') #PHILIPPINES ALPHABET +FINNISH_ALPHABET = set(u'abcdefghijklmnopqrsštuvwxyzžåäöABCDEFGHIJKLMNOPQRSŠTUVWXYZŽÅÄÖ') #FINNISH ALPHABET +FRENCH_ALPHABET = set(u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') #FRENCH ALPHABET +HAKASS_ALPHABET = set(u'абвгғдеёжзиiйклмнңoӧпрстуӱфхцчӌшщъыьэюяАБВГҒДЕЁЖЗИIЙКЛМНҢOӦПРСТУӰФХЦЧӋШЩЪЫЬЭЮЯ') #HAKASS ALPHABET +HANTY_ALPHABET = set(u'аӓӑбвгдеёәӛжзийкқлӆмнңн̆оӧөӫпрстуӱўфхҳцчҷшщъыьэєє̈юю̆яя̆АӒӐБВГДЕЁӘӚЖЗИЙКҚЛӅМНҢН̆ОӦӨӪПРСТУӰЎФХҲЦЧҶШЩЪЫЬЭЄЄ̈ЮЮ̆ЯЯ̆') #HANTY ALPHABET +CROATIAN_ALPHABET = set(u'abcčćddžðefghijklljmnnjoprsštuvzžABCČĆDDžÐEFGHIJKLLjMNNjOPRSŠTUVZŽ') #CROATIAN ALPHABET +BOSNIAN_ALPHABET = set(u'abcčćddžðefghijklljmnnjoprsštuvzžABCČĆDDžÐEFGHIJKLLjMNNjOPRSŠTUVZŽ') #BOSNIAN ALPHABET +CZECH_ALPHABET = set(u'aábcčdďeéěfghchiíjklmnňoópqrřsštťuúůvwxyýzžAÁBCČDĎEÉĚFGHChIÍJKLMNŇOÓPQRŘSŠTŤUÚŮVWXYÝZŽ') #CZECH ALPHABET +CHUVASH_ALPHABET = set(u'аăбвгдеёĕжзийклмнопрсçтуӳфхцчшщьыъэюяАĂБВГДЕЁĔЖЗИЙКЛМНОПРСÇТУӲФХЦЧШЩЬЫЪЭЮЯ') #CHUVASH ALPHABET +SWEDISH_ALPHABET = set(u'aåäbcdefghijklmnoöpqrstuvwxyzAÅÄBCDEFGHIJKLMNOÖPQRSTUVWXYZ') #SWEDISH ALPHABET +ESPERANTO_ALPHABET = set(u'abcĉdefgĝhĥijĵklmnoprsŝtuŭvzABCĈDEFGĜHĤIJĴKLMNOPRSŜTUŬVZ') #ESPERANTO ALPHABET +ESTONIAN_ALPHABET = set(u'abcdefghijklmnopqrsšzžtuvwõäöüxyABCDEFGHIJKLMNOPQRSŠZŽTUVWÕÄÖÜXY') #ESTONIAN ALPHABET +YAKUTIAN_ALPHABET = set(u'абвгҕддьеёжзийклмнҥньоөпрсһтуүфхцчшщъыьэАБВГҔДДьЕЁЖЗИЙКЛМНҤНьОӨПРСҺТУҮФХЦЧШЩЪЫЬЭ') #YAKUTIAN ALPHABET +MONTENEGRIN_ALPHABET = set(u'abcčćddžðefghijklljmnnjoprsštuvzžABCČĆDDžÐEFGHIJKLLjMNNjOPRSŠTUVZŽ') #MONTENEGRIN ALPHABET + +UTF8Writer = codecs.getwriter('utf8') +sys.stdout = UTF8Writer(sys.stdout) + +SYMBOLS = set(RUSSIAN_ALPHABET) +SYMBOLS.update(RUSSIAN_ALPHABET, ENGLISH_ALPHABET, AZERBAIJANI_ALPHABET, ALBANIAN_ALPHABET, ARABIC_ALPHABET, ARMENIAN_ALPHABET, AFRIKAANS_ALPHABET, BASQUE_ALPHABET, BASHKIR_ALPHABET, +BELORUSSIAN_ALPHABET, BULGARIAN_ALPHABET, BURYATIAN_ALPHABET, WELSH_ALPHABET, HUNGARIAN_ALPHABET, VIETNAMESE_ALPHABET, HAITIAN_ALPHABET, GALICIAN_ALPHABET, DUTCH_ALPHABET, GREEK_ALPHABET, +DANISH_ALPHABET, INDONESIAN_ALPHABET, IRISH_ALPHABET, ICELANDIC_ALPHABET, SPANISH_ALPHABET, ITALIAN_ALPHABET, KAZAKH_ALPHABET, KALMYK_ALPHABET, KARAKALPAK_ALPHABET, KARELIAN_ALPHABET, +CATALAN_ALPHABET, KYRGYZ_ALPHABET, LATIN_ALPHABET, LATVIAN_ALPHABET, LITHUANIAN_ALPHABET, MACEDONIAN_ALPHABET, MALTESE_ALPHABET, MARI_ALPHABET, MOLDAVIAN_ALPHABET, MONGOLIAN_ALPHABET, +GERMAN_ALPHABET, NORWEGIAN_ALPHABET, OSETIAN_ALPHABET, POLISH_ALPHABET, PORTUGUESE_ALPHABET, ROMANIAN_ALPHABET, SERBIAN_ALPHABET, SLOVAK_ALPHABET, SLOVENIAN_ALPHABET, TAJIK_ALPHABET, TATAR_ALPHABET, +TUVIN_ALPHABET, TURKISH_ALPHABET, UDMURT_ALPHABET, UZBEK_ALPHABET, UKRAINIAN_ALPHABET, FARSI_ALPHABET, PHILIPPINES_ALPHABET, FINNISH_ALPHABET, FRENCH_ALPHABET, HAKASS_ALPHABET,HANTY_ALPHABET, +BOSNIAN_ALPHABET, CROATIAN_ALPHABET, CZECH_ALPHABET, CHUVASH_ALPHABET, SWEDISH_ALPHABET, ESPERANTO_ALPHABET, ESTONIAN_ALPHABET, YAKUTIAN_ALPHABET, MONTENEGRIN_ALPHABET) + +L = list(SYMBOLS) +print ''.join(L) + diff --git a/scripts/asan_symbolize.py b/scripts/asan_symbolize.py new file mode 100755 index 000000000..ffa57ee62 --- /dev/null +++ b/scripts/asan_symbolize.py @@ -0,0 +1,469 @@ +#!/usr/bin/env python +#===- lib/asan/scripts/asan_symbolize.py -----------------------------------===# +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +import argparse +import bisect +import getopt +import os +import pty +import re +import subprocess +import sys +import termios + +symbolizers = {} +DEBUG = False +demangle = False +binutils_prefix = None +sysroot_path = None +binary_name_filter = None +fix_filename_patterns = None +logfile = sys.stdin + +# FIXME: merge the code that calls fix_filename(). +def fix_filename(file_name): + if fix_filename_patterns: + for path_to_cut in fix_filename_patterns: + file_name = re.sub('.*' + path_to_cut, '', file_name) + file_name = re.sub('.*asan_[a-z_]*.cc:[0-9]*', '_asan_rtl_', file_name) + file_name = re.sub('.*crtstuff.c:0', '???:0', file_name) + return file_name + +def sysroot_path_filter(binary_name): + return sysroot_path + binary_name + +def guess_arch(addr): + # Guess which arch we're running. 10 = len('0x') + 8 hex digits. + if len(addr) > 10: + return 'x86_64' + else: + return 'i386' + +class Symbolizer(object): + def __init__(self): + pass + + def symbolize(self, addr, binary, offset): + """Symbolize the given address (pair of binary and offset). + + Overriden in subclasses. + Args: + addr: virtual address of an instruction. + binary: path to executable/shared object containing this instruction. + offset: instruction offset in the @binary. + Returns: + list of strings (one string for each inlined frame) describing + the code locations for this instruction (that is, function name, file + name, line and column numbers). + """ + return None + + +class LLVMSymbolizer(Symbolizer): + def __init__(self, symbolizer_path, default_arch, system, dsym_hints=[]): + super(LLVMSymbolizer, self).__init__() + self.symbolizer_path = symbolizer_path + self.default_arch = default_arch + self.system = system + self.dsym_hints = dsym_hints + self.pipe = self.open_llvm_symbolizer() + + def open_llvm_symbolizer(self): + cmd = [self.symbolizer_path, + '--use-symbol-table=true', + '--demangle=%s' % demangle, + '--functions=short', + '--inlining=true', + '--default-arch=%s' % self.default_arch] + if self.system == 'Darwin': + for hint in self.dsym_hints: + cmd.append('--dsym-hint=%s' % hint) + if DEBUG: + print ' '.join(cmd) + try: + result = subprocess.Popen(cmd, stdin=subprocess.PIPE, + stdout=subprocess.PIPE) + except OSError: + result = None + return result + + def symbolize(self, addr, binary, offset): + """Overrides Symbolizer.symbolize.""" + if not self.pipe: + return None + result = [] + try: + symbolizer_input = '"%s" %s' % (binary, offset) + if DEBUG: + print symbolizer_input + print >> self.pipe.stdin, symbolizer_input + while True: + function_name = self.pipe.stdout.readline().rstrip() + if not function_name: + break + file_name = self.pipe.stdout.readline().rstrip() + file_name = fix_filename(file_name) + if (not function_name.startswith('??') or + not file_name.startswith('??')): + # Append only non-trivial frames. + result.append('%s in %s %s' % (addr, function_name, + file_name)) + except Exception: + result = [] + if not result: + result = None + return result + + +def LLVMSymbolizerFactory(system, default_arch, dsym_hints=[]): + symbolizer_path = os.getenv('LLVM_SYMBOLIZER_PATH') + if not symbolizer_path: + symbolizer_path = os.getenv('ASAN_SYMBOLIZER_PATH') + if not symbolizer_path: + # Assume llvm-symbolizer is in PATH. + symbolizer_path = 'llvm-symbolizer' + return LLVMSymbolizer(symbolizer_path, default_arch, system, dsym_hints) + + +class Addr2LineSymbolizer(Symbolizer): + def __init__(self, binary): + super(Addr2LineSymbolizer, self).__init__() + self.binary = binary + self.pipe = self.open_addr2line() + + def open_addr2line(self): + addr2line_tool = 'addr2line' + if binutils_prefix: + addr2line_tool = binutils_prefix + addr2line_tool + cmd = [addr2line_tool, '-f'] + if demangle: + cmd += ['--demangle'] + cmd += ['-e', self.binary] + if DEBUG: + print ' '.join(cmd) + return subprocess.Popen(cmd, + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + + def symbolize(self, addr, binary, offset): + """Overrides Symbolizer.symbolize.""" + if self.binary != binary: + return None + try: + print >> self.pipe.stdin, offset + function_name = self.pipe.stdout.readline().rstrip() + file_name = self.pipe.stdout.readline().rstrip() + except Exception: + function_name = '' + file_name = '' + file_name = fix_filename(file_name) + return ['%s in %s %s' % (addr, function_name, file_name)] + + +class UnbufferedLineConverter(object): + """ + Wrap a child process that responds to each line of input with one line of + output. Uses pty to trick the child into providing unbuffered output. + """ + def __init__(self, args, close_stderr=False): + pid, fd = pty.fork() + if pid == 0: + # We're the child. Transfer control to command. + if close_stderr: + dev_null = os.open('/dev/null', 0) + os.dup2(dev_null, 2) + os.execvp(args[0], args) + else: + # Disable echoing. + attr = termios.tcgetattr(fd) + attr[3] = attr[3] & ~termios.ECHO + termios.tcsetattr(fd, termios.TCSANOW, attr) + # Set up a file()-like interface to the child process + self.r = os.fdopen(fd, "r", 1) + self.w = os.fdopen(os.dup(fd), "w", 1) + + def convert(self, line): + self.w.write(line + "\n") + return self.readline() + + def readline(self): + return self.r.readline().rstrip() + + +class DarwinSymbolizer(Symbolizer): + def __init__(self, addr, binary): + super(DarwinSymbolizer, self).__init__() + self.binary = binary + self.arch = guess_arch(addr) + self.open_atos() + + def open_atos(self): + if DEBUG: + print 'atos -o %s -arch %s' % (self.binary, self.arch) + cmdline = ['atos', '-o', self.binary, '-arch', self.arch] + self.atos = UnbufferedLineConverter(cmdline, close_stderr=True) + + def symbolize(self, addr, binary, offset): + """Overrides Symbolizer.symbolize.""" + if self.binary != binary: + return None + atos_line = self.atos.convert('0x%x' % int(offset, 16)) + while "got symbolicator for" in atos_line: + atos_line = self.atos.readline() + # A well-formed atos response looks like this: + # foo(type1, type2) (in object.name) (filename.cc:80) + match = re.match('^(.*) \(in (.*)\) \((.*:\d*)\)$', atos_line) + if DEBUG: + print 'atos_line: ', atos_line + if match: + function_name = match.group(1) + function_name = re.sub('\(.*?\)', '', function_name) + file_name = fix_filename(match.group(3)) + return ['%s in %s %s' % (addr, function_name, file_name)] + else: + return ['%s in %s' % (addr, atos_line)] + + +# Chain several symbolizers so that if one symbolizer fails, we fall back +# to the next symbolizer in chain. +class ChainSymbolizer(Symbolizer): + def __init__(self, symbolizer_list): + super(ChainSymbolizer, self).__init__() + self.symbolizer_list = symbolizer_list + + def symbolize(self, addr, binary, offset): + """Overrides Symbolizer.symbolize.""" + for symbolizer in self.symbolizer_list: + if symbolizer: + result = symbolizer.symbolize(addr, binary, offset) + if result: + return result + return None + + def append_symbolizer(self, symbolizer): + self.symbolizer_list.append(symbolizer) + + +def BreakpadSymbolizerFactory(binary): + suffix = os.getenv('BREAKPAD_SUFFIX') + if suffix: + filename = binary + suffix + if os.access(filename, os.F_OK): + return BreakpadSymbolizer(filename) + return None + + +def SystemSymbolizerFactory(system, addr, binary): + if system == 'Darwin': + return DarwinSymbolizer(addr, binary) + elif system == 'Linux': + return Addr2LineSymbolizer(binary) + + +class BreakpadSymbolizer(Symbolizer): + def __init__(self, filename): + super(BreakpadSymbolizer, self).__init__() + self.filename = filename + lines = file(filename).readlines() + self.files = [] + self.symbols = {} + self.address_list = [] + self.addresses = {} + # MODULE mac x86_64 A7001116478B33F18FF9BEDE9F615F190 t + fragments = lines[0].rstrip().split() + self.arch = fragments[2] + self.debug_id = fragments[3] + self.binary = ' '.join(fragments[4:]) + self.parse_lines(lines[1:]) + + def parse_lines(self, lines): + cur_function_addr = '' + for line in lines: + fragments = line.split() + if fragments[0] == 'FILE': + assert int(fragments[1]) == len(self.files) + self.files.append(' '.join(fragments[2:])) + elif fragments[0] == 'PUBLIC': + self.symbols[int(fragments[1], 16)] = ' '.join(fragments[3:]) + elif fragments[0] in ['CFI', 'STACK']: + pass + elif fragments[0] == 'FUNC': + cur_function_addr = int(fragments[1], 16) + if not cur_function_addr in self.symbols.keys(): + self.symbols[cur_function_addr] = ' '.join(fragments[4:]) + else: + # Line starting with an address. + addr = int(fragments[0], 16) + self.address_list.append(addr) + # Tuple of symbol address, size, line, file number. + self.addresses[addr] = (cur_function_addr, + int(fragments[1], 16), + int(fragments[2]), + int(fragments[3])) + self.address_list.sort() + + def get_sym_file_line(self, addr): + key = None + if addr in self.addresses.keys(): + key = addr + else: + index = bisect.bisect_left(self.address_list, addr) + if index == 0: + return None + else: + key = self.address_list[index - 1] + sym_id, size, line_no, file_no = self.addresses[key] + symbol = self.symbols[sym_id] + filename = self.files[file_no] + if addr < key + size: + return symbol, filename, line_no + else: + return None + + def symbolize(self, addr, binary, offset): + if self.binary != binary: + return None + res = self.get_sym_file_line(int(offset, 16)) + if res: + function_name, file_name, line_no = res + result = ['%s in %s %s:%d' % ( + addr, function_name, file_name, line_no)] + print result + return result + else: + return None + + +class SymbolizationLoop(object): + def __init__(self, binary_name_filter=None, dsym_hint_producer=None): + # Used by clients who may want to supply a different binary name. + # E.g. in Chrome several binaries may share a single .dSYM. + self.binary_name_filter = binary_name_filter + self.dsym_hint_producer = dsym_hint_producer + self.system = os.uname()[0] + if self.system not in ['Linux', 'Darwin', 'FreeBSD']: + raise Exception('Unknown system') + self.llvm_symbolizers = {} + self.last_llvm_symbolizer = None + self.dsym_hints = set([]) + self.frame_no = 0 + + def symbolize_address(self, addr, binary, offset): + # On non-Darwin (i.e. on platforms without .dSYM debug info) always use + # a single symbolizer binary. + # On Darwin, if the dsym hint producer is present: + # 1. check whether we've seen this binary already; if so, + # use |llvm_symbolizers[binary]|, which has already loaded the debug + # info for this binary (might not be the case for + # |last_llvm_symbolizer|); + # 2. otherwise check if we've seen all the hints for this binary already; + # if so, reuse |last_llvm_symbolizer| which has the full set of hints; + # 3. otherwise create a new symbolizer and pass all currently known + # .dSYM hints to it. + if not binary in self.llvm_symbolizers: + use_new_symbolizer = True + if self.system == 'Darwin' and self.dsym_hint_producer: + dsym_hints_for_binary = set(self.dsym_hint_producer(binary)) + use_new_symbolizer = bool(dsym_hints_for_binary - self.dsym_hints) + self.dsym_hints |= dsym_hints_for_binary + if self.last_llvm_symbolizer and not use_new_symbolizer: + self.llvm_symbolizers[binary] = self.last_llvm_symbolizer + else: + self.last_llvm_symbolizer = LLVMSymbolizerFactory( + self.system, guess_arch(addr), self.dsym_hints) + self.llvm_symbolizers[binary] = self.last_llvm_symbolizer + # Use the chain of symbolizers: + # Breakpad symbolizer -> LLVM symbolizer -> addr2line/atos + # (fall back to next symbolizer if the previous one fails). + if not binary in symbolizers: + symbolizers[binary] = ChainSymbolizer( + [BreakpadSymbolizerFactory(binary), self.llvm_symbolizers[binary]]) + result = symbolizers[binary].symbolize(addr, binary, offset) + if result is None: + # Initialize system symbolizer only if other symbolizers failed. + symbolizers[binary].append_symbolizer( + SystemSymbolizerFactory(self.system, addr, binary)) + result = symbolizers[binary].symbolize(addr, binary, offset) + # The system symbolizer must produce some result. + assert result + return result + + def get_symbolized_lines(self, symbolized_lines): + if not symbolized_lines: + return [self.current_line] + else: + result = [] + for symbolized_frame in symbolized_lines: + result.append(' #%s %s' % (str(self.frame_no), symbolized_frame.rstrip())) + self.frame_no += 1 + return result + + def process_logfile(self): + self.frame_no = 0 + while True: + line = logfile.readline() + if not line: + break + processed = self.process_line(line) + print '\n'.join(processed) + + def process_line(self, line): + self.current_line = line.rstrip() + #0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45) + stack_trace_line_format = ( + '^( *#([0-9]+) *)(0x[0-9a-f]+) *\((.*)\+(0x[0-9a-f]+)\)') + match = re.match(stack_trace_line_format, line) + if not match: + return [self.current_line] + if DEBUG: + print line + _, frameno_str, addr, binary, offset = match.groups() + if frameno_str == '0': + # Assume that frame #0 is the first frame of new stack trace. + self.frame_no = 0 + original_binary = binary + if self.binary_name_filter: + binary = self.binary_name_filter(binary) + symbolized_line = self.symbolize_address(addr, binary, offset) + if not symbolized_line: + if original_binary != binary: + symbolized_line = self.symbolize_address(addr, binary, offset) + return self.get_symbolized_lines(symbolized_line) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, + description='ASan symbolization script', + epilog='''Example of use: + asan_symbolize.py -c "$HOME/opt/cross/bin/arm-linux-gnueabi-" -s "$HOME/SymbolFiles" < asan.log''') + parser.add_argument('path_to_cut', nargs='*', + help='pattern to be cut from the result file path ') + parser.add_argument('-d','--demangle', action='store_true', + help='demangle function names') + parser.add_argument('-s', metavar='SYSROOT', + help='set path to sysroot for sanitized binaries') + parser.add_argument('-c', metavar='CROSS_COMPILE', + help='set prefix for binutils') + parser.add_argument('-l','--logfile', default=sys.stdin, type=argparse.FileType('r'), + help='set log file name to parse, default is stdin') + args = parser.parse_args() + if args.path_to_cut: + fix_filename_patterns = args.path_to_cut + if args.demangle: + demangle = True + if args.s: + binary_name_filter = sysroot_path_filter + sysroot_path = args.s + if args.c: + binutils_prefix = args.c + if args.logfile: + logfile = args.logfile + else: + logfile = sys.stdin + loop = SymbolizationLoop(binary_name_filter) + loop.process_logfile() diff --git a/scripts/launchpad_stats.py b/scripts/launchpad_stats.py new file mode 100644 index 000000000..0ea6fff2b --- /dev/null +++ b/scripts/launchpad_stats.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# See https://api.launchpad.net/+apidoc/devel.html#binary_package_publishing_history +# See https://help.launchpad.net/API/launchpadlib + +from launchpadlib.launchpad import Launchpad + +import os + +print 'Please, wait...' + +USERNAME='dismine' +PPA='valentina-dev' +PACKAGE='valentina' + +print 'Connect to Service.' + +cachedir = os.environ['HOME'] + '/.launchpadlib/cache/' +launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir) + +print 'Getting package information.' + +ppa = launchpad.people[USERNAME].getPPAByName(name=PPA) +bins = ppa.getPublishedBinaries(binary_name=PACKAGE) +builds = [] +total = 0 + +print 'Creation statistic.' + +for bin in bins: + count = bin.getDownloadCount() + total += count + if (count > 0): + builds.append([count,'%s %s' % (bin.binary_package_name,bin.binary_package_version)]) + +builds_sorted = sorted(builds,key=lambda count: count[0],reverse=True) + +for build in builds_sorted: + print '%s:%s' % (build[0], build[1]) + +print 'Total: %s' % (total) diff --git a/scripts/lrelease.sh b/scripts/lrelease.sh new file mode 100755 index 000000000..b8ee902fd --- /dev/null +++ b/scripts/lrelease.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Run this script if you want release all translated string in program. +# lrelease doesn't work with recursive *.pro file and without direct pointing to correct *.pro doesn't find anything. +# Please run this script from folder /scripts. +lrelease -removeidentical -nounfinished ../share/translations.pro diff --git a/scripts/lupdate.sh b/scripts/lupdate.sh new file mode 100755 index 000000000..86e89a0f8 --- /dev/null +++ b/scripts/lupdate.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Run this script if you want find and update all string in code. +# lupdate doesn't work with recursive *.pro file and without direct pointing to correct *.pro file just update exists strings in code. +# Please run this script from folder /scripts. +lupdate -recursive ../share/translations.pro diff --git a/scripts/makedoc.sh b/scripts/makedoc.sh index a81f00073..7ed988724 100755 --- a/scripts/makedoc.sh +++ b/scripts/makedoc.sh @@ -1,5 +1,10 @@ #!/bin/sh -# Script generate developer documentation for progect. -# Output directory doc/ -# Run from root directory of project +# Script generate developer documentation for whole progect. +# Output directories src/app/doc/, src/libs/qmuparser/doc/ +# Run from "scripts" directory +cd .. +cd src/app +doxygen doc/doxygen/Doxyfile +cd .. +cd libs/qmuparser doxygen doc/doxygen/Doxyfile diff --git a/share/Valentina-Logo_v1.png b/share/Valentina-Logo_v1.png new file mode 100644 index 000000000..cfe9cf475 Binary files /dev/null and b/share/Valentina-Logo_v1.png differ diff --git a/share/Valentina-Logo_v2.png b/share/Valentina-Logo_v2.png new file mode 100644 index 000000000..ae2f895cb Binary files /dev/null and b/share/Valentina-Logo_v2.png differ diff --git a/share/copyright_template.txt b/share/copyright_template.txt new file mode 100644 index 000000000..0d8dc9653 --- /dev/null +++ b/share/copyright_template.txt @@ -0,0 +1,27 @@ +/************************************************************************ + ** + ** @file %FILENAME% + ** @author Roman Telezhynskyi + ** @date %DAY% %MONTH%, %YEAR% + ** + ** @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) %YEAR% 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 . + ** + *************************************************************************/ diff --git a/share/coverity_model.cpp b/share/coverity_model.cpp new file mode 100644 index 000000000..874d94a73 --- /dev/null +++ b/share/coverity_model.cpp @@ -0,0 +1,17 @@ +/* Coverity Scan model + * + * This is a modeling file for Coverity Scan. Modeling helps to avoid false + * positives. + * + * - A model file can't import any header files. + * - Therefore only some built-in primitives like int, char and void are + * available but not wchar_t, NULL etc. + * - Modeling doesn't need full structs and typedefs. Rudimentary structs + * and similar types are sufficient. + * - An uninitialized local pointer is not an error. It signifies that the + * variable could be either NULL or have some data. + * + * Coverity Scan doesn't pick up modifications automatically. The model file + * must be uploaded by an admin in the analysis settings of + * http://scan.coverity.com/projects/1820 + */ diff --git a/share/resources/cursor/new_detail_cursor.png b/share/resources/cursor/new_detail_cursor.png deleted file mode 100644 index a2df3cbe6..000000000 Binary files a/share/resources/cursor/new_detail_cursor.png and /dev/null differ diff --git a/share/resources/cursor/pointcontact_cursor.png b/share/resources/cursor/pointcontact_cursor.png deleted file mode 100644 index 0501136db..000000000 Binary files a/share/resources/cursor/pointcontact_cursor.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowDown.png b/share/resources/icon/24x24/arrowDown.png deleted file mode 100644 index 817af191d..000000000 Binary files a/share/resources/icon/24x24/arrowDown.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowLeft.png b/share/resources/icon/24x24/arrowLeft.png deleted file mode 100644 index 9be8ca1bb..000000000 Binary files a/share/resources/icon/24x24/arrowLeft.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowLeftDown.png b/share/resources/icon/24x24/arrowLeftDown.png deleted file mode 100644 index f77bdf696..000000000 Binary files a/share/resources/icon/24x24/arrowLeftDown.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowLeftUp.png b/share/resources/icon/24x24/arrowLeftUp.png deleted file mode 100644 index 5f4024ad0..000000000 Binary files a/share/resources/icon/24x24/arrowLeftUp.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowRight.png b/share/resources/icon/24x24/arrowRight.png deleted file mode 100644 index 768ebaf7d..000000000 Binary files a/share/resources/icon/24x24/arrowRight.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowRightDown.png b/share/resources/icon/24x24/arrowRightDown.png deleted file mode 100644 index 7e5a1095b..000000000 Binary files a/share/resources/icon/24x24/arrowRightDown.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowRightUp.png b/share/resources/icon/24x24/arrowRightUp.png deleted file mode 100644 index 4a17aede6..000000000 Binary files a/share/resources/icon/24x24/arrowRightUp.png and /dev/null differ diff --git a/share/resources/icon/24x24/arrowUp.png b/share/resources/icon/24x24/arrowUp.png deleted file mode 100644 index bca77c6d1..000000000 Binary files a/share/resources/icon/24x24/arrowUp.png and /dev/null differ diff --git a/share/resources/icon/24x24/equal.png b/share/resources/icon/24x24/equal.png deleted file mode 100644 index ff7ca4845..000000000 Binary files a/share/resources/icon/24x24/equal.png and /dev/null differ diff --git a/share/resources/icon/24x24/putHere.png b/share/resources/icon/24x24/putHere.png deleted file mode 100644 index 00e4d8f1d..000000000 Binary files a/share/resources/icon/24x24/putHere.png and /dev/null differ diff --git a/share/resources/icon/24x24/putHereLeft.png b/share/resources/icon/24x24/putHereLeft.png deleted file mode 100644 index a69736efd..000000000 Binary files a/share/resources/icon/24x24/putHereLeft.png and /dev/null differ diff --git a/share/resources/icon/32x32/history.png b/share/resources/icon/32x32/history.png deleted file mode 100644 index fb6443942..000000000 Binary files a/share/resources/icon/32x32/history.png and /dev/null differ diff --git a/share/resources/icon/32x32/new_detail.png b/share/resources/icon/32x32/new_detail.png deleted file mode 100644 index ee90d379c..000000000 Binary files a/share/resources/icon/32x32/new_detail.png and /dev/null differ diff --git a/share/resources/icon/32x32/new_draw.png b/share/resources/icon/32x32/new_draw.png deleted file mode 100644 index aae524272..000000000 Binary files a/share/resources/icon/32x32/new_draw.png and /dev/null differ diff --git a/share/resources/icon/32x32/point_of_contact.png b/share/resources/icon/32x32/point_of_contact.png deleted file mode 100644 index 110aa8fdf..000000000 Binary files a/share/resources/icon/32x32/point_of_contact.png and /dev/null differ diff --git a/share/resources/icon/32x32/triangle.png b/share/resources/icon/32x32/triangle.png deleted file mode 100644 index c409b3b41..000000000 Binary files a/share/resources/icon/32x32/triangle.png and /dev/null differ diff --git a/share/resources/icon/64x64/icon64x64.ico b/share/resources/icon/64x64/icon64x64.ico deleted file mode 100644 index bddb86f9c..000000000 Binary files a/share/resources/icon/64x64/icon64x64.ico and /dev/null differ diff --git a/share/resources/icon/64x64/icon64x64.png b/share/resources/icon/64x64/icon64x64.png deleted file mode 100644 index d6cc04903..000000000 Binary files a/share/resources/icon/64x64/icon64x64.png and /dev/null differ diff --git a/share/resources/valentina.rc b/share/resources/valentina.rc deleted file mode 100644 index 2ab63e289..000000000 --- a/share/resources/valentina.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "icon/64x64/icon64x64.ico" diff --git a/share/translations.pro b/share/translations.pro new file mode 100644 index 000000000..108b2a8e3 --- /dev/null +++ b/share/translations.pro @@ -0,0 +1,38 @@ +# Don't use this pro file for building project!!! +# I made this hack for creation one TS file for whole project. +# Because we have several libraries that also have strings for translation, have several TS files for each +# subproject annoying. +# +# Original idea "How to generate a single translation file for a large Qt project?" +# https://stackoverflow.com/questions/1829474/how-to-generate-a-single-translation-file-for-a-large-qt-project + +TEMPLATE = app +DEPENDPATH += \ + ../src/app \ + ../src/libs/qmuparser \ + ../src/libs/vpropertyexplorer \ + ../src/libs/ifc \ + ../src/libs/vobj + +include(../src/app/app.pri) +include(../src/libs/qmuparser/qmuparser.pri) +include(../src/libs/vpropertyexplorer/vpropertyexplorer.pri) +include(../src/libs/ifc/ifc.pri) +include(../src/libs/vobj/vobj.pri) + +# Add here path to new translation file with name "valentina_*_*.ts" if you want to add new language. +# Same paths in variable INSTALL_TRANSLATIONS (app.pro). + +# File valentina.ts we use in transifex.com. It is empty translation file only with english inside. transifex.com use +# this file like base for new language. Don't add path to valentina.ts to INSTALL_TRANSLATIONS variable (app.pro). +# When adding a translation here, also add it in the macx part (app.pro). +TRANSLATIONS += translations/valentina.ts \ + translations/valentina_ru_RU.ts \ + translations/valentina_uk_UA.ts \ + translations/valentina_de_DE.ts \ + translations/valentina_cs_CZ.ts \ + translations/valentina_he_IL.ts \ + translations/valentina_fr_FR.ts \ + translations/valentina_it_IT.ts \ + translations/valentina_nl_NL.ts \ + translations/valentina_id_ID.ts diff --git a/share/translations/Localizable.strings b/share/translations/Localizable.strings new file mode 100644 index 000000000..0aab0801f --- /dev/null +++ b/share/translations/Localizable.strings @@ -0,0 +1 @@ +/* Intentionally empty */ diff --git a/share/translations/valentina.ts b/share/translations/valentina.ts new file mode 100644 index 000000000..7389c3bf9 --- /dev/null +++ b/share/translations/valentina.ts @@ -0,0 +1,6256 @@ + + + + + AddDet + + Add detail + + + + + AddPatternPiece + + Add pattern piece %1 + + + + + AddToCalc + + Add object + + + + + AddUnionDetails + + Add union details + + + + + CommunityPage + + Server + + + + Server name/IP + + + + Secure connection + + + + Proxy settings + + + + Use Proxy + + + + Proxy address + + + + Proxy port + + + + Proxy user + + + + Proxy pass + + + + User settings + + + + User Name + + + + Save password + + + + Password + + + + + ConfigDialog + + Apply + + + + &Cancel + + + + &Ok + + + + Config Dialog + + + + Configuration + + + + Pattern + + + + Community + + + + Paths + + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + + + + Default unit updated and will be used the next pattern creation + + + + Save + + + + Auto-save modified pattern + + + + min + + + + Interval: + + + + Language + + + + GUI language + + + + Decimal separator parts + + + + With OS options (%1) + + + + Default unit + + + + Centimeters + + + + Millimiters + + + + Inches + + + + Label language + + + + Send crash reports + + + + Send crash reports (recommended) + + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + + + + + DelTool + + Delete tool + + + + + DeleteDetail + + Delete tool + + + + + DeletePatternPiece + + Delete pattern piece %1 + + + + + DialogAboutApp + + About Valentina + + + + Valentina version + + + + Contributors + + + + Built on %3 at %4 + + + + Web site : %1 + + + + Warning + + + + Cannot open your default browser + + + + Build revision: + + + + + DialogAlongLine + + Point along line + + + + Length + + + + Insert variable into the formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + First point of line + + + + Second point + + + + Second point of line + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogArc + + Arc + + + + Radius + + + + Insert variable into the formula + + + + Calculate value + + + + Value of radius + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + First angle + + + + Insert variable into formula + + + + Value of first angle + + + + Second angle + + + + Insert marked variable into formula + + + + Value of second angle + + + + Center point + + + + Select point of center of arc + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Value of angle of line. + + + + Error + + + + Radius can't be negative + + + + Angles equal + + + + + DialogBisector + + Bisector + + + + Length + + + + Insert marked variable into the formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + First point of angle + + + + Second point + + + + Second point of angle + + + + Third point + + + + Third point of angle + + + + Type of line + + + + Show line from second point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of angle + + + + Select third point of angle + + + + + DialogCurveIntersectAxis + + Curve intersect axis + + + + Angle + + + + Calculate value + + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + Curve + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select axis point + + + + + DialogCutArc + + Cut arc + + + + Length + + + + Calculate value + + + + Value of length + + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Arc + + + + Selected curve + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSpline + + Cut curve + + + + Length + + + + Calculate value + + + + Value of length + + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + + + + Selected curve + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSplinePath + + Cut curve path + + + + Length + + + + Calculate value + + + + Value of length + + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + + + + Selected curve path + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogDetail + + Detail + + + + Bias X + + + + cm + + + + Bias Y + + + + Options + + + + Name of detail + + + + Seam allowance + + + + Width + + + + Closed + + + + Delete + + + + Got wrong scene object. Ignore. + + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + + + + Formula + + + + Insert variable into formula + + + + Calculate value + + + + Value of first angle + + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogEndLine + + Point in the end of a line + + + + Length + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Angle + + + + Value of angle + + + + Base point + + + + First point of line + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogHeight + + Height + + + + Point label + + + + Base point + + + + First point of line + + + + Second point of line + + + + Type of line + + + + Show line from first point to our point + + + + Select first point of line + + + + Select second point of line + + + + + DialogHistory + + History + + + + Tool + + + + Can't create record. + + + + %1 - Base point + + + + %1_%2 - Line from point %1 to point %2 + + + + %3 - Point along line %1_%2 + + + + %1 - Point of shoulder + + + + %3 - normal to line %1_%2 + + + + %4 - bisector of angle %1_%2_%3 + + + + %5 - intersection of lines %1_%2 and %3_%4 + + + + Curve %1_%2 + + + + Arc with center in point %1 + + + + Curve point %1 + + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + + + + Point of perpendicular from point %1 to line %2_%3 + + + + Triangle: axis %1_%2, points %3 and %4 + + + + %1 - point of intersection %2 and %3 + + + + %1 - cut arc with center %2 + + + + %1 - cut curve %2_%3 + + + + %1 - cut curve path %2 + + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + Increments + + + + Measurements + + + + Load another measurements table + + + + Personal information + + + + Given name + + + + Family name + + + + Birth date + + + + Sex + + + + Email + + + + Hide empty measurements + + + + Name + + + + The calculated value + + + + Base value + + + + In sizes + + + + In heights + + + + Description + + + + Lines + + + + Line + + + + Length + + + + Curves + + + + Curve + + + + Arcs + + + + Arc + + + + File error. + + + + male + + + + female + + + + Could not save GivenName + + + + Could not save FamilyName + + + + Could not save Email + + + + Could not save Sex + + + + Could not save BirthDate + + + + Measurements use different units than pattern. This pattern required measurements in %1 + + + + Individual measurements (*.vit) + + + + Open file + + + + Wrong units. + + + + Standard measurements (*.vst) + + + + Name_%1 + + + + Can't save measurement + + + + + DialogIndividualMeasurements + + Individual measurements + + + + Pattern piece name + + + + Exist measurements + + + + Path: + + + + Given name: + + + + Family name: + + + + New measurements + + + + Units: + + + + Could not create measurements file + + + + Please try again or change file + + + + File error. + + + + Individual measurements (*.vit) + + + + Open file + + + + Where save measurements? + + + + Centimeters + + + + Millimiters + + + + Inches + + + + + DialogLine + + Line + + + + First point + + + + Second point + + + + Type of line + + + + Show line from first point to this point + + + + Select second point + + + + + DialogLineIntersect + + Intersection of lines + + + + Point label + + + + First line + + + + First point + + + + Second point + + + + Second line + + + + Select second point of first line + + + + Select first point of second line + + + + Select second point of second line + + + + + DialogLineIntersectAxis + + Line intersect axis + + + + Angle + + + + Calculate value + + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + First line point + + + + Second line point + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select second point of line + + + + Select axis point + + + + + DialogMeasurements + + Measurements + + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + + + + Graduation + + + + Use for creation pattern standard measurement table + + + + Individual + + + + Use for creation pattern individual measurements + + + + + DialogNormal + + Normal + + + + Length + + + + Insert variable into formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + Second point + + + + Additional angle degrees + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogPatternProperties + + Pattern properties + + + + Description + + + + Author name + + + + Pattern description + + + + For technical notes. + + + + Heights and Sizes + + + + All heights (cm) + + + + All sizes (cm) + + + + + DialogPatternXmlEdit + + XML Editor + + + + Value : + + + + Name : + + + + <No selection> + + + + Type : + + + + Add attribute + + + + Add son + + + + Remove attribute + + + + Remove node + + + + Set + + + + Cancel + + + + Apply changes + + + + Undo last + + + + Immediate apply + + + + Base selection + + + + All pattern pieces + + + + No changes + + + + Cannot delete previously created node + + + + No changes left + + + + Cannot undo change + + + + <no value> + + + + Unchanged + + + + Cannot delete previously created attribute + + + + Node Name + + + + Name: + + + + Node Value (may be empty) + + + + Value: + + + + Attribute Name + + + + Attribute Value + + + + No selection + + + + Root node + + + + Node + + + + Attribute + + + + + DialogPointOfContact + + Point of contact + + + + Radius + + + + Insert variable into formula + + + + Calculate value + + + + Value of radius + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + Center of arc + + + + Select point of center of arc + + + + Top of the line + + + + End of the line + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula. + + + + Select second point of line + + + + + DialogPointOfIntersection + + Point of intersection + + + + Point label + + + + vertical point + + + + First point of angle + + + + horizontal point + + + + Second point of angle + + + + Select point horizontally + + + + + DialogShoulderPoint + + Point of shoulder + + + + Length + + + + Insert variable into formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + Second point + + + + Third point + + + + Type of line + + + + Show line from first point to our point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select first point of line + + + + Select second point of line + + + + + DialogSinglePoint + + Single point + + + + Coordinates on the sheet + + + + Coordinates + + + + Y coordinate + + + + X coordinate + + + + Point label + + + + + DialogSpline + + Curve + + + + First point + + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Second point + + + + Length ratio of the second control point + + + + The angle of the second control point + + + + Coefficient of curvature of the curve + + + + Select last point of curve + + + + + DialogSplinePath + + Curved path + + + + Point of curve + + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Length ratio of the second control point + + + + The angle of the second control point + + + + List of points + + + + Coefficient of curvature of the curve + + + + Select point of curve path + + + + + DialogStandardMeasurements + + Standard table + + + + Pattern piece name + + + + Standard measurements table + + + + File error. + + + + + DialogTool + + Error + + + + Empty field + + + + Value can't be 0 + + + + Value + + + + Height + + + + Size + + + + Line length + + + + Arc length + + + + Curve length + + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + + + + Point label + + + + First point of axis + + + + First point of line + + + + Second point of axis + + + + First point + + + + Second point + + + + Select second point of axis + + + + Select first point + + + + Select second point + + + + + DialogUndo + + Broken formula + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + + &Undo + + + + &Fix formula + + + + &Cancel + + + + + DialogUnionDetails + + Union details + + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + + + Select first point + + + + Select second point + + + + Select another second point + + + + Select detail + + + + + Functions + + sin + sine function + + + + cos + cosine function + + + + tan + tangens function + + + + asin + arcus sine function + + + + acos + arcus cosine function + + + + atan + arcus tangens function + + + + sinh + hyperbolic sine function + + + + cosh + hyperbolic cosine + + + + tanh + hyperbolic tangens function + + + + asinh + hyperbolic arcus sine function + + + + acosh + hyperbolic arcus tangens function + + + + atanh + hyperbolic arcur tangens function + + + + log2 + logarithm to the base 2 + + + + log10 + logarithm to the base 10 + + + + log + logarithm to the base 10 + + + + ln + logarithm to base e (2.71828...) + + + + exp + e raised to the power of x + + + + sqrt + square root of a value + + + + sign + sign function -1 if x<0; 1 if x>0 + + + + rint + round to nearest integer + + + + abs + absolute value + + + + min + min of all arguments + + + + max + max of all arguments + + + + sum + sum of all arguments + + + + avg + mean value of all arguments + + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + Valentina + + + + Tools for creating points. + + + + Point + + + + Point along perpendicular + + + + Special point on shoulder. + + + + Tool triangle. + + + + Perpendicular point along line + + + + Point along bisector + + + + Point at intersection of arc and line. + + + + Tool to make point from x & y of two other points. + + + + Point at distance and angle + + + + Point at distance along line + + + + Point of intersection line and axis + + + + ... + + + + Tools for creating lines. + + + + Line + + + + Line between points + + + + Point at line intersection + + + + Tools for creating curves. + + + + Curve + + + + Curve tool. + + + + Tool for path curve. + + + + Tool for segmenting a curve. + + + + Tool segment a pathed curve. + + + + Tools for creating arcs. + + + + Arc + + + + Arc tool. + + + + Cut arc tool. + + + + Tools for creating details. + + + + Detail + + + + Tool new detail. + + + + Tool for union two details. + + + + &File + + + + &Help + + + + &Pattern piece + + + + Measurements + + + + Window + + + + Toolbar files + + + + ToolBar modes + + + + Toolbar pattern + + + + Toolbar options + + + + Toolbar tools + + + + Tool options + + + + New + + + + &New + + + + Create a new pattern + + + + Ctrl+N + + + + Open + + + + &Open + + + + Open file with pattern + + + + Save + + + + &Save + + + + Save pattern + + + + Ctrl+S + + + + Save &As... + + + + Save not yet saved pattern + + + + Ctrl+Shift+S + + + + Draw + + + + Draw mode + + + + Ctrl+W + + + + Details + + + + Details mode + + + + Ctrl+E + + + + Pointer tools + + + + New pattern piece + + + + Add new pattern piece + + + + Ctrl+Shift+N + + + + Change the label of pattern piece + + + + Table of variables + + + + Tables of variables + + + + Ctrl+T + + + + History + + + + Ctrl+H + + + + Export pattern (layout) + + + + Create layout + + + + Ctrl+L + + + + About &Qt + + + + &About Valentina + + + + E&xit + + + + Exit the application + + + + Ctrl+Q + + + + Preferences + + + + Pattern properties + + + + Zoom in + + + + zoom in + + + + Zoom out + + + + Edit pattern XML code + + + + Original zoom + + + + Original Zoom + + + + Zoom fit best + + + + Ctrl+= + + + + Stop + + + + Stop using tool + + + + Repot Bug... + + + + Report bug + + + + Close window + + + + Online help + + + + Show online help + + + + Pattern piece %1 + + + + Individual measurements is under development + + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + Select point + + + + Select first point + + + + Select first point of line + + + + Select first point of angle + + + + Select first point of first line + + + + Select first point curve + + + + Select simple curve + + + + Select point of center of arc + + + + Select point of curve path + + + + Select curve path + + + + Select points, arcs, curves clockwise. + + + + Select base point + + + + Select first point of axis + + + + Select point vertically + + + + Select detail + + + + Select arc + + + + Select curve + + + + About Qt + + + + Height: + + + + Size: + + + + Pattern Piece: + + + + Pattern files (*.val) + + + + pattern + + + + /pattern.val + + + + Save as + + + + Could not save file + + + + Open file + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Bad id. + + + + File saved + + + + untitled.val + + + + Unsaved change + + + + The pattern has been modified. +Do you want to save your changes? + + + + &Undo + + + + &Redo + + + + Pattern piece: + + + + Enter a new label for the pattern piece. + + + + This file already opened in another window. + + + + Wrong units. + + + + Application doesn't support standard table with inches. + + + + File error. + + + + File loaded + + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + + + + Reopen files. + + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + + + + could not be found. Do you want to update the file location + + + + Standard measurements (*.vst) + + + + Individual measurements (*.vit) + + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + + + + Around middle part of Neck + Full measurement description + + + + Around Neck at base + Full measurement description + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + NeckPoint to ShoulderTip + Full measurement description + + + + Armpit to Waist side + Full measurement description + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + Around HighHip, parallel to floor + Full measurement description + + + + Around Hip, parallel to floor + Full measurement description + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + + + + Back Waist side to side + Full measurement description + + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + + + + Around Calf + Full measurement description + + + + Around Ankle + Full measurement description + + + + Knee to Floor + Full measurement description + + + + Ankle to Floor + Full measurement description + + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + + + + Waist side to Hip + Full measurement description + + + + Waist side to Knee + Full measurement description + + + + Crotch to Floor along inside leg + Full measurement description + + + + Size + Full measurement description + + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + + + + Head height + Full measurement description + + + + Body position + Full measurement description + + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + + + + Mid-neck girth + Full measurement name + + + + Neck Base girth + Full measurement name + + + + Head and Neck length + Full measurement name + + + + Front Center length + Full measurement name + + + + Back Center length + Full measurement name + + + + Shoulder length + Full measurement name + + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + + + + Shoulder girth + Full measurement name + + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + + + + HighHip girth + Full measurement name + + + + Hip girth + Full measurement name + + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + + + + Shoulder height + Full measurement name + + + + Head height + Full measurement name + + + + Body position + Full measurement name + + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + + + + + MoveSpline + + Move spline + + + + + MoveSplinePath + + Move spline path + + + + + PathPage + + Open Directory + + + + Path that use Valentina + + + + Default + + + + Edit + + + + Type + + + + Path + + + + Individual measurements + + + + Patterns + + + + + PatternPage + + User + + + + User name + + + + Graphical output + + + + Use antialiasing + + + + Undo + + + + Count steps (0 - no limit) + + + + + PostfixOperators + + cm + centimeter + + + + mm + millimeter + + + + in + inch + + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + + + + Add node + + + + Move detail + + + + mm + + + + cm + + + + inch + + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + Save detail option + + + + + SaveToolOptions + + Save tool option + + + + + TableWindow + + Create a layout + + + + toolBar + + + + Save + + + + Save layout + + + + Next + + + + Next detail + + + + Turn + + + + Turn the detail 90 degrees + + + + Stop + + + + Stop laying + + + + Enlarge letter + + + + Enlarge the length of the sheet + + + + Reduce sheet + + + + Reduce the length of the sheet + + + + Mirroring + + + + Zoom In + + + + Zoom Out + + + + 0 details left. + + + + Collisions not found. + + + + %1 details left. + + + + untitled + + + + Svg files (*.svg) + + + + PDF files (*.pdf) + + + + Images (*.png) + + + + PS files (*.ps) + + + + EPS files (*.eps) + + + + Collisions found. + + + + Creating file '%1' failed! %2 + + + + Critical error! + + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + + + + Do you really want delete? + + + + + VApplication + + Error parsing file. Program will be terminated. + + + + Error bad id. Program will be terminated. + + + + Error can't convert value. Program will be terminated. + + + + Error empty parameter. Program will be terminated. + + + + Error wrong id. Program will be terminated. + + + + Something's wrong!! + + + + + VContainer + + Can't find object + + + + Can't cast object + + + + Can't find object. Type mismatch. + + + + + VDomDocument + + Can't convert toUInt parameter + + + + Can't convert toBool parameter + + + + Got empty parameter + + + + Can't convert toDouble parameter + + + + Can't open file %1: +%2. + + + + Can't open schema file %1: +%2. + + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + + + + Parsing error file %3 in line %1 column %2 + + + + Couldn't get node + + + + Got wrong parameter id. Need only id > 0. + + + + This id is not unique. + + + + Could not copy temp file to document file + + + + Could not remove document file + + + + + VDrawTool + + Edit wrong formula + + + + Options + + + + Delete + + + + + VException + + Critical error! + + + + + VFormula + + Error + + + + + VFormulaProperty + + Value + + + + Formula + + + + + VPE::VBoolProperty + + True + + + + False + + + + + VPE::VFileEditWidget + + Directory + + + + Open File + + + + + VPattern + + Can't find tool in table. + + + + Error no unique id. + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Error creating or updating detail + + + + Error creating or updating single point + + + + Error creating or updating point of end line + + + + Error creating or updating point along line + + + + Error creating or updating point of shoulder + + + + Error creating or updating point of normal + + + + Error creating or updating point of bisector + + + + Error creating or updating point of lineintersection + + + + Error creating or updating point of contact + + + + Error creating or updating modeling point + + + + Error creating or updating height + + + + Error creating or updating triangle + + + + Error creating or updating point of intersection + + + + Error creating or updating cut spline point + + + + Error creating or updating cut spline path point + + + + Error creating or updating cut arc point + + + + Error creating or updating point of intersection line and axis + + + + Error creating or updating point of intersection curve and axis + + + + Error creating or updating line + + + + Error creating or updating simple curve + + + + Error creating or updating curve path + + + + Error creating or updating modeling simple curve + + + + Error creating or updating modeling curve path + + + + Error creating or updating simple arc + + + + Error creating or updating modeling arc + + + + Error creating or updating union details + + + + File error. + + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + + + + This spline does not exist. + + + + Can't cut spline path with one point + + + + + VTableGraphicsView + + can't find detail + + + + detail found + + + + + VToolDetail + + Options + + + + Delete + + + + + VToolOptionsPropertyBrowser + + Base point + + + + Point label + + + + Position + + + + Point at distance and angle + + + + Line type + + + + Length + + + + Angle + + + + Point at distance along line + + + + Arc + + + + Radius + + + + First angle + + + + Second angle + + + + Point along bisector + + + + Cut arc tool + + + + Tool for segmenting a curve + + + + Tool segment a pathed curve + + + + Perpendicular point along line + + + + Line between points + + + + Point at line intersection + + + + Point along perpendicular + + + + Additional angle degrees + + + + Point at intersection of arc and line + + + + Tool to make point from x & y of two other points + + + + Special point on shoulder + + + + Curve tool + + + + Curve factor + + + + Tool for path curve + + + + Tool triangle + + + + Point intersection line and axis + + + + + Variables + + Line_ + Left symbol _ in name + + + + AngleLine_ + Left symbol _ in name + + + + Arc_ + Left symbol _ in name + + + + Spl_ + Left symbol _ in name + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + + + + Pattern file. + + + + diff --git a/share/translations/valentina_cs_CZ.ts b/share/translations/valentina_cs_CZ.ts new file mode 100644 index 000000000..b3cc1b8d6 --- /dev/null +++ b/share/translations/valentina_cs_CZ.ts @@ -0,0 +1,6279 @@ + + + + + AddDet + + Add detail + Přidat detail + + + + AddPatternPiece + + Add pattern piece %1 + Přidat díl střihu %1 + + + + AddToCalc + + Add object + Přidat předmět + + + + AddUnionDetails + + Add union details + Přidat detaily spojky + + + + CommunityPage + + Server + Server + + + Server name/IP + Název serveru/IP + + + Secure connection + Bezpečné připojení + + + Proxy settings + Nastavení proxy + + + Use Proxy + Použít proxy + + + Proxy address + Adresa proxy + + + Proxy port + Přípojka proxy + + + Proxy user + Uživatel proxy + + + Proxy pass + Heslo proxy + + + User settings + Uživatelská nastavení + + + User Name + Uživatelské jméno + + + Save password + Uložit heslo + + + Password + Heslo + + + + ConfigDialog + + Apply + Použít + + + &Cancel + Z&rušit + + + &Ok + &OK + + + Config Dialog + Dialog pro nastavení + + + Configuration + Nastavení + + + Pattern + Střih + + + Community + Společenství + + + Paths + Cesty + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + + + + Default unit updated and will be used the next pattern creation + + + + Save + Uložit + + + Auto-save modified pattern + Automaticky uložit změněný střih + + + min + min + + + Interval: + Interval: + + + Language + Jazyk + + + GUI language + Jazyk rozhraní + + + Decimal separator parts + Oddělovač desetinných míst + + + With OS options (%1) + S možnostmi OS (%1) + + + Default unit + Výchozí jednotka + + + Centimeters + Centimetry + + + Millimiters + Milimetry + + + Inches + Palce + + + Label language + + + + Send crash reports + Poslat hlášení o pádu + + + Send crash reports (recommended) + Poslat hlášení o pádu (doporučeno) + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + + + + + DelTool + + Delete tool + Smazat nástroj + + + + DeleteDetail + + Delete tool + Smazat nástroj + + + + DeletePatternPiece + + Delete pattern piece %1 + Smazat díl střihu %1 + + + + DialogAboutApp + + About Valentina + O programu Valentina + + + Valentina version + Verze Valentiny + + + Contributors + Přispěvatelé + + + Based on Qt %2 (32 bit) + Založeno na Qt %2 (32 bit) + + + Built on %3 at %4 + Sestaveno %3 v %4 + + + Web site : %1 + Stránky: %1 + + + Warning + Varování + + + Cannot open your default browser + Nelze otevřít váš výchozí prohlížeč + + + Build revision: + + + + + DialogAlongLine + + Point along line + Bod podél čáry + + + Length + Délka + + + Insert variable into the formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Point label + Označení bodu + + + First point + První bod + + + First point of line + První bod čáry + + + Second point + Druhý bod + + + Second point of line + Druhý bod čáry + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + Select second point of line + Vybrat druhý bod čáry + + + + DialogArc + + Arc + Oblouk + + + Radius + Poloměr + + + Insert variable into the formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of radius + Hodnota poloměru + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + First angle + První úhel + + + Insert variable into formula + Vložit proměnnou do vzorce + + + Value of first angle + Hodnota prvního úhlu + + + Second angle + Druhý úhel + + + Insert marked variable into formula + Vložit označenou proměnnou do vzorce + + + Value of second angle + Hodnota druhého úhlu + + + Center point + Bod ve středu + + + Select point of center of arc + Vybrat bod středu oblouku + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables + Proměnné + + + Value of angle of line. + Hodnota úhlu čáry. + + + Error + Chyba + + + Radius can't be negative + + + + Angles equal + + + + + DialogBisector + + Bisector + Osa souměrnosti úhlu + + + Length + Délka + + + Insert marked variable into the formula + Vložit označenou proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Point label + Označení bodu + + + First point + První bod + + + First point of angle + První bod úhlu + + + Second point + Druhý bod + + + Second point of angle + Druhý bod úhlu + + + Third point + Třetí bod + + + Third point of angle + Třetí bod úhlu + + + Type of line + Typ čáry + + + Show line from second point to this point + Ukázat čáru od druhého bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + Select second point of angle + Vybrat druhý bod úhlu + + + Select third point of angle + Vybrat třetí bod úhlu + + + + DialogCurveIntersectAxis + + Curve intersect axis + Osa průsečíku křivky + + + Angle + Úhel + + + Calculate value + Vypočítat hodnotu + + + Value of angle + Hodnota úhlu + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Axis point + Bod osy + + + First point of line + První bod čáry + + + Curve + Křivka + + + Point label + Označení bodu + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables + Proměnné + + + Select axis point + Vybrat bod osy + + + + DialogCutArc + + Cut arc + Vyjmout oblouk + + + Length + Délka + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Arc + Oblouk + + + Selected curve + Vybraná křivka + + + Point label + Označení bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + + DialogCutSpline + + Cut curve + Vyjmout úhel + + + Length + Délka + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Curve + Křivka + + + Selected curve + Vybraná křivka + + + Point label + Označení bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + + DialogCutSplinePath + + Cut curve path + Vyjmout cestu křivky + + + Length + Délka + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Curve + Křivka + + + Selected curve path + Vybraná cesta křivky + + + Point label + Označení bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + + DialogDetail + + Detail + Detail + + + Bias X + Odchylka X + + + cm + cm + + + Bias Y + Odchylka Y + + + Options + Volby + + + Name of detail + Název detailu + + + Seam allowance + Přídavek na šev + + + Width + Šířka + + + Closed + Zavřeno + + + Delete + Smazat + + + Got wrong scene object. Ignore. + Obdržen nesprávný předmět scény. Přehlížet. + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + Upravit vzorec + + + Formula + Vzorec + + + Insert variable into formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of first angle + Hodnota prvního úhlu + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables + Proměnné + + + + DialogEndLine + + Point in the end of a line + Bod na konci čáry + + + Length + Délka + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Angle + Úhel + + + Value of angle + Hodnota úhlu + + + Base point + Základní bod + + + First point of line + První bod čáry + + + Point label + Označení bodu + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables + Proměnné + + + + DialogHeight + + Height + Výška + + + Point label + Označení bodu + + + Base point + Základní bod + + + First point of line + První bod čáry + + + Second point of line + Druhý bod čáry + + + Type of line + Typ čáry + + + Show line from first point to our point + Ukázat čáru od prvního bodu k našemu bodu + + + Select first point of line + Vybrat první bod čáry + + + Select second point of line + Vybrat druhý bod čáry + + + + DialogHistory + + History + Historie + + + Tool + Nástroj + + + Can't create record. + Nelze vytvořit záznam. + + + %1 - Base point + %1 - Základní bod + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - Čára od bodu %1 k bodu %2 + + + %3 - Point along line %1_%2 + %3 - Bod podél čáry %1_%2 + + + %1 - Point of shoulder + %1 - Bod ramene + + + %3 - normal to line %1_%2 + %3 - Kolmice k čáře %1_%2 + + + %4 - bisector of angle %1_%2_%3 + %4 - Osa úhlu %1_%2_%3 + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - Průsečík čar %1_%2 a %3_%4 + + + Curve %1_%2 + Křivka %1_%2 + + + Arc with center in point %1 + Oblouk se středem v bodě %1 + + + Curve point %1 + Bod křivky %1 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + + + + Point of perpendicular from point %1 to line %2_%3 + + + + Triangle: axis %1_%2, points %3 and %4 + Trojúhelník: osa %1_%2, body %3 a %4 + + + %1 - point of intersection %2 and %3 + %1 - Bod průsečíku %2 a %3 + + + %1 - cut arc with center %2 + %1 - Vyjmout oblouk se středem %2 + + + %1 - cut curve %2_%3 + %1 - Vyjmout křivku %2_%3 + + + %1 - cut curve path %2 + %1 - Vyjmout cestu křivky %2 + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + Increments + Přídavky + + + Measurements + Míry + + + Load another measurements table + Načíst jinou tabulku s mírami + + + Personal information + Osobní informace + + + Given name + Křestní jméno + + + Family name + Příjmení + + + Birth date + Datum narození + + + Sex + Pohlaví + + + Email + E-mail + + + Hide empty measurements + Skrýt prázdné míry + + + Name + Název + + + The calculated value + Vypočítaná hodnota + + + Base value + Základní hodnota + + + In sizes + Ve velikostech + + + In heights + O výškách + + + Description + Popis + + + Lines + Čáry + + + Line + Čára + + + Length + Délka + + + Curves + Křivky + + + Curve + Křivka + + + Arcs + Oblouky + + + Arc + Oblouk + + + File error. + Chyba souboru. + + + male + Muž + + + female + Žena + + + Could not save GivenName + Nepodařilo se uložit křestní jméno + + + Could not save FamilyName + Nepodařilo se uložit příjmení + + + Could not save Email + Nepodařilo se uložit adresu elektronické pošty + + + Could not save Sex + Nepodařilo se uložit pohlaví + + + Could not save BirthDate + Nepodařilo se uložit datum narození + + + Measurements use different units than pattern. This pattern required measurements in %1 + Míry používají odlišné jednotky než střihy. Tento střih vyžaduje míry v %1 + + + Individual measurements (*.vit) + Osobité míry (*.vit) + + + Open file + Otevřít soubor + + + Wrong units. + Nesprávné jednotky. + + + Standard measurements (*.vst) + Obvyklé míry (*.vst) + + + Name_%1 + Jméno_%1 + + + Can't save measurement + Nelze uložit míry + + + + DialogIndividualMeasurements + + Individual measurements + Osobité míry + + + Pattern piece name + Název dílu střihu + + + Exist measurements + Stávající míry + + + Path: + Cesta: + + + Given name: + Křestní jméno: + + + Family name: + Příjmení: + + + New measurements + Nové míry + + + Units: + Jednotky: + + + Could not create measurements file + Nepodařilo se vytvořit soubor s mírami + + + Please try again or change file + Zkuste to, prosím, znovu, anebo změňte soubor + + + File error. + Chyba souboru. + + + Individual measurements (*.vit) + Osobité míry (*.vit) + + + Open file + Otevřít soubor + + + Where save measurements? + Kam míry uložit? + + + Centimeters + Centimetry + + + Millimiters + Milimitry + + + Inches + Palce + + + + DialogLine + + Line + Čára + + + First point + První bod + + + Second point + Druhý bod + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Select second point + Vybrat druhý bod + + + + DialogLineIntersect + + Intersection of lines + Průsečík čar + + + Point label + Označení bodu + + + First line + První čára + + + First point + První bod + + + Second point + Druhý bod + + + Second line + Druhá čára + + + Select second point of first line + Vybrat druhý bod první čáry + + + Select first point of second line + Vybrat první bod druhé čáry + + + Select second point of second line + Vybrat druhý bod druhé čáry + + + + DialogLineIntersectAxis + + Line intersect axis + Osa průsečíku čáry + + + Angle + Úhel + + + Calculate value + Vypočítat hodnotu + + + Value of angle + Hodnota úhlu + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Axis point + Bod osy + + + First point of line + První bod čáry + + + First line point + První bod čáry + + + Second line point + Druhý bod čáry + + + Point label + Označení bodu + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables + Proměnné + + + Select second point of line + Vybrat druhý bod čáry + + + Select axis point + Vybrat bod osy + + + + DialogMeasurements + + Measurements + Míry + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + <html><head/><body><p><span style=" font-size:18pt;">Vyberte, prosím, typ střihu.</span></p></body></html> + + + Graduation + Stupňování + + + Use for creation pattern standard measurement table + Pro vytvoření střihu použít tabulku obvyklých měr + + + Individual + Osobité + + + Use for creation pattern individual measurements + Pro vytvoření střihu použít osobité míry + + + + DialogNormal + + Normal + Kolmice + + + Length + Délka + + + Insert variable into formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Point label + Označení bodu + + + First point + První bod + + + Second point + Druhý bod + + + Additional angle degrees + Dodatečné úhlové stupně + + + Type of line + Typ čáry + + + Show line from first point to this point + Ukázat čáru od prvního bodu k tomuto bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + Select second point of line + Vybrat druhý bod čáry + + + + DialogPatternProperties + + Pattern properties + Vlastnosti střihu + + + Description + Popis + + + Author name + Jméno autora + + + Pattern description + Popis střihu + + + For technical notes. + Pro technické poznámky. + + + Heights and Sizes + Výšky a velikosti + + + All heights (cm) + Všechny výšky (cm) + + + All sizes (cm) + Všechny velikosti (cm) + + + + DialogPatternXmlEdit + + XML Editor + Editor XML + + + Value : + Hodnota: + + + Name : + Název: + + + <No selection> + <Žádný výběr> + + + Type : + Typ: + + + Add attribute + Přidat vlastnost + + + Add son + Přidat potomka + + + Remove attribute + Odstranit vlastnost + + + Remove node + Odstranit uzel + + + Set + Nastavit + + + Cancel + Zrušit + + + Apply changes + Použít změny + + + Undo last + Zpět poslední + + + Immediate apply + Použít okamžitě + + + Base selection + Základní výběr + + + All pattern pieces + Všechny díly střihu + + + No changes + Žádné změny + + + Cannot delete previously created node + Nelze smazat předtím vytvořený uzel + + + No changes left + Nezůstaly žádné změny + + + Cannot undo change + Změnu nelze vrátit zpět + + + <no value> + <Žádná hodnota> + + + Unchanged + Nezměněno + + + Cannot delete previously created attribute + Nelze smazat předtím vytvořenou vlastnost + + + Node Name + Název uzlu + + + Name: + Název: + + + Node Value (may be empty) + Hodnota uzlu (může být ponecháno prázdné) + + + Value: + Hodnota: + + + Attribute Name + Název vlastnosti + + + Attribute Value + Hodnota vlastnosti + + + No selection + Žádný výběr + + + Root node + Kořenový uzel + + + Node + Uzel + + + Attribute + Vlastnost + + + + DialogPointOfContact + + Point of contact + Bod dotyku + + + Radius + Poloměr + + + Insert variable into formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of radius + Hodnota poloměru + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Point label + Označení bodu + + + Center of arc + Střed oblouku + + + Select point of center of arc + Vybrat bod středu oblouku + + + Top of the line + Začátek čáry + + + End of the line + Konec čáry + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula. + Proměnné - Klepněte dvakrát pro vložení do vzorce. + + + Select second point of line + Vybrat druhý bod čáry + + + + DialogPointOfIntersection + + Point of intersection + Bod průsečíku + + + Point label + Označení bodu + + + vertical point + Svislý bod + + + First point of angle + První bod úhlu + + + horizontal point + Vodorovný bod + + + Second point of angle + Druhý bod úhlu + + + Select point horizontally + Vybrat bod vodorovně + + + + DialogShoulderPoint + + Point of shoulder + Bod ramene + + + Length + Délka + + + Insert variable into formula + Vložit proměnnou do vzorce + + + Calculate value + Vypočítat hodnotu + + + Value of length + Hodnota délky + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Ukázat celý výpočet v okně se zprávami</p></body></html> + + + Point label + Označení bodu + + + First point + První bod + + + Second point + Druhý bod + + + Third point + Třetí bod + + + Type of line + Typ čáry + + + Show line from first point to our point + Ukázat čáru od prvního bodu k našemu bodu + + + Input data + Vstupní data + + + Size and height + Velikost a výška + + + Measurements + Míry + + + Increments + Přídavky + + + Length of lines + Délka čar + + + Length of arcs + Délka oblouků + + + Length of curves + Délka křivek + + + Angle of lines + Úhel čar + + + Hide empty measurements + Skrýt prázdné míry + + + Variables - Click twice to insert into formula + Proměnné - Klepněte dvakrát pro vložení do vzorce + + + Select first point of line + Vybrat první bod čáry + + + Select second point of line + Vybrat druhý bod čáry + + + + DialogSinglePoint + + Single point + Jeden bod + + + Coordinates on the sheet + Souřadnice na listu + + + Coordinates + Souřadnice + + + Y coordinate + Souřadnice y + + + X coordinate + Souřadnice x + + + Point label + Označení bodu + + + + DialogSpline + + Curve + Křivka + + + First point + První bod + + + Length ratio of the first control point + Poměr délky prvního ovládacího bodu + + + The angle of the first control point + Úhel prvního ovládacího bodu + + + Second point + Druhý bod + + + Length ratio of the second control point + Poměr délky druhého ovládacího bodu + + + The angle of the second control point + Úhel druhého ovládacího bodu + + + Coefficient of curvature of the curve + Součinitel zakřivení křivky + + + Select last point of curve + Vybrat poslední bod čáry + + + + DialogSplinePath + + Curved path + Cesta křivky + + + Point of curve + Bod křivky + + + Length ratio of the first control point + Poměr délky prvního ovládacího bodu + + + The angle of the first control point + Úhel prvního ovládacího bodu + + + Length ratio of the second control point + Poměr délky druhého ovládacího bodu + + + The angle of the second control point + Úhel druhého ovládacího bodu + + + List of points + Seznam bodů + + + Coefficient of curvature of the curve + Součinitel zakřivení křivky + + + Select point of curve path + Vybrat bod cesty křivky + + + + DialogStandardMeasurements + + Standard table + Standardní tabulka + + + Pattern piece name + Název dílu střihu + + + Standard measurements table + Tabulka s obvyklými mírami + + + File error. + Chyba souboru. + + + + DialogTool + + Error + Chyba + + + Empty field + Prázdné pole + + + Value can't be 0 + Hodnota nemůže být 0 + + + Value + Hodnota + + + Height + Výška + + + Size + Velikost + + + Line length + Délka čáry + + + Arc length + Délka oblouku + + + Curve length + Délka křivky + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + Trojúhelník + + + Point label + Označení bodu + + + First point of axis + První bod osy + + + First point of line + První bod čáry + + + Second point of axis + Druhý bod osy + + + First point + První bod + + + Second point + Druhý bod + + + Select second point of axis + Vybrat druhý bod osy + + + Select first point + Vybrat první bod + + + Select second point + Vybrat druhý bod + + + + DialogUndo + + Broken formula + Poškozený vzorec + + + Error while calculation formula. You can try undo last operation or fix broken formula. + Chyba při počítání vzorce. Můžete zkusit vrátit poslední operaci zpět, anebo opravit poškozený vzorec. + + + &Undo + &Zpět + + + &Fix formula + &Opravit vzorec + + + &Cancel + Z&rušit + + + + DialogUnionDetails + + Union details + Sjednotit detaily + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><p>Opravdu chcete sjednotit detaily?</p></body></html> + + + Select first point + Vybrat první bod + + + Select second point + Vybrat druhý bod + + + Select another second point + Vybrat jiný druhý bod + + + Select detail + Vybrat detail + + + + Functions + + sin + sine function + sin + + + cos + cosine function + cos + + + tan + tangens function + tan + + + asin + arcus sine function + asin + + + acos + arcus cosine function + acos + + + atan + arcus tangens function + atan + + + sinh + hyperbolic sine function + sinh + + + cosh + hyperbolic cosine + cosh + + + tanh + hyperbolic tangens function + tanh + + + asinh + hyperbolic arcus sine function + asinh + + + acosh + hyperbolic arcus tangens function + acosh + + + atanh + hyperbolic arcur tangens function + atanh + + + log2 + logarithm to the base 2 + log2 + + + log10 + logarithm to the base 10 + log10 + + + log + logarithm to the base 10 + log + + + ln + logarithm to base e (2.71828...) + ln + + + exp + e raised to the power of x + exp + + + sqrt + square root of a value + sqrt + + + sign + sign function -1 if x<0; 1 if x>0 + sign + + + rint + round to nearest integer + rint + + + abs + absolute value + abs + + + min + min of all arguments + min + + + max + max of all arguments + max + + + sum + sum of all arguments + sum + + + avg + mean value of all arguments + avg + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Nástroje na vytváření bodů. + + + Point + Bod + + + Point along perpendicular + Bod podél v pravém úhlu + + + Special point on shoulder. + Zvláštní bod na rameni. + + + Tool triangle. + Nástroj trojúhelník. + + + Perpendicular point along line + Bod v pravém úhlu podél čáry + + + Point along bisector + Bod podél osy úhlu + + + Point at intersection of arc and line. + Bod v průsečíku oblouku a čáry. + + + Tool to make point from x & y of two other points. + Nástroj na udělání bodu z x a y dvou jiných bodů. + + + Point at distance and angle + Bod ve vzdálenosti a úhlu + + + Point at distance along line + Bod ve vzdálenosti podél čáry + + + Point of intersection line and axis + Bod průsečíku čáry a úhlu + + + ... + ... + + + Tools for creating lines. + Nástroje na vytváření čar. + + + Line + Čára + + + Line between points + Čára mezi body + + + Point at line intersection + Bod na průsečíku čar + + + Tools for creating curves. + Nástroje na vytváření křivek. + + + Curve + Křivka + + + Curve tool. + Nástroj na křivku. + + + Tool for path curve. + Nástroj pro křivku cesty. + + + Tool for segmenting a curve. + Nástroj pro rozdělení křivky. + + + Tool segment a pathed curve. + Nástroj pro rozdělení cesty křivky. + + + Tools for creating arcs. + Nástroje na vytváření oblouků. + + + Arc + Oblouk + + + Arc tool. + Nástroj na oblouk. + + + Cut arc tool. + Nástroj na vyjmutí oblouku. + + + Tools for creating details. + Nástroje na vytváření detailů. + + + Detail + Detail + + + Tool new detail. + Nástroj pro nový detail. + + + Tool for union two details. + Nástroj na spojení dvou detailů. + + + &File + &Soubor + + + &Help + &Nápověda + + + &Pattern piece + &Díl střihu + + + Measurements + Míry + + + Window + Okno + + + Toolbar files + Nástrojový pruh Soubory + + + ToolBar modes + Nástrojový pruh Režimy + + + Toolbar pattern + Nástrojový pruh Střihy + + + Toolbar options + Nástrojový pruh Volby + + + Toolbar tools + Nástrojový pruh Nástroje + + + Tool options + Volby pro nástroje + + + New + Nový + + + &New + &Nový + + + Create a new pattern + Vytvořit nový vzor + + + Ctrl+N + Ctrl+N + + + Open + Otevřít + + + &Open + &Otevřít + + + Open file with pattern + Otevřít soubor se vzorem + + + Save + Uložit + + + &Save + &Uložit + + + Save pattern + Uložit vzor + + + Ctrl+S + Ctrl+S + + + Save &As... + Uložit &jako... + + + Save not yet saved pattern + Uložit ještě neuložený vzor + + + Ctrl+Shift+S + Ctrl+Shift+S + + + Draw + Kreslit + + + Draw mode + Režim kreslení + + + Ctrl+W + Ctrl+W + + + Details + Detaily + + + Details mode + Režim detailů + + + Ctrl+E + Ctrl+E + + + Pointer tools + Nástroje ukazovátka + + + New pattern piece + Nový díl střihu + + + Add new pattern piece + Přidat nový díl střihu + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Change the label of pattern piece + Změnit označení dílu střihu + + + Table of variables + Tabulka proměnných + + + Tables of variables + Tabulky proměnných + + + Ctrl+T + Ctrl+T + + + History + Historie + + + Ctrl+H + Ctrl+H + + + Export pattern (layout) + Vyvést střih (rozvržení) + + + Create layout + Vytvořit rozvržení + + + Ctrl+L + Ctrl+L + + + About &Qt + O &Qt + + + &About Valentina + &O programu Valentina + + + E&xit + &Ukončit + + + Exit the application + Ukončit program + + + Ctrl+Q + Ctrl+Q + + + Preferences + Nastavení + + + Pattern properties + Vlastnosti střihu + + + Zoom in + Přiblížit + + + zoom in + Přiblížit + + + Zoom out + Oddálit + + + Edit pattern XML code + Upravit kód XML střihu + + + Original zoom + Původní zvětšení + + + Original Zoom + Původní zvětšení + + + Zoom fit best + Nejlepší přizpůsobení zvětšení + + + Ctrl+= + Ctrl+= + + + Stop + Zastavit + + + Stop using tool + Zastavit používání nástroje + + + Repot Bug... + Nahlásit chybu... + + + Report bug + Nahlásit chybu + + + Close window + Zavřít okno + + + Online help + + + + Show online help + + + + Pattern piece %1 + Díl střihu %1 + + + Individual measurements is under development + Osobité míry se vyvíjejí + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + Select point + Vybrat bod + + + Select first point + Vybrat první bod + + + Select first point of line + Vybrat první bod čáry + + + Select first point of angle + Vybrat první bod úhlu + + + Select first point of first line + Vybrat první bod první čáry + + + Select first point curve + Vybrat první bod křivky + + + Select simple curve + Vybrat jednoduchou křivku + + + Select point of center of arc + Vybrat bod středu oblouku + + + Select point of curve path + Vybrat bod cesty křivky + + + Select curve path + Vybrat cestu křivky + + + Select points, arcs, curves clockwise. + Vybrat body, oblouky, křivky po směru hodinových ručiček. + + + Select base point + Vybrat základní bod + + + Select first point of axis + Vybrat první bod osy + + + Select point vertically + Vybrat bod svisle + + + Select detail + Vybrat detail + + + Select arc + Vybrat oblouk + + + Select curve + Vybrat křivku + + + About Qt + O Qt + + + Height: + Výška: + + + Size: + Velikost: + + + Pattern Piece: + Díl střihu: + + + Pattern files (*.val) + Soubory se střihy (*.val) + + + pattern + střih + + + /pattern.val + /pattern.val + + + Save as + Uložit jako + + + Could not save file + Nepodařilo se uložit soubor + + + Open file + Otevřít soubor + + + Error parsing file. + Chyba při zpracování souboru. + + + Error can't convert value. + Chyba. Nelze převést hodnotu. + + + Error empty parameter. + Chyba. Prázdný parametr. + + + Error wrong id. + Chyba. Špatné ID. + + + Critical error! + Zásadní chyba! + + + Error parsing file (std::bad_alloc). + Chyba při zpracování souboru (std::bad_alloc). + + + Bad id. + Špatné ID. + + + File saved + Soubor uložen + + + untitled.val + Bez názvu.val + + + Unsaved change + Neuložená změna + + + The pattern has been modified. +Do you want to save your changes? + Střih byl změněn. +Chcete uložit své změny? + + + &Undo + &Zpět + + + &Redo + &Znovu + + + Pattern piece: + Díl střihu: + + + Enter a new label for the pattern piece. + Zadejte nové označení dílu střihu. + + + This file already opened in another window. + + + + Wrong units. + Nesprávné jednotky. + + + Application doesn't support standard table with inches. + Program nepodporuje standardní tabulku s palci. + + + File error. + Chyba souboru. + + + File loaded + Soubor nahrán + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + Valentina se nevypla správně. Chcete otevřít soubory (%1), které jste měl otevřeny, znovu? + + + Reopen files. + Otevřít soubor znovu + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + Soubor s mírami <br/><br/> <b>%1</b> <br/><br/> %3 + + + could not be found. Do you want to update the file location + se nepodařilo nalézt. Chcete aktualizovat umístění souboru + + + Standard measurements (*.vst) + Obvyklé míry (*.vst) + + + Individual measurements (*.vit) + Osobité míry (*.vit) + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + + + + Around middle part of Neck + Full measurement description + + + + Around Neck at base + Full measurement description + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + NeckPoint to ShoulderTip + Full measurement description + + + + Armpit to Waist side + Full measurement description + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + Around HighHip, parallel to floor + Full measurement description + + + + Around Hip, parallel to floor + Full measurement description + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + + + + Back Waist side to side + Full measurement description + + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + + + + Around Calf + Full measurement description + + + + Around Ankle + Full measurement description + + + + Knee to Floor + Full measurement description + + + + Ankle to Floor + Full measurement description + + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + + + + Waist side to Hip + Full measurement description + + + + Waist side to Knee + Full measurement description + + + + Crotch to Floor along inside leg + Full measurement description + + + + Size + Full measurement description + Velikost + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + Výška ramen + + + Head height + Full measurement description + Výška hlavy + + + Body position + Full measurement description + Poloha těla + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + + + + Mid-neck girth + Full measurement name + + + + Neck Base girth + Full measurement name + + + + Head and Neck length + Full measurement name + + + + Front Center length + Full measurement name + + + + Back Center length + Full measurement name + + + + Shoulder length + Full measurement name + + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + + + + Shoulder girth + Full measurement name + + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + + + + HighHip girth + Full measurement name + + + + Hip girth + Full measurement name + + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + Velikost + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + + + + Shoulder height + Full measurement name + Výška ramen + + + Head height + Full measurement name + Výška hlavy + + + Body position + Full measurement name + Poloha těla + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + Přesunout jeden bod + + + + MoveSpline + + Move spline + Posunout křivku + + + + MoveSplinePath + + Move spline path + Posunout cestu křivky + + + + PathPage + + Open Directory + Otevřít adresář + + + Path that use Valentina + Cesta, kterou používá Valentina + + + Default + Výchozí + + + Edit + Upravit + + + Type + Typ + + + Path + Cesta + + + Individual measurements + Osobité míry + + + Patterns + Střihy + + + + PatternPage + + User + Uživatel + + + User name + Uživatelské jméno + + + Graphical output + Obrazový výstup + + + Use antialiasing + Použít vyhlazování + + + Undo + Zpět + + + Count steps (0 - no limit) + Počítat kroky (0 - bez omezení) + + + + PostfixOperators + + cm + centimeter + cm + + + mm + millimeter + mm + + + in + inch + palce + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + Vytvořit nový díl střihu pro započetí s prací. + + + Add node + Přidat uzel + + + Move detail + Posunout detail + + + mm + mm + + + cm + cm + + + inch + palec + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + Hodnota + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + Přejmenovat díl střihu + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + Save detail option + Uložit volbu pro detail + + + + SaveToolOptions + + Save tool option + Uložit volbu pro nástroj + + + + TableWindow + + Create a layout + Vytvořit rozvržení + + + toolBar + Nástrojový pruh + + + Save + Uložit + + + Save layout + Uložit rozvržení + + + Next + Další + + + Next detail + Další detail + + + Turn + Otočit + + + Turn the detail 90 degrees + Otočit detail o 90 stupňů + + + Stop + Zastavit + + + Stop laying + Zastavit kladení + + + Enlarge letter + Zvětšit list + + + Enlarge the length of the sheet + Zvětšit délku listu + + + Reduce sheet + Zmenšit list + + + Reduce the length of the sheet + Zmenšit velikost listu + + + Mirroring + Zrcadlení + + + Zoom In + Přiblížit + + + Zoom Out + Oddálit + + + 0 details left. + Zbylo 0 detailů. + + + Collisions not found. + Střety nenalezeny. + + + %1 details left. + Zbylo %1 detailů. + + + untitled + bez názvu + + + Svg files (*.svg) + Soubory SVG (*.svg) + + + PDF files (*.pdf) + Soubory PDF (*.pdf) + + + Images (*.png) + Obrázky (*.png) + + + PS files (*.ps) + Soubory PS (*.ps) + + + EPS files (*.eps) + Soubory EPS (*.eps) + + + Collisions found. + Střety nalezeny. + + + Creating file '%1' failed! %2 + Vytvoření souboru '%1' se nezdařilo! %2 + + + Critical error! + Zásadní chyba! + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + Chyba. Není jedinečné ID. + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + Potvrdit smazání. + + + Do you really want delete? + Opravdu chcete smazat? + + + + VApplication + + Error parsing file. Program will be terminated. + Chyba při zpracování souboru. Program bude ukončen. + + + Error bad id. Program will be terminated. + Chyba. Špatný identifikátor. Program bude ukončen. + + + Error can't convert value. Program will be terminated. + Chyba. Nelze převést hodnotu. Program bude ukončen. + + + Error empty parameter. Program will be terminated. + Chyba. Prázdný parametr. Program bude ukončen. + + + Error wrong id. Program will be terminated. + Chyba. Špatný identifikátor. Program bude ukončen. + + + Something's wrong!! + Něco je špatně! + + + Could not copy temp file to document file + Nepodařilo se zkopírovat dočasný soubor do souboru s dokumentem + + + Could not remove document file + Nepodařilo se odstranit soubor s dokumentem + + + + VContainer + + Can't find object + Nelze najít předmět + + + Can't cast object + Nelze najít předmět + + + Can't find object. Type mismatch. + Nelze najít předmět. Neodpovídající typ. + + + + VDomDocument + + Can't convert toUInt parameter + Nelze převést parametr toUInt + + + Can't convert toBool parameter + Nelze převést parametr toBool + + + Got empty parameter + Obdržen prázdný parametr + + + Can't convert toDouble parameter + Nelze převést parametr toDouble + + + Can't open file %1: +%2. + Nelze otevřít soubor %1: +%2. + + + Can't open schema file %1: +%2. + Nelze otevřít soubor se schématem %1: +%2. + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + Chyba při ověřování souboru %3 na řádku %1, ve sloupci %2 + + + Parsing error file %3 in line %1 column %2 + Chyba při zpracování souboru%3 na řádku %1, ve sloupci %2 + + + Couldn't get node + Nepodařilo se získat uzel + + + Got wrong parameter id. Need only id > 0. + Obdrženo špatné ID parametru. Je potřeba jen ID > 0. + + + This id is not unique. + Toto ID není jedinečné. + + + Could not copy temp file to document file + Nepodařilo se zkopírovat dočasný soubor do souboru s dokumentem + + + Could not remove document file + Nepodařilo se odstranit soubor s dokumentem + + + + VDrawTool + + Edit wrong formula + Upravit nesprávný vzorec + + + Options + Volby + + + Delete + Smazat + + + + VException + + Critical error! + Zásadní chyba! + + + + VFormula + + Error + Chyba + + + + VFormulaProperty + + Value + Hodnota + + + Formula + Vzorec + + + + VPE::VBoolProperty + + True + + + + False + + + + + VPE::VFileEditWidget + + Directory + + + + Open File + + + + + VPattern + + Can't find tool in table. + Nelze najít nástroj v tabulce. + + + Error no unique id. + Chyba. Není jedinečné ID. + + + Error parsing file. + Chyba při zpracování souboru. + + + Error can't convert value. + Chyba. Nelze převést hodnotu. + + + Error empty parameter. + Chyba. Prázdný parametr. + + + Error wrong id. + Chyba. Špatné ID. + + + Critical error! + Zásadní chyba! + + + Error parsing file (std::bad_alloc). + Chyba při zpracování souboru (std::bad_alloc). + + + Error creating or updating detail + Chyba při vytváření nebo aktualizaci detailu + + + Error creating or updating single point + Chyba při vytváření nebo aktualizaci základního bodu + + + Error creating or updating point of end line + Chyba při vytváření nebo aktualizaci bodu na konci čáry + + + Error creating or updating point along line + Chyba při vytváření nebo aktualizaci bodu podél čáry + + + Error creating or updating point of shoulder + Chyba při vytváření nebo aktualizaci bodu ramene + + + Error creating or updating point of normal + Chyba při vytváření nebo aktualizaci bodu kolmice + + + Error creating or updating point of bisector + Chyba při vytváření nebo aktualizaci bodu osy úhlu + + + Error creating or updating point of lineintersection + Chyba při vytváření nebo aktualizaci bodu průsečíku čar + + + Error creating or updating point of contact + Chyba při vytváření nebo aktualizaci bodu dotyku + + + Error creating or updating modeling point + Chyba při vytváření nebo aktualizaci bodu + + + Error creating or updating height + Chyba při vytváření nebo aktualizaci výšky + + + Error creating or updating triangle + Chyba při vytváření nebo aktualizaci trojúhelníku + + + Error creating or updating point of intersection + Chyba při vytváření nebo aktualizaci bodu průsečíku + + + Error creating or updating cut spline point + Chyba při vytváření nebo aktualizaci bodu vyjmutí křivky + + + Error creating or updating cut spline path point + Chyba při vytváření nebo aktualizaci bodu cesty vyjmutí křivky + + + Error creating or updating cut arc point + Chyba při vytváření nebo aktualizaci bodu vyjmutí oblouku + + + Error creating or updating point of intersection line and axis + Chyba při vytváření nebo aktualizaci bodu průsečíku křivky a osy + + + Error creating or updating point of intersection curve and axis + Chyba při vytváření nebo aktualizaci bodu průsečíku křivky a osy + + + Error creating or updating line + Chyba při vytváření nebo aktualizaci čáry + + + Error creating or updating simple curve + Chyba při vytváření nebo aktualizaci křivky + + + Error creating or updating curve path + Chyba při vytváření nebo aktualizaci cesty křivky + + + Error creating or updating modeling simple curve + Chyba při vytváření nebo aktualizaci modelové křivky + + + Error creating or updating modeling curve path + Chyba při vytváření nebo aktualizaci cesty modelové křivky + + + Error creating or updating simple arc + Chyba při vytváření nebo aktualizaci oblouku + + + Error creating or updating modeling arc + Chyba při vytváření nebo aktualizaci modelového oblouku + + + Error creating or updating union details + Chyba při vytváření nebo aktualizaci detailu spojení + + + Got wrong parameter id. Need only id > 0. + Obdrženo špatné ID parametru. Je potřeba jen ID > 0. + + + This id is not unique. + Toto ID není jedinečné. + + + File error. + Chyba souboru. + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + Nedostatek bodů na vytvoření křivky. + + + This spline does not exist. + Tato křivka neexistuje. + + + Can't cut spline path with one point + Nelze vyjmout cestu křivky s jedním bodem + + + + VTableGraphicsView + + can't find detail + Nelze najít detail + + + detail found + Detail nalezen + + + + VToolDetail + + Options + Volby + + + Delete + Smazat + + + + VToolOptionsPropertyBrowser + + Base point + Základní bod + + + Point label + Označení bodu + + + Position + Poloha + + + Point at distance and angle + Bod ve vzdálenosti a úhlu + + + Line type + Typ čáry + + + Length + Délka + + + Angle + Úhel + + + Point at distance along line + Bod ve vzdálenosti podél čáry + + + Arc + Oblouk + + + Radius + Poloměr + + + First angle + První úhel + + + Second angle + Druhý úhel + + + Point along bisector + Bod podél osy úhlu + + + Cut arc tool + Nástroj na vyjmutí oblouku + + + Tool for segmenting a curve + Nástroj pro rozdělení křivky + + + Tool segment a pathed curve + Nástroj pro rozdělení cesty křivky + + + Perpendicular point along line + Bod v pravém úhlu podél čáry + + + Line between points + Čára mezi body + + + Point at line intersection + Bod na průsečíku čar + + + Point along perpendicular + Bod podél v pravém úhlu + + + Additional angle degrees + Dodatečné úhlové stupně + + + Point at intersection of arc and line + Bod v průsečíku oblouku a čáry. + + + Tool to make point from x & y of two other points + Nástroj na udělání bodu z x a y dvou jiných bodů + + + Special point on shoulder + Zvláštní bod na rameni + + + Curve tool + Nástroj na křivku + + + Curve factor + Násobek křivky + + + Tool for path curve + Nástroj pro křivku cesty + + + Tool triangle + Nástroj na trojúhelník + + + Point intersection line and axis + Bod průsečíku oblouku a čáry + + + + Variables + + Line_ + Left symbol _ in name + Čára_ + + + AngleLine_ + Left symbol _ in name + Úhel čáry_ + + + Arc_ + Left symbol _ in name + Oblouk_ + + + Spl_ + Left symbol _ in name + Křivka_ + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + Program na tvorbu střihů. + + + Pattern file. + Soubor se střihem + + + diff --git a/share/translations/valentina_de_DE.ts b/share/translations/valentina_de_DE.ts new file mode 100644 index 000000000..509ba8fdb --- /dev/null +++ b/share/translations/valentina_de_DE.ts @@ -0,0 +1,6261 @@ + + + + + AddDet + + Add detail + Detail hinzufügen + + + + AddPatternPiece + + Add pattern piece %1 + Schnittteil %1 hinzufügen + + + + AddToCalc + + Add object + Objekt hinzufügen + + + + AddUnionDetails + + Add union details + Vereinigung von Details hinzufügen + + + + CommunityPage + + Server + Server + + + Server name/IP + Servername/IP + + + Secure connection + sichere Verbindung + + + Proxy settings + Proxyeinstellungen + + + Use Proxy + Proxy benutzen + + + Proxy address + Proxyadresse + + + Proxy port + Proxyport + + + Proxy user + Proxybenutzer + + + Proxy pass + + + + User settings + Benutzereinstellungen + + + User Name + Nutzername + + + Save password + Passwort speichern + + + Password + Passwort + + + + ConfigDialog + + Apply + Anwenden + + + &Cancel + &Abbrechen + + + &Ok + &Ok + + + Config Dialog + + + + Configuration + + + + Pattern + + + + Community + + + + Paths + + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + + + + Default unit updated and will be used the next pattern creation + + + + Save + Speichern + + + Auto-save modified pattern + + + + min + min + + + Interval: + + + + Language + Sprache + + + GUI language + GUI Sprache + + + Decimal separator parts + + + + With OS options (%1) + + + + Default unit + + + + Centimeters + Zentimeter + + + Millimiters + + + + Inches + Zoll + + + Label language + + + + Send crash reports + + + + Send crash reports (recommended) + + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + + + + + DelTool + + Delete tool + + + + + DeleteDetail + + Delete tool + + + + + DeletePatternPiece + + Delete pattern piece %1 + Schnittteil %1 löschen + + + + DialogAboutApp + + About Valentina + Über Valentina + + + Valentina version + Valentina Version + + + Contributors + Mitwirkende + + + Based on Qt %2 (32 bit) + Basiert auf Qt %2 (32 bit) + + + Built on %3 at %4 + Gebaut auf %3 um %4 + + + Web site : %1 + Webseite: %1 + + + Warning + Warnung + + + Cannot open your default browser + + + + Build revision: + + + + + DialogAlongLine + + Point along line + Punkt auf einer Linie + + + Length + Länge + + + Insert variable into the formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + Bezeichnung des Punktes + + + First point + Erster Punkt + + + First point of line + Erster Punkt der Linie + + + Second point + Zweiter Punkt + + + Second point of line + Zweiter Punkt der Linie + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + + DialogArc + + Arc + Bogen + + + Radius + Radius + + + Insert variable into the formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of radius + Wert des Radius + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + First angle + + + + Insert variable into formula + Variable in die Formel einfügen + + + Value of first angle + Wert des ersten Winkels + + + Second angle + + + + Insert marked variable into formula + Markierte Variable in die Formel einfügen + + + Value of second angle + Wert des zweiten Winkels + + + Center point + Mittelpunkt + + + Select point of center of arc + Mittelpunkt des Bogens auswählen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + Linenwinkel + + + Hide empty measurements + + + + Variables + Variablen + + + Value of angle of line. + Wert des Linenwinkels. + + + Error + Fehler + + + Radius can't be negative + + + + Angles equal + + + + + DialogBisector + + Bisector + Winkelhalbierende + + + Length + Länge + + + Insert marked variable into the formula + Markierte Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + Bezeichnung des Punktes + + + First point + Erster Punkt + + + First point of angle + Punkt der ersten Schenkelgeraden + + + Second point + Zweiter Punkt + + + Second point of angle + Scheitel des Winkels + + + Third point + Punkt der zweiten Scheitelgeraden + + + Third point of angle + Punkt der zweiten Schenkelgeraden + + + Type of line + Linientyp + + + Show line from second point to this point + Zeige Linie vom Scheitelpunkt zu diesem Punkt + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + Select second point of angle + Scheitelpunkt auswählen + + + Select third point of angle + zweiten Punkt auf dem zweiten Schenkel wählen + + + + DialogCurveIntersectAxis + + Curve intersect axis + + + + Angle + + + + Calculate value + Wert berechnen + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + Erster Punkt der Linie + + + Curve + Kurve + + + Point label + Bezeichnung des Punktes + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + Variablen + + + Select axis point + + + + + DialogCutArc + + Cut arc + + + + Length + Länge + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Arc + Bogen + + + Selected curve + Ausgewählte Kurve + + + Point label + Bezeichnung des Punktes + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + + DialogCutSpline + + Cut curve + + + + Length + Länge + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + Kurve + + + Selected curve + Ausgewählte Kurve + + + Point label + Bezeichnung des Punktes + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + + DialogCutSplinePath + + Cut curve path + + + + Length + Länge + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + Kurve + + + Selected curve path + Ausgewählter Kurvenpfad + + + Point label + Bezeichnung des Punktes + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + + DialogDetail + + Detail + Detail + + + Bias X + Bias X + + + cm + cm + + + Bias Y + Bias Y + + + Options + Optionen + + + Name of detail + Name des Deails + + + Seam allowance + Nahtzugaben + + + Width + Breite + + + Closed + Geschlossen + + + Delete + Löschen + + + Got wrong scene object. Ignore. + Falsches scene object. Wird ignoriert. + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + + + + Formula + + + + Insert variable into formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of first angle + Wert des ersten Winkels + + + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Zeige die ganze Berechnung in der Nachrichtenbox box</p></body></html> + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlänge + + + Length of arcs + Bogenlänge + + + Length of curves + Kurvenlänge + + + Angle of lines + Winkel der Linien + + + Hide empty measurements + + + + Variables + Variablen + + + + DialogEndLine + + Point in the end of a line + Punkt am Ende einer Linie + + + Length + Länge + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Angle + + + + Value of angle + + + + Base point + Startpunkt + + + First point of line + Erster Punkt der Linie + + + Point label + Bezeichnung des Punktes + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables + Variablen + + + + DialogHeight + + Height + Größe + + + Point label + Bezeichnung des Punktes + + + Base point + Startpunkt + + + First point of line + Erster Punkt der Linie + + + Second point of line + Zweiter Punkt der Linie + + + Type of line + Linientyp + + + Show line from first point to our point + Zeige linie vom ersten punkt zu diesem Punkt + + + Select first point of line + Ersten Punkt der Linie auswählen + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + + DialogHistory + + History + Chronik + + + Tool + Werkzeug + + + Can't create record. + + + + %1 - Base point + %1 - Startpunkt + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - Linie von Punkt %1 nach Punkt %2 + + + %3 - Point along line %1_%2 + %3 - Punkt auf der Linie %1_%2 + + + %1 - Point of shoulder + %1 -. Schulterpunkt + + + %3 - normal to line %1_%2 + %3 - Normale zur Linie %1_%2 + + + %4 - bisector of angle %1_%2_%3 + %4 - Winkelhalbierende des Winkels %1_%2_%3 + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - Schnittpunkt der Linien %1_%2 und %3_%4 + + + Curve %1_%2 + Kurve %1_%2 + + + Arc with center in point %1 + Bogen mit dem Mittelpunkt %1 + + + Curve point %1 + Kurvenpunkt %1 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + %4 - Kontaktpunkt von Bogen und dem Mittelpunkt von Punkt %1 und Linie %2_%3 + + + Point of perpendicular from point %1 to line %2_%3 + Lotfußpunkt von Punkt %1 zu Linie %2_%3 + + + Triangle: axis %1_%2, points %3 and %4 + Dreieck: Achse %1_%2, Punkte %3 und %4 + + + %1 - point of intersection %2 and %3 + %1 - Schnittpunkt von %2 und %3 + + + %1 - cut arc with center %2 + %1 - Bogen mit Zentrum %2 schneiden + + + %1 - cut curve %2_%3 + %1 - schneide Kurve %2_%3 + + + %1 - cut curve path %2 + + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + Increments + weitere Maße + + + Measurements + Maße + + + Load another measurements table + + + + Personal information + + + + Given name + + + + Family name + + + + Birth date + + + + Sex + + + + Email + + + + Hide empty measurements + + + + Name + Bezeichnung + + + The calculated value + Berechneter Wert + + + Base value + Basiswert + + + In sizes + In Konfektionen + + + In heights + + + + Description + Beschreibung + + + Lines + Linien + + + Line + Linie + + + Length + Länge + + + Curves + Kurven + + + Curve + Kurve + + + Arcs + Bögen + + + Arc + Bogen + + + File error. + Dateifehler. + + + male + männlich + + + female + weiblich + + + Could not save GivenName + + + + Could not save FamilyName + + + + Could not save Email + + + + Could not save Sex + + + + Could not save BirthDate + + + + Measurements use different units than pattern. This pattern required measurements in %1 + Die Maße sind in einer anderen Einheit als das Schnittmuster. Dieses Schnittmuster setzt Maße in %1 vorraus + + + Individual measurements (*.vit) + Individuelle Maße (*.vit) + + + Open file + Datei öffnen + + + Wrong units. + Falsche Maßeinheit. + + + Standard measurements (*.vst) + Standardmaße (*.vst) + + + Name_%1 + Name_%1 + + + Can't save measurement + + + + + DialogIndividualMeasurements + + Individual measurements + individuelle Maße + + + Pattern piece name + Schnittteilname + + + Exist measurements + + + + Path: + Pfad: + + + Given name: + Vorname: + + + Family name: + Nachname: + + + New measurements + Neue Maße + + + Units: + Einheiten: + + + Could not create measurements file + Die Maßdatei konnte nicht erstellt werden + + + Please try again or change file + Bitte versuchen sie es noch einmal oder ändern sie den Datei + + + File error. + Datei Fehler. + + + Individual measurements (*.vit) + Individuelle Maße (*.vit) + + + Open file + Datei öffnen + + + Where save measurements? + + + + Centimeters + Zentimeter + + + Millimiters + + + + Inches + Zoll + + + + DialogLine + + Line + Linie + + + First point + Erster Punkt + + + Second point + Zweiter Punkt + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Select second point + Wähle zweiten Punkt + + + + DialogLineIntersect + + Intersection of lines + Schnittpunkt von Linien + + + Point label + Bezeichnung des Punktes + + + First line + Erste Linie + + + First point + Erster Punkt + + + Second point + Zweiter Punkt + + + Second line + Zweite Linie + + + Select second point of first line + Zweiten Punkt der ersten Linie auswählen + + + Select first point of second line + Ersten Punkt der zweiten Linie auswählen + + + Select second point of second line + Zweiten Punkt der zweiten Linie auswählen + + + + DialogLineIntersectAxis + + Line intersect axis + + + + Angle + + + + Calculate value + Wert berechnen + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + Erster Punkt der Linie + + + First line point + + + + Second line point + + + + Point label + Bezeichnung des Punktes + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + Variablen + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + Select axis point + + + + + DialogMeasurements + + Measurements + Maße + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + <html><head/><body><p><span style=" font-size:18pt;">Bitte einen Schnittmustertyp auswählen.</span></p></body></html> + + + Graduation + Gradierung + + + Use for creation pattern standard measurement table + Für die Erstellung eines Schnittmusters, die Standardmaßtabelle benutzen + + + Individual + Individuell + + + Use for creation pattern individual measurements + Für die Erstellung eines Schnittmusters individuelle Maße benutzen + + + + DialogNormal + + Normal + Normale + + + Length + Länge + + + Insert variable into formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Die ganze Berechnung in der Messagebox anzeigen</p></body></html> + + + Point label + Bezeichnung des Punktes + + + First point + Erster Punkt + + + Second point + Zweiter Punkt + + + Additional angle degrees + Zusätzlicher Winkel + + + Type of line + Linientyp + + + Show line from first point to this point + Linie vom ersten zu diesem Punkt zeigen + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + + DialogPatternProperties + + Pattern properties + Schnittmustereigenschaften + + + Description + Beschreibung + + + Author name + Name des Autors + + + Pattern description + Schnittmusterbeschreibung + + + For technical notes. + Für technische Notizen. + + + Heights and Sizes + + + + All heights (cm) + + + + All sizes (cm) + + + + + DialogPatternXmlEdit + + XML Editor + XML Editor + + + Value : + Wert: + + + Name : + Name: + + + <No selection> + <nichts ausgewählt> + + + Type : + Typ: + + + Add attribute + Attribut hinzufügen + + + Add son + Kind hinzufügen + + + Remove attribute + + + + Remove node + Knoten entfernen + + + Set + Setzen + + + Cancel + Abbrechen + + + Apply changes + Änderungen übernehmen + + + Undo last + Rückgängig machen + + + Immediate apply + Sofort übernehmen + + + Base selection + Basisauswahl + + + All pattern pieces + Alle Schnittteile + + + No changes + Keine Änderungen + + + Cannot delete previously created node + Der vorher erstellte Knoten kann nicht entfernt werden + + + No changes left + Keine Änderungen übrig + + + Cannot undo change + Änderung kann nicht rückgängig gemacht werden + + + <no value> + <kein Wert> + + + Unchanged + Unverändert + + + Cannot delete previously created attribute + Das vorher erstellte Attribut kann nicht gelöscht werden + + + Node Name + Knotenname + + + Name: + Name: + + + Node Value (may be empty) + Knotenwert (kann leer sein) + + + Value: + Wert: + + + Attribute Name + Attributname + + + Attribute Value + Attributwert + + + No selection + Nichts ausgewählt + + + Root node + Wurzelknoten + + + Node + Knoten + + + Attribute + Attribut + + + + DialogPointOfContact + + Point of contact + Kontaktpunkt + + + Radius + Radius + + + Insert variable into formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of radius + Wert des Radius + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Die vollständige Berechnung in einer Messagebox anzeigen</p></body></html> + + + Point label + Bezeichnung des Punktes + + + Center of arc + Mittelpunkt des Bogens + + + Select point of center of arc + Mittelpunkt des Bogens auswählen + + + Top of the line + Anfang der Linie + + + End of the line + Ende der Linie + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + Bogenlängen + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula. + Variablen - Doppelklick fügt die Variable in die Formel ein. + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + + DialogPointOfIntersection + + Point of intersection + + + + Point label + Bezeichnung des Punktes + + + vertical point + vertikaler Punkt + + + First point of angle + Punkt der ersten Schenkelgeraden + + + horizontal point + horizontaler Punkt + + + Second point of angle + Scheitel des Winkels + + + Select point horizontally + Wähle Punkt horizontal + + + + DialogShoulderPoint + + Point of shoulder + Schulterpunkt + + + Length + Länge + + + Insert variable into formula + Variable in die Formel einfügen + + + Calculate value + Wert berechnen + + + Value of length + Wert der Länge + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + Bezeichnung des Punktes + + + First point + Erster Punkt + + + Second point + Zweiter Punkt + + + Third point + Punkt der zweiten Scheitelgeraden + + + Type of line + Linientyp + + + Show line from first point to our point + Zeige linie vom ersten punkt zu diesem Punkt + + + Input data + Eingabedaten + + + Size and height + Konfektion und Größe + + + Measurements + Maße + + + Increments + weitere Maße + + + Length of lines + Linienlängen + + + Length of arcs + + + + Length of curves + Kurvenlängen + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + Variablen - Doppelklick fügt die Variable in die Formel ein + + + Select first point of line + Ersten Punkt der Linie auswählen + + + Select second point of line + Zweiten Punkt der Linie auswählen + + + + DialogSinglePoint + + Single point + Einzelpunkt + + + Coordinates on the sheet + Koordinaten auf der Seite + + + Coordinates + Koordinaten + + + Y coordinate + Y Koordinate + + + X coordinate + X Koordinate + + + Point label + Bezeichnung des Punktes + + + + DialogSpline + + Curve + Kurve + + + First point + Erster Punkt + + + Length ratio of the first control point + Längenverhältnis des ersten Kontrollpunktes + + + The angle of the first control point + Winkel des ersten Kontrollpunktes + + + Second point + Zweiter Punkt + + + Length ratio of the second control point + Längenverhältnis des zweiten Kontrollpunktes + + + The angle of the second control point + Winkel des zweiten Kontrollpunktes + + + Coefficient of curvature of the curve + Koeffizient für die Krümmung der Kurve + + + Select last point of curve + Letzten Punkt auf der Kurve auswählen + + + + DialogSplinePath + + Curved path + + + + Point of curve + Punkt der Kurve + + + Length ratio of the first control point + Längenverhältnis des ersten Kontrollpunktes + + + The angle of the first control point + Winkel des ersten Kontrollpunktes + + + Length ratio of the second control point + Längenverhältnis des zweiten Kontrollpunktes + + + The angle of the second control point + Winkel des zweiten Kontrollpunktes + + + List of points + Liste von Punkten + + + Coefficient of curvature of the curve + Koeffizient für die Krümmung der Kurve + + + Select point of curve path + Punkt für den Kurvenpfad auswählen + + + + DialogStandardMeasurements + + Standard table + + + + Pattern piece name + Schnittteilname + + + Standard measurements table + + + + File error. + + + + + DialogTool + + Error + Fehler + + + Empty field + + + + Value can't be 0 + + + + Value + + + + Height + Größe + + + Size + Konfektion + + + Line length + Linienlänge + + + Arc length + Bogenlänge + + + Curve length + Kurvenlänge + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + + + + Point label + Bezeichnung des Punktes + + + First point of axis + Erster Punkt der Achse + + + First point of line + Erster Punkt der Linie + + + Second point of axis + Zweiter Punkt der Achse + + + First point + Erster Punkt + + + Second point + Zweiter Punkt + + + Select second point of axis + Den zweiten Punkt der Achse auswählen + + + Select first point + Zweiten Punkt wählen + + + Select second point + Zweiten Punkt wählen + + + + DialogUndo + + Broken formula + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + + &Undo + + + + &Fix formula + + + + &Cancel + &Abbrechen + + + + DialogUnionDetails + + Union details + Details vereinigen + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><p>Soll die Details wirklich vereinigt werden?</p></body></html> + + + Select first point + Ersten Punkt auswählen + + + Select second point + Zweiten Punkt auswählen + + + Select another second point + Einen anderen zweiten Punkt auswählen + + + Select detail + Detail auswählen + + + + Functions + + sin + sine function + + + + cos + cosine function + + + + tan + tangens function + + + + asin + arcus sine function + + + + acos + arcus cosine function + + + + atan + arcus tangens function + + + + sinh + hyperbolic sine function + + + + cosh + hyperbolic cosine + + + + tanh + hyperbolic tangens function + + + + asinh + hyperbolic arcus sine function + + + + acosh + hyperbolic arcus tangens function + + + + atanh + hyperbolic arcur tangens function + + + + log2 + logarithm to the base 2 + + + + log10 + logarithm to the base 10 + + + + log + logarithm to the base 10 + + + + ln + logarithm to base e (2.71828...) + + + + exp + e raised to the power of x + + + + sqrt + square root of a value + + + + sign + sign function -1 if x<0; 1 if x>0 + + + + rint + round to nearest integer + + + + abs + absolute value + + + + min + min of all arguments + min + + + max + max of all arguments + + + + sum + sum of all arguments + + + + avg + mean value of all arguments + + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Werkzeuge zum Erstellen von Punkten. + + + Point + Punkt + + + Point along perpendicular + Punkt auf einer Normalen + + + Special point on shoulder. + Spezieller Punkt an einer Schulter + + + Tool triangle. + Werkzeug Dreieck. + + + Perpendicular point along line + Lotfußpunkt auf einer Linie + + + Point along bisector + Punkt auf einer Winkelhalbierenden + + + Point at intersection of arc and line. + Schnittpunkt eines Bogens und einer Linie + + + Tool to make point from x & y of two other points. + Werkzeug zum Erstellen eines Punktes aus den x- und y-Koordinaten zweier anderer Punkte. + + + Point at distance and angle + Punkt in einer Distanz und mit einem Winkel + + + Point at distance along line + Punkt in einer Distanz auf einer Linie + + + Point of intersection line and axis + + + + ... + + + + Tools for creating lines. + Werkzeuge zur Linienerzeugung. + + + Line + Linie + + + Line between points + Linie zwischen Punkten + + + Point at line intersection + Linienschnittpunkt + + + Tools for creating curves. + Werkzeuge zur Kurvenerzeugung. + + + Curve + Kurve + + + Curve tool. + Kurvenverkzeug. + + + Tool for path curve. + Werkzeug zur Definition einer Kurve. + + + Tool for segmenting a curve. + Werkzeug zur Kurvensegmentierung. + + + Tool segment a pathed curve. + Werkzeug zum Segmentieren einer definierten Kurve + + + Tools for creating arcs. + Werkzeuge zur Kurvenerzeugung. + + + Arc + Bogen + + + Arc tool. + Bogenwerkzeug. + + + Cut arc tool. + + + + Tools for creating details. + Werkzeuge zur Detailerzeugung. + + + Detail + Detail + + + Tool new detail. + Werkzeug neues Detail. + + + Tool for union two details. + + + + &File + + + + &Help + + + + &Pattern piece + + + + Measurements + Maße + + + Window + + + + Toolbar files + + + + ToolBar modes + + + + Toolbar pattern + + + + Toolbar options + + + + Toolbar tools + + + + Tool options + + + + New + Neu + + + &New + &Neu + + + Create a new pattern + Neues Schnittmuster erstellen + + + Ctrl+N + Strg+N + + + Open + Öffnen + + + &Open + &Öffnen + + + Open file with pattern + Datei mit Schnittmuster öffnen + + + Save + Speichern + + + &Save + &Speichern + + + Save pattern + Schnittmuster speichern + + + Ctrl+S + Strg+S + + + Save &As... + + + + Save not yet saved pattern + Speichere ungesichertes Schnittmuster + + + Ctrl+Shift+S + Strg+Umschalt+S + + + Draw + Zeichnen + + + Draw mode + Zeichnenmodus + + + Ctrl+W + Strg+W + + + Details + Details + + + Details mode + Detailmodus + + + Ctrl+E + Strg+E + + + Pointer tools + Zeigerwerkzeuge + + + New pattern piece + Neues Schnittteil + + + Add new pattern piece + Neues Schnittteil hinzufügen + + + Ctrl+Shift+N + Strg+Umschalt+N + + + Change the label of pattern piece + Das Label eines Schnittteils ändern + + + Table of variables + Variablentabelle + + + Tables of variables + Variablentabellen + + + Ctrl+T + Strg+T + + + History + Chronik + + + Ctrl+H + Strg+H + + + Export pattern (layout) + + + + Create layout + Layout erstellen + + + Ctrl+L + Strg+L + + + About &Qt + + + + &About Valentina + &Über Valentina + + + E&xit + + + + Exit the application + + + + Ctrl+Q + Strg+Q + + + Preferences + + + + Pattern properties + Schnittmustereigenschaften + + + Zoom in + + + + zoom in + + + + Zoom out + + + + Edit pattern XML code + + + + Original zoom + + + + Original Zoom + + + + Zoom fit best + + + + Ctrl+= + + + + Stop + Stop + + + Stop using tool + + + + Repot Bug... + + + + Report bug + + + + Close window + + + + Online help + + + + Show online help + + + + Pattern piece %1 + Schnittteil %1 + + + Individual measurements is under development + + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + Select point + Punkt wählen + + + Select first point + Zweiten Punkt wählen + + + Select first point of line + Ersten Punkt der Linie auswählen + + + Select first point of angle + Den Erstehn Punkt des Winkels wählen + + + Select first point of first line + Den ersten Punkt der Linie wählen + + + Select first point curve + Ersten Punkt der Kurve wählen + + + Select simple curve + Einfache Kurve auswählen + + + Select point of center of arc + Mittelpunkt des Bogens auswählen + + + Select point of curve path + Punkt für den Kurvenpfad auswählen + + + Select curve path + Kurvenpfad auswählen + + + Select points, arcs, curves clockwise. + Punkte, Bögen, Kurven im Uhrzeigersinn auswählen. + + + Select base point + Fußpunkt auswählen + + + Select first point of axis + Ersten Punkt der Achse auswählen + + + Select point vertically + + + + Select detail + Detail auswählen + + + Select arc + + + + Select curve + + + + About Qt + Über Qt + + + Height: + Größe: + + + Size: + + + + Pattern Piece: + Schnittteil: + + + Pattern files (*.val) + Schnittmuster Dateien (*.val) + + + pattern + + + + /pattern.val + /schnittmuster.val + + + Save as + Speichern als + + + Could not save file + + + + Open file + Datei öffnen + + + Error parsing file. + Fehler beim Parsen der Datei. + + + Error can't convert value. + Fehler Wert kann nicht konvertiert werden. + + + Error empty parameter. + Fehler leerer parameter. + + + Error wrong id. + Fehler falsche Id. + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Bad id. + + + + File saved + Datei gespeichert + + + untitled.val + unbenannt.val + + + Unsaved change + Ungespeicherte Änderungen + + + The pattern has been modified. +Do you want to save your changes? + Das Schnittmuster wurde geändert. +Sollen die Änderungen gespeichert werden? + + + &Undo + + + + &Redo + &Wiederholen + + + Pattern piece: + Schnittteil: + + + Enter a new label for the pattern piece. + Es muss ein neues Label für das Schnittteil eingegeben werden. + + + This file already opened in another window. + + + + Wrong units. + Falsche Maßeinheiten. + + + Application doesn't support standard table with inches. + + + + File error. + Dateifehler. + + + File loaded + + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + + + + Reopen files. + + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + + + + could not be found. Do you want to update the file location + + + + Standard measurements (*.vst) + Standardmaße (*.vst) + + + Individual measurements (*.vit) + Individuelle Maße (*.vit) + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + schulter_breite + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + + + + Around middle part of Neck + Full measurement description + + + + Around Neck at base + Full measurement description + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + NeckPoint to ShoulderTip + Full measurement description + + + + Armpit to Waist side + Full measurement description + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + Around HighHip, parallel to floor + Full measurement description + + + + Around Hip, parallel to floor + Full measurement description + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + + + + Back Waist side to side + Full measurement description + + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + + + + Around Calf + Full measurement description + + + + Around Ankle + Full measurement description + + + + Knee to Floor + Full measurement description + + + + Ankle to Floor + Full measurement description + + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + + + + Waist side to Hip + Full measurement description + + + + Waist side to Knee + Full measurement description + + + + Crotch to Floor along inside leg + Full measurement description + + + + Size + Full measurement description + Konfektion + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + + + + Head height + Full measurement description + + + + Body position + Full measurement description + + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + + + + Mid-neck girth + Full measurement name + + + + Neck Base girth + Full measurement name + + + + Head and Neck length + Full measurement name + + + + Front Center length + Full measurement name + + + + Back Center length + Full measurement name + + + + Shoulder length + Full measurement name + + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + + + + Shoulder girth + Full measurement name + + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + + + + HighHip girth + Full measurement name + + + + Hip girth + Full measurement name + + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + Konfektion + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + + + + Shoulder height + Full measurement name + + + + Head height + Full measurement name + + + + Body position + Full measurement name + + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + + + + + MoveSpline + + Move spline + + + + + MoveSplinePath + + Move spline path + + + + + PathPage + + Open Directory + + + + Path that use Valentina + + + + Default + + + + Edit + + + + Type + + + + Path + + + + Individual measurements + individuelle Maße + + + Patterns + Schnittmuster + + + + PatternPage + + User + Benutzer + + + User name + Nutzername + + + Graphical output + Grafische Ausgabe + + + Use antialiasing + + + + Undo + Rückgängig + + + Count steps (0 - no limit) + + + + + PostfixOperators + + cm + centimeter + cm + + + mm + millimeter + mm + + + in + inch + in + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + Es muss ein neues Schnittteil erstellt werden, um fortfahen zu können. + + + Add node + Knoten hinzufügen + + + Move detail + Detail bewegen + + + mm + mm + + + cm + cm + + + inch + + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + Schnittteil umbenennen + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + Save detail option + Detailoption speichern + + + + SaveToolOptions + + Save tool option + Werkzeugoption speichern + + + + TableWindow + + Create a layout + Layout erstellen + + + toolBar + toolBar + + + Save + Speichern + + + Save layout + Layout speichern + + + Next + Weiter + + + Next detail + Nächstes Detail + + + Turn + Drehen + + + Turn the detail 90 degrees + Detail um 90° drehen + + + Stop + Stop + + + Stop laying + Legen stoppen + + + Enlarge letter + Buchstaben vergrößern + + + Enlarge the length of the sheet + Länge des Blattes verlängern + + + Reduce sheet + Seite verkleinern + + + Reduce the length of the sheet + Die Länge der Seite verkleinern + + + Mirroring + Spiegeln + + + Zoom In + Vergrößern + + + Zoom Out + Verkleinern + + + 0 details left. + 0 Details übrig. + + + Collisions not found. + Kollisionen nicht gefunden. + + + %1 details left. + %1 Details übrig. + + + untitled + + + + Svg files (*.svg) + + + + PDF files (*.pdf) + + + + Images (*.png) + + + + PS files (*.ps) + + + + EPS files (*.eps) + + + + Collisions found. + Kollisionen gefunden. + + + Creating file '%1' failed! %2 + + + + Critical error! + + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + + + + Do you really want delete? + + + + + VApplication + + Error parsing file. Program will be terminated. + Fehler beim Parsen der Datei. Das Programm wird geschlossen. + + + Error bad id. Program will be terminated. + Fehler - unbekannte Id. Fas Programm wird geschlossen. + + + Error can't convert value. Program will be terminated. + Fehler - Wert kann nicht konvertiert werden. Das Programm wird geschlossen. + + + Error empty parameter. Program will be terminated. + Fehler - leerer Parameter. Das Programm wird geschlossen. + + + Error wrong id. Program will be terminated. + Fehler - falsche Id. Das Programm wird geschlossen. + + + Something's wrong!! + + + + + VContainer + + Can't find object + Objekt kann nicht gefunden werden + + + Can't cast object + + + + Can't find object. Type mismatch. + + + + + VDomDocument + + Can't convert toUInt parameter + + + + Can't convert toBool parameter + + + + Got empty parameter + Leerer Parameter übermittelt + + + Can't convert toDouble parameter + Kann Parameter nicht toDouble konvertieren + + + Can't open file %1: +%2. + + + + Can't open schema file %1: +%2. + + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + + + + Parsing error file %3 in line %1 column %2 + + + + Couldn't get node + + + + Got wrong parameter id. Need only id > 0. + + + + This id is not unique. + + + + Could not copy temp file to document file + + + + Could not remove document file + + + + + VDrawTool + + Edit wrong formula + + + + Options + Optionen + + + Delete + Löschen + + + + VException + + Critical error! + + + + + VFormula + + Error + Fehler + + + + VFormulaProperty + + Value + + + + Formula + + + + + VPE::VBoolProperty + + True + + + + False + + + + + VPE::VFileEditWidget + + Directory + + + + Open File + + + + + VPattern + + Can't find tool in table. + + + + Error no unique id. + + + + Error parsing file. + Fehler beim Parsen der Datei. + + + Error can't convert value. + Fehler Wert kann nicht konvertiert werden. + + + Error empty parameter. + Fehler leerer parameter. + + + Error wrong id. + Fehler falsche Id. + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Error creating or updating detail + + + + Error creating or updating single point + + + + Error creating or updating point of end line + + + + Error creating or updating point along line + + + + Error creating or updating point of shoulder + + + + Error creating or updating point of normal + + + + Error creating or updating point of bisector + + + + Error creating or updating point of lineintersection + + + + Error creating or updating point of contact + + + + Error creating or updating modeling point + + + + Error creating or updating height + + + + Error creating or updating triangle + + + + Error creating or updating point of intersection + + + + Error creating or updating cut spline point + + + + Error creating or updating cut spline path point + + + + Error creating or updating cut arc point + + + + Error creating or updating point of intersection line and axis + + + + Error creating or updating point of intersection curve and axis + + + + Error creating or updating line + + + + Error creating or updating simple curve + + + + Error creating or updating curve path + + + + Error creating or updating modeling simple curve + + + + Error creating or updating modeling curve path + + + + Error creating or updating simple arc + + + + Error creating or updating modeling arc + + + + Error creating or updating union details + + + + File error. + + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + Nicht genügend Punkte um den Spline zu erstellen. + + + This spline does not exist. + Dieser Spline existiert nicht. + + + Can't cut spline path with one point + Splinepfad mit nur einem Punkt kann nicht zerschnitten werden + + + + VTableGraphicsView + + can't find detail + Kann Detail nicht finden + + + detail found + Detail gefunden + + + + VToolDetail + + Options + Optionen + + + Delete + Löschen + + + + VToolOptionsPropertyBrowser + + Base point + Startpunkt + + + Point label + Bezeichnung des Punktes + + + Position + + + + Point at distance and angle + Punkt in einer Distanz und mit einem Winkel + + + Line type + + + + Length + Länge + + + Angle + + + + Point at distance along line + Punkt in einer Distanz auf einer Linie + + + Arc + Bogen + + + Radius + Radius + + + First angle + + + + Second angle + + + + Point along bisector + Punkt auf einer Winkelhalbierenden + + + Cut arc tool + + + + Tool for segmenting a curve + + + + Tool segment a pathed curve + + + + Perpendicular point along line + Lotfußpunkt auf einer Linie + + + Line between points + Linie zwischen Punkten + + + Point at line intersection + Linienschnittpunkt + + + Point along perpendicular + Punkt auf einer Normalen + + + Additional angle degrees + Zusätzlicher Winkel + + + Point at intersection of arc and line + + + + Tool to make point from x & y of two other points + + + + Special point on shoulder + + + + Curve tool + + + + Curve factor + + + + Tool for path curve + + + + Tool triangle + + + + Point intersection line and axis + + + + + Variables + + Line_ + Left symbol _ in name + + + + AngleLine_ + Left symbol _ in name + + + + Arc_ + Left symbol _ in name + + + + Spl_ + Left symbol _ in name + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + Programm zum Schnittmuster erstellen. + + + Pattern file. + Schnittmusterdatei + + + diff --git a/share/translations/valentina_fr_FR.ts b/share/translations/valentina_fr_FR.ts new file mode 100644 index 000000000..0bdb6ad8b --- /dev/null +++ b/share/translations/valentina_fr_FR.ts @@ -0,0 +1,6278 @@ + + + + + AddDet + + Add detail + Ajouter un détail + + + + AddPatternPiece + + Add pattern piece %1 + Ajouter un élément de patron %1 + + + + AddToCalc + + Add object + Ajouter un objet + + + + AddUnionDetails + + Add union details + Ajouter des détails + + + + CommunityPage + + Server + Serveur + + + Server name/IP + Nom du serveur/IP + + + Secure connection + Connexion séurisée + + + Proxy settings + Réglages du proxy + + + Use Proxy + Utiliser un proxy + + + Proxy address + Adresse du proxy + + + Proxy port + Port du proxy + + + Proxy user + Nom d'utilisateur du proxy + + + Proxy pass + Mot de passe du proxy + + + User settings + Paramètres de l'utilisateur + + + User Name + Nom de l'utilisateur + + + Save password + Enregistrer le mot de passe + + + Password + Mot de passe + + + + ConfigDialog + + Apply + Appliquer + + + &Cancel + &Annuler + + + &Ok + &OK + + + Config Dialog + Boîte de configuration + + + Configuration + Configuration + + + Pattern + Patron + + + Community + Communauté + + + Paths + Chemins + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + La langue de l'interface a été mise à jour et sera utilisée dès le prochain démarrage + + + Default unit updated and will be used the next pattern creation + L'unité par défaut a été mise à jour et sera utilisée pour le prochain nouveau patron + + + Save + Sauvegarder + + + Auto-save modified pattern + Auto-sauvegarde modifiée + + + min + minimum + + + Interval: + Intervalle : + + + Language + Langue + + + GUI language + Langue de l'interface + + + Decimal separator parts + Séparateur de décimale + + + With OS options (%1) + Utiliser les réglages par défaut (%1) + + + Default unit + Unité par défaut + + + Centimeters + Centimètres + + + Millimiters + Millimètres + + + Inches + Pouces + + + Label language + Langue + + + Send crash reports + Envoyer le rapport de plantage + + + Send crash reports (recommended) + Envoyer le rapport de plantage (recommandé) + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + Après chaque plantage Valentina collecte des informations qui pourront nous être utile a la résolutions du problème. Nous ne collectons pas d'informations personnelles. En savoir plus sur <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">genre d'informations</a>que nous collectons. + + + + DelTool + + Delete tool + Supprimer l'outil + + + + DeleteDetail + + Delete tool + Supprimer l'outil + + + + DeletePatternPiece + + Delete pattern piece %1 + Supprimer l'élément de patron %1 + + + + DialogAboutApp + + About Valentina + À propos de Valentina + + + Valentina version + Version de Valentina + + + Contributors + Contributeurs + + + Based on Qt %2 (32 bit) + Fonctionne avec Qt %2 (32 bit) + + + Built on %3 at %4 + Compilé le %3 à %4 + + + Web site : %1 + Site web : %1 + + + Warning + Avertissement + + + Cannot open your default browser + Impossible d'ouvrir votre navigateur par défaut + + + Build revision: + + + + + DialogAlongLine + + Point along line + Point le long d'une ligne + + + Length + Longueur + + + Insert variable into the formula + Ajouter une variable dans la formule + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Point label + Désignation du point + + + First point + Premier point + + + First point of line + Premier point de la ligne + + + Second point + Deuxième point + + + Second point of line + Deuxième point de la ligne + + + Type of line + Type de ligne + + + Show line from first point to this point + Afficher la ligne du premier point jusqu'à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + Select second point of line + Choisir le deuxième point d'une ligne + + + + DialogArc + + Arc + Arc + + + Radius + Rayon + + + Insert variable into the formula + Ajouter une variable dans la formule + + + Calculate value + Calculer la valeur + + + Value of radius + Rayon + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + First angle + Premier angle + + + Insert variable into formula + Ajouter une variable dans la formule + + + Value of first angle + Valeur du premier angle + + + Second angle + Deuxième angle + + + Insert marked variable into formula + Ajouter les variables sélectionnées dans la formule + + + Value of second angle + Valeur du deuxième angle + + + Center point + Point central + + + Select point of center of arc + Choisir le point central de l'arc + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle des lignes + + + Hide empty measurements + Masquer les mesures vides + + + Variables + Variables + + + Value of angle of line. + valeur de l'Angle de la ligne. + + + Error + Erreur + + + Radius can't be negative + La valeur en radians ne peut pas être négative + + + Angles equal + + + + + DialogBisector + + Bisector + Bissectrice + + + Length + Longueur + + + Insert marked variable into the formula + Ajouter les variables sélectionnées dans la formule + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Point label + Désignation du point + + + First point + Premier point + + + First point of angle + Premier point de l'angle + + + Second point + Deuxième point + + + Second point of angle + Deuxième point de l'angle + + + Third point + Troisième point + + + Third point of angle + Troisième point de l'angle + + + Type of line + Type de ligne + + + Show line from second point to this point + Afficher la ligne du deuxième point jusqu'à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Evolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + Select second point of angle + Choisir le deuxième point de l'angle + + + Select third point of angle + Choisir le troisième point de l'angle + + + + DialogCurveIntersectAxis + + Curve intersect axis + Intersection courbe, axe + + + Angle + Angle + + + Calculate value + Calculer la valeur + + + Value of angle + Valeur de l'angle + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Montrer le calcul complet dans une boite de dioalogue</p></body></html> + + + Axis point + point d'axe + + + First point of line + Premier point de la ligne + + + Curve + courbe + + + Point label + Désignation du point + + + Type of line + Type de ligne + + + Show line from first point to this point + Montre la ligne depuis le premier point jusqu'a ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle des lignes + + + Hide empty measurements + Masquer les mesures vides + + + Variables + Variables + + + Select axis point + Choisir un point d'axe + + + + DialogCutArc + + Cut arc + Couper l'arc + + + Length + longueur + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Arc + Arc + + + Selected curve + Courbe selectionnée + + + Point label + Désignation du point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Evolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + + DialogCutSpline + + Cut curve + Couper la courbe + + + Length + Longueur + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Curve + Courbe + + + Selected curve + Courbe sélectionnée + + + Point label + Désignation du point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + + DialogCutSplinePath + + Cut curve path + Couper le chemin de la courbe + + + Length + Longueur + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Curve + Courbe + + + Selected curve path + Chemin de courbe sélectionné + + + Point label + Désignation du point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + + DialogDetail + + Detail + Détail + + + Bias X + Biais X + + + cm + Cm + + + Bias Y + Biais Y + + + Options + Options + + + Name of detail + Nom du détail + + + Seam allowance + Marge de couture + + + Width + Largeur + + + Closed + Fermé + + + Delete + Supprimer + + + Got wrong scene object. Ignore. + Récupération du mauvais objet de scène. Ignorer. + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + Modifier la formule + + + Formula + Formules + + + Insert variable into formula + Insérer une variable dans la formule + + + Calculate value + Valeur calculée + + + Value of first angle + Valeur du premier angle + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul entier dans une boite de dialogue</p></body></html> + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Incréments + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle des lignes + + + Hide empty measurements + Masquer les mesures vides + + + Variables + Variables + + + + DialogEndLine + + Point in the end of a line + Point en fin de ligne + + + Length + Longueur + + + Calculate value + Valeur calculée + + + Value of length + Longueur + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Angle + Angle + + + Value of angle + Valeur de l'angle + + + Base point + Point de départ + + + First point of line + Premier point de la ligne + + + Point label + Désignation du point + + + Type of line + Type de ligne + + + Show line from first point to this point + Montrer la ligne du premier point jusqu'à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables + Variables + + + + DialogHeight + + Height + Stature + + + Point label + Désignation du point + + + Base point + Point de départ + + + First point of line + Premier point de la ligne + + + Second point of line + Deuxième point de la ligne + + + Type of line + Type de ligne + + + Show line from first point to our point + Montrer la ligne du premier point jusqu'à ce point + + + Select first point of line + Choisir le premier point de la ligne + + + Select second point of line + Choisir le deuxième point de la ligne + + + + DialogHistory + + History + Historique + + + Tool + Outil + + + Can't create record. + Ne peut pat créer d'enregistrement. + + + %1 - Base point + %1 - Point de départ + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - Ligne du point %1 au point %2 + + + %3 - Point along line %1_%2 + %3 - Point le long d'une ligne %1_%2 + + + %1 - Point of shoulder + %1 - Point d'épaule + + + %3 - normal to line %1_%2 + %3 - normal à la ligne %1_%2 + + + %4 - bisector of angle %1_%2_%3 + %4 - bissectrice de l'angle %1_%2_%3 + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - intersection des lignes %1_%2 et %3_%4 + + + Curve %1_%2 + Courbe %1_%2 + + + Arc with center in point %1 + Arc centré sur le point %1 + + + Curve point %1 + Point de courbe %1 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + %4 - point de contact de l'arc avec le centre au point %1 et à la ligne %2_%3 + + + Point of perpendicular from point %1 to line %2_%3 + Point de la perpendiculaire du point %1 à la ligne %2_%3 + + + Triangle: axis %1_%2, points %3 and %4 + Triangle : axe %1_%2, points %3 et %4 + + + %1 - point of intersection %2 and %3 + %1 - point d'intersection %2 et %3 + + + %1 - cut arc with center %2 + %1 - couper l'arc avec le centre %2 + + + %1 - cut curve %2_%3 + %1 - couper la courbe %2_%3 + + + %1 - cut curve path %2 + %1 - coup le chemin de la courbe %2 + + + %1 - point of intersection line %2_%3 and axis through point %4 + %1- point d'intersection ligne%2_%3 et l'axe en passant par le point %4 + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + Increments + Évolutions + + + Measurements + Mesures + + + Load another measurements table + Charger une autre table de mesure + + + Personal information + Données personnelles + + + Given name + Nom + + + Family name + Nom de famille + + + Birth date + Date de naissance + + + Sex + Sexe + + + Email + Courriel + + + Hide empty measurements + Masquer les mesures vides + + + Name + Nom + + + The calculated value + Valeur calculée + + + Base value + Valeur de départ + + + In sizes + En taille + + + In heights + Taille + + + Description + Description + + + Lines + Lignes + + + Line + Ligne + + + Length + Longueur + + + Curves + Courbes + + + Curve + Courbe + + + Arcs + Arcs + + + Arc + Arc + + + File error. + Erreur de fichier. + + + male + homme + + + female + femme + + + Could not save GivenName + Le nom ne peut être enregistré + + + Could not save FamilyName + Le nom de famille ne peut être enregistré + + + Could not save Email + Le courriel ne peut être enregistré + + + Could not save Sex + le sexe ne peut etre enregistré + + + Could not save BirthDate + La date de naissance ne peut etre enregistrée + + + Measurements use different units than pattern. This pattern required measurements in %1 + Les mesures utilisées dans ce patron sont différentes. Ce patron nécessite des mesures en %1 + + + Individual measurements (*.vit) + Mesure Individuelles (*.vit) + + + Open file + Ouvrir + + + Wrong units. + Mauvaise unité. + + + Standard measurements (*.vst) + Mesures standard (*.vst) + + + Name_%1 + Nom_%1 + + + Can't save measurement + Les mesures ne peuvent être enregistrées + + + + DialogIndividualMeasurements + + Individual measurements + Mesures individuelles + + + Pattern piece name + Nom de la pièce de patron + + + Exist measurements + Mesures existantes + + + Path: + Chemin: + + + Given name: + Prénom: + + + Family name: + Nom de famille: + + + New measurements + Nouvelles mesures + + + Units: + Unités: + + + Could not create measurements file + Impossible de créer le fichier de mesures + + + Please try again or change file + Essayez de nouveau ou changer de fichier + + + File error. + Erreur de fichier. + + + Individual measurements (*.vit) + Mesures individuelles (*.vit) + + + Open file + Ouvrir + + + Where save measurements? + Où sauvegarder les mesures ? + + + Centimeters + Centimètres + + + Millimiters + Millimètres + + + Inches + Pouces + + + + DialogLine + + Line + Ligne + + + First point + Premier point + + + Second point + Deuxième point + + + Type of line + Type de ligne + + + Show line from first point to this point + Visualiser la ligne du premier points à ce point + + + Select second point + Choisir le deuxième point + + + + DialogLineIntersect + + Intersection of lines + Intersection des lignes + + + Point label + Désignation du point + + + First line + Première ligne + + + First point + Premier point + + + Second point + Deuxième point + + + Second line + Deuxième ligne + + + Select second point of first line + Choisir le deuxième point de la première ligne + + + Select first point of second line + Choisir le premier point de la deuxième ligne + + + Select second point of second line + Choisir le deuxième point de la deuxième ligne + + + + DialogLineIntersectAxis + + Line intersect axis + Intersection ligne, axe + + + Angle + Angle + + + Calculate value + Calcule la valeur + + + Value of angle + Valeur de l'angle + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul dans une boite de dialogue</p></body></html> + + + Axis point + point d'axe + + + First point of line + Premier point de la ligne + + + First line point + Point de la première ligne + + + Second line point + Point de deuxieme ligne + + + Point label + Désignation du point + + + Type of line + Type de ligne + + + Show line from first point to this point + Montre la ligne du premier point jusqu’à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle des lignes + + + Hide empty measurements + Masquer les mesures vides + + + Variables + Variables + + + Select second point of line + Choisir le deuxième point d'une ligne + + + Select axis point + Choisir un point d'axe + + + + DialogMeasurements + + Measurements + Mesures + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + <html><head/><body><p><span style=" font-size:18pt;">Choisisez un type de patron</span></p></body></html> + + + Graduation + Graduation + + + Use for creation pattern standard measurement table + Créer un patron avec des mesures standards + + + Individual + Individuel + + + Use for creation pattern individual measurements + Créer un patron avec des mesures personnalisées + + + + DialogNormal + + Normal + Normal + + + Length + Longueur + + + Insert variable into formula + Ajouter une variable dans la formule + + + Calculate value + Calculer la valeur + + + Value of length + Longueur + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul entier dans une boite de dialogue</p></body></html> + + + Point label + Désignation du point + + + First point + Premier point + + + Second point + Deuxième point + + + Additional angle degrees + Angle supplémentaire + + + Type of line + Type de ligne + + + Show line from first point to this point + Montrer la ligne du premier point jusqu'à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures renseignées + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + Select second point of line + Choisir le second point d'une ligne + + + + DialogPatternProperties + + Pattern properties + Propriétés du patron + + + Description + Description du patron + + + Author name + Nom de l'auteur + + + Pattern description + Description du patron + + + For technical notes. + Pour les notes techniques. + + + Heights and Sizes + Longueurs et tailles + + + All heights (cm) + Toutes les longueurs (cm) + + + All sizes (cm) + Toutes les tailles (cm) + + + + DialogPatternXmlEdit + + XML Editor + Editeur XML + + + Value : + Valeur : + + + Name : + Nom : + + + <No selection> + <Pas de sélection> + + + Type : + Type : + + + Add attribute + Ajouter un attribut + + + Add son + Ajouter un fils + + + Remove attribute + Retirer un attribut + + + Remove node + Supprimer un nœud + + + Set + Valider + + + Cancel + Annuler + + + Apply changes + Appliquer les changements + + + Undo last + Annuler + + + Immediate apply + Appliquer immédiatement + + + Base selection + Sélection de Base + + + All pattern pieces + Toute les pièces du patron + + + No changes + Pas de changements + + + Cannot delete previously created node + Impossible de supprimer le précédent nœud crée + + + No changes left + Plus de changement restant + + + Cannot undo change + Impossible d'annuler le changement + + + <no value> + <sans valeur> + + + Unchanged + Inchangé + + + Cannot delete previously created attribute + Impossible de supprimer l'attribut précédemment crée + + + Node Name + Nom du nœud + + + Name: + Nom: + + + Node Value (may be empty) + Valeur de Nœud (peut être vide) + + + Value: + Valeur: + + + Attribute Name + Nom d'attribut + + + Attribute Value + Valeur d'attribut + + + No selection + Pas de sélection + + + Root node + Noeud racine + + + Node + Nœud + + + Attribute + Attribut + + + + DialogPointOfContact + + Point of contact + Point de contact + + + Radius + Rayon + + + Insert variable into formula + Ajouter une variable dans la formule + + + Calculate value + Calculer valeur + + + Value of radius + Rayon + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul entier dans une boite de dialogue</p></body></html> + + + Point label + Désignation du point + + + Center of arc + Centre de l'arc + + + Select point of center of arc + Choisir le point central de l'arc + + + Top of the line + Sommet de la ligne + + + End of the line + Fin de la ligne + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + MEsures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula. + Variables - Double-cliquer pour ajouter à une formule. + + + Select second point of line + Choisir le second point d'une ligne + + + + DialogPointOfIntersection + + Point of intersection + Point d'intersection + + + Point label + Désignation du point + + + vertical point + Point vertical + + + First point of angle + Premier point de l'angle + + + horizontal point + point horizontal + + + Second point of angle + Second point de l'angle + + + Select point horizontally + Choisir le point horizontalement + + + + DialogShoulderPoint + + Point of shoulder + Point d'épaule + + + Length + Longueur + + + Insert variable into formula + Ajouter une variable dans la formule + + + Calculate value + Calculer valeur + + + Value of length + Longueur + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Voir le calcul entier dans une boite de dialogue</p></body></html> + + + Point label + Désignation du point + + + First point + Premier point + + + Second point + Deuxième point + + + Third point + Troisième point + + + Type of line + Type de ligne + + + Show line from first point to our point + Montrer la ligne du premier point jusqu'à ce point + + + Input data + Données + + + Size and height + Taille et stature + + + Measurements + Mesures + + + Increments + Évolutions + + + Length of lines + Longueur des lignes + + + Length of arcs + Longueur des arcs + + + Length of curves + Longueur des courbes + + + Angle of lines + Angle + + + Hide empty measurements + Masquer les mesures vides + + + Variables - Click twice to insert into formula + Variables - Double-cliquer pour ajouter à une formule + + + Select first point of line + Sélectionnez le premier point de la ligne + + + Select second point of line + Choisir le second point d'une ligne + + + + DialogSinglePoint + + Single point + Point unique + + + Coordinates on the sheet + Coordonnées sur la feuille + + + Coordinates + Coordonnées + + + Y coordinate + Coordonnées Y + + + X coordinate + Coordonnées X + + + Point label + Désignation du point + + + + DialogSpline + + Curve + Courbe + + + First point + Premier point + + + Length ratio of the first control point + Ratio de longueur du premier point de contrôle + + + The angle of the first control point + Angle du premier point de contrôle + + + Second point + Deuxième point + + + Length ratio of the second control point + Ratio de longueur du deuxième point de contrôle + + + The angle of the second control point + Angle du deuxième point de contrôle + + + Coefficient of curvature of the curve + Coefficient de courbure + + + Select last point of curve + Choisir le dernier point de la courbe + + + + DialogSplinePath + + Curved path + Chemin de courbe + + + Point of curve + Point de courbe + + + Length ratio of the first control point + Ratio de longueur du premier point de contrôle + + + The angle of the first control point + Angle du premier point de contrôle + + + Length ratio of the second control point + Ratio de longueur du deuxième point de contrôle + + + The angle of the second control point + Angle du deuxième point de contrôle + + + List of points + Liste des points + + + Coefficient of curvature of the curve + Coefficient de courbure + + + Select point of curve path + Choisir un point sur la courbe + + + + DialogStandardMeasurements + + Standard table + Table standard + + + Pattern piece name + Nom de la pièce de patron + + + Standard measurements table + tableau des mesures strandard + + + File error. + Erreur de fichier. + + + + DialogTool + + Error + Erreur + + + Empty field + Champ vide + + + Value can't be 0 + La valeur ne peut pas être 0 + + + Value + Valeur + + + Height + Stature + + + Size + Taille + + + Line length + Longueur de ligne + + + Arc length + Longueur d'arc + + + Curve length + Longueur de courbe + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + Triangle + + + Point label + Désignation du point + + + First point of axis + Premier point de l'axe + + + First point of line + Premier point de la ligne + + + Second point of axis + Deuxième point de l'axe + + + First point + Premier point + + + Second point + Deuxième point + + + Select second point of axis + Choisir le deuxième point de l'axe + + + Select first point + Choisir le premier point + + + Select second point + Choisir le deuxième point + + + + DialogUndo + + Broken formula + Formule incorecte + + + Error while calculation formula. You can try undo last operation or fix broken formula. + Erreur lors du calcul de la formule. Essayez d'annuler la dernière opération ou corrigez la formule. + + + &Undo + &Annuler + + + &Fix formula + &Corriger la formule + + + &Cancel + &Annuler + + + + DialogUnionDetails + + Union details + Détail d'union + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><p>Voulez-vous vraiment fusionner les propriétés ?</p></body></html> + + + Select first point + Choisir le premier point + + + Select second point + Choisir le deuxième point + + + Select another second point + Choisir un autre deuxième point + + + Select detail + Choisir les détails + + + + Functions + + sin + sine function + sin + + + cos + cosine function + cos + + + tan + tangens function + tan + + + + asin + arcus sine function + asin + + + acos + arcus cosine function + acos + + + atan + arcus tangens function + atan + + + sinh + hyperbolic sine function + sinh + + + cosh + hyperbolic cosine + cosh + + + tanh + hyperbolic tangens function + tanh + + + asinh + hyperbolic arcus sine function + asinh + + + acosh + hyperbolic arcus tangens function + acosh + + + atanh + hyperbolic arcur tangens function + atanh + + + log2 + logarithm to the base 2 + log2 + + + log10 + logarithm to the base 10 + log10 + + + log + logarithm to the base 10 + log + + + ln + logarithm to base e (2.71828...) + ln + + + exp + e raised to the power of x + exp + + + sqrt + square root of a value + sqrt + + + sign + sign function -1 if x<0; 1 if x>0 + signe + + + rint + round to nearest integer + rint + + + abs + absolute value + abs + + + min + min of all arguments + min + + + max + max of all arguments + max + + + sum + sum of all arguments + somme + + + avg + mean value of all arguments + moyenne + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + Le programme est fourni TEL QUEL, SANS AUCUNE GARANTIE, Y COMPRIS LA GARANTIE DE CONCEPTION, DE QUALITÉ MARCHANDE ET D'ADAPTATION À UN USAGE PERSONNEL. + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Outils pour créer des points. + + + Point + Point + + + Point along perpendicular + Point le long d'une perpendiculaire + + + Special point on shoulder. + Point spécial d'épaule. + + + Tool triangle. + Outil triangle. + + + Perpendicular point along line + Point perpendiculaire le long d'une ligne + + + Point along bisector + point le long d'une bissectrice + + + Point at intersection of arc and line. + Point à l'intersection d'un arc et d'une ligne. + + + Tool to make point from x & y of two other points. + Créer un nouveau point à partir des coordonnées x & y de deux points différents. + + + Point at distance and angle + Point à distance et angle + + + Point at distance along line + Point à distance le long d'un ligne + + + Point of intersection line and axis + Point à l'intersection d'un axe et d'une ligne + + + ... + ... + + + Tools for creating lines. + Outil pour créer des lignes. + + + Line + Ligne + + + Line between points + Ligne entre plusieurs points + + + Point at line intersection + Point à l'intersection de ligne + + + + Tools for creating curves. + Outil pour créer des courbes. + + + Curve + Courbe + + + Curve tool. + Outils courbe. + + + Tool for path curve. + Outil pour chemin de courbe. + + + Tool for segmenting a curve. + Outil pour segmenter une courbe. + + + Tool segment a pathed curve. + Outil segment d'une courbe le long d'un chemin. + + + Tools for creating arcs. + Outils pour créer des arcs. + + + Arc + Arc + + + Arc tool. + Outil arc. + + + Cut arc tool. + Outil Coupe Arc. + + + Tools for creating details. + Outils pour créer des détails. + + + Detail + Détail + + + Tool new detail. + Outil nouveau détail. + + + Tool for union two details. + outil d'union de deux détails. + + + &File + &Fichier + + + &Help + Aid&e + + + &Pattern piece + Élément de &patron + + + Measurements + Mesures + + + Window + Fenêtre + + + Toolbar files + Barre d'outil fichier + + + ToolBar modes + Barre d'outils modes + + + Toolbar pattern + Barre d'outil patron + + + Toolbar options + Barre d'outils options + + + Toolbar tools + Barre d'outils Outils + + + Tool options + Barre d'outils + + + New + Nouveau + + + &New + &Nouveau + + + Create a new pattern + Créer un nouveau patron + + + Ctrl+N + Ctrl+N + + + Open + Ouvrir + + + &Open + &Ouvrir + + + Open file with pattern + Ouvrir un fichier de patron + + + Save + Enregistrer + + + &Save + &Sauver + + + Save pattern + Enregistrer le patron + + + Ctrl+S + Ctrl+S + + + Save &As... + Enregistrer &sous... + + + Save not yet saved pattern + Enregistrer le patron en cours + + + Ctrl+Shift+S + Ctrl+Shift+S + + + Draw + Dessin + + + Draw mode + Mode dessin + + + Ctrl+W + Ctrl+W + + + Details + Détails + + + Details mode + Mode détails + + + Ctrl+E + Ctrl+E + + + Pointer tools + Outil pointeur + + + New pattern piece + Nouveau élément de patron + + + Add new pattern piece + Ajouter un nouveau élément de patron + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Change the label of pattern piece + Changer la désignation de l'élément de patron + + + Table of variables + Tableau des variables + + + Tables of variables + Tableaux des variables + + + Ctrl+T + Ctrl+T + + + History + Historique + + + Ctrl+H + Ctrl+H + + + Export pattern (layout) + Exporter le patron (agencement) + + + Create layout + Créer une mise en page + + + Ctrl+L + Ctrl+L + + + About &Qt + À propos de &Qt + + + &About Valentina + À propos de &Valentina + + + E&xit + &Quitter + + + Exit the application + Quitter l'application + + + Ctrl+Q + Ctrl+Q + + + Preferences + Préférences + + + Pattern properties + Propriétés du patron + + + Zoom in + Zoom avant + + + zoom in + Zoom avant + + + Zoom out + Zoom arrière + + + Edit pattern XML code + Editer le code XML du patron + + + Original zoom + Zoom par défaut + + + Original Zoom + Zoom par défaut + + + Zoom fit best + Zoom optimal + + + Ctrl+= + Ctrl+= + + + Stop + stop + + + Stop using tool + + + + Repot Bug... + Reporter un bug + + + Report bug + rapport de plantage + + + Close window + Fermer la fenêtre + + + Online help + Aide en ligne + + + Show online help + Afficher l'aide en ligne + + + Pattern piece %1 + Élément de patron %1 + + + Individual measurements is under development + Mesures individuelles en cours de developpement + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + Il n'est pas possible de créer des mesures individuelles indépendament dufichier patron. +Pour ouvrir un patron vous devez garder les deux fichiers: patron et mesures. Voulez-vous continuer? + + + Select point + Choisir un point + + + Select first point + Choisir le premier point + + + Select first point of line + Choisir le premier point de la ligne + + + Select first point of angle + Choisir le premier point de l'angle + + + Select first point of first line + Choisir le premier point de la première ligne + + + Select first point curve + Choisir le premier point de la courbe + + + Select simple curve + Choisir une courbe simple + + + Select point of center of arc + Choisir le point central de l'arc + + + Select point of curve path + Choisir un point sur la courbe + + + Select curve path + Choisir le chemin de courbe + + + Select points, arcs, curves clockwise. + Choisir points, arcs et courbes dans le sens horaire. + + + Select base point + Choisir le point de départ + + + Select first point of axis + Choisir le premier point de l'axe + + + Select point vertically + Choisir le point verticallement + + + Select detail + Choisir les détails + + + Select arc + Choisir un arc + + + Select curve + Choisr courbe + + + About Qt + À propos de Qt + + + Height: + Stature : + + + Size: + Taille : + + + Pattern Piece: + Élément de patron : + + + Pattern files (*.val) + Fichier de patron (*.val) + + + pattern + parton + + + /pattern.val + /pattern.val + + + Save as + Enregistrer sous + + + Could not save file + le fichier n'a pas pu etre enregistré + + + Open file + Ouvrir fichier + + + Error parsing file. + Erreur d'interprétation de fichier. + + + Error can't convert value. + Erreur : valeur non convertissable. + + + Error empty parameter. + Erreur : paramètre vide. + + + Error wrong id. + Erreur : mauvais id. + + + Critical error! + Erreur critique! + + + Error parsing file (std::bad_alloc). + Erreur d'interprétation de fichier.(std::bad_alloc). + + + Bad id. + Mauvais id. + + + File saved + Fichier sauvegardé + + + untitled.val + sanstitre.val + + + Unsaved change + Changements non enregistrés + + + The pattern has been modified. +Do you want to save your changes? + Le patron a été changé. +Voulez-vous sauvegarder les changements ? + + + &Undo + &Annuler + + + &Redo + &Rétablir + + + Pattern piece: + Élément de patron: + + + Enter a new label for the pattern piece. + Saisir une nouvelle désignation pour cet élément de patron. + + + This file already opened in another window. + Ce fichier est déjà ouvert dans une autre fenêtre + + + Wrong units. + Mauvaises unités de mesure. + + + Application doesn't support standard table with inches. + L'application ne supporte pas la table de mesure standard en pouces. + + + File error. + Erreur de fichier. + + + File loaded + Fichier chargé + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + Valentina ne s'est pas fermé correctement. Voulez vous ré-ouvrir le fichier %1 que vous aviez ouvert? + + + Reopen files. + Re-ouvrir fichier. + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + Fichier de mesures file <br/><br/> <b>%1</b> <br/><br/> %3 + + + could not be found. Do you want to update the file location + Ne peut être trouvé. voulez vous mettre à jour le chemin du fichier + + + Standard measurements (*.vst) + Mesures standard (*.vst) + + + Individual measurements (*.vit) + Mesures individuelles (*.vit) + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + Tour_de_tête + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + tour_de_cou_milieu + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + encolure + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + longueur_tête_nuque + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + Longueur_milieu_devant + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + Longueur_milieu_dos + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + Longueur_d'épaule + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + Longueur_hanche_cote + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + longueur_tronc + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + Tour d'épaule + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + Tour de poitrine + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + Tour_sous_poitrine + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + Tour_de_taille + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + tour_de_hanches_hautes + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + Tour_de_hanches + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + Largeur_épaule_de_face + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + Largeur_épaule_de_dos + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + Largeur de dos + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + point_de_buste_a_point_de_buste + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + longueur_entrejambe + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + Angle tombé épaule + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + tour_coude + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + tour_bras_haut + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + tour_poignet + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + longueur_cou__poignet + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + longueur_bras_coude + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + Longueur_bras + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + tour_de_mollet + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + tour_de_cheville + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + hauteur_de_cheville + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + Pointure en mm + + + height + Short measurement name. Don't use math symbols in name!!!! + Stature + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + hauteur_cou + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + hauteur_cou_genou + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + Hauteur_taille + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + Hauteur_petites_hanches + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + Hauteur_hanches + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + hauteur_taille_hanche + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + Distance_genou_taille + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + Hauteur_entrejambe + + + size + Short measurement name. Don't use math symbols in name!!!! + taille + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + hauteur_base_cou + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + Hauteur_tetons + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + hanche_sol + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + longueur_taille_sol + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + Montant + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + largeur_poitrine + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + taille_genou + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + position_du_corps + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + Atour de la tête + + + Around middle part of Neck + Full measurement description + Autour du milieu du cou + + + Around Neck at base + Full measurement description + Autour du cou a la base + + + Vertical Distance from Crown to Nape + Full measurement description + Longueur verticale de la tête à la nuque + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + De dos du milieu de la base du cou au milieu de la taille + + + NeckPoint to ShoulderTip + Full measurement description + Du point du cou a la pointe d'épaule + + + Armpit to Waist side + Full measurement description + Sur le côté du dessous de l'aisselle à la taille + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + autour des bras et du torse, au niveau des biceps, parallèle au sol les bras le long du corps + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + Atour du buste, parallèlement au sol + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + Tendre un cordon autour de la partie la plus fine de la taille, garder ce dernier tendu pendant la prise de mesures. pas toujours parrallele au solpour l'avant et l'arriere. + + + Around HighHip, parallel to floor + Full measurement description + Autour des hanches hautes, paralleles au sol + + + Around Hip, parallel to floor + Full measurement description + Autour des hanches, parallèlement au sol + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + D'une pointe d'épaule à l'autre , devant + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + d'une pointe d'épaule à l'autre, dans le dos + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + Distance entre les points de buste au niveau de la poitrine devant + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + du creux du cou au point de buste + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + de la ligne de taille avant en passant par l'entre-jambe à la ligne de taille dos + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + Assis sur une chaise rigide, mesurer de la taille au siege + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + Distance verticale du point du cou a la pointe de l'épaule + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + de la pointe de l'épaule au milieu hanche devant + + + ShoulderTip to Back Waist Center + Full measurement description + de la pointe de l'épaule a mileu hanche dos + + + NeckPoint straight down front chest to Waistline + Full measurement description + devant du creux du cou a la ligne de taille en ligne droite + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + devant d'un coté a l'autre de la taille + + + Back Waist side to side + Full measurement description + dos d'un cote de la taille a l'autre + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + sur le devant des hanches d'un coté a l'autre + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + Tour de coude avec le coude plié + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + Autour de la main + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + Atour du genou + + + Around Calf + Full measurement description + autour du mollet + + + Around Ankle + Full measurement description + Tour de cheville + + + Knee to Floor + Full measurement description + Du genou au sol + + + Ankle to Floor + Full measurement description + De la cheville au sol + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + Du dessus de la tête au sol + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + de la hanche au sol + + + Waist side to Hip + Full measurement description + du coté de la taille a la hanche + + + Waist side to Knee + Full measurement description + du coté de la taille au genou + + + Crotch to Floor along inside leg + Full measurement description + De l'entrejambe au sol le long de l'interieur de la jambe + + + Size + Full measurement description + Taille + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + Hauteur d'épaule + + + Head height + Full measurement description + hauteur de tête + + + Body position + Full measurement description + + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + Tour_de_tête + + + Mid-neck girth + Full measurement name + tour de cou milieu + + + Neck Base girth + Full measurement name + encolure + + + Head and Neck length + Full measurement name + longueur tête nuque + + + Front Center length + Full measurement name + Longueur milieu devant + + + Back Center length + Full measurement name + Longueur milieu dos + + + Shoulder length + Full measurement name + Longueur d'épaule + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + longueur tronc + + + Shoulder girth + Full measurement name + Tour d'épaules + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + Tour de buste + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + Tour de taille + + + HighHip girth + Full measurement name + tour de hanches hautes + + + Hip girth + Full measurement name + Tour de hanches + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + point de buste a point de buste + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + Tour d'emanchure + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + Profondeur d'emanchure + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + Longueur de bras + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + Tour de cheville + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + Hauteur de cheville + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + Taille + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + De la taille au genou + + + Shoulder height + Full measurement name + Hauteur d'épaule + + + Head height + Full measurement name + hauteur de tête + + + Body position + Full measurement name + + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + + + + + MoveSpline + + Move spline + + + + + MoveSplinePath + + Move spline path + + + + + PathPage + + Open Directory + Ouvrir un dossier + + + Path that use Valentina + + + + Default + Défault + + + Edit + Editer + + + Type + Type + + + Path + Chemin + + + Individual measurements + Mesures individuelles + + + Patterns + Patrons + + + + PatternPage + + User + Utilisateur + + + User name + Nom d'utilisateur + + + Graphical output + Sortie graphique + + + Use antialiasing + Utiliser l'antialiasing + + + Undo + Annuler + + + Count steps (0 - no limit) + + + + + PostfixOperators + + cm + centimeter + cm + + + mm + millimeter + mm + + + in + inch + in + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + créer un nouvel élément de patron pour commencer. + + + Add node + Ajouter un nœud + + + Move detail + Déplacer le détail + + + mm + mm + + + cm + cm + + + inch + Pouce + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + Valeur + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + Renommer la pièce de patron + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + Mesures standard homme du 1er groupe, Tour de poitrine 100cm + + + + SaveDetailOptions + + Save detail option + Sauver les options du détail + + + + SaveToolOptions + + Save tool option + Options d'outil de Sauvegarde + + + + TableWindow + + Create a layout + Créer une mise en page + + + toolBar + toolBar + + + Save + Sauvegarder + + + Save layout + Enregistrer la mise en page + + + Next + Suivant + + + Next detail + Détail suivant + + + Turn + Tourner + + + Turn the detail 90 degrees + Tourne le détail de 90 degrés + + + Stop + Arrêter + + + Stop laying + Arrêter la mise en page + + + Enlarge letter + Grossier la lettre + + + Enlarge the length of the sheet + Augmenter la longueur de la feuille + + + Reduce sheet + Réduire la feuille + + + Reduce the length of the sheet + Réduire la longueur de la feuille + + + Mirroring + Mise en miroir + + + Zoom In + Zoom avant + + + Zoom Out + Zoom arrière + + + 0 details left. + 0 détails restant. + + + Collisions not found. + Collisions non trouvées. + + + %1 details left. + %1 détails restant(s). + + + untitled + sans titre + + + Svg files (*.svg) + Fichiers Svg (*.svg) + + + PDF files (*.pdf) + fichiers PDF (*.pdf) + + + Images (*.png) + Images (*.png) + + + PS files (*.ps) + Fichiers PS (*.ps) + + + EPS files (*.eps) + Fichiers EPS (*.eps) + + + Collisions found. + Collisions trouvées. + + + Creating file '%1' failed! %2 + Création du fichier '%1' Raté ! %2 + + + Critical error! + Erreur critique! + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + Erreur : id non unique. + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + Confirmer la suppression. + + + Do you really want delete? + Voulez vous vraiment supprimer ? + + + + VApplication + + Error parsing file. Program will be terminated. + Erreur d'interprétation du fichier. Fin du programme. + + + Error bad id. Program will be terminated. + Erreur d'identifiant. Fin du programme. + + + Error can't convert value. Program will be terminated. + Erreur : valeur non convertissable. Fin du programme. + + + Error empty parameter. Program will be terminated. + Erreur : paramètre vide. Fin du programme. + + + Error wrong id. Program will be terminated. + Erreur : mauvais identifiant. Fin du programme. + + + Something's wrong!! + Quel que chose ne va pas!! + + + Could not remove document file + le fichier n'a pas pu etre supprimé + + + + VContainer + + Can't find object + Objet non trouvé + + + Can't cast object + Ne peut convertir l'objet + + + Can't find object. Type mismatch. + impossible de trouver l'objet. Le type ne correspond pas. + + + + VDomDocument + + Can't convert toUInt parameter + Conversion du paramètre impossible vers toUInt + + + Can't convert toBool parameter + Conversion du paramètre impossible vers toBool + + + Got empty parameter + Paramètre vide + + + Can't convert toDouble parameter + Conversion du paramètre impossible vers toDouble + + + Can't open file %1: +%2. + impossible d'ouvrir le fichier %1: +%2. + + + Can't open schema file %1: +%2. + + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + + + + Parsing error file %3 in line %1 column %2 + + + + Couldn't get node + + + + Got wrong parameter id. Need only id > 0. + Mauvais id . Seul les id > 0 sont autorisés. + + + This id is not unique. + Cet idientifiant n'est pas unique. + + + Could not copy temp file to document file + + + + Could not remove document file + le fichier n'a pas pu etre supprimé + + + + VDrawTool + + Edit wrong formula + Editer la formule erronée + + + Options + Options + + + Delete + Supprimer + + + + VException + + Critical error! + Erreur critique! + + + + VFormula + + Error + Erreur + + + + VFormulaProperty + + Value + Valeur + + + Formula + Formule + + + + VPE::VBoolProperty + + True + Vrai + + + False + Faux + + + + VPE::VFileEditWidget + + Directory + Dossier + + + Open File + Ouvrir fichier + + + + VPattern + + Can't find tool in table. + Impossible de trouver l'outil dans la table. + + + Error no unique id. + Erreur : id non unique. + + + Error parsing file. + Erreur d'interprétation de fichier. + + + Error can't convert value. + Erreur : valeur non convertissable. + + + Error empty parameter. + Erreur : paramètre vide. + + + Error wrong id. + Erreur : mauvais id. + + + Critical error! + Erreur Critique! + + + Error parsing file (std::bad_alloc). + Erreur d'interprétation de fichier. (std::bad_alloc). + + + Error creating or updating detail + Erreur : Création ou mise à jour du détail + + + Error creating or updating single point + Erreur lors de la création ou de la mise à jour d'un point seul + + + Error creating or updating point of end line + Erreur lors de la création ou de la mise à jour d'un point de fin de ligne + + + Error creating or updating point along line + Erreur lors de la création ou de la mise à jour d'un point de la ligne + + + Error creating or updating point of shoulder + Erreur : Création ou mise à jour du point d'épaule + + + Error creating or updating point of normal + Erreur lors de la création ou de la mise à jour d'un point de la normale + + + Error creating or updating point of bisector + Erreur : Création ou mise à jour du point de bisection + + + Error creating or updating point of lineintersection + Erreur : Création ou mise à jour du point d'intersection de ligne + + + Error creating or updating point of contact + Erreur : Création ou mise à jour du point de contact + + + Error creating or updating modeling point + Erreur : Création ou mise à jour du point de modélisation + + + Error creating or updating height + Erreur : Création ou mise à jour de la taille + + + Error creating or updating triangle + Erreur lors de la création ou de la mise à jour d'un triangle + + + Error creating or updating point of intersection + Erreur : Création ou mise à jour du point d'intersection + + + Error creating or updating cut spline point + Erreur : Création ou mise à jour du point de découpe de crannelure + + + Error creating or updating cut spline path point + Erreur : Création ou mise à jour du point du chemine de cannelure + + + Error creating or updating cut arc point + Erreur lors de la création ou de la mise à jour d'un point de découpe d'arc + + + Error creating or updating point of intersection line and axis + Erreur : Création ou mise à jour du point d'intersection de ligne et d'axe + + + Error creating or updating point of intersection curve and axis + Erreur : Création ou mise à jour du point d'intersection de courbe et d'axe + + + Error creating or updating line + Erreur lors de la création ou de la mise à jour de la ligne + + + Error creating or updating simple curve + Erreur lors de la création ou de la mise à jour de la courbe + + + Error creating or updating curve path + Erreur lors de la création ou de la mise à jour du chemin de la courbe + + + Error creating or updating modeling simple curve + Erreur lors de la création ou de la mise à jour de la courbe simple + + + Error creating or updating modeling curve path + Erreur lors de la création ou de la mise à jour du chemin de la coubre + + + Error creating or updating simple arc + Erreur : Création ou mise à jour d'un arc simple + + + Error creating or updating modeling arc + Erreur : Création ou mise à jour d'un arc modelé + + + Error creating or updating union details + Erreur : Création ou mise à jour d'un union de détails + + + Got wrong parameter id. Need only id > 0. + Mauvais id . Seul les id > 0 sont autorisés. + + + This id is not unique. + Cet idientifiant n'est pas unique. + + + File error. + Erreur de fichier. + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + Pas assez de poins pour créer une cannelure. + + + This spline does not exist. + La cannelure n'existe pas. + + + Can't cut spline path with one point + Impossible de couper une cannelure avec un point + + + + VTableGraphicsView + + can't find detail + détail introuvable + + + detail found + détail trouvé + + + + VToolDetail + + Options + Options + + + Delete + Supprimer + + + + VToolOptionsPropertyBrowser + + Base point + Point de départ + + + Point label + Désignation du point + + + Position + Position + + + Point at distance and angle + Point à distance et angle + + + Line type + Type de ligne + + + Length + Longueur + + + Angle + Angle + + + Point at distance along line + Point à distance le long d'un ligne + + + Arc + Arc + + + Radius + Rayon + + + First angle + Premier angle + + + Second angle + Deuxième angle + + + Point along bisector + point le long d'une bissectrice + + + Cut arc tool + Outil Coupe Arc + + + Tool for segmenting a curve + Outil pour segmenter une courbe + + + Tool segment a pathed curve + Outil segmantation de chemin de courbe + + + Perpendicular point along line + Point perpendiculaire le long d'une ligne + + + Line between points + Ligne entre plusieurs points + + + Point at line intersection + Point à l'intersection de lignes + + + + Point along perpendicular + Point le long d'une perpendiculaire + + + Additional angle degrees + Angle supplémentaire + + + Point at intersection of arc and line + Point à l'intersection d'un arc et d'une ligne + + + Tool to make point from x & y of two other points + Créer un nouveau point à partir des coordonnées x & y de deux points différents + + + Special point on shoulder + Point spécial d'épaule + + + Curve tool + Outils courbe + + + Curve factor + facteur de courbe + + + Tool for path curve + Outil pour chemin de courbe + + + Tool triangle + Outil triangle + + + Point intersection line and axis + Point à l'intersection d'un axe et d'une ligne + + + + Variables + + Line_ + Left symbol _ in name + Ligne_ + + + AngleLine_ + Left symbol _ in name + + + + Arc_ + Left symbol _ in name + Arc_ + + + Spl_ + Left symbol _ in name + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + Programme de réalisation de patrons. + + + Pattern file. + Fichier Patron. + + + diff --git a/share/translations/valentina_he_IL.ts b/share/translations/valentina_he_IL.ts new file mode 100644 index 000000000..c404d266f --- /dev/null +++ b/share/translations/valentina_he_IL.ts @@ -0,0 +1,6256 @@ + + + + + AddDet + + Add detail + + + + + AddPatternPiece + + Add pattern piece %1 + + + + + AddToCalc + + Add object + + + + + AddUnionDetails + + Add union details + + + + + CommunityPage + + Server + + + + Server name/IP + + + + Secure connection + + + + Proxy settings + + + + Use Proxy + + + + Proxy address + + + + Proxy port + + + + Proxy user + + + + Proxy pass + + + + User settings + + + + User Name + + + + Save password + + + + Password + + + + + ConfigDialog + + Apply + + + + &Cancel + + + + &Ok + + + + Config Dialog + + + + Configuration + + + + Pattern + + + + Community + + + + Paths + + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + + + + Default unit updated and will be used the next pattern creation + + + + Save + שמור + + + Auto-save modified pattern + + + + min + + + + Interval: + + + + Language + + + + GUI language + + + + Decimal separator parts + + + + With OS options (%1) + + + + Default unit + + + + Centimeters + + + + Millimiters + + + + Inches + + + + Label language + + + + Send crash reports + + + + Send crash reports (recommended) + + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + + + + + DelTool + + Delete tool + + + + + DeleteDetail + + Delete tool + + + + + DeletePatternPiece + + Delete pattern piece %1 + + + + + DialogAboutApp + + About Valentina + + + + Valentina version + + + + Contributors + + + + Built on %3 at %4 + + + + Web site : %1 + + + + Warning + + + + Cannot open your default browser + + + + Build revision: + + + + + DialogAlongLine + + Point along line + + + + Length + אורך + + + Insert variable into the formula + + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + תווית הנקודה + + + First point + נקודה ראשונה + + + First point of line + נקודה ראשונה בקו + + + Second point + נקודה שנייה + + + Second point of line + נקודה שנייה בקו + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogArc + + Arc + + + + Radius + רדיוס + + + Insert variable into the formula + + + + Calculate value + לחשב ערך + + + Value of radius + ערך הרדיוס + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + First angle + + + + Insert variable into formula + + + + Value of first angle + + + + Second angle + + + + Insert marked variable into formula + + + + Value of second angle + + + + Center point + נקודת מרכז + + + Select point of center of arc + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Value of angle of line. + + + + Error + + + + Radius can't be negative + + + + Angles equal + + + + + DialogBisector + + Bisector + + + + Length + אורך + + + Insert marked variable into the formula + + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + תווית הנקודה + + + First point + נקודה ראשונה + + + First point of angle + + + + Second point + נקודה שנייה + + + Second point of angle + + + + Third point + + + + Third point of angle + + + + Type of line + סוג הקו + + + Show line from second point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of angle + + + + Select third point of angle + + + + + DialogCurveIntersectAxis + + Curve intersect axis + + + + Angle + + + + Calculate value + לחשב ערך + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + Curve + עקומה + + + Point label + תווית הנקודה + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select axis point + + + + + DialogCutArc + + Cut arc + + + + Length + אורך + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Arc + + + + Selected curve + + + + Point label + תווית הנקודה + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSpline + + Cut curve + + + + Length + אורך + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + עקומה + + + Selected curve + + + + Point label + תווית הנקודה + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSplinePath + + Cut curve path + + + + Length + אורך + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + עקומה + + + Selected curve path + + + + Point label + תווית הנקודה + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogDetail + + Detail + + + + Bias X + + + + cm + + + + Bias Y + + + + Options + אפשרויות + + + Name of detail + + + + Seam allowance + + + + Width + רוחב + + + Closed + + + + Delete + למחוק + + + Got wrong scene object. Ignore. + + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + + + + Formula + + + + Insert variable into formula + + + + Calculate value + לחשב ערך + + + Value of first angle + + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogEndLine + + Point in the end of a line + + + + Length + אורך + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Angle + + + + Value of angle + + + + Base point + + + + First point of line + נקודה ראשונה בשורה + + + Point label + תווית הנקודה + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogHeight + + Height + + + + Point label + תווית הנקודה + + + Base point + + + + First point of line + נקודה ראשונה בשורה + + + Second point of line + נקודה שנייה בשורה + + + Type of line + סוג הקו + + + Show line from first point to our point + + + + Select first point of line + לבחור נקודה ראשונה + + + Select second point of line + + + + + DialogHistory + + History + + + + Tool + כלי + + + Can't create record. + + + + %1 - Base point + + + + %1_%2 - Line from point %1 to point %2 + + + + %3 - Point along line %1_%2 + + + + %1 - Point of shoulder + + + + %3 - normal to line %1_%2 + + + + %4 - bisector of angle %1_%2_%3 + + + + %5 - intersection of lines %1_%2 and %3_%4 + + + + Curve %1_%2 + + + + Arc with center in point %1 + + + + Curve point %1 + + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + + + + Point of perpendicular from point %1 to line %2_%3 + + + + Triangle: axis %1_%2, points %3 and %4 + + + + %1 - point of intersection %2 and %3 + + + + %1 - cut arc with center %2 + + + + %1 - cut curve %2_%3 + + + + %1 - cut curve path %2 + + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + Increments + + + + Measurements + + + + Load another measurements table + + + + Personal information + + + + Given name + + + + Family name + + + + Birth date + + + + Sex + + + + Email + + + + Hide empty measurements + + + + Name + + + + The calculated value + הערך המחושב + + + Base value + + + + In sizes + + + + In heights + + + + Description + + + + Lines + קווים + + + Line + קו + + + Length + אורך + + + Curves + עקומות + + + Curve + עקומה + + + Arcs + + + + Arc + + + + File error. + + + + male + + + + female + + + + Could not save GivenName + + + + Could not save FamilyName + + + + Could not save Email + + + + Could not save Sex + + + + Could not save BirthDate + + + + Measurements use different units than pattern. This pattern required measurements in %1 + + + + Individual measurements (*.vit) + + + + Open file + + + + Wrong units. + + + + Standard measurements (*.vst) + + + + Name_%1 + + + + Can't save measurement + + + + + DialogIndividualMeasurements + + Individual measurements + + + + Pattern piece name + + + + Exist measurements + + + + Path: + + + + Given name: + + + + Family name: + + + + New measurements + + + + Units: + + + + Could not create measurements file + + + + Please try again or change file + + + + File error. + + + + Individual measurements (*.vit) + + + + Open file + + + + Where save measurements? + + + + Centimeters + + + + Millimiters + + + + Inches + + + + + DialogLine + + Line + קו + + + First point + נקודה ראשונה + + + Second point + נקודה שנייה + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Select second point + לבחור נקודה שנייה + + + + DialogLineIntersect + + Intersection of lines + הצטלבות של קווים + + + Point label + תווית הנקודה + + + First line + + + + First point + נקודה ראשונה + + + Second point + נקודה שנייה + + + Second line + + + + Select second point of first line + + + + Select first point of second line + + + + Select second point of second line + + + + + DialogLineIntersectAxis + + Line intersect axis + + + + Angle + + + + Calculate value + לחשב ערך + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + First line point + + + + Second line point + + + + Point label + תווית הנקודה + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select second point of line + + + + Select axis point + + + + + DialogMeasurements + + Measurements + + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + + + + Graduation + + + + Use for creation pattern standard measurement table + + + + Individual + + + + Use for creation pattern individual measurements + + + + + DialogNormal + + Normal + + + + Length + אורך + + + Insert variable into formula + + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + תווית הנקודה + + + First point + נקודה ראשונה + + + Second point + נקודה שנייה + + + Additional angle degrees + + + + Type of line + סוג הקו + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogPatternProperties + + Pattern properties + + + + Description + + + + Author name + + + + Pattern description + + + + For technical notes. + + + + Heights and Sizes + + + + All heights (cm) + + + + All sizes (cm) + + + + + DialogPatternXmlEdit + + XML Editor + + + + Value : + + + + Name : + + + + <No selection> + + + + Type : + + + + Add attribute + + + + Add son + + + + Remove attribute + + + + Remove node + + + + Set + + + + Cancel + + + + Apply changes + + + + Undo last + + + + Immediate apply + + + + Base selection + + + + All pattern pieces + + + + No changes + + + + Cannot delete previously created node + + + + No changes left + + + + Cannot undo change + + + + <no value> + + + + Unchanged + + + + Cannot delete previously created attribute + + + + Node Name + + + + Name: + + + + Node Value (may be empty) + + + + Value: + + + + Attribute Name + + + + Attribute Value + + + + No selection + + + + Root node + + + + Node + + + + Attribute + + + + + DialogPointOfContact + + Point of contact + + + + Radius + רדיוס + + + Insert variable into formula + + + + Calculate value + לחשב ערך + + + Value of radius + ערך הרדיוס + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + תווית הנקודה + + + Center of arc + + + + Select point of center of arc + + + + Top of the line + + + + End of the line + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula. + + + + Select second point of line + + + + + DialogPointOfIntersection + + Point of intersection + + + + Point label + תווית הנקודה + + + vertical point + + + + First point of angle + + + + horizontal point + + + + Second point of angle + + + + Select point horizontally + + + + + DialogShoulderPoint + + Point of shoulder + + + + Length + אורך + + + Insert variable into formula + + + + Calculate value + לחשב ערך + + + Value of length + ערך האורך + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + תווית הנקודה + + + First point + נקודה ראשונה + + + Second point + נקודה שנייה + + + Third point + + + + Type of line + סוג הקו + + + Show line from first point to our point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + אורך הקווים + + + Length of arcs + + + + Length of curves + אורך העקומות + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select first point of line + לבחור נקודה ראשונה + + + Select second point of line + + + + + DialogSinglePoint + + Single point + + + + Coordinates on the sheet + + + + Coordinates + + + + Y coordinate + + + + X coordinate + + + + Point label + תווית הנקודה + + + + DialogSpline + + Curve + עקומה + + + First point + נקודה ראשונה + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Second point + נקודה שנייה + + + Length ratio of the second control point + + + + The angle of the second control point + + + + Coefficient of curvature of the curve + + + + Select last point of curve + + + + + DialogSplinePath + + Curved path + + + + Point of curve + + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Length ratio of the second control point + + + + The angle of the second control point + + + + List of points + + + + Coefficient of curvature of the curve + + + + Select point of curve path + + + + + DialogStandardMeasurements + + Standard table + + + + Pattern piece name + + + + Standard measurements table + + + + File error. + + + + + DialogTool + + Error + + + + Empty field + + + + Value can't be 0 + + + + Value + + + + Height + + + + Size + + + + Line length + אורך הקו + + + Arc length + + + + Curve length + אורך העקומה + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + + + + Point label + תווית הנקודה + + + First point of axis + + + + First point of line + + + + Second point of axis + + + + First point + נקודה ראשונה + + + Second point + נקודה שנייה + + + Select second point of axis + + + + Select first point + לבחור נקודה ראשונה + + + Select second point + לבחור נקודה שנייה + + + + DialogUndo + + Broken formula + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + + &Undo + + + + &Fix formula + + + + &Cancel + + + + + DialogUnionDetails + + Union details + + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + + + Select first point + לבחור נקודה ראשונה + + + Select second point + לבחור נקודה שנייה + + + Select another second point + + + + Select detail + + + + + Functions + + sin + sine function + + + + cos + cosine function + + + + tan + tangens function + + + + asin + arcus sine function + + + + acos + arcus cosine function + + + + atan + arcus tangens function + + + + sinh + hyperbolic sine function + + + + cosh + hyperbolic cosine + + + + tanh + hyperbolic tangens function + + + + asinh + hyperbolic arcus sine function + + + + acosh + hyperbolic arcus tangens function + + + + atanh + hyperbolic arcur tangens function + + + + log2 + logarithm to the base 2 + + + + log10 + logarithm to the base 10 + + + + log + logarithm to the base 10 + + + + ln + logarithm to base e (2.71828...) + + + + exp + e raised to the power of x + + + + sqrt + square root of a value + + + + sign + sign function -1 if x<0; 1 if x>0 + + + + rint + round to nearest integer + + + + abs + absolute value + + + + min + min of all arguments + + + + max + max of all arguments + + + + sum + sum of all arguments + + + + avg + mean value of all arguments + + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + Valentina + + + + Tools for creating points. + + + + Point + נקודה + + + Point along perpendicular + + + + Special point on shoulder. + + + + Tool triangle. + + + + Perpendicular point along line + + + + Point along bisector + + + + Point at intersection of arc and line. + + + + Tool to make point from x & y of two other points. + + + + Point at distance and angle + + + + Point at distance along line + + + + Point of intersection line and axis + + + + ... + + + + Tools for creating lines. + כלים ליצירת קווים. + + + Line + קו + + + Line between points + + + + Point at line intersection + + + + Tools for creating curves. + + + + Curve + עקומה + + + Curve tool. + + + + Tool for path curve. + + + + Tool for segmenting a curve. + + + + Tool segment a pathed curve. + + + + Tools for creating arcs. + + + + Arc + + + + Arc tool. + + + + Cut arc tool. + + + + Tools for creating details. + + + + Detail + + + + Tool new detail. + + + + Tool for union two details. + + + + &File + + + + &Help + + + + &Pattern piece + + + + Measurements + + + + Window + + + + Toolbar files + + + + ToolBar modes + + + + Toolbar pattern + + + + Toolbar options + + + + Toolbar tools + + + + Tool options + + + + New + חדש + + + &New + + + + Create a new pattern + + + + Ctrl+N + + + + Open + + + + &Open + + + + Open file with pattern + + + + Save + שמור + + + &Save + + + + Save pattern + + + + Ctrl+S + + + + Save &As... + + + + Save not yet saved pattern + + + + Ctrl+Shift+S + + + + Draw + + + + Draw mode + + + + Ctrl+W + + + + Details + + + + Details mode + + + + Ctrl+E + + + + Pointer tools + + + + New pattern piece + + + + Add new pattern piece + + + + Ctrl+Shift+N + + + + Change the label of pattern piece + + + + Table of variables + + + + Tables of variables + + + + Ctrl+T + + + + History + + + + Ctrl+H + + + + Export pattern (layout) + + + + Create layout + + + + Ctrl+L + + + + About &Qt + + + + &About Valentina + + + + E&xit + + + + Exit the application + + + + Ctrl+Q + + + + Preferences + + + + Pattern properties + + + + Zoom in + + + + zoom in + + + + Zoom out + + + + Edit pattern XML code + + + + Original zoom + + + + Original Zoom + + + + Zoom fit best + + + + Ctrl+= + + + + Stop + + + + Stop using tool + + + + Repot Bug... + + + + Report bug + + + + Close window + + + + Online help + + + + Show online help + + + + Pattern piece %1 + + + + Individual measurements is under development + + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + Select point + + + + Select first point + לבחור נקודה ראשונה + + + Select first point of line + לבחור נקודה ראשונה + + + Select first point of angle + + + + Select first point of first line + + + + Select first point curve + + + + Select simple curve + + + + Select point of center of arc + + + + Select point of curve path + + + + Select curve path + + + + Select points, arcs, curves clockwise. + + + + Select base point + + + + Select first point of axis + + + + Select point vertically + + + + Select detail + + + + Select arc + + + + Select curve + + + + About Qt + + + + Height: + + + + Size: + + + + Pattern Piece: + + + + Pattern files (*.val) + + + + pattern + + + + /pattern.val + + + + Save as + + + + Could not save file + + + + Open file + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Bad id. + + + + File saved + + + + untitled.val + + + + Unsaved change + + + + The pattern has been modified. +Do you want to save your changes? + + + + &Undo + + + + &Redo + + + + Pattern piece: + + + + Enter a new label for the pattern piece. + + + + This file already opened in another window. + + + + Wrong units. + + + + Application doesn't support standard table with inches. + + + + File error. + + + + File loaded + + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + + + + Reopen files. + + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + + + + could not be found. Do you want to update the file location + + + + Standard measurements (*.vst) + + + + Individual measurements (*.vit) + + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + + + + Around middle part of Neck + Full measurement description + + + + Around Neck at base + Full measurement description + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + NeckPoint to ShoulderTip + Full measurement description + + + + Armpit to Waist side + Full measurement description + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + Around HighHip, parallel to floor + Full measurement description + + + + Around Hip, parallel to floor + Full measurement description + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + + + + Back Waist side to side + Full measurement description + + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + + + + Around Calf + Full measurement description + + + + Around Ankle + Full measurement description + + + + Knee to Floor + Full measurement description + + + + Ankle to Floor + Full measurement description + + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + + + + Waist side to Hip + Full measurement description + + + + Waist side to Knee + Full measurement description + + + + Crotch to Floor along inside leg + Full measurement description + + + + Size + Full measurement description + + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + + + + Head height + Full measurement description + + + + Body position + Full measurement description + + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + + + + Mid-neck girth + Full measurement name + + + + Neck Base girth + Full measurement name + + + + Head and Neck length + Full measurement name + + + + Front Center length + Full measurement name + + + + Back Center length + Full measurement name + + + + Shoulder length + Full measurement name + + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + + + + Shoulder girth + Full measurement name + + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + + + + HighHip girth + Full measurement name + + + + Hip girth + Full measurement name + + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + + + + Shoulder height + Full measurement name + + + + Head height + Full measurement name + + + + Body position + Full measurement name + + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + + + + + MoveSpline + + Move spline + + + + + MoveSplinePath + + Move spline path + + + + + PathPage + + Open Directory + + + + Path that use Valentina + + + + Default + + + + Edit + + + + Type + + + + Path + + + + Individual measurements + + + + Patterns + + + + + PatternPage + + User + + + + User name + + + + Graphical output + + + + Use antialiasing + + + + Undo + + + + Count steps (0 - no limit) + + + + + PostfixOperators + + cm + centimeter + + + + mm + millimeter + + + + in + inch + + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + + + + Add node + + + + Move detail + + + + mm + + + + cm + + + + inch + + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + Save detail option + + + + + SaveToolOptions + + Save tool option + + + + + TableWindow + + Create a layout + + + + toolBar + + + + Save + שמור + + + Save layout + + + + Next + + + + Next detail + + + + Turn + + + + Turn the detail 90 degrees + + + + Stop + + + + Stop laying + + + + Enlarge letter + + + + Enlarge the length of the sheet + + + + Reduce sheet + + + + Reduce the length of the sheet + + + + Mirroring + + + + Zoom In + + + + Zoom Out + + + + 0 details left. + + + + Collisions not found. + + + + %1 details left. + + + + untitled + + + + Svg files (*.svg) + + + + PDF files (*.pdf) + + + + Images (*.png) + + + + PS files (*.ps) + + + + EPS files (*.eps) + + + + Collisions found. + + + + Creating file '%1' failed! %2 + + + + Critical error! + + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + + + + Do you really want delete? + + + + + VApplication + + Error parsing file. Program will be terminated. + + + + Error bad id. Program will be terminated. + + + + Error can't convert value. Program will be terminated. + + + + Error empty parameter. Program will be terminated. + + + + Error wrong id. Program will be terminated. + + + + Something's wrong!! + + + + + VContainer + + Can't find object + + + + Can't cast object + + + + Can't find object. Type mismatch. + + + + + VDomDocument + + Can't convert toUInt parameter + + + + Can't convert toBool parameter + + + + Got empty parameter + + + + Can't convert toDouble parameter + + + + Can't open file %1: +%2. + + + + Can't open schema file %1: +%2. + + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + + + + Parsing error file %3 in line %1 column %2 + + + + Couldn't get node + + + + Got wrong parameter id. Need only id > 0. + + + + This id is not unique. + + + + Could not copy temp file to document file + + + + Could not remove document file + + + + + VDrawTool + + Edit wrong formula + + + + Options + אפשרויות + + + Delete + למחוק + + + + VException + + Critical error! + + + + + VFormula + + Error + + + + + VFormulaProperty + + Value + + + + Formula + + + + + VPE::VBoolProperty + + True + + + + False + + + + + VPE::VFileEditWidget + + Directory + + + + Open File + + + + + VPattern + + Can't find tool in table. + + + + Error no unique id. + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Error creating or updating detail + + + + Error creating or updating single point + + + + Error creating or updating point of end line + + + + Error creating or updating point along line + + + + Error creating or updating point of shoulder + + + + Error creating or updating point of normal + + + + Error creating or updating point of bisector + + + + Error creating or updating point of lineintersection + + + + Error creating or updating point of contact + + + + Error creating or updating modeling point + + + + Error creating or updating height + + + + Error creating or updating triangle + + + + Error creating or updating point of intersection + + + + Error creating or updating cut spline point + + + + Error creating or updating cut spline path point + + + + Error creating or updating cut arc point + + + + Error creating or updating point of intersection line and axis + + + + Error creating or updating point of intersection curve and axis + + + + Error creating or updating line + + + + Error creating or updating simple curve + + + + Error creating or updating curve path + + + + Error creating or updating modeling simple curve + + + + Error creating or updating modeling curve path + + + + Error creating or updating simple arc + + + + Error creating or updating modeling arc + + + + Error creating or updating union details + + + + File error. + + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + + + + This spline does not exist. + + + + Can't cut spline path with one point + + + + + VTableGraphicsView + + can't find detail + + + + detail found + + + + + VToolDetail + + Options + אפשרויות + + + Delete + למחוק + + + + VToolOptionsPropertyBrowser + + Base point + + + + Point label + תווית הנקודה + + + Position + + + + Point at distance and angle + + + + Line type + + + + Length + אורך + + + Angle + + + + Point at distance along line + + + + Arc + + + + Radius + רדיוס + + + First angle + + + + Second angle + + + + Point along bisector + + + + Cut arc tool + + + + Tool for segmenting a curve + + + + Tool segment a pathed curve + + + + Perpendicular point along line + + + + Line between points + + + + Point at line intersection + + + + Point along perpendicular + + + + Additional angle degrees + + + + Point at intersection of arc and line + + + + Tool to make point from x & y of two other points + + + + Special point on shoulder + + + + Curve tool + + + + Curve factor + + + + Tool for path curve + + + + Tool triangle + + + + Point intersection line and axis + + + + + Variables + + Line_ + Left symbol _ in name + + + + AngleLine_ + Left symbol _ in name + + + + Arc_ + Left symbol _ in name + + + + Spl_ + Left symbol _ in name + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + + + + Pattern file. + + + + diff --git a/share/translations/valentina_id_ID.ts b/share/translations/valentina_id_ID.ts new file mode 100644 index 000000000..44fd724af --- /dev/null +++ b/share/translations/valentina_id_ID.ts @@ -0,0 +1,7784 @@ + + + + + AddDet + + + Add detail + tambahkan detail + + + + AddPatternPiece + + + Add pattern piece %1 + Tambahkan Potongan Pola %1 + + + + AddToCalc + + + Add object + tambahkan obyek + + + + AddUnionDetails + + + Add union details + Tambah rincian himpunan + + + + CommunityPage + + + Server + Server + + + + Server name/IP + Nama Server/IP + + + + Secure connection + Sambungan Aman + + + + Proxy settings + Setingan Proxy + + + + Use Proxy + Gunakan Proxy + + + + Proxy address + Alamat Proxy + + + + Proxy port + Saluran Proxy + + + + Proxy user + Pengguna Proxy + + + + Proxy pass + + + + + User settings + Pengaturan Pengguna + + + + User Name + Nama Pengguna + + + + Save password + Simpan sandi + + + + Password + Sandi + + + + ConfigDialog + + + Apply + Terapkan + + + + &Cancel + &Batalkan + + + + &Ok + &Ok + + + + Config Dialog + Dialog konfigurasi + + + + Configuration + Konfigurasi + + + + Pattern + Pola + + + + Community + Komunitas + + + + Paths + + + + + ConfigurationPage + + + Setup user interface language updated and will be used the next time start + Pengaturan bahasa antarmuka pengguna diperbarui dan akan digunakan waktu mulai berikutnya + + + + Default unit updated and will be used the next pattern creation + Unit standar diperbarui dan akan digunakan pada pembuatan pola berikutnya + + + + Save + Simpan + + + + Auto-save modified pattern + Simpan otomatis Pola yang telah dimodifikasi + + + + Interval: + selang waktu + + + + min + minimal + + + + Language + Bahasa + + + + GUI language + Bahasa GUI + + + + Decimal separator parts + komponen pemisah desimal + + + + With OS options (%1) + dengan pilihan OS (%1) + + + + Default unit + Unit Standar + + + + Centimeters + Centimeter + + + + Millimiters + Milimeter + + + + Inches + Inchi + + + + Label language + label bahasa + + + + Send crash reports + Kirim laporan kerusakan + + + + Send crash reports (recommended) + Kirim laporan kerusakan (disarankan) + + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + Setelah setiap kerusakan Valentina mengumpulkan informasi yang dapat membantu kami memperbaiki suatu masalah. Kami tidak mengumpulkan informasi pribadi apapun. Temukan lebih lanjut tentang apa <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports"> jenis informasi </a> kami kumpulkan. + + + + DelTool + + + Delete tool + Hapus alat bantu + + + + DeleteDetail + + + Delete tool + Hapus alat bantu + + + + DeletePatternPiece + + + Delete pattern piece %1 + Hapus bagian pola % 1 + + + + DialogAboutApp + + + About Valentina + Mengenai Valentina + + + + Valentina version + Versi Valentina + + + + Build revision: + + + + + Contributors + para kontributor + + + Based on Qt %2 (32 bit) + Berdasarkan pada Qt %2 (32 bit) + + + + Built on %3 at %4 + Dibuat pada %3 at %4 + + + + Web site : %1 + Situs web : % 1 + + + + Warning + peringatan + + + + Cannot open your default browser + Tidak dapat membuka peramban bawaan Anda + + + + DialogAlongLine + + + Point along line + Titik di sepanjang garis + + + + Length + panjang + + + + Insert variable into the formula + Masukkan variabel ke dalam rumus + + + + Calculate value + Hitung nilai + + + + Value of length + Nilai panjang + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan penuh perhitungan dalam kotak pesan</p></body></html> + + + + Point label + label titik + + + + First point + Titik pertama + + + + First point of line + Titik pertama dari baris + + + + Second point + titik kedua + + + + Second point of line + titik kedua dari baris + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Input data + masukkan data + + + + Size and height + Ukuran dan tinggi + + + + Measurements + pengukuran + + + + Increments + penambahan + + + + Length of lines + Panjang garis + + + + Length of arcs + Panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + Select second point of line + Pilih titik kedua dari garis + + + + DialogArc + + + Arc + busur + + + + Radius + radius + + + + + Insert variable into the formula + sisipkan variabel ke dalam formula + + + + + + Calculate value + hitung nilai + + + + Value of radius + nilai radius + + + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan perhitungan penuh dalam kotak pesa</p></body></html> + + + + Insert variable into formula + sisipkan variabel ke dalam formula + + + + Value of first angle + nilai dari sudut pertama + + + + Measurements + pengukuran + + + + First angle + sudut pertama + + + + Second angle + sudut kedua + + + + Insert marked variable into formula + sisipkan variabel yang ditandai ke dalam formula + + + + Value of second angle + nilai dari sudut kedua + + + + Center point + titik tengah + + + + Select point of center of arc + pilih titik tengah dari busur + + + + Input data + masukkan data + + + + Size and height + ukuran dan tinggi + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + panjang kurva + + + + Angle of lines + sudut garis + + + + Hide empty measurements + sembunyikan pengukuran yang kosong + + + + Variables + variabel + + + + Value of angle of line. + nilai sudut garis + + + + + + Error + + + + + Radius can't be negative + + + + + + Angles equal + + + + + DialogBisector + + + Bisector + + + + + Length + panjang + + + + Insert marked variable into the formula + sisipkan variabel yang ditandai ke dalam rumus + + + + Calculate value + hitung nilai + + + + Value of length + nilai panjang + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan penuh perhitungan dalam kotak pesan</p></body></html> + + + + Point label + label titik + + + + First point + Titik pertama + + + + First point of angle + Titik pertama dari sudut + + + + Second point + titik kedua + + + + Second point of angle + titik kedua dari sudut + + + + Third point + titik ketiga + + + + Third point of angle + titik ketiga dari sudut + + + + Type of line + Jenis baris + + + + Show line from second point to this point + Tampilkan garis dari titik kedua ke titik ini + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + Panjang garis + + + + Length of arcs + Panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + Select second point of angle + Pilih titik kedua dari sudut + + + + Select third point of angle + Pilih titik ketiga dari garis + + + + DialogCurveIntersectAxis + + + Curve intersect axis + sumbu perpotongan kurva + + + + Angle + sudut + + + + Calculate value + Hitung nilai + + + + Value of angle + nilai dari sudut + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan penuh perhitungan dalam kotak pesan</p></body></html> + + + + Axis point + titik sumbu + + + + + First point of line + Titik pertama dari baris + + + + Curve + kurva + + + + Point label + label titik + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables + variabel + + + + Select axis point + pilih titik sumbu + + + + DialogCutArc + + + Length + panjang + + + + Cut arc + potong busur + + + + Calculate value + Hitung nilai + + + + Value of length + Nilai panjang + + + + _ + - + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan perhitungan penuh dalam kotak pesan</p></body></html> + + + + Arc + busur + + + + Selected curve + kurva yang telah dipilih + + + + Point label + label titik + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + DialogCutSpline + + + Length + panjang + + + + Cut curve + potong kurva + + + + Calculate value + Hitung nilai + + + + Value of length + Nilai panjang + + + + _ + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan perhitungan penuh dalam kotak pesan</p></body></html> + + + + Curve + kurva + + + + Selected curve + kurva yang telah dipilih + + + + Point label + label titik + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + DialogCutSplinePath + + + Length + panjang + + + + Cut curve path + potong jalur curva + + + + Calculate value + Hitung nilai + + + + Value of length + Nilai panjang + + + + _ + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan perhitungan penuh dalam kotak pesan</p></body></html> + + + + Curve + kurva + + + + Selected curve path + jalur kurva yang telah dipilih + + + + Point label + label titik + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + DialogDetail + + + + Detail + rincial + + + + Bias X + + + + + + + cm + cm + + + + Bias Y + + + + + Reverse + + + + + Options + pilihan + + + + Name of detail + nama rincian + + + + Seam allowance + kampuh + + + + Width + lebar + + + + Closed + tertutup + + + + Delete + hapus + + + + Got wrong scene object. Ignore. + + + + + DialogEditWrongFormula + + + Edit formula + edit rumus + + + + Formula + rumus + + + + Insert variable into formula + sisipkan variabel ke dalam rumus + + + + Calculate value + Hitung nilai + + + + Value of first angle + nilai dari sudut pertama + + + + _ + _ + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>Tampilkan perhitungan penuh dalam kotak pesan</p></body></html> + + + + Input data + masukan data + + + + Size and height + ukuran dan panjang + + + + Measurements + pengukuran + + + + Increments + tambahan + + + + Length of lines + panjang garis + + + + Length of arcs + panjang busur + + + + Length of curves + Panjang kurva + + + + Angle of lines + Sudut garis + + + + Hide empty measurements + Sembunyikan pengukuran kosong + + + + Variables + variabel + + + + DialogEndLine + + + Point in the end of a line + + + + + Length + panjang + + + + + Calculate value + + + + + Value of length + + + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + Angle + sudut + + + + Value of angle + nilai dari sudut + + + + Base point + + + + + First point of line + Titik pertama dari baris + + + + Point label + label titik + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Input data + + + + + Size and height + + + + + Measurements + pengukuran + + + + Increments + + + + + Length of lines + + + + + Length of arcs + + + + + Length of curves + + + + + Angle of lines + + + + + Hide empty measurements + + + + + Variables + variabel + + + + DialogHeight + + + Height + + + + + Point label + label titik + + + + Base point + + + + + + + + First point of line + Titik pertama dari baris + + + + Second point of line + titik kedua dari baris + + + + Type of line + Jenis baris + + + + Show line from first point to our point + + + + + Select first point of line + + + + + Select second point of line + Pilih titik kedua dari garis + + + + DialogHistory + + + History + + + + + + Tool + + + + + + + + + Can't create record. + + + + + %1 - Base point + + + + + + %1_%2 - Line from point %1 to point %2 + + + + + %3 - Point along line %1_%2 + + + + + %1 - Point of shoulder + + + + + %3 - normal to line %1_%2 + + + + + %4 - bisector of angle %1_%2_%3 + + + + + %5 - intersection of lines %1_%2 and %3_%4 + + + + + Curve %1_%2 + + + + + Arc with center in point %1 + + + + + Curve point %1 + + + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + + + + + Point of perpendicular from point %1 to line %2_%3 + + + + + Triangle: axis %1_%2, points %3 and %4 + + + + + %1 - point of intersection %2 and %3 + + + + + %1 - cut arc with center %2 + + + + + %1 - cut curve %2_%3 + + + + + %1 - cut curve path %2 + + + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + + + Increments + + + + + Email + Surel + + + + + Name + Nama + + + + + The calculated value + + + + + + Base value + + + + + + In sizes + + + + + + + Description + + + + + + Measurements + pengukuran + + + + Load another measurements table + + + + + Personal information + + + + + Given name + + + + + Family name + + + + + Birth date + + + + + Sex + + + + + Hide empty measurements + + + + + + In heights + + + + + Lines + + + + + Line + + + + + + + Length + panjang + + + + Curves + + + + + Curve + kurva + + + + Arcs + + + + + Arc + busur + + + + + + File error. + + + + + male + + + + + female + + + + + Could not save GivenName + + + + + Could not save FamilyName + + + + + Could not save Email + + + + + Could not save Sex + + + + + Could not save BirthDate + + + + + Measurements use different units than pattern. This pattern required measurements in %1 + + + + + Individual measurements (*.vit) + + + + + + Open file + Buka file + + + + + Wrong units. + + + + + Standard measurements (*.vst) + + + + + Name_%1 + + + + + Can't save measurement + + + + + DialogIndividualMeasurements + + + Individual measurements + + + + + Pattern piece name + Nama potongan pola + + + + Exist measurements + + + + + + Path: + + + + + Given name: + + + + + Family name: + + + + + New measurements + + + + + Units: + + + + + Could not create measurements file + + + + + Please try again or change file + + + + + + File error. + + + + + + Individual measurements (*.vit) + + + + + Open file + + + + + Where save measurements? + + + + + Centimeters + Centimeter + + + + Millimiters + Milimeter + + + + Inches + Inchi + + + + DialogLine + + + Line + + + + + First point + Titik pertama + + + + Second point + titik kedua + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Select second point + + + + + DialogLineIntersect + + + Intersection of lines + + + + + Point label + label titik + + + + First line + + + + + + First point + Titik pertama + + + + + Second point + titik kedua + + + + Second line + + + + + Select second point of first line + + + + + Select first point of second line + + + + + Select second point of second line + + + + + DialogLineIntersectAxis + + + Line intersect axis + + + + + Angle + sudut + + + + Calculate value + + + + + Value of angle + nilai dari sudut + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + Axis point + titik sumbu + + + + + + First point of line + Titik pertama dari baris + + + + First line point + + + + + Second line point + + + + + Point label + label titik + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Input data + + + + + Size and height + + + + + Measurements + pengukuran + + + + Increments + + + + + Length of lines + + + + + Length of arcs + + + + + Length of curves + + + + + Angle of lines + + + + + Hide empty measurements + + + + + Variables + variabel + + + + Select second point of line + Pilih titik kedua dari garis + + + + Select axis point + pilih titik sumbu + + + + DialogMeasurements + + + Measurements + pengukuran + + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + + + + + Graduation + + + + + Use for creation pattern standard measurement table + + + + + Individual + + + + + Use for creation pattern individual measurements + + + + + DialogNormal + + + Normal + + + + + Length + panjang + + + + Insert variable into formula + + + + + Calculate value + + + + + Value of length + + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + Point label + label titik + + + + First point + Titik pertama + + + + Second point + titik kedua + + + + Additional angle degrees + + + + + Type of line + Jenis baris + + + + Show line from first point to this point + Tampilkan garis dari titik pertama ke titik ini + + + + Input data + + + + + Size and height + + + + + Measurements + pengukuran + + + + Increments + + + + + Length of lines + + + + + Length of arcs + + + + + Length of curves + + + + + Angle of lines + + + + + Hide empty measurements + + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + Select second point of line + Pilih titik kedua dari garis + + + + DialogPatternProperties + + + Pattern properties + + + + + Description + + + + + Author name + Nama Pembuat + + + + Pattern description + Keterangan Pola + + + + For technical notes. + Untuk catatan teknis + + + + Heights and Sizes + + + + + All heights (cm) + + + + + All sizes (cm) + + + + + DialogPatternXmlEdit + + + XML Editor + + + + + Value : + + + + + Name : + + + + + <No selection> + + + + + Type : + + + + + Add attribute + + + + + Add son + + + + + Remove attribute + + + + + Remove node + + + + + Set + + + + + Cancel + + + + + Apply changes + + + + + Undo last + + + + + Immediate apply + + + + + Base selection + + + + + All pattern pieces + + + + + + + + No changes + + + + + Cannot delete previously created node + + + + + No changes left + + + + + Cannot undo change + + + + + + <no value> + + + + + + Unchanged + + + + + Cannot delete previously created attribute + + + + + Node Name + + + + + + Name: + + + + + Node Value (may be empty) + + + + + + Value: + + + + + Attribute Name + + + + + Attribute Value + + + + + No selection + + + + + Root node + + + + + Node + + + + + Attribute + + + + + DialogPointOfContact + + + Point of contact + + + + + Radius + radius + + + + + Insert variable into formula + + + + + Calculate value + + + + + Value of radius + nilai radius + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + Point label + label titik + + + + Center of arc + + + + + + Select point of center of arc + pilih titik tengah dari busur + + + + Top of the line + + + + + End of the line + + + + + Input data + + + + + Size and height + + + + + Measurements + pengukuran + + + + Increments + + + + + Length of lines + + + + + Length of arcs + + + + + Length of curves + + + + + Angle of lines + + + + + Hide empty measurements + + + + + Variables - Click twice to insert into formula. + + + + + Select second point of line + Pilih titik kedua dari garis + + + + DialogPointOfIntersection + + + Point of intersection + + + + + Point label + label titik + + + + vertical point + + + + + First point of angle + Titik pertama dari sudut + + + + horizontal point + + + + + Second point of angle + titik kedua dari sudut + + + + Select point horizontally + + + + + DialogShoulderPoint + + + Point of shoulder + + + + + Length + panjang + + + + Insert variable into formula + + + + + Calculate value + + + + + Value of length + + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + Point label + label titik + + + + First point + Titik pertama + + + + Second point + titik kedua + + + + Third point + titik ketiga + + + + Type of line + Jenis baris + + + + Show line from first point to our point + + + + + Input data + + + + + Size and height + + + + + Measurements + pengukuran + + + + Increments + + + + + Length of lines + + + + + Length of arcs + + + + + Length of curves + + + + + Angle of lines + + + + + Hide empty measurements + + + + + Variables - Click twice to insert into formula + Variabel - Klik dua kali untuk menyisipkan ke dalam rumus + + + + Select first point of line + + + + + Select second point of line + Pilih titik kedua dari garis + + + + DialogSinglePoint + + + Single point + + + + + Coordinates on the sheet + + + + + Coordinates + + + + + Y coordinate + + + + + X coordinate + + + + + Point label + label titik + + + + DialogSpline + + + Curve + kurva + + + + First point + Titik pertama + + + + Length ratio of the first control point + + + + + The angle of the first control point + + + + + Second point + titik kedua + + + + Length ratio of the second control point + + + + + The angle of the second control point + + + + + Coefficient of curvature of the curve + + + + + Select last point of curve + + + + + DialogSplinePath + + + Curved path + + + + + Point of curve + + + + + Length ratio of the first control point + + + + + The angle of the first control point + + + + + Length ratio of the second control point + + + + + The angle of the second control point + + + + + List of points + + + + + Coefficient of curvature of the curve + + + + + Select point of curve path + + + + + DialogStandardMeasurements + + + Standard table + + + + + Pattern piece name + Nama potongan pola + + + + Standard measurements table + + + + + File error. + + + + + DialogTool + + + + + + + Error + + + + + + + Empty field + + + + + Value can't be 0 + + + + + Value + + + + + + Parser error: %1 + + + + + Height + + + + + Size + + + + + Line length + + + + + Arc length + + + + + Curve length + + + + + DialogTriangle + + + Triangle + + + + + Point label + label titik + + + + First point of axis + + + + + + + + First point of line + Titik pertama dari baris + + + + Second point of axis + + + + + First point + Titik pertama + + + + Second point + titik kedua + + + + Select second point of axis + + + + + Select first point + + + + + Select second point + + + + + DialogUndo + + + Broken formula + + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + + + &Undo + + + + + &Fix formula + + + + + &Cancel + &Batalkan + + + + DialogUnionDetails + + + Select first point + + + + + Select second point + + + + + + Select another second point + + + + + Select detail + + + + + Union details + + + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + + + + Functions + + + sin + sine function + + + + + cos + cosine function + + + + + tan + tangens function + + + + + asin + arcus sine function + + + + + acos + arcus cosine function + + + + + atan + arcus tangens function + + + + + sinh + hyperbolic sine function + + + + + cosh + hyperbolic cosine + + + + + tanh + hyperbolic tangens function + + + + + asinh + hyperbolic arcus sine function + + + + + acosh + hyperbolic arcus tangens function + + + + + atanh + hyperbolic arcur tangens function + + + + + log2 + logarithm to the base 2 + + + + + log10 + logarithm to the base 10 + + + + + log + logarithm to the base 10 + + + + + ln + logarithm to base e (2.71828...) + + + + + exp + e raised to the power of x + + + + + sqrt + square root of a value + + + + + sign + sign function -1 if x<0; 1 if x>0 + + + + + rint + round to nearest integer + + + + + abs + absolute value + + + + + min + min of all arguments + minimal + + + + max + max of all arguments + + + + + sum + sum of all arguments + + + + + avg + mean value of all arguments + + + + + InternalStrings + + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + + Valentina + + + + + Tools for creating points. + + + + + Point + + + + + Point at distance and angle + + + + + Special point on shoulder. + + + + + Point at intersection of arc and line. + + + + + Point along bisector + + + + + Point along perpendicular + + + + + Point at distance along line + + + + + Perpendicular point along line + + + + + Tool triangle. + + + + + Tool to make point from x & y of two other points. + + + + + Tools for creating lines. + + + + + Line + + + + + Line between points + + + + + Point at line intersection + + + + + Tools for creating curves. + + + + + Curve + kurva + + + + Curve tool. + + + + + Tool for path curve. + + + + + Tool segment a pathed curve. + + + + + Tool for segmenting a curve. + + + + + Point of intersection line and axis + + + + + + + ... + + + + + Tools for creating arcs. + + + + + Arc + busur + + + + Arc tool. + + + + + Cut arc tool. + + + + + Tools for creating details. + + + + + Detail + rincial + + + + Tool new detail. + + + + + Tool for union two details. + + + + + &File + + + + + &Help + + + + + &Pattern piece + + + + + Measurements + pengukuran + + + + Window + + + + + Toolbar files + + + + + ToolBar modes + + + + + Toolbar pattern + + + + + Toolbar options + + + + + Toolbar tools + + + + + Tool options + + + + + Save &As... + + + + + Export pattern (layout) + + + + + About &Qt + + + + + &About Valentina + + + + + E&xit + + + + + Exit the application + + + + + Preferences + + + + + Zoom in + + + + + Original zoom + + + + + Original Zoom + + + + + Zoom fit best + + + + + Ctrl+= + + + + + Stop + + + + + Stop using tool + + + + + Repot Bug... + + + + + Report bug + + + + + Close window + + + + + Online help + + + + + Show online help + + + + + zoom in + + + + + + Zoom out + + + + + Edit pattern XML code + + + + + Pattern properties + + + + + New + + + + + &New + + + + + Create a new pattern + + + + + Ctrl+N + + + + + Open + + + + + &Open + + + + + Open file with pattern + + + + + Save + Simpan + + + + &Save + + + + + Save pattern + + + + + Ctrl+S + + + + + Save as + + + + + Save not yet saved pattern + + + + + Ctrl+Shift+S + + + + + Draw + + + + + Draw mode + + + + + Ctrl+W + + + + + Details + + + + + Details mode + + + + + Ctrl+E + + + + + + Pointer tools + + + + + New pattern piece + + + + + Add new pattern piece + + + + + Ctrl+Shift+N + + + + + + Change the label of pattern piece + + + + + Table of variables + + + + + Tables of variables + + + + + Ctrl+T + + + + + History + + + + + Ctrl+H + + + + + Create layout + + + + + Ctrl+L + + + + + About Qt + + + + + Ctrl+Q + + + + + Pattern piece %1 + + + + + Pattern piece: + + + + + Enter a new label for the pattern piece. + + + + + + + Select point + + + + + Individual measurements is under development + + + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + + Select first point + + + + + + + Select first point of line + + + + + Select first point of angle + + + + + Select first point of first line + + + + + Select first point curve + + + + + Select simple curve + + + + + Select point of center of arc + pilih titik tengah dari busur + + + + Select point of curve path + + + + + Select curve path + + + + + Select points, arcs, curves clockwise. + + + + + Select base point + + + + + Select first point of axis + + + + + Select point vertically + + + + + Select detail + + + + + Select arc + + + + + Select curve + + + + + Size: + + + + + pattern + + + + + Critical error! + + + + + Error parsing file (std::bad_alloc). + + + + + Bad id. + + + + + + Could not save file + + + + + &Undo + + + + + &Redo + + + + + This file already opened in another window. + + + + + Wrong units. + + + + + Application doesn't support standard table with inches. + + + + + File error. + + + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + + + + + Reopen files. + + + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + + + + + could not be found. Do you want to update the file location + + + + + Standard measurements (*.vst) + + + + + Individual measurements (*.vit) + + + + + File loaded + + + + + Height: + + + + + Pattern Piece: + + + + + + Pattern files (*.val) + + + + + /pattern.val + /Pola.val + + + + File saved + File telah disimpan + + + + untitled.val + tanpajudul.val + + + + Unsaved change + Perubahan belum disimpan + + + + The pattern has been modified. +Do you want to save your changes? + Pola telah dimodiikasi +Apakah anda ingin menyimpan perubahan anda? + + + + + Open file + Buka File + + + + + Error parsing file. + + + + + Error can't convert value. + + + + + + Error empty parameter. + + + + + Error wrong id. + + + + + Measurements + + + head_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar Kepala + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + Setengah Lingkar Leher + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar Leher Bawah + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + Panjang Leher dan Kepala + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + Panjang Bahu + + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + Panjang Sisi Pinggang + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + Panjang Badan + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar Bahu + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar data atas + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar dada/payudara + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + lingkar bawah payudara + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar Pinggang + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + Tinggi Lingkar Pinggul + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + Lingkar Pinggul + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Lebar dada depan atas + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Lebar dada depan + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + + Around fullest part of Head + Full measurement description + + + + + Around middle part of Neck + Full measurement description + + + + + Around Neck at base + Full measurement description + + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + + NeckPoint to ShoulderTip + Full measurement description + + + + + Armpit to Waist side + Full measurement description + + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + + Around HighHip, parallel to floor + Full measurement description + + + + + Around Hip, parallel to floor + Full measurement description + + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + + Distance between BustPoints, across Chest + Full measurement description + + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + + From NeckPoint to BustPoint + Full measurement description + + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + + Front upper-bust arc + Full measurement description + + + + + Back UpperBust side to side + Full measurement description + + + + + Front Waist side to side + Full measurement description + + + + + Back Waist side to side + Full measurement description + + + + + Front UpperHip side to side + Full measurement description + + + + + Back UpperHip side to side + Full measurement description + + + + + Front Hip side to side + Full measurement description + + + + + Back Hip side to side + Full measurement description + + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + + Front Upper chest waist + Full measurement description + + + + + Front waist to lower breast + Full measurement description + + + + + Back waist to upper chest + Full measurement description + + + + + Strap length + Full measurement description + + + + + Around Armscye + Full measurement description + + + + + Around Elbow with elbow bent + Full measurement description + + + + + Around UpperArm + Full measurement description + + + + + Around Wrist + Full measurement description + + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + + Hand side to side + Full measurement description + + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + + Around Hand + Full measurement description + + + + + Around Thigh + Full measurement description + + + + + Around MidThigh + Full measurement description + + + + + Around Knee + Full measurement description + + + + + Around Calf + Full measurement description + + + + + Around Ankle + Full measurement description + + + + + Knee to Floor + Full measurement description + + + + + Ankle to Floor + Full measurement description + + + + + Widest part of Foot side to side + Full measurement description + + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + + Top of head to floor + Full measurement description + + + + + Nape to Floor + Full measurement description + + + + + Nape to Knee + Full measurement description + + + + + Waist side to floor + Full measurement description + + + + + HighHip side to Floor + Full measurement description + + + + + Hip side to Floor + Full measurement description + + + + + Waist side to Hip + Full measurement description + + + + + Waist side to Knee + Full measurement description + + + + + Crotch to Floor along inside leg + Full measurement description + + + + + Size + Full measurement description + + + + + Height of the point base of the neck in front + Full measurement description + + + + + Height of the base of the neck side point + Full measurement description + + + + + The height of the shoulder point + Full measurement description + + + + + Height nipple point + Full measurement description + + + + + Height back angle axilla + Full measurement description + + + + + Height scapular point + Full measurement description + + + + + Height under buttock folds + Full measurement description + + + + + Hips excluding protruding abdomen + Full measurement description + + + + + Girth foot instep + Full measurement description + + + + + The distance from the side waist to floor + Full measurement description + + + + + The distance from the front waist to floor + Full measurement description + + + + + Arc through groin area + Full measurement description + + + + + The distance from the waist to the plane seat + Full measurement description + + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + + Chest width + Full measurement description + + + + + Anteroposterior diameter of the hands + Full measurement description + + + + + Height clavicular point + Full measurement description + + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + + Slash shoulder height + Full measurement description + + + + + Half girth neck + Full measurement description + + + + + Half girth neck for shirts + Full measurement description + + + + + Half girth chest first + Full measurement description + + + + + Half girth chest second + Full measurement description + + + + + Half girth chest third + Full measurement description + + + + + Half girth waist + Full measurement description + + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + + Girth knee flexed feet + Full measurement description + + + + + Neck transverse diameter + Full measurement description + + + + + Front slash shoulder height + Full measurement description + + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + + Hand vertical diameter + Full measurement description + + + + + Distance from neck to knee point + Full measurement description + + + + + The distance from the waist to the knee + Full measurement description + + + + + Shoulder height + Full measurement description + + + + + Head height + Full measurement description + + + + + Body position + Full measurement description + + + + + Arc behind the shoulder girdle + Full measurement description + + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + + Depth waist first + Full measurement description + + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + + Head girth + Full measurement name + + + + + Mid-neck girth + Full measurement name + + + + + Neck Base girth + Full measurement name + + + + + Head and Neck length + Full measurement name + + + + + Front Center length + Full measurement name + + + + + Back Center length + Full measurement name + + + + + Shoulder length + Full measurement name + + + + + Side Waist length + Full measurement name + + + + + Trunk length + Full measurement name + + + + + Shoulder girth + Full measurement name + + + + + Upper Chest girth + Full measurement name + + + + + Bust girth + Full measurement name + + + + + Under Bust girth + Full measurement name + + + + + Waist girth + Full measurement name + + + + + HighHip girth + Full measurement name + + + + + Hip girth + Full measurement name + + + + + Front Upper Chest width + Full measurement name + + + + + Front Chest width + Full measurement name + + + + + Front Across Shoulder width + Full measurement name + + + + + Back Across Shoulder width + Full measurement name + + + + + Back Upper Chest width + Full measurement name + + + + + Back Chest width + Full measurement name + + + + + BustPoint to BustPoint + Full measurement name + + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + + NeckPoint to BustPoint + Full measurement name + + + + + Crotch length + Full measurement name + + + + + Rise height + Full measurement name + + + + + Shoulder Drop + Full measurement name + + + + + Shoulder Slope degrees + Full measurement name + + + + + Front Shoulder Balance + Full measurement name + + + + + Back Shoulder Balance + Full measurement name + + + + + Front Full Length + Full measurement name + + + + + Back Full Length + Full measurement name + + + + + Front Neck arc + Full measurement name + + + + + Back Neck arc + Full measurement name + + + + + Front upper-bust arc + Full measurement name + + + + + Back UpperBust arc + Full measurement name + + + + + Front Waist arc + Full measurement name + + + + + Back Waist arc + Full measurement name + + + + + Front UpperHip arc + Full measurement name + + + + + Back UpperHip arc + Full measurement name + + + + + Front Hip arc + Full measurement name + + + + + Back Hip arc + Full measurement name + + + + + Chest Balance + Full measurement name + + + + + Back Balance + Full measurement name + + + + + Front Waist Balance + Full measurement name + + + + + Back Waist Balance + Full measurement name + + + + + Front UpperChest height + Full measurement name + + + + + Bust height + Full measurement name + + + + + Front Upper chest waist + Full measurement name + + + + + Front waist to lower breast + Full measurement name + + + + + Back waist to upper chest + Full measurement name + + + + + Strap length + Full measurement name + + + + + Armscye Girth + Full measurement name + + + + + Elbow Girth + Full measurement name + + + + + Upperarm Girth + Full measurement name + + + + + Wrist girth + Full measurement name + + + + + Armscye depth + Full measurement name + + + + + Shoulder and Arm length + Full measurement name + + + + + Underarm length + Full measurement name + + + + + Nape to wrist length + Full measurement name + + + + + Elbow length + Full measurement name + + + + + Arm length + Full measurement name + + + + + Hand width + Full measurement name + + + + + Hand length + Full measurement name + + + + + Hand girth + Full measurement name + + + + + Thigh girth + Full measurement name + + + + + Midthigh girth + Full measurement name + + + + + Knee girth + Full measurement name + + + + + Calf girth + Full measurement name + + + + + Ankle girth + Full measurement name + + + + + Knee height + Full measurement name + + + + + Ankle height + Full measurement name + + + + + Foot width + Full measurement name + + + + + Foot length + Full measurement name + + + + + Total Height + Full measurement name + + + + + Nape height + Full measurement name + + + + + Nape to knee height + Full measurement name + + + + + Waist height + Full measurement name + + + + + HighHip height + Full measurement name + + + + + Hip height + Full measurement name + + + + + Waist to Hip height + Full measurement name + + + + + Waist to Knee height + Full measurement name + + + + + Crotch height/Inseam + Full measurement name + + + + + Size + Full measurement name + + + + + Height front neck base point + Full measurement name + + + + + Height base neck side point + Full measurement name + + + + + Height shoulder point + Full measurement name + + + + + Height nipple point + Full measurement name + + + + + Height back angle axilla + Full measurement name + + + + + Height scapular point + Full measurement name + + + + + Height under buttock folds + Full measurement name + + + + + Hips excluding protruding abdomen + Full measurement name + + + + + Girth foot instep + Full measurement name + + + + + Side waist to floor + Full measurement name + + + + + Front waist to floor + Full measurement name + + + + + Arc through groin area + Full measurement name + + + + + Waist to plane seat + Full measurement name + + + + + Neck to radial point + Full measurement name + + + + + Neck to third finger + Full measurement name + + + + + Neck to first line chest circumference + Full measurement name + + + + + Front waist length + Full measurement name + + + + + Arc through shoulder joint + Full measurement name + + + + + Neck to back line chest circumference + Full measurement name + + + + + Waist to neck side + Full measurement name + + + + + Arc length upper body + Full measurement name + + + + + Chest width + Full measurement name + + + + + Anteroposterior diameter hands + Full measurement name + + + + + Height clavicular point + Full measurement name + + + + + Height armhole slash + Full measurement name + + + + + Slash shoulder height + Full measurement name + + + + + Half girth neck + Full measurement name + + + + + Half girth neck for shirts + Full measurement name + + + + + Half girth chest first + Full measurement name + + + + + Half girth chest second + Full measurement name + + + + + Half girth chest third + Full measurement name + + + + + Half girth waist + Full measurement name + + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + + Girth knee flexed feet + Full measurement name + + + + + Neck transverse diameter + Full measurement name + + + + + Front slash shoulder height + Full measurement name + + + + + Neck to front waist line + Full measurement name + + + + + Hand vertical diameter + Full measurement name + + + + + Neck to knee point + Full measurement name + + + + + Waist to knee + Full measurement name + + + + + Shoulder height + Full measurement name + + + + + Head height + Full measurement name + + + + + Body position + Full measurement name + + + + + Arc behind shoulder girdle + Full measurement name + + + + + Neck to neck base + Full measurement name + + + + + Depth waist first + Full measurement name + + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + + Move point label + + + + + MoveSPoint + + + Move single point + + + + + MoveSpline + + + Move spline + + + + + MoveSplinePath + + + Move spline path + + + + + PathPage + + + Open Directory + + + + + Path that use Valentina + + + + + Default + + + + + Edit + + + + + Type + + + + + Path + + + + + Individual measurements + + + + + Patterns + + + + + PatternPage + + + User + + + + + User name + + + + + Graphical output + + + + + Use antialiasing + + + + + Undo + + + + + Count steps (0 - no limit) + + + + + PostfixOperators + + + cm + centimeter + cm + + + + mm + millimeter + + + + + in + inch + + + + + QCoreApplication + + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + + Create new pattern piece to start working. + + + + + Add node + + + + + Move detail + + + + + mm + + + + + + cm + cm + + + + inch + + + + + Property + The text that appears in the first column header + + + + + Value + The text that appears in the second column header + + + + + QmuParserErrorMsg + + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Internal error + Math parser error messages. + + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + + Invalid pointer to callback function. + Math parser error messages. + + + + + Expression is empty. + Math parser error messages. + + + + + Invalid pointer to variable. + Math parser error messages. + + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + + Missing parenthesis + Math parser error messages. + + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Divide by zero + Math parser error messages. + + + + + Domain error + Math parser error messages. + + + + + Name conflict + Math parser error messages. + + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + + String function called with a non string type of argument. + Math parser error messages. + + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + + Function result is a string. + Math parser error messages. + + + + + Parser error. + Math parser error messages. + + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + + RenamePP + + + Rename pattern piece + + + + + STDescriptions + + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + + Save detail option + + + + + SaveToolOptions + + + Save tool option + + + + + TableWindow + + + Create a layout + + + + + toolBar + + + + + Save + Simpan + + + + + Save layout + + + + + Next + + + + + Next detail + + + + + Turn + + + + + Turn the detail 90 degrees + + + + + Stop + + + + + Stop laying + + + + + Enlarge letter + + + + + Enlarge the length of the sheet + + + + + Reduce sheet + + + + + Reduce the length of the sheet + + + + + + Mirroring + + + + + + Zoom In + + + + + + Zoom Out + + + + + 0 details left. + + + + + + Collisions not found. + + + + + %1 details left. + + + + + untitled + + + + + Svg files (*.svg) + + + + + PDF files (*.pdf) + + + + + Images (*.png) + + + + + Wavefront OBJ (*.obj) + + + + + PS files (*.ps) + + + + + EPS files (*.eps) + + + + + Collisions found. + + + + + Creating file '%1' failed! %2 + + + + + Critical error! + + + + + VAbstractConverter + + + Error creation backup file: %1. + + + + + Couldn't get version information. + + + + + Too many tags <%1> in file. + + + + + Version "%1" invalid. + + + + + Version "0.0.0" invalid. + + + + + Invalid version. Minimum supported version is %1 + + + + + Invalid version. Maximum supported version is %1 + + + + + Error no unique id. + + + + + Could not change version. + + + + + VAbstractTool + + + Confirm the deletion. + + + + + Do you really want delete? + + + + + VApplication + + + Error parsing file. Program will be terminated. + + + + + Error bad id. Program will be terminated. + + + + + Error can't convert value. Program will be terminated. + + + + + Error empty parameter. Program will be terminated. + + + + + Error wrong id. Program will be terminated. + + + + + Something's wrong!! + + + + + VContainer + + + + + + Can't find object + + + + + + Can't cast object + + + + + Can't find object. Type mismatch. + + + + + VDomDocument + + + Can't convert toUInt parameter + + + + + Can't convert toBool parameter + + + + + Got empty parameter + + + + + Can't convert toDouble parameter + + + + + Got wrong parameter id. Need only id > 0. + + + + + This id is not unique. + + + + + + Can't open file %1: +%2. + + + + + Can't open schema file %1: +%2. + + + + + Could not load schema file. + + + + + Validation error file %3 in line %1 column %2 + + + + + Parsing error file %3 in line %1 column %2 + + + + + Couldn't get node + + + + + Could not copy temp file to document file + + + + + Could not remove document file + + + + + VDrawTool + + + Options + pilihan + + + + Delete + hapus + + + + Edit wrong formula + + + + + VException + + + Critical error! + + + + + VFormula + + + + + + Error + + + + + VFormulaProperty + + + Value + + + + + Formula + rumus + + + + VPE::VBoolProperty + + + True + + + + + False + + + + + VPE::VFileEditWidget + + + Directory + + + + + Open File + + + + + VPattern + + + Can't find tool in table. + + + + + Error no unique id. + + + + + + Error parsing file. + + + + + Error can't convert value. + + + + + Error empty parameter. + + + + + Error wrong id. + + + + + Critical error! + + + + + Error parsing file (std::bad_alloc). + + + + + Error creating or updating detail + + + + + Error creating or updating single point + + + + + + Error creating or updating point of end line + + + + + + Error creating or updating point along line + + + + + + Error creating or updating point of shoulder + + + + + + Error creating or updating point of normal + + + + + + Error creating or updating point of bisector + + + + + Error creating or updating point of lineintersection + + + + + + Error creating or updating point of contact + + + + + Error creating or updating modeling point + + + + + Error creating or updating height + + + + + Error creating or updating triangle + + + + + Error creating or updating point of intersection + + + + + + Error creating or updating cut spline point + + + + + + Error creating or updating cut spline path point + + + + + + Error creating or updating cut arc point + + + + + + Error creating or updating point of intersection line and axis + + + + + + Error creating or updating point of intersection curve and axis + + + + + Error creating or updating line + + + + + Error creating or updating simple curve + + + + + Error creating or updating curve path + + + + + Error creating or updating modeling simple curve + + + + + Error creating or updating modeling curve path + + + + + + Error creating or updating simple arc + + + + + Error creating or updating modeling arc + + + + + Error creating or updating union details + + + + + File error. + + + + + VPatternConverter + + + Unexpected version "%1". + + + + + Error restoring backup file: %1. + + + + + VSplinePath + + + Not enough points to create the spline. + + + + + + + This spline does not exist. + + + + + Can't cut spline path with one point + + + + + VTableGraphicsView + + + can't find detail + + + + + detail found + + + + + VToolDetail + + + Options + pilihan + + + + Delete + hapus + + + + VToolOptionsPropertyBrowser + + + Base point + + + + + + + + + + + + + + + + + + + + Point label + label titik + + + + Position + + + + + Point at distance and angle + + + + + + + + + + + + + Line type + + + + + + + + + + + + Length + panjang + + + + + + Angle + sudut + + + + Point at distance along line + + + + + Arc + busur + + + + + Radius + radius + + + + + First angle + sudut pertama + + + + Second angle + sudut kedua + + + + Point along bisector + + + + + Cut arc tool + + + + + Tool for segmenting a curve + + + + + Tool segment a pathed curve + + + + + Perpendicular point along line + + + + + Line between points + + + + + Point at line intersection + + + + + Point along perpendicular + + + + + Additional angle degrees + + + + + Point at intersection of arc and line + + + + + Tool to make point from x & y of two other points + + + + + Special point on shoulder + + + + + Curve tool + + + + + + Curve factor + + + + + Tool for path curve + + + + + Tool triangle + + + + + + Point intersection line and axis + + + + + Variables + + + Line_ + Left symbol _ in name + + + + + AngleLine_ + Left symbol _ in name + + + + + Arc_ + Left symbol _ in name + + + + + Spl_ + Left symbol _ in name + + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + + <b>Curved path</b>: select three or more points + + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + + Pattern making program. + program pembuat pola + + + + Pattern file. + Berkas pola. + + + diff --git a/share/translations/valentina_it_IT.ts b/share/translations/valentina_it_IT.ts new file mode 100644 index 000000000..51ae471d1 --- /dev/null +++ b/share/translations/valentina_it_IT.ts @@ -0,0 +1,6358 @@ + + + + + AddDet + + Add detail + + + + + AddPatternPiece + + Add pattern piece %1 + + + + + AddToCalc + + Add object + + + + + AddUnionDetails + + Add union details + + + + + CommunityPage + + Server + + + + Server name/IP + + + + Secure connection + + + + Proxy settings + + + + Use Proxy + + + + Proxy address + + + + Proxy port + + + + Proxy user + + + + Proxy pass + + + + User settings + + + + User Name + + + + Save password + + + + Password + + + + + ConfigDialog + + Apply + + + + &Cancel + + + + &Ok + + + + Config Dialog + + + + Configuration + + + + Pattern + + + + Community + + + + Paths + + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + + + + Default unit updated and will be used the next pattern creation + + + + Save + + + + Auto-save modified pattern + + + + min + + + + Interval: + + + + Language + + + + GUI language + + + + Decimal separator parts + + + + With OS options (%1) + + + + Default unit + + + + Centimeters + + + + Millimiters + + + + Inches + + + + Label language + + + + Send crash reports + + + + Send crash reports (recommended) + + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + + + + + DelTool + + Delete tool + + + + + DeleteDetail + + Delete tool + + + + + DeletePatternPiece + + Delete pattern piece %1 + + + + + DialogAboutApp + + About Valentina + + + + Valentina version + + + + Contributors + + + + Built on %3 at %4 + + + + Web site : %1 + + + + Warning + + + + Cannot open your default browser + + + + Build revision: + + + + + DialogAlongLine + + ... + ... + + + _ + _ + + + Point along line + + + + Length + + + + Insert variable into the formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + First point of line + + + + Second point + + + + Second point of line + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogArc + + ... + ... + + + _ + _ + + + Arc + + + + Radius + + + + Insert variable into the formula + + + + Calculate value + + + + Value of radius + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + First angle + + + + Insert variable into formula + + + + Value of first angle + + + + Second angle + + + + Insert marked variable into formula + + + + Value of second angle + + + + Center point + + + + Select point of center of arc + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Value of angle of line. + + + + Error + + + + Radius can't be negative + + + + Angles equal + + + + + DialogBisector + + ... + ... + + + _ + _ + + + Bisector + + + + Length + + + + Insert marked variable into the formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + First point of angle + + + + Second point + + + + Second point of angle + + + + Third point + + + + Third point of angle + + + + Type of line + + + + Show line from second point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of angle + + + + Select third point of angle + + + + + DialogCurveIntersectAxis + + Curve intersect axis + + + + Angle + + + + Calculate value + + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + Curve + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select axis point + + + + + DialogCutArc + + ... + ... + + + _ + _ + + + Cut arc + + + + Length + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Arc + + + + Selected curve + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSpline + + ... + ... + + + _ + _ + + + Cut curve + + + + Length + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + + + + Selected curve + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogCutSplinePath + + ... + ... + + + _ + _ + + + Cut curve path + + + + Length + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Curve + + + + Selected curve path + + + + Point label + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + + DialogDetail + + Detail + + + + Bias X + + + + cm + + + + Bias Y + + + + Options + + + + Name of detail + + + + Seam allowance + + + + Width + + + + Closed + + + + Delete + + + + Got wrong scene object. Ignore. + + + + Reverse + + + + + DialogEditWrongFormula + + ... + ... + + + _ + _ + + + Edit formula + + + + Formula + + + + Insert variable into formula + + + + Calculate value + + + + Value of first angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogEndLine + + ... + ... + + + _ + _ + + + Point in the end of a line + + + + Length + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Angle + + + + Value of angle + + + + Base point + + + + First point of line + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + + DialogHeight + + Height + + + + Point label + + + + Base point + + + + First point of line + + + + Second point of line + + + + Type of line + + + + Show line from first point to our point + + + + Select first point of line + + + + Select second point of line + + + + + DialogHistory + + History + + + + Tool + + + + Can't create record. + + + + %1 - Base point + + + + %1_%2 - Line from point %1 to point %2 + + + + %3 - Point along line %1_%2 + + + + %1 - Point of shoulder + + + + %3 - normal to line %1_%2 + + + + %4 - bisector of angle %1_%2_%3 + + + + %5 - intersection of lines %1_%2 and %3_%4 + + + + Curve %1_%2 + + + + Arc with center in point %1 + + + + Curve point %1 + + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + + + + Point of perpendicular from point %1 to line %2_%3 + + + + Triangle: axis %1_%2, points %3 and %4 + + + + %1 - point of intersection %2 and %3 + + + + %1 - cut arc with center %2 + + + + %1 - cut curve %2_%3 + + + + %1 - cut curve path %2 + + + + %1 - point of intersection line %2_%3 and axis through point %4 + + + + %1 - point of intersection curve and axis through point %2 + + + + + DialogIncrements + + ... + ... + + + Increments + + + + Measurements + + + + Load another measurements table + + + + Personal information + + + + Given name + + + + Family name + + + + Birth date + + + + Sex + + + + Email + + + + Hide empty measurements + + + + Name + + + + The calculated value + + + + Base value + + + + In sizes + + + + In heights + + + + Description + + + + Lines + + + + Line + + + + Length + + + + Curves + + + + Curve + + + + Arcs + + + + Arc + + + + File error. + + + + male + + + + female + + + + Could not save GivenName + + + + Could not save FamilyName + + + + Could not save Email + + + + Could not save Sex + + + + Could not save BirthDate + + + + Measurements use different units than pattern. This pattern required measurements in %1 + + + + Individual measurements (*.vit) + + + + Open file + + + + Wrong units. + + + + Standard measurements (*.vst) + + + + Name_%1 + + + + Can't save measurement + + + + + DialogIndividualMeasurements + + ... + ... + + + Individual measurements + + + + Pattern piece name + + + + Exist measurements + + + + Path: + + + + Given name: + + + + Family name: + + + + New measurements + + + + Units: + + + + Could not create measurements file + + + + Please try again or change file + + + + File error. + + + + Individual measurements (*.vit) + + + + Open file + + + + Where save measurements? + + + + Centimeters + + + + Millimiters + + + + Inches + + + + + DialogLine + + Line + + + + First point + + + + Second point + + + + Type of line + + + + Show line from first point to this point + + + + Select second point + + + + + DialogLineIntersect + + Intersection of lines + + + + Point label + + + + First line + + + + First point + + + + Second point + + + + Second line + + + + Select second point of first line + + + + Select first point of second line + + + + Select second point of second line + + + + + DialogLineIntersectAxis + + Line intersect axis + + + + Angle + + + + Calculate value + + + + Value of angle + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Axis point + + + + First point of line + + + + First line point + + + + Second line point + + + + Point label + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables + + + + Select second point of line + + + + Select axis point + + + + + DialogMeasurements + + Measurements + + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + + + + Graduation + + + + Use for creation pattern standard measurement table + + + + Individual + + + + Use for creation pattern individual measurements + + + + + DialogNormal + + ... + ... + + + _ + _ + + + Normal + + + + Length + + + + Insert variable into formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + Second point + + + + Additional angle degrees + + + + Type of line + + + + Show line from first point to this point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select second point of line + + + + + DialogPatternProperties + + Pattern properties + + + + Description + + + + Author name + + + + Pattern description + + + + For technical notes. + + + + Heights and Sizes + + + + All heights (cm) + + + + All sizes (cm) + + + + + DialogPatternXmlEdit + + XML Editor + + + + Value : + + + + Name : + + + + <No selection> + + + + Type : + + + + Add attribute + + + + Add son + + + + Remove attribute + + + + Remove node + + + + Set + + + + Cancel + + + + Apply changes + + + + Undo last + + + + Immediate apply + + + + Base selection + + + + All pattern pieces + + + + No changes + + + + Cannot delete previously created node + + + + No changes left + + + + Cannot undo change + + + + <no value> + + + + Unchanged + + + + Cannot delete previously created attribute + + + + Node Name + + + + Name: + + + + Node Value (may be empty) + + + + Value: + + + + Attribute Name + + + + Attribute Value + + + + No selection + + + + Root node + + + + Node + + + + Attribute + + + + + DialogPointOfContact + + ... + ... + + + _ + _ + + + Point of contact + + + + Radius + + + + Insert variable into formula + + + + Calculate value + + + + Value of radius + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + Center of arc + + + + Select point of center of arc + + + + Top of the line + + + + End of the line + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula. + + + + Select second point of line + + + + + DialogPointOfIntersection + + Point of intersection + + + + Point label + + + + vertical point + + + + First point of angle + + + + horizontal point + + + + Second point of angle + + + + Select point horizontally + + + + + DialogShoulderPoint + + ... + ... + + + _ + _ + + + Point of shoulder + + + + Length + + + + Insert variable into formula + + + + Calculate value + + + + Value of length + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + Point label + + + + First point + + + + Second point + + + + Third point + + + + Type of line + + + + Show line from first point to our point + + + + Input data + + + + Size and height + + + + Measurements + + + + Increments + + + + Length of lines + + + + Length of arcs + + + + Length of curves + + + + Angle of lines + + + + Hide empty measurements + + + + Variables - Click twice to insert into formula + + + + Select first point of line + + + + Select second point of line + + + + + DialogSinglePoint + + Single point + + + + Coordinates on the sheet + + + + Coordinates + + + + Y coordinate + + + + X coordinate + + + + Point label + + + + + DialogSpline + + Curve + + + + First point + + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Second point + + + + Length ratio of the second control point + + + + The angle of the second control point + + + + Coefficient of curvature of the curve + + + + Select last point of curve + + + + + DialogSplinePath + + Curved path + + + + Point of curve + + + + Length ratio of the first control point + + + + The angle of the first control point + + + + Length ratio of the second control point + + + + The angle of the second control point + + + + List of points + + + + Coefficient of curvature of the curve + + + + Select point of curve path + + + + + DialogStandardMeasurements + + Standard table + + + + Pattern piece name + + + + Standard measurements table + + + + File error. + + + + + DialogTool + + Error + + + + Empty field + + + + Value can't be 0 + + + + Value + + + + Height + + + + Size + + + + Line length + + + + Arc length + + + + Curve length + + + + Parser error: %1 + + + + + DialogTriangle + + Triangle + + + + Point label + + + + First point of axis + + + + First point of line + + + + Second point of axis + + + + First point + + + + Second point + + + + Select second point of axis + + + + Select first point + + + + Select second point + + + + + DialogUndo + + Broken formula + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + + &Undo + + + + &Fix formula + + + + &Cancel + + + + + DialogUnionDetails + + Union details + + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + + + Select first point + + + + Select second point + + + + Select another second point + + + + Select detail + + + + + Functions + + sin + sine function + + + + cos + cosine function + + + + tan + tangens function + + + + asin + arcus sine function + + + + acos + arcus cosine function + + + + atan + arcus tangens function + + + + sinh + hyperbolic sine function + + + + cosh + hyperbolic cosine + + + + tanh + hyperbolic tangens function + + + + asinh + hyperbolic arcus sine function + + + + acosh + hyperbolic arcus tangens function + + + + atanh + hyperbolic arcur tangens function + + + + log2 + logarithm to the base 2 + + + + log10 + logarithm to the base 10 + + + + log + logarithm to the base 10 + + + + ln + logarithm to base e (2.71828...) + + + + exp + e raised to the power of x + + + + sqrt + square root of a value + + + + sign + sign function -1 if x<0; 1 if x>0 + + + + rint + round to nearest integer + + + + abs + absolute value + + + + min + min of all arguments + + + + max + max of all arguments + + + + sum + sum of all arguments + + + + avg + mean value of all arguments + + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + ... + ... + + + Ctrl+E + Ctrl+E + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Ctrl+T + Ctrl+T + + + Ctrl+H + Ctrl+H + + + Ctrl+L + Ctrl+L + + + Ctrl+Q + Ctrl+Q + + + <h1>%1</h1> %2 <br/><br/> %3 <br/><br/> %4 + <h1>%1</h1> %2 <br/><br/> %3 <br/><br/> %4 + + + Valentina + + + + Tools for creating points. + + + + Point + + + + Point along perpendicular + + + + Special point on shoulder. + + + + Tool triangle. + + + + Perpendicular point along line + + + + Point along bisector + + + + Point at intersection of arc and line. + + + + Tool to make point from x & y of two other points. + + + + Point at distance and angle + + + + Point at distance along line + + + + Point of intersection line and axis + + + + Tools for creating lines. + + + + Line + + + + Line between points + + + + Point at line intersection + + + + Tools for creating curves. + + + + Curve + + + + Curve tool. + + + + Tool for path curve. + + + + Tool for segmenting a curve. + + + + Tool segment a pathed curve. + + + + Tools for creating arcs. + + + + Arc + + + + Arc tool. + + + + Cut arc tool. + + + + Tools for creating details. + + + + Detail + + + + Tool new detail. + + + + Tool for union two details. + + + + &File + + + + &Help + + + + &Pattern piece + + + + Measurements + + + + Window + + + + Toolbar files + + + + ToolBar modes + + + + Toolbar pattern + + + + Toolbar options + + + + Toolbar tools + + + + Tool options + + + + New + + + + &New + + + + Create a new pattern + + + + Ctrl+N + + + + Open + + + + &Open + + + + Open file with pattern + + + + Save + + + + &Save + + + + Save pattern + + + + Ctrl+S + + + + Save &As... + + + + Save not yet saved pattern + + + + Ctrl+Shift+S + + + + Draw + + + + Draw mode + + + + Ctrl+W + + + + Details + + + + Details mode + + + + Pointer tools + + + + New pattern piece + + + + Add new pattern piece + + + + Change the label of pattern piece + + + + Table of variables + + + + Tables of variables + + + + History + + + + Export pattern (layout) + + + + Create layout + + + + About &Qt + + + + &About Valentina + + + + E&xit + + + + Exit the application + + + + Preferences + + + + Pattern properties + + + + Zoom in + + + + zoom in + + + + Zoom out + + + + Edit pattern XML code + + + + Original zoom + + + + Original Zoom + + + + Zoom fit best + + + + Ctrl+= + + + + Stop + + + + Stop using tool + + + + Repot Bug... + + + + Report bug + + + + Close window + + + + Online help + + + + Show online help + + + + Pattern piece %1 + + + + Individual measurements is under development + + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + + + + Select point + + + + Select first point + + + + Select first point of line + + + + Select first point of angle + + + + Select first point of first line + + + + Select first point curve + + + + Select simple curve + + + + Select point of center of arc + + + + Select point of curve path + + + + Select curve path + + + + Select points, arcs, curves clockwise. + + + + Select base point + + + + Select first point of axis + + + + Select point vertically + + + + Select detail + + + + Select arc + + + + Select curve + + + + About Qt + + + + Height: + + + + Size: + + + + Pattern Piece: + + + + Pattern files (*.val) + + + + pattern + + + + /pattern.val + + + + Save as + + + + Could not save file + + + + Open file + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Bad id. + + + + File saved + + + + untitled.val + + + + Unsaved change + + + + The pattern has been modified. +Do you want to save your changes? + + + + &Undo + + + + &Redo + + + + Pattern piece: + + + + Enter a new label for the pattern piece. + + + + This file already opened in another window. + + + + Wrong units. + + + + Application doesn't support standard table with inches. + + + + File error. + + + + File loaded + + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + + + + Reopen files. + + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + + + + could not be found. Do you want to update the file location + + + + Standard measurements (*.vst) + + + + Individual measurements (*.vit) + + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + + + + back_width + Short measurement name. Don't use math symbols in name!!!! + + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + + + + height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + + + + size + Short measurement name. Don't use math symbols in name!!!! + + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + + + + head_height + Short measurement name. Don't use math symbols in name!!!! + + + + body_position + Short measurement name. Don't use math symbols in name!!!! + + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + + + + Around middle part of Neck + Full measurement description + + + + Around Neck at base + Full measurement description + + + + Vertical Distance from Crown to Nape + Full measurement description + + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + + + + Back Neck Center to Back Waist Center + Full measurement description + + + + NeckPoint to ShoulderTip + Full measurement description + + + + Armpit to Waist side + Full measurement description + + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + + + + Around fullest part of Bust, parallel to floor + Full measurement description + + + + Around Chest below the Bust, parallel to floor + Full measurement description + + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + + + + Around HighHip, parallel to floor + Full measurement description + + + + Around Hip, parallel to floor + Full measurement description + + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Front Chest, from armfold to armfold + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + + + + Across Back Chest, from armfold to armfold + Full measurement description + + + + Distance between BustPoints, across Chest + Full measurement description + + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + + + + From NeckPoint to BustPoint + Full measurement description + + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + + + + ShoulderTip to Front Waist Center + Full measurement description + + + + ShoulderTip to Back Waist Center + Full measurement description + + + + NeckPoint straight down front chest to Waistline + Full measurement description + + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + + + + NeckPoint to NeckPoint across Nape + Full measurement description + + + + Front upper-bust arc + Full measurement description + + + + Back UpperBust side to side + Full measurement description + + + + Front Waist side to side + Full measurement description + + + + Back Waist side to side + Full measurement description + + + + Front UpperHip side to side + Full measurement description + + + + Back UpperHip side to side + Full measurement description + + + + Front Hip side to side + Full measurement description + + + + Back Hip side to side + Full measurement description + + + + NeckPoint to Front ArmfoldPoint + Full measurement description + + + + NeckPoint to Back ArmfoldPoint + Full measurement description + + + + NeckPoint across Front Chest to Waist side + Full measurement description + + + + NeckPoint across Back Chest to Waist side + Full measurement description + + + + Front Neck Center straight down to UpperChest line + Full measurement description + + + + Front Neck Center straight down to Bust line + Full measurement description + + + + Front Upper chest waist + Full measurement description + + + + Front waist to lower breast + Full measurement description + + + + Back waist to upper chest + Full measurement description + + + + Strap length + Full measurement description + + + + Around Armscye + Full measurement description + + + + Around Elbow with elbow bent + Full measurement description + + + + Around UpperArm + Full measurement description + + + + Around Wrist + Full measurement description + + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + + + + Hand side to side + Full measurement description + + + + Hand Middle Finger tip to wrist + Full measurement description + + + + Around Hand + Full measurement description + + + + Around Thigh + Full measurement description + + + + Around MidThigh + Full measurement description + + + + Around Knee + Full measurement description + + + + Around Calf + Full measurement description + + + + Around Ankle + Full measurement description + + + + Knee to Floor + Full measurement description + + + + Ankle to Floor + Full measurement description + + + + Widest part of Foot side to side + Full measurement description + + + + Tip of Longest Toe straight to back of heel + Full measurement description + + + + Top of head to floor + Full measurement description + + + + Nape to Floor + Full measurement description + + + + Nape to Knee + Full measurement description + + + + Waist side to floor + Full measurement description + + + + HighHip side to Floor + Full measurement description + + + + Hip side to Floor + Full measurement description + + + + Waist side to Hip + Full measurement description + + + + Waist side to Knee + Full measurement description + + + + Crotch to Floor along inside leg + Full measurement description + + + + Size + Full measurement description + + + + Height of the point base of the neck in front + Full measurement description + + + + Height of the base of the neck side point + Full measurement description + + + + The height of the shoulder point + Full measurement description + + + + Height nipple point + Full measurement description + + + + Height back angle axilla + Full measurement description + + + + Height scapular point + Full measurement description + + + + Height under buttock folds + Full measurement description + + + + Hips excluding protruding abdomen + Full measurement description + + + + Girth foot instep + Full measurement description + + + + The distance from the side waist to floor + Full measurement description + + + + The distance from the front waist to floor + Full measurement description + + + + Arc through groin area + Full measurement description + + + + The distance from the waist to the plane seat + Full measurement description + + + + The distance from the base of the neck to the side of the radial point + Full measurement description + + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + + + + Arc through the highest point of the shoulder joint + Full measurement description + + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + + + + The distance from the waist to the back base of the neck side point + Full measurement description + + + + Arc length of the upper body through the base of the neck side point + Full measurement description + + + + Chest width + Full measurement description + + + + Anteroposterior diameter of the hands + Full measurement description + + + + Height clavicular point + Full measurement description + + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + + + + Slash shoulder height + Full measurement description + + + + Half girth neck + Full measurement description + + + + Half girth neck for shirts + Full measurement description + + + + Half girth chest first + Full measurement description + + + + Half girth chest second + Full measurement description + + + + Half girth chest third + Full measurement description + + + + Half girth waist + Full measurement description + + + + Half girth hips considering protruding abdomen + Full measurement description + + + + Half girth hips excluding protruding abdomen + Full measurement description + + + + Girth knee flexed feet + Full measurement description + + + + Neck transverse diameter + Full measurement description + + + + Front slash shoulder height + Full measurement description + + + + The distance from the base of the neck to the waist line front + Full measurement description + + + + Hand vertical diameter + Full measurement description + + + + Distance from neck to knee point + Full measurement description + + + + The distance from the waist to the knee + Full measurement description + + + + Shoulder height + Full measurement description + + + + Head height + Full measurement description + + + + Body position + Full measurement description + + + + Arc behind the shoulder girdle + Full measurement description + + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + + + + Depth waist first + Full measurement description + + + + Depth waist second + Full measurement description + + + + + MeasurementsFullNames + + Head girth + Full measurement name + + + + Mid-neck girth + Full measurement name + + + + Neck Base girth + Full measurement name + + + + Head and Neck length + Full measurement name + + + + Front Center length + Full measurement name + + + + Back Center length + Full measurement name + + + + Shoulder length + Full measurement name + + + + Side Waist length + Full measurement name + + + + Trunk length + Full measurement name + + + + Shoulder girth + Full measurement name + + + + Upper Chest girth + Full measurement name + + + + Bust girth + Full measurement name + + + + Under Bust girth + Full measurement name + + + + Waist girth + Full measurement name + + + + HighHip girth + Full measurement name + + + + Hip girth + Full measurement name + + + + Front Upper Chest width + Full measurement name + + + + Front Chest width + Full measurement name + + + + Front Across Shoulder width + Full measurement name + + + + Back Across Shoulder width + Full measurement name + + + + Back Upper Chest width + Full measurement name + + + + Back Chest width + Full measurement name + + + + BustPoint to BustPoint + Full measurement name + + + + Halter Bustpoint to Bustpoint + Full measurement name + + + + NeckPoint to BustPoint + Full measurement name + + + + Crotch length + Full measurement name + + + + Rise height + Full measurement name + + + + Shoulder Drop + Full measurement name + + + + Shoulder Slope degrees + Full measurement name + + + + Front Shoulder Balance + Full measurement name + + + + Back Shoulder Balance + Full measurement name + + + + Front Full Length + Full measurement name + + + + Back Full Length + Full measurement name + + + + Front Neck arc + Full measurement name + + + + Back Neck arc + Full measurement name + + + + Front upper-bust arc + Full measurement name + + + + Back UpperBust arc + Full measurement name + + + + Front Waist arc + Full measurement name + + + + Back Waist arc + Full measurement name + + + + Front UpperHip arc + Full measurement name + + + + Back UpperHip arc + Full measurement name + + + + Front Hip arc + Full measurement name + + + + Back Hip arc + Full measurement name + + + + Chest Balance + Full measurement name + + + + Back Balance + Full measurement name + + + + Front Waist Balance + Full measurement name + + + + Back Waist Balance + Full measurement name + + + + Front UpperChest height + Full measurement name + + + + Bust height + Full measurement name + + + + Front Upper chest waist + Full measurement name + + + + Front waist to lower breast + Full measurement name + + + + Back waist to upper chest + Full measurement name + + + + Strap length + Full measurement name + + + + Armscye Girth + Full measurement name + + + + Elbow Girth + Full measurement name + + + + Upperarm Girth + Full measurement name + + + + Wrist girth + Full measurement name + + + + Armscye depth + Full measurement name + + + + Shoulder and Arm length + Full measurement name + + + + Underarm length + Full measurement name + + + + Nape to wrist length + Full measurement name + + + + Elbow length + Full measurement name + + + + Arm length + Full measurement name + + + + Hand width + Full measurement name + + + + Hand length + Full measurement name + + + + Hand girth + Full measurement name + + + + Thigh girth + Full measurement name + + + + Midthigh girth + Full measurement name + + + + Knee girth + Full measurement name + + + + Calf girth + Full measurement name + + + + Ankle girth + Full measurement name + + + + Knee height + Full measurement name + + + + Ankle height + Full measurement name + + + + Foot width + Full measurement name + + + + Foot length + Full measurement name + + + + Total Height + Full measurement name + + + + Nape height + Full measurement name + + + + Nape to knee height + Full measurement name + + + + Waist height + Full measurement name + + + + HighHip height + Full measurement name + + + + Hip height + Full measurement name + + + + Waist to Hip height + Full measurement name + + + + Waist to Knee height + Full measurement name + + + + Crotch height/Inseam + Full measurement name + + + + Size + Full measurement name + + + + Height front neck base point + Full measurement name + + + + Height base neck side point + Full measurement name + + + + Height shoulder point + Full measurement name + + + + Height nipple point + Full measurement name + + + + Height back angle axilla + Full measurement name + + + + Height scapular point + Full measurement name + + + + Height under buttock folds + Full measurement name + + + + Hips excluding protruding abdomen + Full measurement name + + + + Girth foot instep + Full measurement name + + + + Side waist to floor + Full measurement name + + + + Front waist to floor + Full measurement name + + + + Arc through groin area + Full measurement name + + + + Waist to plane seat + Full measurement name + + + + Neck to radial point + Full measurement name + + + + Neck to third finger + Full measurement name + + + + Neck to first line chest circumference + Full measurement name + + + + Front waist length + Full measurement name + + + + Arc through shoulder joint + Full measurement name + + + + Neck to back line chest circumference + Full measurement name + + + + Waist to neck side + Full measurement name + + + + Arc length upper body + Full measurement name + + + + Chest width + Full measurement name + + + + Anteroposterior diameter hands + Full measurement name + + + + Height clavicular point + Full measurement name + + + + Height armhole slash + Full measurement name + + + + Slash shoulder height + Full measurement name + + + + Half girth neck + Full measurement name + + + + Half girth neck for shirts + Full measurement name + + + + Half girth chest first + Full measurement name + + + + Half girth chest second + Full measurement name + + + + Half girth chest third + Full measurement name + + + + Half girth waist + Full measurement name + + + + Half girth hips considering protruding abdomen + Full measurement name + + + + Half girth hips excluding protruding abdomen + Full measurement name + + + + Girth knee flexed feet + Full measurement name + + + + Neck transverse diameter + Full measurement name + + + + Front slash shoulder height + Full measurement name + + + + Neck to front waist line + Full measurement name + + + + Hand vertical diameter + Full measurement name + + + + Neck to knee point + Full measurement name + + + + Waist to knee + Full measurement name + + + + Shoulder height + Full measurement name + + + + Head height + Full measurement name + + + + Body position + Full measurement name + + + + Arc behind shoulder girdle + Full measurement name + + + + Neck to neck base + Full measurement name + + + + Depth waist first + Full measurement name + + + + Depth waist second + Full measurement name + + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + + + + + MoveSpline + + Move spline + + + + + MoveSplinePath + + Move spline path + + + + + PathPage + + Open Directory + + + + Path that use Valentina + + + + Default + + + + Edit + + + + Type + + + + Path + + + + Individual measurements + + + + Patterns + + + + + PatternPage + + User + + + + User name + + + + Graphical output + + + + Use antialiasing + + + + Undo + + + + Count steps (0 - no limit) + + + + + PostfixOperators + + cm + centimeter + + + + mm + millimeter + + + + in + inch + + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + + + + Add node + + + + Move detail + + + + mm + + + + cm + + + + inch + + + + Property + The text that appears in the first column header + + + + Value + The text that appears in the second column header + + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Internal error + Math parser error messages. + + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + + + + Invalid pointer to callback function. + Math parser error messages. + + + + Expression is empty. + Math parser error messages. + + + + Invalid pointer to variable. + Math parser error messages. + + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + + + + Missing parenthesis + Math parser error messages. + + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Divide by zero + Math parser error messages. + + + + Domain error + Math parser error messages. + + + + Name conflict + Math parser error messages. + + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + + + + String function called with a non string type of argument. + Math parser error messages. + + + + String value used where a numerical argument is expected. + Math parser error messages. + + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + + + + Function result is a string. + Math parser error messages. + + + + Parser error. + Math parser error messages. + + + + Decimal separator is identic to function argument separator. + Math parser error messages. + + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + + + + + RenamePP + + Rename pattern piece + + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + + + + + SaveDetailOptions + + Save detail option + + + + + SaveToolOptions + + Save tool option + + + + + TableWindow + + Create a layout + + + + toolBar + + + + Save + + + + Save layout + + + + Next + + + + Next detail + + + + Turn + + + + Turn the detail 90 degrees + + + + Stop + + + + Stop laying + + + + Enlarge letter + + + + Enlarge the length of the sheet + + + + Reduce sheet + + + + Reduce the length of the sheet + + + + Mirroring + + + + Zoom In + + + + Zoom Out + + + + 0 details left. + + + + Collisions not found. + + + + %1 details left. + + + + untitled + + + + Svg files (*.svg) + + + + PDF files (*.pdf) + + + + Images (*.png) + + + + PS files (*.ps) + + + + EPS files (*.eps) + + + + Collisions found. + + + + Creating file '%1' failed! %2 + + + + Critical error! + + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + + + + Do you really want delete? + + + + + VApplication + + Error parsing file. Program will be terminated. + + + + Error bad id. Program will be terminated. + + + + Error can't convert value. Program will be terminated. + + + + Error empty parameter. Program will be terminated. + + + + Error wrong id. Program will be terminated. + + + + Something's wrong!! + + + + + VContainer + + Can't find object + + + + Can't cast object + + + + Can't find object. Type mismatch. + + + + + VDomDocument + + Can't convert toUInt parameter + + + + Can't convert toBool parameter + + + + Got empty parameter + + + + Can't convert toDouble parameter + + + + Can't open file %1: +%2. + + + + Can't open schema file %1: +%2. + + + + Could not load schema file. + + + + Validation error file %3 in line %1 column %2 + + + + Parsing error file %3 in line %1 column %2 + + + + Couldn't get node + + + + Got wrong parameter id. Need only id > 0. + + + + This id is not unique. + + + + Could not copy temp file to document file + + + + Could not remove document file + + + + + VDrawTool + + Edit wrong formula + + + + Options + + + + Delete + + + + + VException + + Critical error! + + + + + VFormula + + Error + + + + + VFormulaProperty + + Value + + + + Formula + + + + + VFormulaPropertyEditor + + ... + ... + + + + VPE::VBoolProperty + + True + + + + False + + + + + VPE::VColorPropertyEditor + + ... + ... + + + + VPE::VFileEditWidget + + ... + ... + + + Directory + + + + Open File + + + + + VPattern + + Can't find tool in table. + + + + Error no unique id. + + + + Error parsing file. + + + + Error can't convert value. + + + + Error empty parameter. + + + + Error wrong id. + + + + Critical error! + + + + Error parsing file (std::bad_alloc). + + + + Error creating or updating detail + + + + Error creating or updating single point + + + + Error creating or updating point of end line + + + + Error creating or updating point along line + + + + Error creating or updating point of shoulder + + + + Error creating or updating point of normal + + + + Error creating or updating point of bisector + + + + Error creating or updating point of lineintersection + + + + Error creating or updating point of contact + + + + Error creating or updating modeling point + + + + Error creating or updating height + + + + Error creating or updating triangle + + + + Error creating or updating point of intersection + + + + Error creating or updating cut spline point + + + + Error creating or updating cut spline path point + + + + Error creating or updating cut arc point + + + + Error creating or updating point of intersection line and axis + + + + Error creating or updating point of intersection curve and axis + + + + Error creating or updating line + + + + Error creating or updating simple curve + + + + Error creating or updating curve path + + + + Error creating or updating modeling simple curve + + + + Error creating or updating modeling curve path + + + + Error creating or updating simple arc + + + + Error creating or updating modeling arc + + + + Error creating or updating union details + + + + File error. + + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + + + + This spline does not exist. + + + + Can't cut spline path with one point + + + + + VTableGraphicsView + + can't find detail + + + + detail found + + + + + VToolDetail + + Options + + + + Delete + + + + + VToolOptionsPropertyBrowser + + Base point + + + + Point label + + + + Position + + + + Point at distance and angle + + + + Line type + + + + Length + + + + Angle + + + + Point at distance along line + + + + Arc + + + + Radius + + + + First angle + + + + Second angle + + + + Point along bisector + + + + Cut arc tool + + + + Tool for segmenting a curve + + + + Tool segment a pathed curve + + + + Perpendicular point along line + + + + Line between points + + + + Point at line intersection + + + + Point along perpendicular + + + + Additional angle degrees + + + + Point at intersection of arc and line + + + + Tool to make point from x & y of two other points + + + + Special point on shoulder + + + + Curve tool + + + + Curve factor + + + + Tool for path curve + + + + Tool triangle + + + + Point intersection line and axis + + + + + Variables + + Line_ + Left symbol _ in name + + + + AngleLine_ + Left symbol _ in name + + + + Arc_ + Left symbol _ in name + + + + Spl_ + Left symbol _ in name + + + + SplPath + Do not add symbol _ to the end of name + + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + + + + Pattern file. + + + + diff --git a/share/translations/valentina_nl_NL.ts b/share/translations/valentina_nl_NL.ts new file mode 100644 index 000000000..3abffcb12 --- /dev/null +++ b/share/translations/valentina_nl_NL.ts @@ -0,0 +1,6278 @@ + + + + + AddDet + + Add detail + Voeg detail toe + + + + AddPatternPiece + + Add pattern piece %1 + Voeg patroondeel 1 toe + + + + AddToCalc + + Add object + Voeg object toe + + + + AddUnionDetails + + Add union details + Voeg de gezamenlijke details toe + + + + CommunityPage + + Server + Server + + + Server name/IP + Server naam/IP + + + Secure connection + Maak connectie + + + Proxy settings + Proxy instellingen + + + Use Proxy + Gebruik Proxy + + + Proxy address + Proxy adres + + + Proxy port + Proxy poort + + + Proxy user + Proxy gebruiker + + + Proxy pass + Proxy pass + + + User settings + Gebruikers instellingen + + + User Name + Gebruikers naam + + + Save password + Opslaan paswoord + + + Password + Paswoord + + + + ConfigDialog + + Apply + Pas toe + + + &Cancel + &Stoppen + + + &Ok + &Ok + + + Config Dialog + Configureer dialoog + + + Configuration + Configuratie + + + Pattern + Patroon + + + Community + Gemeenschap + + + Paths + Paden + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + De taal van de setup gebruikers interface is opgewaardeerd en zal gebruikt worden bij de volgende start + + + Default unit updated and will be used the next pattern creation + De standaardwaarde van de eenheid is opgewaardeerd en zal worden gebruikt voor de volgende patrooncreatie + + + Save + Opslaan + + + Auto-save modified pattern + Automatisch opgeslagen van veranderd patroon + + + min + min + + + Interval: + Interval + + + Language + Taal + + + GUI language + GUI taal + + + Decimal separator parts + Decimale gescheiden delen + + + With OS options (%1) + Met OS opties (%1) + + + Default unit + Standaardwaarde eenheid + + + Centimeters + Centimeters + + + Millimiters + Millimiters + + + Inches + Inches + + + Label language + Label taal + + + Send crash reports + Verzend crash rapport + + + Send crash reports (recommended) + Verzend crash rapport( aanbevolen) + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + Na elke crash zal Valentina informatie verzamelen dat ons kan helpen het probleem op te lossen. Wij verzamelen geen persoonlijke informatie. Hier vind u wat wij aan informatie verzamelen :<ahref="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">". + + + + DelTool + + Delete tool + Verwijder gereedschap + + + + DeleteDetail + + Delete tool + Verwijder hulpmiddel + + + + DeletePatternPiece + + Delete pattern piece %1 + Verwijder patroondeel %1 + + + + DialogAboutApp + + About Valentina + Over Valentina + + + Valentina version + Valentina versie + + + Contributors + Bijdragers + + + Based on Qt %2 (32 bit) + Gebaseerd op Qt %2 (32 bit) + + + Built on %3 at %4 + Gebouwd op %3 op %4 + + + Web site : %1 + Website: %1 + + + Warning + Waarschuwing + + + Cannot open your default browser + Kan uw standaard browser niet openen + + + Build revision: + + + + + DialogAlongLine + + Point along line + Punt langs de lijn + + + Length + Lengte + + + Insert variable into the formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Point label + Punt label + + + First point + Eerste punt + + + First point of line + Eerste punt van de lijn + + + Second point + Tweede punt + + + Second point of line + Tweede punt van de lijn + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + Select second point of line + Selecteer tweede punt van lijn + + + + DialogArc + + Arc + Boog + + + Radius + Straal + + + Insert variable into the formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of radius + Waarde van de straal + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + First angle + Eerste hoek + + + Insert variable into formula + Voeg variabele info in de formule + + + Value of first angle + Waarde van eerste hoek + + + Second angle + Tweede hoek + + + Insert marked variable into formula + Voeg gemarkeerde variabele info in de formule + + + Value of second angle + Waarde van tweede hoek + + + Center point + Middelste punt + + + Select point of center of arc + Selecteer middelste punt van boog + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables + Variabelen + + + Value of angle of line. + Waarde van hoek van de lijn + + + Error + Error + + + Radius can't be negative + Straal kan niet negatief zijn + + + Angles equal + Gelijke zijden + + + + DialogBisector + + Bisector + Bisector + + + Length + Lengte + + + Insert marked variable into the formula + Voeg gemarkeerde variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Point label + Punt label + + + First point + Eerste punt + + + First point of angle + Eerste punt van hoek + + + Second point + Tweede punt + + + Second point of angle + Tweede punt van hoek + + + Third point + Derde punt + + + Third point of angle + Derde punt van hoek + + + Type of line + Soort lijn + + + Show line from second point to this point + Toon lijn vanaf tweede punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + Select second point of angle + Selecteer tweede punt van lijn + + + Select third point of angle + Selecteer derde punt van lijn + + + + DialogCurveIntersectAxis + + Curve intersect axis + Kromming doorkruist as + + + Angle + Hoek + + + Calculate value + Bereken waarde + + + Value of angle + Waarde van hoek + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Axis point + As punt + + + First point of line + Eerste punt van de lijn + + + Curve + Kromming + + + Point label + Punt label + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables + Variabelen + + + Select axis point + Selecteer as punt + + + + DialogCutArc + + Cut arc + Knip boog + + + Length + Lengte + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Arc + Boog + + + Selected curve + Geselecteerde kromming + + + Point label + Punt label + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + + DialogCutSpline + + Cut curve + Knip kromming + + + Length + Lengte + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Curve + Kromming + + + Selected curve + Geselecteerde kromming + + + Point label + Punt label + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + + DialogCutSplinePath + + Cut curve path + Knip kromming + + + Length + Lengte + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Curve + Kromming + + + Selected curve path + Geselecteerde krommingspad + + + Point label + Punt label + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + + DialogDetail + + Detail + Detail + + + Bias X + X-coordinaat + + + cm + cm + + + Bias Y + Y-coordinaat + + + Options + Opties + + + Name of detail + Naam van detail + + + Seam allowance + Naadtoeslag + + + Width + Wijdte + + + Closed + Gesloten + + + Delete + Verwijderen + + + Got wrong scene object. Ignore. + Verkeerde scene object. Negeren + + + Reverse + + + + + DialogEditWrongFormula + + Edit formula + Verander formule + + + Formula + Formule + + + Insert variable into formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of first angle + Waarde van eerste hoek + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables + Variabelen + + + + DialogEndLine + + Point in the end of a line + Punt aan het einde van een lijn + + + Length + Lengte + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Angle + Hoek + + + Value of angle + Waarde van hoek + + + Base point + Basis punt + + + First point of line + Eerste punt van de lijn + + + Point label + Punt label + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables + Variabelen + + + + DialogHeight + + Height + Hoogte + + + Point label + Punt label + + + Base point + Basis punt + + + First point of line + Eerste punt van de lijn + + + Second point of line + Tweede punt van de lijn + + + Type of line + Soort lijn + + + Show line from first point to our point + Toon lijn vanaf het eerste punt naar ons punt + + + Select first point of line + Selecteer eerste punt van lijn + + + Select second point of line + Selecteer tweede punt van lijn + + + + DialogHistory + + History + Geschiedenis + + + Tool + Gereedschap + + + Can't create record. + Kan geen melding maken. + + + %1 - Base point + %1 - Basis punt + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - lijn van punt %1 naar punt %2 + + + %3 - Point along line %1_%2 + %3 - Punt langs lijn %1_%2 + + + %1 - Point of shoulder + %1 - Schouderpunt + + + %3 - normal to line %1_%2 + %3 - Normaal naar lijn %1_%2 + + + %4 - bisector of angle %1_%2_%3 + + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - Kruispunt van lijnen %1_%2 en %3_%4 + + + Curve %1_%2 + Kromming %1_%2 + + + Arc with center in point %1 + Boog met middenpunt %1 + + + Curve point %1 + Krommingspunt %1 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + %4 - Contactpunt met het middenpunt van boog %1 en lijn %2_%3 + + + Point of perpendicular from point %1 to line %2_%3 + Haakse hoek punt vanaf punt %1 naar lijn %2_%3 + + + Triangle: axis %1_%2, points %3 and %4 + Driehoek: As %1_%2, naar punten %3 en %4 + + + %1 - point of intersection %2 and %3 + %1 - Kruispunt %2 en %3 + + + %1 - cut arc with center %2 + %1 - Geknipte boog met middenpunt %2 + + + %1 - cut curve %2_%3 + %1 - Geknipte kromming %2_%3 + + + %1 - cut curve path %2 + %1 - Geknipte krommingspad %2 + + + %1 - point of intersection line %2_%3 and axis through point %4 + %1 - Kruispunt op lijn %2_%3 en as via punt %4 + + + %1 - point of intersection curve and axis through point %2 + %1 - Kruispunt van kromming en as via %2 + + + + DialogIncrements + + Increments + Vergroten of verkleinen + + + Measurements + Maten + + + Load another measurements table + Laad een andere matentabel + + + Personal information + Persoonlijke informatie + + + Given name + Voornaam + + + Family name + Achternaam + + + Birth date + Geboortedatum + + + Sex + Geslacht + + + Email + Emailadres + + + Hide empty measurements + Verberg ongeschreven maten + + + Name + Naam + + + The calculated value + Bereken waarde + + + Base value + Basis waarde + + + In sizes + In maten + + + In heights + In hoogtes + + + Description + Beschrijving + + + Lines + Lijnen + + + Line + Lijn + + + Length + Lengte + + + Curves + Krommingen + + + Curve + Kromming + + + Arcs + Bogen + + + Arc + Boog + + + File error. + Bestandsfout + + + male + Mannelijk + + + female + Vrouwelijk + + + Could not save GivenName + Kon voornaam niet opslaan + + + Could not save FamilyName + Kon achternaam niet opslaan + + + Could not save Email + Kon emailadres niet opslaan + + + Could not save Sex + Kon geslacht niet opslaan + + + Could not save BirthDate + Kon geboortedatum niet opslaan + + + Measurements use different units than pattern. This pattern required measurements in %1 + "Maten" gebruikt andere eenheden dan patroon. Dit patroon heeft maten nodig in %1 + + + Individual measurements (*.vit) + Individuele maten(*.vit) + + + Open file + Open bestand + + + Wrong units. + Foute eenheden. + + + Standard measurements (*.vst) + Standaard maten(*.vst) + + + Name_%1 + Naam_%1 + + + Can't save measurement + Kan maten niet opslaan + + + + DialogIndividualMeasurements + + Individual measurements + Individuele maten + + + Pattern piece name + Patroondeel naam + + + Exist measurements + Bestaande maten + + + Path: + Pad: + + + Given name: + Voornaam: + + + Family name: + Achternaam: + + + New measurements + Nieuwe maten + + + Units: + Eenheden: + + + Could not create measurements file + Kon geen maten bestand maken + + + Please try again or change file + Probeer het opnieuw of verander bestand + + + File error. + Bestandsfout + + + Individual measurements (*.vit) + Individuele maten(*.vit) + + + Open file + Open bestand + + + Where save measurements? + Waar wil je de maten opslaan? + + + Centimeters + Centimeters + + + Millimiters + Millimiters + + + Inches + Inches + + + + DialogLine + + Line + Lijn + + + First point + Eerste punt + + + Second point + Tweede punt + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Select second point + Selecteer tweede punt + + + + DialogLineIntersect + + Intersection of lines + Kruispunt van lijnen + + + Point label + Punt label + + + First line + Eerste lijn + + + First point + Eerste punt + + + Second point + Tweede punt + + + Second line + Tweede lijn + + + Select second point of first line + Selecteer tweede punt van eerste lijn + + + Select first point of second line + Selecteer eerste punt van tweede lijn + + + Select second point of second line + Selecteer tweede punt van tweede lijn + + + + DialogLineIntersectAxis + + Line intersect axis + Lijn kruist de as + + + Angle + Hoek + + + Calculate value + Bereken waarde + + + Value of angle + Waarde van hoek + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Axis point + As punt + + + First point of line + Eerste punt van de lijn + + + First line point + Eerste lijnpunt + + + Second line point + Tweede lijnpunt + + + Point label + Punt label + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables + Variabelen + + + Select second point of line + Selecteer tweede punt van lijn + + + Select axis point + Selecteer as punt + + + + DialogMeasurements + + Measurements + Maten + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + html><head/><body><p><span style=" font-size:18pt;">Aub, kies patroon type.</span></p></body></html> + + + Graduation + Gradatie + + + Use for creation pattern standard measurement table + Gebruik dit om een standaard matentabel te maken + + + Individual + Individueel + + + Use for creation pattern individual measurements + Gebruik dit om een individuele matentabel te maken + + + + DialogNormal + + Normal + Normaal + + + Length + Lengte + + + Insert variable into formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Point label + Punt label + + + First point + Eerste punt + + + Second point + Tweede punt + + + Additional angle degrees + Aanvullende graden hoek + + + Type of line + Soort lijn + + + Show line from first point to this point + Toon lijn vanaf het eerste punt naar dit punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijnen + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + Select second point of line + Selecteer tweede punt van lijn + + + + DialogPatternProperties + + Pattern properties + Patroon eigenschappen + + + Description + Beschrijving + + + Author name + Auteursnaam + + + Pattern description + Patroon beschrijving + + + For technical notes. + Voor technische aantekeningen + + + Heights and Sizes + Hoogtes en maten + + + All heights (cm) + Alle hoogtes (cm) + + + All sizes (cm) + Alle maten (cm) + + + + DialogPatternXmlEdit + + XML Editor + XML Editor + + + Value : + Waarde: + + + Name : + Naam: + + + <No selection> + <geen selectie> + + + Type : + Soort: + + + Add attribute + Voeg een kenmerkende eigenschap toe + + + Add son + Add son + + + Remove attribute + Verwijder een kenmerkende eigenschap + + + Remove node + Verwijder kernpunt + + + Set + Klaar + + + Cancel + Stop + + + Apply changes + Pas veranderingen toe + + + Undo last + Maak laatste ongedaan + + + Immediate apply + Pas onmiddellijk toe + + + Base selection + Basis selectie + + + All pattern pieces + Alle patroon delen + + + No changes + Geen veranderingen + + + Cannot delete previously created node + Kan eerder aangemaakt kernpunt niet verwijderen + + + No changes left + Geen veranderingen over + + + Cannot undo change + Kan verandering niet ongedaan maken + + + <no value> + <geen waarde> + + + Unchanged + Onveranderd + + + Cannot delete previously created attribute + Kan eerder aangemaakt kenmerkende eigenschap niet verwijderen + + + Node Name + Kernpunt naam + + + Name: + Naam: + + + Node Value (may be empty) + Kernpunt waarde ( mag leeg zijn) + + + Value: + Waarde: + + + Attribute Name + Kenmerkende eigenschap naam: + + + Attribute Value + Kenmerkende eigenschap waarde + + + No selection + Geen selectie + + + Root node + Fundamenteel kernpunt + + + Node + Knooppunt + + + Attribute + Kenmerkende eigenschap + + + + DialogPointOfContact + + Point of contact + Contactpunt + + + Radius + Straal + + + Insert variable into formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of radius + Waarde van de straal + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Point label + Punt label + + + Center of arc + Midden van de boog + + + Select point of center of arc + Selecteer middelste punt van boog + + + Top of the line + Bovenkant van de lijn + + + End of the line + Einde van de lijn + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula. + Variabelen - Klik 2 keer om formule in te voeren + + + Select second point of line + Selecteer tweede punt van lijn + + + + DialogPointOfIntersection + + Point of intersection + Kruispunt + + + Point label + Punt label + + + vertical point + Verticaal punt + + + First point of angle + Eerste punt van hoek + + + horizontal point + Horizontaal punt + + + Second point of angle + Tweede punt van hoek + + + Select point horizontally + Selecteer punt horzontaal + + + + DialogShoulderPoint + + Point of shoulder + Schouderpunt + + + Length + Lengte + + + Insert variable into formula + Voeg variabele info in de formule + + + Calculate value + Bereken waarde + + + Value of length + Lengtewaarde + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><p>toont volledige berekening in berichten box </p></body></html> + + + Point label + Punt label + + + First point + Eerste punt + + + Second point + Tweede punt + + + Third point + Derde punt + + + Type of line + Soort lijn + + + Show line from first point to our point + Toon lijn vanaf het eerste punt naar ons punt + + + Input data + Breng data in + + + Size and height + Maat en hoogte + + + Measurements + Maten + + + Increments + Vergroten of verkleinen + + + Length of lines + Lijnlengte + + + Length of arcs + Booglengte + + + Length of curves + Lengte van kromming + + + Angle of lines + Hoek van de lijn + + + Hide empty measurements + Verberg ongeschreven maten + + + Variables - Click twice to insert into formula + Variabelen - Klik 2 keer om formule in te voeren + + + Select first point of line + Selecteer eerste punt van lijn + + + Select second point of line + Selecteer tweede punt van lijn + + + + DialogSinglePoint + + Single point + Enkel punt + + + Coordinates on the sheet + Coordinaten op het blad + + + Coordinates + Coordinaten + + + Y coordinate + Y coordinaat + + + X coordinate + X coordinaat + + + Point label + Punt label + + + + DialogSpline + + Curve + Kromming + + + First point + Eerste punt + + + Length ratio of the first control point + Lengteverhouding van het eerste controlepunt + + + The angle of the first control point + De hoek van het eerste controlepunt + + + Second point + Tweede punt + + + Length ratio of the second control point + Lengteverhouding van het tweede controlepunt + + + The angle of the second control point + De hoek van het tweede controlepunt + + + Coefficient of curvature of the curve + Getal waarmee de kronkel van de kromming vermenigvuldigd wordt + + + Select last point of curve + Selecteer laatste punt van de krommming + + + + DialogSplinePath + + Curved path + Krommingspad + + + Point of curve + Punt van kromming + + + Length ratio of the first control point + Lengteverhouding van het eerste controlepunt + + + The angle of the first control point + De hoek van het eerste controlepunt + + + Length ratio of the second control point + Lengteverhouding van het tweede controlepunt + + + The angle of the second control point + De hoek van het tweede controlepunt + + + List of points + Lijst van punten + + + Coefficient of curvature of the curve + Coefficientie van de kronkel van de kromming + + + Select point of curve path + Selecteer punt van krommingspad + + + + DialogStandardMeasurements + + Standard table + Standaard tabel + + + Pattern piece name + Patroondeel naam + + + Standard measurements table + Standaard maten tabel + + + File error. + Bestandsfout + + + + DialogTool + + Error + Error + + + Empty field + Leeg veld + + + Value can't be 0 + Waarde kan geen 0 zijn + + + Value + Waarde + + + Height + Hoogte + + + Size + Maat + + + Line length + Lijn lengte + + + Arc length + Booglengte + + + Curve length + Krommingslengte + + + Parser error: %1 + Fout bij uitpakken: %1 + + + + DialogTriangle + + Triangle + Driehoek + + + Point label + Punt label + + + First point of axis + Eerste punt van de as + + + First point of line + Eerste punt van de lijn + + + Second point of axis + Tweede punt van de as + + + First point + Eerste punt + + + Second point + Tweede punt + + + Select second point of axis + Selecteer tweede punt van de as + + + Select first point + Selecteer eerste punt + + + Select second point + Selecteer tweede punt + + + + DialogUndo + + Broken formula + Incorrecte formule + + + Error while calculation formula. You can try undo last operation or fix broken formula. + Fout ontstaan bij berekenen van formule. Probeer de laatste operatie ongedaan te maken of incorrecte formule te corrigeren + + + &Undo + &Ongedaan maken + + + &Fix formula + &Verbeter formule + + + &Cancel + &Stop + + + + DialogUnionDetails + + Union details + Gezamenlijke details + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><p>Wil je echt gezamenlijke details?</p></body></html> + + + Select first point + Selecteer eerste punt + + + Select second point + Selecteer tweede punt + + + Select another second point + Selecteer een ander tweede punt + + + Select detail + Selecteer een detail + + + + Functions + + sin + sine function + sin + + + cos + cosine function + cos + + + tan + tangens function + tan + + + asin + arcus sine function + asin + + + acos + arcus cosine function + acos + + + atan + arcus tangens function + atan + + + sinh + hyperbolic sine function + sinh + + + cosh + hyperbolic cosine + cosh + + + tanh + hyperbolic tangens function + tanh + + + asinh + hyperbolic arcus sine function + asinh + + + acosh + hyperbolic arcus tangens function + acosh + + + atanh + hyperbolic arcur tangens function + atanh + + + log2 + logarithm to the base 2 + log2 + + + log10 + logarithm to the base 10 + log10 + + + log + logarithm to the base 10 + log + + + ln + logarithm to base e (2.71828...) + In + + + exp + e raised to the power of x + exp + + + sqrt + square root of a value + sqrt + + + sign + sign function -1 if x<0; 1 if x>0 + sign + + + rint + round to nearest integer + rint + + + abs + absolute value + abs + + + min + min of all arguments + min + + + max + max of all arguments + max + + + sum + sum of all arguments + som + + + avg + mean value of all arguments + avg + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Gereedschap om punten te maken + + + Point + Punt + + + Point along perpendicular + Punt voor haakse hoek + + + Special point on shoulder. + Speciaal punt op schouder + + + Tool triangle. + Driehoek gereedschap + + + Perpendicular point along line + Haakse hoek punt langs lijn + + + Point along bisector + Punt langs bisector + + + Point at intersection of arc and line. + Kruispunt van boog en lijn + + + Tool to make point from x & y of two other points. + Gereedschap om een punt te maken van X & Y van twee andere punten + + + Point at distance and angle + Punt op afstand en hoek + + + Point at distance along line + Punt op afstand langs lijn + + + Point of intersection line and axis + Kruispunt tussen lijn en as + + + ... + ... + + + Tools for creating lines. + Gereedschap om lijnen te maken + + + Line + Lijn + + + Line between points + Lijn tussen punten + + + Point at line intersection + Punt op lijnkruising + + + Tools for creating curves. + Gereedschap om krommingen te maken + + + Curve + Kromming + + + Curve tool. + Krommingsgereedschap + + + Tool for path curve. + Gereedschap voorkrommingspad + + + Tool for segmenting a curve. + Gereedschap om een kromming in segmenten te delen + + + Tool segment a pathed curve. + Gereedschap segmenteerd een krommingspad + + + Tools for creating arcs. + Gereedschap voor het maken van bogen + + + Arc + Boog + + + Arc tool. + Boog gereedschap + + + Cut arc tool. + Knip een boog gereedschap + + + Tools for creating details. + Gereedschap om details te maken + + + Detail + Detail + + + Tool new detail. + Gereedschap nieuw detail + + + Tool for union two details. + Gereedschap om twee details te verenigen. + + + &File + &Bestand + + + &Help + &Help + + + &Pattern piece + &Patroon deel + + + Measurements + Maten + + + Window + Raamwerk + + + Toolbar files + Werkbalk bestanden + + + ToolBar modes + Werkbalk modes + + + Toolbar pattern + Werkbalk patroon + + + Toolbar options + Werkbalk opties + + + Toolbar tools + Werkbalk gereedschappen + + + Tool options + Werkbalk opties + + + New + Nieuw + + + &New + &Nieuw + + + Create a new pattern + Maak een nieuw patroon + + + Ctrl+N + Ctrl+N + + + Open + Open + + + &Open + &Open + + + Open file with pattern + Open bestand met patroon + + + Save + Opslaan + + + &Save + &Opslaan + + + Save pattern + Opslaan patroon + + + Ctrl+S + Ctrl+S + + + Save &As... + Opslaan &als... + + + Save not yet saved pattern + Sla nog niet opgeslagen patroon op + + + Ctrl+Shift+S + Ctrl+Shift+S + + + Draw + Teken + + + Draw mode + Teken mode + + + Ctrl+W + Ctrl+W + + + Details + Details + + + Details mode + Details mode + + + Ctrl+E + Ctrl+E + + + Pointer tools + Aanwijzer gereedschap + + + New pattern piece + Nieuw patroon deel + + + Add new pattern piece + Voeg nieuw patroon deel toe + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Change the label of pattern piece + Verander het label van patroon deel + + + Table of variables + Tabel van variabelen + + + Tables of variables + Tabellen van variabelen + + + Ctrl+T + Ctrl+T + + + History + Geschiedenis + + + Ctrl+H + Ctrl+H + + + Export pattern (layout) + Exporteer patroon ( opmaak) + + + Create layout + Maak opmaak + + + Ctrl+L + Ctrl+L + + + About &Qt + Over &Qt + + + &About Valentina + &Over Valentina + + + E&xit + E&xit + + + Exit the application + Stop met de toepassing + + + Ctrl+Q + Ctrl+Q + + + Preferences + Voorkeuren + + + Pattern properties + Patroon eigenschappen + + + Zoom in + Inzoomen + + + zoom in + Inzoomen + + + Zoom out + Uitzoomen + + + Edit pattern XML code + Wijzig patroon XML code + + + Original zoom + Origineel zoom + + + Original Zoom + Originele zoom + + + Zoom fit best + Zoom naar beste afstemming + + + Ctrl+= + Ctrl+= + + + Stop + Stop + + + Stop using tool + Stop gebruik gereedschap + + + Repot Bug... + Rapporteer fout... + + + Report bug + Rapporteer fout + + + Close window + Sluit raamwerk + + + Online help + Online help + + + Show online help + Toon online help + + + Pattern piece %1 + Patroon deel %1 + + + Individual measurements is under development + Individuele maten is in ontwikkeling + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + Er is geen mogelijkheid om een individuele matentabel te maken onafhankelijk van een patroonbestand. Om een patronenbestand te openen heb je beide bestanden nodig: Het patroon en de maten. Wil je doorgaan? + + + Select point + Selecteer punt + + + Select first point + Selecteer eerste punt + + + Select first point of line + Selecteer eerste punt van lijn + + + Select first point of angle + Selecteer eerste punt van hoek + + + Select first point of first line + Selecteer eerste punt van eerste lijn + + + Select first point curve + Selecteer eerste punt kromming + + + Select simple curve + Selecteer simpele kromming + + + Select point of center of arc + Selecteer middelste punt van boog + + + Select point of curve path + Selecteer punt van krommingspad + + + Select curve path + Selecteer krommingspad + + + Select points, arcs, curves clockwise. + Selecteer punten, bogen, krommingen rechtsom + + + Select base point + Selecteer basis punt + + + Select first point of axis + Selecteer eerste punt van de as + + + Select point vertically + Selecteer punt verticaal + + + Select detail + Selecteer een detail + + + Select arc + Selecteer boog + + + Select curve + Selecteer kromming + + + About Qt + Over Qt + + + Height: + Hoogte: + + + Size: + Maat: + + + Pattern Piece: + Patroon deel: + + + Pattern files (*.val) + Patroon bestanden (*.val) + + + pattern + Patroon + + + /pattern.val + /patroon.val + + + Save as + Opslaan als + + + Could not save file + Kon bestand niet opslaan + + + Open file + Open bestand + + + Error parsing file. + Fout bij uitpakken bestand. + + + Error can't convert value. + Fout. Kan waarde niet omzetten + + + Error empty parameter. + Fout. Leeg parameter. + + + Error wrong id. + Fout. Verkeerde id. + + + Critical error! + Cruciale fout! + + + Error parsing file (std::bad_alloc). + Fout bij uitpakken bestand(std::bad_alloc). + + + Bad id. + Slecht id. + + + File saved + Bestand opgeslagen + + + untitled.val + zonder titel.val + + + Unsaved change + Niet opgeslagen verandering. + + + The pattern has been modified. +Do you want to save your changes? + Het patroon is aangepast. Wil je de veranderingen opslaan? + + + &Undo + &Ongedaan maken + + + &Redo + &Opnieuw doen + + + Pattern piece: + Patroon deel: + + + Enter a new label for the pattern piece. + Schrijf een nieuw label voor het patroon deel. + + + This file already opened in another window. + Dit bestand is al geopend in een ander raamwerk. + + + Wrong units. + Verkeerde eenheden. + + + Application doesn't support standard table with inches. + Applicatie ondersteunt het standaard tabel niet met inches. + + + File error. + Bestandsfout + + + File loaded + Bestand geladen + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + Valentina is niet correct gesloten. Wil je de geopende bestanden(%1) heropenen? + + + Reopen files. + Heropen bestanden + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + Het maten bestand <br/><br/> <b>%1</b> <br/><br/> %3 + + + could not be found. Do you want to update the file location + Kon niet gevonden worden. Wil je de bestandslocatie bijwerken? + + + Standard measurements (*.vst) + Standaard maten(*.vst) + + + Individual measurements (*.vit) + Individuele maten(*.vit) + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + hoofd_wijdte + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + midden_hals_wijdte + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + hals_basis_wijdte + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + hoofd_en_hals_lengte + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + midden_voorkant_taille_lengte + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + midden_achterkant_taille_lengte + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + schouder_lengte + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + zijkant_taille_lengte + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + romp_lengte + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + schouder_wijdte + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + boven_borst_wijdte + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + borst_wijdte + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + onder_borst_wijdte + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + taille_wijdte + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + hoog_heup_wijdte + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + heup_wijdte + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + boven_voorkant_borst_wijdte + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + voorkant_borst_wijdte + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + kruiselings_voorkant_schouder_wijdte + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + kruiselings_rug_schouder_wijdte + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + boven_rug_breedte + + + back_width + Short measurement name. Don't use math symbols in name!!!! + rug_breedte + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + bustepunt_naar_bustepunt + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + halterlijn_bustepunt_naar_bustepunt + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + hals_naar_bustepunt + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + kruis_lengte + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + omhoogkomen_hoogte + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + Schouder_val + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + schouder_kop_graden + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + voor_schouder_kop_lengte + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + rug_schouder_kop_lengte + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + voorkant_schouder_naar_taille_lengte + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + rug_schouder_naar_taille_lengte + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + voorkant_hals_boog + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + rug_hals_ronding + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + voorkant_boven_borst_ronding + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + rug_boven-borst-ronding + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + voorkant_taille_ronding + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + rug_taille_ronding + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + voorkant_boven_heup_boog + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + rug_boven_heup_ronding + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + voorkant_heup_ronding + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + rug_heup_ronding + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + borst_schuinte + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + rug_schuinte + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + voorkant_taille_schuinte + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + rug_taille_schuinte + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + voorkant_hals_naar_boven_borst_hoogte + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + voorkant_hals_naar_buste_hoogte + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + voorkant_taille_naar_boven_borst + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + voorkant_taille_naar_lager_bustelijn + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + rug_taille_naar_boven_borst + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + riem_lengte + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + armsgat_wijdte + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + elleboog_wijdte + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + boven_arm_wijdte + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + pols_wijdte + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + armsgat_diepte + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + schouder_en_arm_lengte + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + onderarm_lengte + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + halswervel_naar_pols_lengte + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + schouder_naar_elleboog_wijdte + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + arm_lengte + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + hand_breedte + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + hand_lengte + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + hand_wijdte + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + dij_wijdte + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + midden_dij_wijdte + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + knie_wijdte + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + kuit_wijdte + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + enkel_wijdte + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + knie_hoogte + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + enkel_hoogte + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + voet_breedte + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + voet_lengte + + + height + Short measurement name. Don't use math symbols in name!!!! + hoogte + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + halswervel_hoogte + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + halswervel_naar_knie_hoogte + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + taille_hoogte + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + hoog_heup_hoogte + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + heup_hoogte + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + taille_naar_heup_hoogte + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + taille_naar_knie_hoogte + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + kruis_hoogte + + + size + Short measurement name. Don't use math symbols in name!!!! + maat + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_voorkant_hals_basis_punt + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_basis_hals_zijkant_punt + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_schouder_punt + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_tepel_punt + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + hoogte_rug_hoek_oksel + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_schouderblad_punt + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + hoogte_onder_zitvlak_plooien + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + heupen_uitgezonderd_uitpuilend_onderbuik + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + wijdte_voet_instap + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + zijkant_taille_naar_vloer + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + voorkant_taiile_naar_vloer + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + boog_door_lies_gebied + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + taille_naar_vlakke_stoel + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + hals_naar_draai_punt + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + hals_naar_derde_vinger + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + hals_naar_eerste_lijn_borst_omtrek + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + voorkant_taille_lengte + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + boog_door_schouder_gewricht + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + hals_naar_rug_lijn_borst_omtrek + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + taiile_naar_hals_zijkant + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + boog_lengte_boven_lichaam + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + borst_wijdte + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + Omtrek_diameter_handen + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + hoogte_sleutelbeen_punt + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + hoogte_armholte_verlaagdpunt + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + verlaagd_schouder_hoogte + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_hals + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_hals_voor_shirts + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_borst_eerste + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_borst_tweede + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_borst_derde + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_taille + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_heupen_overwegend_uitpullend_onderbuik + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + helft_wijdte_heupen_uitgezonderd_uitpuilend_onderbuik + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + wijdte_knie_gebogen_voet + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + hals_doorsnee_diameter + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + voorkant_verlaagd_schouder_hoogte + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + hals_naar_voorkant_taille_lijn + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + hand_vertivaal_diameter + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + hals_naar_knie_punt + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + taille_naar_knie + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + schouder_hoogte + + + head_height + Short measurement name. Don't use math symbols in name!!!! + hoofd_hoogte + + + body_position + Short measurement name. Don't use math symbols in name!!!! + lichaam_positie + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + boog_achter_schouder_gordel + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + hlas_naar_hals_basis + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + diepte_taille_eerste + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + diepte_taille_tweede + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + Rond dikste deel van het hoofd + + + Around middle part of Neck + Full measurement description + Rond middelste gedeelte van de Hals + + + Around Neck at base + Full measurement description + Rond Hals aan de basis + + + Vertical Distance from Crown to Nape + Full measurement description + Verticale Afstand van Kruin tot Nek + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + Voorkant Midden Hals over meetlint op Bustelijn naar Voorkant Midden Taille + + + Back Neck Center to Back Waist Center + Full measurement description + Rug Hals Midden naar Rug Taiile Midden + + + NeckPoint to ShoulderTip + Full measurement description + HalsPunt naar Schouder Tip + + + Armpit to Waist side + Full measurement description + Oksel naar Taille zijkant + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + Rond het Lichaam vanaf midden Schouder lengte naar BustePunt naar Kruis en weer terug naar het beginpunt + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + Rond Armen en Torso, op bicepshoogte naar vloer, met armen langs je lichaam hangend + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + Rond Borstkas op Okselhoogte, parallel aan de vloer kruislings over de rug, niet parallel aan de vloer voorlangs kruislings over de borstkas + + + Around fullest part of Bust, parallel to floor + Full measurement description + Rond het dikste deel van de buste, parallel aan de vloer + + + Around Chest below the Bust, parallel to floor + Full measurement description + Rond de borstkas onder de Buste, parallel aan de vloer + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + Knoop een elastiek rond het smalste deel van de taille, zorg dat dit elastiek goed op zijn plek blijft zitten terwijl u maten neemt. Voorkant taille of achterkant taille is niet altijd parallel aan de vloer, dat geldt ook voor het elastiek + + + Around HighHip, parallel to floor + Full measurement description + Rond Hoogheup, parallel aan de vloer + + + Around Hip, parallel to floor + Full measurement description + Rond Heup, parallel aan de vleor + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + Over voorkant BovenBorst, smalste breedte vanaf armsgat naar armsgat + + + Across Front Chest, from armfold to armfold + Full measurement description + Over Voorkant Borstkas, van armvouw naar armvouw + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + Van SchouderTip naar Schouder Tip, via de Voorkant + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + Van Schouder Tip naar Schouder Tip, via de rug + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + Kruislings Rug bovenborst, smalste breedte vanaf armsgat naar armsgat + + + Across Back Chest, from armfold to armfold + Full measurement description + Over Rug Borstkas, vanaf armvouw naar armvouw + + + Distance between BustPoints, across Chest + Full measurement description + Afstand tussen BustePunten, via borstkas + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + Afstand van BustePunt, achter de hals naar beneden naar het andere BustePunt + + + From NeckPoint to BustPoint + Full measurement description + Van HalsPunt naar BustePunt + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + Van Voorkant Taiile Midden, naar beneden via kruis, naar Rug Taille Midden + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + Ga op een vlakke harde stoel zitten, meet aan de zijkant vanaf taille naar beneden tot op stoelzitting. + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + Verticale afstand van HalsPunt level tot Schouder Tip level + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + Graden hoek van HalsPunt tot SchouderTip - vereist een goniometer + + + ShoulderTip to Front Waist Center + Full measurement description + Schouder Tip naar Voorkant Taille Midden + + + ShoulderTip to Back Waist Center + Full measurement description + Schouder Tip naar Rug Taille Midden + + + NeckPoint straight down front chest to Waistline + Full measurement description + HalsPunt recht naar beneden voorkant borstkas naar Taillelijn + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + Rug HalsPunt recht naar beneden rug borstkas naar taillelijn + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + HalsPunt naar Halspunt via Voorkant Hals Midden + + + NeckPoint to NeckPoint across Nape + Full measurement description + HalsPunt naar HalsPunt kruiselings onderkant nek + + + Front upper-bust arc + Full measurement description + Voorkant boven-buste boog + + + Back UpperBust side to side + Full measurement description + Rug BovenBuste van zijkant naar zijkant + + + Front Waist side to side + Full measurement description + Voorkant Taille van zijkant naar zijkant + + + Back Waist side to side + Full measurement description + Rug Taille van zijkant naar zijkant + + + Front UpperHip side to side + Full measurement description + Voorkant Bovenheup van zijkant naar zijkant + + + Back UpperHip side to side + Full measurement description + Rug BovenHeup van zijkant naar zijkant + + + Front Hip side to side + Full measurement description + Voorkant Heup van zijkant naar zijkant + + + Back Hip side to side + Full measurement description + Rug Heup van zijkant naar zijkant + + + NeckPoint to Front ArmfoldPoint + Full measurement description + HalsPunt naar voorkant ArmvouwPunt + + + NeckPoint to Back ArmfoldPoint + Full measurement description + HalsPunt naar Rug ArmvouwPunt + + + NeckPoint across Front Chest to Waist side + Full measurement description + HalsPunt gekruisd over Voorkant Borstkas naar Zijkant Taille + + + NeckPoint across Back Chest to Waist side + Full measurement description + HalsPunt gekruisd over Rug Borstkas naar Zijkant Taille + + + Front Neck Center straight down to UpperChest line + Full measurement description + Voorkant Midden Hals recht naar beneden tot BovenBorstkas lijn + + + Front Neck Center straight down to Bust line + Full measurement description + Voorkant Midden Hals recht naar beneden tot Buste lijn + + + Front Upper chest waist + Full measurement description + Voorkant Boven Borst Taille + + + Front waist to lower breast + Full measurement description + Voorkant Taille naar onder borst + + + Back waist to upper chest + Full measurement description + Rug Taille naar Boven Borstkas + + + Strap length + Full measurement description + Riemlengte + + + Around Armscye + Full measurement description + Rondom Armsgat + + + Around Elbow with elbow bent + Full measurement description + Rondom Elleboog met gebogen elleboog + + + Around UpperArm + Full measurement description + Rondom Bovenarm + + + Around Wrist + Full measurement description + Rondom pols + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + Onderkant nek recht naar beneden naar OnderBuste lijn ( gelijk aan Rug Bovenborstkas hoogte) + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + HalsPunt naar schouder Tip naar Pols, met gebogen elleboog en hand op heup + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + Oksel naar pols, met arm recht en naast het lichaam hangend + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + Onderkant nek naar Pols, met gebogen elleboog en hand op heup + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + SchouderTip naar Elleboog, met gebogen elleboog en hand op heup + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + SchouderTip naar pols, met gebogen elleboog en hand op heup + + + Hand side to side + Full measurement description + Hand van zijkant naar zijkant + + + Hand Middle Finger tip to wrist + Full measurement description + Hand top van Middelvinger naar pols + + + Around Hand + Full measurement description + Rondom Hand + + + Around Thigh + Full measurement description + Rondom dij + + + Around MidThigh + Full measurement description + Rondom MiddenDij + + + Around Knee + Full measurement description + Rondom Knie + + + Around Calf + Full measurement description + Rondom Kuit + + + Around Ankle + Full measurement description + Rondom Enkel + + + Knee to Floor + Full measurement description + Knie naar vloer + + + Ankle to Floor + Full measurement description + Enkel naar Vloer + + + Widest part of Foot side to side + Full measurement description + Breedste deel van de voet van zijkant naar zijkant + + + Tip of Longest Toe straight to back of heel + Full measurement description + Top van de Langste Teen recht naar achterkant van hiel + + + Top of head to floor + Full measurement description + Top van Hoofd naar Vloer + + + Nape to Floor + Full measurement description + Nek naar Vloer + + + Nape to Knee + Full measurement description + Nek naar knie + + + Waist side to floor + Full measurement description + Zijkant Taille naar vloer + + + HighHip side to Floor + Full measurement description + Zijkant HogeHeup naar Vloer + + + Hip side to Floor + Full measurement description + Zijkant Heup naar Vloer + + + Waist side to Hip + Full measurement description + Zijkant Taille naar Heup + + + Waist side to Knee + Full measurement description + Zijkant Taille naar knie + + + Crotch to Floor along inside leg + Full measurement description + Kruis naar vloer langs binnenkant been + + + Size + Full measurement description + Maat + + + Height of the point base of the neck in front + Full measurement description + Hoogte van de basis van de voorkant van de hals + + + Height of the base of the neck side point + Full measurement description + Hoogte van de basis van de zijkant van de hals + + + The height of the shoulder point + Full measurement description + Hoogte van het schouderpunt + + + Height nipple point + Full measurement description + Hoogte van het tepelpunt + + + Height back angle axilla + Full measurement description + Hoogte van oksel op rugzijde + + + Height scapular point + Full measurement description + Hoogte schouderblad punt + + + Height under buttock folds + Full measurement description + Hoogte onder bilplooien + + + Hips excluding protruding abdomen + Full measurement description + Heupen uitgezonderd uitpuilend onderbuik + + + Girth foot instep + Full measurement description + Wijdte voetstap + + + The distance from the side waist to floor + Full measurement description + De afstand van zijkant taiile naar vloer + + + The distance from the front waist to floor + Full measurement description + De afstand van de voorkant taille naar vloer + + + Arc through groin area + Full measurement description + Boog door lies gebied + + + The distance from the waist to the plane seat + Full measurement description + De afstand van taille naar vlakke zitting van stoel + + + The distance from the base of the neck to the side of the radial point + Full measurement description + De afstand van de basis van de hals naar de zijkant van het radiale punt + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + Afstand van de basis van de zijkant van de hals naar het topje van de derde vinger + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + De afstand van de basis van de hals naar de zijkant van de eerste lijn van de voorkant borstomvang + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + De afstand van de basis van de hals naar zijvoorkant van de taille(taille lengte aan de voorkant) + + + Arc through the highest point of the shoulder joint + Full measurement description + Boog via het hoogste punt van het schoudergewricht + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + De afstand van de basis van de hals naar de rug lijn van de borstomvang van de eerste en tweede basis op het randje van ....... + + + The distance from the waist to the back base of the neck side point + Full measurement description + De afstand van taille naar de basis van de zijkant van de rughals + + + Arc length of the upper body through the base of the neck side point + Full measurement description + booglengte van de bovenlichaam via de basis van de zijkant van de hals + + + Chest width + Full measurement description + Borstomvang + + + Anteroposterior diameter of the hands + Full measurement description + Anteroposterior diameter van de handen + + + Height clavicular point + Full measurement description + Hoogte van sleutelbeen punt + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + De afstand van het punt naar de halswervel level van de uitgerekte hoek van voorkant van de oksel(onderarm hoogte schuine spieren) + + + Slash shoulder height + Full measurement description + Verlaagd schouder hoogte + + + Half girth neck + Full measurement description + Helft hals wijdte + + + Half girth neck for shirts + Full measurement description + Helft halswijdte voor shirts + + + Half girth chest first + Full measurement description + Helft eerste borstkas wijdte + + + Half girth chest second + Full measurement description + Helft tweede borstkas wijdte + + + Half girth chest third + Full measurement description + Helft derde borstkas wijdte + + + Half girth waist + Full measurement description + Helft taille wijdte + + + Half girth hips considering protruding abdomen + Full measurement description + Helft heupwijdte rekening houdend met uitpuilende onderbuik + + + Half girth hips excluding protruding abdomen + Full measurement description + Helft heupwijdte uitgezonderd uitpuilende onderbuik + + + Girth knee flexed feet + Full measurement description + Wijdte van gebogen voet + + + Neck transverse diameter + Full measurement description + Hals doorsnee diameter + + + Front slash shoulder height + Full measurement description + Voorkant verlaagde schouder hoogte + + + The distance from the base of the neck to the waist line front + Full measurement description + De afstand van de basis van de hals naar voorkant van taillelijn + + + Hand vertical diameter + Full measurement description + Hand verticale diameter + + + Distance from neck to knee point + Full measurement description + Afstand van hals naar knie punt + + + The distance from the waist to the knee + Full measurement description + De afstand van taille naar de knie + + + Shoulder height + Full measurement description + Schouder hoogte + + + Head height + Full measurement description + Hoofd hoogte + + + Body position + Full measurement description + Lichaams positie + + + Arc behind the shoulder girdle + Full measurement description + Boog achter de schoudergordel + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + Afstand van hals punt naar basispunt van de hals zijkant halswijdte gemeten lijn + + + Depth waist first + Full measurement description + Diepte eerste taille + + + Depth waist second + Full measurement description + Diepte tweede taille + + + + MeasurementsFullNames + + Head girth + Full measurement name + Hoofd wijdte + + + Mid-neck girth + Full measurement name + Midden-hals wijdte + + + Neck Base girth + Full measurement name + Hals basis wijdte + + + Head and Neck length + Full measurement name + Hoofd en hals lengte + + + Front Center length + Full measurement name + Voorkant midden lengte + + + Back Center length + Full measurement name + Rug midden lengte + + + Shoulder length + Full measurement name + Schouder lengte + + + Side Waist length + Full measurement name + ZIjkant taille lengte + + + Trunk length + Full measurement name + Romp lengte + + + Shoulder girth + Full measurement name + Schouder wijdte + + + Upper Chest girth + Full measurement name + Boven borstkas wijdte + + + Bust girth + Full measurement name + Buste wijdte + + + Under Bust girth + Full measurement name + Onder buste wijdte + + + Waist girth + Full measurement name + Taille wijdte + + + HighHip girth + Full measurement name + Hoog heup wijdte + + + Hip girth + Full measurement name + Heup wijdte + + + Front Upper Chest width + Full measurement name + Voorkant boven borstkas wijdte + + + Front Chest width + Full measurement name + Voorkant borstkas wijdte + + + Front Across Shoulder width + Full measurement name + Voorkant via Schouder wijdte + + + Back Across Shoulder width + Full measurement name + Rug via Schouder wijdte + + + Back Upper Chest width + Full measurement name + Rug boven borstkas wijdte + + + Back Chest width + Full measurement name + Rug borstkas wijdte + + + BustPoint to BustPoint + Full measurement name + Buste Punt naar Buste Punt + + + Halter Bustpoint to Bustpoint + Full measurement name + Halter Buste Punt naar Buste Punt + + + NeckPoint to BustPoint + Full measurement name + Hals Punt naar Buste Punt + + + Crotch length + Full measurement name + Kruis lengte + + + Rise height + Full measurement name + Gaan staan hoogte + + + Shoulder Drop + Full measurement name + Schouder val + + + Shoulder Slope degrees + Full measurement name + Schouder kop graden + + + Front Shoulder Balance + Full measurement name + Voorkant schouder Balans + + + Back Shoulder Balance + Full measurement name + Rug Schouder Balans + + + Front Full Length + Full measurement name + Volledige lengte voorkant + + + Back Full Length + Full measurement name + Volledige lengte rugkant + + + Front Neck arc + Full measurement name + Voorkant hals boog + + + Back Neck arc + Full measurement name + Rugkant Hals boog + + + Front upper-bust arc + Full measurement name + Voorkant boven-buste boog + + + Back UpperBust arc + Full measurement name + Rug boven-buste boog + + + Front Waist arc + Full measurement name + Voorkant taille boog + + + Back Waist arc + Full measurement name + Rug Taille boog + + + Front UpperHip arc + Full measurement name + Voorkant Bovenheup boog + + + Back UpperHip arc + Full measurement name + Rugkant bovenheup boog + + + Front Hip arc + Full measurement name + Voorkant heup boog + + + Back Hip arc + Full measurement name + Rug heup boog + + + Chest Balance + Full measurement name + Borstkas balans + + + Back Balance + Full measurement name + Rugkant balans + + + Front Waist Balance + Full measurement name + Voorkant Taille Balans + + + Back Waist Balance + Full measurement name + Rug Taille Balans + + + Front UpperChest height + Full measurement name + Voorkant Bovenborstkas hoogte + + + Bust height + Full measurement name + Buste hoogte + + + Front Upper chest waist + Full measurement name + Voorkant boven borstkas hoogte + + + Front waist to lower breast + Full measurement name + Voorkant Taille naar lager borst + + + Back waist to upper chest + Full measurement name + Rug taille naar boven borstkas + + + Strap length + Full measurement name + Riemlengte + + + Armscye Girth + Full measurement name + Armsgat Wijdte + + + Elbow Girth + Full measurement name + Elleboog wijdte + + + Upperarm Girth + Full measurement name + Bovenarm wijdte + + + Wrist girth + Full measurement name + Pols wijdte + + + Armscye depth + Full measurement name + Armsgat Diepte + + + Shoulder and Arm length + Full measurement name + Schouder en arm lengte + + + Underarm length + Full measurement name + Onderarm lengte + + + Nape to wrist length + Full measurement name + Nek naar pols lengte + + + Elbow length + Full measurement name + Elleboog lenge + + + Arm length + Full measurement name + Arm lengte + + + Hand width + Full measurement name + Hand breedte + + + Hand length + Full measurement name + Hnad lengte + + + Hand girth + Full measurement name + Hand wijdte + + + Thigh girth + Full measurement name + Dij wijdte + + + Midthigh girth + Full measurement name + Middendij wijdte + + + Knee girth + Full measurement name + Knie wijdte + + + Calf girth + Full measurement name + Kuit wijdte + + + Ankle girth + Full measurement name + Enkel wijdte + + + Knee height + Full measurement name + Knie hoogte + + + Ankle height + Full measurement name + Enkel hoogte + + + Foot width + Full measurement name + Voet breedte + + + Foot length + Full measurement name + Voet lengte + + + Total Height + Full measurement name + Totale hoote + + + Nape height + Full measurement name + Nek hoogte + + + Nape to knee height + Full measurement name + Nek naar knie hoogte + + + Waist height + Full measurement name + Taille hoogte + + + HighHip height + Full measurement name + Hoogheup hoogte + + + Hip height + Full measurement name + Heup hoogte + + + Waist to Hip height + Full measurement name + Taille naar heup hoogte + + + Waist to Knee height + Full measurement name + Taille naar knie hoogte + + + Crotch height/Inseam + Full measurement name + Kruis hoogte/binnenbeenlengte + + + Size + Full measurement name + Maat + + + Height front neck base point + Full measurement name + Hoogte voorkant hals basis punt + + + Height base neck side point + Full measurement name + Hoogte basis hals zijkant punt + + + Height shoulder point + Full measurement name + Hoogte Schouder punt + + + Height nipple point + Full measurement name + Hoogte tepelpunt + + + Height back angle axilla + Full measurement name + Hoogte rug hoek oksel + + + Height scapular point + Full measurement name + Hoogte schouderblad punt + + + Height under buttock folds + Full measurement name + Hoogte onder bliplooien + + + Hips excluding protruding abdomen + Full measurement name + Heupen zonder uitpuilende onderbuik + + + Girth foot instep + Full measurement name + Wijdte voetstap + + + Side waist to floor + Full measurement name + Zijkant TAille naar vloer + + + Front waist to floor + Full measurement name + Voorkant Taille naar vloer + + + Arc through groin area + Full measurement name + Boog door lies gebied + + + Waist to plane seat + Full measurement name + Taille naar harde zitting stoel + + + Neck to radial point + Full measurement name + Hals naar radiale punt + + + Neck to third finger + Full measurement name + Hals naar derde vinger + + + Neck to first line chest circumference + Full measurement name + Hals naar eerste lijn borstomvang + + + Front waist length + Full measurement name + Voorkant taille lengte + + + Arc through shoulder joint + Full measurement name + Boog via schouder gewricht + + + Neck to back line chest circumference + Full measurement name + Hals naar rug lijn borstomvang + + + Waist to neck side + Full measurement name + Taille naar hals zijkant + + + Arc length upper body + Full measurement name + Boog lengte boven lichaam + + + Chest width + Full measurement name + Borstkas wijdte + + + Anteroposterior diameter hands + Full measurement name + Diameter uItgestrekte hand van voor naar achter + + + Height clavicular point + Full measurement name + Hoogte van sleutelbeen punt + + + Height armhole slash + Full measurement name + Hooge verlaagd armholte + + + Slash shoulder height + Full measurement name + Verlaagd schouder hoogte + + + Half girth neck + Full measurement name + Helft halswijdte + + + Half girth neck for shirts + Full measurement name + Helft halswijdte voor shirts + + + Half girth chest first + Full measurement name + Helft wijdte eerste borstkas + + + Half girth chest second + Full measurement name + Helft wijdte tweede borstkas + + + Half girth chest third + Full measurement name + Helft wijdte derde borstkas + + + Half girth waist + Full measurement name + Helft taille wijdte + + + Half girth hips considering protruding abdomen + Full measurement name + Helft wijdte heupen rekening houdend met uitpuilende onderbuik + + + Half girth hips excluding protruding abdomen + Full measurement name + Helft wijdte heupen zonder uitpuilende onderbuik + + + Girth knee flexed feet + Full measurement name + Wijdte knie gebogen voet + + + Neck transverse diameter + Full measurement name + Hals doorsnee diameter + + + Front slash shoulder height + Full measurement name + Voorkant verlaagd schouder hoogte + + + Neck to front waist line + Full measurement name + Hals naar voorkant taillelijn + + + Hand vertical diameter + Full measurement name + Hand verticale diameter + + + Neck to knee point + Full measurement name + Hals naar knie punt + + + Waist to knee + Full measurement name + Taille naar knie + + + Shoulder height + Full measurement name + Schouder hoogte + + + Head height + Full measurement name + Hoofd hoogte + + + Body position + Full measurement name + Lichaams positie + + + Arc behind shoulder girdle + Full measurement name + Boog achter de schoudergordel + + + Neck to neck base + Full measurement name + Hals naar hals basis + + + Depth waist first + Full measurement name + Diepte eerste taille + + + Depth waist second + Full measurement name + Diepte tweede taille + + + + MoveLabel + + Move point label + + + + + MoveSPoint + + Move single point + Verplaats enige punt + + + + MoveSpline + + Move spline + Verplaats sleuf + + + + MoveSplinePath + + Move spline path + Verplaats sleuf pad + + + + PathPage + + Open Directory + Open Directory + + + Path that use Valentina + Pad welke Valentina gebruikt + + + Default + Standaardwaarde + + + Edit + Verander + + + Type + Soort + + + Path + Pad + + + Individual measurements + Individuele maten + + + Patterns + Patronen + + + + PatternPage + + User + Gebruiker + + + User name + Gebruikersnaam + + + Graphical output + Grafische ontwikkeling + + + Use antialiasing + Gebruik anti-aliasing + + + Undo + Ongedaan maken + + + Count steps (0 - no limit) + Tel stappen (0- geen limiet) + + + + PostfixOperators + + cm + centimeter + cm + + + mm + millimeter + mm + + + in + inch + in + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + + + + + QObject + + Create new pattern piece to start working. + Maak een nieuw patroon deel om te gaan werken + + + Add node + Voeg kernpunt toe + + + Move detail + Verplaats detail + + + mm + mm + + + cm + cm + + + inch + inch + + + Property + The text that appears in the first column header + Eigendom + + + Value + The text that appears in the second column header + Waarde + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwacht teken "$TOK$"gevonden op positie $POS$. + + + Internal error + Math parser error messages. + Interne fout + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Ongeldige functie-, variabele- of constant naam:"$TOK$". + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Ongeldige binary operator identificator: "$TOKS". + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Ongeldige aanpassing operator identificator: "$TOKS". + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Ongeldige postfix operator identificator: "$TOKS". + + + Invalid pointer to callback function. + Math parser error messages. + Ongeldige aanwijzer naar terughaalfunktie + + + Expression is empty. + Math parser error messages. + Beschrijving is leeg + + + Invalid pointer to variable. + Math parser error messages. + Ongeldige aanwijzer voor variabele + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwachte bediener "$TOK$" gevonden op positie $POS$ + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + Onverwacht eind van beschrijving voor positie $POS$ + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + Onverwacht argument scheidingsteken voor positie $POS$ + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwacht tussenzin "$TOK$"voor positie $POS$ + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwachte funktie "$TOK$" voor positie $POS$ + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwachte waarde "$TOK$" gevonden op positie $POS$ + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Onverwachte variabele "$TOK$" gevonden op positie $POS$ + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + Funktie argumenten gebruikt zonder funktie( positie : $POS$) + + + Missing parenthesis + Math parser error messages. + Tussenzin missend + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Te veel parameters voor funktie "$TOK$" voor beschrijving positie $POS$ + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Te weinig parameters voor funktie "$TOK$" voor beschrijving positie $POS$ + + + Divide by zero + Math parser error messages. + Gedeeld door nul + + + Domain error + Math parser error messages. + Domein fout + + + Name conflict + Math parser error messages. + Naam conflict + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + Ongeldige waarde voor bediener prioriteiten( moet groter zijn of gelijk aan nul) + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + Door de gebruiker definieerde binary bediener "$TOK$" komt in conflict met een ingebouwde bediener + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + Onverwachte karakterreeks teken gevonden op positie $POS$ + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + Onbeëindigd karakterreeks startend op positie $POS$ + + + String function called with a non string type of argument. + Math parser error messages. + Karakterreeks funktie benoemd met een niet-karakterreeks soort van argument + + + String value used where a numerical argument is expected. + Math parser error messages. + Karakterreeks waarde gebruikt waar een nummeriek argument wordt verwacht + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Geen passende overbelasting voor bediener "$TOK$" voor positie $POS$. + + + Function result is a string. + Math parser error messages. + Funktie resultaat is een karakterreeks + + + Parser error. + Math parser error messages. + Uitpak fout. + + + Decimal separator is identic to function argument separator. + Math parser error messages. + Decimale afscheidingsteken is identiek aan de funktie argument afscheidingsteken + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + Als-dan-anders bediener vermist een anders clausule + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + Misplaatste dubbele punt op positie $POS$ + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + De "$TOK$" bediener moet worden vervolgd worden met een gesloten accolade + + + + RenamePP + + Rename pattern piece + Hernoem patroon deel + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + Standaard figuren van mannen 1e groep, borstkas 100 cm + + + + SaveDetailOptions + + Save detail option + Detail opslaan optie + + + + SaveToolOptions + + Save tool option + Sla gereedschap optie op + + + + TableWindow + + Create a layout + Maak een opmaak + + + toolBar + Werkbalk + + + Save + Opslaan + + + Save layout + Sla opmaak op + + + Next + Volgende + + + Next detail + Volgend detail + + + Turn + Omdraaien + + + Turn the detail 90 degrees + Draai het detail 90 graden + + + Stop + Stop + + + Stop laying + Stop plaatsen + + + Enlarge letter + Vergroot letter + + + Enlarge the length of the sheet + Vergroot de lengte van het werkblad + + + Reduce sheet + Verklein werkblad + + + Reduce the length of the sheet + Verklein de lengte van het werkblad + + + Mirroring + Spiegelen + + + Zoom In + Inzoomen + + + Zoom Out + Uitzoomen + + + 0 details left. + 0 details over. + + + Collisions not found. + Conflicten niet gevonden + + + %1 details left. + %1 details over + + + untitled + Niet betiteld + + + Svg files (*.svg) + Svg bestanden (*.svg) + + + PDF files (*.pdf) + PDF bestanden (*.pdf) + + + Images (*.png) + Afbeeldingen (*.png) + + + PS files (*.ps) + PS bestanden (*.ps) + + + EPS files (*.eps) + EPS bestanden (*.eps) + + + Collisions found. + Conflicten gevonden + + + Creating file '%1' failed! %2 + Bestand '%1' gefaald te maken! %2 + + + Critical error! + Cruciale fout! + + + Wavefront OBJ (*.obj) + + + + + VAbstractConverter + + Error creation backup file: %1. + + + + Couldn't get version information. + + + + Too many tags <%1> in file. + + + + Version "%1" invalid. + + + + Version "0.0.0" invalid. + + + + Invalid version. Minimum supported version is %1 + + + + Invalid version. Maximum supported version is %1 + + + + Error no unique id. + Fout geen unieke ID. + + + Could not change version. + + + + + VAbstractTool + + Confirm the deletion. + Bevestig de verwijdering. + + + Do you really want delete? + Wil je echt verwijderen? + + + + VApplication + + Error parsing file. Program will be terminated. + Fout bij uitpakken bestand. Programma wordt beëindigd. + + + Error bad id. Program will be terminated. + Fout slechte ID. Programma wordt beëindigd. + + + Error can't convert value. Program will be terminated. + Fout kan waarde niet omzetten. Programma wordt beëindigd. + + + Error empty parameter. Program will be terminated. + Fout lege parameter. Programma wordt beëindigd. + + + Error wrong id. Program will be terminated. + Fout verkeerde ID. Programma wordt beëindigd + + + Something's wrong!! + Er gaat iets verkeerd! + + + Could not copy temp file to document file + Kon temp bestand niet kopiren naar document bestand + + + Could not remove document file + Kon document bestand niet verwijderen + + + + VContainer + + Can't find object + Kan object niet vinden + + + Can't cast object + Kan het object niet verplaatsen + + + Can't find object. Type mismatch. + Kan object niet vinden. Soort komt niet overeen + + + + VDomDocument + + Can't convert toUInt parameter + Kan niet omzetten naar UInt parameter + + + Can't convert toBool parameter + Kan niet omzetten naar toBool parameter + + + Got empty parameter + Heeft een lege parameter + + + Can't convert toDouble parameter + Kan niet omzetten naar toDouble parameter + + + Can't open file %1: +%2. + kan bestand niet openen %1: +%2. + + + Can't open schema file %1: +%2. + Kan schema bestand niet openen %1: +%2. + + + Could not load schema file. + Kan schema bestand niet laden + + + Validation error file %3 in line %1 column %2 + Validatie fout bestand %3 op lijn %1 kolom %2 + + + Parsing error file %3 in line %1 column %2 + Fout bij uitpakken bestand %3 op lijn %1 kolom %2 + + + Couldn't get node + krijg het kernpunt niet + + + Got wrong parameter id. Need only id > 0. + Heeft verkeerde parameter ID. Heeft alleen nodig ID > 0 + + + This id is not unique. + Deze ID is niet uniek. + + + Could not copy temp file to document file + Kon temp bestand niet kopiren naar document bestand + + + Could not remove document file + Kon document bestand niet verwijderen + + + + VDrawTool + + Edit wrong formula + Verander verkeerde formule + + + Options + Opties + + + Delete + Verwijderen + + + + VException + + Critical error! + Cruciale fout! + + + + VFormula + + Error + Error + + + + VFormulaProperty + + Value + Waarde + + + Formula + Formule + + + + VPE::VBoolProperty + + True + Waar + + + False + Niet waar + + + + VPE::VFileEditWidget + + Directory + Directory + + + Open File + Open bestand + + + + VPattern + + Can't find tool in table. + Kan gereedschap niet vinden in tabel + + + Error no unique id. + Fout geen unieke ID. + + + Error parsing file. + Fout bij uitpakken bestand. + + + Error can't convert value. + Fout kan waarde niet omzetten + + + Error empty parameter. + Fout leeg parameter. + + + Error wrong id. + Fout verkeerde ID. + + + Critical error! + Cruciale fout! + + + Error parsing file (std::bad_alloc). + Fout bij uitpakken bestand(std::bad_alloc). + + + Error creating or updating detail + Fout bij het maken of bijwerken van detail + + + Error creating or updating single point + Fout bij het maken of bijwerken van een enkele punt + + + Error creating or updating point of end line + Fout bij het maken of bijwerken van eindpunt van een lijn + + + Error creating or updating point along line + Fout bij het maken of bijwerken van een punt langs een lijn + + + Error creating or updating point of shoulder + Fout bij het maken of bijwerken van schouderpunt + + + Error creating or updating point of normal + Fout bij het maken of bijwerken van een normaal punt + + + Error creating or updating point of bisector + Fout bij het maken of bijwerken van punt van bisector + + + Error creating or updating point of lineintersection + Fout bij het maken of bijwerken van het punt van kruising van lijnen + + + Error creating or updating point of contact + Fout bij het maken of bijwerken van punt van contact + + + Error creating or updating modeling point + Fout bij het maken of bijwerken van vormgevend punt + + + Error creating or updating height + Fout bij het maken of bijwerken van hoogte + + + Error creating or updating triangle + Fout bij het maken of bijwerken van driehoek + + + Error creating or updating point of intersection + Fout bij het maken of bijwerken van het punt van een kruising + + + Error creating or updating cut spline point + Fout bij het maken of bijwerken van geknipte vrijevormkrommings punt + + + Error creating or updating cut spline path point + Fout bij het maken of bijwerken van geknipte vrijevormkrommings pad punt + + + Error creating or updating cut arc point + Fout bij het maken of bijwerken van geknipte boog punt + + + Error creating or updating point of intersection line and axis + Fout bij het maken of bijwerken van het punt van kruising van lijnen en assen + + + Error creating or updating point of intersection curve and axis + Fout bij het maken of bijwerken van het punt van kruising van krommingen en assen + + + Error creating or updating line + Fout bij het maken of bijwerken van lijnen + + + Error creating or updating simple curve + Fout bij het maken of bijwerken van een simpele kromming + + + Error creating or updating curve path + Fout bij het maken of bijwerken van een krommingspad + + + Error creating or updating modeling simple curve + Fout bij het maken of bijwerken van modelleren van simpele kromming + + + Error creating or updating modeling curve path + Fout bij het maken of bijwerken van modellering krommingspad + + + Error creating or updating simple arc + Fout bij het maken of bijwerken van een simpele boog + + + Error creating or updating modeling arc + Fout bij het maken of bijwerken van modellering van een boog + + + Error creating or updating union details + Fout bij het maken of bijwerken van gezamelijke details + + + Got wrong parameter id. Need only id > 0. + Heeft verkeerde parameter ID. Heeft alleen nodig ID > 0 + + + This id is not unique. + Deze ID is niet uniek. + + + File error. + Bestandsfout + + + + VPatternConverter + + Unexpected version "%1". + + + + Error restoring backup file: %1. + + + + + VSplinePath + + Not enough points to create the spline. + Niet genoeg punten om een vrijevormkromming te maken. + + + This spline does not exist. + Deze vrijevormkromming bestaat niet + + + Can't cut spline path with one point + Kan vrijevormkromming pad .niet knippen met een punt + + + + VTableGraphicsView + + can't find detail + Kan detail niet vinden + + + detail found + Detail gevonden + + + + VToolDetail + + Options + Opties + + + Delete + Verwijderen + + + + VToolOptionsPropertyBrowser + + Base point + Basis punt + + + Point label + Punt label + + + Position + Positie + + + Point at distance and angle + Punt op afstand en hoek + + + Line type + Lijn soort + + + Length + Lengte + + + Angle + Hoek + + + Point at distance along line + Punt op afstand langs lijn + + + Arc + Boog + + + Radius + Straal + + + First angle + Eerste hoek + + + Second angle + Tweede hoek + + + Point along bisector + Punt langs bisector + + + Cut arc tool + Knip een boog gereedschap + + + Tool for segmenting a curve + Gereedschap om een kromming in segmenten te delen + + + Tool segment a pathed curve + Gereedschap segmenteerd een krommingspad + + + Perpendicular point along line + Haakse hoek punt langs lijn + + + Line between points + Lijn tussen punten + + + Point at line intersection + Punt op lijnkruising + + + Point along perpendicular + Punt langs haakse hoek + + + Additional angle degrees + Aanvullende graden hoek + + + Point at intersection of arc and line + Kruispunt van boog en lijn + + + Tool to make point from x & y of two other points + Gereedschap om een punt te maken van X & Y van twee andere punten + + + Special point on shoulder + Speciaal punt op schouder + + + Curve tool + Krommingsgereedschap + + + Curve factor + Krommingsfactor + + + Tool for path curve + Gereedschap voorkrommingspad + + + Tool triangle + Driehoek gereedschap + + + Point intersection line and axis + Kruispunt tussen lijn en as + + + + Variables + + Line_ + Left symbol _ in name + Lijn_ + + + AngleLine_ + Left symbol _ in name + HoekLijn_ + + + Arc_ + Left symbol _ in name + Boog_ + + + Spl_ + Left symbol _ in name + Spl_ + + + SplPath + Do not add symbol _ to the end of name + SplPath + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + + + + + VisToolSplinePath + + <b>Curved path</b>: select three or more points + + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + + + + + main + + Pattern making program. + Patroon teken programma + + + Pattern file. + Patroon bestand. + + + diff --git a/share/translations/valentina_ru.ts b/share/translations/valentina_ru.ts deleted file mode 100644 index 08f500b2c..000000000 --- a/share/translations/valentina_ru.ts +++ /dev/null @@ -1,2538 +0,0 @@ - - - - - DialogAlongLine - - - Point along line - Точка вдоль линии - - - - Length - Длина - - - - Formula calculation of length of line - Формула разчета длины линии - - - - Calculate formula - Расчитать формулу - - - - - ... - - - - - Value of length - Значение длины - - - - _ - - - - - Name new point - Имя новой точки - - - - Put variable into formula - Поместить переменную в формулу - - - - First point - Первая точка - - - - First point of line - Первая точка линии - - - - Second point - Вторая точка - - - - Second point of line - Вторая точка линии - - - - Type line - Тип линии - - - - Show line from first point to our point - Показать линию с первой точки к нашей - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - Select second point of line - Выберить вторую точку линии - - - - DialogArc - - - Arc - Дуга - - - - Radius - Радиус - - - - Formula calculation of radius of arc - Формула расчета радиуса дуги - - - - - - Put variable into formula - Вставить переменную в формулу - - - - - - - - - ... - - - - - - - Calculate formula - Расчитать формулу - - - - Value of radius - Значение радиуса - - - - - - _ - - - - - First angle degree - Первый угол градусы - - - - First angle of arc counterclockwise - Первый угол дуги против часовой стрелки - - - - Value of first angle - Значение первого угла - - - - Second angle degree - Второй угол градусы - - - - Second angle of arc counterclockwise - Второй угол дуги против часвой стрелки - - - - Value of second angle - Значение второго угла - - - - Center point - Центральная точка - - - - Select point of center of arc - Выберите точку центра дуги - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Angle of lines - Уголы линий - - - - Variables - Переменные - - - - Value angle of line. - Значение угла линии. - - - - DialogBisector - - - Bisector - Бисектриса - - - - Length - Длина - - - - Formula calculation of length of bisector - Формула расчета длины бисектрисы - - - - Calculate formula - Расчитать формулу - - - - - ... - - - - - Value of length - Значение длины - - - - _ - - - - - Name new point - Имя новой точки - - - - Put variable into formula - Поместить переменную в формулу - - - - First point - Первая точка - - - - First point of angle - Первая точка угла - - - - Second point - Вторая точка - - - - Second point of angle - Вторая точка угла - - - - Third point - Треться точка - - - - Third point of angle - Третья точка угла - - - - Type line - Тип линии - - - - Show line from second point to our point - Показать линию с второй точки к нашей - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - Select second point of angle - Выберить вторую точку угла - - - - Select third point of angle - Выберить третью точку угла - - - - DialogDetail - - - Detail - Деталь - - - - Bias X - Смещение по Х - - - - Bias Y - Смещение по Y - - - - Option - Параметры - - - - Name of detail - Имя детали - - - - Supplement for seams - Прибавка на швы - - - - Width - Ширина - - - Name detail - Имя детали - - - - Closed - Замкнутая - - - - Get wrong scene object. Ignore. - Получено не правильный объект сцены. Игнорируем. - - - - Get wrong tools. Ignore. - Получено неправильный инструмент. Игнорируем. - - - - DialogEndLine - - - Point in the end of line - Точка на конце линии - - - - Length - Длина - - - - Formula calculation of length of line - Формула расчета длины линии - - - - Calculate formula - Расчитать формулу - - - - - - - - - - - - - ... - - - - - Value of length - Значение длины - - - - _ - - - - - Base point - Базовая точка - - - - First point of line - Первая точка линии - - - - Name new point - Имя новой точки - - - - Angle degree - Угол градусы - - - - Angle of line - Угол линии - - - - Type line - Тип линии - - - - Show line from first point to our point - Показать линию с первой точки к нашей - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - DialogHeight - - - Dialog - Диалог - - - - Name new point - Имя новой точки - - - - Base point - Базовая точка - - - - - - - First point of line - Первая точка линии - - - - Second point of line - Вторая точка линии - - - - Type line - Тип линии - - - - Show line from first point to our point - Показать линию с первой точки к нашей - - - - Select first point of line - Выберить первую точку линии - - - - Select second point of line - Выберить вторую точку линии - - - - DialogHistory - - - History - История - - - - - Tool - Инструмент - - - - %1 - Base point - %1 - Базовая точка - - - - - %1_%2 - Line from point %1 to point %2 - %1_%2 - Линия с точки %1 к точке %2 - - - - %3 - Point along line %1_%2 - %3 - Точка вдоль линии %1_%2 - - - - %1 - Point of soulder - %1 - Точка плеча - - - - %3 - Normal to line %1_%2 - %3 - Перпендикуляр к линии %1_%2 - - - - %4 - Bisector of angle %1_%2_%3 - %4 - Бисектриса угла %1_%2_%3 - - - - %5 - Point of intersection lines %1_%2 and %3_%4 - %5 - Точка пересичения линий %1_%2 и %3_%4 - - - - Curve %1_%2 - Кривая %1_%2 - - - - Arc with center in point %1 - Дуга з центром в точке %1 - - - - Curve point %1 - Точка кривой %1 - - - - %4 - Point of contact arc with center in point %1 and line %2_%3 - %4 - Точка касания дуги с центром в точке %1 и линии %2_%3 - - - - Point of perpendical from point %1 to line %2_%3 - Точка перпендикуляра с точки %1 к линии %2_%3 - - - - Triangle: axis %1_%2, points %3 and %4 - Триугольник: ось %1_%2, точки %3 и %4 - - - - Get wrong tool type. Ignore. - Получено неправилый тип инструмента. Игнорируется. - - - - DialogIncrements - - - - Increments - Прибавки - - - - Table sizes - Таблица размеров - - - - - - - Denotation - Обозначение - - - - - The calculated value - Расчитаное значение - - - - - - - Base value - Базовое значение - - - - In sizes - В размерах - - - - In growths - В ростах - - - - - - - - - Description - Опис - - - - - - In size - В размерах - - - - - - In growth - В ростах - - - - - ... - - - - - Lines - Линии - - - - - Line - Линия - - - - Length of the line - Длина линии - - - - Curves - Кривые - - - - - Curve - Кривая - - - - Length of the curve - Длина кривой - - - - Arcs - Дуги - - - - - Arc - Дуга - - - - Length of arc - Длина дуги - - - - Denotation %1 - Обозначение %1 - - - - Can't convert toDouble value. - Не могу конвертировать к toDouble значение. - - - - - Calculated value - Расчитаное значение - - - - - - Length - Длина - - - - DialogLine - - - Line - Линия - - - - First point - Первая точка - - - - Second point - Вторая точка - - - - Select second point - Выберить вторую точку - - - - DialogLineIntersect - - - Point of line intersection - Точка пересичения линий - - - - Name new point - Имя новой точки - - - - First line - Первая линия - - - - - First point - Первая точка - - - - - Second point - Вторая точка - - - - Second line - Вторая линия - - - - Select second point of first line - Выберить вторую точку первой линии - - - - Select first point of second line - Выберить первую точку второй линии - - - - Select second point of second line - Выберить вторую точку второй линии - - - - DialogNormal - - - Normal - Перпендикуляр - - - - Length - Длина - - - - Formula calculation of length of normal - Формула расчета длины перпендикуляра - - - - Calculate formula - Расчитать формулу - - - - - - - - - - - - - ... - - - - - Value of length - Значение длины - - - - _ - - - - - Name new point - Имя новой точки - - - - Put variable into formula - Поместить переменную в формулу - - - - First point - Первая точка - - - - Second point - Вторая точка - - - - Additional angle degrees - Дополнительные угол градусы - - - - Type line - Тип линии - - - - Show line from first point to our point - Показать линию с первой точки к нашей - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - Select second point of line - Выберить вторую точку линии - - - - DialogPointOfContact - - - Point of contact - Точка касания - - - - Radius - Радиус - - - - Formula calculation of radius of arc - Формула расчета радиуса дуги - - - - Calculate formula - Расчитать формулу - - - - - ... - - - - - Value of radius - Значение радиуса - - - - _ - - - - - Name new point - Имя новой точки - - - - Put variable into formula - Поместить переменную в формулу - - - - Center of arc - Центр дуги - - - - Slect point of center of arc - Выберите точку центра дуги - - - - Top of the line - Начало линии - - - - End of the line - Конец линии - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - Length of lines - Длина линий - - - - Length of arcs - Длина дуг - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - Select second point of line - Выберить вторую точку линии - - - - Select point of center of arc - Выберите точку центра дуги - - - - DialogPointOfIntersection - - - Dialog - Диалог - - - - Name new point - Имя новой точки - - - - Point vertically - Точка по вертикали - - - - First point of angle - Первая точка угла - - - - Point horizontally - Точка по горизонтали - - - - Second point of angle - Вторая точка угла - - - - Select point horizontally - Выберить точку по горозинтали - - - - DialogShoulderPoint - - - - Point of shoulder - Точка плеча - - - - Length - Длина - - - - Formula calculation of length of line - Формула расчета длины линии - - - - Calculate formula - Расчитать формулу - - - - - ... - - - - - Value of length - Значение длины - - - - _ - - - - - Name new point - Имя новой точки - - - - Put variable into formula - Поместить переменную в формулу - - - - First point - Первая точка - - - - Second point - Вторая точка - - - - Type of line - Тип линии - - - - Show line from first point to our point - Показать линию с первой точки к нашей - - - - Input data - Входные данные - - - - Size and growth - Размер и рост - - - - Standart table - Стандартная таблица - - - - Increments - Прибавки - - - - - Length of lines - Длина линий - - - - Length of curves - Длина кривых - - - - Variables. Click twice to select. - Переменые. Нажмите дважды для вставки. - - - - Select second point of line - Выберить вторую точку линии - - - - Select point of shoulder - Выберить точку плеча - - - - DialogSinglePoint - - - Single point - Одиночная точка - - - Координати - Координаты - - - - Coordinates on the sheet - Координаты на листе - - - - Coordinates - Координаты - - - - Y coordinate - Y координата - - - - X coordinate - Х координата - - - - Point name - Имя точки - - - - DialogSpline - - - Curve - Кривая - - - - First point - Первая точка - - - - Length ratio of the first control point - Коефициент длины первой контрольной точки - - - - The angle of the first control point - Угол первой контрольной точки - - - - Second point - Вторая точка - - - - Length ratio of the second control point - Коефициент длины второй контрольной точки - - - - The angle of the second control point - Угол второй контрольной точки - - - - Coefficient of curvature of the curve - Коефициент кривизные кривой - - - - Select last point of curve - Выберить последнюю точку кривой - - - - DialogSplinePath - - - Curve path - Сложная кривая - - - - Point of curve - Точка кривой - - - - Length ratio of the first control point - Коефициент длины первой контрольной точки - - - - The angle of the first control point - Угол первой контрольной точки - - - - Length ratio of the second control point - Коефициент длины второй контрольной точки - - - - The angle of the second control point - Угол второй контрольной точки - - - - List of points - Список точок - - - - Coefficient of curvature of the curve - Коефициент кривизные кривой - - - - Select point of curve path - Выберить точку сложной кривой - - - - DialogTool - - - Wrong details id. - Неправильный id детали. - - - - - - Line - Линия - - - - - No line - Без линии - - - - Can't find point by name - Не могу найти точку за именем - - - - Error - Ошибка - - - - Growth - Рост - - - - Size - Размер - - - - Line length - Длина линии - - - - Arc length - Длина дуги - - - - Curve length - Длина кривой - - - - DialogTriangle - - - Dialog - Диалог - - - - Name new point - Имя новой точки - - - - First point of axis - Первая точка оси - - - - - - - First point of line - Первая точка линии - - - - Second point of axis - Вторая точка оси - - - - First point - Первая точка - - - - Second point - Вторая точка - - - - Select second point of axis - Выберить вторую точку оси - - - - Select first point - Выберить первую точку - - - - Select second point - Выберить вторую точку - - - - MainWindow - - - Valentina - Valentina - - - - Tools for creating points. - Инструменты для создания точок. - - - - Point - Точка - - - - Tool point of normal. - Инструмент точка перпендикуляра. - - - - - - - - - - - - - - - - - - ... - - - - - Tool point of shoulder. - Инструмент точка плеча. - - - - Tool point on the end line. - Инструмент точка на конце отрезка. - - - - Tool point along line. - Инструмент точка вдоль линии. - - - - Tool point of bisector. - Инструмент точка бисектрисы. - - - - Tool point of contact. - Инструмент точка касания. - - - - Tool point of height. - Инструмент точка высоты. - - - - Tool triangle. - Инструмент угольник. - - - - Tools for creating lines. - Инструменты создания линий. - - - - Line - Линия - - - - Tool line. - Инструмент линия. - - - - Tool point of line intersection. - Инструмент точка пересичения линий. - - - - Tools for creating curves. - Инструменты создания кривых. - - - - Curve - Кривая - - - - Tool curve. - Инструмент кривая. - - - - Tool path curve. - Инструмент сложная кривая. - - - - Tools for creating arcs. - Инструменты создания дуг. - - - - Arc - Дуга - - - - Tool arc. - Инструмент дуга. - - - - Tools for creating details. - Инструменты создания деталей. - - - - Detail - Деталь - - - - Tool new detail. - Инструмент новая деталь. - - - - File - Файл - - - - Help - Помощь - - - - Drawing - Чертеж - - - - toolBar - - - - - toolBar_2 - - - - - toolBar_3 - - - - - New - Новое - - - - Create a new pattern - Создать новое лекало - - - - Open - Открыть - - - - Open file with pattern - Открыть файл с лекалом - - - - Save - Сохранить - - - - Save pattern - Сохранить лекало - - - - - Save as - Сохранить как - - - - Save not yet saved pattern - Сохранить еще не сохраненное лекало - - - - Draw - Рисование - - - - Draw mode - Режим рисования - - - - Details - Детали - - - - Deatils mode - Режим деталей - - - - - Tools pointer - Инструмент указатель - - - - New drawing - Новый чертеж - - - - Add new drawing - Добавить новый чертеж - - - - - Change the name of drawing - Изменить имя чертежа - - - - Table of variables - Таблица переменных - - - - Tables of variables - Таблици переменных - - - - History - История - - - - Layout - Роскладка - - - - Create layout - Создать раскладку - - - - - About Qt - Про Qt - - - - - About Valentina - Про Valentina - - - - Exit - Выход - - - - Drawing %1 - Чертеж %1 - - - - - Drawing: - Чертеж: - - - - Enter a name for the drawing. - Введите имя чертежа. - - - - - Error. Drawing of same name already exists. - Ошибка. Чертеж с таким именем уже существует. - - - - Error creating drawing with the name - Ошибка создания чертежа с именем - - - - Enter a new name for the drawing. - Введите новое имя для чертежа. - - - - Error saving change!!! - Пошибка сохранение изменений!!! - - - - Can't save new name of drawing - Не могу сохранить новое имя чертежа - - - - - Select point - Выберить точку - - - - Select first point - Выберить первую точку - - - - - - Select first point of line - Выберить первую точку линии - - - - Select first point of angle - Выберить первую точку угла - - - - Select first point of first line - Выберить первую точку первой линии - - - - Select first point curve - Выберить первую точку кривой - - - - Select point of center of arc - Выберить точку центра дуги - - - - Select point of curve path - Выберить точку сложной кривой - - - - The pattern has been modified. - Лекало было изменено. - - - - Do you want to save your changes? - Вы хочете сохранить изменения? - - - - Growth: - Рост: - - - - Size: - Размер: - - - - Drawing: - Чертеж: - - - - Lekalo files (*.xml);;All files (*.*) - Файлы лекала (*.xml);;Все файлы (*.*) - - - - - Lekalo files (*.xml) - Файл лекала (*.xml) - - - - Error saving file. Can't save file. - Ошибка сохранения файла. Не могу сохранить файл. - - - - Open file - Открыть файл - - - - Got empty file name. - Получено пустое имя файла. - - - - Could not copy temp file to pattern file - Не могу скопировать временный файл у файл лекала - - - - Could not remove pattern file - Не смог удалить файл лекала - - - - Can't open pattern file. File name empty - Не могу открыть файл лекала. Пустое имя файла - - - - - - - - - - - Error! - Ошибка! - - - - Create new drawing for start working. - Создайте новый чертеж для начала роботы. - - - - Select points, arcs, curves clockwise. - Выберить точки, дуги, кривые за часовой стрелкой. - - - - Select base point - Выберить базовую точку - - - - Select first point of axis - Выберить первую тчоку оси - - - - Select point vertically - Выберить точку по вертикали - - - - Based on Qt %2 (32 bit) - Базируется на Qt %2 (32 bit) - - - - Built on %3 at %4 - Создано %3 в %4 - - - - <h1>%1</h1> %2 <br/><br/> %3 <br/><br/> %4 - - - - - Error parsing file. - Ошибка парсинга файла. - - - - Error can't convert value. - Ошибка, не могу конвертовать значение. - - - - Error empty parameter. - Ошибка, пустой параметр. - - - - Error wrong id. - Ошибка, неправильный id. - - - - - Error don't unique id. - Ошибка не уникальный id. - - - - Error parsing pattern file. - Ошибка парсинга файла лекала. - - - - Error in line %1 column %2 - Ошибка в линии %1 столбец %2 - - - - TableWindow - - - Create a layout - Создать раскладку - - - - toolBar - toolBar - - - - Save - Сохранить - - - - - Save layout - Создать раскладку - - - - Next - Следующая - - - - Next detail - Следующая деталь - - - - Turn - Перевернуть - - - - Turn the detail 180 degrees - Перевернуть детальна на 180 градусов - - - - Stop laying - Прекратить укладку - - - - Enlarge letter - Увеличить лист - - - - Enlarge the length of sheet - Увеличить длину листа - - - - Reduce sheet - Уменьшить лист - - - - Reduce the length of the sheet - Уменьшить длину листа - - - - - Mirroring - Отражение - - - - - Zoom In - Увеличить - - - - - Zoom Out - Уменьшить - - - - Stop - Стоп - - - - SVG Generator Example Drawing - SVG Generator Example Drawing - - - - An SVG drawing created by the SVG Generator Example provided with Qt. - An SVG drawing created by the SVG Generator Example provided with Qt. - - - - VAbstractNode - - - Can't find tag Modeling - Не могу найти тег Modeling - - - - VApplication - - - - - - - - Error! - Ошибка! - - - - Error parsing file. Program will be terminated. - Ошибка парсинга файла. Програма будет закрыта. - - - - Error bad id. Program will be terminated. - Ошибка, неправильный id. Програма будет закрыта. - - - - Error can't convert value. Program will be terminated. - Ошибка не могу конвертировать значение. Програма будет закрыта. - - - - Error empty parameter. Program will be terminated. - Ошибка пустой параметр. Програма будет закрыта. - - - - Error wrong id. Program will be terminated. - Ошибка неправельный id. Програма будет закрыта. - - - - Something wrong!! - Что то не так!!! - - - - VArc - - - Can't find id = %1 in table. - Не могу найти id = %1 в таблице. - - - - Angle of arc can't be 0 degree. - Угол дуги не может быть 0 градусов. - - - - Arc have not this number of part. - Дуга не имеет ету часть. - - - - VContainer - - - Can't find object - Не могу найти объект - - - - VDomDocument - - - Got wrong parameter id. Need only id > 0. - Получен неправельный параметр id. Допустимы только id > 0. - - - - Can't convert toLongLong parameter - Не могу конвертировать toLongLong параметр - - - - Got empty parameter - Получен пустой параметр - - - - Can't convert toDouble parameter - Не могу конвертировать toDouble параметр - - - - This id is not unique. - Этот id не уникальный. - - - - Error creating or updating detail - Ошибка создания или обновления детали - - - - Error creating or updating single point - Ошибка создания или обновления базовой точки - - - - Error creating or updating point of end line - Ошибка создания или обновления точки на конце линии - - - - Error creating or updating point along line - Ошибка создания или обновления точки вдоль линии - - - - Error creating or updating point of shoulder - Ошибка создания или обновления точки плеча - - - - Error creating or updating point of normal - Ошибка создания или обновления точки нормали - - - - Error creating or updating point of bisector - Ошибка создания или обновления точки бисектрисы - - - - Error creating or updating point of lineintersection - Ошибка создания или обновления точки пересичения линий - - - - Error creating or updating point of contact - Ошибка создания или обновления точки прикосновения - - - - Error creating or updating modeling point - Ошибка создания или обновления точки - - - - Error creating or updating height - Ошибка создания или обновления высоты - - - - Error creating or updating triangle - Ошибка создания или обновления треугольника - - - - Error creating or updating point of intersection - Ошибка создания или обновления точки пересичения - - - - Error creating or updating line - Ошибка создания или обновления линии - - - - Error creating or updating simple curve - Ошибка создания или обновления кривой - - - - Error creating or updating curve path - Ошибка создания или обновления сложной кривой - - - - Error creating or updating modeling simple curve - Ошибка создания или обновления модельной кривой - - - - Error creating or updating modeling curve path - Ошибка создания или обновления сложной модельной кривой - - - - Error creating or updating simple arc - Ошибка создания или обновления дуги - - - - Error creating or updating modeling arc - Ошибка создания или обновления модельной дуги - - - - Error! - Ошибка! - - - - Error parsing file. - Ошибка парсинга файла. - - - Can't get parent for object id = %1 - Не могу получить родителя объекта id = %1 - - - - VDrawTool - - - Options - Параметры - - - - Delete - Удалить - - - - Can not find the element after which you want to insert. - Не могу найти елемент после которого вы хочете вставить. - - - - Can't find tag Calculation - Не могу найти тег Calculation - - - - VModelingTool - - - Option - Параметры - - - - Delete - Удалить - - - - VSplinePath - - - Not enough points to create the spline. - Не достаточно точок для создания кривой. - - - - - - This spline is not exist. - Такой кривой не существует. - - - - VTableGraphicsView - - - detail don't find - деталь не найдена - - - - detail find - деталь найдена - - - - VToolDetail - - - Options - Параметры - - - - Delete - Удалить - - - - VToolTriangle - - - Can't find point. - Не могу найти точку. - - - diff --git a/share/translations/valentina_ru_RU.ts b/share/translations/valentina_ru_RU.ts new file mode 100644 index 000000000..88e81d194 --- /dev/null +++ b/share/translations/valentina_ru_RU.ts @@ -0,0 +1,8159 @@ + + + + + AddDet + + Add detail + Добавить деталь + + + + AddPatternPiece + + Add pattern piece %1 + Добавить лекало %1 + + + + AddToCalc + + Add object + Добавить объект + + + + AddUnionDetails + + Add union details + Добавить объединение деталей + + + + CommunityPage + + Server + Сервер + + + Server name/IP + Имя / IP сервера + + + Secure connection + Безопасное подключение + + + Proxy settings + Настройки прокси-сервера + + + Use Proxy + Использовать прокси + + + Proxy address + Адрес прокси + + + Proxy port + Порт прокси-сервера + + + Proxy user + Пользователь Proxy + + + Proxy pass + Пароль прокси-сервера + + + User settings + Пользовательские настройки + + + User Name + Имя пользователя + + + Save password + Сохранить пароль + + + Password + Пароль + + + + ConfigDialog + + Apply + Применить + + + &Cancel + &Отмена + + + &Ok + &Ок + + + Config Dialog + Диалог параметров + + + Configuration + Настройки + + + Pattern + Лекало + + + Community + Сообщество + + + Paths + Пути + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + Настройки языка интерфейса пользователя оновлены и будут задействованы при следующем запуске + + + Default unit updated and will be used the next pattern creation + Единицы измерения обновлены и будут применены при следующем создании лекала + + + Save + Сохранить + + + Auto-save modified pattern + Автосохранение измененного лекала + + + Interval: + Интервал: + + + min + мин + + + Language + Язык + + + GUI language + Язык интерфейса + + + Decimal separator parts + Разделитель дробовой части + + + With OS options (%1) + С опциями ОС (%1) + + + Default unit + Единица измерения по умолчанию + + + Centimeters + Сантиметры + + + Millimiters + Миллиметры + + + Send crash reports + Отсылка отчета об ошибках + + + Send crash reports (recommended) + Отсылка отчета об ошибках (рекомендуется) + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + После каждого падения Valentina собирает информацию которая может помочь нам в исправлении ошибки. Мы не собираем персональную информацию пользователей. Узнать больше о <a href=https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports>информации</a> которую мы собираем. + + + Milimiters + Milimiters + + + Inches + Дюймы + + + Label language + Язык имени точки + + + With OS options (.) + С параметров ОС (.) + + + + DelTool + + Delete tool + Удалить инструмент + + + + DeleteDetail + + Delete tool + Удалить инструмент + + + + DeletePatternPiece + + Delete pattern piece %1 + Удалить лекало %1 + + + + DialogAboutApp + + About Valentina + Про Valentina + + + Valentina version + Версия Valentina + + + Contributors + Авторы + + + Based on Qt %2 (32 bit) + Базируется на Qt %2 (32 bit) + + + Built on %3 at %4 + Создано %3 в %4 + + + Web site : %1 + Веб сайт : %1 + + + Warning + Предупреждение + + + Cannot open your default browser + Не могу открыть браузер по умолчанию + + + Build revision: + Резвизия: + + + + DialogAlongLine + + Point along line + Точка вдоль линии + + + Length + Длина + + + ... + ... + + + Value of length + Значение длины + + + _ + _ + + + Formula for the calculation of length of line + Формула расчета длины линии + + + Calculate value + Расчитать значение + + + Point label + Имя точки + + + Insert variable into the formula + Вставить переменную в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + + + First point + Первая точка + + + First point of line + Первая точка линии + + + Second point + Вторая точка + + + Second point of line + Вторая точка линии + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Select second point of line + Выберить вторую точку линии + + + + DialogArc + + Arc + Дуга + + + Radius + Радиус + + + ... + ... + + + Formula for the calculation of radius of arc + Формула расчета радиуса дуги + + + Insert variable into the formula + Вставить переменную в формулу + + + Calculate value + Расчитать значение + + + Value of radius + Значение радиуса + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + First angle degree + Первый угол градусы + + + First angle of arc counterclockwise + Первый угол дуги против часовой стрелки + + + Insert variable into formula + Вставить переменную в формулу + + + Value of first angle + Значение первого угла + + + Second angle degree + Второй угол градусы + + + Second angle of arc counterclockwise + Второй угол дуги против часвой стрелки + + + Insert marked variable into formula + Вставить выбраную переменную в формулу + + + Value of second angle + Значение второго угла + + + Center point + Центральная точка + + + Select point of center of arc + Выберите точку центра дуги + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Size and growth + Размер и рост + + + First angle + Первый угол + + + Second angle + Второй угол + + + Standard table + Стандартная таблица + + + Measurements + Мерки + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables + Переменные + + + Value of angle of line. + Значение угла линии. + + + Error + Ошибка + + + Radius can't be negative + Радиус не может иметь значение меньше нуля + + + Angles equal + Углы равны + + + + DialogBisector + + Bisector + Бисектриса + + + Length + Длина + + + ... + ... + + + Value of length + Значение длины + + + _ + _ + + + Calculation of length of bisector by using the formula + Расчет длины бисектрисы используя формулу + + + Insert marked variable into the formula + Вставить выбраную переменную в формулу + + + Calculate value + Расчитать значение + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Point label + Имя точки + + + First point + Первая точка + + + First point of angle + Первая точка угла + + + Second point + Вторая точка + + + Second point of angle + Вторая точка угла + + + Third point + Третья точка + + + Third point of angle + Третья точка угла + + + Type of line + Тип линии + + + Show line from second point to this point + Показать линию с первой точки до этой + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Select second point of angle + Выберить вторую точку угла + + + Select third point of angle + Выберить третью точку угла + + + + DialogCurveIntersectAxis + + Curve intersect axis + Пересичение кривой и оси + + + Angle + Угол + + + Calculate value + Расчитать значение + + + Value of angle + Значение угла + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + + + Axis point + Точка оси + + + First point of line + Первая точка линии + + + Curve + Кривая + + + Point label + Имя точки + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables + Переменные + + + Select axis point + Выберить точку оси + + + + DialogCutArc + + Dialog + Диалог + + + Length + Длина + + + Formula for the calculation of the spline + Формула расчета сплайна + + + Cut arc + Разрезать дугу + + + ... + ... + + + Calculate value + Расчитать значение + + + Value of length + Значение длины + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Arc + Дуга + + + Selected curve + Выбраная кривая + + + Point label + Имя точки + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + + DialogCutSpline + + Dialog + Диалог + + + Length + Длина + + + Formula for the calculation of the spline + Формула расчета сплайна + + + Cut curve + Разрезать кривую + + + ... + ... + + + Calculate value + Расчитать значение + + + Value of length + Значение длины + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Curve + Кривая + + + Selected curve + Выбраная кривая + + + Point label + Имя точки + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + + DialogCutSplinePath + + Dialog + Диалог + + + Length + Длина + + + Formula for the calculation of the curve length + Формула для расчета длины кривои + + + Cut curve path + Разрезать сложную кривую + + + ... + ... + + + Calculate value + Расчитать значение + + + Value of length + Значение длины + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Curve + Кривая + + + Selected curve path + Выбраная сложная кривая + + + Point label + Имя точки + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + + DialogDetail + + Detail + Деталь + + + Bias X + Смещение по Х + + + cm + см + + + Bias Y + Смещение по Y + + + Options + Параметры + + + Seam allowance + Прибавка на швы + + + Delete + Удалить + + + Name of detail + Имя детали + + + Width + Ширина + + + Closed + Замкнутая + + + Got wrong scene object. Ignore. + Получен не правильный объект сцены. Ингорируем. + + + Got wrong tools. Ignore. + Получен не правильный инструмент. Игнорируем. + + + Reverse + Изменить направление + + + + DialogEditWrongFormula + + Edit formula + Редактировать формулу + + + Formula + Формула + + + Insert variable into formula + Вставить переменную в формулу + + + ... + ... + + + Calculate value + Расчитать значение + + + Value of first angle + Значение первого угла + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Standard table + Стандартная таблица + + + Measurements + Мерки + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables + Переменные + + + + DialogEndLine + + Length + Длина + + + Point in the end of a line + Точка на конце отрезка + + + Formula for calculation of length of line + Формула расчета длины линии + + + Calculate value + Расчитать значение + + + ... + ... + + + Value of length + Значение длины + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Angle + Угол + + + Value of angle + Значение угла + + + Base point + Базовая точка + + + First point of line + Первая точка линии + + + Point label + Имя точки + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Standard table + Стандартная таблица + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables + Переменные + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + Angle of line + Угол линии + + + Degree of angle + Угол + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + + DialogHeight + + Dialog + Диалог + + + Height + Рост + + + Point label + Имя точки + + + Base point + Базовая точка + + + First point of line + Первая точка линии + + + Second point of line + Вторая точка линии + + + Type of line + Тип линии + + + Show line from first point to our point + Показать линию с первой точки к нашей + + + Select first point of line + Выберить первую точку линии + + + Select second point of line + Выберить вторую точку линии + + + + DialogHistory + + History + История + + + Tool + Инструмент + + + %1 - Base point + %1 - Базовая точка + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - Линия с точки %1 к точке %2 + + + %3 - Point along line %1_%2 + %3 - Точка вдоль линии %1_%2 + + + %1 - Point of shoulder + %1 - Точка плеча + + + %3 - normal to line %1_%2 + %3 - перпендикуляр к линии %1_%2 + + + %4 - bisector of angle %1_%2_%3 + %4 - биссектриса угла %1_%2_%3 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + %4 - точка пересечения дуги с центром в точке %1 и линии %2_%3 + + + Point of perpendicular from point %1 to line %2_%3 + Точка перпендикуляра с точки %1 до линии %2_%3 + + + %1 - point of intersection %2 and %3 + %1 - точка пересечения %2 и %3 + + + %1 - cut arc with center %2 + %1 - разрезает дугу с центром в %2 + + + %1 - cut curve %2_%3 + %1 - разрезает кривую %2_%3 + + + %1 - cut curve path %2 + %1 - разрезает сложную кривую %2 + + + %1 - point of intersection line %2_%3 and axis through point %4 + %1 - точка пересечения линии %2_%3 и оси через точку %4 + + + %1 - point of intersection curve and axis through point %2 + %1 - точка пересечения кривой и оси через точку %2 + + + %1 - cut curve point %2 + %1 - разрезает сложную кривую %2 + + + Got wrong tool type. Ignore. + Получено неправильный тип инструмента. Игнорируем. + + + Curve %1_%2 + Кривая %1_%2 + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - пересечение линий %1_%2 и %3_%4 + + + Can't create record. + Не могу создать запись. + + + Arc with center in point %1 + Дуга c центром в точке %1 + + + Curve point %1 + Точка кривой %1 + + + Triangle: axis %1_%2, points %3 and %4 + Треугольник: ось %1_%2, точки %3 и %4 + + + + DialogIncrements + + Increments + Прибавки + + + Sizes table + Стандартная таблица + + + Measurements + Мерки + + + Load another measurements table + Загрузить другую таблицу с мерками + + + Personal information + Персональная информация + + + Given name + Имя + + + Family name + Фамилия + + + Birth date + Дата рождения + + + Sex + Стать + + + Hide empty measurements + Спрятать пустые мерки + + + Name + Обозначение + + + The calculated value + Расчитаное значение + + + Base value + Базовое значение + + + In sizes + В размерах + + + In growths + В ростах + + + Description + Опис + + + In size + В размерах + + + In growth + В ростах + + + ... + ... + + + Email + E-mail + + + In heights + В ростах + + + Lines + Линии + + + Line + Линия + + + Length of the line + Длина линии + + + Curves + Кривые + + + Curve + Кривая + + + Length of the curve + Длина кривой + + + Arcs + Дуги + + + Arc + Дуга + + + Length of arc + Длина дуги + + + Name %1 + Обозначение %1 + + + File error. + Ошибка файла. + + + male + мужчина + + + female + женщина + + + Could not save GivenName + Не удалось сохранить имя + + + Could not save FamilyName + Не удалось сохранить фамилию + + + Could not save Email + Не удалось сохранить Email + + + Could not save Sex + Не удалось сохранить стать + + + Could not save BirthDate + Не удалось сохранить дату рождения + + + Measurements use different units than pattern. This pattern required measurements in %1 + Мерки используют другие единицы измерения нежели лекало. Это лекало требует мерки в %1 + + + Individual measurements (*.vit) + Индивидуальные мерки (*.vit) + + + Open file + Открыть файл + + + Wrong units. + Неправильные единицы измерения. + + + Standard measurements (*.vst) + Стандартные мерки (*.vst) + + + Name_%1 + Имя_%1 + + + Can't save measurement + Не удалось сохранить мерки + + + Can't convert toDouble value. + Не могу конвертировать к toDouble значение. + + + Calculated value + Расчитаное значение + + + Length + Длина + + + + DialogIndividualMeasurements + + Dialog + Диалог + + + Individual measurements + Индивидуальные мерки + + + Pattern piece name + Имя лекала + + + Exist measurements + Существующие мерки + + + Path: + Путь: + + + ... + ... + + + Given name: + Имя: + + + Family name: + Фамилия: + + + New measurements + Новые мерки + + + Units: + Единицы измерения: + + + Could not create measurements file + Не могу создать файл мерок + + + Please try again or change file + Пожайлуста попробуйте снова или смените файл + + + File error. + Ошибка файла. + + + Individual measurements (*.vit) + Индивидуальные мерки (*.vit) + + + Open file + Открыть файл + + + Where save measurements? + Где сохранить мерки? + + + Centimeters + Сантиметры + + + Millimiters + Миллиметры + + + Milimiters + Milimiters + + + Inches + Дюймы + + + centimeter + сантиметры + + + inch + дюймы + + + + DialogLine + + Line + Линия + + + First point + Первая точка + + + Second point + Вторая точка + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Select second point + Выберить вторую точку + + + + DialogLineIntersect + + Point of line intersection + Точка пересичения линий + + + Intersection of lines + Пересичение линий + + + Point label + Имя точки + + + First line + Первая линия + + + First point + Первая точка + + + Second point + Вторая точка + + + Second line + Вторая линия + + + Select second point of first line + Выберить вторую точку первой линии + + + Select first point of second line + Выберить первую точку второй линии + + + Select second point of second line + Выберить вторую точку второй линии + + + + DialogLineIntersectAxis + + Line intersect axis + Пересечение линии и оси + + + Angle + Угол + + + Calculate value + Расчитать значение + + + Value of angle + Значение угла + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + + + Axis point + Точка оси + + + First point of line + Первая точка линии + + + First line point + Первая точка линии + + + Second line point + Вторая точка линии + + + Point label + Имя точки + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Input data + Входные данные + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables + Переменные + + + Select second point of line + Выберить вторую точку линии + + + Select axis point + Выберить точку оси + + + + DialogMeasurements + + Measurements + Мерки + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + <html><head/><body><p><span style=" font-size:18pt;">Пожалуйста, выберите тип лекала.</span></p></body></html> + + + Graduation + Градация + + + Use for creation pattern standard measurement table + Лекало со стандартной таблицей + + + Individual + Индивиндуальные + + + Use for creation pattern individual measurements + Лекало с индивидуальных мерок + + + + DialogNormal + + Normal + Перпендикуляр + + + Length + Длина + + + ... + ... + + + Value of length + Значение длины + + + _ + _ + + + First point + Первая точка + + + Second point + Вторая точка + + + Additional angle degrees + Доп. угол градусы + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Formula for calculation of length of normal + Формула расчета длины перпендикуляра + + + Calculate value + Расчитать значение + + + Point label + Имя точки + + + Insert variable into formula + Вставить переменную в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Type of line + Тип линии + + + Show line from first point to this point + Показать линию с первой точки до этой + + + Size and height + Размер и рост + + + Standard table + Стандартная таблица + + + Measurements + Мерки + + + Increments + Прибавки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + Select second point of line + Выберить вторую точку линии + + + + DialogPatternProperties + + Pattern properties + Свойства лекала + + + Description + Описание + + + Author name + Имя автора + + + Pattern description + Описание лекала + + + For technical notes. + Для технических заметок. + + + Heights and Sizes + Роста и размеры + + + All heights (cm) + Все роста (см) + + + 92 + 92 + + + 146 + 146 + + + 98 + 9 + + + 152 + 152 + + + 104 + 104 + + + 158 + 158 + + + 110 + 110 + + + 164 + 164 + + + 116 + 116 + + + 170 + 170 + + + 122 + 122 + + + 176 + 176 + + + 128 + 128 + + + 182 + 182 + + + 134 + 134 + + + 188 + 188 + + + 140 + 140 + + + 194 + 194 + + + All sizes (cm) + Все размеры (см) + + + 22 + 2 + + + 40 + 4 + + + 24 + 24 + + + 42 + 42 + + + 26 + 2 + + + 44 + 44 года + + + 28 + 28 + + + 46 + 46 + + + 30 + 30 + + + 48 + 48 + + + 32 + 32 + + + 50 + 50 + + + 34 + 34 + + + 52 + 52 + + + 36 + 36 + + + 54 + 54 + + + 38 + 38 + + + 56 + 56 + + + + DialogPatternXmlEdit + + XML Editor + XML редактор + + + Value : + Значение: + + + Name : + Имя: + + + <No selection> + <Нет выбораного> + + + Type : + Тип: + + + Add attribute + Добавить атрибут + + + Add son + Добавить сына + + + Remove attribute + Удалить атрибут + + + Remove attibute + Удалить attibute + + + Remove node + Удалить узел + + + Set + Задать + + + Cancel + Отмена + + + Apply changes + Применить изменения + + + Undo last + Отменить последнее + + + Immediate apply + Немедленно применить + + + Base selection + Выбор базы + + + All pattern pieces + Все выкройки + + + No changes + Нету изменений + + + Cannot delete previously created node + Не вдається видалити раніше створений вузол + + + No changes left + Больше изменений не осталось + + + Cannot undo change + Не могу отменить изменения + + + <no value> + <Нет значения> + + + Unchanged + Неизменившийся + + + Cannot delete previously created attribute + Не удается удалить ранее созданный атрибут + + + Node Name + Имя Узла + + + Name: + Название: + + + Node Value (may be empty) + Значение узла (может быть пустым) + + + Value: + Значение: + + + Attribute Name + Название атрибута + + + Attribute Value + Значение атрибута + + + No selection + Не выбрано + + + Root node + Корневой узел + + + Node + Узел + + + Attribute + Атрибут + + + + DialogPointOfContact + + Point of contact + Точка касания + + + Radius + Радиус + + + ... + ... + + + Value of radius + Значение радиуса + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + Center of arc + Центр дуги + + + Formula for calculation of radius of arc + Формула расчета радиуса дуги + + + Calculate value + Расчитать значение + + + Point label + Имя точки + + + Insert variable into formula + Вставить переменную в формулу + + + Top of the line + Начало линии + + + End of the line + Конец линии + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Standard table + Стандартная таблица + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula. + Переменные - кликнете дважды для вставки в формулу. + + + Increments + Прибавки + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Select second point of line + Выберить вторую точку линии + + + Select point of center of arc + Выберите точку центра дуги + + + + DialogPointOfIntersection + + Dialog + Диалог + + + Point label + Имя точки + + + vertical point + Точка вертикали + + + horizontal point + Точка горизонтали + + + First point of angle + Первая точка угла + + + Point of intersection + Точка пересечения + + + Second point of angle + Вторая точка угла + + + Select point horizontally + Выберить точку по горозинтали + + + + DialogShoulderPoint + + Point of shoulder + Точка плеча + + + Length + Длина + + + ... + ... + + + Value of length + Значение длины + + + _ + _ + + + Formula for calculation of length of line + Формула расчета длины линии + + + Calculate value + Расчитать значение + + + Point label + Имя точки + + + Insert variable into formula + Вставить переменную в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + First point + Первая точка + + + Second point + Вторая точка + + + Third point + Третья точка + + + Type of line + Тип линии + + + Show line from first point to our point + Показать линию с первой точки к нашей + + + Input data + Входные данные + + + Size and growth + Размер и рост + + + Standard table + Стандартная таблица + + + Angle of lines + Уголы линий + + + Hide empty measurements + Спрятать пустые мерки + + + Variables - Click twice to insert into formula + Переменные - кликнете дважды для вставки в формулу + + + Increments + Прибавки + + + Size and height + Размер и рост + + + Measurements + Мерки + + + Length of lines + Длина линий + + + Length of arcs + Длина дуг + + + Length of curves + Длина кривых + + + Select first point of line + Выберить первую точку линии + + + Select second point of line + Выберить вторую точку линии + + + Select point of shoulder + Выберить точку плеча + + + + DialogSinglePoint + + Single point + Одиночная точка + + + Coordinates on the sheet + Координаты на листе + + + Coordinates + Координаты + + + Y coordinate + Y координата + + + X coordinate + Х координата + + + Point label + Имя точки + + + + DialogSpline + + Curve + Кривая + + + First point + Первая точка + + + Length ratio of the first control point + Коефициент длины первой контрольной точки + + + The angle of the first control point + Угол первой контрольной точки + + + Second point + Вторая точка + + + Length ratio of the second control point + Коефициент длины второй контрольной точки + + + The angle of the second control point + Угол второй контрольной точки + + + Coefficient of curvature of the curve + Коэффициент кривизны кривой + + + Select last point of curve + Выберить последнюю точку кривой + + + + DialogSplinePath + + Curve path + Сложная кривая + + + Curved path + Сложная кривая + + + Point of curve + Точка кривой + + + Length ratio of the first control point + Коефициент длины первой контрольной точки + + + The angle of the first control point + Угол первой контрольной точки + + + Length ratio of the second control point + Коефициент длины второй контрольной точки + + + The angle of the second control point + Угол второй контрольной точки + + + List of points + Список точок + + + Coefficient of curvature of the curve + Коефициент кривизные кривой + + + Select point of curve path + Выберить точку сложной кривой + + + + DialogStandardMeasurements + + Standard table + Стандартная таблица + + + Pattern piece name + Имя лекала + + + Standard measurements table + Стандартная таблица мерок + + + File error. + Ошибка файла. + + + + DialogTool + + Wrong details id. + Неправильный id детали. + + + Line + Линия + + + No line + Без линии + + + Can't find point by name + Не могу найти точку за именем + + + Error + Ошибка + + + Growth + Рост + + + Dash Line + Пунктирная линия(-) + + + Dot Line + Пунктирная линия(.) + + + Dash Dot Line + Пунктирная линия(-.) + + + Dash Dot Dot Line + Пунктирная линия(-..) + + + Can't find object by name + Не могу найти объект за именем + + + Empty field + Пустое поле + + + Value can't be 0 + Значение не может быть 0 + + + Value + Значение + + + Height + Рост + + + Size + Размер + + + Line length + Длина линии + + + Arc length + Длина дуги + + + Curve length + Длина кривой + + + Parser error: %1 + Ошибка синтаксического анализа: %1 + + + + DialogTriangle + + Dialog + Диалог + + + Triangle + Треугольник + + + Point label + Имя точки + + + First point of axis + Первая точка оси + + + First point of line + Первая точка линии + + + Second point of axis + Вторая точка оси + + + First point + Первая точка + + + Second point + Вторая точка + + + Select second point of axis + Выберить вторую точку оси + + + Select first point + Выберить первую точку + + + Select second point + Выберить вторую точку + + + + DialogUndo + + Broken formula + Сломанная формула + + + Error while calculation formula. You can try undo last operation or fix broken formula. + Ошибка при расчете формулы. Вы можете попробывать отменить последнюю операцию или исправить неисправную формулу. + + + &Undo + &Отменить + + + &Fix formula + &Исправить формулу + + + &Cancel + &Отмена + + + + DialogUnionDetails + + Dialog + Диалог + + + Do you really want union details? This operation can't be undone. + Вы точно хотите объединить детали? Эту операцию нельзя будет отменить. + + + Select first point + Выберить первую точку + + + Select second point + Выберить вторую точку + + + Select another second point + Выберите другую точку + + + Select detail + Выберить деталь + + + Union details + Объединение деталей + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><р>Показать полный расчет в окне сообщения</p></body></html> + + + + Functions + + sin + sine function + sin + + + cos + cosine function + cos + + + tan + tangens function + tan + + + asin + arcus sine function + asin + + + acos + arcus cosine function + acos + + + atan + arcus tangens function + atan + + + sinh + hyperbolic sine function + sinh + + + cosh + hyperbolic cosine + cosh + + + tanh + hyperbolic tangens function + tanh + + + asinh + hyperbolic arcus sine function + asibh + + + acosh + hyperbolic arcus tangens function + acosh + + + atanh + hyperbolic arcur tangens function + atanh + + + log2 + logarithm to the base 2 + log2 + + + log10 + logarithm to the base 10 + log10 + + + log + logarithm to the base 10 + log + + + ln + logarithm to base e (2.71828...) + ln + + + exp + e raised to the power of x + exp + + + sqrt + square root of a value + sqrt + + + sign + sign function -1 if x<0; 1 if x>0 + sign + + + rint + round to nearest integer + rint + + + abs + absolute value + abs + + + min + min of all arguments + min + + + max + max of all arguments + max + + + sum + sum of all arguments + sum + + + avg + mean value of all arguments + avg + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + Программа предоставляется КАК ЕСТЬ без ГАРАНТИЙ ЛЮБОГО РОДА, ВКЛЮЧАЯ ГАРАНТИЙ ДИЗАЙНА, КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНЫХ ЦЕЛЕЙ. + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Инструменты для создания точек. + + + Point + Точка + + + Point along perpendicular + Инструмент точка перпендикуляра + + + ... + ... + + + Special point on shoulder. + Инструмент точка плеча. + + + Point at distance and angle + Инструмент точка на конце отрезка + + + Point at distance along line + Инструмент точка вдоль линии + + + Point along bisector + Инструмент точка бисектрисы + + + Point at intersection of arc and line. + Инструмент точка касания. + + + Tool point of height. + Инструмент точка высоты. + + + Tool triangle. + Инструмент угольник. + + + Tools for creating lines. + Инструменты создания линий. + + + Line + Линия + + + Tool line. + Инструмент линия. + + + Tool point of line intersection. + Инструмент точка пересичения линий. + + + Tools for creating curves. + Инструменты создания кривых. + + + Curve + Кривая + + + Tool curve. + Инструмент кривая. + + + Tool path curve. + Инструмент сложная кривая. + + + Tools for creating arcs. + Инструменты создания дуг. + + + Arc + Дуга + + + Tool arc. + Инструмент дуга. + + + Tools for creating details. + Инструменты создания деталей. + + + Detail + Деталь + + + Tool new detail. + Инструмент новая деталь. + + + File + Файл + + + Help + Помощь + + + Pattern piece + Чертеж + + + Details mode + Режим деталей + + + Pointer tools + Инструмент указатель + + + New pattern piece + Новый чертеж + + + Add new pattern piece + Добавить новый чертеж + + + Perpendicular point along line + Перпендикулярная точка вдоль линии + + + Tool to make point from x & y of two other points. + Инструмент, чтобы сделать точку от х и у двух других точек. + + + Line between points + Линия между точками + + + Point at line intersection + Точка пересичения линий + + + Curve tool. + Инструмент кривая. + + + Tool for path curve. + Инструмент сложная кривая. + + + Tool segment a pathed curve. + Инструмент разрезания сложной кривой. + + + Tool for segmenting a curve. + Инструмент разрезания кривой. + + + Point of intersection line and axis + Точка пересечения линии и оси + + + Arc tool. + Инструмент дуга. + + + Cut arc tool. + Инструмент разрезания дуги. + + + Tool for union two details. + Инструмент объединения двух деталей. + + + &File + &Файл + + + &Help + &Помощь + + + &Pattern piece + &Чертеж + + + New + Новое + + + &New + &Новый + + + Create a new pattern + Создать новое лекало + + + Ctrl+N + Ctrl+N + + + Open + Открыть + + + &Open + &Открыть + + + Open file with pattern + Открыть файл с лекалом + + + Save + Сохранить + + + &Save + &Сохранить + + + Save pattern + Сохранить лекало + + + Ctrl+S + Ctrl+S + + + Save &As... + Сохранить &как... + + + Options... + Параметры... + + + Pattern properties + Свойства лекала + + + Save as + Сохранить как + + + Measurements + Мерки + + + Window + Окно + + + Toolbar files + Панель инструментов файлы + + + ToolBar modes + Панель инструментов режимы + + + Toolbar pattern + Панель инструментов лекала + + + Toolbar options + Панель инструментов настройки + + + Toolbar tools + Панель инструментов + + + Tool options + Параметры инструметнов + + + Save not yet saved pattern + Сохранить еще не сохраненное лекало + + + Ctrl+Shift+S + Ctrl+Shift+S + + + Draw + Рисование + + + Draw mode + Режим рисования + + + Ctrl+W + Ctrl+W + + + Details + Детали + + + Ctrl+E + Ctrl+E + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Change the label of pattern piece + Изменить имя чертежа + + + Export pattern (layout) + Экспорт чертежа (роскладка) + + + About &Qt + Про &Qt + + + &About Valentina + &Про Valentina + + + E&xit + &Выход + + + Exit the application + Закрыть программу] + + + Ctrl+Q + Ctrl+Q + + + Preferences + Свойства + + + Zoom in + Увеличить + + + Original zoom + Начальный масштаб + + + Original Zoom + Начальный масштаб + + + Zoom fit best + Уместить + + + Ctrl+= + Ctrl+= + + + Stop + Стоп + + + Stop using tool + Прекратить использование инструмента + + + Repot Bug... + Сообщить об ошибке... + + + Report bug + Сообщить об ошибке + + + Close window + Закрыть окно + + + Zoom In + Увеличить + + + zoom in + приблизить + + + Zoom Out + Уменьшить + + + Zoom out + Уменьшить + + + Edit pattern XML code + Редактировать XML код чертежа + + + ZoomOriginal + ZoomOriginal + + + ZoomFitBest + ZoomFitBest + + + Deatils mode + Режим деталей + + + Tools pointer + Инструмент указатель + + + Table of variables + Таблица переменных + + + Tables of variables + Таблици переменных + + + Ctrl+T + Ctrl+T + + + History + История + + + Ctrl+H + Ctrl+H + + + Layout + Роскладка + + + Create layout + Создать раскладку + + + Ctrl+L + Ctrl+L + + + About Qt + Про Qt + + + About Valentina + Про Valentina + + + Exit + Выход + + + Drawing %1 + Чертеж %1 + + + Drawing: + Чертеж: + + + Error creating drawing with the name + Ошибка создания чертежа с именем + + + Error saving change!!! + Пошибка сохранение изменений!!! + + + Create new pattern piece to start working. + Создайте новый чертеж для начала работы. + + + Enter a label for the pattern piece. + Введите имя чертежа. + + + Error. Pattern piece of same label already exists. + Ошибка. Чертеж с таким именем уже сущевствует. + + + Pattern piece: + Чертеж: + + + Pattern piece %1 + Чертеж %1 + + + Error creating pattern with the name + Ошибка создания чертежа с именем + + + Enter a new label for the pattern piece. + Введите новое имя для чертежа. + + + Error. Pattern piece of same name already exists. + Ошибка. Чертеж с таким именем уже сувществует. + + + Can't save new label of pattern piece + Не могу сохранить новое имя чертежа + + + Select point + Выберить точку + + + Select first point + Выберить первую точку + + + Select point of shoulder + Выберить точку плеча + + + Individual measurements is under development + Индивидуальные мерки находится в стадии разработки + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + У вас не будет возможности создать файл с индивидуальными мерками независимо от файла лекала. +Для того что бы отрыть файл лекала сохраните оба вайла: выкройку и мерки. Вы хотите продолжить? + + + Select first point of line + Выберить первую точку линии + + + Select first point of angle + Выберить первую точку угла + + + Select first point of first line + Выберить первую точку первой линии + + + Select first point curve + Выберить первую точку кривой + + + Select simple curve + Выберить простую кривую + + + Select point of center of arc + Выберить точку центра дуги + + + Select point of curve path + Выберить точку сложной кривой + + + Select curve path + Выберить сложною кривую + + + Select detail + Выберить деталь + + + Select arc + Выберить дугу + + + Select curve + Выберите кривую + + + Size: + Размеры: + + + pattern + Чертеж + + + Critical error! + Критическая ошибка! + + + Error parsing file (std::bad_alloc). + Ошибка парсинга файла (std::bad_alloc). + + + Bad id. + Плохой id. + + + File saved + Файл сохранен + + + Could not save file + Не удалось сохранить файл + + + &Undo + &Отменить + + + &Redo + &Повторить + + + Measurements use different units than pattern. This pattern required measurements in %1 + Мерки используют другие единицы измерения нежели лекало. Ето леколо требует мерки в %1 + + + Wrong units. + Неправильные единицы измерения. + + + Application doesn't support standard table with inches. + Приложение не поддерживает стандартную таблицу с дюймами. + + + File error. + Ошибка файла. + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + Валентина не была закрыта корректно. Вы хотите восстановить файлы (%1) которые былы открыты раньше? + + + Reopen files. + Повторно открыть файлы. + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + Файл мерок <br/><br/> <b>%1</b> <br/><br/> %3 + + + could not be found. Do you want to update the file location + не может быть найден. Вы хотите обновить путь к файлу + + + Standard measurements (*.vst) + Стандартные мерки (*.vst) + + + Individual measurements (*.vit) + Индивидуальные мерки (*.vit) + + + Can not save pattern + Не могу сохранить лекало + + + untitled.val + без_имени.val + + + Unsaved change + Не сохраненные изменения + + + The pattern has been modified. +Do you want to save your changes? + Лекало было изменено. Вы хотите сохранить ваши изменения? + + + &%1 %2 + &%1 %2 + + + Cannot read file %1: +%2. + Не могу прочитать файл %1:\n%2. + + + File loaded + Файл загружен + + + The pattern has been modified. + Лекало было изменено. + + + Do you want to save your changes? + Вы хочете сохранить изменения? + + + Parsing pattern file error. + Ошибка парсинга файла лекала. + + + Validation file error. + Ошибка валидации файла. + + + Growth: + Рост: + + + Size: + Размер: + + + Drawing: + Чертеж: + + + Lekalo files (*.xml);;All files (*.*) + Файлы лекала (*.xml);;Все файлы (*.*) + + + Lekalo files (*.xml) + Файл лекала (*.xml) + + + Error saving file. Can't save file. + Ошибка сохранения файла. Не могу сохранить файл. + + + Open file + Открыть файл + + + Can't open pattern file %1: +%2. + Не могу окрыть файл лекала %1:\n%2. + + + Can't open schema file %1: +%2. + Не могу окрыть файл схемы %1:\n%2. + + + Error no unique id. + Ошибка не уникальный id. + + + Got empty file name. + Получено пустое имя файла. + + + Could not copy temp file to pattern file + Не могу скопировать временный файл у файл лекала + + + Could not remove pattern file + Не смог удалить файл лекала + + + Can't open pattern file. File name empty + Не могу открыть файл лекала. Пустое имя файла + + + Error! + Ошибка! + + + Select points, arcs, curves clockwise. + Выберить точки, дуги, кривые за часовой стрелкой. + + + Select base point + Выберить базовую точку + + + Select first point of axis + Выберить первую тчоку оси + + + Select point vertically + Выберить точку по вертикали + + + Based on Qt %2 (32 bit) + Базируется на Qt %2 (32 bit) + + + Built on %3 at %4 + Создано %3 в %4 + + + Height: + Рост: + + + Pattern Piece: + Чертеж: + + + Pattern files (*.val) + Файл лекала (*.val) + + + /pattern.val + /лекало.val + + + Can't open pattern file. + Не могу открыть файл лекала. + + + Empty schema path. + Пустой путь к схеме. + + + Can't open schema file. + Не могу открыть файл схемы. + + + Can't open pattern file. File name is empty + Не могу открыть файл лекала. Имя файла пустое + + + Error parsing file. + Ошибка парсинга файла. + + + Error can't convert value. + Ошибка, не могу конвертовать значение. + + + Error empty parameter. + Ошибка, пустой параметр. + + + Error wrong id. + Ошибка, неправильный id. + + + Error parsing pattern file. + Ошибка парсинга файла лекала. + + + Error in line %1 column %2 + Ошибка в линии %1 столбец %2 + + + Online help + Справка в Интернете + + + Show online help + Показать справку + + + This file already opened in another window. + Этот файл уже открыт в другом окне. + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + Огол + + + Head girth + Full measurement name + Обхват головы + + + Around fullest part of Head + Full measurement description + Обхват головы + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + mid_neck_girth + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + Ош + + + Neck Base girth + Full measurement name + Обхват шеи + + + Around Neck at base + Full measurement description + Обхват шеи + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + head_and_neck_length + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дпт + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дтс + + + Back Center length + Full measurement name + Длина спины до талии с учетом выступа лопаток + + + Back Neck Center to Back Waist Center + Full measurement description + Длина спины до талии с учетом выступа лопаток + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + Шп + + + Shoulder length + Full measurement name + Длина плечевого ската + + + NeckPoint to ShoulderTip + Full measurement description + Длина плечевого ската + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дб + + + Side Waist length + Full measurement name + Длина боковой части + + + Armpit to Waist side + Full measurement description + Длина боковой части + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + trunk_length + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + shoulder_girth + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + ОгI + + + Upper Chest girth + Full measurement name + Обхват груди первый + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + Обхват груди первый + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + ОгII + + + Bust girth + Full measurement name + Обхват груди второй + + + Around fullest part of Bust, parallel to floor + Full measurement description + Обхват груди второй + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + ОгIII + + + Under Bust girth + Full measurement name + Обхват груди третий + + + Around Chest below the Bust, parallel to floor + Full measurement description + Обхват груди третий + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + От + + + Waist girth + Full measurement name + Обхват талии + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + Обхват талии. + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + high_hip_girth + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + Об + + + Hip girth + Full measurement name + Обхват бедер с учетом выступания живота + + + Around Hip, parallel to floor + Full measurement description + Обхват бедер с учетом выступания живота + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг1 + + + Front Upper Chest width + Full measurement name + Ширина груди первая + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + Ширина груди первая + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг2 + + + Front Chest width + Full measurement name + Ширина груди вторая + + + Across Front Chest, from armfold to armfold + Full measurement description + Ширина груди вторая + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + dпл + + + Front Across Shoulder width + Full measurement name + Плечевой диаметр + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + Плечевой диаметр + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + across_back_shoulder_width + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + upper_back_width + + + back_width + Short measurement name. Don't use math symbols in name!!!! + Шс + + + Back Chest width + Full measurement name + Ширина спины + + + Across Back Chest, from armfold to armfold + Full measurement description + Ширина спины + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + Цг + + + BustPoint to BustPoint + Full measurement name + Расстояние между сосковыми точками + + + Distance between BustPoints, across Chest + Full measurement description + Расстояние между сосковыми точками + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + halter_bustpoint_to_bustpoint + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + Вг + + + NeckPoint to BustPoint + Full measurement name + Расстояние от точки основания шеи сбоку до сосковой точки (высота груди) + + + From NeckPoint to BustPoint + Full measurement description + Расстояние от точки основания шеи сбоку до сосковой точки (высота груди) + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + crotch_length + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + Дпс + + + Rise height + Full measurement name + Расстояние от линии талии до подъягодичной складки + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + Расстояние от линии талии до подъягодичной складки + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + shoulder_drop + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + shoulder_slope_degrees + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + front_shoulder_slope_length + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + back_shoulder_slope_length + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + front_shoulder_to_waist_length + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + back_shoulder_to_waist_length + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + front_neck_arc + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + back_neck_arc + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + front_upper_chest_arc + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + back_upper_chest_arc + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + front_waist_arc + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + back_waist_arc + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + front_upper_hip_arc + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + back_upper_hip_arc + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + front_hip_arc + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + back_hip_arc + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + chest_slope + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + back_slope + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + front_waist_slope + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + back_waist_slope + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + front_neck_to_upper_chest_height + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + front_neck_to_bust_height + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + Дпер + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + Дпг + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + Дст + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + Дбр + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + armscye_girth + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + Олк + + + Elbow Girth + Full measurement name + Обхват локтя + + + Around Elbow with elbow bent + Full measurement description + Обхват локтя + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + Оп + + + Upperarm Girth + Full measurement name + Обхват плеча + + + Around UpperArm + Full measurement description + Обхват плеча + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + Озап + + + Wrist girth + Full measurement name + Обхват запястья + + + Around Wrist + Full measurement description + Обхват запястья + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + scye_depth + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + Дзап + + + Shoulder and Arm length + Full measurement name + Расстояние от точки основания шеи сбоку до линии обхвата запястья + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Расстояние от точки основания шеи сбоку до линии обхвата запястья + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + Втр + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + cervicale_to_wrist_length + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + Дрлок + + + Elbow length + Full measurement name + Длина руки до локтя + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + Длина руки до локтя + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + Дрзап + + + Arm length + Full measurement name + Длина рукава до линии обхвата запястья + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Длина рукава до линии обхвата запястья + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + hand_width + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + hand_length + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + Окис + + + Hand girth + Full measurement name + Обхват кисти + + + Around Hand + Full measurement description + Обхват кисти + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + Обед + + + Thigh girth + Full measurement name + Обхват бедра + + + Around Thigh + Full measurement description + Обхват бедра + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + mid_thigh_girth + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + Ок + + + Knee girth + Full measurement name + Обхват колена + + + Around Knee + Full measurement description + Обхват колена + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + Ои + + + Calf girth + Full measurement name + Обхват икры + + + Around Calf + Full measurement description + Обхват икры + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + Ощ + + + Ankle girth + Full measurement name + Обхват щиколотки + + + Around Ankle + Full measurement description + Обхват щиколотки + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + Вк + + + Knee height + Full measurement name + Высота коленной точки + + + Knee to Floor + Full measurement description + Высота коленной точки + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + ankle_height + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + foot_width + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + foot_length + + + height + Short measurement name. Don't use math symbols in name!!!! + Р + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + Вшт + + + Nape height + Full measurement name + Высота точки основания шеи сзади + + + Nape to Floor + Full measurement description + Высота точки основания шеи сзади + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + cervicale_to_knee_height + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + Влт + + + Waist height + Full measurement name + Высота линии талии + + + Waist side to floor + Full measurement description + Высота линии талии + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + high_hip_height + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + hip_height + + + Hip side to Floor + Full measurement description + Боковая сторона ступни + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + waist_to_hip_height + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + waist_to_knee_height + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + Дн + + + Crotch height/Inseam + Full measurement name + Длина ноги по внутренней поверхности + + + Crotch to Floor along inside leg + Full measurement description + Длина ноги по внутренней поверхности + + + size + Short measurement name. Don't use math symbols in name!!!! + Сг + + + Size + Full measurement name + Размер + + + Size + Full measurement description + Размер + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + Втос + + + Height front neck base point + Full measurement name + Высота точки основания шеи спереди + + + Height of the point base of the neck in front + Full measurement description + Высота точки основания шеи спереди + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + Втош + + + Height base neck side point + Full measurement name + Высота точки основания шеи сбоку + + + Height of the base of the neck side point + Full measurement description + Высота точки основания шеи сбоку + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + Впт + + + Height shoulder point + Full measurement name + Высота плечевой точки + + + The height of the shoulder point + Full measurement description + Высота плечевой точки + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + Вст + + + Height nipple point + Full measurement name + Высота сосковой точки + + + Height nipple point + Full measurement description + Высота сосковой точки + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + Взу + + + Height back angle axilla + Full measurement name + Высота заднего угла подмышечной впадины + + + Height back angle axilla + Full measurement description + Высота заднего угла подмышечной впадины + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + Влоп + + + Height scapular point + Full measurement name + Высота лопаточной точки + + + Height scapular point + Full measurement description + Высота лопаточной точки + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + Впс + + + Height under buttock folds + Full measurement name + Высота подъягодичной складки + + + Height under buttock folds + Full measurement description + Высота подъягодичной складки + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + ОбI + + + Hips excluding protruding abdomen + Full measurement name + Обхват бедер без учета выступания живота + + + Hips excluding protruding abdomen + Full measurement description + Обхват бедер без учета выступания живота + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + Ос + + + Girth foot instep + Full measurement name + Обхват подъема стопы + + + Girth foot instep + Full measurement description + Обхват подъема стопы + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + Дсб + + + Side waist to floor + Full measurement name + Расстояние от линии талии до пола сбоку + + + The distance from the side waist to floor + Full measurement description + Расстояние от линии талии до пола сбоку + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + Дсп + + + Front waist to floor + Full measurement name + Расстояние от линии талии до пола спереди + + + The distance from the front waist to floor + Full measurement description + Расстояние от линии талии до пола спереди + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + Дпоб + + + Arc through groin area + Full measurement name + Дуга через паховую область + + + Arc through groin area + Full measurement description + Дуга через паховую область + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + Вс + + + Waist to plane seat + Full measurement name + Расстояние от линии талии до плоскости сидения + + + The distance from the waist to the plane seat + Full measurement description + Расстояние от линии талии до плоскости сидения + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + Длуч + + + Neck to radial point + Full measurement name + Расстояние от точки основания шеи сбоку до лучевой точки + + + The distance from the base of the neck to the side of the radial point + Full measurement description + Расстояние от точки основания шеи сбоку до лучевой точки + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + ДIIIп + + + Neck to third finger + Full measurement name + Расстояние от точки основания шеи сбоку до конца третьего пальца + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + Расстояние от точки основания шеи сбоку до конца третьего пальца + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + Впрп + + + Neck to first line chest circumference + Full measurement name + Расстояние от точки основания шеи сбоку до линии обхвата груди первого спереди + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + Расстояние от точки основания шеи сбоку до линии обхвата груди первого спереди + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дтп + + + Front waist length + Full measurement name + Расстояние от точки основания шеи сбоку до линии талии спереди (длани талии спереди) + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + Расстояние от точки основания шеи сбоку до линии талии спереди (длани талии спереди) + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + Дп + + + Arc through shoulder joint + Full measurement name + Дуга через высшую точку плечевого сустава + + + Arc through the highest point of the shoulder joint + Full measurement description + Дуга через высшую точку плечевого сустава + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + Впрз + + + Neck to back line chest circumference + Full measurement name + Расстояние от точки основания шеи сзади до линии обхватов груди первого и второго с учетом выступа лопаток + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + Расстояние от точки основания шеи сзади до линии обхватов груди первого и второго с учетом выступа лопаток + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + ДтсI + + + Waist to neck side + Full measurement name + Расстояние от линии талии сзади до точки основания шеи сбоку + + + The distance from the waist to the back base of the neck side point + Full measurement description + Расстояние от линии талии сзади до точки основания шеи сбоку + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + Двчт + + + Arc length upper body + Full measurement name + Длина дуги верхней части туловища через точку основания шеи сбоку + + + Arc length of the upper body through the base of the neck side point + Full measurement description + Длина дуги верхней части туловища через точку основания шеи сбоку + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг + + + Chest width + Full measurement name + Ширина груди + + + Chest width + Full measurement description + Ширина груди + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + dпзр + + + Anteroposterior diameter hands + Full measurement name + Передне-задний диаметр руки + + + Anteroposterior diameter of the hands + Full measurement description + Передне-задний диаметр руки + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + Вкт + + + Height clavicular point + Full measurement name + Высота ключичной точки + + + Height clavicular point + Full measurement description + Высота ключичной точки + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + Впрк + + + Height armhole slash + Full measurement name + Расстояние от шейной точки до уровня заднего угла подмышечной впадины спереди (высота проймы косая) + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + Расстояние от шейной точки до уровня заднего угла подмышечной впадины спереди (высота проймы косая) + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Впк + + + Slash shoulder height + Full measurement name + Высота плеча косая + + + Slash shoulder height + Full measurement description + Высота плеча косая + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + Сш + + + Half girth neck + Full measurement name + Полуобхват шеи + + + Half girth neck + Full measurement description + Полуобхват шеи + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + Сш1 + + + Half girth neck for shirts + Full measurement name + Полуобхват шеи для сорочек + + + Half girth neck for shirts + Full measurement description + Полуобхват шеи для сорочек + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + СгI + + + Half girth chest first + Full measurement name + Полуобхват груди первый + + + Half girth chest first + Full measurement description + Полуобхват груди первый + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + СгII + + + Half girth chest second + Full measurement name + Полуобхват груди второй + + + Half girth chest second + Full measurement description + Полуобхват груди второй + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + СгIII + + + Half girth chest third + Full measurement name + Полуобхват груди третий + + + Half girth chest third + Full measurement description + Полуобхват груди третий + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + Ст + + + Half girth waist + Full measurement name + Полуобхват талии + + + Half girth waist + Full measurement description + Полуобхват талии + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + Сб + + + Half girth hips considering protruding abdomen + Full measurement name + Полуобхват бедер с учетом выступания живота + + + Half girth hips considering protruding abdomen + Full measurement description + Полуобхват бедер с учетом выступания живота + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + СбI + + + Half girth hips excluding protruding abdomen + Full measurement name + Полуобхват бедер без учета выступания живота + + + Half girth hips excluding protruding abdomen + Full measurement description + Полуобхват бедер без учета выступания живота + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + Окс + + + Girth knee flexed feet + Full measurement name + Обхват колена в согнутом положении ноги + + + Girth knee flexed feet + Full measurement description + Обхват колена в согнутом положении ноги + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + Neck transverse diameter + Full measurement name + Поперечный диаметр шеи + + + Neck transverse diameter + Full measurement description + Поперечный диаметр шеи + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Впкп + + + Front slash shoulder height + Full measurement name + Высота плеча косая спереди + + + Front slash shoulder height + Full measurement description + Высота плеча косая спереди + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + Дтн1 + + + Neck to front waist line + Full measurement name + Расстояние от точки основания шеи до линии талии спереди + + + The distance from the base of the neck to the waist line front + Full measurement description + Расстояние от точки основания шеи до линии талии спереди + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + dвр + + + Hand vertical diameter + Full measurement name + Вертикальный диаметр руки + + + Hand vertical diameter + Full measurement description + Вертикальный диаметр руки + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + Дшк + + + Neck to knee point + Full measurement name + Расстояние от шейной точки до колена + + + Distance from neck to knee point + Full measurement description + Расстояние от шейной точки до колена + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + Дтк + + + Waist to knee + Full measurement name + Расстояние от линии талии до колена + + + The distance from the waist to the knee + Full measurement description + Расстояние от линии талии до колена + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Вп + + + Shoulder height + Full measurement name + Высота плеча + + + Shoulder height + Full measurement description + Высота плеча + + + head_height + Short measurement name. Don't use math symbols in name!!!! + Вгол + + + Head height + Full measurement name + Высота головы + + + Head height + Full measurement description + Высота головы + + + body_position + Short measurement name. Don't use math symbols in name!!!! + Пкор + + + Body position + Full measurement name + Положение корпуса + + + Body position + Full measurement description + Положение корпуса + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + Дпз + + + Arc behind shoulder girdle + Full measurement name + Дуга плечевого пояса сзади + + + Arc behind the shoulder girdle + Full measurement description + Дуга плечевого пояса сзади + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + Дшош + + + Neck to neck base + Full measurement name + Расстояние от шейной точки до точки основания шеи сбоку по линии измерения обхвата шеи + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + Расстояние от шейной точки до точки основания шеи сбоку по линии измерения обхвата шеи + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + Гт1 + + + Depth waist first + Full measurement name + Глубина талии первая + + + Depth waist first + Full measurement description + Глубина талии первая + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + ГтII + + + Depth waist second + Full measurement name + Глубина талии вторая + + + Depth waist second + Full measurement description + Глубина талии вторая + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + Обхват головы + + + Around middle part of Neck + Full measurement description + Вокруг средней части шеи + + + Around Neck at base + Full measurement description + Обхват шеи + + + Vertical Distance from Crown to Nape + Full measurement description + Вертикальное расстояние от темени до затылка + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + Длина переда до талии + + + Back Neck Center to Back Waist Center + Full measurement description + Длина спины до талии с учетом выступа лопаток + + + NeckPoint to ShoulderTip + Full measurement description + Длина плечевого ската + + + Armpit to Waist side + Full measurement description + Длина боковой части + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + Обхват груди первый + + + Around fullest part of Bust, parallel to floor + Full measurement description + Обхват груди второй + + + Around Chest below the Bust, parallel to floor + Full measurement description + Обхват груди третий + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + Обхват талии. + + + Around HighHip, parallel to floor + Full measurement description + Around HighHip, parallel to floor + + + Around Hip, parallel to floor + Full measurement description + Обхват бедер с учетом выступания живота + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + Ширина груди первая + + + Across Front Chest, from armfold to armfold + Full measurement description + Ширина груди вторая + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + Плечевой диаметр + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + Around HighHip, parallel to floor + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + Across Back UpperChest, smallest width from armscye to armscye + + + Across Back Chest, from armfold to armfold + Full measurement description + Ширина спины + + + Distance between BustPoints, across Chest + Full measurement description + Расстояние между сосковыми точками + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + Distance from Bustpoint, behind neck, down to Bustpoint + + + From NeckPoint to BustPoint + Full measurement description + Расстояние от точки основания шеи сбоку до сосковой точки (высота груди) + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + From Front Waist Center, down to crotch, up to Back Waist Center + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + Расстояние от линии талии до подъягодичной складки + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + Vertical Distance from NeckPoint level to ShoulderTip level + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + + + ShoulderTip to Front Waist Center + Full measurement description + ShoulderTip to Front Waist Center + + + ShoulderTip to Back Waist Center + Full measurement description + ShoulderTip to Back Waist Center + + + NeckPoint straight down front chest to Waistline + Full measurement description + NeckPoint straight down front chest to Waistline + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + Back NeckPoint straight down back chest to Waistline + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + NeckPoint to NeckPoint through Front Neck Center + + + NeckPoint to NeckPoint across Nape + Full measurement description + NeckPoint to NeckPoint across Nape + + + front_upper-bust_arc + Full measurement description + front_upper-bust_arc + + + Front upper-bust arc + Full measurement description + Front upper-bust arc + + + Back UpperBust side to side + Full measurement description + Back UpperBust side to side + + + Front Waist side to side + Full measurement description + Front Waist side to side + + + Back Waist side to side + Full measurement description + Back Waist side to side + + + Front UpperHip side to side + Full measurement description + Front UpperHip side to side + + + Back UpperHip side to side + Full measurement description + Back UpperHip side to side + + + Front Hip side to side + Full measurement description + Front Hip side to side + + + Back Hip side to side + Full measurement description + Back Hip side to side + + + NeckPoint to Front ArmfoldPoint + Full measurement description + NeckPoint to Front ArmfoldPoint + + + NeckPoint to Back ArmfoldPoint + Full measurement description + NeckPoint to Back ArmfoldPoint + + + NeckPoint across Front Chest to Waist side + Full measurement description + NeckPoint across Front Chest to Waist side + + + NeckPoint across Back Chest to Waist side + Full measurement description + NeckPoint across Back Chest to Waist side + + + Front Neck Center straight down to UpperChest line + Full measurement description + Front Neck Center straight down to UpperChest line + + + Front Neck Center straight down to Bust line + Full measurement description + Front Neck Center straight down to Bust line + + + Front Upper chest waist + Full measurement description + Длина переда от линии талии вверх по центру до начала ложбины + + + Front waist to lower breast + Full measurement description + Длина от талии до основания грудных желез + + + Back waist to upper chest + Full measurement description + Длина спинки по спине от линии талии вверх до выступающего уголка лопатки + + + Strap length + Full measurement description + Длина бретели от выступающего уголка лопатки вертикально до начала грудной железы + + + Around Armscye + Full measurement description + Around Armscye + + + Around Elbow with elbow bent + Full measurement description + Обхват локтя + + + Around UpperArm + Full measurement description + Обхват плеча + + + Around Wrist + Full measurement description + Обхват запястья + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + Nape straight down to UnderBust line (same as Back UpperBust height) + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Расстояние от точки основания шеи сбоку до линии обхвата запястья + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + Внутренняя длина рукава (с окатом) + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + Nape to Wrist, with elbow bent and hand on hip + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + Длина руки до локтя + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Длина рукава до линии обхвата запястья + + + Hand side to side + Full measurement description + Рука из стороны в сторону + + + Hand Middle Finger tip to wrist + Full measurement description + Hand Middle Finger tip to wrist + + + Around Hand + Full measurement description + Обхват кисти + + + Around Thigh + Full measurement description + Обхват бедра + + + Around MidThigh + Full measurement description + Around MidThigh + + + Around Knee + Full measurement description + Обхват колена + + + Around Calf + Full measurement description + Обхват икры + + + Around Ankle + Full measurement description + Обхват щиколотки + + + Knee to Floor + Full measurement description + Высота коленной точки + + + Ankle to Floor + Full measurement description + Ankle to Floor + + + Widest part of Foot side to side + Full measurement description + Widest part of Foot side to side + + + Tip of Longest Toe straight to back of heel + Full measurement description + Кончик длинного пальца прямо к задней части каблука + + + Top of head to floor + Full measurement description + Верх головы к полу + + + Nape to Floor + Full measurement description + Высота точки основания шеи сзади + + + Nape to Knee + Full measurement description + Длина с затылок до колена + + + Waist side to floor + Full measurement description + Высота линии талии + + + HighHip side to Floor + Full measurement description + HighHip side to Floor + + + Hip side to Floor + Full measurement description + Боковая сторона ступни + + + Waist side to Hip + Full measurement description + Waist side to Hip + + + Waist side to Knee + Full measurement description + Waist side to Knee + + + Crotch to Floor along inside leg + Full measurement description + Длина ноги по внутренней поверхности + + + Size + Full measurement description + Размер + + + Height of the point base of the neck in front + Full measurement description + Высота точки основания шеи спереди + + + Height of the base of the neck side point + Full measurement description + Высота точки основания шеи сбоку + + + The height of the shoulder point + Full measurement description + Высота плечевой точки + + + Height nipple point + Full measurement description + Высота сосковой точки + + + Height back angle axilla + Full measurement description + Высота заднего угла подмышечной впадины + + + Height scapular point + Full measurement description + Высота лопаточной точки + + + Height under buttock folds + Full measurement description + Высота подъягодичной складки + + + Hips excluding protruding abdomen + Full measurement description + Обхват бедер без учета выступания живота + + + Girth foot instep + Full measurement description + Обхват подъема стопы + + + The distance from the side waist to floor + Full measurement description + Расстояние от линии талии до пола сбоку + + + The distance from the front waist to floor + Full measurement description + Расстояние от линии талии до пола спереди + + + Arc through groin area + Full measurement description + Дуга через паховую область + + + The distance from the waist to the plane seat + Full measurement description + Расстояние от линии талии до плоскости сидения + + + The distance from the base of the neck to the side of the radial point + Full measurement description + Расстояние от точки основания шеи сбоку до лучевой точки + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + Расстояние от точки основания шеи сбоку до конца третьего пальца + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + Расстояние от точки основания шеи сбоку до линии обхвата груди первого спереди + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + Расстояние от точки основания шеи сбоку до линии талии спереди (обхват талии спереди) + + + Arc through the highest point of the shoulder joint + Full measurement description + Дуга через высшую точку плечевого сустава + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + Расстояние от точки основания шеи сзади до линии обхватов груди первого и второго с учетом выступа лопаток + + + The distance from the waist to the back base of the neck side point + Full measurement description + Расстояние от линии талии сзади до точки основания шеи сбоку + + + Arc length of the upper body through the base of the neck side point + Full measurement description + Длина дуги верхней части туловища через точку основания шеи сбоку + + + Chest width + Full measurement description + Ширина груди + + + Anteroposterior diameter of the hands + Full measurement description + Передне-задний диаметр руки + + + Height clavicular point + Full measurement description + Высота ключичной точки + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + Расстояние от шейной точки до уровня заднего угла подмышечной впадины спереди (высота проймы косая) + + + Slash shoulder height + Full measurement description + Высота плеча косая + + + Half girth neck + Full measurement description + Полуобхват шеи + + + Half girth neck for shirts + Full measurement description + Полуобхват шеи для сорочек + + + Half girth chest first + Full measurement description + Полуобхват груди первый + + + Half girth chest second + Full measurement description + Полуобхват груди второй + + + Half girth chest third + Full measurement description + Полуобхват груди третий + + + Half girth waist + Full measurement description + Полуобхват талии + + + Half girth hips considering protruding abdomen + Full measurement description + Полуобхват бедер с учетом выступания живота + + + Half girth hips excluding protruding abdomen + Full measurement description + Полуобхват бедер без учета выступания живота + + + Girth knee flexed feet + Full measurement description + Обхват колена в согнутом положении ноги + + + Neck transverse diameter + Full measurement description + Поперечный диаметр шеи + + + Front slash shoulder height + Full measurement description + Высота плеча косая спереди + + + The distance from the base of the neck to the waist line front + Full measurement description + Расстояние от точки основания шеи до линии талии спереди + + + Hand vertical diameter + Full measurement description + Вертикальный диаметр руки + + + Distance from neck to knee point + Full measurement description + Расстояние от шейной точки до колена + + + The distance from the waist to the knee + Full measurement description + Расстояние от линии талии до колена + + + Shoulder height + Full measurement description + Высота плеча + + + Head height + Full measurement description + Высота головы + + + Body position + Full measurement description + Положение корпуса + + + Arc behind the shoulder girdle + Full measurement description + Дуга плечевого пояса сзади + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + Расстояние от шейной точки до точки основания шеи сбоку по линии измерения обхвата шеи + + + Depth waist first + Full measurement description + Глубина талии первая + + + Depth waist second + Full measurement description + Глубина талии вторая + + + + MeasurementsFullNames + + Head girth + Full measurement name + Обхват головы + + + Mid-neck girth + Full measurement name + Половина обхвата шеи + + + Neck Base girth + Full measurement name + Обхват шеи + + + Head and Neck length + Full measurement name + Длина шеи и головы + + + Front Center length + Full measurement name + Длина переда до талии + + + Back Center length + Full measurement name + Длина спины до талии с учетом выступа лопаток + + + Shoulder length + Full measurement name + Длина плечевого ската + + + Side Waist length + Full measurement name + Длина боковой части + + + Trunk length + Full measurement name + Длина туловища + + + Shoulder girth + Full measurement name + Обхват плеча + + + Upper Chest girth + Full measurement name + Обхват груди первый + + + Bust girth + Full measurement name + Обхват груди второй + + + Under Bust girth + Full measurement name + Обхват груди третий + + + Waist girth + Full measurement name + Обхват талии + + + HighHip girth + Full measurement name + HighHip girth + + + Hip girth + Full measurement name + Обхват бедер с учетом выступания живота + + + Front Upper Chest width + Full measurement name + Ширина груди первая + + + Front Chest width + Full measurement name + Ширина груди вторая + + + Front Across Shoulder width + Full measurement name + Плечевой диаметр + + + Back Across Shoulder width + Full measurement name + Back Across Shoulder width + + + Back Upper Chest width + Full measurement name + Back Upper Chest width + + + Back Chest width + Full measurement name + Ширина спины + + + BustPoint to BustPoint + Full measurement name + Расстояние между сосковыми точками + + + Halter Bustpoint to Bustpoint + Full measurement name + Halter Bustpoint to Bustpoint + + + NeckPoint to BustPoint + Full measurement name + Расстояние от точки основания шеи сбоку до сосковой точки (высота груди) + + + Crotch length + Full measurement name + Длина промежности + + + Rise height + Full measurement name + Расстояние от линии талии до подъягодичной складки + + + Shoulder Drop + Full measurement name + Shoulder Drop + + + Shoulder Slope degrees + Full measurement name + Склон плеча в градусах + + + Front Shoulder Balance + Full measurement name + Передний баланс плеча + + + Back Shoulder Balance + Full measurement name + Задний баланс плеча + + + Front Full Length + Full measurement name + Полная передняя длина + + + Back Full Length + Full measurement name + Полная задняя длина + + + Front Neck arc + Full measurement name + Передняя дуга шеи + + + Back Neck arc + Full measurement name + Задняя дуга шеи + + + Front upper-bust arc + Full measurement name + Front upper-bust arc + + + Back UpperBust arc + Full measurement name + Back UpperBust arc + + + Front Waist arc + Full measurement name + Передняя дуга талии + + + Back Waist arc + Full measurement name + Задняя дуга талии + + + Front UpperHip arc + Full measurement name + Front UpperHip arc + + + Back UpperHip arc + Full measurement name + Back UpperHip arc + + + Front Hip arc + Full measurement name + Front Hip arc + + + Back Hip arc + Full measurement name + Back Hip arc + + + Chest Balance + Full measurement name + Баланс груди + + + Back Balance + Full measurement name + Задний баланс + + + Front Waist Balance + Full measurement name + Передний баланс талии + + + Back Waist Balance + Full measurement name + Задний баланс талии + + + Front UpperChest height + Full measurement name + Front UpperChest height + + + Bust height + Full measurement name + Высота бюста + + + Front Upper chest waist + Full measurement name + Длина переда от линии талии вверх по центру до начала ложбины + + + Front waist to lower breast + Full measurement name + Длина от талии до основания грудных желез + + + Back waist to upper chest + Full measurement name + Длина спинки + + + Strap length + Full measurement name + Длина бретели + + + Armscye Girth + Full measurement name + Armscye Girth + + + Elbow Girth + Full measurement name + Обхват локтя + + + Upperarm Girth + Full measurement name + Обхват плеча + + + Wrist girth + Full measurement name + Обхват запястья + + + Armscye depth + Full measurement name + Armscye depth + + + Shoulder and Arm length + Full measurement name + Расстояние от точки основания шеи сбоку до линии обхвата запястья + + + Underarm length + Full measurement name + Внутренняя длина рукава (с окатом) + + + Nape to wrist length + Full measurement name + Nape to wrist length + + + Elbow length + Full measurement name + Длина руки до локтя + + + Arm length + Full measurement name + Длина рукава до линии обхвата запястья + + + Hand width + Full measurement name + Ширина руки + + + Hand length + Full measurement name + Длина руки + + + Hand girth + Full measurement name + Обхват кисти + + + Thigh girth + Full measurement name + Обхват бедра + + + Midthigh girth + Full measurement name + Midthigh girth + + + Knee girth + Full measurement name + Обхват колена + + + Calf girth + Full measurement name + Обхват икры + + + Ankle girth + Full measurement name + Обхват щиколотки + + + Knee height + Full measurement name + Высота коленной точки + + + Ankle height + Full measurement name + Высота лодыжки + + + Foot width + Full measurement name + Ширина ноги + + + Foot length + Full measurement name + Длина ноги + + + Total Height + Full measurement name + Общая высота + + + Nape height + Full measurement name + Высота точки основания шеи сзади + + + Nape to knee height + Full measurement name + Затылок к высоте колена + + + Waist height + Full measurement name + Высота линии талии + + + HighHip height + Full measurement name + HighHip height + + + Hip height + Full measurement name + Hip height + + + Waist to Hip height + Full measurement name + Waist to Hip height + + + Waist to Knee height + Full measurement name + Талия к высоте колена + + + Crotch height/Inseam + Full measurement name + Длина ноги по внутренней поверхности + + + Size + Full measurement name + Размер + + + Height front neck base point + Full measurement name + Высота точки основания шеи спереди + + + Height base neck side point + Full measurement name + Высота точки основания шеи сбоку + + + Height shoulder point + Full measurement name + Высота плечевой точки + + + Height nipple point + Full measurement name + Высота сосковой точки + + + Height back angle axilla + Full measurement name + Высота заднего угла подмышечной впадины + + + Height scapular point + Full measurement name + Высота лопаточной точки + + + Height under buttock folds + Full measurement name + Высота подъягодичной складки + + + Hips excluding protruding abdomen + Full measurement name + Обхват бедер без учета выступания живота + + + Girth foot instep + Full measurement name + Обхват подъема стопы + + + Side waist to floor + Full measurement name + Расстояние от линии талии до пола сбоку + + + Front waist to floor + Full measurement name + Расстояние от линии талии до пола спереди + + + Arc through groin area + Full measurement name + Дуга через паховую область + + + Waist to plane seat + Full measurement name + Расстояние от линии талии до плоскости сидения + + + Neck to radial point + Full measurement name + Расстояние от точки основания шеи сбоку до лучевой точки + + + Neck to third finger + Full measurement name + Расстояние от точки основания шеи сбоку до конца третьего пальца + + + Neck to first line chest circumference + Full measurement name + Расстояние от точки основания шеи сбоку до линии обхвата груди первого спереди + + + Front waist length + Full measurement name + Расстояние от точки основания шеи сбоку до линии талии спереди (длина талии спереди) + + + Arc through shoulder joint + Full measurement name + Дуга через высшую точку плечевого сустава + + + Neck to back line chest circumference + Full measurement name + Расстояние от точки основания шеи сзади до линии обхватов груди первого и второго с учетом выступа лопаток + + + Waist to neck side + Full measurement name + Расстояние от линии талии сзади до точки основания шеи сбоку + + + Arc length upper body + Full measurement name + Длина дуги верхней части туловища через точку основания шеи сбоку + + + Chest width + Full measurement name + Ширина груди + + + Anteroposterior diameter hands + Full measurement name + Передне-задний диаметр руки + + + Height clavicular point + Full measurement name + Высота ключичной точки + + + Height armhole slash + Full measurement name + Расстояние от шейной точки до уровня заднего угла подмышечной впадины спереди (высота проймы косая) + + + Slash shoulder height + Full measurement name + Высота плеча косая + + + Half girth neck + Full measurement name + Полуобхват шеи + + + Half girth neck for shirts + Full measurement name + Полуобхват шеи для сорочек + + + Half girth chest first + Full measurement name + Полуобхват груди первый + + + Half girth chest second + Full measurement name + Полуобхват груди второй + + + Half girth chest third + Full measurement name + Полуобхват груди третий + + + Half girth waist + Full measurement name + Полуобхват талии + + + Half girth hips considering protruding abdomen + Full measurement name + Полуобхват бедер с учетом выступания живота + + + Half girth hips excluding protruding abdomen + Full measurement name + Полуобхват бедер без учета выступания живота + + + Girth knee flexed feet + Full measurement name + Обхват колена в согнутом положении ноги + + + Neck transverse diameter + Full measurement name + Поперечный диаметр шеи + + + Front slash shoulder height + Full measurement name + Высота плеча косая спереди + + + Neck to front waist line + Full measurement name + Расстояние от точки основания шеи до линии талии спереди + + + Hand vertical diameter + Full measurement name + Вертикальный диаметр руки + + + Neck to knee point + Full measurement name + Расстояние от шейной точки до колена + + + Waist to knee + Full measurement name + Расстояние от линии талии до колена + + + Shoulder height + Full measurement name + Высота плеча + + + Head height + Full measurement name + Высота головы + + + Body position + Full measurement name + Положение корпуса + + + Arc behind shoulder girdle + Full measurement name + Дуга плечевого пояса сзади + + + Neck to neck base + Full measurement name + Расстояние от шейной точки до точки основания шеи сбоку по линии измерения обхвата шеи + + + Depth waist first + Full measurement name + Глубина талии первая + + + Depth waist second + Full measurement name + Глубина талии вторая + + + + MoveLabel + + Move point label + Переместить метку точки + + + + MoveSPoint + + Move single point + Переместить базовую точку + + + + MoveSpline + + Move spline + Переместить сплайн + + + + MoveSplinePath + + Move spline path + Переместить сложный сплайн + + + + PathPage + + Open Directory + Открыть директорию + + + Path that use Valentina + Путь, что использует Валентина + + + Default + По умолчанию + + + Edit + Редактировать + + + Type + Тип + + + Path + Путь + + + Individual measurements + Индивидуальные мерки + + + Patterns + Лекала + + + + PatternPage + + User + Пользователь + + + User name + Имя пользователя + + + Graphical output + Графический вывод + + + Use antialiasing + Использовать сглаживание + + + Undo + Отменить + + + Count steps (0 - no limit) + Количество шагов (0 - без ограничений) + + + Undone + Отменить + + + Count steps + Количество шагов + + + + PostfixOperators + + cm + centimeter + см + + + mm + millimeter + мм + + + in + inch + дюйм + + + + QCommandLineParser + + Displays version information. + Показать информацию о версии. + + + Displays this help. + Показать эту справку. + + + Unknown option '%1'. + Неизвестный параметр '%1'. + + + Unknown options: %1. + Неизвестные параметры: %1. + + + Missing value after '%1'. + Пропущено значение после '%1'. + + + Unexpected value after '%1'. + Неожиданое значение после '%1'. + + + [options] + [параметры] + + + Usage: %1 + Использование: %1 + + + Options: + Параметры: + + + Arguments: + Аргументы: + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + Базируется на Qt %1 (%2, %3 bit) + + + + QObject + + Create new pattern piece to start working. + Создайте новый чертеж для начала работы. + + + Add node + Добавить узел + + + Move detail + Переместить деталь + + + mm + мм + + + cm + см + + + inch + дюймы + + + in + inch abbreviation + дюйм + + + Property + The text that appears in the first column header + Свойства + + + Value + The text that appears in the second column header + Значение + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданный токен "$TOK$" найден в позиции $POS$. + + + Internal error + Math parser error messages. + Внутренняя ошибка + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Неверное имя функции, переменной или константы: "$TOK$". + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Неверный идентификатор бинарного оператора: "$TOK$". + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Неверный идентификатор инфиксного оператора: "$TOK$". + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Неверный идентификатор постфиксного оператора: "$TOK$". + + + Invalid pointer to callback function. + Math parser error messages. + Неверный указатель на функцию обратного вызова. + + + Expression is empty. + Math parser error messages. + Выражение пустое. + + + Invalid pointer to variable. + Math parser error messages. + Неверный указатель на переменную. + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданный оператор "$TOK$" найден в позиции $POS$ + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + Неожиданный конец выражения в позиции $POS$ + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + Неожиданный разделитель аргументов в позиции $POS$ + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданная скобка "$TOK$" в позиции $POS$ + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданная функция "$TOK$" в позиции $POS$ + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданное значение "$TOK$" найденое в позиции $POS$ + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Неожиданная переменная "$TOK$" найденая в позиции $POS$ + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + Аргументы функции используются без функции (позиция: $POS$) + + + Missing parenthesis + Math parser error messages. + Отсутствует скобка + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Слишком много параметров для функции "$TOK$" в выражении в позиции $POS$ + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Слишком мало параметров для функции "$TOK$" в выражении в позиции $POS$ + + + Divide by zero + Math parser error messages. + Деление на ноль + + + Domain error + Math parser error messages. + Ошибка домена + + + Name conflict + Math parser error messages. + Конфликт имени + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + Неверное значение для определения приоритетов оператора (должна быть больше или равна нулю). + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + Определенный пользователем бинарный оператор "$TOK$" конфликтует с встроенным оператором. + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + Неожиданный строковый токен находящийся в позиции $POS$. + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + Незавершенная строка, начиная с позиции $POS$. + + + String function called with a non string type of argument. + Math parser error messages. + Функция, которая принимает строковое значение, вызвана с не строковым типом аргумента. + + + String value used where a numerical argument is expected. + Math parser error messages. + Строковое значение используется там, где ожидается числовой параметр. + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Нет подходящего кандидата для перегрузки оператора "$TOK$" в позиции $POS$. + + + Function result is a string. + Math parser error messages. + Результат функции строковой. + + + Parser error. + Math parser error messages. + Ошибка синтаксического анализа. + + + Decimal separator is identic to function argument separator. + Math parser error messages. + Десятичный разделитель является идентичным разделителю аргумент функции. + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + Оператор "$TOK$" должен предшествувать закрывающей скобке + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + Для оператора If-then-else отсутствует пункт else + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + Неожиданое положение двоеточия в позиции $POS$ + + + + RenamePP + + Rename pattern piece + Переименовать лекало + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см + + + + SaveDetailOptions + + Save detail option + Сохранить параметры детали + + + + SaveToolOptions + + Save tool option + Сохранить параметры инструмента + + + + TableWindow + + Create a layout + Создать раскладку + + + toolBar + Панель инструментов + + + Save + Сохранить + + + Save layout + Создать раскладку + + + Next + Следующая + + + Next detail + Следующая деталь + + + Turn + Перевернуть + + + Turn the detail 90 degrees + Перевернуть детальна на 90 градусов + + + Turn the detail 180 degrees + Перевернуть детальна на 180 градусов + + + Stop laying + Прекратить укладку + + + Enlarge letter + Увеличить лист + + + Enlarge the length of the sheet + Увеличить длину листа + + + Enlarge the length of sheet + Увеличить длину листа + + + Reduce sheet + Уменьшить лист + + + Reduce the length of the sheet + Уменьшить длину листа + + + Mirroring + Отражение + + + Zoom In + Увеличить + + + Zoom Out + Уменьшить + + + Stop + Стоп + + + 0 details left. + 0 деталей осталось. + + + Collisions not found. + Колизии не обнаружены. + + + %1 details left. + %1 деталей осталось. + + + untitled + без имени + + + Svg files (*.svg) + Svg файлы (*.svg) + + + PDF files (*.pdf) + Pdf файлы (*.pdf) + + + Images (*.png) + Изображения (*.png) + + + PS files (*.ps) + Ps файл (*.ps) + + + EPS files (*.eps) + EPS файл (*.eps) + + + Collisions found. + Найдены колизии. + + + Creating file '%1' failed! %2 + Создание файла '%1' не удалось! %2 + + + Critical error! + Критическая ошибка! + + + SVG Generator Example Drawing + SVG Generator Example Drawing + + + An SVG drawing created by the SVG Generator Example provided with Qt. + An SVG drawing created by the SVG Generator Example provided with Qt. + + + Wavefront OBJ (*.obj) + Wavefront OBJ (*.obj) + + + + VAbstractConverter + + Error creation backup file: %1. + Ошибка создания резервного файла: %1. + + + Couldn't get version information. + Не удалось получить информацию о версии. + + + Too many tags <%1> in file. + Слишком много тегов <%1> в файле. + + + Version "%1" invalid. + Версия "%1" недействительная + + + Version "0.0.0" invalid. + Версия "0.0.0" недействительная. + + + Invalid version. Minimum supported version is %1 + Недействительная версия. Минимально поддерживаемая %1 + + + Invalid version. Maximum supported version is %1 + Недействительная версия. Максимально поддерживаемая %1 + + + Error no unique id. + Ошибка не уникальный id. + + + Could not change version. + Не удалось изменить версию. + + + + VAbstractNode + + Can't find tag Modeling + Не могу найти тег Modeling + + + + VAbstractTool + + Confirm the deletion. + Подтвердить удаление. + + + Do you really want delete? + Вы точно хотите удалить? + + + + VApplication + + Error! + Ошибка! + + + Error parsing file. Program will be terminated. + Ошибка парсинга файла. Програма будет закрыта. + + + Error bad id. Program will be terminated. + Ошибка, неправильный id. Програма будет закрыта. + + + Error can't convert value. Program will be terminated. + Ошибка не могу конвертировать значение. Програма будет закрыта. + + + Error empty parameter. Program will be terminated. + Ошибка пустой параметр. Програма будет закрыта. + + + Error wrong id. Program will be terminated. + Ошибка неправельный id. Програма будет закрыта. + + + Something's wrong!! + Что то не так!!! + + + Could not copy temp file to document file + Не удалось скопировать временный файл в выходной файл + + + Could not remove document file + Не удалось удалить файл документа. + + + Something wrong!! + Что то не так!!! + + + + VArc + + Can't find id = %1 in table. + Не могу найти id = %1 в таблице. + + + Angle of arc can't be 0 degree. + Угол дуги не может быть 0 градусов. + + + + VContainer + + Can't find object + Не могу найти объект + + + Can't cast object + Не могу привести объект + + + Can't find object. Type mismatch. + Не могу найти объект. Несоответствие типа. + + + + VDomDocument + + Can't find tool id = %1 in table. + Не могу найти инструмент с id = %1 в таблице. + + + Got wrong parameter id. Need only id > 0. + Получен неправельный параметр id. Допустимы только id > 0. + + + Can't convert toLongLong parameter + Не могу конвертировать toLongLong параметр + + + Can't convert toUInt parameter + Не могу конвертировать toUInt параметр + + + Can't convert toBool parameter + Не удается преобразовать параметр toBool + + + Got empty parameter + Получен пустой параметр + + + Can't convert toDouble parameter + Не могу конвертировать toDouble параметр + + + Can't open file %1: +%2. + Не могу открыть файл %1: +%2. + + + Can't open schema file %1: +%2. + Не могу окрыть файл схемы %1:\n%2. + + + Validation error file %3 in line %1 column %2 + Ошибка валидации файла %3 в строке %1 столбца %2 + + + Parsing error file %3 in line %1 column %2 + Ошибка разбора файла %3 в строке %1 столбца %2 + + + Couldn't get node + Не удалось получить узел. + + + Validation error in line %1 column %2 + Ошибка валидации линия %1 столбик %2 + + + Parcing error in line %1 column %2 + Ошибка разбора линия %1 столбец %2 + + + This id is not unique. + Этот id не уникальный. + + + Error creating or updating detail + Ошибка создания или обновления детали + + + Error creating or updating single point + Ошибка создания или обновления базовой точки + + + Error creating or updating point of end line + Ошибка создания или обновления точки на конце линии + + + Error creating or updating point along line + Ошибка создания или обновления точки вдоль линии + + + Error creating or updating point of shoulder + Ошибка создания или обновления точки плеча + + + Error creating or updating point of normal + Ошибка создания или обновления точки нормали + + + Error creating or updating point of bisector + Ошибка создания или обновления точки бисектрисы + + + Error creating or updating point of lineintersection + Ошибка создания или обновления точки пересичения линий + + + Error creating or updating point of contact + Ошибка создания или обновления точки прикосновения + + + Error creating or updating modeling point + Ошибка создания или обновления точки + + + Error creating or updating height + Ошибка создания или обновления высоты + + + Error creating or updating triangle + Ошибка создания или обновления треугольника + + + Error creating or updating point of intersection + Ошибка создания или обновления точки пересичения + + + Error creating or updating cut spline point + Ошибка создания или обновления точки разрезания сплайна + + + Error creating or updating cut spline path point + Ошибка создания или обновления точки разрезания сложного сплайна + + + Error creating or updating cut arc point + Ошибка создания или обновления точки разрезания дуги + + + Error creating or updating line + Ошибка создания или обновления линии + + + Error creating or updating simple curve + Ошибка создания или обновления кривой + + + Error creating or updating curve path + Ошибка создания или обновления сложной кривой + + + Error creating or updating modeling simple curve + Ошибка создания или обновления модельной кривой + + + Error creating or updating modeling curve path + Ошибка создания или обновления сложной модельной кривой + + + Error creating or updating simple arc + Ошибка создания или обновления дуги + + + Error creating or updating modeling arc + Ошибка создания или обновления модельной дуги + + + Error creating or updating union details + Ошибка создания или обновления объединения деталей + + + Error! + Ошибка! + + + Error parsing file. + Ошибка парсинга файла. + + + Could not load schema file. + Неудалось открыть файл схемы. + + + Could not copy temp file to document file + Не удалось скопировать временный файл в выходной файл + + + Could not remove document file + Не удалось удалить файл документа + + + + VDrawTool + + Options + Параметры + + + Delete + Удалить + + + Can not find the element after which you want to insert. + Не могу найти елемент после которого вы хочете вставить. + + + Can't find tag Calculation + Не могу найти тег Calculation + + + Edit wrong formula + Редактировать неправильную формулу + + + + VException + + Critical error! + Критическая ошибка! + + + + VFormula + + Error + Ошибка + + + + VFormulaProperty + + Value + Значение + + + Formula + Формула + + + + VFormulaPropertyEditor + + ... + ... + + + + VModelingTool + + Options + Параметры + + + Delete + Удалить + + + + VPE::VBoolProperty + + True + Верно + + + False + Неверно + + + + VPE::VColorPropertyEditor + + ... + ... + + + + VPE::VFileEditWidget + + ... + ... + + + Directory + Директория + + + Open File + Открыть файл + + + + VPattern + + Can't find tool id = %1 in table. + Не могу найти инструмент с id = %1 в таблице. + + + Error no unique id. + Ошибка не уникальный id. + + + Error! + Ошибка! + + + Can't find tool in table. + Не могу найти инструмент в таблице. + + + Error parsing file. + Ошибка парсинга файла. + + + Error can't convert value. + Ошибка, не могу конвертовать значение. + + + Error empty parameter. + Помилка, пустий параметр. + + + Error wrong id. + Ошибка, неправильный id. + + + Critical error! + Критическая ошибка! + + + Error parsing file (std::bad_alloc). + Ошибка парсинга файла (std::bad_alloc). + + + Error creating or updating detail + Ошибка создания или обновления детали + + + Error creating or updating single point + Ошибка создания или обновления базовой точки + + + Error creating or updating point of end line + Ошибка создания или обновления точки на конце линии + + + Error creating or updating point along line + Ошибка создания или обновления точки вдоль линии + + + Error creating or updating point of shoulder + Ошибка создания или обновления точки плеча + + + Error creating or updating point of normal + Ошибка создания или обновления точки нормали + + + Error creating or updating point of bisector + Ошибка создания или обновления точки бисектрисы + + + Error creating or updating point of lineintersection + Ошибка создания или обновления точки пересичения линий + + + Error creating or updating point of contact + Ошибка создания или обновления точки прикосновения + + + Error creating or updating modeling point + Ошибка создания или обновления точки + + + Error creating or updating height + Ошибка создания или обновления высоты + + + Error creating or updating triangle + Ошибка создания или обновления треугольника + + + Error creating or updating point of intersection + Ошибка создания или обновления точки пересичения + + + Error creating or updating cut spline point + Ошибка создания или обновления точки разрезания сплайна + + + Error creating or updating cut spline path point + Ошибка создания или обновления точки разрезания сложного сплайна + + + Error creating or updating cut arc point + Ошибка создания или обновления точки разрезания дуги + + + Error creating or updating point of intersection line and axis + Ошибка создания или обновления точки пересечения линии и оси + + + Error creating or updating point of intersection curve and axis + Ошибка создания или обновления точки пересечения кривой и оси + + + Error creating or updating line + Ошибка создания или обновления линии + + + Error creating or updating simple curve + Ошибка создания или обновления кривой + + + Error creating or updating curve path + Ошибка создания или обновления сложной кривой + + + Error creating or updating modeling simple curve + Ошибка создания или обновления модельной кривой + + + Error creating or updating modeling curve path + Ошибка создания или обновления сложной модельной кривой + + + Error creating or updating simple arc + Ошибка создания или обновления дуги + + + Error creating or updating modeling arc + Ошибка создания или обновления модельной дуги + + + Error creating or updating union details + Ошибка создания или обновления объединения деталей + + + Got wrong parameter id. Need only id > 0. + Получен неправельный параметр id. Допустимы только id > 0. + + + This id is not unique. + Этот id не уникальный. + + + File error. + Ошибка файла. + + + + VPatternConverter + + Unexpected version "%1". + Неожиданная версия "%1". + + + Error restoring backup file: %1. + Ошибка востановления с резервного файла: %1. + + + + VSplinePath + + Not enough points to create the spline. + Не достаточно точок для создания кривой. + + + This spline does not exist. + Этот сплайн не сувществует. + + + Can't cut spline path with one point + Не могу разреть сплайн из одной точки + + + + VTableGraphicsView + + can't find detail + не могу найти деталь + + + detail found + деталь найдена + + + + VToolDetail + + Options + Параметры + + + Delete + Удалить + + + + VToolOptionsPropertyBrowser + + Base point + Базовая точка + + + Point label + Имя точки + + + Position + Положение + + + Point at distance and angle + Инструмент точка на конце отрезка + + + Line type + Тип линии + + + Length + Длина + + + Angle + Угол + + + Point at distance along line + Инструмент точка вдоль линии + + + Arc + Дуга + + + Radius + Радиус + + + First angle + Первый угол + + + Second angle + Второй угол + + + Point along bisector + Инструмент точка бисектрисы + + + Cut arc tool + Инструмент разрезания дуги + + + Tool for segmenting a curve + Инструмент для сегментации кривой + + + Tool segment a pathed curve + Инструмент для сегментации сложной кривой + + + Perpendicular point along line + Перпендикулярная точка вдоль линии + + + Line between points + Линия между точками + + + Point at line intersection + Точка пересичения линий + + + Point along perpendicular + Инструмент точка перпендикуляра + + + Additional angle degrees + Доп. угол градусы + + + Point at intersection of arc and line + Точка на пересечении дуги и линии + + + Tool to make point from x & y of two other points + Инструмент, чтобы сделать точку от х и у двух других точек + + + Special point on shoulder + Специальная точка на плечо + + + Curve tool + Инструмент кривая + + + Curve factor + Коэффициент кривой + + + Tool for path curve + Инструмент для создания сложной кривой + + + Tool triangle + Инструмент треугольник + + + Point intersection line and axis + Точка пересечения линии и оси + + + + VToolTriangle + + Can't find point. + Не могу найти точку. + + + + VToolUnionDetails + + Can't find tag Modeling + Не могу найти тег Modeling + + + + Variables + + Line_ + Left symbol _ in name + Линия_ + + + AngleLine_ + Left symbol _ in name + УголЛинии_ + + + Arc_ + Left symbol _ in name + Дуга_ + + + Spl_ + Left symbol _ in name + Спл_ + + + SplPath + Do not add symbol _ to the end of name + СлСпл + + + SplPath + Do not add symbol _ to enf of name + СлСпл + + + SplPath + СлСпл + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>пересечение кривой и дуги</b>: угол = %1°; <b>Shift</b> - фиксация угола, <b>Enter</b> - завершение создания + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>Точка на конце отрезка</b>: угол = %1°; <b>Shift</b> - фиксация угла, <b>Enter</b> - завершение создания + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>Пересечение линии и оси</b>: угол = %1°; <b>Shift</b> - "фиксация угола, <b>Enter</b> - завершение создания + + + + VisToolSplinePath + + <b>Curve path</b>: <b>Enter</b> - finish creation + <b>Сложная кривая</b>: <b>Enter</b> - завершение создания + + + <b>Curved path</b>: select three or more points + <b>Сложная кривая</b>: выберите три или больше точек + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + <b>Сложная кривая</b>: выберите три или больше точек, <b>Enter</b> - завершение создания + + + + main + + Pattern making program. + Программа создания выкроек. + + + Pattern file. + Файл лекала. + + + diff --git a/share/translations/valentina_uk.ts b/share/translations/valentina_uk.ts deleted file mode 100644 index c0f158af8..000000000 --- a/share/translations/valentina_uk.ts +++ /dev/null @@ -1,2546 +0,0 @@ - - - - - DialogAlongLine - - - Point along line - Точка вздовж лінії - - - - Length - Довжина - - - - Formula calculation of length of line - Формула розрахунку довжини лінії - - - - Calculate formula - Розрахувати формулу - - - - - ... - - - - - Value of length - Значення довжини - - - - _ - - - - - Name new point - Ім'я нової точки - - - - Put variable into formula - Вставити змінну в формулу - - - - First point - Перша точка - - - - First point of line - Перша точка лінії - - - - Second point - Друга точка - - - - Second point of line - Друга точка лінії - - - - Type line - Тип лінії - - - - Show line from first point to our point - Показати лінію від першої точки до нашої точки - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжина ліній - - - - Length of arcs - Довжина дуг - - - - Length of curves - Довжина кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - Select second point of line - Виберіть другу точку лінії - - - - DialogArc - - - Arc - Дуга - - - - Radius - Радіус - - - - Formula calculation of radius of arc - Формула калькуляції радіуса дуги - - - - - - Put variable into formula - Вставити змінну в формулу - - - - - - - - - ... - - - - - - - Calculate formula - Розрахувати формулу - - - - Value of radius - Значення радіусу - - - - - - _ - - - - - First angle degree - Перший кут градуси - - - - First angle of arc counterclockwise - Перший кут дуги проти годинникової стрілки - - - - Value of first angle - Значення першого кута - - - - Second angle degree - Другий кут градуси - - - - Second angle of arc counterclockwise - Другий кут дуги проти годинникової стрілки - - - - Value of second angle - Значення другого кута - - - - Center point - Точка центру - - - - Select point of center of arc - Виберіть точку центра дуги - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжина ліній - - - - Length of arcs - Довжина дуг - - - - Length of curves - Довжина кривих - - - - Angle of lines - Кут ліній - - - - Variables - Змінні - - - - Value angle of line. - Значення дуги лінії. - - - - DialogBisector - - - Bisector - Бісектриса - - - - Length - Довжина - - - - Formula calculation of length of bisector - Формула калькуляції довжини бісектриси - - - - Calculate formula - Розрахувати формулу - - - - - ... - - - - - Value of length - Значення довжини - - - - _ - - - - - Name new point - Ім'я нової точки - - - - Put variable into formula - Вставити змінну в формулу - - - - First point - Перша точка - - - - First point of angle - Перша точка кута - - - - Second point - Друга точка - - - - Second point of angle - Друга точка кута - - - - Third point - Третя точка - - - - Third point of angle - Третя точка кута - - - - Type line - Тип лінії - - - - Show line from second point to our point - Показати лінію з другої точки кута до нашої точки - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжина ліній - - - - Length of arcs - Довжина дуг - - - - Length of curves - Довжина кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - Select second point of angle - Виберіть другу точку кута - - - - Select third point of angle - Виберіть третю точку кута - - - - DialogDetail - - - Detail - Деталь - - - - Bias X - Зміщення по Х - - - - Bias Y - Зміщення по Y - - - - Option - Параметри - - - - Name of detail - Ім'я деталі - - - - Supplement for seams - Прибавка на шви - - - - Width - Ширина - - - Name detail - Ім'я деталі - - - - Closed - Замкнена - - - - Get wrong scene object. Ignore. - Отримано непаравильний об'єкт сцени. Ігноровано. - - - - Get wrong tools. Ignore. - Отримано неправильний інструмент. Ігноровано. - - - - DialogEndLine - - - Point in the end of line - Точка на кінці відрізку - - - - Length - Довжина - - - - Formula calculation of length of line - Формула розрахунку довжини лінії - - - - Calculate formula - Розрахувати формулу - - - - - - - - - - - - - ... - - - - - Value of length - Значення довжини - - - - _ - - - - - Base point - Базова точка - - - - First point of line - Перша точка лінії - - - - Name new point - Ім'я нової точки - - - - Angle degree - Кут градуси - - - - Angle of line - Кут лінії - - - - Type line - Тип лінії - - - - Show line from first point to our point - Показати лінію від першої точки до нашої точки - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжина ліній - - - - Length of arcs - Довжина дуг - - - - Length of curves - Довжина кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - DialogHeight - - - Dialog - Діалог - - - - Name new point - Ім'я нової точки - - - - Base point - Базова точка - - - - - - - First point of line - Перша точка лінії - - - - Second point of line - Друга точка лінії - - - - Type line - Тип лінії - - - - Show line from first point to our point - Показати лінію від першої точки до нашої точки - - - - Select first point of line - Виберість першу точку лінії - - - - Select second point of line - Виберіть другу точку лінії - - - - DialogHistory - - - History - Історія - - - - - Tool - Інструмент - - - - %1 - Base point - %1 - Базова точка - - - - - %1_%2 - Line from point %1 to point %2 - %1_%2 - Лінія від точки %1 до точки %2 - - - - %3 - Point along line %1_%2 - %3 - Точка вздовж лінії %1_%2 - - - - %1 - Point of soulder - %1 - Точка плеча - - - - %3 - Normal to line %1_%2 - %3 - Перпедикуляр до лінії %1_%2 - - - - %4 - Bisector of angle %1_%2_%3 - %4 - Бісектриса кута %1_%2_%3 - - - - %5 - Point of intersection lines %1_%2 and %3_%4 - %5 - Точка перетину лінії %1_%2 і %3_%4 - - - - Curve %1_%2 - Крива %1_%2 - - - - Arc with center in point %1 - Дуга з центром в точці %1 - - - - Curve point %1 - Точка кривої %1 - - - - %4 - Point of contact arc with center in point %1 and line %2_%3 - %4 - Точка дотику дуги з центром в точці %1 і лінії %2_%3 - - - - Point of perpendical from point %1 to line %2_%3 - Точка перпендикуляра з точки %1 до лінії %2_%3 - - - - Triangle: axis %1_%2, points %3 and %4 - Трикутник: вісь %1_%2, точки %3 і %4 - - - - Get wrong tool type. Ignore. - Отримано неправильний тип інструменту. Ігноруємо. - - - - DialogIncrements - - - - Increments - Прибавки - - - - Table sizes - Таблиця розмірів - - - - - - - Denotation - Позначення - - - - - The calculated value - Розраховане значення - - - - - - - Base value - Базове значення - - - - In sizes - В розмірах - - - - In growths - В ростах - - - - - - - - - Description - Опис - - - - - - In size - В розмірах - - - - - - In growth - В ростах - - - - - ... - - - - - Lines - Лінії - - - - - Line - Лінія - - - - Length of the line - Довжина лінії - - - - Curves - Криві - - - - - Curve - Крива - - - - Length of the curve - Довжина кривої - - - - Arcs - Дуги - - - - - Arc - Дуга - - - - Length of arc - Довжина дуги - - - - Denotation %1 - Позначення %1 - - - - Can't convert toDouble value. - Не можу конвертувати toDouble значення. - - - - - Calculated value - Розраховане значення - - - - - - Length - Довжина - - - - DialogLine - - - Line - Лінія - - - - First point - Перша точка - - - - Second point - Друга точка - - - - Select second point - Виберіть другу точку - - - - DialogLineIntersect - - - Point of line intersection - Точка перетину ліній - - - - Name new point - Ім'я нової точки - - - - First line - Перша лінія - - - - - First point - Перша точка - - - - - Second point - Друга точка - - - - Second line - Друга лінія - - - - Select second point of first line - Виберіть другу точка першої лінії - - - - Select first point of second line - Виберіть першу точку другої лінії - - - - Select second point of second line - Виберіть другу точку другої лінії - - - - DialogNormal - - - Normal - Перпендикуляр - - - - Length - Довжина - - - - Formula calculation of length of normal - Формула розрахунку довжини перпендикуляра - - - - Calculate formula - Розрахувати формулу - - - - - - - - - - - - - ... - - - - - Value of length - Значення довжини - - - - _ - - - - - Name new point - Ім'я нової точки - - - - Put variable into formula - Вставити змінну в формулу - - - - First point - Перша точка - - - - Second point - Друга точка - - - - Additional angle degrees - Додатковий кут градуси - - - - Type line - Тип лінії - - - - Show line from first point to our point - Показати лінію від першої точки до нашої точки - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжини ліній - - - - Length of arcs - Довжини дуг - - - - Length of curves - Довжини кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - Select second point of line - Виберіть другу точку лінії - - - - DialogPointOfContact - - - Point of contact - Точка дотику - - - - Radius - Радіус - - - - Formula calculation of radius of arc - Формула розрахунку радіуса дуги - - - - Calculate formula - Розрахувати формулу - - - - - ... - - - - - Value of radius - Значення радіусу - - - - _ - - - - - Name new point - Ім'я нової точки - - - - Put variable into formula - Вставити змінну в формулу - - - - Center of arc - Центер дуги - - - - Slect point of center of arc - Виберіть точку центру дуги - - - - Top of the line - Початок лінії - - - - End of the line - Кінець лінії - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - Length of lines - Довжини ліній - - - - Length of arcs - Довжини дуг - - - - Length of curves - Довжини кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - Select second point of line - Виберіть другу точку лінії - - - - Select point of center of arc - Виберіть точку центру дуги - - - - DialogPointOfIntersection - - - Dialog - Діалог - - - - Name new point - Ім'я нової точки - - - - Point vertically - Точка по вертикалі - - - - First point of angle - Перша точка кута - - - - Point horizontally - Точка по горизонталі - - - - Second point of angle - Друга точка кута - - - - Select point horizontally - Виберіть точку горизонталі - - - - DialogShoulderPoint - - - - Point of shoulder - Точка плеча - - - - Length - Довжина - - - - Formula calculation of length of line - Формула розрахунку довжини лінії - - - - Calculate formula - Розрахувати формулу - - - - - ... - - - - - Value of length - Значення довжини - - - - _ - - - - - Name new point - Ім'я нової точки - - - - Put variable into formula - Вставити змінну в формулу - - - - First point - Перша точка - - - - Second point - Друга точка - - - - Type of line - Тип лінії - - - - Show line from first point to our point - Показати лінію від першої точки до нашої точки - - - - Input data - Вхідні данні - - - - Size and growth - Розмір і зріст - - - - Standart table - Стандартна таблиця - - - - Increments - Прибавки - - - - - Length of lines - Довжини лінії - - - - Length of curves - Довжни кривих - - - - Variables. Click twice to select. - Змінні. Подвійний клік для вибору. - - - - Select second point of line - Виберіть другу точку лінії - - - - Select point of shoulder - Виберіть точку плеча - - - - DialogSinglePoint - - - Single point - Точка - - - Координати - Координати - - - - Coordinates on the sheet - Координати на листі - - - - Coordinates - Координати - - - - Y coordinate - Y координата - - - - X coordinate - Х координата - - - - Point name - Ім'я точки - - - - DialogSpline - - - Curve - Крива - - - - First point - Перша точка - - - - Length ratio of the first control point - Коефіцієнт довжини першої контрольної точки - - - - The angle of the first control point - Кут першої контрольної точки - - - - Second point - Друга точка - - - - Length ratio of the second control point - Коефіцієнт довжини другої контрольної точки - - - - The angle of the second control point - Кут другої контрольної точки - - - - Coefficient of curvature of the curve - Коефіцієнт кривизни кривої - - - - Select last point of curve - Виберість останню точку кривої - - - - DialogSplinePath - - - Curve path - Складна крива - - - - Point of curve - Точка кривої - - - - Length ratio of the first control point - Коефіцієнт довжини першої контрольної точки - - - - The angle of the first control point - Кут першої контрольної точки - - - - Length ratio of the second control point - Коефіцієнт довжини другої контрольної точки - - - - The angle of the second control point - Кут другої контрольної точки - - - - List of points - Список точок - - - - Coefficient of curvature of the curve - Коефіцієнт кривизни кривої - - - - Select point of curve path - Виберіть точку складної кривої - - - - DialogTool - - - Wrong details id. - Неправильний id деталі. - - - - - - Line - Лінія - - - - - No line - Без лінії - - - - Can't find point by name - Не можу знайти точку за ім'ям - - - - Error - Помилка - - - - Growth - Зріст - - - - Size - Розмір - - - - Line length - Довжина лінії - - - - Arc length - Довжина дуги - - - - Curve length - Довжина кривої - - - - DialogTriangle - - - Dialog - Діалог - - - - Name new point - Ім'я нової точки - - - - First point of axis - Перша точка вісі - - - - - - - First point of line - Перша точка лінії - - - - Second point of axis - Друга точка вісі - - - - First point - Перша точка - - - - Second point - Друга точка - - - - Select second point of axis - Виберіть другу точку вісі - - - - Select first point - Виберість першу точку - - - - Select second point - Виберіть другу точку - - - - MainWindow - - - Valentina - Valentina - - - - Tools for creating points. - Інструмент створення точок. - - - - Point - Точка - - - - Tool point of normal. - Інструмент точка перпендикуляра. - - - - - - - - - - - - - - - - - - ... - - - - - Tool point of shoulder. - Інструмент точка плеча. - - - - Tool point on the end line. - Інструмент точка на кінці лінії. - - - - Tool point along line. - Інструмент точка вздовж лінії. - - - - Tool point of bisector. - Інструмент точка бісектриси кута. - - - - Tool point of contact. - Інструмент точка дотику. - - - - Tool point of height. - Інструмент точка висоти. - - - - Tool triangle. - Інструмент трикутник. - - - - Tools for creating lines. - Інструменти для створення ліній. - - - - Line - Лінія - - - - Tool line. - Інструмент лінія. - - - - Tool point of line intersection. - Інструмент точка перетину ліній. - - - - Tools for creating curves. - Інструменти для створення кривих. - - - - Curve - Крива - - - - Tool curve. - Інструмент крива. - - - - Tool path curve. - Інструмент складна крива. - - - - Tools for creating arcs. - Інструменти для створення дуг. - - - - Arc - Дуга - - - - Tool arc. - Інструмент дуга. - - - - Tools for creating details. - Інструменти для створення деталей. - - - - Detail - Деталь - - - - Tool new detail. - Інструмент нова деталь. - - - - File - Файл - - - - Help - Допомога - - - - Drawing - Креслення - - - - toolBar - - - - - toolBar_2 - - - - - toolBar_3 - - - - - New - Новий - - - - Create a new pattern - Створити нове лекало - - - - Open - Відкрити - - - - Open file with pattern - Відкрити файл з лекалами - - - - Save - Зберегти - - - - Save pattern - Зберегти лекало - - - - - Save as - Зберегти як - - - - Save not yet saved pattern - Зберегти ще не збережене лекало - - - - Draw - Малювання - - - - Draw mode - Режим малювання - - - - Details - Деталь - - - - Deatils mode - Режим деталей - - - - - Tools pointer - Інструмент вказівник - - - - New drawing - Нове креслення - - - - Add new drawing - Додати нове креслення - - - - - Change the name of drawing - Змінити ім'я креслення - - - - Table of variables - Таблиця змінних - - - - Tables of variables - Таблиці змінних - - - - History - Історія - - - - Layout - Розкладки - - - - Create layout - Створити розкладку - - - - - About Qt - Про Qt - - - - - About Valentina - Про Valentina - - - - Exit - Вихід - - - - Drawing %1 - Креслення %1 - - - - - Drawing: - Креслення: - - - - Enter a name for the drawing. - Введіть ім'я креслення. - - - - - Error. Drawing of same name already exists. - Помилка. Креслення з таким ім'ям вже існує. - - - - Error creating drawing with the name - Помилка створення креслення з ім'ям - - - - Enter a new name for the drawing. - Введіть нове ім'я креслення. - - - - Error saving change!!! - Помилка збереження змін!!! - - - - Can't save new name of drawing - Не можу зберегти нове ім'я креслення - - - - - Select point - Виберість точку - - - - Select first point - Виберість першу точку - - - - - - Select first point of line - Виберість першу точку лінії - - - - Select first point of angle - Виберіть першу точку кута - - - - Select first point of first line - Виберіть першу точку першої лінії - - - - Select first point curve - Виберіть першу точку кривої - - - - Select point of center of arc - Виберіть точку центру дуги - - - - Select point of curve path - Виберіть точку складної кривої - - - Select points, arcs, curves and details clockwise. - Виберіть точки, дуги, криві і д - - - Valentina v.0.1.0 - Valentina v.0.1.0 - - - - The pattern has been modified. - Лекало було зміненно. - - - - Do you want to save your changes? - Ви хочете зберегти зміни? - - - - Growth: - Зріст: - - - - Size: - Розмір: - - - - Drawing: - Креслення: - - - - Lekalo files (*.xml);;All files (*.*) - Файли лекала (*.xml);;Всі файли (*.*) - - - - - Lekalo files (*.xml) - Файл лекала (*.xml) - - - - Error saving file. Can't save file. - Помилка збереження файлу. Не можу зберегти файл. - - - - Open file - Відкрити файл - - - - Got empty file name. - Отримано пусте імя файлу. - - - - Could not copy temp file to pattern file - Не можу копіювати тимчасовий файл до файлу лекала - - - - Could not remove pattern file - Не можу видалити файл лекала - - - - Can't open pattern file. File name empty - Не можу відкрити файл лекала. Пусте ім'я файлу - - - - - - - - - - - Error! - Помилка! - - - - Create new drawing for start working. - Створіть нове креслення для початку роботи. - - - - Select points, arcs, curves clockwise. - Виберіть точки, дуги, криві загодинниковою стрілкою. - - - - Select base point - Виберіть базову точку - - - - Select first point of axis - Виберіть першу точку вісі - - - - Select point vertically - Виберіть точку по вертикалі - - - - Based on Qt %2 (32 bit) - Базується на Qt %2 (32 bit) - - - - Built on %3 at %4 - Зібрано %3 в %4 - - - - <h1>%1</h1> %2 <br/><br/> %3 <br/><br/> %4 - - - - - Error parsing file. - Помилка парсингу файла. - - - - Error can't convert value. - Помилка, не можу конвертувати значення. - - - - Error empty parameter. - Помилка, пустий параметр. - - - - Error wrong id. - Помикла, неправильний id. - - - - - Error don't unique id. - Помилка, не унікальний id. - - - - Error parsing pattern file. - Помилка парсінгу файлу лекала. - - - - Error in line %1 column %2 - Помилка в лінії %1 стовпчик %2 - - - - TableWindow - - - Create a layout - Створити розкладку - - - - toolBar - - - - - Save - Зберегти - - - - - Save layout - Зберегти розкладку - - - - Next - Наступний - - - - Next detail - Наступна деталь - - - - Turn - Повернути - - - - Turn the detail 180 degrees - Повернути деталь на 180 градусів - - - - Stop laying - Припинити укладання - - - - Enlarge letter - Збільшити аркуш - - - - Enlarge the length of sheet - Збільшити довжину аркушу - - - - Reduce sheet - Зменшити аркуш - - - - Reduce the length of the sheet - Зменшити довжину аркушу - - - - - Mirroring - Дзеркальне відображення - - - - - Zoom In - Збільшити - - - - - Zoom Out - Зменшити - - - - Stop - Зупинити - - - - SVG Generator Example Drawing - - - - - An SVG drawing created by the SVG Generator Example provided with Qt. - - - - - VAbstractNode - - - Can't find tag Modeling - Не можу знайти тег Modeling - - - - VApplication - - - - - - - - Error! - Помилка! - - - - Error parsing file. Program will be terminated. - Помилка парсінгу файла. Програма буде закрита. - - - - Error bad id. Program will be terminated. - Помилка неправильний id. Програма буде закрита. - - - - Error can't convert value. Program will be terminated. - Помилка конвертації значення. Програма буде закрита. - - - - Error empty parameter. Program will be terminated. - Помилка пустий параметр. Програма буде закрита. - - - - Error wrong id. Program will be terminated. - Помилка неправильний id. Програма буде закрита. - - - - Something wrong!! - Щось не так!! - - - - VArc - - - Can't find id = %1 in table. - Не можу знайти id = %1 в таблиці. - - - - Angle of arc can't be 0 degree. - Кут дуги не може бути 0 градусів. - - - - Arc have not this number of part. - Дуга не має цієї частини. - - - - VContainer - - - Can't find object - Не можу знайти об'єкт - - - - VDomDocument - - - Got wrong parameter id. Need only id > 0. - Отримано неправильний id. Допускаються тільки id > 0. - - - - Can't convert toLongLong parameter - Не можу конвертувати toLongLong параметру - - - - Got empty parameter - Отримано пустий параметр - - - - Can't convert toDouble parameter - Не можу конвертувати toDouble параметру - - - - This id is not unique. - Цей id не унікальний. - - - - Error creating or updating detail - Помилка створення чи оновлення деталі - - - - Error creating or updating single point - Помилка створення чи оновлення простої точки - - - - Error creating or updating point of end line - Помилка створення чи оновлення точки кінця відрізку - - - - Error creating or updating point along line - Помилка створення чи оновлення точки вздовж лінії - - - - Error creating or updating point of shoulder - Помилка створення чи оновлення точки плеча - - - - Error creating or updating point of normal - Помилка створення чи оновлення точки нормалі - - - - Error creating or updating point of bisector - Помилка створення чи оновлення точки бісектриси - - - - Error creating or updating point of lineintersection - Помилка створення чи оновлення точки перетину ліній - - - - Error creating or updating point of contact - Помилка створення чи оновлення точки дотику - - - - Error creating or updating modeling point - Помилка створення чи оновлення модельної точки - - - - Error creating or updating height - Помилка створення чи оновлення висоти - - - - Error creating or updating triangle - Помилка створення чи оновлення трикутника - - - - Error creating or updating point of intersection - Помилка створення чи оновлення точки перетину - - - - Error creating or updating line - Помилка створення чи оновлення лінії - - - - Error creating or updating simple curve - Помилка створення чи оновлення кривої - - - - Error creating or updating curve path - Помилка створення чи оновлення шляху кривих - - - - Error creating or updating modeling simple curve - Помилка створення чи оновлення модельної кривої - - - - Error creating or updating modeling curve path - Помилка створення чи оновлення модельного шляху кривих - - - - Error creating or updating simple arc - Помилка створення чи оновлення дуги - - - - Error creating or updating modeling arc - Помилка створення чи оновлення модельної дуги - - - - Error! - Помилка! - - - - Error parsing file. - Помилка парсингу файла. - - - Can't get parent for object id = %1 - Не можу отримати батька для об'єкту id = %1 - - - - VDrawTool - - - Options - Параметри - - - - Delete - Видалити - - - - Can not find the element after which you want to insert. - Не можу знайти елемент після якого ви хочете вставити. - - - - Can't find tag Calculation - Не можу знайти тег Calculation - - - - VModelingTool - - - Option - Параметри - - - - Delete - Видалити - - - - VSplinePath - - - Not enough points to create the spline. - Не достатньо точок для створення кривої. - - - - - - This spline is not exist. - Такий сплайн не існує. - - - - VTableGraphicsView - - - detail don't find - деталь не знайдено - - - - detail find - деталь знайдено - - - - VToolDetail - - - Options - Параметри - - - - Delete - Видалити - - - - VToolTriangle - - - Can't find point. - Не можу знайти точку. - - - diff --git a/share/translations/valentina_uk_UA.ts b/share/translations/valentina_uk_UA.ts new file mode 100644 index 000000000..c031dcfec --- /dev/null +++ b/share/translations/valentina_uk_UA.ts @@ -0,0 +1,7108 @@ + + + + + AddDet + + Add detail + Додати деталь + + + + AddPatternPiece + + Add pattern piece %1 + Додати лекало %1 + + + + AddToCalc + + Add object + Додати обєкт + + + + AddUnionDetails + + Add union details + Додати обєднання деталей + + + + CommunityPage + + Server + Сервер + + + Server name/IP + Імя / IP сервера + + + Secure connection + Безпечне підключення + + + Proxy settings + Налаштування проксі-сервера + + + Use Proxy + Використовувати проксі + + + Proxy address + Адресса проксі + + + Proxy port + Порт проксі-сервера + + + Proxy user + Користувач Proxy + + + Proxy pass + Пароль проксі-сервера + + + User settings + Користувацькі налаштування + + + User Name + Імя користувача + + + Save password + Зберегти пароль + + + Password + Пароль + + + + ConfigDialog + + Apply + Застосовувати + + + &Cancel + &Відмінити + + + &Ok + &Ок + + + Config Dialog + Діалог налаштувань + + + Configuration + Налаштування + + + Pattern + Лекало + + + Community + Спільнота + + + Paths + Шляхи + + + + ConfigurationPage + + Setup user interface language updated and will be used the next time start + Налаштування мови інтерфейсу користувача оновлені і будуть застосовані наступного запуску + + + Default unit updated and will be used the next pattern creation + Одиниці виміру оновленні і будуть використані при наступному створенні лекала + + + Save + Зберегти + + + Auto-save modified pattern + Авто збереження модифіковане лекало + + + Interval: + Інтервал: + + + min + хв + + + Language + Мова + + + GUI language + Мова інтерфейсу + + + Decimal separator parts + Розділювач десяткової частини + + + With OS options (%1) + З параметрами ОС (%1) + + + Default unit + Одиниця виміру по замовчуванню + + + Centimeters + Сантиметри + + + Millimiters + Міліметри + + + Inches + Дюйми + + + Label language + Мова назви точки + + + Send crash reports + Надсилати звіти про помилки + + + Send crash reports (recommended) + Надсилати звіти про помилки (рекомендується) + + + After each crash Valentina collect information that may help us fix a problem. We do not collect any personal information. Find more about what <a href="https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports">kind of information</a> we collect. + Після кожного падіння Valentina збирає інформацію яка може допомогти нам у виправленні помилки. Ми не збираємо персональну інформацію користувачів. Дізнатися більше про <a href=https://bitbucket.org/dismine/valentina/wiki/manual/Crash_reports>информацію</a> яку ми збираємо. + + + With OS options (.) + З параметрів ОС (.) + + + + DelTool + + Delete tool + Видалити деталь + + + + DeleteDetail + + Delete tool + Видалити інструмент + + + + DeletePatternPiece + + Delete pattern piece %1 + Видалити лекало %1 + + + + DialogAboutApp + + About Valentina + Про Valentina + + + Valentina version + Версія Valentina + + + Contributors + Автори + + + Based on Qt %2 (32 bit) + Базується на Qt %2 (32 bit) + + + Built on %3 at %4 + Зібрано %3 в %4 + + + Web site : %1 + Веб сайт : %1 + + + Warning + Попердження + + + Cannot open your default browser + Не можу відкрити браузер по замовчуванню + + + Build revision: + Ревізія: + + + + DialogAlongLine + + Point along line + Точка вздовж лінії + + + Length + Довжина + + + Value of length + Значення довжини + + + Formula for the calculation of length of line + Формула для розрахунку довжини лінії + + + Calculate value + Розрахунок довжини + + + Point label + Ім'я точки + + + Insert variable into the formula + Вставте значення в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + First point + Перша точка + + + First point of line + Перша точка лінії + + + Second point + Друга точка + + + Second point of line + Друга точка лінії + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Angle of lines + Кути ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + Input data + Вхідні данні + + + Size and growth + Розмір і зріст + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Select second point of line + Виберіть другу точку лінії + + + + DialogArc + + Arc + Дуга + + + Radius + Радіус + + + Formula for the calculation of radius of arc + Формула для розрахунку радіуса дуги + + + Insert variable into the formula + Вставте змінну в формулу + + + Calculate value + Розрахувати значення + + + Value of radius + Значення радіусу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + First angle degree + Перший кут градуси + + + First angle of arc counterclockwise + Перший кут дуги проти годинникової стрілки + + + Insert variable into formula + Вставте значення в формулу + + + Value of first angle + Значення першого кута + + + Second angle degree + Другий кут градуси + + + Second angle of arc counterclockwise + Другий кут дуги проти годинникової стрілки + + + Insert marked variable into formula + Вставити позначену змінну у формулу + + + Value of second angle + Значення другого кута + + + Center point + Точка центру + + + Select point of center of arc + Виберіть точку центра дуги + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Size and growth + Розмір і зріст + + + First angle + Перший кут + + + Second angle + Другий кут + + + Standard table + Стандартна таблиця + + + Measurements + Мірки + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables + Змінні + + + Value of angle of line. + Значення кута лінії. + + + Error + Помилка + + + Radius can't be negative + Радіус не може мати від'ємне значення + + + Angles equal + Кути однакові + + + + DialogBisector + + Bisector + Бісектриса + + + Length + Довжина + + + Value of length + Значення довжини + + + Calculation of length of bisector by using the formula + Розрахувати довжину бісектриси використовуючи формулу + + + Insert marked variable into the formula + Вставити позначену змінну у формулу + + + Calculate value + Розрахувати значення + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Point label + Ім'я точки + + + First point + Перша точка + + + First point of angle + Перша точка кута + + + Second point + Друга точка + + + Second point of angle + Друга точка кута + + + Third point + Третя точка + + + Third point of angle + Третя точка кута + + + Type of line + Тип лінії + + + Show line from second point to this point + Показати лінію від першої точки до даної + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + Input data + Вхідні данні + + + Size and growth + Розмір і зріст + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Select second point of angle + Виберіть другу точку кута + + + Select third point of angle + Виберіть третю точку кута + + + _ + _ + + + + DialogCurveIntersectAxis + + Curve intersect axis + Перетин кривої і осі + + + Angle + Кут + + + Calculate value + Розрахувати значення + + + Value of angle + Значення кута + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Axis point + Точка осі + + + First point of line + Перша точка лінії + + + Curve + Крива + + + Point label + Ім'я точки + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кути ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables + Змінні + + + Select axis point + Виберіть точку осі + + + + DialogCutArc + + Dialog + Діалог + + + Length + Довжина + + + Formula for the calculation of the spline + Формула розрахунку довжини сплайну + + + Cut arc + Розрізати дугу + + + ... + ... + + + Calculate value + Розрахувати значення + + + Value of length + Значення довжини + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Arc + Дуга + + + Selected curve + Вибрана крива + + + Point label + Ім'я точки + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + + DialogCutSpline + + Dialog + Діалог + + + Length + Довжина + + + Formula for the calculation of the spline + Формула розрахунку сплайну + + + Cut curve + Розрізат криву + + + ... + ... + + + Calculate value + Розрахувати значення + + + Value of length + Значення довжини + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Curve + Крива + + + Selected curve + Вибрана крива + + + Point label + Ім'я точки + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + + DialogCutSplinePath + + Dialog + Діалог + + + Length + Довжина + + + Formula for the calculation of the curve length + Формула розрахунку довжини сплайну + + + Cut curve path + Розрізати складну криву + + + ... + ... + + + Calculate value + Розрахувати значення + + + Value of length + Значення довжини + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Curve + Крива + + + Selected curve path + Вибрана складна крива + + + Point label + Ім'я точки + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + + DialogDetail + + Detail + Деталь + + + Bias X + Зміщення по Х + + + cm + см + + + Bias Y + Зміщення по Y + + + Options + Параметри + + + Seam allowance + Прибавка на шви + + + Delete + Видалити + + + Name of detail + Ім'я деталі + + + Width + Ширина + + + Closed + Замкнена + + + Got wrong scene object. Ignore. + Отримано не правильний об'єкт сцени. Інгнорується. + + + Got wrong tools. Ignore. + Отримано не правильний інструмент. Інгнорується. + + + Reverse + Протилежний напрямок + + + + DialogEditWrongFormula + + Edit formula + Редагувати формулу + + + Formula + Формула + + + Insert variable into formula + Вставити змінну у формулу + + + ... + ... + + + Calculate value + Розрахувати значення + + + Value of first angle + Значення першого кута + + + _ + _ + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Standard table + Стандартна таблиця + + + Measurements + Мірки + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables + Змінні + + + + DialogEndLine + + Length + Довжина + + + Point in the end of a line + Точка на кінці відрізку + + + Formula for calculation of length of line + Формула для розрахунку довжини лінії + + + Calculate value + Розрахувати значення + + + Value of length + Значення довжини + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Angle + Кут + + + Value of angle + Значення кута + + + Base point + Базова точка + + + First point of line + Перша точка лінії + + + Point label + Ім'я точки + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Standard table + Стандартна таблиця + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables + Змінні + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + Angle of line + Кут лінії + + + Degree of angle + Кут + + + Input data + Вхідні данні + + + Size and growth + Розмір і зріст + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + + DialogHeight + + Dialog + Діалог + + + Height + Зріст + + + Point label + Ім'я точки + + + Base point + Базова точка + + + First point of line + Перша точка лінії + + + Second point of line + Друга точка лінії + + + Type of line + Тип лінії + + + Show line from first point to our point + Показати лінію від першої точки до нашої точки + + + Select first point of line + Виберість першу точку лінії + + + Select second point of line + Виберіть другу точку лінії + + + + DialogHistory + + History + Історія + + + Tool + Інструмент + + + %1 - Base point + %1 - Базова точка + + + %1_%2 - Line from point %1 to point %2 + %1_%2 - Лінія від точки %1 до точки %2 + + + %3 - Point along line %1_%2 + %3 - Точка вздовж лінії %1_%2 + + + %1 - Point of shoulder + %1 - точка плеча + + + %3 - normal to line %1_%2 + %3 - перпендикуляр до лінії %1_%2 + + + %4 - bisector of angle %1_%2_%3 + %4 - бісектриса кута %1_%2_%3 + + + %4 - point of contact of arc with the center in point %1 and line %2_%3 + %4 - точка перетину дуги з центром в точці %1 і лінії %2_%3 + + + Point of perpendicular from point %1 to line %2_%3 + Точка перпендикуляра з точки %1 до лінії %2_%3 + + + %1 - point of intersection %2 and %3 + %1 - перитину %2 і %3 + + + %1 - cut arc with center %2 + %1 - розразає дугу з центром в точці %2 + + + %1 - cut curve %2_%3 + %1 - розрізає криву %2_%3 + + + %1 - cut curve path %2 + %1 - розрізає складну криву %2 + + + %1 - point of intersection line %2_%3 and axis through point %4 + %1 - точка перетину лінії %2_%3 і осі через точку %4 + + + %1 - point of intersection curve and axis through point %2 + %1 - точка перетину кривої і осі через точку %2 + + + %1 - cut curve point %2 + %1 - розрізає криву точкою %2 + + + Got wrong tool type. Ignore. + Отримано не правильний тип інструменту. Ігнорується. + + + Curve %1_%2 + Крива %1_%2 + + + %5 - intersection of lines %1_%2 and %3_%4 + %5 - перетин ліній %1_%2 і %3_%4 + + + Can't create record. + Не можу створити запис. + + + Arc with center in point %1 + Дуга з центром в точці %1 + + + Curve point %1 + Точка кривої %1 + + + Triangle: axis %1_%2, points %3 and %4 + Трикутник: вісь %1_%2, точки %3 і %4 + + + + DialogIncrements + + Increments + Прибавки + + + Sizes table + Таблиця розмірів + + + Measurements + Мірки + + + Load another measurements table + Завантажити іншу таблицю з мірками + + + Personal information + Персональна інформація + + + Given name + Імя + + + Family name + Прізвище + + + Birth date + Дата народження + + + Sex + Стать + + + Hide empty measurements + Сховати пусті мірки + + + Name + Позначення + + + The calculated value + Розраховане значення + + + Base value + Базове значення + + + In sizes + В розмірах + + + In growths + В ростах + + + Description + Опис + + + In size + В розмірах + + + In growth + В ростах + + + Email + E-mail + + + In heights + В ростах + + + Lines + Лінії + + + Line + Лінія + + + Length of the line + Довжина лінії + + + Curves + Криві + + + Curve + Крива + + + Length of the curve + Довжина кривої + + + Arcs + Дуги + + + Arc + Дуга + + + Length of arc + Довжина дуги + + + Name %1 + Позначення %1 + + + File error. + Помилка файла. + + + male + чоловік + + + female + жінка + + + Could not save GivenName + Не вдалося зебрегти імя + + + Could not save FamilyName + Не вдалося збергети прізвище + + + Could not save Email + Не вдалося зберегти Email + + + Could not save Sex + Не вдалося зберегти стать + + + Could not save BirthDate + Не вдалося зберегти Дату народження + + + Measurements use different units than pattern. This pattern required measurements in %1 + Мірки використовують інші одиниці виміри ніж лекало. Це лекало потребує мірок в %1 + + + Individual measurements (*.vit) + Індивідуальні мірки (*.vit) + + + Open file + Відкрити файл + + + Wrong units. + Неправильні одиниці виміру. + + + Standard measurements (*.vst) + Стандартні мірки (*.vst) + + + Name_%1 + Name_%1 + + + Can't save measurement + Не вдалося зберегти мірки + + + Can't convert toDouble value. + Не можу конвертувати toDouble значення. + + + Calculated value + Розраховане значення + + + Length + Довжина + + + + DialogIndividualMeasurements + + Dialog + Діалог + + + Individual measurements + Індивідуальні мірки + + + Pattern piece name + Імя лекала + + + Exist measurements + Існуючі мірки + + + Path: + Шлях: + + + ... + ... + + + Given name: + Імя: + + + Family name: + Прізвище: + + + New measurements + Нові мірки + + + Units: + Одинці виміру: + + + Could not create measurements file + Не можу створити файл мірок + + + Please try again or change file + Будь ласка спробуйте знову чи змініть файл + + + File error. + Помилка файла. + + + Individual measurements (*.vit) + Індивідуальні мірки (*.vit) + + + Open file + Відкрити файл + + + Where save measurements? + Де зберегти мірки? + + + Centimeters + Сантиметри + + + Millimiters + Міліметри + + + Inches + Дюйми + + + + DialogLine + + Line + Лінія + + + First point + Перша точка + + + Second point + Друга точка + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Select second point + Виберіть другу точку + + + + DialogLineIntersect + + Point of line intersection + Точка перетину ліній + + + Intersection of lines + Перетин ліній + + + Point label + Ім'я точки + + + First line + Перша лінія + + + First point + Перша точка + + + Second point + Друга точка + + + Second line + Друга лінія + + + Select second point of first line + Виберіть другу точка першої лінії + + + Select first point of second line + Виберіть першу точку другої лінії + + + Select second point of second line + Виберіть другу точку другої лінії + + + + DialogLineIntersectAxis + + Line intersect axis + Перетин лінії і осі + + + Angle + Кут + + + Calculate value + Розрахувати значення + + + Value of angle + Значення кута + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Axis point + Точка осі + + + First point of line + Перша точка лінії + + + First line point + Перша точка лінії + + + Second line point + Друга точка лінії + + + Point label + Ім'я точки + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Input data + Вхідні данні + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Increments + Прибавки + + + Length of lines + Довжина ліній + + + Length of arcs + Довжина дуг + + + Length of curves + Довжина кривих + + + Angle of lines + Кути ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables + Змінні + + + Select second point of line + Виберіть другу точку лінії + + + Select axis point + Виберіть точку осі + + + + DialogMeasurements + + Measurements + Мірки + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + <html><head/><body><p><span style=" font-size:18pt;">Будь ласка, виберіть тип лекала.</span></p></body></html> + + + Graduation + Градація + + + Use for creation pattern standard measurement table + Лекало зі стандартною таблицею + + + Individual + Індивідуальні + + + Use for creation pattern individual measurements + Лекало з індивідуальними мірками + + + + DialogNormal + + Normal + Перпендикуляр + + + Length + Довжина + + + Value of length + Значення довжини + + + First point + Перша точка + + + Second point + Друга точка + + + Additional angle degrees + Додатковий кут градуси + + + Input data + Вхідні данні + + + Measurements + Мірки + + + Size and growth + Розмір і зріст + + + Formula for calculation of length of normal + Формула розрахунку довжини перпендикуляра + + + Calculate value + Розрахувати значення + + + Point label + Ім'я точки + + + Insert variable into formula + Вставте змінну в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Type of line + Тип лінії + + + Show line from first point to this point + Показати лінію від першої точки до даної + + + Size and height + Розмір і зріст + + + Standard table + Стандартна таблиця + + + Increments + Прибавки + + + Length of lines + Довжини ліній + + + Length of arcs + Довжини дуг + + + Length of curves + Довжини кривих + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + Select second point of line + Виберіть другу точку лінії + + + + DialogPatternProperties + + Pattern properties + Властивості лекала + + + Description + Опис + + + Author name + Ім'я автора + + + Pattern description + Опис лекала + + + For technical notes. + Для технічних заміток. + + + Heights and Sizes + Зрости і розміри + + + All heights (cm) + Всі зрости (см) + + + All sizes (cm) + Всі розміри (см) + + + + DialogPatternXmlEdit + + XML Editor + XML редактор + + + Value : + Значення: + + + Name : + Ім'я: + + + <No selection> + <Немає вибраного> + + + Type : + Тип: + + + Add attribute + Додати атрибут + + + Add son + Додати сина + + + Remove attribute + Видалити атрибут + + + Remove node + Видалити вузол + + + Set + Задати + + + Cancel + Відмінити + + + Apply changes + Застосувати зміни + + + Undo last + Відмінити останнє + + + Immediate apply + Негайно застосувати + + + Base selection + Вибір бази + + + All pattern pieces + Всі лекала + + + No changes + Немає змін + + + Cannot delete previously created node + Не вдається видалити раніше створений вузол + + + No changes left + Змін більше не залишилось + + + Cannot undo change + Не можу відмінити зміни + + + <no value> + <Немає значення> + + + Unchanged + Незмінений + + + Cannot delete previously created attribute + Не вдається видалити раніше створений атрибут + + + Node Name + Імя вузла + + + Name: + Імя: + + + Node Value (may be empty) + Значення вузла (може бути пустим) + + + Value: + Значення: + + + Attribute Name + Ім'я атрибуту + + + Attribute Value + Значення атрибуту + + + No selection + Не вибрано + + + Root node + Корневий вузол + + + Node + Вузел + + + Attribute + Атрибут + + + + DialogPointOfContact + + Point of contact + Точка дотику + + + Radius + Радіус + + + Value of radius + Значення радіусу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + Center of arc + Центер дуги + + + Formula for calculation of radius of arc + Формула для розрахунку радіуса дуги + + + Calculate value + Розрахувати значення + + + Point label + Ім'я точки + + + Insert variable into formula + Вставте змінну в формулу + + + Top of the line + Початок лінії + + + End of the line + Кінець лінії + + + Input data + Вхідні данні + + + Size and growth + Розмір і зріст + + + Standard table + Стандартна таблиця + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula. + Змінні - клікніть двічі для вставки в формулу. + + + Increments + Прибавки + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Length of lines + Довжини ліній + + + Length of arcs + Довжини дуг + + + Length of curves + Довжини кривих + + + Select second point of line + Виберіть другу точку лінії + + + Select point of center of arc + Виберіть точку центру дуги + + + + DialogPointOfIntersection + + Dialog + Діалог + + + Point label + Ім'я точки + + + vertical point + Точка по вертикалі + + + horizontal point + Точка по горизонталі + + + First point of angle + Перша точка кута + + + Point of intersection + Точка перетину + + + Second point of angle + Друга точка кута + + + Select point horizontally + Виберіть точку горизонталі + + + + DialogShoulderPoint + + Point of shoulder + Точка плеча + + + Length + Довжина + + + Value of length + Значення довжини + + + Formula for calculation of length of line + Формула для розрахунку довжини лінії + + + Calculate value + Розрахувати значення + + + Point label + Ім'я точки + + + Insert variable into formula + Вставте значення в формулу + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + First point + Перша точка + + + Second point + Друга точка + + + Third point + Третя точка + + + Type of line + Тип лінії + + + Show line from first point to our point + Показати лінію від першої точки до нашої точки + + + Input data + Вхідні данні + + + Size and growth + Розмір і зріст + + + Standard table + Стандартна таблиця + + + Angle of lines + Кут ліній + + + Hide empty measurements + Сховати пусті мірки + + + Variables - Click twice to insert into formula + Змінні - клікніть двічі для вставки в формулу + + + Increments + Прибавки + + + Size and height + Розмір і зріст + + + Measurements + Мірки + + + Length of lines + Довжини лінії + + + Length of arcs + Довжина дуг + + + Length of curves + Довжни кривих + + + Select first point of line + Виберість першу точку лінії + + + Select second point of line + Виберіть другу точку лінії + + + Select point of shoulder + Виберіть точку плеча + + + + DialogSinglePoint + + Single point + Точка + + + Coordinates on the sheet + Координати на листі + + + Coordinates + Координати + + + Y coordinate + Y координата + + + X coordinate + Х координата + + + Point label + Ім'я точки + + + + DialogSpline + + Curve + Крива + + + First point + Перша точка + + + Length ratio of the first control point + Коефіцієнт довжини першої контрольної точки + + + The angle of the first control point + Кут першої контрольної точки + + + Second point + Друга точка + + + Length ratio of the second control point + Коефіцієнт довжини другої контрольної точки + + + The angle of the second control point + Кут другої контрольної точки + + + Coefficient of curvature of the curve + Коефіцієнт кривизни кривої + + + Select last point of curve + Виберість останню точку кривої + + + + DialogSplinePath + + Curve path + Складна крива + + + Curved path + Складна крива + + + Point of curve + Точка кривої + + + Length ratio of the first control point + Коефіцієнт довжини першої контрольної точки + + + The angle of the first control point + Кут першої контрольної точки + + + Length ratio of the second control point + Коефіцієнт довжини другої контрольної точки + + + The angle of the second control point + Кут другої контрольної точки + + + List of points + Список точок + + + Coefficient of curvature of the curve + Коефіцієнт кривизни кривої + + + Select point of curve path + Виберіть точку складної кривої + + + + DialogStandardMeasurements + + Standard table + Стандартна таблиця + + + Pattern piece name + Ім'я лекала + + + Standard measurements table + Стандартна таблиця мірок + + + File error. + Помилка файла. + + + + DialogTool + + Wrong details id. + Неправильний id деталі. + + + Line + Лінія + + + No line + Без лінії + + + Can't find point by name + Не можу знайти точку за ім'ям + + + Error + Помилка + + + Growth + Зріст + + + Dash Line + Пунктирна лінія (-) + + + Dot Line + Пунктирна лінія (.) + + + Dash Dot Line + Пунктирна лінія (-.) + + + Dash Dot Dot Line + Пунктирна лінія (-..) + + + Can't find object by name + Не можу знайти об'єкт за ім'ям + + + Empty field + Пусте поле + + + Value can't be 0 + Значення не може бути 0 + + + Value + Значення + + + Height + Зріст + + + Size + Розмір + + + Line length + Довжина лінії + + + Arc length + Довжина дуги + + + Curve length + Довжина кривої + + + Parser error: %1 + Помилка синтаксичного аналізу: %1 + + + + DialogTriangle + + Dialog + Діалог + + + Triangle + Трикутник + + + Point label + Ім'я точки + + + First point of axis + Перша точка вісі + + + First point of line + Перша точка лінії + + + Second point of axis + Друга точка вісі + + + First point + Перша точка + + + Second point + Друга точка + + + Select second point of axis + Виберіть другу точку вісі + + + Select first point + Виберість першу точку + + + Select second point + Виберіть другу точку + + + + DialogUndo + + Broken formula + Зламана формула + + + Error while calculation formula. You can try undo last operation or fix broken formula. + Помилка при розрахунку формули. Ви можете попробувати відмінити останню операцію чи виправити поламану формулу. + + + &Undo + &Відмінити + + + &Fix formula + &Виправити формулу + + + &Cancel + &Відмінити + + + + DialogUnionDetails + + Dialog + Діалог + + + Do you really want union details? This operation can't be undone. + Ви дійсно хочете обєднати деталі? Цю операцію не можна буде відмінити. + + + Select first point + Виберість першу точку + + + Select second point + Виберіть другу точку + + + Select another second point + Виберіть іншу точку + + + Select detail + Виберіть деталь + + + Union details + Обєднання деталей + + + <html><head/><body><p>Do you really want union details?</p></body></html> + <html><head/><body><р>Показати повний розрахунок у вікні повідомлення</p></body</html> + + + + Functions + + sin + sine function + sin + + + cos + cosine function + cos + + + tan + tangens function + tan + + + asin + arcus sine function + asin + + + acos + arcus cosine function + acos + + + atan + arcus tangens function + atan + + + sinh + hyperbolic sine function + sinh + + + cosh + hyperbolic cosine + cosh + + + tanh + hyperbolic tangens function + tanh + + + asinh + hyperbolic arcus sine function + asibh + + + acosh + hyperbolic arcus tangens function + acosh + + + atanh + hyperbolic arcur tangens function + atanh + + + log2 + logarithm to the base 2 + log2 + + + log10 + logarithm to the base 10 + log10 + + + log + logarithm to the base 10 + log + + + ln + logarithm to base e (2.71828...) + ln + + + exp + e raised to the power of x + exp + + + sqrt + square root of a value + sqrt + + + sign + sign function -1 if x<0; 1 if x>0 + sign + + + rint + round to nearest integer + rint + + + abs + absolute value + abs + + + min + min of all arguments + min + + + max + max of all arguments + max + + + sum + sum of all arguments + sum + + + avg + mean value of all arguments + avg + + + + InternalStrings + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + Програма надається ЯК Є без ГАРАНТІЙ БУДЬ-ЯКОГО РОДУ, ВКЛЮЧАЮЧИ ГАРАНТІЙ ДИЗАЙНУ, КОМЕРЦІЙНОЇ ЦІННОСТІ І ПРИДАТНОСТІ ДЛЯ КОНКРЕТНИХ ЦІЛЕЙ. + + + + MainWindow + + Valentina + Valentina + + + Tools for creating points. + Інструмент створення точок. + + + Point + Точка + + + Point along perpendicular + Інструмент точка перпендикуляра + + + Special point on shoulder. + Інструмент точка плеча. + + + Point at distance and angle + Інструмент точка на кінці лінії + + + Point at distance along line + Інструмент точка вздовж лінії + + + Point along bisector + Інструмент точка бісектриси кута + + + Point at intersection of arc and line. + Інструмент точка дотику. + + + Tool point of height. + Інструмент точка висоти. + + + Tool triangle. + Інструмент трикутник. + + + Tools for creating lines. + Інструменти для створення ліній. + + + Line + Лінія + + + Tool line. + Інструмент лінія. + + + Tool point of line intersection. + Інструмент точка перетину ліній. + + + Tools for creating curves. + Інструменти для створення кривих. + + + Curve + Крива + + + Tool curve. + Інструмент крива. + + + Tool path curve. + Інструмент складна крива. + + + Tools for creating arcs. + Інструменти для створення дуг. + + + Arc + Дуга + + + Tool arc. + Інструмент дуга. + + + Tools for creating details. + Інструменти для створення деталей. + + + Detail + Деталь + + + Tool new detail. + Інструмент нова деталь. + + + File + Файл + + + Help + Допомога + + + Pattern piece + Креслення + + + Details mode + Режим деталей + + + Pointer tools + Інструмент вказівник + + + New pattern piece + Нове креслення + + + Add new pattern piece + Додати нове креслення + + + Perpendicular point along line + Перпендикулярна точка вздовж лінії + + + Tool to make point from x & y of two other points. + Інструменд для створення точки з двух х и у координат двух інших точок. + + + Line between points + Лінія між двома точками + + + Point at line intersection + Точка перетину ліній + + + Curve tool. + Інструмент крива. + + + Tool for path curve. + Інструмент складна крива. + + + Tool segment a pathed curve. + Інструмент розрізання складної кривої. + + + Tool for segmenting a curve. + Інструмент розрізання кривої. + + + Point of intersection line and axis + Точка на перетині лінії і осі + + + ... + ... + + + Arc tool. + Інструмент дуга. + + + Cut arc tool. + Інструмент розрізання дуги. + + + Tool for union two details. + Інструмент обєднання двух деталей. + + + &File + &Файл + + + &Help + &Допомога + + + &Pattern piece + &Креслення + + + New + Новий + + + &New + &Новий + + + Create a new pattern + Створити нове лекало + + + Ctrl+N + Ctrl+N + + + Open + Відкрити + + + &Open + &Відкрити + + + Open file with pattern + Відкрити файл з лекалами + + + Save + Зберегти + + + &Save + &Зберегти + + + Save pattern + Зберегти лекало + + + Ctrl+S + Ctrl+S + + + Save &As... + Зберегти &як... + + + Options... + Нашатування... + + + Pattern properties + Властивості лекала + + + Save as + Зберегти як + + + Measurements + Мірки + + + Window + Вікно + + + Toolbar files + Панель інструментів файли + + + ToolBar modes + Панель інструментів режими + + + Toolbar pattern + Панель інструметнів лекала + + + Toolbar options + Панель інструментів налаштування + + + Toolbar tools + Панель інструментів + + + Tool options + Параметри інструментів + + + Save not yet saved pattern + Зберегти ще не збережене лекало + + + Ctrl+Shift+S + Ctrl+Shift+S + + + Draw + Малювання + + + Draw mode + Режим малювання + + + Ctrl+W + Ctrl+W + + + Details + Деталь + + + Ctrl+E + Ctrl+E + + + Ctrl+Shift+N + Ctrl+Shift+N + + + Change the label of pattern piece + Змінити ім'я креслення + + + Export pattern (layout) + Експорт креслення (розкладка) + + + About &Qt + Про &Qt + + + &About Valentina + &Про Valentina + + + E&xit + &Вихід + + + Exit the application + Закрити програму + + + Ctrl+Q + Ctrl+Q + + + Preferences + Властивості + + + Zoom in + Збільшити + + + Original zoom + Початковий масштаб + + + Original Zoom + Початковий масштаб + + + Zoom fit best + Помістити все + + + Ctrl+= + Ctrl+= + + + Stop + Зупинити + + + Stop using tool + Зупинити використання інструменту + + + Repot Bug... + Повідомити про помилку... + + + Report bug + Повідомити про помилку + + + Close window + Закрити вікно + + + Zoom In + Збільшити + + + zoom in + наблизити + + + Zoom Out + Зменшити + + + Zoom out + Зменшити + + + Edit pattern XML code + Редагувати XML код креслення + + + Deatils mode + Режим деталей + + + Tools pointer + Інструмент вказівник + + + Table of variables + Таблиця змінних + + + Tables of variables + Таблиці змінних + + + Ctrl+T + Ctrl+T + + + History + Історія + + + Ctrl+H + Ctrl+H + + + Layout + Розкладки + + + Create layout + Створити розкладку + + + Ctrl+L + Ctrl+L + + + About Qt + Про Qt + + + About Valentina + Про Valentina + + + Exit + Вихід + + + Drawing %1 + Креслення %1 + + + Drawing: + Креслення: + + + Error creating drawing with the name + Помилка створення креслення з ім'ям + + + Error saving change!!! + Помилка збереження змін!!! + + + Select point + Виберість точку + + + Select first point + Виберіть першу точку + + + Select point of shoulder + Виберіть точку плеча + + + Individual measurements is under development + Індивідуальні мірки знаходяться в стадії розробки + + + There is no way create individual measurements file independent on the pattern file. +For opening pattern need keep both files: pattern and measurements. Do you want continue? + У вас не буде можливості створити файл індивідуальних мірок незалежно від файлу викройки. +Для того щоб відкрити файл викройки зберігайте обидва файли: викройку і індивідуальні мірки. Ви хочете продовжити створення? + + + Select first point of line + Виберіть першу точку лінії + + + Select first point of angle + Виберіть першу точку кута + + + Select first point of first line + Виберіть першу точку першої лінії + + + Select first point curve + Виберіть першу точку кривої + + + Select point of center of arc + Виберіть точку центру дуги + + + Select point of curve path + Виберіть точку складної кривої + + + Select curve + Вибрати криву + + + Size: + Розмір: + + + pattern + Лекало + + + Critical error! + Критична помилка! + + + Error parsing file (std::bad_alloc). + Помилка парсінгу файлу (std::bad_alloc). + + + Bad id. + Поганий id. + + + Could not save file + Не вдалося зберегти файл + + + &Undo + &Відмінити + + + &Redo + &Повторити + + + Wrong units. + Неправильні одиниці виміру. + + + Application doesn't support standard table with inches. + Програма не підтримує стандарнту таблицю з дюймами. + + + File error. + Помилка файла. + + + Valentina didn't shut down correctly. Do you want reopen files (%1) you had open? + Валентина не була закрита правильно. Ви хочете знову відкрити ці файли (%1)? + + + Reopen files. + Відкрити знову файли. + + + The measurements file <br/><br/> <b>%1</b> <br/><br/> %3 + Файл мірок <br/><br/> <b>%1</b> <br/><br/> %3 + + + could not be found. Do you want to update the file location + не може бути знайдений. Ви хочете оновити шлях до файлу + + + Standard measurements (*.vst) + Стандартні мірки (*.vst) + + + Individual measurements (*.vit) + Індивідуальні мірки (*.vit) + + + Create new pattern piece to start working. + Створіть нове креслення для початку роботи. + + + Enter a label for the pattern piece. + Введить імя креслення. + + + Error. Pattern piece of same label already exists. + Помилка. Креслення з таким імям уже існує. + + + Pattern piece: + Креслення: + + + Enter a new label for the pattern piece. + Введить нове ім'я для креслення. + + + Error. Pattern piece of same name already exists. + Помилка. Креслення з таким ім'ям вже існує. + + + Can't save new label of pattern piece + Не можу зберегти нове ім'я креслення + + + The pattern has been modified. + Лекало було зміненно. + + + Do you want to save your changes? + Ви хочете зберегти зміни? + + + Growth: + Зріст: + + + Size: + Розмір: + + + Drawing: + Креслення: + + + Lekalo files (*.xml);;All files (*.*) + Файли лекала (*.xml);;Всі файли (*.*) + + + Lekalo files (*.xml) + Файл лекала (*.xml) + + + Error saving file. Can't save file. + Помилка збереження файлу. Не можу зберегти файл. + + + Open file + Відкрити файл + + + Can't open pattern file %1: +%2. + Не можу відкрити файл лекала %1: +%2. + + + Can't open schema file %1: +%2. + Не можу відкрити файл схеми %1: +%2. + + + Error no unique id. + Помилка не унікальний id. + + + Got empty file name. + Отримано пусте імя файлу. + + + Could not copy temp file to pattern file + Не можу копіювати тимчасовий файл до файлу лекала + + + Could not remove pattern file + Не можу видалити файл лекала + + + Can't open pattern file. File name empty + Не можу відкрити файл лекала. Пусте ім'я файлу + + + Error! + Помилка! + + + Select points, arcs, curves clockwise. + Виберіть точки, дуги, криві загодинниковою стрілкою. + + + Pattern piece %1 + Креслення %1 + + + Error creating pattern with the name + Помилка створення лекала з ім'ям + + + Select simple curve + Виберіть просту криву + + + Select curve path + Виберіть складну криву + + + Select base point + Виберіть базову точку + + + Select first point of axis + Виберіть першу точку вісі + + + Select point vertically + Виберіть точку по вертикалі + + + Select detail + Виберіть деталь + + + Select arc + Виберіть дугу + + + Based on Qt %2 (32 bit) + Базується на Qt %2 (32 bit) + + + Built on %3 at %4 + Зібрано %3 в %4 + + + Height: + Зріст: + + + Pattern Piece: + Креслення: + + + Pattern files (*.val) + Файл лекала (*.val) + + + /pattern.val + /викрійка.val + + + File saved + Файл збережено + + + Can not save pattern + Не можу зберегти лекало + + + untitled.val + безімений.val + + + Unsaved change + Незбережені зміни + + + The pattern has been modified. +Do you want to save your changes? + Лекало було змінено. Ви хочете зберегти ваші зміни? + + + &%1 %2 + &%1 %2 + + + Cannot read file %1: +%2. + Не можу прочитати файл%1:\n%2. + + + File loaded + Файл завантажено + + + Can't open pattern file. + Не можу відкрити файл викрійки. + + + Empty schema path. + Пустий шлях до схеми. + + + Can't open schema file. + Не можу відкрити файл схеми. + + + Can't open pattern file. File name is empty + Не можу відкрити файл викрійки. Ім'я файлу пусте + + + Error parsing file. + Помилка парсингу файла. + + + Error can't convert value. + Помилка, не можу конвертувати значення. + + + Error empty parameter. + Помилка, пустий параметр. + + + Error wrong id. + Помикла, неправильний id. + + + Parsing pattern file error. + Помилка парсингу файлу викрійки. + + + Validation file error. + Помилка валідації файлу. + + + Error parsing pattern file. + Помилка парсінгу файлу лекала. + + + Error in line %1 column %2 + Помилка в лінії %1 стовпчик %2 + + + Online help + Довідка в Інтернеті + + + Show online help + Показати довідку + + + This file already opened in another window. + Цей файл вже відкрито в іншому вікні. + + + + Measurements + + head_girth + Short measurement name. Don't use math symbols in name!!!! + Огол + + + mid_neck_girth + Short measurement name. Don't use math symbols in name!!!! + mid_neck_girth + + + neck_base_girth + Short measurement name. Don't use math symbols in name!!!! + Ош + + + head_and_neck_length + Short measurement name. Don't use math symbols in name!!!! + head_and_neck_length + + + center_front_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дпт + + + center_back_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дтс + + + shoulder_length + Short measurement name. Don't use math symbols in name!!!! + Шп + + + side_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дб + + + trunk_length + Short measurement name. Don't use math symbols in name!!!! + trunk_length + + + shoulder_girth + Short measurement name. Don't use math symbols in name!!!! + shoulder_girth + + + upper_chest_girth + Short measurement name. Don't use math symbols in name!!!! + ОгI + + + bust_girth + Short measurement name. Don't use math symbols in name!!!! + ОгII + + + under_bust_girth + Short measurement name. Don't use math symbols in name!!!! + ОгIII + + + waist_girth + Short measurement name. Don't use math symbols in name!!!! + От + + + high_hip_girth + Short measurement name. Don't use math symbols in name!!!! + high_hip_girth + + + hip_girth + Short measurement name. Don't use math symbols in name!!!! + Об + + + upper_front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг1 + + + front_chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг2 + + + across_front_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + dпл + + + across_back_shoulder_width + Short measurement name. Don't use math symbols in name!!!! + across_back_shoulder_width + + + upper_back_width + Short measurement name. Don't use math symbols in name!!!! + upper_back_width + + + back_width + Short measurement name. Don't use math symbols in name!!!! + Шс + + + bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + Цг + + + halter_bustpoint_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + halter_bustpoint_to_bustpoint + + + neck_to_bustpoint + Short measurement name. Don't use math symbols in name!!!! + Вг + + + crotch_length + Short measurement name. Don't use math symbols in name!!!! + crotch_length + + + rise_height + Short measurement name. Don't use math symbols in name!!!! + Дпс + + + shoulder_drop + Short measurement name. Don't use math symbols in name!!!! + shoulder_drop + + + shoulder_slope_degrees + Short measurement name. Don't use math symbols in name!!!! + shoulder_slope_degrees + + + front_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + front_shoulder_slope_length + + + back_shoulder_slope_length + Short measurement name. Don't use math symbols in name!!!! + back_shoulder_slope_length + + + front_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + front_shoulder_to_waist_length + + + back_shoulder_to_waist_length + Short measurement name. Don't use math symbols in name!!!! + back_shoulder_to_waist_length + + + front_neck_arc + Short measurement name. Don't use math symbols in name!!!! + front_neck_arc + + + back_neck_arc + Short measurement name. Don't use math symbols in name!!!! + back_neck_arc + + + front_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + front_upper_chest_arc + + + back_upper_chest_arc + Short measurement name. Don't use math symbols in name!!!! + back_upper_chest_arc + + + front_waist_arc + Short measurement name. Don't use math symbols in name!!!! + front_waist_arc + + + back_waist_arc + Short measurement name. Don't use math symbols in name!!!! + back_waist_arc + + + front_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + front_upper_hip_arc + + + back_upper_hip_arc + Short measurement name. Don't use math symbols in name!!!! + back_upper_hip_arc + + + front_hip_arc + Short measurement name. Don't use math symbols in name!!!! + front_hip_arc + + + back_hip_arc + Short measurement name. Don't use math symbols in name!!!! + back_hip_arc + + + chest_slope + Short measurement name. Don't use math symbols in name!!!! + chest_slope + + + back_slope + Short measurement name. Don't use math symbols in name!!!! + back_slope + + + front_waist_slope + Short measurement name. Don't use math symbols in name!!!! + front_waist_slope + + + back_waist_slope + Short measurement name. Don't use math symbols in name!!!! + back_waist_slope + + + front_neck_to_upper_chest_height + Short measurement name. Don't use math symbols in name!!!! + front_neck_to_upper_chest_height + + + front_neck_to_bust_height + Short measurement name. Don't use math symbols in name!!!! + front_neck_to_bust_height + + + front_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + Дпер + + + front_waist_to_lower_breast + Short measurement name. Don't use math symbols in name!!!! + Дпг + + + back_waist_to_upper_chest + Short measurement name. Don't use math symbols in name!!!! + Дст + + + strap_length + Short measurement name. Don't use math symbols in name!!!! + Дбр + + + armscye_girth + Short measurement name. Don't use math symbols in name!!!! + armscye_girth + + + elbow_girth + Short measurement name. Don't use math symbols in name!!!! + Олк + + + upper_arm_girth + Short measurement name. Don't use math symbols in name!!!! + Оп + + + wrist_girth + Short measurement name. Don't use math symbols in name!!!! + Озап + + + scye_depth + Short measurement name. Don't use math symbols in name!!!! + scye_depth + + + shoulder_and_arm_length + Short measurement name. Don't use math symbols in name!!!! + Дзап + + + underarm_length + Short measurement name. Don't use math symbols in name!!!! + Втр + + + cervicale_to_wrist_length + Short measurement name. Don't use math symbols in name!!!! + cervicale_to_wrist_length + + + shoulder_to_elbow_length + Short measurement name. Don't use math symbols in name!!!! + Дрлок + + + arm_length + Short measurement name. Don't use math symbols in name!!!! + Дрзап + + + hand_width + Short measurement name. Don't use math symbols in name!!!! + hand_width + + + hand_length + Short measurement name. Don't use math symbols in name!!!! + hand_length + + + hand_girth + Short measurement name. Don't use math symbols in name!!!! + Окис + + + thigh_girth + Short measurement name. Don't use math symbols in name!!!! + Обед + + + mid_thigh_girth + Short measurement name. Don't use math symbols in name!!!! + mid_thigh_girth + + + knee_girth + Short measurement name. Don't use math symbols in name!!!! + Ок + + + calf_girth + Short measurement name. Don't use math symbols in name!!!! + Ои + + + ankle_girth + Short measurement name. Don't use math symbols in name!!!! + Ощ + + + knee_height + Short measurement name. Don't use math symbols in name!!!! + Вк + + + ankle_height + Short measurement name. Don't use math symbols in name!!!! + ankle_height + + + foot_width + Short measurement name. Don't use math symbols in name!!!! + foot_width + + + foot_length + Short measurement name. Don't use math symbols in name!!!! + foot_length + + + height + Short measurement name. Don't use math symbols in name!!!! + Р + + + cervicale_height + Short measurement name. Don't use math symbols in name!!!! + Вшт + + + cervicale_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + cervicale_to_knee_height + + + waist_height + Short measurement name. Don't use math symbols in name!!!! + Влт + + + high_hip_height + Short measurement name. Don't use math symbols in name!!!! + high_hip_height + + + hip_height + Short measurement name. Don't use math symbols in name!!!! + hip_height + + + waist_to_hip_height + Short measurement name. Don't use math symbols in name!!!! + waist_to_hip_height + + + waist_to_knee_height + Short measurement name. Don't use math symbols in name!!!! + waist_to_knee_height + + + crotch_height + Short measurement name. Don't use math symbols in name!!!! + Дн + + + size + Short measurement name. Don't use math symbols in name!!!! + Сг + + + Size + Full measurement name + Розмір + + + Size + Full measurement description + Розмір + + + height_front_neck_base_point + Short measurement name. Don't use math symbols in name!!!! + Втос + + + height_base_neck_side_point + Short measurement name. Don't use math symbols in name!!!! + Втош + + + height_shoulder_point + Short measurement name. Don't use math symbols in name!!!! + Впт + + + height_nipple_point + Short measurement name. Don't use math symbols in name!!!! + Вст + + + height_back_angle_axilla + Short measurement name. Don't use math symbols in name!!!! + Взу + + + height_scapular_point + Short measurement name. Don't use math symbols in name!!!! + Влоп + + + height_under_buttock_folds + Short measurement name. Don't use math symbols in name!!!! + Впс + + + hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + ОбI + + + girth_foot_instep + Short measurement name. Don't use math symbols in name!!!! + Ос + + + side_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + Дсб + + + front_waist_to_floor + Short measurement name. Don't use math symbols in name!!!! + Дсп + + + arc_through_groin_area + Short measurement name. Don't use math symbols in name!!!! + Дпоб + + + waist_to_plane_seat + Short measurement name. Don't use math symbols in name!!!! + Вс + + + neck_to_radial_point + Short measurement name. Don't use math symbols in name!!!! + Длуч + + + neck_to_third_finger + Short measurement name. Don't use math symbols in name!!!! + ДIIIп + + + neck_to_first_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + Впрп + + + front_waist_length + Short measurement name. Don't use math symbols in name!!!! + Дтп + + + arc_through_shoulder_joint + Short measurement name. Don't use math symbols in name!!!! + Дп + + + neck_to_back_line_chest_circumference + Short measurement name. Don't use math symbols in name!!!! + Впрз + + + waist_to_neck_side + Short measurement name. Don't use math symbols in name!!!! + ДтсI + + + arc_length_upper_body + Short measurement name. Don't use math symbols in name!!!! + Двчт + + + chest_width + Short measurement name. Don't use math symbols in name!!!! + Шг + + + anteroposterior_diameter_hands + Short measurement name. Don't use math symbols in name!!!! + dпзр + + + height_clavicular_point + Short measurement name. Don't use math symbols in name!!!! + Вкт + + + height_armhole_slash + Short measurement name. Don't use math symbols in name!!!! + Впрк + + + slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Впк + + + half_girth_neck + Short measurement name. Don't use math symbols in name!!!! + Сш + + + half_girth_neck_for_shirts + Short measurement name. Don't use math symbols in name!!!! + Сш1 + + + half_girth_chest_first + Short measurement name. Don't use math symbols in name!!!! + СгI + + + half_girth_chest_second + Short measurement name. Don't use math symbols in name!!!! + СгII + + + half_girth_chest_third + Short measurement name. Don't use math symbols in name!!!! + СгIII + + + half_girth_waist + Short measurement name. Don't use math symbols in name!!!! + Ст + + + half_girth_hips_considering_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + Сб + + + half_girth_hips_excluding_protruding_abdomen + Short measurement name. Don't use math symbols in name!!!! + СбI + + + girth_knee_flexed_feet + Short measurement name. Don't use math symbols in name!!!! + Окс + + + neck_transverse_diameter + Short measurement name. Don't use math symbols in name!!!! + + + + front_slash_shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Впкп + + + neck_to_front_waist_line + Short measurement name. Don't use math symbols in name!!!! + Дтн1 + + + hand_vertical_diameter + Short measurement name. Don't use math symbols in name!!!! + dвр + + + neck_to_knee_point + Short measurement name. Don't use math symbols in name!!!! + Дшк + + + waist_to_knee + Short measurement name. Don't use math symbols in name!!!! + Дтк + + + shoulder_height + Short measurement name. Don't use math symbols in name!!!! + Вп + + + head_height + Short measurement name. Don't use math symbols in name!!!! + Вгол + + + body_position + Short measurement name. Don't use math symbols in name!!!! + Пкор + + + arc_behind_shoulder_girdle + Short measurement name. Don't use math symbols in name!!!! + Дпз + + + neck_to_neck_base + Short measurement name. Don't use math symbols in name!!!! + Дшош + + + depth_waist_first + Short measurement name. Don't use math symbols in name!!!! + Гт1 + + + depth_waist_second + Short measurement name. Don't use math symbols in name!!!! + ГтII + + + + MeasurementsDescriptions + + Around fullest part of Head + Full measurement description + Обхват голови + + + Around middle part of Neck + Full measurement description + Навколо середньої частини шиї + + + Around Neck at base + Full measurement description + Обхват шиї + + + Vertical Distance from Crown to Nape + Full measurement description + Вертикальна відстань від тімені до затилку + + + Front Neck Center over tape at Bustline to Front Waist Center + Full measurement description + Довжина переду до талії + + + Back Neck Center to Back Waist Center + Full measurement description + Довжина спини до талії з урахуванням виступу лопаток + + + NeckPoint to ShoulderTip + Full measurement description + Довжина плечового скату + + + Armpit to Waist side + Full measurement description + Довжина бокової частини + + + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + Full measurement description + Around Body from middle of Shoulder length to BustPoint to Crotch up back to beginning point + + + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + Full measurement description + Around Arms and Torso, at bicep level parallel to floor, with arms hanging at the sides + + + Around Chest at Armfold level, will be parallel to floor across back, will not be parallel to floor across front chest + Full measurement description + Обхват грудей перший + + + Around fullest part of Bust, parallel to floor + Full measurement description + Обхват грудей другий + + + Around Chest below the Bust, parallel to floor + Full measurement description + Обхват грудей третій + + + Tie a string around smallest part of waist, keep string tied while taking meaasurements. Not usually parallel to floor for front waist or back waist. + Full measurement description + Обхват талії. + + + Around HighHip, parallel to floor + Full measurement description + Around HighHip, parallel to floor + + + Around Hip, parallel to floor + Full measurement description + Обхват стегон з урахуванням виступу живота + + + Across Front UpperChest, smallest width from armscye to armscye + Full measurement description + Ширина грудей перша + + + Across Front Chest, from armfold to armfold + Full measurement description + Ширина грудей друга + + + From ShoulderTip to ShoulderTip, across Front + Full measurement description + Плечовий діаметр + + + From ShoulderTip to ShoulderTip, across Back + Full measurement description + Around HighHip, parallel to floor + + + Across Back UpperChest, smallest width from armscye to armscye + Full measurement description + Across Back UpperChest, smallest width from armscye to armscye + + + Across Back Chest, from armfold to armfold + Full measurement description + Ширина спини + + + Distance between BustPoints, across Chest + Full measurement description + Відстань між сосковими точками + + + Distance from Bustpoint, behind neck, down to Bustpoint + Full measurement description + Distance from Bustpoint, behind neck, down to Bustpoint + + + From NeckPoint to BustPoint + Full measurement description + Відстань від точки основи шиї збоку до соскової точки (висота грудей) + + + From Front Waist Center, down to crotch, up to Back Waist Center + Full measurement description + From Front Waist Center, down to crotch, up to Back Waist Center + + + Sit on hard chair, measure from side waist straight down to chair bottom + Full measurement description + Відстань від лінії талії до під сідничної складки + + + Vertical Distance from NeckPoint level to ShoulderTip level + Full measurement description + Vertical Distance from NeckPoint level to ShoulderTip level + + + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + Full measurement description + Degrees of angle from NeckPoint to ShoulderTip – requires goniometer + + + ShoulderTip to Front Waist Center + Full measurement description + ShoulderTip to Front Waist Center + + + ShoulderTip to Back Waist Center + Full measurement description + ShoulderTip to Back Waist Center + + + NeckPoint straight down front chest to Waistline + Full measurement description + NeckPoint straight down front chest to Waistline + + + Back NeckPoint straight down back chest to Waistline + Full measurement description + Back NeckPoint straight down back chest to Waistline + + + NeckPoint to NeckPoint through Front Neck Center + Full measurement description + NeckPoint to NeckPoint through Front Neck Center + + + NeckPoint to NeckPoint across Nape + Full measurement description + NeckPoint to NeckPoint across Nape + + + front_upper-bust_arc + Full measurement description + front_upper-bust_arc + + + Front upper-bust arc + Full measurement description + Front upper-bust arc + + + Back UpperBust side to side + Full measurement description + Back UpperBust side to side + + + Front Waist side to side + Full measurement description + Front Waist side to side + + + Back Waist side to side + Full measurement description + Back Waist side to side + + + Front UpperHip side to side + Full measurement description + Front UpperHip side to side + + + Back UpperHip side to side + Full measurement description + Back UpperHip side to side + + + Front Hip side to side + Full measurement description + Front Hip side to side + + + Back Hip side to side + Full measurement description + Back Hip side to side + + + NeckPoint to Front ArmfoldPoint + Full measurement description + NeckPoint to Front ArmfoldPoint + + + NeckPoint to Back ArmfoldPoint + Full measurement description + NeckPoint to Back ArmfoldPoint + + + NeckPoint across Front Chest to Waist side + Full measurement description + NeckPoint across Front Chest to Waist side + + + NeckPoint across Back Chest to Waist side + Full measurement description + NeckPoint across Back Chest to Waist side + + + Front Neck Center straight down to UpperChest line + Full measurement description + Front Neck Center straight down to UpperChest line + + + Front Neck Center straight down to Bust line + Full measurement description + Front Neck Center straight down to Bust line + + + Front Upper chest waist + Full measurement description + Довжина переду від лінії талії вгору по центру до початку ложбини + + + Front waist to lower breast + Full measurement description + Довжина від талії до основи грудних залоз + + + Back waist to upper chest + Full measurement description + Довжина спинки по спині від лінії талії вверх до виступаючого кута лопатки + + + Strap length + Full measurement description + Довжина бретелі від виступаючого куточка лопатки вертикально до початку грудної залози + + + Around Armscye + Full measurement description + Around Armscye + + + Around Elbow with elbow bent + Full measurement description + Обхват локтя + + + Around UpperArm + Full measurement description + Обхват плеча + + + Around Wrist + Full measurement description + Обхват зап'ястя + + + Nape straight down to UnderBust line (same as Back UpperBust height) + Full measurement description + Nape straight down to UnderBust line (same as Back UpperBust height) + + + NeckPoint to ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Відстань від точки основи шиї збоку до лінії обхвату зап'ястя + + + Armpit to Wrist, with arm straight and hanging at side + Full measurement description + Внутрішня довжина рукава (з окатом) + + + Nape to Wrist, with elbow bent and hand on hip + Full measurement description + Nape to Wrist, with elbow bent and hand on hip + + + ShoulderTip to Elbow, with elbow bent and hand on hip + Full measurement description + Довжина руки до локтя + + + ShoulderTip to Wrist, with elbow bent and hand on hip + Full measurement description + Довжина рукава до лінії обхвату зап'ястя + + + Hand side to side + Full measurement description + Рука з боку в бік + + + Hand Middle Finger tip to wrist + Full measurement description + Hand Middle Finger tip to wrist + + + Around Hand + Full measurement description + Обхват кисті + + + Around Thigh + Full measurement description + Обхват стегна + + + Around MidThigh + Full measurement description + Around MidThigh + + + Around Knee + Full measurement description + Обхват коліна + + + Around Calf + Full measurement description + Обхват ікри + + + Around Ankle + Full measurement description + Обхват щиколотки + + + Knee to Floor + Full measurement description + Висота колінної точки + + + Ankle to Floor + Full measurement description + Ankle to Floor + + + Widest part of Foot side to side + Full measurement description + Widest part of Foot side to side + + + Tip of Longest Toe straight to back of heel + Full measurement description + Кінчик довгого пальця прямо до задньої частини каблука + + + Top of head to floor + Full measurement description + Верх голови до підлоги + + + Nape to Floor + Full measurement description + Висота точки основи шиї ззаду + + + Nape to Knee + Full measurement description + Довжина з потилицю до коліна + + + Waist side to floor + Full measurement description + Висота лінії талії + + + HighHip side to Floor + Full measurement description + HighHip side to Floor + + + Hip side to Floor + Full measurement description + Бічна сторона ступні + + + Waist side to Hip + Full measurement description + Waist side to Hip + + + Waist side to Knee + Full measurement description + Waist side to Knee + + + Crotch to Floor along inside leg + Full measurement description + Довжина ноги по внутрішній поверхні + + + Size + Full measurement description + Розмір + + + Height of the point base of the neck in front + Full measurement description + Висота точки основи шиї спереду + + + Height of the base of the neck side point + Full measurement description + Висота точки основи шиї збоку + + + The height of the shoulder point + Full measurement description + Висота плечової точки + + + Height nipple point + Full measurement description + Висота соскової точки + + + Height back angle axilla + Full measurement description + Висота заднього кута пахвової западини + + + Height scapular point + Full measurement description + Висота лопаточной точки + + + Height under buttock folds + Full measurement description + Висота під сідничної складки + + + Hips excluding protruding abdomen + Full measurement description + Обхват стегон без урахування виступу живота + + + Girth foot instep + Full measurement description + Обхват підйому стопи + + + The distance from the side waist to floor + Full measurement description + Відстань від лінії талії до підлоги збоку + + + The distance from the front waist to floor + Full measurement description + Відстань від лінії талії до підлоги спереду + + + Arc through groin area + Full measurement description + Дуга через пахову область + + + The distance from the waist to the plane seat + Full measurement description + Відстань від лінії талії до площини сидіння + + + The distance from the base of the neck to the side of the radial point + Full measurement description + Відстань від точки основи шиї збоку до променевої точки + + + Distance from the base of the neck side point to the end of the third finger + Full measurement description + Відстань від точки основи шиї збоку до кінця третього пальця + + + The distance from the base of the neck to the side of the first line in front of chest circumference + Full measurement description + Відстань від точки основи шиї збоку до лінії обхвату грудей першого спереду + + + The distance from the base of the neck to the waist side front (waist length in the front) + Full measurement description + Відстань від точки основи шиї збоку до лінії талії спереду (обхват талії спереду) + + + Arc through the highest point of the shoulder joint + Full measurement description + Дуга через вищу точку плечового суглоба + + + The distance from the base of the neck to the back line of chest circumference of the first and the second based on ledge vanes + Full measurement description + Відстань від точки основи шиї ззаду до лінії обхватів грудей першого і другого з урахуванням виступу лопаток + + + The distance from the waist to the back base of the neck side point + Full measurement description + Відстань від лінії талії ззаду до точки основи шиї збоку + + + Arc length of the upper body through the base of the neck side point + Full measurement description + Довжина дуги верхньої частини тулуба через точку підстави шиї збоку + + + Chest width + Full measurement description + Ширина грудей + + + Anteroposterior diameter of the hands + Full measurement description + Передньо-задній діаметр руки + + + Height clavicular point + Full measurement description + Висота ключичної точки + + + The distance from the point to the cervical level of the posterior angle of the front armpit (underarm height oblique) + Full measurement description + Відстань від шийної точки до рівня заднього кута пахвової западини спереду (коса висота пройми) + + + Slash shoulder height + Full measurement description + Коса висота плеча + + + Half girth neck + Full measurement description + Півобхват шиї + + + Half girth neck for shirts + Full measurement description + Півобхват шиї для сорочок + + + Half girth chest first + Full measurement description + Півобхват грудей перший + + + Half girth chest second + Full measurement description + Півобхват грудей другий + + + Half girth chest third + Full measurement description + Півобхват грудей третій + + + Half girth waist + Full measurement description + Півобхват талії + + + Half girth hips considering protruding abdomen + Full measurement description + Півобхват стегон з урахуванням виступу живота + + + Half girth hips excluding protruding abdomen + Full measurement description + Півобхват стегон без урахування виступу живота + + + Girth knee flexed feet + Full measurement description + Обхват коліна в зігнутому положенні ноги + + + Neck transverse diameter + Full measurement description + Поперечний діаметр шиї + + + Front slash shoulder height + Full measurement description + Коса висота плеча переду + + + The distance from the base of the neck to the waist line front + Full measurement description + Відстань від точки основи шиї до лінії талії спереду + + + Hand vertical diameter + Full measurement description + Вертикальний діаметр руки + + + Distance from neck to knee point + Full measurement description + Відстань від шийної точки до коліна + + + The distance from the waist to the knee + Full measurement description + Відстань від лінії талії до коліна + + + Shoulder height + Full measurement description + Висота плеча + + + Head height + Full measurement description + Висота голови + + + Body position + Full measurement description + Положення корпусу + + + Arc behind the shoulder girdle + Full measurement description + Дуга плечового пояса ззаду + + + Distance from neck point to point on the base of the neck side neck girth measurement line + Full measurement description + Відстань від шийної точки до точки основи шиї збоку по лінії вимірювання обхвату шиї + + + Depth waist first + Full measurement description + Глибина талії перша + + + Depth waist second + Full measurement description + Глибина талії друга + + + + MeasurementsFullNames + + Head girth + Full measurement name + Обхват голови + + + Mid-neck girth + Full measurement name + Половина обхвата шиї + + + Neck Base girth + Full measurement name + Обхват шиї + + + Head and Neck length + Full measurement name + Довжина шиї і голови + + + Front Center length + Full measurement name + Довжина переду до талії + + + Back Center length + Full measurement name + Довжина спини до талії з урахуванням виступу лопаток + + + Shoulder length + Full measurement name + Довжина плечового ската + + + Side Waist length + Full measurement name + Довжина бічної частини + + + Trunk length + Full measurement name + Довжина тулуба + + + Shoulder girth + Full measurement name + Обхват плеча + + + Upper Chest girth + Full measurement name + Обхват грудей перший + + + Bust girth + Full measurement name + Обхват грудей другий + + + Under Bust girth + Full measurement name + Обхват грудей третій + + + Waist girth + Full measurement name + Обхват талії + + + HighHip girth + Full measurement name + HighHip girth + + + Hip girth + Full measurement name + Обхват стегон з урахуванням виступу живота + + + Front Upper Chest width + Full measurement name + Ширина грудей перша + + + Front Chest width + Full measurement name + Ширина грудей друга + + + Front Across Shoulder width + Full measurement name + Плечевий діаметр + + + Back Across Shoulder width + Full measurement name + Back Across Shoulder width + + + Back Upper Chest width + Full measurement name + Back Upper Chest width + + + Back Chest width + Full measurement name + Ширина спини + + + BustPoint to BustPoint + Full measurement name + Відстань між сосковими точками + + + Halter Bustpoint to Bustpoint + Full measurement name + Halter Bustpoint to Bustpoint + + + NeckPoint to BustPoint + Full measurement name + Відстань від точки основи шиї збоку до соскової точки (висота грудей) + + + Crotch length + Full measurement name + Довжина промежини + + + Rise height + Full measurement name + Відстань від лінії талії до под'ягодічной складки + + + Shoulder Drop + Full measurement name + Shoulder Drop + + + Shoulder Slope degrees + Full measurement name + Схил плеча в градусах + + + Front Shoulder Balance + Full measurement name + Передній баланс плеча + + + Back Shoulder Balance + Full measurement name + Задній баланс плеча + + + Front Full Length + Full measurement name + Повна передня довжина + + + Back Full Length + Full measurement name + Повна задня довжина + + + Front Neck arc + Full measurement name + Передня дуга шиї + + + Back Neck arc + Full measurement name + Задня дуга шиї + + + Front upper-bust arc + Full measurement name + Front upper-bust arc + + + Back UpperBust arc + Full measurement name + Back UpperBust arc + + + Front Waist arc + Full measurement name + Передня дуга талії + + + Back Waist arc + Full measurement name + Задня дуга талії + + + Front UpperHip arc + Full measurement name + Front UpperHip arc + + + Back UpperHip arc + Full measurement name + Back UpperHip arc + + + Front Hip arc + Full measurement name + Front Hip arc + + + Back Hip arc + Full measurement name + Back Hip arc + + + Chest Balance + Full measurement name + Баланс грудей + + + Back Balance + Full measurement name + Задній баланс + + + Front Waist Balance + Full measurement name + Передній баланс талії + + + Back Waist Balance + Full measurement name + Задній баланс талії + + + Front UpperChest height + Full measurement name + Front UpperChest height + + + Bust height + Full measurement name + Висота бюста + + + Front Upper chest waist + Full measurement name + Довжина переду від лінії талії вгору по центру до початку улоговини + + + Front waist to lower breast + Full measurement name + Довжина від талії до підстави грудних залоз + + + Back waist to upper chest + Full measurement name + Довжина спинки + + + Strap length + Full measurement name + Довжина бретелі + + + Armscye Girth + Full measurement name + Armscye Girth + + + Elbow Girth + Full measurement name + Обхват локтя + + + Upperarm Girth + Full measurement name + Обхват плеча + + + Wrist girth + Full measurement name + Обхват зап'ястя + + + Armscye depth + Full measurement name + Armscye depth + + + Shoulder and Arm length + Full measurement name + Відстань від точки основи шиї збоку до лінії обхвату зап'ястя + + + Underarm length + Full measurement name + Внутрішня довжина рукава (з окатом) + + + Nape to wrist length + Full measurement name + Nape to wrist length + + + Elbow length + Full measurement name + Довжина руки до ліктя + + + Arm length + Full measurement name + Довжина рукава до лінії обхвату зап'ястя + + + Hand width + Full measurement name + Ширина руки + + + Hand length + Full measurement name + Довжина руки + + + Hand girth + Full measurement name + Обхват кисті + + + Thigh girth + Full measurement name + Обхват стегна + + + Midthigh girth + Full measurement name + Midthigh girth + + + Knee girth + Full measurement name + Обхват коліна + + + Calf girth + Full measurement name + Обхват ікри + + + Ankle girth + Full measurement name + Обхват щиколотки + + + Knee height + Full measurement name + Висота колінної точки + + + Ankle height + Full measurement name + Висота щиколотки + + + Foot width + Full measurement name + Ширина ноги + + + Foot length + Full measurement name + Довжина ноги + + + Total Height + Full measurement name + Загальна висота + + + Nape height + Full measurement name + Висота точки основи шиї ззаду + + + Nape to knee height + Full measurement name + Потилиця до висоти коліна + + + Waist height + Full measurement name + Висота лінії талії + + + HighHip height + Full measurement name + HighHip height + + + Hip height + Full measurement name + Hip height + + + Waist to Hip height + Full measurement name + Waist to Hip height + + + Waist to Knee height + Full measurement name + Талія до висоти коліна + + + Crotch height/Inseam + Full measurement name + Довжина ноги по внутрішній поверхні + + + Size + Full measurement name + Розмір + + + Height front neck base point + Full measurement name + Висота точки основи шиї спереду + + + Height base neck side point + Full measurement name + Висота точки основи шиї збоку + + + Height shoulder point + Full measurement name + Висота плечової точки + + + Height nipple point + Full measurement name + Висота соскової точки + + + Height back angle axilla + Full measurement name + Висота заднього кута пахвової западини + + + Height scapular point + Full measurement name + Висота лопаточной точки + + + Height under buttock folds + Full measurement name + Висота под'ягодічной складки + + + Hips excluding protruding abdomen + Full measurement name + Обхват стегон без урахування виступу живота + + + Girth foot instep + Full measurement name + Обхват підйому стопи + + + Side waist to floor + Full measurement name + Відстань від лінії талії до підлоги збоку + + + Front waist to floor + Full measurement name + Відстань від лінії талії до підлоги спереду + + + Arc through groin area + Full measurement name + Дуга через пахову область + + + Waist to plane seat + Full measurement name + Відстань від лінії талії до площини сидіння + + + Neck to radial point + Full measurement name + Відстань від точки основи шиї збоку до променевої точки + + + Neck to third finger + Full measurement name + Відстань від точки основи шиї збоку до кінця третього пальця + + + Neck to first line chest circumference + Full measurement name + Відстань від точки основи шиї збоку до лінії обхвату грудей першого спереду + + + Front waist length + Full measurement name + Відстань від точки основи шиї збоку до лінії талії спереду (довжина талії спереду) + + + Arc through shoulder joint + Full measurement name + Дуга через вищу точку плечового суглоба + + + Neck to back line chest circumference + Full measurement name + Відстань від точки основи шиї ззаду до лінії обхватів грудей першого і другого з урахуванням виступу лопаток + + + Waist to neck side + Full measurement name + Відстань від лінії талії ззаду до точки основи шиї збоку + + + Arc length upper body + Full measurement name + Довжина дуги верхньої частини тулуба через точку підстави шиї збоку + + + Chest width + Full measurement name + Ширина грудей + + + Anteroposterior diameter hands + Full measurement name + Передньо-задній діаметр руки + + + Height clavicular point + Full measurement name + Висота ключичній точки + + + Height armhole slash + Full measurement name + Відстань від шийної точки до рівня заднього кута пахвової западини спереду (висота пройми коса) + + + Slash shoulder height + Full measurement name + Висота плеча коса + + + Half girth neck + Full measurement name + Полуобхват шиї + + + Half girth neck for shirts + Full measurement name + Полуобхват шиї для сорочок + + + Half girth chest first + Full measurement name + Напівобхват грудей перший + + + Half girth chest second + Full measurement name + Напівобхват грудей другий + + + Half girth chest third + Full measurement name + Напівобхват грудей третій + + + Half girth waist + Full measurement name + Полуобхват талії + + + Half girth hips considering protruding abdomen + Full measurement name + Полуобхват стегон з урахуванням виступу живота + + + Half girth hips excluding protruding abdomen + Full measurement name + Полуобхват стегон без урахування виступу живота + + + Girth knee flexed feet + Full measurement name + Обхват коліна в зігнутому положенні ноги + + + Neck transverse diameter + Full measurement name + Поперечний діаметр шиї + + + Front slash shoulder height + Full measurement name + Висота плеча коса спереду + + + Neck to front waist line + Full measurement name + Відстань від точки основи шиї до лінії талії спереду + + + Hand vertical diameter + Full measurement name + Вертикальний діаметр руки + + + Neck to knee point + Full measurement name + Відстань від шийної точки до коліна + + + Waist to knee + Full measurement name + Відстань від лінії талії до коліна + + + Shoulder height + Full measurement name + Висота плеча + + + Head height + Full measurement name + Висота голови + + + Body position + Full measurement name + Положення корпусу + + + Arc behind shoulder girdle + Full measurement name + Дуга плечового пояса ззаду + + + Neck to neck base + Full measurement name + Відстань від шийної точки до точки основи шиї збоку по лінії вимірювання обхвату шиї + + + Depth waist first + Full measurement name + Глибина талії перша + + + Depth waist second + Full measurement name + Глибина талії друга + + + + MoveLabel + + Move point label + Перемістити мітку точки + + + + MoveSPoint + + Move single point + Перемістити базову точку + + + + MoveSpline + + Move spline + Перемістити сплайн + + + + MoveSplinePath + + Move spline path + Перемістити складний сплайн + + + + PathPage + + Open Directory + Відкрити директорію + + + Path that use Valentina + Шлях, що використовує Валентина + + + Default + По замовчуванню + + + Edit + Редагувати + + + Type + Тип + + + Path + Шлях + + + Individual measurements + Індивідуальні мірки + + + Patterns + Лекала + + + + PatternPage + + User + Користувач + + + User name + Ім'я користувача + + + Graphical output + Графічний вивід + + + Use antialiasing + Використовувати згладжування + + + Undo + Відмінити + + + Count steps (0 - no limit) + Кількість кроків (0 - без обмежень) + + + Undone + Відмінити + + + Count steps + Кількість кроків + + + + PostfixOperators + + cm + centimeter + см + + + mm + millimeter + мм + + + in + inch + дюйм + + + + QCommandLineParser + + Displays version information. + Показати інформацію про версію. + + + Displays this help. + Показати цю довідку. + + + Unknown option '%1'. + Невідомий параметр '%1'. + + + Unknown options: %1. + Невідомі параметри: %1. + + + Missing value after '%1'. + Пропущено значення після '%1'. + + + Unexpected value after '%1'. + Неочікуване значення після '%1'. + + + [options] + [параметри] + + + Usage: %1 + Використання: %1 + + + Options: + Параметри: + + + Arguments: + Аргументи: + + + + QCoreApplication + + Based on Qt %1 (%2, %3 bit) + Базується на Qt %1 (%2, %3 bit) + + + + QObject + + Create new pattern piece to start working. + Створіть нове креслення для початку роботи. + + + Add node + Додати вузол + + + Move detail + Перемістити деталь + + + mm + мм + + + cm + см + + + inch + дюйми + + + Property + The text that appears in the first column header + Властивості + + + Value + The text that appears in the second column header + Значення + + + + QmuParserErrorMsg + + Unexpected token "$TOK$" found at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподіваний токен "$TOK$" знейдено в позиції $POS$. + + + Internal error + Math parser error messages. + Внутрішня помилка + + + Invalid function-, variable- or constant name: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Невірне ім'я функції, змінної або константи: "$TOK$". + + + Invalid binary operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Невірний ідентифікатор бінарного оператора: "$TOK$". + + + Invalid infix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Невірний ідентифікатор інфіксного оператора: "$TOK$". + + + Invalid postfix operator identifier: "$TOK$". + Math parser error messages. Left untouched "$TOK$" + Невірний ідентифікатор постфіксного оператора: "$TOK$". + + + Invalid pointer to callback function. + Math parser error messages. + Невірний покажчик на функцію зворотного виклику. + + + Expression is empty. + Math parser error messages. + Вираз порожній. + + + Invalid pointer to variable. + Math parser error messages. + Невірний покажчик на змінну. + + + Unexpected operator "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподіваний оператор "$TOK$" знайдено в позиції $POS$ + + + Unexpected end of expression at position $POS$ + Math parser error messages. Left untouched $POS$ + Несподіваний кінець виразу в положенні $POS$ + + + Unexpected argument separator at position $POS$ + Math parser error messages. Left untouched $POS$ + Несподіваний розділювач аргументів у позиції $POS$ + + + Unexpected parenthesis "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподівана дужка "$TOK$"в позиції $POS$ + + + Unexpected function "$TOK$" at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподівана функція "$TOK$"в позиції $POS$ + + + Unexpected value "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподіване значення "$TOK$" знайдено в позиції $POS$ + + + Unexpected variable "$TOK$" found at position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Несподівана змінна "$TOK$" знайдена в позиції $POS$ + + + Function arguments used without a function (position: $POS$) + Math parser error messages. Left untouched $POS$ + Аргументи функції використовуються без функції (позиція: $POS$) + + + Missing parenthesis + Math parser error messages. + Відсутня дужка + + + Too many parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Занадто багато параметрів для функції "$TOK$" у виразі в позиції $POS$ + + + Too few parameters for function "$TOK$" at expression position $POS$ + Math parser error messages. Left untouched "$TOK$" and $POS$ + Занадто мало параметрів для функції "$TOK$" у виразі в позиції $POS$ + + + Divide by zero + Math parser error messages. + Ділення на нуль + + + Domain error + Math parser error messages. + Помилка домену + + + Name conflict + Math parser error messages. + Конфлікт імені + + + Invalid value for operator priority (must be greater or equal to zero). + Math parser error messages. + Неправильне значення для визначення пріоритетів оператора (повинно бути більше або дорівнює нулю). + + + user defined binary operator "$TOK$" conflicts with a built in operator. + Math parser error messages. Left untouched "$TOK$" + назначений користувачем бінарний оператор "$TOK$" конфліктує з вбудованим оператором. + + + Unexpected string token found at position $POS$. + Math parser error messages. Left untouched $POS$ + Несподіваний рядковий токен, що знаходиться в позиції $POS$. + + + Unterminated string starting at position $POS$. + Math parser error messages. Left untouched $POS$ + Незавершений рядок, починаючи з позиції $POS$. + + + String function called with a non string type of argument. + Math parser error messages. + Функція, що приймає рядковий тип, викликана з не рядковим типом аргументу. + + + String value used where a numerical argument is expected. + Math parser error messages. + Рядкове значення використовується там, де очікується числовий параметр. + + + No suitable overload for operator "$TOK$" at position $POS$. + Math parser error messages. Left untouched "$TOK$" and $POS$ + Не знайдено підходящого перевантаження оператора "$TOK$"в позиції $POS$. + + + Function result is a string. + Math parser error messages. + Результат функції рядоковий. + + + Parser error. + Math parser error messages. + Помилка синтаксичного аналізу. + + + Decimal separator is identic to function argument separator. + Math parser error messages. + Десятковий роздільник ідентичний роздільнику аргументів функції. + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched $TOK$ + "$TOK$" оператор повинен передувати закриваючій дужці. + + + If-then-else operator is missing an else clause + Math parser error messages. Do not translate operator name. + Для оператора If-then-else відсутній пункт else + + + Misplaced colon at position $POS$ + Math parser error messages. Left untouched $POS$ + Неправильне положення двокрапки в позиції $POS$ + + + The "$TOK$" operator must be preceeded by a closing bracket. + Math parser error messages. Left untouched "$TOK$" + "$TOK$" оператор повинен передувати закриваючій дужці. + + + + RenamePP + + Rename pattern piece + Перейменувати лекало + + + + STDescriptions + + Standard figures of men 1st group, chest 100 cm + Standard table description + Типові фігури чоловіків 1ї повнотної групи, обхват грудей 100 см + + + + SaveDetailOptions + + Save detail option + Зберегти параметри деталі + + + + SaveToolOptions + + Save tool option + Зберегти параметри інструменту + + + + TableWindow + + Create a layout + Створити розкладку + + + Save + Зберегти + + + Save layout + Зберегти розкладку + + + Next + Наступний + + + Next detail + Наступна деталь + + + Turn + Повернути + + + Turn the detail 90 degrees + Повернути деталь на 90 градусів + + + Turn the detail 180 degrees + Повернути деталь на 180 градусів + + + Stop laying + Припинити укладання + + + Enlarge letter + Збільшити аркуш + + + Enlarge the length of the sheet + Збільшити довжину аркушу + + + Enlarge the length of sheet + Збільшити довжину аркушу + + + Reduce sheet + Зменшити аркуш + + + Reduce the length of the sheet + Зменшити довжину аркушу + + + Mirroring + Дзеркальне відображення + + + Zoom In + Збільшити + + + Zoom Out + Зменшити + + + Stop + Зупинити + + + 0 details left. + 0 деталей залишилось. + + + Collisions not found. + Колізії не знайдено. + + + %1 details left. + %1 деталей залишилось. + + + untitled + без імені + + + Svg files (*.svg) + Svg файли (*.svg) + + + PDF files (*.pdf) + Pdf файли (*.pdf) + + + Images (*.png) + Зображення (*.png) + + + PS files (*.ps) + Ps файл (*.ps) + + + EPS files (*.eps) + EPS файл (*.eps) + + + Collisions found. + Знайдено колізії. + + + Creating file '%1' failed! %2 + Створення файлу '%1' не вдалося! %2 + + + Critical error! + Критична помилка! + + + toolBar + Панель інструментів + + + Wavefront OBJ (*.obj) + Wavefront OBJ (*.obj) + + + + VAbstractConverter + + Error creation backup file: %1. + Помилка створення резервного файлу: %1. + + + Couldn't get version information. + Не вдалося отримати інформацію про версію. + + + Too many tags <%1> in file. + За надто багато тегів <%1> у файлі. + + + Version "%1" invalid. + Версія "%1" має неправильне значення. + + + Version "0.0.0" invalid. + Версія "0.0.0" не дійсне. + + + Invalid version. Minimum supported version is %1 + Не правильна весрія. Мінімально підтримувана %1 + + + Invalid version. Maximum supported version is %1 + Неправильна версія. Максимально підтримувана %1 + + + Error no unique id. + Помилка не унікальний id. + + + Could not change version. + Не давлося змінити версію. + + + + VAbstractNode + + Can't find tag Modeling + Не можу знайти тег Modeling + + + + VAbstractTool + + Confirm the deletion. + Підтвердіть видалення. + + + Do you really want delete? + Ви дійсно хочете видалити? + + + + VApplication + + Error! + Помилка! + + + Error parsing file. Program will be terminated. + Помилка парсінгу файла. Програма буде закрита. + + + Error bad id. Program will be terminated. + Помилка неправильний id. Програма буде закрита. + + + Error can't convert value. Program will be terminated. + Помилка конвертації значення. Програма буде закрита. + + + Error empty parameter. Program will be terminated. + Помилка пустий параметр. Програма буде закрита. + + + Error wrong id. Program will be terminated. + Помилка неправильний id. Програма буде закрита. + + + Something's wrong!! + Щось не так!! + + + Could not copy temp file to document file + Не вдалося зкопіювати тимчасовий файл до файлу документа + + + Could not remove document file + Не вдалося видалити файл документа + + + Something wrong!! + Щось не так!! + + + + VArc + + Can't find id = %1 in table. + Не можу знайти id = %1 в таблиці. + + + Angle of arc can't be 0 degree. + Кут дуги не може бути 0 градусів. + + + + VContainer + + Can't find object + Не можу знайти об'єкт + + + Can't cast object + Не можу привести об'єкт + + + Can't find object. Type mismatch. + Не можу знайти об'єкт. Невідповідність типу. + + + + VDomDocument + + Can't find tool id = %1 in table. + Не можу знайти інструмент з id = %1 в таблиці. + + + Got wrong parameter id. Need only id > 0. + Отримано неправильний id. Допускаються тільки id > 0. + + + Can't convert toLongLong parameter + Не можу конвертувати toLongLong параметру + + + Can't convert toUInt parameter + Не можу конвертувати toUInt параметр + + + Can't convert toBool parameter + Не вдається перетворити параметр toBool + + + Got empty parameter + Отримано пустий параметр + + + Can't convert toDouble parameter + Не можу конвертувати toDouble параметру + + + Can't open file %1: +%2. + Не можу відкрити файл%1: +%2. + + + Can't open schema file %1: +%2. + Не можу відкрити файл схеми %1:\n%2. + + + Validation error file %3 in line %1 column %2 + Помилка валідації файлу %3 в рядку %1 стовпця %2 + + + Parsing error file %3 in line %1 column %2 + Помилка розбору файлу %3 в рядку %1 стовпця %2 + + + Couldn't get node + Не вдалося отримати вузол + + + This id is not unique. + Цей id не унікальний. + + + Error creating or updating detail + Помилка створення чи оновлення деталі + + + Error creating or updating single point + Помилка створення чи оновлення простої точки + + + Error creating or updating point of end line + Помилка створення чи оновлення точки кінця відрізку + + + Error creating or updating point along line + Помилка створення чи оновлення точки вздовж лінії + + + Error creating or updating point of shoulder + Помилка створення чи оновлення точки плеча + + + Error creating or updating point of normal + Помилка створення чи оновлення точки нормалі + + + Error creating or updating point of bisector + Помилка створення чи оновлення точки бісектриси + + + Error creating or updating point of lineintersection + Помилка створення чи оновлення точки перетину ліній + + + Error creating or updating point of contact + Помилка створення чи оновлення точки дотику + + + Error creating or updating modeling point + Помилка створення чи оновлення модельної точки + + + Error creating or updating height + Помилка створення чи оновлення висоти + + + Error creating or updating triangle + Помилка створення чи оновлення трикутника + + + Error creating or updating point of intersection + Помилка створення чи оновлення точки перетину + + + Error creating or updating cut spline point + Помилка створення чи оновлення точки розрізання кривої + + + Error creating or updating cut spline path point + Помилка створення чи оновлення точки розрізаня складної кривої + + + Error creating or updating cut arc point + Помилка створення чи оновлення точки розрізання дуги + + + Error creating or updating line + Помилка створення чи оновлення лінії + + + Error creating or updating simple curve + Помилка створення чи оновлення кривої + + + Error creating or updating curve path + Помилка створення чи оновлення шляху кривих + + + Error creating or updating modeling simple curve + Помилка створення чи оновлення модельної кривої + + + Error creating or updating modeling curve path + Помилка створення чи оновлення модельного шляху кривих + + + Error creating or updating simple arc + Помилка створення чи оновлення дуги + + + Error creating or updating modeling arc + Помилка створення чи оновлення модельної дуги + + + Error creating or updating union details + Помилка створення чи оновлення об'єднання деталей + + + Error! + Помилка! + + + Error parsing file. + Помилка парсингу файла. + + + Could not load schema file. + Не вдалося відкрити файл схеми. + + + Could not copy temp file to document file + Не вдалося зкопіювати тимчасовий файл до файлу документа + + + Could not remove document file + Не вдалося видалити файл документа + + + + VDrawTool + + Options + Параметри + + + Delete + Видалити + + + Can not find the element after which you want to insert. + Не можу знайти елемент після якого ви хочете вставити. + + + Can't find tag Calculation + Не можу знайти тег Calculation + + + Edit wrong formula + Редагувати неправильну формулу + + + + VException + + Critical error! + Критична помилка! + + + + VFormula + + Error + Помилка + + + + VFormulaProperty + + Value + Значення + + + Formula + Формула + + + + VFormulaPropertyEditor + + ... + ... + + + + VModelingTool + + Options + Параметри + + + Delete + Видалити + + + + VPE::VBoolProperty + + True + Вірно + + + False + Невірно + + + + VPE::VColorPropertyEditor + + ... + ... + + + + VPE::VFileEditWidget + + ... + ... + + + Directory + Директорія + + + Open File + Відкрити файл + + + + VPattern + + Can't find tool id = %1 in table. + Не можу знайти інструмент з id = %1 в таблиці. + + + Error no unique id. + Помилка не унікальний id. + + + Error! + Помилка! + + + Can't find tool in table. + Не можу знайти інструмент в таблиці. + + + Error parsing file. + Помилка парсингу файла. + + + Error can't convert value. + Помилка, не можу конвертувати значення. + + + Error empty parameter. + Помилка, пустий параметр. + + + Error wrong id. + Помикла, неправильний id. + + + Critical error! + Критична помилка! + + + Error parsing file (std::bad_alloc). + Помилка парсінгу файлу (std::bad_alloc). + + + Error creating or updating detail + Помилка створення чи оновлення деталі + + + Error creating or updating single point + Помилка створення чи оновлення простої точки + + + Error creating or updating point of end line + Помилка створення чи оновлення точки кінця відрізку + + + Error creating or updating point along line + Помилка створення чи оновлення точки вздовж лінії + + + Error creating or updating point of shoulder + Помилка створення чи оновлення точки плеча + + + Error creating or updating point of normal + Помилка створення чи оновлення точки нормалі + + + Error creating or updating point of bisector + Помилка створення чи оновлення точки бісектриси + + + Error creating or updating point of lineintersection + Помилка створення чи оновлення точки перетину ліній + + + Error creating or updating point of contact + Помилка створення чи оновлення точки дотику + + + Error creating or updating modeling point + Помилка створення чи оновлення модельної точки + + + Error creating or updating height + Помилка створення чи оновлення висоти + + + Error creating or updating triangle + Помилка створення чи оновлення трикутника + + + Error creating or updating point of intersection + Помилка створення чи оновлення точки перетину + + + Error creating or updating cut spline point + Помилка створення чи оновлення точки розрізання кривої + + + Error creating or updating cut spline path point + Помилка створення чи оновлення точки розрізаня складної кривої + + + Error creating or updating cut arc point + Помилка створення чи оновлення точки розрізання дуги + + + Error creating or updating point of intersection line and axis + Помилка створення чи оновлення точки перетину лінії і осі + + + Error creating or updating point of intersection curve and axis + Помилка створення чи оновлення точки перетину кривої і осі + + + Error creating or updating line + Помилка створення чи оновлення лінії + + + Error creating or updating simple curve + Помилка створення чи оновлення кривої + + + Error creating or updating curve path + Помилка створення чи оновлення шляху кривих + + + Error creating or updating modeling simple curve + Помилка створення чи оновлення модельної кривої + + + Error creating or updating modeling curve path + Помилка створення чи оновлення модельного шляху кривих + + + Error creating or updating simple arc + Помилка створення чи оновлення дуги + + + Error creating or updating modeling arc + Помилка створення чи оновлення модельної дуги + + + Error creating or updating union details + Помилка створення чи оновлення об'єднання деталей + + + Got wrong parameter id. Need only id > 0. + Отримано неправильний id. Допускаються тільки id > 0. + + + This id is not unique. + Цей id не унікальний. + + + File error. + Помилка файла. + + + + VPatternConverter + + Unexpected version "%1". + Неочікувана версія "%1". + + + Error restoring backup file: %1. + Помилка відновлення резервного файлу: %1. + + + + VSplinePath + + Not enough points to create the spline. + Не достатньо точок для створення кривої. + + + This spline does not exist. + Цей сплайн не існує. + + + Can't cut spline path with one point + Не можу розрізати складну криву що складається з одної точки + + + + VTableGraphicsView + + can't find detail + не можу знайти деталь + + + detail found + деталь знайдено + + + + VToolDetail + + Options + Параметри + + + Delete + Видалити + + + + VToolOptionsPropertyBrowser + + Base point + Базова точка + + + Point label + Ім'я точки + + + Position + Позиція + + + Point at distance and angle + Інструмент точка на кінці лінії + + + Line type + Тип лінії + + + Length + Довжина + + + Angle + Кут + + + Point at distance along line + Інструмент точка вздовж лінії + + + Arc + Дуга + + + Radius + Радіус + + + First angle + Перший кут + + + Second angle + Другий кут + + + Point along bisector + Інструмент точка бісектриси кута + + + Cut arc tool + Інструмент розрізання дуги + + + Tool for segmenting a curve + Інструмент для сегментації кривої + + + Tool segment a pathed curve + Інструмент для сегментації складної кривої + + + Perpendicular point along line + Перпендикулярна точка вздовж лінії + + + Line between points + Лінія між двома точками + + + Point at line intersection + Точка перетину ліній + + + Point along perpendicular + Інструмент точка перпендикуляра + + + Additional angle degrees + Дод. кут градуси + + + Point at intersection of arc and line + Точка на перетині дуги та лінії + + + Tool to make point from x & y of two other points + Інструменд для створення точки з двух х и у координат двух інших точок + + + Special point on shoulder + Спеціальна точка на плече + + + Curve tool + Інструмент крива + + + Curve factor + Коефіцієнт кривої + + + Tool for path curve + Інструмент для створення складної кривої + + + Tool triangle + Інструмент трикутник + + + Point intersection line and axis + Точка на перетині лінії і осі + + + + VToolTriangle + + Can't find point. + Не можу знайти точку. + + + + VToolUnionDetails + + Can't find tag Modeling + Не можу знайти тег Modeling + + + + Variables + + Line_ + Left symbol _ in name + Лінія_ + + + AngleLine_ + Left symbol _ in name + КутЛінії_ + + + Arc_ + Left symbol _ in name + Дуга_ + + + Spl_ + Left symbol _ in name + Спл_ + + + SplPath + Do not add symbol _ to the end of name + СкСпл + + + SplPath + Do not add symbol _ to enf of name + СкСпл + + + SplPath + СкСпл_ + + + + VisToolCurveIntersectAxis + + <b>Intersection curve and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>Перетин кривої і осі</b>: кут =%1°; <b>Shift</b> - фіксація кута, <b>Enter</b> - завершення створення + + + + VisToolEndLine + + <b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>Точка на кінці відрізка</b>: кут =%1°; <b>Shift</b> - фіксація кута, <b>Enter</b> - завершення створення + + + + VisToolLineIntersectAxis + + <b>Intersection line and axis</b>: angle = %1°; <b>Shift</b> - sticking angle, <b>Enter</b> - finish creation + <b>Перетин лінії і осі</b>: кут =%1°; <b>Shift</b> - фіксація кута, <b>Enter</b> - завершення створення + + + + VisToolSplinePath + + <b>Curve path</b>: <b>Enter</b> - finish creation + <b>Складна крива</b>: <b>Enter</b> - завершення створення + + + <b>Curved path</b>: select three or more points + <b>Складна крива</b>: виберіть три чи більше точок + + + <b>Curved path</b>: select three or more points, <b>Enter</b> - finish creation + <b>Складна крива</b>: виберіть три чи більше точок, <b>Enter</b> - завершення створення + + + + main + + Pattern making program. + Програма створення викрійок. + + + Pattern file. + Файл лекала. + + + diff --git a/share/valentina_code_style.xml b/share/valentina_code_style.xml new file mode 100644 index 000000000..7d866273c --- /dev/null +++ b/share/valentina_code_style.xml @@ -0,0 +1,39 @@ + + + + + + CodeStyleData + + false + false + true + false + false + false + true + false + true + false + false + false + true + true + false + true + false + false + false + 4 + true + true + 2 + true + 4 + + + + DisplayName + Valentina + + diff --git a/src/app/app.pri b/src/app/app.pri new file mode 100644 index 000000000..bfc1e20c3 --- /dev/null +++ b/src/app/app.pri @@ -0,0 +1,37 @@ +# Suport subdirectories. Just better project code tree. +include(container/container.pri) +include(dialogs/dialogs.pri) +include(geometry/geometry.pri) +include(tools/tools.pri) +include(widgets/widgets.pri) +include(xml/xml.pri) +include(undocommands/undocommands.pri) +include(visualization/visualization.pri) +include(core/core.pri) + +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +# Some source files +SOURCES += \ + $$PWD/main.cpp \ + $$PWD/mainwindow.cpp \ + $$PWD/tablewindow.cpp \ + $$PWD/stable.cpp \ + $$PWD/version.cpp \ + $$PWD/options.cpp + +# Some header files +HEADERS += \ + $$PWD/mainwindow.h \ + $$PWD/options.h \ + $$PWD/tablewindow.h \ + $$PWD/stable.h \ + $$PWD/version.h + +# Main forms +FORMS += \ + $$PWD/mainwindow.ui \ + $$PWD/tablewindow.ui + + diff --git a/src/app/app.pro b/src/app/app.pro new file mode 100644 index 000000000..2f2885803 --- /dev/null +++ b/src/app/app.pro @@ -0,0 +1,419 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-06-18T12:36:43 +# +#------------------------------------------------- + +# Compilation main binary file + +# File with common stuff for whole project +include(../../Valentina.pri) + +# Here we don't see "network" library, but, i think, "printsupport" depend on this library, so we still need this +# library in installer. +QT += core gui widgets xml svg printsupport xmlpatterns + +# We want create executable file +TEMPLATE = app + +# Name of binary file +TARGET = valentina + +# Use out-of-source builds (shadow builds) +CONFIG -= debug_and_release debug_and_release_target + +# We use C++11 standard +CONFIG += c++11 + +# Since Qt 5.4.0 the source code location is recorded only in debug builds. +# We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT. +DEFINES += QT_MESSAGELOGCONTEXT + +# Directory for executable file +DESTDIR = bin + +# Directory for files created moc +MOC_DIR = moc + +# Directory for objecs files +OBJECTS_DIR = obj + +# Directory for files created rcc +RCC_DIR = rcc + +# Directory for files created uic +UI_DIR = uic + +# Suport subdirectories. Just better project code tree. +include(app.pri) + +# This include path help promoute VMainGraphicsView on main window. Without it compiler can't find path to custom view +INCLUDEPATH += "$${PWD}/widgets" + +# Resource files. This files will be included in binary. +RESOURCES += \ + share/resources/icon.qrc \ # All other icons except cursors and Windows theme. + share/resources/cursor.qrc \ # Tools cursor icons. + share/resources/theme.qrc \ # Windows theme icons. + share/resources/measurements.qrc \ # For measurements files that we save as resource. + share/resources/flags.qrc + +# Compilation will fail without this files after we added them to this section. +OTHER_FILES += \ + share/resources/valentina.rc \ # For Windows system. + share/resources/icon/64x64/icon64x64.ico # Valentina's logo. + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +macx { + CONFIG(debug, debug|release){ + $$enable_ccache()# Use only in debug mode on Mac + } +} else { + $$enable_ccache() +} + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +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 Valentina.pri for more details. + + #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_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 Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + + #Calculate latest tag distance and build revision only in release mode. Change number each time requare + #recompilation precompiled headers file. + DEFINES += "LATEST_TAG_DISTANCE=0" + DEFINES += "BUILD_REVISION=\\\"uknown\\\"" +}else{ + # Release mode + DEFINES += V_NO_ASSERT + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + # 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 = + } + + #latest tag distance number for using in version + HG_DISTANCE=$$system(hg log -r tip --template '{latesttagdistance}') + isEmpty(HG_DISTANCE){ + HG_DISTANCE = 0 # if we can't find local revision left 0. + } + message("Latest tag distance:" $${HG_DISTANCE}) + DEFINES += "LATEST_TAG_DISTANCE=$${HG_DISTANCE}" # Make available latest tag distance number in sources. + + #build revision number for using in version + unix { + HG_HESH=$$system("hg log -r tip --template '{node|short}'") + } else { + # Use escape character before "|" on Windows + HG_HESH=$$system(hg log -r tip --template "{node^|short}") + } + isEmpty(HG_HESH){ + HG_HESH = "unknown" # if we can't find build revision left unknown. + } + message("Build revision:" $${HG_HESH}) + DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. +} + +# Some extra information about Qt. Can be usefull. +message(Qt version: $$[QT_VERSION]) +message(Qt is installed in $$[QT_INSTALL_PREFIX]) +message(Qt resources can be found in the following locations:) +message(Documentation: $$[QT_INSTALL_DOCS]) +message(Header files: $$[QT_INSTALL_HEADERS]) +message(Libraries: $$[QT_INSTALL_LIBS]) +message(Binary files (executables): $$[QT_INSTALL_BINS]) +message(Plugins: $$[QT_INSTALL_PLUGINS]) +message(Data files: $$[QT_INSTALL_DATA]) +message(Translation files: $$[QT_INSTALL_TRANSLATIONS]) +message(Settings: $$[QT_INSTALL_SETTINGS]) +message(Examples: $$[QT_INSTALL_EXAMPLES]) + +# Path to recource file. +win32:RC_FILE = share/resources/valentina.rc + +# Keep path to all files with standard measurements we support right now +INSTALL_STANDARD_MEASHUREMENTS += share/resources/tables/standard/GOST_man_ru.vst + +TRANSLATIONS_PATH = ../../share/translations + +# Add to this variable all translation files that you want install with program. +# For generation *.qm file first you need create *.ts. +# See section TRANSLATIONS in file ../../share/translations/translations.pro. +INSTALL_TRANSLATIONS += \ + $${TRANSLATIONS_PATH}/valentina_ru_RU.qm \ + $${TRANSLATIONS_PATH}/valentina_uk_UA.qm \ + $${TRANSLATIONS_PATH}/valentina_de_DE.qm \ + $${TRANSLATIONS_PATH}/valentina_cs_CZ.qm \ + $${TRANSLATIONS_PATH}/valentina_he_IL.qm \ + $${TRANSLATIONS_PATH}/valentina_fr_FR.qm \ + $${TRANSLATIONS_PATH}/valentina_it_IT.qm \ + $${TRANSLATIONS_PATH}/valentina_nl_NL.qm \ + $${TRANSLATIONS_PATH}/valentina_id_ID.qm + +# Set "make install" command for Unix-like systems. +unix{ + # Prefix for binary file. + isEmpty(PREFIX){ + PREFIX = $$DEFAULT_PREFIX + } + + unix:!macx{ + DATADIR =$$PREFIX/share + DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\" + + # Path to bin file after installation + target.path = $$PREFIX/bin + + # .desktop file + desktop.path = $$DATADIR/applications/ + desktop.files += ../../dist/$${TARGET}.desktop + + # logo + pixmaps.path = $$DATADIR/pixmaps/ + pixmaps.files += ../../dist/$${TARGET}.png \ + ../../dist/application-x-valentina-pattern.png + + # Path to translation files after installation + translations.path = $$DATADIR/$${TARGET}/translations/ + translations.files = $$INSTALL_TRANSLATIONS + + # Path to standard measurement after installation + standard.path = $$DATADIR/$${TARGET}/tables/standard/ + standard.files = $$INSTALL_STANDARD_MEASHUREMENTS + + INSTALLS += \ + target \ + desktop \ + pixmaps \ + translations \ + standard + } + macx{ + # Some macx stuff + QMAKE_MAC_SDK = macosx + + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 + # Path to resources in app bundle + RESOURCES_DIR = "Contents/Resources" + FRAMEWORKS_DIR = "Contents/Frameworks" + # On macx we will use app bundle. Bundle doesn't need bin directory inside. + # See issue #166: Creating OSX Homebrew (Mac OS X package manager) formula. + target.path = $$PREFIX/ + + # Copy in bundle translation files. + exists($${TRANSLATIONS_PATH}/valentina_ru_RU.qm){ + TRANSLATION_ru_RU.files += \ + $${TRANSLATIONS_PATH}/valentina_ru_RU.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_ru_RU.path = "$$RESOURCES_DIR/translations/ru_RU.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_ru_RU + } + + exists($${TRANSLATIONS_PATH}/valentina_uk_UA.qm){ + TRANSLATION_uk_UA.files += \ + $${TRANSLATIONS_PATH}/valentina_uk_UA.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_uk_UA.path = "$$RESOURCES_DIR/translations/uk_UA.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_uk_UA + } + + exists($${TRANSLATIONS_PATH}/valentina_de_DE.qm){ + TRANSLATION_de_DE.files += \ + $${TRANSLATIONS_PATH}/valentina_de_DE.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_de_DE.path = "$$RESOURCES_DIR/translations/de_DE.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_de_DE + } + + exists($${TRANSLATIONS_PATH}/valentina_cs_CZ.qm){ + TRANSLATION_cs_CZ.files += \ + $${TRANSLATIONS_PATH}/valentina_cs_CZ.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_cs_CZ.path = "$$RESOURCES_DIR/translations/cs_CZ.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_cs_CZ + } + + exists($${TRANSLATIONS_PATH}/valentina_he_IL.qm){ + TRANSLATION_he_IL.files += \ + $${TRANSLATIONS_PATH}/valentina_he_IL.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_he_IL.path = "$$RESOURCES_DIR/translations/he_IL.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_he_IL + } + + exists($${TRANSLATIONS_PATH}/valentina_fr_FR.qm){ + TRANSLATION_fr_FR.files += \ + $${TRANSLATIONS_PATH}/valentina_fr_FR.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_fr_FR.path = "$$RESOURCES_DIR/translations/fr_FR.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_fr_FR + } + + exists($${TRANSLATIONS_PATH}/valentina_it_IT.qm){ + TRANSLATION_it_IT.files += \ + $${TRANSLATIONS_PATH}/valentina_it_IT.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_it_IT.path = "$$RESOURCES_DIR/translations/it_IT.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_it_IT + } + + exists($${TRANSLATIONS_PATH}/valentina_nl_NL.qm){ + TRANSLATION_nl_NL.files += \ + $${TRANSLATIONS_PATH}/valentina_nl_NL.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_nl_NL.path = "$$RESOURCES_DIR/translations/nl_NL.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_nl_NL + } + + exists($${TRANSLATIONS_PATH}/valentina_id_ID.qm){ + TRANSLATION_id_ID.files += \ + $${TRANSLATIONS_PATH}/valentina_id_ID.qm \ + $${TRANSLATIONS_PATH}/Localizable.strings + TRANSLATION_id_ID.path = "$$RESOURCES_DIR/translations/id_ID.lproj" + QMAKE_BUNDLE_DATA += TRANSLATION_id_ID + } + + qmuparser.path = $$FRAMEWORKS_DIR + qmuparser.files = $${OUT_PWD}/../libs/qmuparser/$${DESTDIR}/ + qmuparser.files += $${OUT_PWD}/../libs/qmuparser/$${DESTDIR}/libqmuparser.2.dylib + vpropertyexplorer.path = $$FRAMEWORKS_DIR + vpropertyexplorer.files = $${OUT_PWD}/../libs/vpropertyexplorer/$${DESTDIR}/ + + + # logo on macx. + ICON = ../../dist/Valentina.icns + + # Copy to bundle standard measurements files + standard.path = $$RESOURCES_DIR/tables/standard/ + standard.files = $$INSTALL_STANDARD_MEASHUREMENTS + + QMAKE_BUNDLE_DATA += \ + standard \ + qmuparser \ + vpropertyexplorer + + } +} + +# Some systems use special name for lrelease. For example opensuse 13.2 has lrelease-qt5. +isEmpty(LRELEASE){ + LRELEASE = lrelease +} + +# Run generation *.qm file for available *.ts files each time you run qmake. +for(_translation_name, INSTALL_TRANSLATIONS) { + _translation_name_qm = $$basename(_translation_name) + _translation_name_ts = $$section(_translation_name_qm, ".", 0, 0).ts + + system($$shell_path($$[QT_INSTALL_BINS]/$$LRELEASE) -removeidentical -nounfinished $$shell_path($${PWD}/$${TRANSLATIONS_PATH}/$$_translation_name_ts) -qm $$shell_path($${PWD}/$$_translation_name)) +} + +for(DIR, INSTALL_TRANSLATIONS) { + #add these absolute paths to a variable which + #ends up as 'mkcommands = path1 path2 path3 ...' + + tr_path += $${PWD}/$$DIR +} + +# Make possible run program even you do not install it. Seek files in local directory. +copyToDestdir($$tr_path, $$shell_path($${OUT_PWD}/$$DESTDIR/translations)) + +for(DIR, INSTALL_STANDARD_MEASHUREMENTS) { + #add these absolute paths to a variable which + #ends up as 'mkcommands = path1 path2 path3 ...' + st_path += $${PWD}/$$DIR +} + +copyToDestdir($$st_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tables/standard)) + +# 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 + +# 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 + +# IFC static library +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 + +# VObj static library +unix|win32: LIBS += -L$$OUT_PWD/../libs/vobj/$${DESTDIR}/ -lvobj + +INCLUDEPATH += $$PWD/../libs/vobj +DEPENDPATH += $$PWD/../libs/vobj + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/vobj.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/libvobj.a + + +# Strip after you link all libaries. +CONFIG(release, debug|release){ + win32:!win32-msvc*{ + # Strip debug symbols. + QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg && + QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} && + QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET} + } + + unix:!macx{ + # Strip debug symbols. + QMAKE_POST_LINK += objcopy --only-keep-debug ${TARGET} ${TARGET}.dbg && + QMAKE_POST_LINK += objcopy --strip-debug ${TARGET} && + QMAKE_POST_LINK += objcopy --add-gnu-debuglink="${TARGET}.dbg" ${TARGET} + } +} + + + +macx{ + # run macdeployqt to include all qt libraries in packet + QMAKE_POST_LINK += $$[QT_INSTALL_BINS]/macdeployqt $${OUT_PWD}/$${DESTDIR}/$${TARGET}.app +} diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp new file mode 100644 index 000000000..175ec14a3 --- /dev/null +++ b/src/app/container/calculator.cpp @@ -0,0 +1,266 @@ +/************************************************************************ + ** + ** @file calculator.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "calculator.h" +#include +#include +#include "../core/vapplication.h" +#include "vcontainer.h" +#include "../core/vsettings.h" + +using namespace qmu; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Calculator class constructor. Make easy initialization math parser. + * + * This constructor hide initialization variables, operators, character sets. + * Use this constuctor for evaluation formula. All formulas must be converted to internal look. + * Example: + * + * const QString formula = qApp->FormulaFromUser(edit->text()); + * Calculator *cal = new Calculator(data); + * const qreal result = cal->EvalFormula(formula); + * delete cal; + * + * @param data pointer to a variable container. + */ +Calculator::Calculator(const VContainer *data) + :QmuParser(), vVarVal(nullptr), data(data) +{ + SCASSERT(data != nullptr) + InitCharacterSets(); + setAllowSubexpressions(false);//Only one expression per time + + SetSepForEval(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Calculator class constructor. Make easy initialization math parser. + * + * This constructor hide initialization variables, operators, character sets. + * Use this constuctor to get tokens from formula. All formulas must be converted to external look. + * Example: + * + * Calculator *cal = new Calculator(formula, false); + * tokens = cal->GetTokens(); + * numbers = cal->GetNumbers(); + * delete cal; + * + * @param formula string with formula. + * @param fromUser true if we parse formula from user + */ +Calculator::Calculator(const QString &formula, bool fromUser) + :QmuParser(), vVarVal(nullptr), data(nullptr) +{ + InitCharacterSets(); + setAllowSubexpressions(false);//Only one expression per time + SetVarFactory(AddVariable, this); + + SetSepForTr(fromUser); + + SetExpr(formula); + //Need run for making tokens. Don't catch exception here, because we want know if formula has error. + Eval(); +} + +//--------------------------------------------------------------------------------------------------------------------- +Calculator::~Calculator() +{ + delete [] vVarVal; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief eval calculate formula. + * @param formula string of formula. + * @return value of formula. + */ +qreal Calculator::EvalFormula(const QString &formula) +{ + SetVarFactory(AddVariable, this); + SetSepForEval();//Reset separators options + + SetExpr(formula); + + qreal result = 0; + result = Eval(); + + QMap tokens = this->GetTokens(); + + // Remove "-" from tokens list if exist. If don't do that unary minus operation will broken. + RemoveAll(tokens, QStringLiteral("-")); + + if (tokens.isEmpty()) + { + return result; + } + + // Add variables + InitVariables(data, tokens, formula); + return Eval(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Calculator::InitVariables(const VContainer *data, const QMap &tokens, const QString &formula) +{ + if (qApp->patternType() == MeasurementsType::Standard) + { + vVarVal = new qreal[2]; + } + + SCASSERT(data != nullptr) + const QHash > *vars = data->DataVariables(); + + QMap::const_iterator i = tokens.constBegin(); + while (i != tokens.constEnd()) + { + bool found = false; + if (vars->contains(i.value())) + { + QSharedPointer var = vars->value(i.value()); + if ((qApp->patternType() == MeasurementsType::Standard) && + (var->GetType() == VarType::Measurement || var->GetType() == VarType::Increment)) + { + QSharedPointer m = data->GetVariable(i.value()); + m->SetValue(data->size(), data->height()); + } + DefineVar(i.value(), var->GetValue()); + found = true; + } + + if (qApp->patternType() == MeasurementsType::Standard) + { + if (i.value() == data->SizeName()) + { + vVarVal[0] = data->size(); + DefineVar(data->SizeName(), &vVarVal[0]); + found = true; + } + + if (i.value() == data->HeightName()) + { + vVarVal[1] = data->height(); + DefineVar(data->HeightName(), &vVarVal[1]); + found = true; + } + } + + if (builInFunctions.contains(i.value())) + {// We found built-in function + found = true; + } + + if (found == false) + { + throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key()); + } + ++i; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void Calculator::InitCharacterSets() +{ + //String with all unique symbols for supported alpabets. + // See script alphabets.py for generation and more information. + //Note. MSVC doen't support normal string concatenation for long string. Thats why we use QStringList in this place. + QStringList symbols = QStringList() << "ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆جگĮаҳѕεشԶиһνԾрυلՆӝшËՎҔPÓՖXӛӟŞӣզhëծpóӞնxßվāŁЃֆĉЋ" + << "CŬđҐГΒęҘЛΚŘġҠУGاհЫدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփїІĈЎ" + << "ґĐΗЖҙĘȚΟОҡĠآΧЦتЮұİزηжԸغοоÁՀقχцÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċБӸēłΔҖ" + << "ЙŤěΜӜDСձģΤӰЩīņحҮбưԳصδHйԻŇμӲӴсՃمτƠщՋєLQŹՓŕÖYśÞaգĽæiŽիӓîqճöyջþĂօЄӦĊЌΑĒДҗј" + << "ΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇčŃЏĕӯЗΖEțŮĝПΞأĥ" + << "ثĹЧΦÆӳЯIسŲԵзζԽпξكՅÄчφNMՍӌяӢՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤک" + << "ЪƯخγвŅԴŪضλкԼĴσтÅՄنъÍՌRӕՔZÝŜbåդﻩjíլļrӵմzýռپêЅքćچЍďӱҒЕůėژșΘØҚНğńءΠFҢХħΨҪ" + << "ЭųįҶرҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝŻşҤӑâeէŐımկòuշÕúտŔ"; + + // Defining identifier character sets + DefineNameChars(QStringLiteral("0123456789_") + symbols.join("")); + DefineOprtChars(symbols.join("") + QStringLiteral("+-*^/?<>=#!$%&|~_")); +} + +//--------------------------------------------------------------------------------------------------------------------- +// Factory function for creating new parser variables +// This could as well be a function performing database queries. +qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData) +{ + Q_UNUSED(a_szName) + Q_UNUSED(a_pUserData) + + static qreal value = 0; + return &value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void Calculator::SetSepForEval() +{ + SetArgSep(','); + SetDecSep('.'); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Calculator::SetSepForTr(bool fromUser) +{ + if (fromUser) + { + const bool osSeparatorValue = qApp->getSettings()->GetOsSeparator(); + + if (osSeparatorValue) + { + QLocale loc = QLocale::system(); + SetDecSep(loc.decimalPoint().toLatin1()); + SetThousandsSep(loc.groupSeparator().toLatin1()); + SetArgSep(';'); + } + else + { + SetArgSep(','); + SetDecSep('.'); + } + } + else + { + + SetArgSep(','); + SetDecSep('.'); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void Calculator::RemoveAll(QMap &map, const QString &val) +{ + QList listKeys = map.keys(val); + if (listKeys.size() > 0) + { + for (int i = 0; i < listKeys.size(); ++i) + { + map.remove(listKeys.at(i)); + } + } +} diff --git a/src/app/container/calculator.h b/src/app/container/calculator.h new file mode 100644 index 000000000..c00cb2360 --- /dev/null +++ b/src/app/container/calculator.h @@ -0,0 +1,74 @@ +/************************************************************************ + ** + ** @file calculator.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 CALCULATOR_H +#define CALCULATOR_H + +#include "../../libs/qmuparser/qmuparser.h" + +class VContainer; + +/** + * @brief The Calculator class for calculation formula. + * + * Main purpose make easy evaluate value of formula and get tokens. + * Note. If created to many parser for different purpes in the same time parser can work wrong. + * Example: + * DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data); + * dialog->setFormula(formula); + * if (dialog->exec() == QDialog::Accepted) + * { + * formula = dialog->getFormula(); + * //Need delete dialog here because parser in dialog don't allow use correct separator for parsing here. + * //Don't know why. + * delete dialog; + * Calculator *cal = new Calculator(data); + * result = cal->EvalFormula(formula); + * delete cal;//Here can be memory leak, but dialog already check this formula and probability very low. + * } + */ +class Calculator:public qmu::QmuParser +{ +public: + Calculator(const VContainer *data); + Calculator(const QString &formula, bool fromUser = true); + ~Calculator(); + qreal EvalFormula(const QString &formula); +private: + Q_DISABLE_COPY(Calculator) + qreal *vVarVal; + const VContainer *data; + void InitVariables(const VContainer *data, const QMap &tokens, const QString &formula); + void InitCharacterSets(); + static qreal* AddVariable(const QString &a_szName, void *a_pUserData); + void SetSepForEval(); + void SetSepForTr(bool fromUser); + static void RemoveAll(QMap &map, const QString &val); +}; + +#endif // CALCULATOR_H diff --git a/src/app/container/container.pri b/src/app/container/container.pri new file mode 100644 index 000000000..e469485cb --- /dev/null +++ b/src/app/container/container.pri @@ -0,0 +1,38 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +SOURCES += \ + $$PWD/vcontainer.cpp \ + $$PWD/calculator.cpp \ + $$PWD/variables/vmeasurement.cpp \ + $$PWD/variables/vincrement.cpp \ + $$PWD/variables/vvariable.cpp \ + $$PWD/variables/vinternalvariable.cpp \ + $$PWD/variables/vlineangle.cpp \ + $$PWD/variables/varclength.cpp \ + $$PWD/variables/vcurvelength.cpp \ + $$PWD/variables/vlinelength.cpp \ + $$PWD/variables/vsplinelength.cpp \ + $$PWD/vformula.cpp + +HEADERS += \ + $$PWD/vcontainer.h \ + $$PWD/calculator.h \ + $$PWD/variables/vmeasurement.h \ + $$PWD/variables/vincrement.h \ + $$PWD/variables/vvariable.h \ + $$PWD/variables/vinternalvariable.h \ + $$PWD/variables/vlineangle.h \ + $$PWD/variables.h \ + $$PWD/variables/vcurvelength.h \ + $$PWD/variables/varclength.h \ + $$PWD/variables/vlinelength.h \ + $$PWD/variables/vsplinelength.h \ + $$PWD/variables/vinternalvariable_p.h \ + $$PWD/variables/vvariable_p.h \ + $$PWD/variables/vincrement_p.h \ + $$PWD/variables/vcurvelength_p.h \ + $$PWD/variables/vlineangle_p.h \ + $$PWD/variables/vlinelength_p.h \ + $$PWD/variables/vmeasurement_p.h \ + $$PWD/vformula.h diff --git a/src/app/container/variables.h b/src/app/container/variables.h new file mode 100644 index 000000000..b87530c5b --- /dev/null +++ b/src/app/container/variables.h @@ -0,0 +1,40 @@ +/************************************************************************ + ** + ** @file variables.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VARIABLES_H +#define VARIABLES_H + +#include "variables/vinternalvariable.h" +#include "variables/vmeasurement.h" +#include "variables/vincrement.h" +#include "variables/varclength.h" +#include "variables/vsplinelength.h" +#include "variables/vlinelength.h" +#include "variables/vlineangle.h" + +#endif // VARIABLES_H diff --git a/src/app/container/variables/varclength.cpp b/src/app/container/variables/varclength.cpp new file mode 100644 index 000000000..2015f14c7 --- /dev/null +++ b/src/app/container/variables/varclength.cpp @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file varclength.cpp + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 "varclength.h" +#include "../geometry/vabstractcurve.h" +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +VArcLength::VArcLength() + :VCurveLength() +{ + SetType(VarType::ArcLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcLength::VArcLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *arc) + :VCurveLength(id, parentId, arc) +{ + SetType(VarType::ArcLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcLength::VArcLength(const VArcLength &var) + :VCurveLength(var) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VArcLength &VArcLength::operator=(const VArcLength &var) +{ + if ( &var == this ) + { + return *this; + } + VCurveLength::operator=(var); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcLength::~VArcLength() +{} diff --git a/src/app/container/variables/varclength.h b/src/app/container/variables/varclength.h new file mode 100644 index 000000000..f56d7ddf3 --- /dev/null +++ b/src/app/container/variables/varclength.h @@ -0,0 +1,46 @@ +/************************************************************************ + ** + ** @file varclength.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VARCLENGTH_H +#define VARCLENGTH_H + +#include "vcurvelength.h" + +class VAbstractCurve; + +class VArcLength :public VCurveLength +{ +public: + VArcLength(); + VArcLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *arc); + VArcLength(const VArcLength &var); + VArcLength &operator=(const VArcLength &var); + virtual ~VArcLength(); +}; + +#endif // VARCLENGTH_H diff --git a/src/app/container/variables/vcurvelength.cpp b/src/app/container/variables/vcurvelength.cpp new file mode 100644 index 000000000..9205e7452 --- /dev/null +++ b/src/app/container/variables/vcurvelength.cpp @@ -0,0 +1,107 @@ +/************************************************************************ + ** + ** @file vcurvelength.cpp + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 "vcurvelength.h" +#include "vcurvelength_p.h" +#include "../core/vapplication.h" +#include "../geometry/vabstractcurve.h" + +//--------------------------------------------------------------------------------------------------------------------- +VCurveLength::VCurveLength() + :VInternalVariable(), d(new VCurveLengthData) +{ + SetType(VarType::Unknown); +} + +//--------------------------------------------------------------------------------------------------------------------- +VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve) + :VInternalVariable(), d(new VCurveLengthData(id, parentId)) +{ + SetType(VarType::Unknown); + SCASSERT(curve != nullptr); + SetName(curve->name()); + SetValue(qApp->fromPixel(curve->GetLength())); +} + +//--------------------------------------------------------------------------------------------------------------------- +VCurveLength::VCurveLength(const VCurveLength &var) + :VInternalVariable(var), d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VCurveLength &VCurveLength::operator=(const VCurveLength &var) +{ + if ( &var == this ) + { + return *this; + } + VInternalVariable::operator=(var); + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VCurveLength::~VCurveLength() +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VCurveLength::Filter(quint32 id) +{ + if (d->parentId != 0)//Do not check if value zero + {// Not all curves have parents. Only those who was created after cutting the parent curve. + return d->id == id || d->parentId == id; + } + else + { + return d->id == id; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VCurveLength::GetId() const +{ + return d->id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCurveLength::SetId(const quint32 &id) +{ + d->id = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VCurveLength::GetParentId() const +{ + return d->parentId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCurveLength::SetParentId(const quint32 &value) +{ + d->parentId = value; +} diff --git a/src/app/container/variables/vcurvelength.h b/src/app/container/variables/vcurvelength.h new file mode 100644 index 000000000..15d45f672 --- /dev/null +++ b/src/app/container/variables/vcurvelength.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file vcurvelength.h + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 VCURVELENGTH_H +#define VCURVELENGTH_H + +#include "vinternalvariable.h" + +class VAbstractCurve; +class VCurveLengthData; + +class VCurveLength : public VInternalVariable +{ +public: + VCurveLength(); + VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve); + VCurveLength(const VCurveLength &var); + VCurveLength &operator=(const VCurveLength &var); + virtual ~VCurveLength(); + + virtual bool Filter(quint32 id); + + quint32 GetId() const; + void SetId(const quint32 &id); + + quint32 GetParentId() const; + void SetParentId(const quint32 &value); +private: + QSharedDataPointer d; +}; + +#endif // VCURVELENGTH_H diff --git a/src/app/container/variables/vcurvelength_p.h b/src/app/container/variables/vcurvelength_p.h new file mode 100644 index 000000000..d4759e4a5 --- /dev/null +++ b/src/app/container/variables/vcurvelength_p.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vcurvelength_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VCURVELENGTH_P_H +#define VCURVELENGTH_P_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VCurveLengthData : public QSharedData +{ +public: + + VCurveLengthData() + :id(NULL_ID), parentId(NULL_ID) + {} + + VCurveLengthData(const quint32 &id, const quint32 &parentId) + :id(id), parentId(parentId) + {} + + VCurveLengthData(const VCurveLengthData &var) + :QSharedData(var), id(var.id), parentId(var.parentId) + {} + + virtual ~VCurveLengthData(); + + quint32 id; + quint32 parentId; +}; + +VCurveLengthData::~VCurveLengthData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VCURVELENGTH_P_H diff --git a/src/app/container/variables/vincrement.cpp b/src/app/container/variables/vincrement.cpp new file mode 100644 index 000000000..df9de9cfe --- /dev/null +++ b/src/app/container/variables/vincrement.cpp @@ -0,0 +1,98 @@ +/************************************************************************ + ** + ** @file vincrementtablerow.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vincrement.h" +#include "vincrement_p.h" +#include "../options.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VIncrement create enpty increment + */ +VIncrement::VIncrement() + :VVariable(), d(new VIncrementData) +{ + SetType(VarType::Increment); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VIncrementTableRow create increment + * @param name increment's name + * @param id id + * @param base value in base size and height + * @param ksize increment in sizes + * @param kheight increment in heights + * @param description description of increment + */ +VIncrement::VIncrement(const QString &name, quint32 id, qreal base, qreal ksize, qreal kheight, QString description) + :VVariable(name, base, ksize, kheight, description), d(new VIncrementData(id)) +{ + SetType(VarType::Increment); +} + +//--------------------------------------------------------------------------------------------------------------------- +VIncrement::VIncrement(const VIncrement &incr) + :VVariable(incr), d(incr.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VIncrement &VIncrement::operator=(const VIncrement &incr) +{ + if ( &incr == this ) + { + return *this; + } + VVariable::operator=(incr); + d = incr.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VIncrement::~VIncrement() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getId return id of row + * @return id + */ +quint32 VIncrement::getId() const +{ + return d->id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId set id of row + * @param value id + */ +void VIncrement::setId(const quint32 &value) +{ + d->id = value; +} diff --git a/src/app/container/variables/vincrement.h b/src/app/container/variables/vincrement.h new file mode 100644 index 000000000..e82806892 --- /dev/null +++ b/src/app/container/variables/vincrement.h @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file vincrementtablerow.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VINCREMENTTABLEROW_H +#define VINCREMENTTABLEROW_H + +#include "vvariable.h" + +class VIncrementData; + +/** + * @brief The VIncrement class keep data row of increment table + */ +class VIncrement :public VVariable +{ +public: + VIncrement(); + VIncrement(const QString &name, quint32 id, qreal base, qreal ksize, qreal kheight, + QString description = QString()); + VIncrement(const VIncrement &incr); + VIncrement &operator=(const VIncrement &incr); + virtual ~VIncrement(); + + quint32 getId() const; + void setId(const quint32 &value); +private: + QSharedDataPointer d; +}; + +#endif // VINCREMENTTABLEROW_H diff --git a/src/app/container/variables/vincrement_p.h b/src/app/container/variables/vincrement_p.h new file mode 100644 index 000000000..57eca4d99 --- /dev/null +++ b/src/app/container/variables/vincrement_p.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vincrement_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VINCREMENT_P_H +#define VINCREMENT_P_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VIncrementData : public QSharedData +{ +public: + + VIncrementData() + :id(NULL_ID) + {} + + VIncrementData(quint32 id) + :id(id) + {} + + VIncrementData(const VIncrementData &incr) + :QSharedData(incr), id(incr.id) + {} + + virtual ~VIncrementData(); + + /** @brief id each increment have unique identificator */ + quint32 id; +}; + +VIncrementData::~VIncrementData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VINCREMENT_P_H diff --git a/src/app/container/variables/vinternalvariable.cpp b/src/app/container/variables/vinternalvariable.cpp new file mode 100644 index 000000000..92c4a06a9 --- /dev/null +++ b/src/app/container/variables/vinternalvariable.cpp @@ -0,0 +1,110 @@ +/************************************************************************ + ** + ** @file vinternalvariable.cpp + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 "vinternalvariable.h" +#include "vinternalvariable_p.h" + +//--------------------------------------------------------------------------------------------------------------------- +VInternalVariable::VInternalVariable() + :d(new VInternalVariableData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VInternalVariable::VInternalVariable(const VInternalVariable &var) + :d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VInternalVariable &VInternalVariable::operator=(const VInternalVariable &var) +{ + if ( &var == this ) + { + return *this; + } + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VInternalVariable::~VInternalVariable() +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VInternalVariable::Filter(quint32 id) +{ + Q_UNUSED(id); + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VInternalVariable::IsNotUsed() const +{ + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VInternalVariable::GetValue() const +{ + return d->value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal *VInternalVariable::GetValue() +{ + return &d->value; +} + +void VInternalVariable::SetValue(const qreal &value) +{ + d->value = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VInternalVariable::GetName() const +{ + return d->name; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VInternalVariable::SetName(const QString &name) +{ + d->name = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +VarType VInternalVariable::GetType() const +{ + return d->type; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VInternalVariable::SetType(const VarType &type) +{ + d->type = type; +} diff --git a/src/app/container/variables/vinternalvariable.h b/src/app/container/variables/vinternalvariable.h new file mode 100644 index 000000000..505d7b771 --- /dev/null +++ b/src/app/container/variables/vinternalvariable.h @@ -0,0 +1,63 @@ +/************************************************************************ + ** + ** @file vinternalvariable.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VINTERNALVARIABLE_H +#define VINTERNALVARIABLE_H + +#include +#include +#include "../options.h" + +class VInternalVariableData; + +class VInternalVariable +{ +public: + VInternalVariable(); + VInternalVariable(const VInternalVariable &var); + VInternalVariable &operator=(const VInternalVariable &var); + virtual ~VInternalVariable(); + + qreal GetValue() const; + qreal* GetValue(); + void SetValue(const qreal &value); + + QString GetName() const; + void SetName(const QString &name); + + VarType GetType() const; + void SetType(const VarType &type); + + virtual bool Filter(quint32 id); + + virtual bool IsNotUsed() const; +private: + QSharedDataPointer d; +}; + +#endif // VINTERNALVARIABLE_H diff --git a/src/exception/vexceptionuniqueid.cpp b/src/app/container/variables/vinternalvariable_p.h similarity index 53% rename from src/exception/vexceptionuniqueid.cpp rename to src/app/container/variables/vinternalvariable_p.h index 9232d0ca7..eeb97d956 100644 --- a/src/exception/vexceptionuniqueid.cpp +++ b/src/app/container/variables/vinternalvariable_p.h @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file vexceptionuniqueid.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file vinternalvariable_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,28 +26,44 @@ ** *************************************************************************/ -#include "vexceptionuniqueid.h" +#ifndef VINTERNALVARIABLE_P_H +#define VINTERNALVARIABLE_P_H -#include +#include +#include "../options.h" -VExceptionUniqueId::VExceptionUniqueId(const QString &what, const QDomElement &domElement) - :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VInternalVariableData : public QSharedData { - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QTextStream stream(&tagText); - domElement.save(stream, 4); - tagName = domElement.tagName(); - lineNumber = domElement.lineNumber(); -} +public: -QString VExceptionUniqueId::ErrorMessage() const -{ - QString error = QString("ExceptionUniqueId: %1").arg(what); - return error; -} + VInternalVariableData() + :type(VarType::Unknown), value(0), name(QString()) + {} -QString VExceptionUniqueId::DetailedInformation() const -{ - QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText); - return detail; -} + VInternalVariableData(const VInternalVariableData &var) + :QSharedData(var), type(var.type), value(var.value), name(var.name) + {} + + virtual ~VInternalVariableData(); + + VarType type; + + /** @brief value variable's value */ + qreal value; + + QString name; +}; + +VInternalVariableData::~VInternalVariableData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VINTERNALVARIABLE_P_H diff --git a/src/app/container/variables/vlineangle.cpp b/src/app/container/variables/vlineangle.cpp new file mode 100644 index 000000000..aceba1c51 --- /dev/null +++ b/src/app/container/variables/vlineangle.cpp @@ -0,0 +1,101 @@ +/************************************************************************ + ** + ** @file vlineangle.cpp + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 "vlineangle.h" +#include "vlineangle_p.h" +#include "../geometry/vpointf.h" +#include "../core/vapplication.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VLineAngle::VLineAngle() + :VInternalVariable(), d(new VLineAngleData) +{ + SetType(VarType::LineAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +VLineAngle::VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id) + :VInternalVariable(), d(new VLineAngleData(p1Id, p2Id)) +{ + SetType(VarType::LineAngle); + + SCASSERT(p1 != nullptr); + SCASSERT(p2 != nullptr); + + SetName(QString(angleLine_+"%1_%2").arg(p1->name(), p2->name())); + SetValue(p1, p2); +} + +//--------------------------------------------------------------------------------------------------------------------- +VLineAngle::VLineAngle(const VLineAngle &var) + :VInternalVariable(var), d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VLineAngle &VLineAngle::operator=(const VLineAngle &var) +{ + if ( &var == this ) + { + return *this; + } + VInternalVariable::operator=(var); + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VLineAngle::~VLineAngle() +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VLineAngle::Filter(quint32 id) +{ + return id == d->p1Id || id == d->p2Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLineAngle::SetValue(const VPointF *p1, const VPointF *p2) +{ + SCASSERT(p1 != nullptr); + SCASSERT(p2 != nullptr); + VInternalVariable::SetValue(QLineF(p1->toQPointF(), p2->toQPointF()).angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VLineAngle::GetP1Id() const +{ + return d->p1Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VLineAngle::GetP2Id() const +{ + return d->p2Id; +} diff --git a/src/app/container/variables/vlineangle.h b/src/app/container/variables/vlineangle.h new file mode 100644 index 000000000..df93a48f6 --- /dev/null +++ b/src/app/container/variables/vlineangle.h @@ -0,0 +1,54 @@ +/************************************************************************ + ** + ** @file vlineangle.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VLINEANGLE_H +#define VLINEANGLE_H + +#include "vinternalvariable.h" + +class VPointF; +class VLineAngleData; + +class VLineAngle :public VInternalVariable +{ +public: + VLineAngle(); + VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id); + VLineAngle(const VLineAngle &var); + VLineAngle &operator=(const VLineAngle &var); + virtual ~VLineAngle(); + + virtual bool Filter(quint32 id); + void SetValue(const VPointF *p1, const VPointF *p2); + quint32 GetP1Id() const; + quint32 GetP2Id() const; +private: + QSharedDataPointer d; +}; + +#endif // VLINEANGLE_H diff --git a/src/app/container/variables/vlineangle_p.h b/src/app/container/variables/vlineangle_p.h new file mode 100644 index 000000000..d8c26ba96 --- /dev/null +++ b/src/app/container/variables/vlineangle_p.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vlineangle_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VLINEANGLE_P_H +#define VLINEANGLE_P_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VLineAngleData : public QSharedData +{ +public: + + VLineAngleData() + :p1Id(NULL_ID), p2Id(NULL_ID) + {} + + VLineAngleData(const quint32 &p1Id, const quint32 &p2Id) + :p1Id(p1Id), p2Id(p2Id) + {} + + VLineAngleData(const VLineAngleData &var) + :QSharedData(var), p1Id(var.p1Id), p2Id(var.p2Id) + {} + + virtual ~VLineAngleData(); + + quint32 p1Id; + quint32 p2Id; +}; + +VLineAngleData::~VLineAngleData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VLINEANGLE_P_H diff --git a/src/app/container/variables/vlinelength.cpp b/src/app/container/variables/vlinelength.cpp new file mode 100644 index 000000000..7146b3f23 --- /dev/null +++ b/src/app/container/variables/vlinelength.cpp @@ -0,0 +1,101 @@ +/************************************************************************ + ** + ** @file vlinelength.cpp + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 "vlinelength.h" +#include "vlinelength_p.h" +#include "../geometry/vpointf.h" +#include "../core/vapplication.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VLengthLine::VLengthLine() + :VInternalVariable(), d(new VLengthLineData) +{ + SetType(VarType::LineLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id) + :VInternalVariable(), d(new VLengthLineData(p1Id, p2Id)) +{ + SCASSERT(p1 != nullptr); + SCASSERT(p2 != nullptr); + + SetType(VarType::LineLength); + SetName(QString(line_+"%1_%2").arg(p1->name(), p2->name())); + SetValue(p1, p2); +} + +//--------------------------------------------------------------------------------------------------------------------- +VLengthLine::VLengthLine(const VLengthLine &var) + :VInternalVariable(var), d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VLengthLine &VLengthLine::operator=(const VLengthLine &var) +{ + if ( &var == this ) + { + return *this; + } + VInternalVariable::operator=(var); + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VLengthLine::~VLengthLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VLengthLine::Filter(quint32 id) +{ + return id == d->p1Id || id == d->p2Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLengthLine::SetValue(const VPointF *p1, const VPointF *p2) +{ + SCASSERT(p1 != nullptr); + SCASSERT(p2 != nullptr); + + VInternalVariable::SetValue(qApp->fromPixel(QLineF(p1->toQPointF(), p2->toQPointF()).length())); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VLengthLine::GetP1Id() const +{ + return d->p1Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VLengthLine::GetP2Id() const +{ + return d->p2Id; +} diff --git a/src/app/container/variables/vlinelength.h b/src/app/container/variables/vlinelength.h new file mode 100644 index 000000000..77311283c --- /dev/null +++ b/src/app/container/variables/vlinelength.h @@ -0,0 +1,54 @@ +/************************************************************************ + ** + ** @file vlinelength.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VLINELENGTH_H +#define VLINELENGTH_H + +#include "vinternalvariable.h" + +class VPointF; +class VLengthLineData; + +class VLengthLine :public VInternalVariable +{ +public: + VLengthLine(); + VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id); + VLengthLine(const VLengthLine &var); + VLengthLine &operator=(const VLengthLine &var); + virtual ~VLengthLine(); + + virtual bool Filter(quint32 id); + void SetValue(const VPointF *p1, const VPointF *p2); + quint32 GetP1Id() const; + quint32 GetP2Id() const; +private: + QSharedDataPointer d; +}; + +#endif // VLINELENGTH_H diff --git a/src/app/container/variables/vlinelength_p.h b/src/app/container/variables/vlinelength_p.h new file mode 100644 index 000000000..ac37bd5f4 --- /dev/null +++ b/src/app/container/variables/vlinelength_p.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vlinelength_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VLINELENGTH_P_H +#define VLINELENGTH_P_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VLengthLineData : public QSharedData +{ +public: + + VLengthLineData() + :p1Id(NULL_ID), p2Id(NULL_ID) + {} + + VLengthLineData(const quint32 &p1Id, const quint32 &p2Id) + :p1Id(p1Id), p2Id(p2Id) + {} + + VLengthLineData(const VLengthLineData &var) + :QSharedData(var), p1Id(var.p1Id), p2Id(var.p2Id) + {} + + virtual ~VLengthLineData(); + + quint32 p1Id; + quint32 p2Id; +}; + +VLengthLineData::~VLengthLineData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VLINELENGTH_P_H diff --git a/src/app/container/variables/vmeasurement.cpp b/src/app/container/variables/vmeasurement.cpp new file mode 100644 index 000000000..f71921b4e --- /dev/null +++ b/src/app/container/variables/vmeasurement.cpp @@ -0,0 +1,189 @@ +/************************************************************************ + ** + ** @file vstandardtablecell.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vmeasurement.h" +#include "vmeasurement_p.h" +#include "../core/vapplication.h" +#include "../xml/vabstractmeasurements.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMeasurement create empty measurement + */ +VMeasurement::VMeasurement() + :VVariable(), d(new VMeasurementData) +{ + SetType(VarType::Measurement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMeasurement create measurement for standard table + * @param name measurement's name + * @param base value in base size and height + * @param ksize increment in sizes + * @param kheight increment in heights + * @param gui_text shor tooltip for user + * @param description measurement full description + * @param tagName measurement's tag name in file + */ +VMeasurement::VMeasurement(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight, + const QString &gui_text, const QString &description, const QString &tagName) + :VVariable(name, base, ksize, kheight, description), d(new VMeasurementData(gui_text, tagName)) +{ + SetType(VarType::Measurement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMeasurement create measurement for individual table + * @param name measurement's name + * @param base value in base size and height + * @param gui_text shor tooltip for user + * @param description measurement full description + * @param tagName measurement's tag name in file + */ +VMeasurement::VMeasurement(const QString &name, const qreal &base, const QString &gui_text, const QString &description, + const QString &tagName) + :VVariable(name, base, description), d(new VMeasurementData(gui_text, tagName)) +{ + SetType(VarType::Measurement); +} + +//--------------------------------------------------------------------------------------------------------------------- +VMeasurement::VMeasurement(const VMeasurement &m) + :VVariable(m), d(m.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VMeasurement &VMeasurement::operator=(const VMeasurement &m) +{ + if ( &m == this ) + { + return *this; + } + VVariable::operator=(m); + d = m.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VMeasurement::~VMeasurement() +{} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList VMeasurement::ListHeights(QMap heights) +{ + QStringList list; + if (qApp->patternUnit() == Unit::Inch) + { + qWarning()<<"Standard table doesn't support inches."; + return list; + } + + QMap::const_iterator i = heights.constBegin(); + while (i != heights.constEnd()) + { + if (i.value() && i.key() != GHeights::ALL) + { + ListValue(list, static_cast(i.key())); + } + ++i; + } + + if (list.isEmpty()) + { + // from 92 cm to 194 cm + for (int i = 92; i<= 194; i = i+6) + { + ListValue(list, i); + } + } + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList VMeasurement::ListSizes(QMap sizes) +{ + QStringList list; + if (qApp->patternUnit() == Unit::Inch) + { + qWarning()<<"Standard table doesn't support inches."; + return list; + } + + QMap::const_iterator i = sizes.constBegin(); + while (i != sizes.constEnd()) + { + if (i.value() && i.key() != GSizes::ALL) + { + ListValue(list, static_cast(i.key())); + } + ++i; + } + + if (list.isEmpty()) + { + // from 22 cm to 56 cm + for (int i = 22; i<= 56; i = i+2) + { + ListValue(list, i); + } + } + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurement::ListValue(QStringList &list, qreal value) +{ + qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit()); + QString strVal = QString("%1").arg(val); + list.append(strVal); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetGuiText measurement name for tooltip + * @return measurement name + */ +QString VMeasurement::GetGuiText() const +{ + return d->gui_text; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VMeasurement::TagName() const +{ + return d->_tagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurement::setTagName(const QString &tagName) +{ + d->_tagName = tagName; +} diff --git a/src/app/container/variables/vmeasurement.h b/src/app/container/variables/vmeasurement.h new file mode 100644 index 000000000..98ac75f08 --- /dev/null +++ b/src/app/container/variables/vmeasurement.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vstandardtablecell.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VSTANDARDTABLEROW_H +#define VSTANDARDTABLEROW_H + +#include "vvariable.h" +#include "../options.h" + +#include + +class VMeasurementData; + +/** + * @brief The VMeasurement class keep data row of standard table + */ +class VMeasurement :public VVariable +{ +public: + VMeasurement(); + VMeasurement(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight, + const QString &gui_text = QString(), const QString &description = QString(), + const QString &TagName = QString()); + VMeasurement(const QString &name, const qreal &base, const QString &gui_text = QString(), + const QString &description = QString(), const QString &TagName = QString()); + VMeasurement(const VMeasurement &m); + VMeasurement &operator=(const VMeasurement &m); + virtual ~VMeasurement(); + + QString GetGuiText() const; + QString TagName() const; + void setTagName(const QString &TagName); + static QStringList ListHeights(QMap heights); + static QStringList ListSizes(QMap sizes); +private: + QSharedDataPointer d; + + static void ListValue(QStringList &list, qreal value); +}; + +#endif // VSTANDARDTABLEROW_H diff --git a/src/exception/vexceptionwrongparameterid.cpp b/src/app/container/variables/vmeasurement_p.h similarity index 52% rename from src/exception/vexceptionwrongparameterid.cpp rename to src/app/container/variables/vmeasurement_p.h index 14f5ab8ef..dec94e809 100644 --- a/src/exception/vexceptionwrongparameterid.cpp +++ b/src/app/container/variables/vmeasurement_p.h @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file vexceptionwrongparameterid.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file vmeasurement_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,27 +26,45 @@ ** *************************************************************************/ -#include "vexceptionwrongparameterid.h" -#include +#ifndef VMEASUREMENT_P_H +#define VMEASUREMENT_P_H -VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement) - :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) -{ - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QTextStream stream(&tagText); - domElement.save(stream, 4); - tagName = domElement.tagName(); - lineNumber = domElement.lineNumber(); -} +#include -QString VExceptionWrongParameterId::ErrorMessage() const -{ - QString error = QString("ExceptionWrongParameterId: %1").arg(what); - return error; -} +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif -QString VExceptionWrongParameterId::DetailedInformation() const +class VMeasurementData : public QSharedData { - QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); - return detail; -} +public: + + VMeasurementData() + :gui_text(QString()), _tagName(QString()) + {} + + VMeasurementData(const QString &gui_text, const QString &tagName) + :gui_text(gui_text), _tagName(tagName) + {} + + VMeasurementData(const VMeasurementData &m) + :QSharedData(m), gui_text(m.gui_text), _tagName(m._tagName) + {} + + virtual ~VMeasurementData(); + + /** @brief description description measurement */ + QString gui_text; + + QString _tagName; +}; + +VMeasurementData::~VMeasurementData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VMEASUREMENT_P_H diff --git a/src/app/container/variables/vsplinelength.cpp b/src/app/container/variables/vsplinelength.cpp new file mode 100644 index 000000000..2cb194c7e --- /dev/null +++ b/src/app/container/variables/vsplinelength.cpp @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file vsplinelength.cpp + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 "vsplinelength.h" +#include "../geometry/vabstractcurve.h" +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +VSplineLength::VSplineLength() + :VCurveLength() +{ + SetType(VarType::SplineLength); +} + +VSplineLength::VSplineLength(const quint32 &id, const quint32 &parentId, const QString &name, const qreal &value) + :VCurveLength() +{ + SetType(VarType::SplineLength); + SetName(name); + SetValue(value); + SetId(id); + SetParentId(parentId); +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplineLength::VSplineLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *path) + :VCurveLength(id, parentId, path) +{ + SetType(VarType::SplineLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplineLength::VSplineLength(const VSplineLength &var) + :VCurveLength(var) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VSplineLength &VSplineLength::operator=(const VSplineLength &var) +{ + if ( &var == this ) + { + return *this; + } + VCurveLength::operator=(var); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplineLength::~VSplineLength() +{} diff --git a/src/app/container/variables/vsplinelength.h b/src/app/container/variables/vsplinelength.h new file mode 100644 index 000000000..10b6448d2 --- /dev/null +++ b/src/app/container/variables/vsplinelength.h @@ -0,0 +1,47 @@ +/************************************************************************ + ** + ** @file vlengthspline.h + ** @author Roman Telezhynskyi + ** @date 28 7, 2014 + ** + ** @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) 2014 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 VSPLINESLENGTH_H +#define VSPLINESLENGTH_H + +#include "vcurvelength.h" + +class VAbstractCurve; + +class VSplineLength :public VCurveLength +{ +public: + VSplineLength(); + VSplineLength(const quint32 &id, const quint32 &parentId, const QString &name, const qreal &value); + VSplineLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *path); + VSplineLength(const VSplineLength &var); + VSplineLength &operator=(const VSplineLength &var); + virtual ~VSplineLength(); +}; + +#endif // VSPLINELENGTH_H diff --git a/src/app/container/variables/vvariable.cpp b/src/app/container/variables/vvariable.cpp new file mode 100644 index 000000000..83589a89c --- /dev/null +++ b/src/app/container/variables/vvariable.cpp @@ -0,0 +1,171 @@ +/************************************************************************ + ** + ** @file vvariable.cpp + ** @author Roman Telezhynskyi + ** @date 9 7, 2014 + ** + ** @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) 2014 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 "vvariable.h" +#include "vvariable_p.h" +#include "../core/vapplication.h" +#include "../xml/vabstractmeasurements.h" + +//--------------------------------------------------------------------------------------------------------------------- +VVariable::VVariable() + :VInternalVariable(), d(new VVariableData) +{ + VInternalVariable::SetValue(d->base); +} + +//--------------------------------------------------------------------------------------------------------------------- +VVariable::VVariable(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight, + const QString &description) + :VInternalVariable(), d(new VVariableData(base, ksize, kheight, description)) +{ + VInternalVariable::SetValue(d->base); + SetName(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +VVariable::VVariable(const QString &name, const qreal &base, const QString &description) + :d(new VVariableData(base, description)) +{ + VInternalVariable::SetValue(base); + SetName(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +VVariable::VVariable(const VVariable &var) + :VInternalVariable(var), d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VVariable &VVariable::operator=(const VVariable &var) +{ + if ( &var == this ) + { + return *this; + } + VInternalVariable::operator=(var); + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VVariable::~VVariable() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VVariable::SetValue(const qreal &size, const qreal &height) +{ + if (qApp->patternUnit() == Unit::Inch) + { + qWarning("Gradation doesn't support inches"); + return; + } + const qreal baseSize = VAbstractMeasurements::UnitConvertor(50.0, Unit::Cm, qApp->patternUnit()); + const qreal baseHeight = VAbstractMeasurements::UnitConvertor(176.0, Unit::Cm, qApp->patternUnit()); + const qreal sizeIncrement = VAbstractMeasurements::UnitConvertor(2.0, Unit::Cm, qApp->patternUnit()); + const qreal heightIncrement = VAbstractMeasurements::UnitConvertor(6.0, Unit::Cm, qApp->patternUnit()); + + // Formula for calculation gradation + const qreal k_size = ( size - baseSize ) / sizeIncrement; + const qreal k_height = ( height - baseHeight ) / heightIncrement; + VInternalVariable::SetValue(d->base + k_size * d->ksize + k_height * d->kheight); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VVariable::IsNotUsed() const +{ + if (qFuzzyCompare(d->base+1, 0+1) && qFuzzyCompare(d->ksize+1, 0+1) && qFuzzyCompare(d->kheight+1, 0+1)) + { + return true; + } + else + { + return false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetBase return value in base size and height + * @return value + */ +qreal VVariable::GetBase() const +{ + return d->base; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VVariable::SetBase(const qreal &value) +{ + d->base = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKsize return increment in sizes + * @return increment + */ +qreal VVariable::GetKsize() const +{ + return d->ksize; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VVariable::SetKsize(const qreal &value) +{ + d->ksize = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKheight return increment in heights + * @return increment + */ +qreal VVariable::GetKheight() const +{ + return d->kheight; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VVariable::SetKheight(const qreal &value) +{ + d->kheight = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VVariable::GetDescription() const +{ + return d->description; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VVariable::SetDescription(const QString &desc) +{ + d->description = desc; +} diff --git a/src/app/container/variables/vvariable.h b/src/app/container/variables/vvariable.h new file mode 100644 index 000000000..0d41d235c --- /dev/null +++ b/src/app/container/variables/vvariable.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vvariable.h + ** @author Roman Telezhynskyi + ** @date 9 7, 2014 + ** + ** @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) 2014 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 VVARIABLE_H +#define VVARIABLE_H + +#include "vinternalvariable.h" + +class VVariableData; + +class VVariable :public VInternalVariable +{ +public: + VVariable(); + VVariable(const QString &name, const qreal &base, const qreal &ksize = 0, const qreal &kheight = 0, + const QString &description = QString()); + VVariable(const QString &name, const qreal &base, const QString &description = QString()); + VVariable(const VVariable &var); + VVariable &operator=(const VVariable &var); + virtual ~VVariable(); + + qreal GetBase() const; + void SetBase(const qreal &value); + + qreal GetKsize() const; + void SetKsize(const qreal &value); + + qreal GetKheight() const; + void SetKheight(const qreal &value); + + QString GetDescription() const; + void SetDescription(const QString &desc); + + void SetValue(const qreal &size, const qreal &height); + + virtual bool IsNotUsed() const; +private: + QSharedDataPointer d; +}; + +#endif // VVARIABLE_H diff --git a/src/app/container/variables/vvariable_p.h b/src/app/container/variables/vvariable_p.h new file mode 100644 index 000000000..57dbb3812 --- /dev/null +++ b/src/app/container/variables/vvariable_p.h @@ -0,0 +1,81 @@ +/************************************************************************ + ** + ** @file vvariable_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VVARIABLE_P_H +#define VVARIABLE_P_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VVariableData : public QSharedData +{ +public: + + VVariableData() + :base(0), ksize(0), kheight(0), description(QString()) + {} + + VVariableData(const qreal &base, const qreal &ksize, const qreal &kheight, const QString &description) + :base(base), ksize(ksize), kheight(kheight), description(description) + {} + + VVariableData(const qreal &base, const QString &description) + :base(base), ksize(0), kheight(0), description(description) + {} + + VVariableData(const VVariableData &var) + :QSharedData(var), base(var.base), ksize(var.ksize), kheight(var.kheight), description(var.description) + {} + + virtual ~VVariableData(); + + /** @brief base value in base size and height */ + qreal base; + + /** @brief ksize increment in sizes */ + qreal ksize; + + /** @brief kgrowth increment in heights */ + qreal kheight; + + /** @brief description description of increment */ + QString description; +}; + +VVariableData::~VVariableData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VVARIABLE_P_H diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp new file mode 100644 index 000000000..4f3f755c9 --- /dev/null +++ b/src/app/container/vcontainer.cpp @@ -0,0 +1,557 @@ +/************************************************************************ + ** + ** @file vcontainer.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vcontainer.h" +#include +#include "../core/vapplication.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" +#include +#include +#include + +Q_LOGGING_CATEGORY(vCon, "v.container") + +quint32 VContainer::_id = NULL_ID; +qreal VContainer::_size = 50; +qreal VContainer::_height = 176; +QSet VContainer::uniqueNames = QSet(); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VContainer create empty container + */ +VContainer::VContainer() + :d(new VContainerData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = copy constructor + * @param data container + * @return copy container + */ +VContainer &VContainer::operator =(const VContainer &data) +{ + if ( &data == this ) + { + return *this; + } + d = data.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VContainer create container from another container + * @param data container + */ +VContainer::VContainer(const VContainer &data) + :d(data.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VContainer::~VContainer() +{ + ClearGObjects(); + ClearVariables(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetGObject returns a point by id + * @param id id of point + * @return point + */ +// cppcheck-suppress unusedFunction +const QSharedPointer VContainer::GetGObject(quint32 id)const +{ + return GetObject(d->gObjects, id); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetObject return object from container + * @param obj container + * @param id id of object + * @return Object + */ +template +const val VContainer::GetObject(const QHash &obj, key id) const +{ + if (obj.contains(id)) + { + return obj.value(id); + } + else + { + throw VExceptionBadId(tr("Can't find object"), id); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetDetail return detail by id + * @param id id of detail + * @return detail + */ +const VDetail VContainer::GetDetail(quint32 id) const +{ + if (d->details.contains(id)) + { + return d->details.value(id); + } + else + { + throw VExceptionBadId(tr("Can't find object"), id); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddGObject add new GObject to container + * @param obj new object + * @return return id of new object in container + */ +quint32 VContainer::AddGObject(VGObject *obj) +{ + SCASSERT(obj != nullptr); + QSharedPointer pointer(obj); + uniqueNames.insert(obj->name()); + return AddObject(d->gObjects, pointer); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddDetail add new detail to container + * @param detail new detail + * @return return id of new detail in container + */ +quint32 VContainer::AddDetail(VDetail detail) +{ + quint32 id = getNextId(); + d->details[id] = detail; + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getNextId generate next unique id + * @return next unique id + */ +quint32 VContainer::getNextId() +{ + _id++; + return _id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateId update id. If new id bigger when current save new like current. + * @param newId id + */ +void VContainer::UpdateId(quint32 newId) +{ + if (newId > _id) + { + _id = newId; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateObject update object in container + * @param obj container + * @param id id of existing object + * @param point object + */ +template +void VContainer::UpdateObject(QHash &obj, const quint32 &id, val point) +{ + Q_ASSERT_X(id > NULL_ID, Q_FUNC_INFO, "id = 0"); + SCASSERT(point.isNull() == false); + point->setId(id); + if (d->gObjects.contains(id)) + { + d->gObjects[id].clear(); + } + obj[id] = point; + UpdateId(id); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear clear data in container. Id will be 0. + */ +void VContainer::Clear() +{ + qCDebug(vCon)<<"Clearing container data."; + _id = NULL_ID; + + d->details.clear(); + ClearVariables(); + ClearGObjects(); + ClearUniqueNames(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClearObject points, splines, arcs, spline paths will be cleared. + */ +void VContainer::ClearGObjects() +{ + QHash >::iterator i; + for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i) + { + i.value().clear(); + } + d->gObjects.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::ClearCalculationGObjects() +{ + if (d->gObjects.size()>0) + { + QVector keys; + QHash >::iterator i; + for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i) + { + if (i.value()->getMode() == Draw::Calculation) + { + i.value().clear(); + keys.append(i.key()); + } + } + if (keys.size()>0) + { + for (int i = 0; i < keys.size(); ++i) + { + d->gObjects.remove(keys.at(i)); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::ClearVariables(const VarType &type) +{ + if (d->variables.size()>0) + { + if (type == VarType::Unknown) + { + QHash >::iterator i; + for (i = d->variables.begin(); i != d->variables.end(); ++i) + { + i.value().clear(); + } + d->variables.clear(); + } + else + { + QVector keys; + QHash >::iterator i; + for (i = d->variables.begin(); i != d->variables.end(); ++i) + { + if (i.value()->GetType() == type) + { + i.value().clear(); + keys.append(i.key()); + } + } + if (keys.size()>0) + { + for (int i = 0; i < keys.size(); ++i) + { + d->variables.remove(keys.at(i)); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddLine add line to container + * @param firstPointId id of first point of line + * @param secondPointId id of second point of line + */ +void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPointId) +{ + const QSharedPointer first = GeometricObject(firstPointId); + const QSharedPointer second = GeometricObject(secondPointId); + + VLengthLine *length = new VLengthLine(first.data(), firstPointId, second.data(), secondPointId); + AddVariable(length->GetName(), length); + + VLineAngle *angle = new VLineAngle(first.data(), firstPointId, second.data(), secondPointId); + AddVariable(angle->GetName(), angle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddObject add object to container + * @param obj container + * @param value object + * @return id of object in container + */ +template +quint32 VContainer::AddObject(QHash &obj, val value) +{ + SCASSERT(value != nullptr); + quint32 id = getNextId(); + value->setId(id); + obj[id] = value; + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateGObject update GObject by id + * @param id id of existing GObject + * @param obj object + */ +void VContainer::UpdateGObject(quint32 id, VGObject* obj) +{ + SCASSERT(obj != nullptr); + QSharedPointer pointer(obj); + UpdateObject(d->gObjects, id, pointer); + uniqueNames.insert(obj->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateDetail update detail by id + * @param id id of existing detail + * @param detail detail + */ +void VContainer::UpdateDetail(quint32 id, const VDetail &detail) +{ + Q_ASSERT_X(id > NULL_ID, Q_FUNC_INFO, "id = 0"); + d->details[id] = detail; + UpdateId(id); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VContainer::GetTableValue(const QString &name) const +{ + QSharedPointer m = GetVariable(name); + if (qApp->patternType() == MeasurementsType::Standard) + { + m->SetValue(size(), height()); + } + return *m->GetValue(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveIncrement remove increment by name from increment table + * @param name name of existing increment + */ +void VContainer::RemoveIncrement(const QString &name) +{ + d->variables[name].clear(); + d->variables.remove(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataMeasurements() const +{ + return DataVar(VarType::Measurement); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataIncrements() const +{ + return DataVar(VarType::Increment); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataLengthLines() const +{ + return DataVar(VarType::LineLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataLengthSplines() const +{ + return DataVar(VarType::SplineLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataLengthArcs() const +{ + return DataVar(VarType::ArcLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataAngleLines() const +{ + return DataVar(VarType::LineAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VContainer::IsUnique(const QString &name) +{ + return (!uniqueNames.contains(name) && !builInFunctions.contains(name)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VariableExist check if exist variable this same name. + * @param name name of row + * @return true if contains + */ +bool VContainer::VariableExist(const QString &name) +{ + return d->variables.contains(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +const QMap > VContainer::DataVar(const VarType &type) const +{ + QMap > map; + //Sorting QHash by id + QHash >::const_iterator i; + for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i) + { + if (i.value()->GetType() == type) + { + QSharedPointer var = GetVariable(i.key()); + map.insert(qApp->VarToUser(i.key()), var); + } + } + return map; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::ClearDetails() +{ + d->details.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::ClearUniqueNames() +{ + uniqueNames.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetSize set value of size + * @param size value of size + */ +void VContainer::SetSize(qreal size) +{ + _size = size; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::SetSizeName(const QString &name) +{ + d->sizeName = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetGrowth set value of growth + * @param height value of height + */ +void VContainer::SetHeight(qreal height) +{ + _height = height; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::SetHeightName(const QString &name) +{ + d->heightName = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief size return size + * @return size in mm + */ +qreal VContainer::size() +{ + return _size; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VContainer::SizeName() const +{ + return d->sizeName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief height return height + * @return height in pattern units + */ +qreal VContainer::height() +{ + return _height; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VContainer::HeightName() const +{ + return d->heightName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief data container with datagObjects return container of gObjects + * @return pointer on container of gObjects + */ +const QHash > *VContainer::DataGObjects() const +{ + return &d->gObjects; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief data container with dataDetails return container of details + * @return pointer on container of details + */ +const QHash *VContainer::DataDetails() const +{ + return &d->details; +} + +//--------------------------------------------------------------------------------------------------------------------- +const QHash > *VContainer::DataVariables() const +{ + return &d->variables; +} + +//--------------------------------------------------------------------------------------------------------------------- +VContainerData::~VContainerData() +{} diff --git a/src/app/container/vcontainer.h b/src/app/container/vcontainer.h new file mode 100644 index 000000000..cb40925d9 --- /dev/null +++ b/src/app/container/vcontainer.h @@ -0,0 +1,260 @@ +/************************************************************************ + ** + ** @file vcontainer.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VCONTAINER_H +#define VCONTAINER_H + +#include "variables.h" +#include "../geometry/vdetail.h" +#include "../geometry/vgobject.h" +#include "../libs/ifc/exception/vexceptionbadid.h" +#include "../geometry/vabstractcurve.h" + +#include +#include +#include +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VContainerData : public QSharedData +{ +public: + + VContainerData() + :sizeName(size_M), heightName(height_M), gObjects(QHash >()), + variables(QHash > ()), details(QHash()) + {} + + VContainerData(const VContainerData &data) + :QSharedData(data), sizeName(data.sizeName), heightName(data.heightName), gObjects(data.gObjects), + variables(data.variables), details(data.details) + {} + + virtual ~VContainerData(); + + QString sizeName; + QString heightName; + /** + * @brief gObjects graphicals objects of pattern. + */ + QHash > gObjects; + + /** + * @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths + */ + QHash> variables; + /** + * @brief details container of details + */ + QHash details; +}; + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +/** + * @brief The VContainer class container of all variables. + */ +class VContainer +{ + Q_DECLARE_TR_FUNCTIONS(VContainer) +public: + VContainer(); + VContainer &operator=(const VContainer &data); + VContainer(const VContainer &data); + ~VContainer(); + + template + const QSharedPointer GeometricObject(const quint32 &id) const + { + QSharedPointer gObj = QSharedPointer(); + if (d->gObjects.contains(id)) + { + gObj = d->gObjects.value(id); + } + else + { + throw VExceptionBadId(tr("Can't find object"), id); + } + + try + { + QSharedPointer obj = qSharedPointerDynamicCast(gObj); + SCASSERT(obj.isNull() == false); + return obj; + } + catch (const std::bad_alloc &) + { + throw VExceptionBadId(tr("Can't cast object"), id); + } + } + + const QSharedPointer GetGObject(quint32 id) const; + const VDetail GetDetail(quint32 id) const; + qreal GetTableValue(const QString& name) const; + template + /** + * @brief GetVariable return varible by name + * @param name variable's name + * @return variable + */ + QSharedPointer GetVariable(QString name) const + { + SCASSERT(name.isEmpty()==false); + if (d->variables.contains(name)) + { + try + { + QSharedPointer value = qSharedPointerDynamicCast(d->variables.value(name)); + SCASSERT(value.isNull() == false); + return value; + } + catch (const std::bad_alloc &) + { + throw VExceptionBadId(tr("Can't cast object"), name); + } + } + else + { + throw VExceptionBadId(tr("Can't find object"), name); + } + } + + static quint32 getId(){return _id;} + static quint32 getNextId(); + static void UpdateId(quint32 newId); + + quint32 AddGObject(VGObject *obj); + quint32 AddDetail(VDetail detail); + void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); + + template + /** + * @brief AddCurveLength add length of curve type to the container + * @param id id of variables + * @param parentId if of parent object. + * + * Parent id - id of cutting point + */ + void AddCurveLength(const quint32 &id, const quint32 &parentId = 0) + { + const QSharedPointer var = GeometricObject(id); + AddVariable(var->name(), new TLength(id, parentId, var.data())); + } + + template + void AddVariable(const QString& name, T *var) + { + if (d->variables.contains(name)) + { + if (d->variables.value(name)->GetType() == var->GetType()) + { + d->variables[name].clear(); + } + else + { + throw VExceptionBadId(tr("Can't find object. Type mismatch."), name); + } + } + d->variables[name] = QSharedPointer(var); + uniqueNames.insert(name); + } + + void UpdateGObject(quint32 id, VGObject* obj); + void UpdateDetail(quint32 id, const VDetail &detail); + + void Clear(); + void ClearGObjects(); + void ClearCalculationGObjects(); + void ClearVariables(const VarType &type = VarType::Unknown); + void ClearDetails(); + static void ClearUniqueNames(); + + static void SetSize(qreal size); + void SetSizeName(const QString &name); + static void SetHeight(qreal height); + void SetHeightName(const QString &name); + static qreal size(); + QString SizeName() const; + static qreal height(); + QString HeightName()const; + + bool VariableExist(const QString& name); + + void RemoveIncrement(const QString& name); + + const QHash > *DataGObjects() const; + const QHash *DataDetails() const; + const QHash> *DataVariables() const; + + const QMap > DataMeasurements() const; + const QMap > DataIncrements() const; + const QMap > DataLengthLines() const; + const QMap > DataLengthSplines() const; + const QMap > DataLengthArcs() const; + const QMap > DataAngleLines() const; + + static bool IsUnique(const QString &name); + +private: + /** + * @brief _id current id. New object will have value +1. For empty class equal 0. + */ + static quint32 _id; + static qreal _size; + static qreal _height; + static QSet uniqueNames; + + QSharedDataPointer d; + + template + uint qHash( const QSharedPointer &p ) + { + return qHash( p.data() ); + } + + template + // cppcheck-suppress functionStatic + const val GetObject(const QHash &obj, key id) const; + + template + void UpdateObject(QHash &obj, const quint32 &id, val point); + + template + static quint32 AddObject(QHash &obj, val value); + + template + const QMap > DataVar(const VarType &type) const; +}; + +#endif // VCONTAINER_H diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp new file mode 100644 index 000000000..ed3659a20 --- /dev/null +++ b/src/app/container/vformula.cpp @@ -0,0 +1,268 @@ +/************************************************************************ + ** + ** @file vformula.cpp + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 "vformula.h" +#include "../container/calculator.h" +#include "../container/vcontainer.h" +#include "../core/vapplication.h" +#include "../core/vsettings.h" +#include + +//VFormula +//--------------------------------------------------------------------------------------------------------------------- +VFormula::VFormula() + :formula(QString()), value(QString(tr("Error"))), checkZero(true), data(nullptr), toolId(NULL_ID), + postfix(QString()), _error(true), dValue(0) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula::VFormula(const QString &formula, const VContainer *container) + :formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container), + toolId(NULL_ID), postfix(QString()), _error(true), dValue(0) +{ + this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist + Eval(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula &VFormula::operator=(const VFormula &formula) +{ + if ( &formula == this ) + { + return *this; + } + this->formula = formula.getFormula(); + this->value = formula.getStringValue(); + this->checkZero = formula.getCheckZero(); + this->data = formula.getData(); + this->toolId = formula.getToolId(); + this->postfix = formula.getPostfix(); + this->_error = formula.error(); + this->dValue = formula.getDoubleValue(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula::VFormula(const VFormula &formula) + :formula(formula.getFormula()), value(formula.getStringValue()), checkZero(formula.getCheckZero()), + data(formula.getData()), toolId(formula.getToolId()), postfix(formula.getPostfix()), _error(formula.error()), + dValue(formula.getDoubleValue()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VFormula::operator==(const VFormula &formula) const +{ + bool isEqual = false; + if (this->formula == formula.getFormula() && this->value == formula.getStringValue() && + this->checkZero == formula.getCheckZero() && this->data == formula.getData() && + this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() && + this->_error == formula.error() && qFuzzyCompare(this->dValue, formula.getDoubleValue())) + { + isEqual = true; + } + return isEqual; +} + +bool VFormula::operator!=(const VFormula &formula) const +{ + return !VFormula::operator==(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VFormula::getFormula(FormulaType type) const +{ + if (type == FormulaType::ToUser) + { + return formula; + } + else + { + return qApp->FormulaFromUser(formula); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::setFormula(const QString &value, FormulaType type) +{ + if (formula != value) + { + if (type == FormulaType::ToUser) + { + formula = value; + } + else + { + formula = qApp->FormulaToUser(value); + } + formula.replace("\n", " ");// Replace line return with spaces for calc if exist + Eval(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VFormula::getStringValue() const +{ + return value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VFormula::getDoubleValue() const +{ + return dValue; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VFormula::getCheckZero() const +{ + return checkZero; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::setCheckZero(bool value) +{ + if (checkZero != value) + { + checkZero = value; + Eval(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +const VContainer *VFormula::getData() const +{ + return data; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::setData(const VContainer *value) +{ + if (data != value && value != nullptr) + { + data = value; + Eval(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VFormula::getToolId() const +{ + return toolId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::setToolId(const quint32 &value) +{ + toolId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VFormula::getPostfix() const +{ + return postfix; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::setPostfix(const QString &value) +{ + if (postfix != value) + { + postfix = value; + Eval(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VFormula::error() const +{ + return _error; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VFormula::FormulaTypeId() +{ + return qMetaTypeId(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormula::Eval() +{ + if (data == nullptr) + { + return; + } + if (formula.isEmpty()) + { + value = QString(tr("Error")); + _error = true; + dValue = 0; + } + else + { + try + { + Calculator *cal = new Calculator(data); + QString expression = qApp->FormulaFromUser(formula); + const qreal result = cal->EvalFormula(expression); + delete cal; + + //if result equal 0 + if (checkZero && qFuzzyCompare(1 + result, 1 + 0)) + { + value = QString("0"); + _error = true; + dValue = 0; + } + else + { + QLocale loc; + if (qApp->getSettings()->GetOsSeparator()) + { + loc = QLocale::system(); + } + else + { + loc = QLocale(QLocale::C); + } + dValue = result; + value = QString(loc.toString(result) + " " + postfix); + _error = false; + } + } + catch (qmu::QmuParserError &e) + { + value = QString(tr("Error")); + _error = true; + dValue = 0; + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; + } + } +} diff --git a/src/app/container/vformula.h b/src/app/container/vformula.h new file mode 100644 index 000000000..222845442 --- /dev/null +++ b/src/app/container/vformula.h @@ -0,0 +1,84 @@ +/************************************************************************ + ** + ** @file vformula.h + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 VFORMULA_H +#define VFORMULA_H + +#include + +enum class FormulaType : char{ToUser, FromUser}; + +class VContainer; + +class VFormula +{ + Q_DECLARE_TR_FUNCTIONS(VFormula) +public: + VFormula(); + VFormula(const QString &formula, const VContainer *container); + VFormula &operator=(const VFormula &formula); + VFormula(const VFormula &formula); + bool operator==(const VFormula &formula) const; + bool operator!=(const VFormula &formula) const; + + QString getFormula(FormulaType type = FormulaType::ToUser) const; + void setFormula(const QString &value, FormulaType type = FormulaType::ToUser); + + QString getStringValue() const; + qreal getDoubleValue() const; + + bool getCheckZero() const; + void setCheckZero(bool value); + + const VContainer *getData() const; + void setData(const VContainer *value); + + quint32 getToolId() const; + void setToolId(const quint32 &value); + + QString getPostfix() const; + void setPostfix(const QString &value); + + bool error() const; + + static int FormulaTypeId(); +private: + QString formula; + QString value; + bool checkZero; + const VContainer *data; + quint32 toolId; + QString postfix; + bool _error; + qreal dValue; + + void Eval(); +}; +Q_DECLARE_METATYPE(VFormula) + +#endif // VFORMULA_H diff --git a/src/app/core/core.pri b/src/app/core/core.pri new file mode 100644 index 000000000..aa1e04485 --- /dev/null +++ b/src/app/core/core.pri @@ -0,0 +1,12 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vapplication.h \ + $$PWD/undoevent.h \ + $$PWD/vsettings.h + +SOURCES += \ + $$PWD/vapplication.cpp \ + $$PWD/undoevent.cpp \ + $$PWD/vsettings.cpp diff --git a/src/container/vstandarttablerow.cpp b/src/app/core/undoevent.cpp similarity index 68% rename from src/container/vstandarttablerow.cpp rename to src/app/core/undoevent.cpp index 668036804..bdbadd91c 100644 --- a/src/container/vstandarttablerow.cpp +++ b/src/app/core/undoevent.cpp @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file vstandarttablecell.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file undoevent.cpp + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,10 +26,13 @@ ** *************************************************************************/ -#include "vstandarttablerow.h" +#include "undoevent.h" -VStandartTableRow::VStandartTableRow() - :base(0), ksize(0), kgrowth(0), description(QString()){} +//--------------------------------------------------------------------------------------------------------------------- +UndoEvent::UndoEvent() + :QEvent(UNDO_EVENT) +{} -VStandartTableRow::VStandartTableRow(qint32 base, qreal ksize, qreal kgrowth, QString description) - :base(base), ksize(ksize), kgrowth(kgrowth), description(description){} +//--------------------------------------------------------------------------------------------------------------------- +UndoEvent::~UndoEvent() +{} diff --git a/src/app/core/undoevent.h b/src/app/core/undoevent.h new file mode 100644 index 000000000..e3f1fc75c --- /dev/null +++ b/src/app/core/undoevent.h @@ -0,0 +1,44 @@ +/************************************************************************ + ** + ** @file undoevent.h + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 + ** + ** @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) 2014 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 UNDOEVENT_H +#define UNDOEVENT_H + +#include + +// Define undo event identifier +const QEvent::Type UNDO_EVENT = static_cast(QEvent::User + 1); + +class UndoEvent : public QEvent +{ +public: + UndoEvent(); + virtual ~UndoEvent(); +}; + +#endif // UNDOEVENT_H diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp new file mode 100644 index 000000000..1167308ee --- /dev/null +++ b/src/app/core/vapplication.cpp @@ -0,0 +1,2347 @@ +/************************************************************************ + ** + ** @file vapplication.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vapplication.h" +#include "../libs/ifc/exception/vexceptionobjecterror.h" +#include "../libs/ifc/exception/vexceptionbadid.h" +#include "../libs/ifc/exception/vexceptionconversionerror.h" +#include "../libs/ifc/exception/vexceptionemptyparameter.h" +#include "../libs/ifc/exception/vexceptionwrongid.h" +#include "vmaingraphicsview.h" +#include "../container/calculator.h" +#include "../version.h" +#include "vsettings.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace qmu; + +Q_LOGGING_CATEGORY(vApp, "v.application") + +//--------------------------------------------------------------------------------------------------------------------- +inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + // Why on earth didn't Qt want to make failed signal/slot connections qWarning? + if ((type == QtDebugMsg) && msg.contains("::connect")) + { + type = QtWarningMsg; + } + + // this is another one that doesn't make sense as just a debug message. pretty serious + // sign of a problem + // http://www.developer.nokia.com/Community/Wiki/QPainter::begin:Paint_device_returned_engine_%3D%3D_0_(Known_Issue) + if ((type == QtDebugMsg) && msg.contains("QPainter::begin") && msg.contains("Paint device returned engine")) + { + type = QtWarningMsg; + } + + // This qWarning about "Cowardly refusing to send clipboard message to hung application..." + // is something that can easily happen if you are debugging and the application is paused. + // As it is so common, not worth popping up a dialog. + if ((type == QtWarningMsg) && QString(msg).contains("QClipboard::event") + && QString(msg).contains("Cowardly refusing")) + { + type = QtDebugMsg; + } + + // only the GUI thread should display message boxes. If you are + // writing a multithreaded application and the error happens on + // a non-GUI thread, you'll have to queue the message to the GUI + QCoreApplication *instance = QCoreApplication::instance(); + const bool isGuiThread = instance && (QThread::currentThread() == instance->thread()); + + if (isGuiThread) + { + QString debugdate = "[" + QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); + QMessageBox messageBox; + switch (type) + { + case QtDebugMsg: + debugdate += QString(":DEBUG:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function).arg(context.category).arg(msg); + break; + case QtWarningMsg: + debugdate += QString(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function).arg(context.category).arg(msg); + messageBox.setIcon(QMessageBox::Warning); + break; + case QtCriticalMsg: + debugdate += QString(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function).arg(context.category).arg(msg); + messageBox.setIcon(QMessageBox::Critical); + break; + case QtFatalMsg: + debugdate += QString(":FATAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) + .arg(context.function).arg(context.category).arg(msg); + messageBox.setIcon(QMessageBox::Critical); + break; + default: + break; + } + + (*qApp->LogFile()) << debugdate << endl; + + if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) + { + messageBox.setInformativeText(msg); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.setWindowModality(Qt::ApplicationModal); + messageBox.setModal(true); + messageBox.exec(); + } + + if (QtFatalMsg == type) + { + abort(); + } + } + else + { + if (type != QtDebugMsg) + { + abort(); // be NOISY unless overridden! + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- + +const qreal VApplication::PrintDPI = 96.0; + +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) +const QString VApplication::GistFileName = QStringLiteral("gist.json"); +#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU) + +#define DefWidth 1.2//mm + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VApplication constructor. + * @param argc number arguments. + * @param argv command line. + */ +VApplication::VApplication(int &argc, char **argv) + : QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual), + _widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap()), + guiTexts(QMap()), descriptions(QMap()), + variables(QMap()), functions(QMap()), + postfixOperators(QMap()), stDescriptions(QMap()), + undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr), mainWindow(nullptr), + openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr), out(nullptr), logLock(nullptr) +{ + undoStack = new QUndoStack(this); + + InitLineWidth(); + InitMeasurements(); + InitVariables(); + InitFunctions(); + InitPostfixOperators(); + InitSTDescriptions(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VApplication::~VApplication() +{ + qCDebug(vApp)<<"Application closing."; + qInstallMessageHandler(0); // Resore the message handler + delete out; + + if (log != nullptr) + { + log->close(); + delete log; + delete logLock; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewValentina start Valentina in new process, send path to pattern file in argument. + * @param fileName path to pattern file. + */ +void VApplication::NewValentina(const QString &fileName) +{ + qCDebug(vApp)<<"Open new detached process."; + if (fileName.isEmpty()) + { + qCDebug(vApp)<<"New process without arguments. program ="<applicationFilePath(); + // Path can contain spaces. + if (QProcess::startDetached("\""+qApp->applicationFilePath()+"\"")) + { + qCDebug(vApp)<<"The process was started successfully."; + } + else + { + qCWarning(vApp)<<"Could not run process. The operation timed out or an error occurred."; + } + } + else + { + const QString run = QString("\"%1\" \"%2\"").arg(qApp->applicationFilePath()).arg(fileName); + qCDebug(vApp)<<"New process with arguments. program ="<= 0.5) + { + oldFactor = Newfactor; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief notify Reimplemented from QApplication::notify(). + * @param receiver receiver. + * @param event event. + * @return value that is returned from the receiver's event handler. + */ +// reimplemented from QApplication so we can throw exceptions in slots +bool VApplication::notify(QObject *receiver, QEvent *event) +{ + try + { + return QApplication::notify(receiver, event); + } + catch (const VExceptionObjectError &e) + { + e.CriticalMessageBox(tr("Error parsing file. Program will be terminated."), mainWindow); + abort(); + } + catch (const VExceptionBadId &e) + { + e.CriticalMessageBox(tr("Error bad id. Program will be terminated."), mainWindow); + abort(); + } + catch (const VExceptionConversionError &e) + { + e.CriticalMessageBox(tr("Error can't convert value. Program will be terminated."), mainWindow); + abort(); + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter. Program will be terminated."), mainWindow); + abort(); + } + catch (const VExceptionWrongId &e) + { + e.CriticalMessageBox(tr("Error wrong id. Program will be terminated."), mainWindow); + abort(); + } + catch (const VException &e) + { + e.CriticalMessageBox(tr("Something's wrong!!"), mainWindow); + return true; + } + catch (std::exception& e) + { + qCritical() << "Exception thrown:" << e.what(); + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +double VApplication::toPixel(double val, const Unit &unit) const +{ + double result = 0; + switch (unit) + { + case Unit::Mm: + result = (val / 25.4) * PrintDPI; + break; + case Unit::Cm: + result = ((val * 10.0) / 25.4) * PrintDPI; + break; + case Unit::Inch: + result = val * PrintDPI; + break; + default: + break; + } + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +double VApplication::toPixel(double val) const +{ + return toPixel(val, _patternUnit); +} + +//--------------------------------------------------------------------------------------------------------------------- +double VApplication::fromPixel(double pix, const Unit &unit) const +{ + double result = 0; + switch (unit) + { + case Unit::Mm: + result = (pix / PrintDPI) * 25.4; + break; + case Unit::Cm: + result = ((pix / PrintDPI) * 25.4) / 10.0; + break; + case Unit::Inch: + result = pix / PrintDPI; + break; + default: + break; + } + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +double VApplication::fromPixel(double pix) const +{ + return fromPixel(pix, _patternUnit); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::pathToTables() const +{ + if (_patternType == MeasurementsType::Individual) + { + return QStringLiteral("://tables/individual/individual.vit"); + } + else + { + const QString stPath = QStringLiteral("/tables/standard"); + #ifdef Q_OS_WIN + return QApplication::applicationDirPath() + stPath; + #else + #ifdef QT_DEBUG + return QApplication::applicationDirPath() + stPath; + #else + QDir dir(QApplication::applicationDirPath() + stPath); + if (dir.exists()) + { + return dir.absolutePath(); + } + else + { + return QStringLiteral("/usr/share/valentina/tables/standard"); + } + #endif + #endif + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::translationsPath() const +{ + const QString trPath = QStringLiteral("/translations"); +#ifdef Q_OS_WIN + return QApplication::applicationDirPath() + trPath; +#else +#ifdef QT_DEBUG + return QApplication::applicationDirPath() + trPath; + #else + QDir dir(QApplication::applicationDirPath() + trPath); + if (dir.exists()) + { + return dir.absolutePath(); + } + else + { + return QStringLiteral("/usr/share/valentina/translations"); + } + #endif +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::InitLineWidth() +{ + switch (_patternUnit) + { + case Unit::Mm: + _widthMainLine = DefWidth; + break; + case Unit::Cm: + _widthMainLine = DefWidth/10.0; + break; + case Unit::Inch: + _widthMainLine = DefWidth/25.4; + break; + default: + _widthMainLine = DefWidth; + break; + } + _widthHairLine = _widthMainLine/3.0; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::InitMeasurement(const QString &name, const QmuTranslation &m, const QmuTranslation &g, + const QmuTranslation &d) +{ + measurements.insert(name, m); + guiTexts.insert(name, g); + descriptions.insert(name, d); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::LogDirPath() const +{ +#if defined(Q_OS_WIN) || defined(Q_OS_OSX) + const QString logDirPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString(), + QStandardPaths::LocateDirectory) + "Valentina"; +#else + const QString logDirPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString(), + QStandardPaths::LocateDirectory) + organizationName(); +#endif + return logDirPath; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::LogPath() const +{ + return QString("%1/valentina-pid%2.log").arg(LogDirPath()).arg(qApp->applicationPid()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::CreateLogDir() const +{ + QDir logDir(LogDirPath()); + if (logDir.exists() == false) + { + logDir.mkpath("."); // Create directory for log if need + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::BeginLogging() +{ + log = new QFile(LogPath()); + if (log->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + { + out = new QTextStream(log); + qInstallMessageHandler(noisyFailureMsgHandler); + logLock = new QLockFile(LogPath()+".lock"); + logLock->setStaleLockTime(0); + if (logLock->tryLock()) + { + qCDebug(vApp) << "Log file"<error(); + } + } + else + { + delete log; + log = nullptr; + qCDebug(vApp) << "Error opening log file '" << LogPath() << "'. All debug output redirected to console."; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::ClearOldLogs() const +{ + QStringList filters{"*.log"}; + QDir logsDir(LogDirPath()); + logsDir.setNameFilters(filters); + logsDir.setCurrent(LogDirPath()); + + const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); + if (allFiles.isEmpty() == false) + { + qCDebug(vApp) << "Clearing old logs"; + for (int i = 0; i < allFiles.size(); ++i) + { + QFileInfo info(allFiles.at(i)); + QLockFile *lock = new QLockFile(info.absoluteFilePath() + ".lock"); + if (lock->tryLock()) + { + qCDebug(vApp) << "Locked file"<0")); + functions.insert(rint_F, QmuTranslation::translate("Functions", "rint", "round to nearest integer")); + functions.insert(abs_F, QmuTranslation::translate("Functions", "abs", "absolute value")); + functions.insert(min_F, QmuTranslation::translate("Functions", "min", "min of all arguments")); + functions.insert(max_F, QmuTranslation::translate("Functions", "max", "max of all arguments")); + functions.insert(sum_F, QmuTranslation::translate("Functions", "sum", "sum of all arguments")); + functions.insert(avg_F, QmuTranslation::translate("Functions", "avg", "mean value of all arguments")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::InitPostfixOperators() +{ + postfixOperators.insert(cm_Oprt, QmuTranslation::translate("PostfixOperators", "cm", "centimeter")); + postfixOperators.insert(mm_Oprt, QmuTranslation::translate("PostfixOperators", "mm", "millimeter")); + postfixOperators.insert(in_Oprt, QmuTranslation::translate("PostfixOperators", "in", "inch")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::InitSTDescriptions() +{ + stDescriptions.insert("0", QmuTranslation::translate("STDescriptions", + "Standard figures of men 1st group, chest 100 cm", + "Standard table description")); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const +{ + QMap::const_iterator i = measurements.constBegin(); + while (i != measurements.constEnd()) + { + if (token == i.value().translate()) + { + newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); + return true; + } + ++i; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const +{ + QMap::const_iterator i = variables.constBegin(); + while (i != variables.constEnd()) + { + if (token.indexOf( i.value().translate() ) == 0) + { + newFormula.replace(position, i.value().translate().length(), i.key()); + QString newToken = token; + newToken.replace(0, i.value().translate().length(), i.key()); + bias = token.length() - newToken.length(); + return true; + } + ++i; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, int &bias) const +{ + QMap::const_iterator i = postfixOperators.constBegin(); + while (i != postfixOperators.constEnd()) + { + if (token == i.value().translate()) + { + newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); + return true; + } + ++i; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const +{ + QMap::const_iterator i = functions.constBegin(); + while (i != functions.constEnd()) + { + if (token == i.value().translate()) + { + newFormula.replace(position, token.length(), i.key()); + bias = token.length() - i.key().length(); + return true; + } + ++i; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VApplication::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const +{ + QMap::const_iterator i = variables.constBegin(); + while (i != variables.constEnd()) + { + if (token.indexOf( i.key() ) == 0) + { + newFormula.replace(position, i.key().length(), i.value().translate()); + + QString newToken = token; + newToken.replace(0, i.key().length(), i.value().translate()); + bias = token.length() - newToken.length(); + return true; + } + ++i; + } + return false; +} + +void VApplication::CorrectionsPositions(int position, int bias, QMap &tokens, + QMap &numbers) +{ + if (bias == 0) + { + return; + } + + BiasTokens(position, bias, tokens); + BiasTokens(position, bias, numbers); +} + +void VApplication::BiasTokens(int position, int bias, QMap &tokens) const +{ + QMap newTokens; + QMap::const_iterator i = tokens.constBegin(); + while (i != tokens.constEnd()) + { + if (i.key()<= position) + { + newTokens.insert(i.key(), i.value()); + } + else + { + newTokens.insert(i.key()-bias, i.value()); + } + ++i; + } + tokens = newTokens; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::setPatternUnit(const Unit &patternUnit) +{ + _patternUnit = patternUnit; + InitLineWidth(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::VarToUser(const QString &var) const +{ + if (measurements.contains(var)) + { + return measurements.value(var).translate(); + } + + if (functions.contains(var)) + { + return functions.value(var).translate(); + } + + if (postfixOperators.contains(var)) + { + return postfixOperators.value(var).translate(); + } + + QString newVar = var; + int bias = 0; + if (VariablesToUser(newVar, 0, var, bias)) + { + return newVar; + } + return newVar; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::VarFromUser(const QString &var) const +{ + QString newVar = var; + int bias = 0; + if (MeasurementsFromUser(newVar, 0, var, bias)) + { + return newVar; + } + + if (VariablesFromUser(newVar, 0, var, bias)) + { + return newVar; + } + + if (PostfixOperatorsFromUser(newVar, 0, var, bias)) + { + return newVar; + } + + if (FunctionsFromUser(newVar, 0, var, bias)) + { + return newVar; + } + return newVar; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::GuiText(const QString &measurement) const +{ + return guiTexts.value(measurement).translate(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::Description(const QString &measurement) const +{ + return descriptions.value(measurement).translate(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::PostfixOperator(const QString &name) const +{ + return postfixOperators.value(name).translate(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::FormulaFromUser(const QString &formula) +{ + QString newFormula = formula; + + Calculator *cal = new Calculator(formula); + QMap tokens = cal->GetTokens(); + QMap numbers = cal->GetNumbers(); + delete cal; + + QList tKeys = tokens.keys(); + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) + { + int bias = 0; + if (MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (PostfixOperatorsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + } + + QLocale loc = QLocale::system(); + if (loc != QLocale(QLocale::C) && getSettings()->GetOsSeparator()) + { + QList nKeys = numbers.keys(); + QList nValues = numbers.values(); + for (int i = 0; i < nKeys.size(); ++i) + { + bool ok = false; + qreal d = loc.toDouble(nValues.at(i), &ok); + if (ok == false) + { + qDebug()<<"Can't convert to double token"< tokens; + QMap numbers; + try + { + Calculator *cal = new Calculator(formula, false); + tokens = cal->GetTokens(); + numbers = cal->GetNumbers(); + delete cal; + } + catch (qmu::QmuParserError &e) + { + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; + return newFormula; + } + + QList tKeys = tokens.keys(); + QList tValues = tokens.values(); + for (int i = 0; i < tKeys.size(); ++i) + { + if (measurements.contains(tValues.at(i))) + { + newFormula.replace(tKeys.at(i), tValues.at(i).length(), measurements.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - measurements.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (functions.contains(tValues.at(i))) + { + newFormula.replace(tKeys.at(i), tValues.at(i).length(), functions.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - functions.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + if (postfixOperators.contains(tValues.at(i))) + { + newFormula.replace(tKeys.at(i), tValues.at(i).length(), postfixOperators.value(tValues.at(i)).translate()); + int bias = tValues.at(i).length() - postfixOperators.value(tValues.at(i)).translate().length(); + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + + int bias = 0; + if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) + { + if (bias != 0) + { + CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); + tKeys = tokens.keys(); + tValues = tokens.values(); + } + continue; + } + } + + QLocale loc = QLocale::system(); + if (loc != QLocale::C && getSettings()->GetOsSeparator()) + { + QList nKeys = numbers.keys(); + QList nValues = numbers.values(); + for (int i = 0; i < nKeys.size(); ++i) + { + QLocale loc = QLocale(QLocale::C); + bool ok = false; + qreal d = loc.toDouble(nValues.at(i), &ok); + if (ok == false) + { + qDebug()<<"Can't convert to double token"<pixmap(); + } + QPixmap newPixmap(pixmapPath); + + QImage oldImage = oldPixmap.toImage(); + QImage newImage = newPixmap.toImage(); + + if (oldImage != newImage ) + { + QApplication::setOverrideCursor(QCursor(newPixmap, hotX, hotY)); + } +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::restoreOverrideCursor(const QString &pixmapPath) +{ +#ifndef QT_NO_CURSOR + QPixmap oldPixmap; + if (QCursor *oldCursor = QGuiApplication::overrideCursor()) + { + oldPixmap = oldCursor->pixmap(); + } + QPixmap newPixmap(pixmapPath); + + QImage oldImage = oldPixmap.toImage(); + QImage newImage = newPixmap.toImage(); + + if (oldImage == newImage ) + { + QApplication::restoreOverrideCursor(); + } +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList VApplication::LabelLanguages() +{ + QStringList list = QStringList() << "de" // German + << "en" // English + << "fr" // French + << "ru" // Russian + << "uk" // Ukrainian + << "hr" // Croatian + << "sr" // Serbian + << "bs"; // Bosnian + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::STDescription(const QString &id) const +{ + if (stDescriptions.contains(id)) + { + return stDescriptions.value(id).translate(); + } + else + { + qDebug()<<"Unknown id number. Got"<applicationDirPath()); + QDir reports(reportsDir); + if (reports.exists()) + { + QStringList filters{"*.log", "*.RPT"}; + QDir logsDir(reportsDir); + logsDir.setNameFilters(filters); + logsDir.setCurrent(reportsDir); + + const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); + if (allFiles.isEmpty() == false) + { + const QDateTime now = QDateTime::currentDateTime(); + for (int i = 0; i < allFiles.size(); ++i) + { + QFileInfo info(allFiles.at(i)); + if (info.created().daysTo(now) > 30) + { + QFile(allFiles.at(i)).remove(); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::GatherLogs() const +{ + QTextStream *out = nullptr; + QFile *log = new QFile(QString("%1/valentina.log").arg(LogDirPath())); + if (log->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + { + out = new QTextStream(log); + + QStringList filters{"*.log"}; + QDir logsDir(LogDirPath()); + logsDir.setNameFilters(filters); + logsDir.setCurrent(LogDirPath()); + + const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); + if (allFiles.isEmpty() == false) + { + for (int i = 0; i < allFiles.size(); ++i) + { + QFileInfo info(allFiles.at(i)); + if (info.fileName() == "valentina.log") + { + continue; + } + QLockFile *logLock = new QLockFile(info.absoluteFilePath()+".lock"); + logLock->setStaleLockTime(0); + if (logLock->tryLock()) + { + *out <<"--------------------------" << endl; + QFile logFile(info.absoluteFilePath()); + if (logFile.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&logFile); + while (!in.atEnd()) + { + *out << in.readLine() << endl; + } + logFile.close(); + } + else + { + *out << "Log file error:" + logFile.errorString() << endl; + } + } + else + { + *out << "Could not lock" << info.absoluteFilePath() << "."; + } + delete logLock; + } + } + else + { + *out << "Could not find logs."; + } + log->close(); + } + delete out; + delete log; +} + +//--------------------------------------------------------------------------------------------------------------------- +// Catch exception and create report. Use if program build with Mingw compiler. +// See more about catcher https://github.com/jrfonseca/drmingw/blob/master/README.md +void VApplication::DrMingw() +{ + QFile drmingw("exchndl.dll"); + if(drmingw.exists()) + {// If don't want create reports just delete exchndl.dll from installer + LoadLibrary(L"exchndl.dll"); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::CollectReports() const +{ + // Seek file "binary_name.RPT" + const QString reportName = QString("%1/%2.RPT").arg(applicationDirPath()) + .arg(QFileInfo(arguments().at(0)).baseName()); + QFile reportFile(reportName); + if (reportFile.exists()) + { // Hooray we have found crash + if (settings == nullptr) + { + return;// Settings was not opened. + } + + if (settings->GetSendReportState()) + { // Try send report + // Remove gist.json file before close app. + connect(this, &VApplication::aboutToQuit, this, &VApplication::CleanGist, Qt::UniqueConnection); + SendReport(reportName); + } + else + { // Just collect report to /reports directory + CollectReport(reportName); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::CollectReport(const QString &reportName) const +{ + const QString reportsDir = QString("%1/reports").arg(qApp->applicationDirPath()); + QDir reports(reportsDir); + if (reports.exists() == false) + { + reports.mkpath("."); // Create directory for reports if need + } + + const QDateTime now = QDateTime::currentDateTime(); + const QString timestamp = now.toString(QLatin1String("yyyy.MM.dd-hh_mm_ss")); + QString filename = QString("%1/reports/crash-%2.RPT").arg(qApp->applicationDirPath()).arg(timestamp); + + QFile reportFile(reportName); + reportFile.copy(filename); // Collect new crash + reportFile.remove(); // Clear after yourself + + filename = QString("%1/reports/log-%2.log").arg(qApp->applicationDirPath()).arg(timestamp); + GatherLogs(); + QFile logFile(QString("%1/valentina.log").arg(LogDirPath())); + logFile.copy(filename); // Collect log +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::CleanGist() const +{ + QFile gistFile(GistFileName); + if (gistFile.exists()) + { + gistFile.remove(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::SendReport(const QString &reportName) const +{ + QString content; + QFile reportFile(reportName); + if (reportFile.open(QIODevice::ReadOnly | QIODevice::Text)) + { + content = ReadFileForSending(reportFile); + reportFile.close(); + } + else + { + content = "RPT file error:" + reportFile.errorString() + "\r\n"; + } + + // Additional information + content.append(QString("-------------------------------")+"\r\n"); + content.append(QString("Version:%1").arg(APP_VERSION)+"\r\n"); + content.append(QString("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR)+"\r\n"); + content.append(QString("Built on %3 at %4").arg(__DATE__).arg(__TIME__)+"\r\n"); + content.append("\r\n"); + + // Creating json with report + // Example: + //{ + // "description":"Crash report", + // "public":"true", + // "files":{ + // "valentina.RPT":{ + // "content":"Report text here" + // } + // } + //} + + // Useful to know when crash was created + const QDateTime now = QDateTime::currentDateTime(); + const QString timestamp = now.toString(QLatin1String("yyyy/MM/dd hh:mm:ss:zzz")); + const QString report = QString("Crash report was created %2").arg(timestamp); + + QJsonObject reportObject; + reportObject.insert(QStringLiteral("description"), QJsonValue(report)); + reportObject.insert(QStringLiteral("public"), QJsonValue(QString("true"))); + + content.append(QString("\r\n-------------------------------\r\n")); + content.append(QString("Log:")+"\r\n"); + + GatherLogs(); + QFile logFile(QString("%1/valentina.log").arg(LogDirPath())); + if (logFile.open(QIODevice::ReadOnly | QIODevice::Text)) + { + const QString logContent = ReadFileForSending(logFile); + if (logContent.isEmpty()) + { + content.append("Log file is empty."); + } + else + { + content.append(logContent); + } + logFile.close(); + } + else + { + content.append("\r\n Log file error:" + logFile.errorString() + "\r\n"); + } + + const QString contentSection = QStringLiteral("content"); + QJsonObject contentObject; + contentObject.insert(contentSection, QJsonValue(content)); + + const QString filesSection = QStringLiteral("files"); + QJsonObject fileObject; + fileObject.insert(QFileInfo(reportName).fileName(), QJsonValue(contentObject)); + reportObject.insert(filesSection, QJsonValue(fileObject)); + + QFile gistFile(GistFileName); + if (!gistFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + { + qDebug("Couldn't open gist file."); + return; + } + + // Save data to file + QJsonDocument saveRep(reportObject); + gistFile.write(saveRep.toJson()); + gistFile.close(); + + QFile curlFile("curl.exe"); + if (curlFile.exists()) + {// Trying send report + // Change token 28df778e0ef75e3724f7b9622fb70b9c69187779 if need + QString arg = QString("curl.exe -k -H \"Authorization: bearer 28df778e0ef75e3724f7b9622fb70b9c69187779\" " + "-H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST " + "--data @gist.json https://api.github.com/gists"); + QProcess::startDetached(arg); + reportFile.remove();// Clear after yourself + } + else + {// We can not send than just collect + CollectReport(reportName); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::ReadFileForSending(QFile &file) const +{ + QString content; + QTextStream in(&file); + while (!in.atEnd()) + { + content.append(in.readLine()+"\r\n");// Windows end of line + } + return content; +} +#endif //defined(Q_OS_WIN) && defined(Q_CC_GNU) diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h new file mode 100644 index 000000000..7122d424d --- /dev/null +++ b/src/app/core/vapplication.h @@ -0,0 +1,268 @@ +/************************************************************************ + ** + ** @file vapplication.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VAPPLICATION_H +#define VAPPLICATION_H + +#include +#include "../options.h" +#include "../widgets/vmaingraphicsview.h" +#include "../../libs/qmuparser/qmutranslation.h" + +class VApplication;// used in define +class QUndoStack; +class VMainGraphicsView; +class VMainGraphicsScene; +class VPattern; +class QFile; +class VSettings; +class QLockFile; + +#if defined(qApp) +#undef qApp +#endif +#define qApp (static_cast(QCoreApplication::instance())) + +/** + * @brief The VApplication class reimplamentation QApplication class. + */ +class VApplication : public QApplication +{ + Q_OBJECT +public: + VApplication(int &argc, char ** argv); + virtual ~VApplication(); + static void NewValentina(const QString &fileName = QString()); + static void CheckFactor(qreal &oldFactor, const qreal &Newfactor); + virtual bool notify(QObject * receiver, QEvent * event); + Unit patternUnit() const; + void setPatternUnit(const Unit &patternUnit); + MeasurementsType patternType() const; + void setPatternType(const MeasurementsType &patternType); + + double toPixel(double val, const Unit &unit) const; + double toPixel(double val) const; + double fromPixel(double pix, const Unit &unit) const; + double fromPixel(double pix) const; + + static const qreal PrintDPI; + QString translationsPath() const; + QString pathToTables() const; + qreal widthMainLine() const; + qreal widthHairLine() const; + QString VarToUser(const QString &var) const; + QString VarFromUser(const QString &var) const; + QString GuiText(const QString &measurement) const; + QString Description(const QString &measurement) const; + QString PostfixOperator(const QString &name) const; + QString FormulaFromUser(const QString &formula); + QString FormulaToUser(const QString &formula); + QUndoStack *getUndoStack() const; + VMainGraphicsView *getSceneView() const; + void setSceneView(VMainGraphicsView *value); + QTimer *getAutoSaveTimer() const; + void setAutoSaveTimer(QTimer *value); + QWidget *getMainWindow() const; + void setMainWindow(QWidget *value); + bool getOpeningPattern() const; + void setOpeningPattern(); + + void OpenSettings(); + VSettings *getSettings(); + + VMainGraphicsScene *getCurrentScene() const; + void setCurrentScene(VMainGraphicsScene *value); + + void setCurrentDocument(VPattern *doc); + VPattern *getCurrentDocument()const; + + static void setOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1); + static void restoreOverrideCursor(const QString & pixmapPath); + + static QStringList LabelLanguages(); + QString STDescription(const QString &id)const; + + void StartLogging(); + QTextStream *LogFile(); + + +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) + static void DrMingw(); + void CollectReports() const; +#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU) + +private slots: +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) + void CleanGist() const; +#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU) + +private: + Q_DISABLE_COPY(VApplication) + Unit _patternUnit; + MeasurementsType _patternType; + qreal _widthMainLine; + qreal _widthHairLine; + QMap measurements; + QMap guiTexts; + QMap descriptions; + QMap variables; + QMap functions; + QMap postfixOperators; + QMap stDescriptions; + QUndoStack *undoStack; + VMainGraphicsView *sceneView; + VMainGraphicsScene *currentScene; + QTimer *autoSaveTimer; + /** + * @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window + * modality doesn't work. + */ + QWidget *mainWindow; + /** + * @brief openingPattern true when we opening pattern. If something will be wrong in formula this help understand if + * we can allow user use Undo option. + */ + bool openingPattern; + /** + * @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable. + */ + VSettings *settings; + + VPattern *doc; + QFile *log; + QTextStream *out; + QLockFile *logLock; + void InitLineWidth(); + void InitMeasurements(); + void InitVariables(); + void InitFunctions(); + void InitPostfixOperators(); + void InitSTDescriptions(); + bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, + int &bias) const; + bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; + void CorrectionsPositions(int position, int bias, QMap &tokens, + QMap &numbers); + void BiasTokens(int position, int bias, QMap &tokens) const; + void InitMeasurement(const QString &name, const qmu::QmuTranslation &m, const qmu::QmuTranslation &g, + const qmu::QmuTranslation &d); + +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) + static const QString GistFileName; + + void CollectReport(const QString &reportName) const; + void SendReport(const QString &reportName) const; + QString ReadFileForSending(QFile &file)const; + void ClearOldReports()const; + void GatherLogs()const; +#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU) + + QString LogDirPath()const; + QString LogPath()const; + void CreateLogDir()const; + void BeginLogging(); + void ClearOldLogs()const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline Unit VApplication::patternUnit() const +{ + return _patternUnit; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline MeasurementsType VApplication::patternType() const +{ + return _patternType; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setPatternType(const MeasurementsType &patternType) +{ + _patternType = patternType; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VApplication::widthMainLine() const +{ + return _widthMainLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VApplication::widthHairLine() const +{ + return _widthHairLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QUndoStack *VApplication::getUndoStack() const +{ + return undoStack; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VMainGraphicsView *VApplication::getSceneView() const +{ + return sceneView; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setSceneView(VMainGraphicsView *value) +{ + sceneView = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QTimer *VApplication::getAutoSaveTimer() const +{ + return autoSaveTimer; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setAutoSaveTimer(QTimer *value) +{ + autoSaveTimer = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setCurrentDocument(VPattern *doc) +{ + this->doc = doc; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VPattern *VApplication::getCurrentDocument() const +{ + SCASSERT(doc != nullptr) + return doc; +} + +#endif // VAPPLICATION_H diff --git a/src/app/core/vsettings.cpp b/src/app/core/vsettings.cpp new file mode 100644 index 000000000..7f507a9e9 --- /dev/null +++ b/src/app/core/vsettings.cpp @@ -0,0 +1,404 @@ +/************************************************************************ + ** + ** @file vsettings.cpp + ** @author Roman Telezhynskyi + ** @date 22 11, 2014 + ** + ** @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) 2014 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 "vsettings.h" + +#include +#include +#include + +const QString VSettings::SettingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator"); +const QString VSettings::SettingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state"); +const QString VSettings::SettingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time"); +const QString VSettings::SettingConfigurationSendReportState = QStringLiteral("configuration/send_report/state"); +const QString VSettings::SettingConfigurationLocale = QStringLiteral("configuration/locale"); +const QString VSettings::SettingConfigurationUnit = QStringLiteral("configuration/unit"); +const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language"); + +const QString VSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements"); +const QString VSettings::SettingPathsPattern = QStringLiteral("paths/pattern"); + +const QString VSettings::SettingPatternUser = QStringLiteral("pattern/user"); +const QString VSettings::SettingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput"); +const QString VSettings::SettingPatternUndo = QStringLiteral("pattern/undo"); + +const QString VSettings::SettingGeneralRecentFileList = QStringLiteral("recentFileList"); +const QString VSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList"); +const QString VSettings::SettingGeneralGeometry = QStringLiteral("geometry"); +const QString VSettings::SettingGeneralWindowState = QStringLiteral("windowState"); + +const QString VSettings::SettingCommunityServer = QStringLiteral("community/server"); +const QString VSettings::SettingCommunityServerSecure = QStringLiteral("community/serverSecure"); +const QString VSettings::SettingCommunityUseProxy = QStringLiteral("community/useProxy"); +const QString VSettings::SettingCommunityProxyAddress = QStringLiteral("community/proxyAddress"); +const QString VSettings::SettingCommunityProxyPort = QStringLiteral("community/proxyPort"); +const QString VSettings::SettingCommunityProxyUser = QStringLiteral("community/proxyUser"); +const QString VSettings::SettingCommunityProxyPass = QStringLiteral("community/proxyPass"); +const QString VSettings::SettingCommunityUsername = QStringLiteral("community/username"); +const QString VSettings::SettingCommunitySavePassword = QStringLiteral("community/savePassword"); +const QString VSettings::SettingCommunityUserPassword = QStringLiteral("community/userpassword"); + +//--------------------------------------------------------------------------------------------------------------------- +VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application, + QObject *parent) + :QSettings(format, scope, organization, application, parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetOsSeparator() const +{ + return value(SettingConfigurationOsSeparator, 1).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetOsSeparator(const bool &value) +{ + setValue(SettingConfigurationOsSeparator, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetAutosaveState() const +{ + return value(SettingConfigurationAutosaveState, 1).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetAutosaveState(const bool &value) +{ + setValue(SettingConfigurationAutosaveState, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VSettings::GetAutosaveTime() const +{ + bool ok = false; + int val = value(SettingConfigurationAutosaveTime, 1).toInt(&ok); + if (ok == false) + { + qDebug()<<"Could not convert value"< + ** @date 22 11, 2014 + ** + ** @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) 2014 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 VSETTINGS_H +#define VSETTINGS_H + +#include + +class VSettings : public QSettings +{ + Q_OBJECT +public: + VSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), + QObject *parent = 0); + + bool GetOsSeparator() const; + void SetOsSeparator(const bool &value); + + bool GetAutosaveState() const; + void SetAutosaveState(const bool &value); + + int GetAutosaveTime() const; + void SetAutosaveTime(const int &value); + + bool GetSendReportState() const; + void SetSendReportState(const bool &value); + + QString GetLocale() const; + void SetLocale(const QString &value); + + QString GetUnit() const; + void SetUnit(const QString &value); + + QString GetLabelLanguage() const; + void SetLabelLanguage(const QString &value); + + QString GetPathIndividualMeasurements() const; + void SetPathIndividualMeasurements(const QString &value); + + QString GetPathPattern() const; + void SetPathPattern(const QString &value); + + QString GetUser() const; + void SetUser(const QString &value); + + bool GetGraphicalOutput() const; + void SetGraphicalOutput(const bool &value); + + int GetUndoCount() const; + void SetUndoCount(const int &value); + + QStringList GetRecentFileList() const; + void SetRecentFileList(const QStringList &value); + + QStringList GetRestoreFileList() const; + void SetRestoreFileList(const QStringList &value); + + QByteArray GetGeometry() const; + void SetGeometry(const QByteArray &value); + + QByteArray GetWindowState() const; + void SetWindowState(const QByteArray &value); + + QString GetServer() const; + void SetServer(const QString &value); + + bool GetServerSecure() const; + void SetServerSecure(const bool &value); + + bool GetProxy() const; + void SetProxy(const bool &value); + + QString GetProxyAddress() const; + void SetProxyAddress(const QString &value); + + QString GetProxyPort() const; + void SetProxyPort(const QString &value); + + QString GetProxyUser() const; + void SetProxyUser(const QString &value); + + QString GetProxyPass() const; + void SetProxyPass(const QString &value); + + QString GetUsername() const; + void SetUsername(const QString &value); + + bool GetSavePassword() const; + void SetSavePassword(const bool &value); + + QString GetUserPassword() const; + void SetUserPassword(const QString &value); + +private: + Q_DISABLE_COPY(VSettings) + static const QString SettingConfigurationOsSeparator; + static const QString SettingConfigurationAutosaveState; + static const QString SettingConfigurationAutosaveTime; + static const QString SettingConfigurationSendReportState; + static const QString SettingConfigurationLocale; + static const QString SettingConfigurationUnit; + static const QString SettingConfigurationLabelLanguage; + + static const QString SettingPathsIndividualMeasurements; + static const QString SettingPathsPattern; + + static const QString SettingPatternUser; + static const QString SettingPatternGraphicalOutput; + static const QString SettingPatternUndo; + + static const QString SettingGeneralRecentFileList; + static const QString SettingGeneralRestoreFileList; + static const QString SettingGeneralGeometry; + static const QString SettingGeneralWindowState; + + static const QString SettingCommunityServer; + static const QString SettingCommunityServerSecure; + static const QString SettingCommunityUseProxy; + static const QString SettingCommunityProxyAddress; + static const QString SettingCommunityProxyPort; + static const QString SettingCommunityProxyUser; + static const QString SettingCommunityProxyPass; + static const QString SettingCommunityUsername; + static const QString SettingCommunitySavePassword; + static const QString SettingCommunityUserPassword; +}; + +#endif // VSETTINGS_H diff --git a/src/app/dialogs/app/configdialog.cpp b/src/app/dialogs/app/configdialog.cpp new file mode 100644 index 000000000..52bc5d5f0 --- /dev/null +++ b/src/app/dialogs/app/configdialog.cpp @@ -0,0 +1,167 @@ +/************************************************************************ + ** + ** @file configdialog.cpp + ** @author Roman Telezhynskyi + ** @date 12 2, 2014 + ** + ** @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 + ** 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 "configdialog.h" +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +ConfigDialog::ConfigDialog(QWidget *parent) : + QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr), + communityPage(nullptr), pathPage(nullptr) +{ + contentsWidget = new QListWidget; + contentsWidget->setViewMode(QListView::IconMode); + contentsWidget->setIconSize(QSize(96, 84)); + contentsWidget->setMovement(QListView::Static); + contentsWidget->setMaximumWidth(128); + contentsWidget->setMinimumHeight(500); + contentsWidget->setSpacing(12); + + pagesWidget = new QStackedWidget; + + configurationPage = new ConfigurationPage(); + pagesWidget->addWidget(configurationPage); + + patternPage = new PatternPage(); + pagesWidget->addWidget(patternPage); + + communityPage = new CommunityPage(); + pagesWidget->addWidget(communityPage); + + pathPage = new PathPage(); + pagesWidget->addWidget(pathPage); + + QPushButton *applyButton = new QPushButton(tr("Apply")); + QPushButton *canselButton = new QPushButton(tr("&Cancel")); + QPushButton *okButton = new QPushButton(tr("&Ok")); + + createIcons(); + contentsWidget->setCurrentRow(0); + + connect(canselButton, &QPushButton::clicked, this, &ConfigDialog::close); + connect(applyButton, &QPushButton::clicked, this, &ConfigDialog::Apply); + connect(okButton, &QPushButton::clicked, this, &ConfigDialog::Ok); + + QHBoxLayout *horizontalLayout = new QHBoxLayout; + horizontalLayout->addWidget(contentsWidget); + horizontalLayout->addWidget(pagesWidget, 1); + + QHBoxLayout *buttonsLayout = new QHBoxLayout; + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(applyButton); + buttonsLayout->addWidget(canselButton); + buttonsLayout->addWidget(okButton); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(horizontalLayout); + mainLayout->addStretch(1); + mainLayout->addSpacing(12); + mainLayout->addLayout(buttonsLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Config Dialog")); + + this->setFixedSize(QSize(750, 550)); + this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) +{ + if (current == nullptr) + { + current = previous; + } + pagesWidget->setCurrentIndex(contentsWidget->row(current)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::closeEvent(QCloseEvent *event) +{ + if (result() == QDialog::Accepted) + { + done(QDialog::Accepted); + } + event->accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::createIcons() +{ + createIcon("://icon/config.png", tr("Configuration")); + createIcon("://icon/pattern_config.png", tr("Pattern")); + createIcon("://icon/community_config.png", tr("Community")); + createIcon("://icon/path_config.png", tr("Paths")); + + connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::createIcon(const QString &icon, const QString &text) +{ + QListWidgetItem *button = new QListWidgetItem(contentsWidget); + button->setIcon(QIcon(icon)); + button->setText(text); + button->setTextAlignment(Qt::AlignHCenter); + button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::Apply() +{ + switch (contentsWidget->currentRow()) + { + case (0): + configurationPage->Apply(); + break; + case (1): + patternPage->Apply(); + break; + case (2): + communityPage->Apply(); + break; + case (3): + pathPage->Apply(); + break; + default: + break; + } + setResult(QDialog::Accepted); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::Ok() +{ + Apply(); + done(QDialog::Accepted); +} diff --git a/src/geometry/vnodedetail.cpp b/src/app/dialogs/app/configdialog.h similarity index 52% rename from src/geometry/vnodedetail.cpp rename to src/app/dialogs/app/configdialog.h index b7b09a005..8045a33d2 100644 --- a/src/geometry/vnodedetail.cpp +++ b/src/app/dialogs/app/configdialog.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file vnodedetail.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file configdialog.h + ** @author Roman Telezhynskyi + ** @date 12 2, 2014 ** ** @brief ** @copyright @@ -26,26 +26,37 @@ ** *************************************************************************/ -#include "vnodedetail.h" +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H -VNodeDetail::VNodeDetail() - :id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling), typeNode(NodeDetail::Contour), mx(0), my(0){} +#include +#include "configpages/pages.h" -VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, - qreal mx, qreal my) - :id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), mx(mx), my(my){} +class QListWidgetItem; +class QStackedWidget; +class QListWidget; -VNodeDetail::VNodeDetail(const VNodeDetail &node) - :id(node.getId()), typeTool(node.getTypeTool()), mode(node.getMode()), typeNode(node.getTypeNode()), - mx(node.getMx()), my(node.getMy()){} - -VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node) +class ConfigDialog : public QDialog { - id = node.getId(); - typeTool = node.getTypeTool(); - mode = node.getMode(); - typeNode = node.getTypeNode(); - mx = node.getMx(); - my = node.getMy(); - return *this; -} + Q_OBJECT +public: + explicit ConfigDialog(QWidget *parent = nullptr); +public slots: + void changePage(QListWidgetItem *current, QListWidgetItem *previous); +protected: + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(ConfigDialog) + QListWidget *contentsWidget; + QStackedWidget *pagesWidget; + ConfigurationPage *configurationPage; + PatternPage *patternPage; + CommunityPage *communityPage; + PathPage *pathPage; + void createIcons(); + void createIcon(const QString &icon, const QString &text); + void Apply(); + void Ok(); +}; + +#endif // CONFIGDIALOG_H diff --git a/src/app/dialogs/app/configpages/communitypage.cpp b/src/app/dialogs/app/configpages/communitypage.cpp new file mode 100644 index 000000000..e770424c0 --- /dev/null +++ b/src/app/dialogs/app/configpages/communitypage.cpp @@ -0,0 +1,172 @@ +/************************************************************************ + ** + ** @file communitypage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 "communitypage.h" +#include "../../../options.h" +#include "../../../core/vapplication.h" +#include "../../../core/vsettings.h" +#include +#include +#include +#include +#include + + +//--------------------------------------------------------------------------------------------------------------------- +CommunityPage::CommunityPage(QWidget *parent): + QWidget(parent), server(nullptr), secureComm(nullptr), useProxy(nullptr), proxyAddress(nullptr), + proxyPort(nullptr), proxyUser(nullptr), proxyPass(nullptr), username(nullptr), savePassword(nullptr), + userpassword(nullptr) +{ + QGroupBox *serverGroup = ServerGroup(); + QGroupBox *proxyGroup = ProxyGroup(); + QGroupBox *userGroup = UserGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(serverGroup); + mainLayout->addWidget(userGroup); + mainLayout->addWidget(proxyGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::Apply() +{ + qApp->getSettings()->SetServer(this->server->text()); + qApp->getSettings()->SetServerSecure(this->secureComm->isChecked()); + qApp->getSettings()->SetProxy(this->useProxy->isChecked()); + qApp->getSettings()->SetProxyAddress(this->proxyAddress->text()); + qApp->getSettings()->SetProxyPort(this->proxyPort->text()); + qApp->getSettings()->SetProxyUser(this->proxyUser->text()); + qApp->getSettings()->SetProxyPass(this->proxyPass->text()); + + qApp->getSettings()->SetUsername(this->username->text()); + qApp->getSettings()->SetSavePassword(this->savePassword->isChecked()); + qApp->getSettings()->SetUserPassword(this->userpassword->text()); + +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::ProxyCheckChanged() +{ + if (this->useProxy->isChecked() == false) + { + this->proxyAddress->setEnabled(false); + this->proxyPort->setEnabled(false); + this->proxyUser->setEnabled(false); + this->proxyPass->setEnabled(false); + } + else + { + this->proxyAddress->setEnabled(true); + this->proxyPort->setEnabled(true); + this->proxyUser->setEnabled(true); + this->proxyPass->setEnabled(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::PasswordCheckChanged() +{ + this->userpassword->setEnabled(this->savePassword->isChecked()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::ServerGroup() +{ + QGroupBox *ServerGroup = new QGroupBox(tr("Server")); + QFormLayout *serverLayout = new QFormLayout; + + CommunityPage::add_lineedit(&this->server, serverLayout, qApp->getSettings()->GetServer(), tr("Server name/IP")); + + CommunityPage::add_checkbox(&this->secureComm, serverLayout, qApp->getSettings()->GetServerSecure(), + tr("Secure connection")); + + ServerGroup->setLayout(serverLayout); + return ServerGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label) +{ + QLabel *labelbox = new QLabel(label); + (*thebox)= new QCheckBox; + (*thebox)->setChecked(checked); + layout->addRow(labelbox, *thebox); +} + +//--------------------------------------------------------------------------------------------------------------------- +void CommunityPage::add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label) +{ + QLabel *labelbox = new QLabel(label); + (*theline)= new QLineEdit; + (*theline)->setText(value); + layout->addRow(labelbox, *theline); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::ProxyGroup() +{ + QGroupBox *proxyGroup = new QGroupBox(tr("Proxy settings")); + + QFormLayout *proxyLayout = new QFormLayout; + + CommunityPage::add_checkbox(&this->useProxy, proxyLayout, qApp->getSettings()->GetProxy(), tr("Use Proxy")); + CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout, qApp->getSettings()->GetProxyAddress(), + tr("Proxy address")); + CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, qApp->getSettings()->GetProxyPort(), tr("Proxy port")); + CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, qApp->getSettings()->GetProxyUser(), tr("Proxy user")); + CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, qApp->getSettings()->GetProxyPass(), tr("Proxy pass")); + connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged); + this->ProxyCheckChanged(); + + proxyGroup->setLayout(proxyLayout); + + return proxyGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *CommunityPage::UserGroup() +{ + QGroupBox *userGroup = new QGroupBox(tr("User settings")); + QFormLayout *userLayout = new QFormLayout; + + CommunityPage::add_lineedit(&this->username, userLayout, qApp->getSettings()->GetUsername(), tr("User Name")); + CommunityPage::add_checkbox(&this->savePassword, userLayout, qApp->getSettings()->GetSavePassword(), + tr("Save password")); + CommunityPage::add_lineedit(&this->userpassword, userLayout, qApp->getSettings()->GetUserPassword(), + tr("Password")); + + connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged); + this->PasswordCheckChanged(); + + userGroup->setLayout(userLayout); + + return userGroup; +} diff --git a/src/app/dialogs/app/configpages/communitypage.h b/src/app/dialogs/app/configpages/communitypage.h new file mode 100644 index 000000000..6af2a1560 --- /dev/null +++ b/src/app/dialogs/app/configpages/communitypage.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file communitypage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 COMMUNITYPAGE_H +#define COMMUNITYPAGE_H + +#include +#include +#include + +class QCheckBox; +class QGroupBox; +class QLineEdit; + +class CommunityPage : public QWidget +{ + Q_OBJECT +public: + CommunityPage(QWidget *parent = nullptr); + void Apply(); +private: + Q_DISABLE_COPY(CommunityPage) + // server name and https connection + QLineEdit *server; + QCheckBox *secureComm; + + // proxy stuff + QCheckBox *useProxy; + QLineEdit *proxyAddress; + QLineEdit *proxyPort; + QLineEdit *proxyUser; + QLineEdit *proxyPass; + + // username and password + QLineEdit *username; + QCheckBox *savePassword; + QLineEdit *userpassword; + + static void add_checkbox(QCheckBox** thebox, QFormLayout *layout, bool checked, QString label); + static void add_lineedit(QLineEdit** theline, QFormLayout *layout, QString value, QString label); + + void ProxyCheckChanged(); + void PasswordCheckChanged(); + + QGroupBox *ServerGroup(); + QGroupBox *ProxyGroup(); + QGroupBox *UserGroup(); +}; + +#endif // COMMUNITYPAGE_H diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp new file mode 100644 index 000000000..06e39023a --- /dev/null +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -0,0 +1,282 @@ +/************************************************************************ + ** + ** @file configurationpage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 "configurationpage.h" +#include "../../../options.h" +#include "../../../core/vapplication.h" +#include "../../../core/vsettings.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +ConfigurationPage::ConfigurationPage(QWidget *parent) + : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr), + unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false), + sendReportCheck(nullptr) +{ + QGroupBox *saveGroup = SaveGroup(); + QGroupBox *langGroup = LangGroup(); + QGroupBox *sendGroup = SendGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(saveGroup); + mainLayout->addWidget(langGroup); + mainLayout->addWidget(sendGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::Apply() +{ + qApp->getSettings()->SetAutosaveState(autoSaveCheck->isChecked()); + qApp->getSettings()->SetAutosaveTime(autoTime->value()); + + QTimer *autoSaveTimer = qApp->getAutoSaveTimer(); + SCASSERT(autoSaveTimer); + + autoSaveCheck->isChecked() ? autoSaveTimer->start(autoTime->value()*60000) : autoSaveTimer->stop(); + + qApp->getSettings()->SetOsSeparator(osOptionCheck->isChecked()); + qApp->getSettings()->SetSendReportState(sendReportCheck->isChecked()); + + if (langChanged) + { + const QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); + qApp->getSettings()->SetLocale(locale); + langChanged = false; + const QString text = tr("Setup user interface language updated and will be used the next time start") + " " + + QApplication::applicationName(); + QMessageBox::information(this, QApplication::applicationName(), text); + } + if (this->unitChanged) + { + const QString unit = qvariant_cast(this->unitCombo->itemData(this->unitCombo->currentIndex())); + qApp->getSettings()->SetUnit(unit); + this->unitChanged = false; + const QString text = tr("Default unit updated and will be used the next pattern creation"); + QMessageBox::information(this, QApplication::applicationName(), text); + } + if (labelLangChanged) + { + const QString locale = qvariant_cast(labelCombo->itemData(labelCombo->currentIndex())); + qApp->getSettings()->SetLabelLanguage(locale); + labelLangChanged = false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::LangChanged() +{ + langChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::UnitChanged() +{ + this->unitChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::LabelLangChanged() +{ + labelLangChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::SaveGroup() +{ + QGroupBox *saveGroup = new QGroupBox(tr("Save")); + + autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern")); + autoSaveCheck->setChecked(qApp->getSettings()->GetAutosaveState()); + + autoTime = new QSpinBox(); + autoTime->setRange(1, 60); + autoTime->setValue(qApp->getSettings()->GetAutosaveTime()); + autoTime->setSuffix(tr("min")); + + QHBoxLayout *autosaveLayout = new QHBoxLayout; + autosaveLayout->addWidget(autoSaveCheck); + autosaveLayout->addWidget(new QLabel(tr("Interval:"))); + autosaveLayout->addWidget(autoTime); + + QVBoxLayout *saveLayout = new QVBoxLayout; + saveLayout->addLayout(autosaveLayout); + saveGroup->setLayout(saveLayout); + return saveGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::LangGroup() +{ + QGroupBox *langGroup = new QGroupBox(tr("Language")); + QLabel *guiLabel = new QLabel(tr("GUI language")); + langCombo = new QComboBox; + + QDir dir(qApp->translationsPath()); + const QStringList fileNames = dir.entryList(QStringList("valentina_*.qm")); + + for (int i = 0; i < fileNames.size(); ++i) + { + // get locale extracted by filename + QString locale; + locale = fileNames.at(i); // "valentina_de_De.qm" + locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De" + locale.remove(0, locale.indexOf('_') + 1); // "de_De" + + QLocale loc = QLocale(locale); + QString lang = loc.nativeLanguageName(); + QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(loc.country()))); + + langCombo->addItem(ico, lang, locale); + } + + // English language is internal and doens't have own *.qm file. + QIcon ico(QString("%1/%2.png").arg("://flags").arg(QLocale::countryToString(QLocale::UnitedStates))); + QString lang = QLocale("en_US").nativeLanguageName(); + langCombo->addItem(ico, lang, "en_US"); + + // set default translators and language checked + qint32 index = langCombo->findData(qApp->getSettings()->GetLocale()); + if (index != -1) + { + langCombo->setCurrentIndex(index); + } + connect(langCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::LangChanged); + + QHBoxLayout *guiLangLayout = new QHBoxLayout; + guiLangLayout->addWidget(guiLabel); + guiLangLayout->addWidget(langCombo); + + //-------------------- Decimal separator setup + QLabel *separatorLabel = new QLabel(tr("Decimal separator parts")); + + osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + osOptionCheck->setChecked(qApp->getSettings()->GetOsSeparator()); + + QHBoxLayout *separatorLayout = new QHBoxLayout; + separatorLayout->addWidget(separatorLabel); + separatorLayout->addWidget(osOptionCheck); + + //----------------------- Unit setup + this->unitCombo = new QComboBox; + QLabel *unitLabel = new QLabel(tr("Default unit")); + + this->unitCombo->addItem(tr("Centimeters"), "cm"); + this->unitCombo->addItem(tr("Millimiters"), "mm"); + this->unitCombo->addItem(tr("Inches"), "in"); + + // set default unit + qint32 indexUnit = this->unitCombo->findData(qApp->getSettings()->GetUnit()); + if (indexUnit != -1) + { + this->unitCombo->setCurrentIndex(indexUnit); + } + connect(this->unitCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::UnitChanged); + + QHBoxLayout *UnitLayout = new QHBoxLayout; + UnitLayout->addWidget(unitLabel); + UnitLayout->addWidget(this->unitCombo); + + //----------------------- Label language + + QLabel *labelName = new QLabel(tr("Label language")); + labelCombo = new QComboBox; + + SetLabelComboBox(VApplication::LabelLanguages()); + + index = labelCombo->findData(qApp->getSettings()->GetLabelLanguage()); + if (index != -1) + { + labelCombo->setCurrentIndex(index); + } + connect(labelCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::LabelLangChanged); + + QHBoxLayout *labelLangLayout = new QHBoxLayout; + labelLangLayout->addWidget(labelName); + labelLangLayout->addWidget(labelCombo); + + //----------------------- + + QVBoxLayout *langLayout = new QVBoxLayout; + langLayout->addLayout(guiLangLayout); + langLayout->addLayout(separatorLayout); + langLayout->addLayout(UnitLayout); + langLayout->addLayout(labelLangLayout); + langGroup->setLayout(langLayout); + + return langGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::SendGroup() +{ + QGroupBox *sendGroup = new QGroupBox(tr("Send crash reports")); + + sendReportCheck = new QCheckBox(tr("Send crash reports (recommended)")); + sendReportCheck->setChecked(qApp->getSettings()->GetSendReportState()); + + QLabel *description = new QLabel(tr("After each crash Valentina collect information that may help us fix a " + "problem. We do not collect any personal information. Find more about what " + "kind of information we collect.")); + description->setTextFormat(Qt::RichText); + description->setTextInteractionFlags(Qt::TextBrowserInteraction); + description->setOpenExternalLinks(true); + description->setWordWrap(true); + + QVBoxLayout *sendLayout = new QVBoxLayout; + sendLayout->addWidget(sendReportCheck); + sendLayout->addWidget(description); + + sendGroup->setLayout(sendLayout); + return sendGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::SetLabelComboBox(const QStringList &list) +{ + for (int i = 0; i < list.size(); ++i) + { + QLocale loc = QLocale(list.at(i)); + labelCombo->addItem(loc.nativeLanguageName(), list.at(i)); + } +} diff --git a/src/app/dialogs/app/configpages/configurationpage.h b/src/app/dialogs/app/configpages/configurationpage.h new file mode 100644 index 000000000..3b83e2996 --- /dev/null +++ b/src/app/dialogs/app/configpages/configurationpage.h @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file configurationpage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 CONFIGURATIONPAGE_H +#define CONFIGURATIONPAGE_H + +#include +#include + +class QCheckBox; +class QSpinBox; +class QComboBox; +class QGroupBox; + +class ConfigurationPage : public QWidget +{ + Q_OBJECT +public: + ConfigurationPage(QWidget *parent = nullptr); + void Apply(); +public slots: + void LangChanged(); + void UnitChanged(); + void LabelLangChanged(); +private: + Q_DISABLE_COPY(ConfigurationPage) + QCheckBox *autoSaveCheck; + QSpinBox *autoTime; + QComboBox *langCombo; + QComboBox *labelCombo; + QComboBox *unitCombo; + QCheckBox *osOptionCheck; + bool langChanged; + bool unitChanged; + bool labelLangChanged; + QCheckBox *sendReportCheck; + + QGroupBox *SaveGroup(); + QGroupBox *LangGroup(); + QGroupBox *SendGroup(); + void SetLabelComboBox(const QStringList &list); +}; + +#endif // CONFIGURATIONPAGE_H diff --git a/src/xml/vtoolrecord.cpp b/src/app/dialogs/app/configpages/pages.h similarity index 74% rename from src/xml/vtoolrecord.cpp rename to src/app/dialogs/app/configpages/pages.h index e5e69ac0a..271a48c3f 100644 --- a/src/xml/vtoolrecord.cpp +++ b/src/app/dialogs/app/configpages/pages.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file vtoolrecord.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file pages.h + ** @author Roman Telezhynskyi + ** @date 12 2, 2014 ** ** @brief ** @copyright @@ -26,10 +26,12 @@ ** *************************************************************************/ -#include "vtoolrecord.h" +#ifndef PAGES_H +#define PAGES_H -VToolRecord::VToolRecord() - :id(0), typeTool(Tool::ArrowTool), nameDraw(QString()){} +#include "configurationpage.h" +#include "patternpage.h" +#include "communitypage.h" +#include "pathpage.h" -VToolRecord::VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw) - :id(id), typeTool(typeTool), nameDraw(nameDraw){} +#endif // PAGES_H diff --git a/src/app/dialogs/app/configpages/pathpage.cpp b/src/app/dialogs/app/configpages/pathpage.cpp new file mode 100644 index 000000000..bf2a8e686 --- /dev/null +++ b/src/app/dialogs/app/configpages/pathpage.cpp @@ -0,0 +1,154 @@ +/************************************************************************ + ** + ** @file pathpage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 "pathpage.h" +#include "../../../options.h" +#include "../../../core/vapplication.h" +#include "../../../core/vsettings.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +PathPage::PathPage(QWidget *parent) + : QWidget(parent), defaultButton(nullptr), editButton(nullptr), pathTable(nullptr) +{ + QGroupBox *pathGroup = PathGroup(); + SCASSERT(pathGroup != nullptr); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(pathGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PathPage::Apply() +{ + qApp->getSettings()->SetPathIndividualMeasurements(pathTable->item(0, 1)->text()); + qApp->getSettings()->SetPathPattern(pathTable->item(1, 1)->text()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PathPage::TableActivated() +{ + defaultButton->setEnabled(true); + defaultButton->setDefault(false); + + editButton->setEnabled(true); + editButton->setDefault(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PathPage::DefaultPath() +{ + QTableWidgetItem *item = pathTable->item(pathTable->currentRow(), 1); + SCASSERT(item != nullptr); + item->setText(QDir::homePath()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PathPage::EditPath() +{ + QTableWidgetItem *item = pathTable->item(pathTable->currentRow(), 1); + SCASSERT(item != nullptr); + QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if (dir.isEmpty()) + { + dir = QDir::homePath(); + } + + item->setText(dir); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PathPage::PathGroup() +{ + QGroupBox *pathGroup = new QGroupBox(tr("Path that use Valentina")); + InitTable(); + + defaultButton = new QPushButton(tr("Default")); + defaultButton->setEnabled(false); + connect(defaultButton, &QPushButton::clicked, this, &PathPage::DefaultPath); + + editButton = new QPushButton(tr("Edit")); + editButton->setEnabled(false); + connect(editButton, &QPushButton::clicked, this, &PathPage::EditPath); + + QHBoxLayout *buttonsLayout = new QHBoxLayout; + buttonsLayout->addWidget(defaultButton); + buttonsLayout->addWidget(editButton); + + QVBoxLayout *pathLayout = new QVBoxLayout; + pathLayout->addWidget(pathTable); + pathLayout->addLayout(buttonsLayout); + + pathGroup->setLayout(pathLayout); + return pathGroup; +} + +void PathPage::InitTable() +{ + pathTable = new QTableWidget(); + pathTable->setRowCount(2); + pathTable->setColumnCount(2); + pathTable->verticalHeader()->setVisible(false); + pathTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + pathTable->setSelectionBehavior(QAbstractItemView::SelectRows); + pathTable->setSelectionMode(QAbstractItemView::SingleSelection); + pathTable->setShowGrid(false); + + QStringList tableHeader = QStringList() << tr("Type") << tr("Path"); + pathTable->setHorizontalHeaderLabels(tableHeader); + + pathTable->setItem(0, 0, new QTableWidgetItem(tr("Individual measurements"))); + pathTable->setItem(0, 1, new QTableWidgetItem(qApp->getSettings()->GetPathIndividualMeasurements())); + + pathTable->setItem(1, 0, new QTableWidgetItem(tr("Patterns"))); + pathTable->setItem(1, 1, new QTableWidgetItem(qApp->getSettings()->GetPathPattern())); + + pathTable->verticalHeader()->setDefaultSectionSize(20); + pathTable->resizeColumnsToContents(); + pathTable->resizeRowsToContents(); + pathTable->horizontalHeader()->setStretchLastSection(true); + + connect(pathTable, &QTableWidget::itemSelectionChanged, this, &PathPage::TableActivated); +} diff --git a/src/app/dialogs/app/configpages/pathpage.h b/src/app/dialogs/app/configpages/pathpage.h new file mode 100644 index 000000000..f51b83da0 --- /dev/null +++ b/src/app/dialogs/app/configpages/pathpage.h @@ -0,0 +1,58 @@ +/************************************************************************ + ** + ** @file pathpage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 PATHPAGE_H +#define PATHPAGE_H + +#include +#include + +class QGroupBox; +class QPushButton; +class QTableWidget; + +class PathPage : public QWidget +{ + Q_OBJECT +public: + PathPage(QWidget *parent = nullptr); + void Apply(); +public slots: + void TableActivated(); + void DefaultPath(); + void EditPath(); +private: + Q_DISABLE_COPY(PathPage) + QPushButton *defaultButton; + QPushButton *editButton; + QTableWidget *pathTable; + QGroupBox *PathGroup(); + void InitTable(); +}; + +#endif // PATHPAGE_H diff --git a/src/app/dialogs/app/configpages/patternpage.cpp b/src/app/dialogs/app/configpages/patternpage.cpp new file mode 100644 index 000000000..5b0669e1d --- /dev/null +++ b/src/app/dialogs/app/configpages/patternpage.cpp @@ -0,0 +1,127 @@ +/************************************************************************ + ** + ** @file patternpage.cpp + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 "patternpage.h" +#include "../../../options.h" +#include "../../../core/vapplication.h" +#include "../../../core/vsettings.h" +#include "../../../widgets/vmaingraphicsview.h" +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +PatternPage::PatternPage(QWidget *parent): + QWidget(parent), userName(nullptr), graphOutputCheck(nullptr), undoCount(nullptr) +{ + QGroupBox *userGroup = UserGroup(); + QGroupBox *graphOutputGroup = GraphOutputGroup(); + QGroupBox *undoGroup = UndoGroup(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(userGroup); + mainLayout->addWidget(graphOutputGroup); + mainLayout->addWidget(undoGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PatternPage::Apply() +{ + qApp->getSettings()->SetUser(userName->text()); + + // Scene antialiasing + qApp->getSettings()->SetGraphicalOutput(graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked()); + + /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a + * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack + * prints a warning and does nothing.*/ + qApp->getSettings()->SetUndoCount(undoCount->value()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::UserGroup() +{ + QGroupBox *userGroup = new QGroupBox(tr("User")); + QLabel *nameLabel = new QLabel(tr("User name")); + + userName = new QLineEdit; + userName->setText(qApp->getSettings()->GetUser()); + + QHBoxLayout *nameLayout = new QHBoxLayout; + nameLayout->addWidget(nameLabel); + nameLayout->addWidget(userName); + + QVBoxLayout *userLayout = new QVBoxLayout; + userLayout->addLayout(nameLayout); + userGroup->setLayout(userLayout); + return userGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::GraphOutputGroup() +{ + QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output")); + + graphOutputCheck = new QCheckBox(tr("Use antialiasing")); + graphOutputCheck->setChecked(qApp->getSettings()->GetGraphicalOutput()); + + QHBoxLayout *graphLayout = new QHBoxLayout; + graphLayout->addWidget(graphOutputCheck); + + QVBoxLayout *graphOutputLayout = new QVBoxLayout; + graphOutputLayout->addLayout(graphLayout); + graphOutputGroup->setLayout(graphOutputLayout); + return graphOutputGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *PatternPage::UndoGroup() +{ + QGroupBox *undoGroup = new QGroupBox(tr("Undo")); + QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)")); + undoCount = new QSpinBox; + undoCount->setMinimum(0); + undoCount->setValue(qApp->getSettings()->GetUndoCount()); + + QHBoxLayout *countLayout = new QHBoxLayout; + countLayout->addWidget(undoLabel); + countLayout->addWidget(undoCount); + + QVBoxLayout *undoLayout = new QVBoxLayout; + undoLayout->addLayout(countLayout); + undoGroup->setLayout(undoLayout); + return undoGroup; +} diff --git a/src/app/dialogs/app/configpages/patternpage.h b/src/app/dialogs/app/configpages/patternpage.h new file mode 100644 index 000000000..5040c7924 --- /dev/null +++ b/src/app/dialogs/app/configpages/patternpage.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file patternpage.h + ** @author Roman Telezhynskyi + ** @date 21 6, 2014 + ** + ** @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) 2014 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 PATTERNPAGE_H +#define PATTERNPAGE_H + +#include +#include + +class QCheckBox; +class QSpinBox; +class QGroupBox; +class QLineEdit; + +class PatternPage : public QWidget +{ + Q_OBJECT +public: + PatternPage(QWidget *parent = nullptr); + void Apply(); +private: + Q_DISABLE_COPY(PatternPage) + QLineEdit *userName; + QCheckBox *graphOutputCheck; + QSpinBox *undoCount; + QGroupBox *UserGroup(); + QGroupBox *GraphOutputGroup(); + QGroupBox *UndoGroup(); +}; + +#endif // PATTERNPAGE_H diff --git a/src/app/dialogs/app/dialogaboutapp.cpp b/src/app/dialogs/app/dialogaboutapp.cpp new file mode 100644 index 000000000..1961177c9 --- /dev/null +++ b/src/app/dialogs/app/dialogaboutapp.cpp @@ -0,0 +1,94 @@ +/************************************************************************ + ** + ** @file dialogaboutapp.cpp + ** @author Patrick Proy + ** @date 6 5, 2014 + ** + ** @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 + ** 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 "dialogaboutapp.h" +#include "ui_dialogaboutapp.h" +#include "../../version.h" +#include +#include +#include +#include "../../options.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutApp::DialogAboutApp(QWidget *parent) : + QDialog(parent), + ui(new Ui::DialogAboutApp) +{ + ui->setupUi(this); + + ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION)); + ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); + ui->label_QT_Version->setText(buildCompatibilityString()); + + QDate date = QLocale(QLocale::C).toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); + ui->label_Valentina_Built->setText(tr("Built on %3 at %4").arg(date.toString()).arg(__TIME__)); + + ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", + "The program is provided AS IS with NO WARRANTY OF ANY " + "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " + "AND FITNESS FOR A PARTICULAR PURPOSE.")); + + + ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, &DialogAboutApp::webButtonClicked ); + + // By default on Windows font point size 8 points we need 11 like on Linux. + FontPointSize(ui->label_Legal_Stuff, 11); + FontPointSize(ui->label_contrib_label, 11); + FontPointSize(ui->label_Valentina_Built, 11); + FontPointSize(ui->label_QT_Version, 11); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutApp::~DialogAboutApp() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutApp::FontPointSize(QWidget *w, int pointSize) +{ + SCASSERT(w != nullptr); + + QFont font = w->font(); + font.setPointSize(pointSize); + w->setFont(font); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Fake button clicked + */ +void DialogAboutApp::webButtonClicked() +{ + if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) + { + QMessageBox::warning(this, tr("Warning"), tr("Cannot open your default browser")); + } + +} diff --git a/src/exception/vexceptionconversionerror.cpp b/src/app/dialogs/app/dialogaboutapp.h similarity index 67% rename from src/exception/vexceptionconversionerror.cpp rename to src/app/dialogs/app/dialogaboutapp.h index cfc0634c5..97c07a104 100644 --- a/src/exception/vexceptionconversionerror.cpp +++ b/src/app/dialogs/app/dialogaboutapp.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file vexceptionconversionerror.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file dialogaboutapp.h + ** @author Patrick Proy + ** @date 6 5, 2014 ** ** @brief ** @copyright @@ -26,16 +26,32 @@ ** *************************************************************************/ -#include "vexceptionconversionerror.h" +#ifndef DIALOGABOUTAPP_H +#define DIALOGABOUTAPP_H -VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str) - :VException(what), str(str) +#include + +namespace Ui { - Q_ASSERT_X(str.isEmpty() == false, Q_FUNC_INFO, "Error converting string is empty"); + class DialogAboutApp; } -QString VExceptionConversionError::ErrorMessage() const +class DialogAboutApp : public QDialog { - QString error = QString("ExceptionConversionError: %1 %2").arg(what, str); - return error; -} + Q_OBJECT + +public: + explicit DialogAboutApp(QWidget *parent = 0); + ~DialogAboutApp(); + +private: + Ui::DialogAboutApp *ui; + Q_DISABLE_COPY(DialogAboutApp) + + void FontPointSize(QWidget *w, int pointSize); + +private slots: + void webButtonClicked(); +}; + +#endif // DIALOGABOUTAPP_H diff --git a/src/app/dialogs/app/dialogaboutapp.ui b/src/app/dialogs/app/dialogaboutapp.ui new file mode 100644 index 000000000..d17d84aa8 --- /dev/null +++ b/src/app/dialogs/app/dialogaboutapp.ui @@ -0,0 +1,345 @@ + + + DialogAboutApp + + + Qt::ApplicationModal + + + + 0 + 0 + 583 + 480 + + + + + 0 + 0 + + + + + 573 + 480 + + + + + 583 + 480 + + + + ArrowCursor + + + Qt::NoContextMenu + + + About Valentina + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + true + + + + + + 4 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + + + + :/icon/64x64/icon64x64.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 15 + 75 + true + + + + Valentina version + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + Build revision: + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + true + + + + PointingHandCursor + + + pushButton_Web_Site + + + false + + + true + + + + + + + + 0 + 0 + + + + Contributors + + + 3 + + + + + + + + 0 + 0 + + + + + 12 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + Roman Telezhinskyi +Susan Spencer +luzpazB +Christine Neupert +Sabine Schmaltz +grumpi +Steve Conklin +Patrick Proy + + + + + + + + 0 + 0 + + + + label_Valentina_Built + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + label_QT_Version + + + + + + + Qt::Vertical + + + + 20 + 45 + + + + + + + + label_Legal_Stuff + + + true + + + + + + + + + + + true + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + true + + + + + + + + + + + buttonBox + accepted() + DialogAboutApp + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogAboutApp + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp new file mode 100644 index 000000000..78b7c6d96 --- /dev/null +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -0,0 +1,471 @@ +/************************************************************************ + ** + ** @file dialoghistory.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialoghistory.h" +#include "ui_dialoghistory.h" +#include "../../geometry/varc.h" +#include "../../geometry/vsplinepath.h" +#include "../../geometry/vpointf.h" +#include "../../tools/vabstracttool.h" +#include "../../tools/drawTools/vtoolcutspline.h" +#include "../../tools/drawTools/vtoolcutsplinepath.h" +#include "../../tools/drawTools/vtoolcutarc.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogHistory create dialog + * @param data container with data + * @param doc dom document container + * @param parent parent widget + */ +DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) + :DialogTool(data, 0, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), + cursorToolRecordRow(0) +{ + ui->setupUi(this); + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); + FillTable(); + InitialTable(); + connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); + connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool); + connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); + connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); + ShowPoint(); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogHistory::~DialogHistory() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogAccepted save data and emit signal about closed dialog. + */ +void DialogHistory::DialogAccepted() +{ + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + quint32 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + emit DialogClosed(QDialog::Accepted); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief cellClicked changed history record + * @param row number row in table + * @param column number column in table + */ +void DialogHistory::cellClicked(int row, int column) +{ + if (column == 0) + { + QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + item->setIcon(QIcon()); + + item = ui->tableWidget->item(row, 0); + cursorRow = row; + item->setIcon(QIcon("://icon/32x32/put_after.png")); + quint32 id = qvariant_cast(item->data(Qt::UserRole)); + doc->blockSignals(true); + doc->setCursor(id); + doc->blockSignals(false); + } + else + { + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + quint32 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + + cursorToolRecordRow = row; + item = ui->tableWidget->item(cursorToolRecordRow, 0); + id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedCursor changed cursor of input. Cursor show after which record we will insert new object + * @param id id of object + */ +void DialogHistory::ChangedCursor(quint32 id) +{ + for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i) + { + QTableWidgetItem *item = ui->tableWidget->item(i, 0); + quint32 rId = qvariant_cast(item->data(Qt::UserRole)); + if (rId == id) + { + QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); + oldCursorItem->setIcon(QIcon()); + cursorRow = i; + item->setIcon(QIcon("://icon/32x32/put_after.png")); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateHistory update history table + */ +void DialogHistory::UpdateHistory() +{ + FillTable(); + InitialTable(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillTable fill table + */ +void DialogHistory::FillTable() +{ + ui->tableWidget->clear(); + QVector history = doc->getLocalHistory(); + qint32 currentRow = -1; + qint32 count = 0; + ui->tableWidget->setRowCount(history.size());//Make row count max possible number + for (qint32 i = 0; i< history.size(); ++i) + { + const VToolRecord tool = history.at(i); + const QString historyRecord = Record(tool); + if (historyRecord.isEmpty() ==false) + { + currentRow++; + + { + QTableWidgetItem *item = new QTableWidgetItem(QString()); + item->setTextAlignment(Qt::AlignHCenter); + item->setData(Qt::UserRole, tool.getId()); + ui->tableWidget->setItem(currentRow, 0, item); + } + + QTableWidgetItem *item = new QTableWidgetItem(historyRecord); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setFlags(item->flags() ^ Qt::ItemIsEditable); + ui->tableWidget->setItem(currentRow, 1, item); + ++count; + } + } + ui->tableWidget->setRowCount(count);//Real row count + if (count>0) + { + cursorRow = currentRow; + QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + SCASSERT(item != nullptr); + item->setIcon(QIcon("://icon/32x32/put_after.png")); + } + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); + ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Record return description for record + * @param tool record data + * @return description + */ +QString DialogHistory::Record(const VToolRecord &tool) +{ + const QDomElement domElem = doc->elementById(QString().setNum(tool.getId())); + if (domElem.isElement() == false) + { + qDebug()<<"Can't find element by id"< spl = data->GeometricObject(tool.getId()); + SCASSERT(spl != nullptr); + return QString(tr("Curve %1_%2")).arg(PointName(spl->GetP1().id())).arg(PointName(spl->GetP4().id())); + } + case Tool::Arc: + { + const QSharedPointer arc = data->GeometricObject(tool.getId()); + SCASSERT(arc != nullptr); + return QString(tr("Arc with center in point %1")).arg(PointName(arc->GetCenter().id())); + } + case Tool::SplinePath: + { + const QSharedPointer splPath = data->GeometricObject(tool.getId()); + SCASSERT(splPath != nullptr); + const QVector points = splPath->GetSplinePath(); + QString record; + if (points.size() != 0 ) + { + // We use only first and last point name in curve + record = QString(tr("Curve point %1")).arg(PointName(points.at(0).P().id())); + if (points.size() > 1) + { + record.append(QString("_%1").arg(PointName(points.last().P().id()))); + } + } + else + { + qDebug()<<"Not enough points in splinepath"< arc = data->GeometricObject(AttrUInt(domElem, VToolCutArc::AttrArc)); + SCASSERT(arc != nullptr); + return QString(tr("%1 - cut arc with center %2")) + .arg(PointName(tool.getId())) + .arg(PointName(arc->GetCenter().id())); + } + case Tool::CutSpline: + { + const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline); + const QSharedPointer spl = data->GeometricObject(splineId); + SCASSERT(spl != nullptr); + return QString(tr("%1 - cut curve %2_%3")) + .arg(PointName(tool.getId())) + .arg(PointName(spl->GetP1().id())) + .arg(PointName(spl->GetP4().id())); + } + case Tool::CutSplinePath: + { + const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath); + const QSharedPointer splPath = data->GeometricObject(splinePathId); + SCASSERT(splPath != nullptr); + const QVector points = splPath->GetSplinePath(); + QString record; + if (points.size() != 0 ) + { + record = QString(tr("%1 - cut curve path %2")) + .arg(PointName(tool.getId())) + .arg(PointName(points.at(0).P().id())); + if (points.size() > 1) + { + record.append(QString("_%1").arg(PointName(points.last().P().id()))); + } + } + else + { + qDebug()<<"Not enough points in splinepath"<tableWidget->setSortingEnabled(false); + ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); + ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool"))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowPoint show selected point + */ +void DialogHistory::ShowPoint() +{ + const QVector *history = doc->getHistory(); + if (history->size()>0) + { + QTableWidgetItem *item = ui->tableWidget->item(0, 1); + item->setSelected(true); + cursorToolRecordRow = 0; + item = ui->tableWidget->item(0, 0); + quint32 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogHistory::PointName return point name by id. + * + * Refacoring what hide ugly string getting point name by id. + * @param pointId point if in data. + * @return point name. + */ +QString DialogHistory::PointName(quint32 pointId) +{ + return data->GeometricObject(pointId)->name(); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogHistory::AttrUInt(const QDomElement &domElement, const QString &name) +{ + return doc->GetParametrUInt(domElement, name, "0"); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle when windows is closing + * @param event event + */ +void DialogHistory::closeEvent(QCloseEvent *event) +{ + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + quint32 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + DialogTool::closeEvent(event); +} diff --git a/src/dialogs/dialoghistory.h b/src/app/dialogs/app/dialoghistory.h similarity index 54% rename from src/dialogs/dialoghistory.h rename to src/app/dialogs/app/dialoghistory.h index 120fff0ee..20b18e6b6 100644 --- a/src/dialogs/dialoghistory.h +++ b/src/app/dialogs/app/dialoghistory.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file dialoghistory.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -29,8 +29,12 @@ #ifndef DIALOGHISTORY_H #define DIALOGHISTORY_H -#include "dialogtool.h" -#include "../xml/vdomdocument.h" +#include "../tools/dialogtool.h" + +#include + +class VPattern; +class VToolRecord; namespace Ui { @@ -44,33 +48,16 @@ class DialogHistory : public DialogTool { Q_OBJECT public: - /** - * @brief DialogHistory create dialog - * @param data container with data - * @param doc dom document container - * @param parent parent widget - */ - DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0); - virtual ~DialogHistory(); + DialogHistory(VContainer *data, VPattern *doc, QWidget *parent = nullptr); + virtual ~DialogHistory(); public slots: - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ virtual void DialogAccepted(); - /** - * @brief cellClicked changed history record - * @param row number row in table - * @param column number column in table - */ + /** TODO ISSUE 79 : create real function + * @brief DialogApply apply data and emit signal about applied dialog. + */ + virtual void DialogApply(){} void cellClicked(int row, int column); - /** - * @brief ChangedCursor changed cursor of input. Cursor show after what record we will insert new object - * @param id id of object - */ - void ChangedCursor(qint64 id); - /** - * @brief UpdateHistory update history table - */ + void ChangedCursor(quint32 id); void UpdateHistory(); signals: /** @@ -79,49 +66,30 @@ signals: * @param color new color of tool * @param enable true enable selection, false disable selection */ - void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); + void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); protected: - /** - * @brief closeEvent handle when windows is closing - * @param event event - */ virtual void closeEvent ( QCloseEvent * event ); private: Q_DISABLE_COPY(DialogHistory) - /** - * @brief ui keeps information about user interface - */ + + /** @brief ui keeps information about user interface */ Ui::DialogHistory *ui; - /** - * @brief doc dom document container - */ - VDomDocument *doc; - /** - * @brief cursorRow save number of row where is cursor - */ + + /** @brief doc dom document container */ + VPattern *doc; + + /** @brief cursorRow save number of row where is cursor */ qint32 cursorRow; - /** - * @brief cursorToolRecordRow save number of row selected record - */ + + /** @brief cursorToolRecordRow save number of row selected record */ qint32 cursorToolRecordRow; - /** - * @brief FillTable fill table - */ + void FillTable(); - /** - * @brief Record return description for record - * @param tool record data - * @return description - */ QString Record(const VToolRecord &tool); - /** - * @brief InitialTable set initial option of table - */ void InitialTable(); - /** - * @brief ShowPoint show selected point - */ void ShowPoint(); + QString PointName(quint32 pointId); + quint32 AttrUInt(const QDomElement &domElement, const QString &name); }; #endif // DIALOGHISTORY_H diff --git a/src/dialogs/dialoghistory.ui b/src/app/dialogs/app/dialoghistory.ui similarity index 96% rename from src/dialogs/dialoghistory.ui rename to src/app/dialogs/app/dialoghistory.ui index 20eaac344..1b7cb38bc 100644 --- a/src/dialogs/dialoghistory.ui +++ b/src/app/dialogs/app/dialoghistory.ui @@ -17,7 +17,7 @@ History - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -73,7 +73,7 @@ buttonBox - + diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp new file mode 100644 index 000000000..055979b35 --- /dev/null +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -0,0 +1,876 @@ +/************************************************************************ + ** + ** @file dialogincrements.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogincrements.h" +#include "ui_dialogincrements.h" +#include "../../widgets/doubledelegate.h" +#include "../../widgets/textdelegate.h" +#include "../../xml/vstandardmeasurements.h" +#include "../../xml/vindividualmeasurements.h" +#include "../../core/vsettings.h" + +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogIncrements create dialog + * @param data container with data + * @param doc dom document container + * @param parent parent widget + */ +DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent) + :DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), + m(nullptr) +{ + ui->setupUi(this); + + qCDebug(vDialog)<<"Showing variables."; + if (qApp->patternType() == MeasurementsType::Individual) + { + qCDebug(vDialog)<<"Pattern with individual measurements."; + const QString filePath = doc->MPath(); + try + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath); + m = new VIndividualMeasurements(data); + m->setXMLContent(filePath); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + emit DialogClosed(QDialog::Rejected); + return; + } + } + + ShowUnits(); + + TextDelegate *textDelegate = new TextDelegate(nameRegExp, data, ui->tableWidgetIncrement); + ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);// name + DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement); + ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);// base value + ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);// in sizes + ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);// in heights + + if (qApp->patternType() == MeasurementsType::Standard) + { + ui->checkBoxHideEmpty->setChecked(true); + } + + FillMeasurements(); + FillIncrements(); + FillLengthLines(); + FillLengthSplines(); + FillLengthArcs(); + + if (qApp->patternType() == MeasurementsType::Standard) + { + ui->toolBoxMeasurements->setItemEnabled(0, false); + } + else + { + QRegExpValidator *reg = new QRegExpValidator(QRegExp("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")); + ui->lineEditMail->setValidator(reg); + + HideColumns(ui->tableWidgetMeasurements); + HideColumns(ui->tableWidgetIncrement); + + ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);// base value + + connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged); + + ui->lineEditGivenName->setText(m->GivenName()); + ui->lineEditFamilyName->setText(m->FamilyName()); + + ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(SexType::Male))); + ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(SexType::Female))); + qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex())); + if (index != -1) + { + ui->comboBoxSex->setCurrentIndex(index); + } + + ui->dateEditBirthDate->setDate(m->BirthDate()); + ui->lineEditMail->setText(m->Mail()); + + connect(ui->lineEditGivenName, &QLineEdit::editingFinished, this, &DialogIncrements::SaveGivenName); + connect(ui->lineEditFamilyName, &QLineEdit::editingFinished, this, &DialogIncrements::SaveFamilyName); + connect(ui->lineEditMail, &QLineEdit::editingFinished, this, &DialogIncrements::SaveEmail); + connect(ui->comboBoxSex, static_cast(&QComboBox::currentIndexChanged), this, + &DialogIncrements::SaveSex); + connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &DialogIncrements::SaveBirthDate); + } + + ui->toolBoxMeasurements->setCurrentIndex(1); + + connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged); + connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd); + connect(ui->toolButtonRemove, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonRemove); + + connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VPattern::LiteParseTree); + connect(this, &DialogIncrements::haveLiteChange, this->doc, &VPattern::haveLiteChange); + connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + + ui->tabWidget->setCurrentIndex(0); + + connect(ui->toolButtonOpenMeasurements, &QToolButton::clicked, this, &DialogIncrements::OpenTable); + connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogIncrements::ShowMeasurements); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillMeasurements load measurements data + */ +void DialogIncrements::FillMeasurements() +{ + const QMap > table = data->DataMeasurements(); + qint32 currentRow = -1; + QMap >::const_iterator iMap; + ui->tableWidgetMeasurements->setRowCount ( table.size() ); + for (iMap = table.constBegin(); iMap != table.constEnd(); ++iMap) + { + QSharedPointer m = iMap.value(); + if (ui->checkBoxHideEmpty->isChecked() && m->IsNotUsed()) + { + continue; // skip this measurement + } + currentRow++; + + QTableWidgetItem *item = new QTableWidgetItem(QString(iMap.key())); + item->setTextAlignment(Qt::AlignHCenter); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setToolTip(m->GetGuiText()); + SetItemViewOnly(item); + item->setTextAlignment(Qt::AlignLeft); + ui->tableWidgetMeasurements->setItem(currentRow, 0, item); + + if (qApp->patternType() == MeasurementsType::Standard) + { + QTableWidgetItem *item = new QTableWidgetItem(QString() + .setNum(data->GetTableValue(qApp->VarFromUser(iMap.key())))); + item->setTextAlignment(Qt::AlignHCenter); + SetItemViewOnly(item); + ui->tableWidgetMeasurements->setItem(currentRow, 1, item);// calculated value + } + + item = new QTableWidgetItem(QString().setNum(m->GetBase())); + item->setTextAlignment(Qt::AlignHCenter); + if (qApp->patternType() == MeasurementsType::Standard) + { + SetItemViewOnly(item); + } + ui->tableWidgetMeasurements->setItem(currentRow, 2, item); + + if (qApp->patternType() == MeasurementsType::Standard) + { + QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m->GetKsize())); + item->setTextAlignment(Qt::AlignHCenter); + SetItemViewOnly(item); + ui->tableWidgetMeasurements->setItem(currentRow, 3, item);// in sizes + + item = new QTableWidgetItem(QString().setNum(m->GetKheight())); + item->setTextAlignment(Qt::AlignHCenter); + SetItemViewOnly(item); + ui->tableWidgetMeasurements->setItem(currentRow, 4, item);// in heights + } + + item = new QTableWidgetItem(m->GetDescription()); + item->setToolTip(m->GetDescription()); + SetItemViewOnly(item); + item->setTextAlignment(Qt::AlignLeft); + ui->tableWidgetMeasurements->setItem(currentRow, 5, item); + } + ui->tableWidgetMeasurements->setRowCount(currentRow+1); + ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20); + ui->tableWidgetMeasurements->resizeColumnsToContents(); + ui->tableWidgetMeasurements->resizeRowsToContents(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillIncrementTable fill data for increment table + */ +void DialogIncrements::FillIncrements() +{ + const QMap > increments = data->DataIncrements(); + QMap >::const_iterator i; + QMap map; + //Sorting QHash by id + for (i = increments.constBegin(); i != increments.constEnd(); ++i) + { + QSharedPointer incr = i.value(); + map.insert(incr->getId(), i.key()); + } + + qint32 currentRow = -1; + QMapIterator iMap(map); + while (iMap.hasNext()) + { + iMap.next(); + QSharedPointer incr = increments.value(iMap.value()); + currentRow++; + ui->tableWidgetIncrement->setRowCount ( increments.size() ); + + QTableWidgetItem *item = new QTableWidgetItem(iMap.value()); + item->setTextAlignment(Qt::AlignHCenter); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, incr->getId()); + ui->tableWidgetIncrement->setItem(currentRow, 0, item); + + if (qApp->patternType() == MeasurementsType::Standard) + { + item = new QTableWidgetItem(QString().setNum(data->GetTableValue(iMap.value()))); + item->setTextAlignment(Qt::AlignHCenter); + SetItemViewOnly(item); + ui->tableWidgetIncrement->setItem(currentRow, 1, item); + } + + item = new QTableWidgetItem(QString().setNum(incr->GetBase())); + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 2, item); + + if (qApp->patternType() == MeasurementsType::Standard) + { + item = new QTableWidgetItem(QString().setNum(incr->GetKsize())); + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 3, item); + + item = new QTableWidgetItem(QString().setNum(incr->GetKheight())); + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 4, item); + } + + item = new QTableWidgetItem(incr->GetDescription()); + item->setToolTip(incr->GetDescription()); + item->setTextAlignment(Qt::AlignLeft); + ui->tableWidgetIncrement->setItem(currentRow, 5, item); + } + if (ui->tableWidgetIncrement->rowCount()>0) + { + ui->toolButtonRemove->setEnabled(true); + } + ui->tableWidgetIncrement->resizeColumnsToContents(); + ui->tableWidgetIncrement->resizeRowsToContents(); + ui->tableWidgetIncrement->setCurrentCell( row, column ); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void DialogIncrements::FillTable(const QMap varTable, QTableWidget *table) +{ + SCASSERT(table != nullptr); + + qint32 currentRow = -1; + QMapIterator i(varTable); + while (i.hasNext()) + { + i.next(); + qreal length = *i.value()->GetValue(); + currentRow++; + table->setRowCount ( varTable.size() ); + + QTableWidgetItem *item = new QTableWidgetItem(i.key()); + item->setTextAlignment(Qt::AlignLeft); + item->setFont(QFont("Times", 12, QFont::Bold)); + table->setItem(currentRow, 0, item); + + item = new QTableWidgetItem(QString().setNum(length)); + item->setTextAlignment(Qt::AlignHCenter); + table->setItem(currentRow, 1, item); + } + table->resizeColumnsToContents(); + table->resizeRowsToContents(); + table->verticalHeader()->setDefaultSectionSize(20); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillLengthLines fill data for table of lines lengths + */ +void DialogIncrements::FillLengthLines() +{ + FillTable(data->DataLengthLines(), ui->tableWidgetLines); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillLengthSplines fill data for table of splines lengths + */ +void DialogIncrements::FillLengthSplines() +{ + FillTable(data->DataLengthSplines(), ui->tableWidgetSplines); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillLengthArcs fill data for table of arcs lengths + */ +void DialogIncrements::FillLengthArcs() +{ + FillTable(data->DataLengthArcs(), ui->tableWidgetArcs); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SetItemViewOnly(QTableWidgetItem *item) +{ + // set the item non-editable (view only), and non-selectable + Qt::ItemFlags flags = item->flags(); + flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag + item->setFlags(flags); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::ShowUnits() +{ + ShowHeaderUnits(ui->tableWidgetIncrement, 2);// base value + ShowHeaderUnits(ui->tableWidgetIncrement, 3);// in sizes + ShowHeaderUnits(ui->tableWidgetIncrement, 4);// in heights + + ShowHeaderUnits(ui->tableWidgetMeasurements, 2);// base value + ShowHeaderUnits(ui->tableWidgetMeasurements, 3);// in sizes + ShowHeaderUnits(ui->tableWidgetMeasurements, 4);// in heights + + ShowHeaderUnits(ui->tableWidgetLines, 1);// lengths + ShowHeaderUnits(ui->tableWidgetSplines, 1);// lengths + ShowHeaderUnits(ui->tableWidgetArcs, 1);// lengths +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::ShowHeaderUnits(QTableWidget *table, int column) +{ + SCASSERT(table != nullptr); + + const QString unit = VDomDocument::UnitsToStr(qApp->patternUnit()); + const QString header = table->horizontalHeaderItem(column)->text(); + const QString unitHeader = QString("%1 (%2)").arg(header).arg(unit); + table->horizontalHeaderItem(column)->setText(unitHeader); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::ShowMeasurements() +{ + if (qApp->patternType() == MeasurementsType::Individual) + { + ui->tableWidgetMeasurements->blockSignals(true); + } + ui->tableWidgetMeasurements->clearContents(); + FillMeasurements(); + ui->tableWidgetMeasurements->horizontalHeader()->setStretchLastSection(true); + if (qApp->patternType() == MeasurementsType::Individual) + { + ui->tableWidgetMeasurements->blockSignals(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update information in tables form file + */ +void DialogIncrements::FullUpdateFromFile() +{ + ShowMeasurements(); + + ui->tableWidgetIncrement->blockSignals(true); + ui->tableWidgetIncrement->clearContents(); + FillIncrements(); + ui->tableWidgetIncrement->horizontalHeader()->setStretchLastSection(true); + ui->tableWidgetIncrement->blockSignals(false); + + ui->tableWidgetLines->clearContents(); + FillLengthLines(); + + ui->tableWidgetSplines->clearContents(); + FillLengthSplines(); + + ui->tableWidgetArcs->clearContents(); + FillLengthArcs(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SaveGivenName() +{ + m->setGivenName(ui->lineEditGivenName->text()); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save GivenName")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SaveFamilyName() +{ + + m->setFamilyName(ui->lineEditFamilyName->text()); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save FamilyName")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SaveEmail() +{ + m->setMail(ui->lineEditMail->text()); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save Email")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SaveSex(int index) +{ + m->setSex(m->StrToGender(ui->comboBoxSex->itemData(index).toString())); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save Sex")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::SaveBirthDate(const QDate & date) +{ + m->setBirthDate(date); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save BirthDate")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::OpenTable() +{ + QString text = tr("Measurements use different units than pattern. This pattern required measurements in %1") + .arg(doc->UnitsToStr(qApp->patternUnit())); + if (qApp->patternType() == MeasurementsType::Individual) + { + const QString filter(tr("Individual measurements (*.vit)")); + + //Use standard path to individual measurements + const QString path = qApp->getSettings()->GetPathIndividualMeasurements(); + + const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); + if (filePath.isEmpty()) + { + return; + } + + VIndividualMeasurements *m1 = nullptr; + try + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath); + + m1 = new VIndividualMeasurements(data); + m1->setXMLContent(filePath); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + delete m1; + emit DialogClosed(QDialog::Rejected); + return; + } + Unit mUnit = m1->MUnit(); + if (qApp->patternUnit() != mUnit) + { + QMessageBox::critical(this, tr("Wrong units."), text); + delete m1; + return; + } + delete m; + m = m1; + data->ClearVariables(VarType::Measurement); + m->Measurements(); + emit FullUpdateTree(Document::LiteParse); + + doc->SetPath(filePath); + emit haveLiteChange(); + } + else + { + const QString filter(tr("Standard measurements (*.vst)")); + const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), qApp->pathToTables(), filter); + if (filePath.isEmpty()) + { + return; + } + + VStandardMeasurements *m1 = nullptr; + try + { + VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath); + + m1 = new VStandardMeasurements(data); + m1->setXMLContent(filePath); + Unit mUnit = m1->MUnit(); + if (qApp->patternUnit() != mUnit) + { + QMessageBox::critical(this, tr("Wrong units."), text); + delete m1; + return; + } + m1->SetSize(); + m1->SetHeight(); + data->ClearVariables(VarType::Measurement); + m1->Measurements(); + delete m1; + emit FullUpdateTree(Document::LiteParse); + + doc->SetPath(filePath); + emit haveLiteChange(); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + delete m1; + emit DialogClosed(QDialog::Rejected); + return; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief clickedToolButtonAdd create new row in table + */ +void DialogIncrements::clickedToolButtonAdd() +{ + qCDebug(vDialog)<<"Add new increment"; + ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason); + ui->tableWidgetIncrement->blockSignals(true); + qint32 currentRow = ui->tableWidgetIncrement->rowCount(); + ui->tableWidgetIncrement->insertRow( currentRow ); + + qint32 num = 1; + QString name; + do + { + name = QString(tr("Name_%1")).arg(num); + num++; + } while (data->IsUnique(name)==false); + + const quint32 id = data->getNextId(); + const QString description(tr("Description")); + VIncrement *incr = new VIncrement(name, id, 0, 0, 0, description); + data->AddVariable(name, incr); + + AddIncrementToFile(id, name, 0, 0, 0, description); + + QTableWidgetItem *item = new QTableWidgetItem(name); + item->setTextAlignment(Qt::AlignHCenter); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, id); + ui->tableWidgetIncrement->setItem(currentRow, 0, item); + ui->tableWidgetIncrement->setCurrentCell(currentRow, 0, QItemSelectionModel::ClearAndSelect); + + item = new QTableWidgetItem("0");// calculated value + item->setTextAlignment(Qt::AlignHCenter); + // set the item non-editable (view only), and non-selectable + Qt::ItemFlags flags = item->flags(); + flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag + item->setFlags(flags); + ui->tableWidgetIncrement->setItem(currentRow, 1, item); + + item = new QTableWidgetItem("0");// base value + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 2, item); + + item = new QTableWidgetItem("0");// in sizes + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 3, item); + + item = new QTableWidgetItem("0"); // in heights + item->setTextAlignment(Qt::AlignHCenter); + ui->tableWidgetIncrement->setItem(currentRow, 4, item); + + item = new QTableWidgetItem(description); + item->setTextAlignment(Qt::AlignLeft); + ui->tableWidgetIncrement->setItem(currentRow, 5, item); + + ui->toolButtonRemove->setEnabled(true); + ui->tableWidgetIncrement->blockSignals(false); + emit haveLiteChange(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief clickedToolButtonRemove remove one row from table + */ +void DialogIncrements::clickedToolButtonRemove() +{ + ui->tableWidgetIncrement->blockSignals(true); + + QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem(); + qint32 row = item->row(); + + QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0); + qCDebug(vDialog)<<"Remove increment"<text(); + data->RemoveIncrement(itemName->text()); + + quint32 id = qvariant_cast(itemName->data(Qt::UserRole)); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements); + list.at(0).removeChild(domElement); + } + else + { + qCDebug(vDialog)<<"Could not find object with id"<tableWidgetIncrement->removeRow(row); + if (ui->tableWidgetIncrement->rowCount() == 0) + { + ui->toolButtonRemove->setEnabled(false); + } + + ui->tableWidgetIncrement->blockSignals(false); + emit haveLiteChange(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddIncrementToFile save created increment to file + * @param id id of increment + * @param name name + * @param base base value + * @param ksize increment in sizes + * @param kheight increment in heights + * @param description description of increment + */ +void DialogIncrements::AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, const qreal &ksize, + const qreal &kheight, const QString &description) +{ + qCDebug(vDialog)<<"Saving new increment to file."; + qCDebug(vDialog)<createElement(VPattern::TagIncrement); + + doc->SetAttribute(element, VDomDocument::AttrId, id); + doc->SetAttribute(element, VPattern::IncrementName, name); + doc->SetAttribute(element, VPattern::IncrementBase, base); + doc->SetAttribute(element, VPattern::IncrementKsize, ksize); + doc->SetAttribute(element, VPattern::IncrementKgrowth, kheight); + doc->SetAttribute(element, VPattern::IncrementDescription, description); + + QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements); + list.at(0).appendChild(element); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::HideColumns(QTableWidget *table) +{ + SCASSERT(table != nullptr); + + table->setColumnHidden( 1, true );// calculated value + table->setColumnHidden( 3, true );// in sizes + table->setColumnHidden( 4, true );// in heights +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief cellChanged cell in table was changed + * @param row number of row + * @param column number of column + */ +void DialogIncrements::IncrementChanged ( qint32 row, qint32 column ) +{ + qCDebug(vDialog)<<"Increment changed."; + const QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0); + const QTableWidgetItem *item = ui->tableWidgetIncrement->item(row, column); + const quint32 id = qvariant_cast(itemName->data(Qt::UserRole)); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement() == false) + { + qCDebug(vDialog)<<"Cant't find increment with id = "<row = row; + switch (column) + { + case 0: // VPattern::IncrementName + qCDebug(vDialog)<<"Changed name to"<text(); + doc->SetAttribute(domElement, VPattern::IncrementName, item->text()); + data->ClearVariables(VarType::Increment); + this->column = 2; + emit FullUpdateTree(Document::LiteParse); + break; + case 2: // VPattern::IncrementBase + qCDebug(vDialog)<<"Changed base to"<text(); + doc->SetAttribute(domElement, VPattern::IncrementBase, item->text()); + this->column = 3; + emit FullUpdateTree(Document::LiteParse); + break; + case 3: // VPattern::IncrementKsize + qCDebug(vDialog)<<"Changed ksize to"<text(); + doc->SetAttribute(domElement, VPattern::IncrementKsize, item->text()); + this->column = 4; + emit FullUpdateTree(Document::LiteParse); + break; + case 4: // VPattern::IncrementKgrowth + qCDebug(vDialog)<<"Changed kheight to"<text(); + doc->SetAttribute(domElement, VPattern::IncrementKgrowth, item->text()); + this->column = 5; + emit FullUpdateTree(Document::LiteParse); + break; + case 5: // VPattern::IncrementDescription + { + qCDebug(vDialog)<<"Changed description to"<text(); + doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text()); + QSharedPointer incr = data->GetVariable(itemName->text()); + incr->SetDescription(item->text()); + ui->tableWidgetIncrement->resizeColumnsToContents(); + ui->tableWidgetIncrement->resizeRowsToContents(); + this->column = 0; + ui->tableWidgetIncrement->setCurrentCell( row, this->column ); + ui->tableWidgetIncrement->horizontalHeader()->setStretchLastSection(true); + break; + } + default: + break; + } + emit haveLiteChange(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::MeasurementChanged(qint32 row, qint32 column) +{ + qCDebug(vDialog)<<"Measurement changed."; + switch (column) + { + case 2:// value column + { + const QTableWidgetItem *itemName = ui->tableWidgetMeasurements->item(row, 0);// name column + QTableWidgetItem *item = ui->tableWidgetMeasurements->item(row, 2); + + QSharedPointer measur = data->GetVariable(qApp->VarFromUser(itemName->text())); + const QString tag = measur->TagName(); + QDomNodeList list = m->elementsByTagName(tag); + QDomElement domElement = list.at(0).toElement(); + if (domElement.isElement() == false) + { + qCDebug(vDialog)<<"Can't find measurement "<text().replace(",", ".").toDouble(&ok); + if (ok == false) + { + measur->SetBase(0); + item->setText("0"); + qCDebug(vDialog)<<"Can't convert toDouble measurement value"<SetBase(base); + } + qCDebug(vDialog)<<"Changed value to"<patternUnit(), m->MUnit()); + + m->SetAttribute(domElement, VIndividualMeasurements::AttrValue, QString("%1").arg(base)); + QString error; + if (m->SaveDocument(doc->MPath(), error) == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Can't save measurement")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } + + data->ClearVariables(); + m->Measurements(); + + emit FullUpdateTree(Document::LiteParse); + break; + } + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::closeEvent(QCloseEvent *event) +{ + emit DialogClosed(QDialog::Accepted); + event->accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogIncrements::~DialogIncrements() +{ + delete ui; + delete m; +} diff --git a/src/app/dialogs/app/dialogincrements.h b/src/app/dialogs/app/dialogincrements.h new file mode 100644 index 000000000..558ad65ff --- /dev/null +++ b/src/app/dialogs/app/dialogincrements.h @@ -0,0 +1,112 @@ +/************************************************************************ + ** + ** @file dialogincrements.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGINCREMENTS_H +#define DIALOGINCREMENTS_H + +#include "../tools/dialogtool.h" +#include "../../xml/vpattern.h" + +class VIndividualMeasurements; +class QTableWidget; +class QTableWidgetItem; + +namespace Ui +{ + class DialogIncrements; +} + +/** + * @brief The DialogIncrements class show dialog increments. Tables of all variables in program will be here. + */ +class DialogIncrements : public DialogTool +{ + Q_OBJECT +public: + DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr); + ~DialogIncrements(); +public slots: + void clickedToolButtonAdd(); + void clickedToolButtonRemove(); + void IncrementChanged ( qint32 row, qint32 column ); + void MeasurementChanged ( qint32 row, qint32 column ); + void FullUpdateFromFile(); + void SaveGivenName(); + void SaveFamilyName(); + void SaveEmail(); + void SaveSex(int index); + void SaveBirthDate(const QDate & date); + void OpenTable(); + void ShowMeasurements(); +signals: + /** + * @brief FullUpdateTree signal update data for dom document + */ + void FullUpdateTree(const Document &parse); + /** + * @brief haveLiteChange signal show sign of change + */ + void haveLiteChange(); +protected: + virtual void closeEvent ( QCloseEvent * event ); +private: + Q_DISABLE_COPY(DialogIncrements) + + /** @brief ui keeps information about user interface */ + Ui::DialogIncrements *ui; + + /** @brief data container with data */ + VContainer *data; // need because we must change data + + /** @brief doc dom document container */ + VPattern *doc; + + /** @brief row save number of row current selected cell */ + qint32 row; + + /** @brief column save number of column current selected cell */ + qint32 column; + + VIndividualMeasurements *m; + + void FillMeasurements(); + void FillIncrements(); + template + void FillTable(const QMap varTable, QTableWidget *table); + void FillLengthLines(); + void FillLengthSplines(); + void FillLengthArcs(); + void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, + const qreal &ksize, const qreal &kheight, const QString &description); + void HideColumns(QTableWidget *table); + void SetItemViewOnly(QTableWidgetItem *item); + void ShowUnits(); + void ShowHeaderUnits(QTableWidget *table, int column); +}; + +#endif // DIALOGINCREMENTS_H diff --git a/src/app/dialogs/app/dialogincrements.ui b/src/app/dialogs/app/dialogincrements.ui new file mode 100644 index 000000000..d55672606 --- /dev/null +++ b/src/app/dialogs/app/dialogincrements.ui @@ -0,0 +1,629 @@ + + + DialogIncrements + + + + 0 + 0 + 979 + 574 + + + + + 800 + 0 + + + + Increments + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + + 1 + 0 + + + + QTabWidget::North + + + 0 + + + + + 0 + 0 + + + + Measurements + + + + + + 6 + + + + + + 0 + 0 + + + + Load another measurements table + + + + + + + + 0 + 0 + + + + ... + + + + + + + + + + + + + + true + + + + 0 + 1 + + + + + 0 + 0 + + + + 1 + + + + true + + + + 0 + 0 + 939 + 411 + + + + + :/icon/16x16/info.png:/icon/16x16/info.png + + + Personal information + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Given name + + + + + + + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + Family name + + + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Birth date + + + + + + + yyyy-MM-dd + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Sex + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Email + + + + + + + + + + + + + + 0 + 0 + 939 + 411 + + + + + :/icon/16x16/measurement.png:/icon/16x16/measurement.png + + + Measurements + + + + + + Hide empty measurements + + + + + + + true + + + Qt::LeftToRight + + + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + 95 + + + 25 + + + false + + + true + + + false + + + 45 + + + 8 + + + + Name + + + + + The calculated value + + + + + Base value + + + + + In sizes + + + + + In heights + + + + + Description + + + + + + + + + + + + + Increments + + + + + + false + + + ... + + + + + + + + + + + + true + + + QAbstractItemView::SingleSelection + + + false + + + true + + + false + + + 120 + + + 70 + + + false + + + true + + + false + + + false + + + 25 + + + 8 + + + false + + + + Name + + + + + The calculated value + + + + + Base value + + + + + In sizes + + + + + In heights + + + + + Description + + + + + + + + ... + + + + + + + + + + + + + Lines + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + 137 + + + false + + + false + + + + Line + + + + + Length + + + + + + + + + Curves + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + 137 + + + false + + + false + + + + Curve + + + + + Length + + + + + + + + + Arcs + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + 137 + + + false + + + false + + + + Arc + + + + + Length + + + + + + + + + + + + tableWidgetMeasurements + tableWidgetIncrement + toolButtonAdd + toolButtonRemove + tableWidgetLines + tableWidgetSplines + tableWidgetArcs + + + + + + diff --git a/src/app/dialogs/app/dialogindividualmeasurements.cpp b/src/app/dialogs/app/dialogindividualmeasurements.cpp new file mode 100644 index 000000000..8adcc8649 --- /dev/null +++ b/src/app/dialogs/app/dialogindividualmeasurements.cpp @@ -0,0 +1,262 @@ +/************************************************************************ + ** + ** @file dialogindividualmeasurements.cpp + ** @author Roman Telezhynskyi + ** @date 22 2, 2014 + ** + ** @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 + ** 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 "dialogindividualmeasurements.h" +#include "ui_dialogindividualmeasurements.h" +#include "../../xml/vindividualmeasurements.h" +#include "../../core/vapplication.h" +#include "../../core/vsettings.h" +#include "../../container/vcontainer.h" + +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, + QWidget *parent) : + QDialog(parent), ui(new Ui::DialogIndividualMeasurements), _name(patternPieceName), _tablePath(QString()), + data(data) +{ + ui->setupUi(this); + + QRect position = this->frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); + + { + const QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + connect(bOk, &QPushButton::clicked, this, &DialogIndividualMeasurements::DialogAccepted); + } + { + const QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCansel != nullptr); + connect(bCansel, &QPushButton::clicked, this, &DialogIndividualMeasurements::DialogRejected); + } + + ui->lineEditName->setText(_name); + + InitUnits(); + CheckState(); + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogIndividualMeasurements::CheckState); + connect(ui->buttonGroupPath, static_cast(&QButtonGroup::buttonClicked), this, + &DialogIndividualMeasurements::CheckState); + connect(ui->toolButtonOpenExist, &QToolButton::clicked, this, &DialogIndividualMeasurements::OpenTable); + connect(ui->toolButtonOpenNew, &QToolButton::clicked, this, &DialogIndividualMeasurements::NewTable); + this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogIndividualMeasurements::~DialogIndividualMeasurements() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIndividualMeasurements::DialogAccepted() +{ + _name = ui->lineEditName->text(); + if (ui->radioButtonExistM->isChecked()) + { + _tablePath = ui->lineEditPathExistM->text(); + } + else + { + _tablePath = ui->lineEditPathNewM->text(); + QFile table(_tablePath); + if (table.exists()) + { + table.remove(); + } + + //just in case + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", qApp->pathToTables()); + QFile iMeasur(qApp->pathToTables()); + //TODO maybe make copy save? + if ( iMeasur.copy(_tablePath) == false ) + { + QMessageBox::warning(this, tr("Could not create measurements file"), tr("Please try again or change file")); + DialogRejected(); + } + } + try + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath); + VIndividualMeasurements m(data); + m.setXMLContent(_tablePath); + const qint32 index = ui->comboBoxUnits->currentIndex(); + Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); + m.setUnit(unit); + qApp->setPatternUnit( m.MUnit()); + QFile iMeasur(_tablePath); + if (iMeasur.open(QIODevice::WriteOnly| QIODevice::Truncate)) + { + const int indent = 4; + QTextStream out(&iMeasur); + out.setCodec("UTF-8"); + m.save(out, indent); + iMeasur.close(); + } + iMeasur.setPermissions(QFile::ReadOwner | QFile::WriteOwner); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + qDebug()<<"File error."<lineEditName->text().isEmpty() == false) + { + flagName = true; + } + + bool flagPath = false; + if (ui->radioButtonExistM->isChecked()) + { + ui->labelGivenName->setEnabled(true); + ui->labelFamilyName->setEnabled(true); + ui->lineEditPathExistM->setEnabled(true); + ui->toolButtonOpenExist->setEnabled(true); + + ui->lineEditPathNewM->setEnabled(false); + ui->toolButtonOpenNew->setEnabled(false); + ui->comboBoxUnits->setEnabled(false); + + if (ui->lineEditPathExistM->text().isEmpty() == false) + { + flagPath = true; + } + } + else + { + ui->lineEditPathNewM->setEnabled(true); + ui->toolButtonOpenNew->setEnabled(true); + ui->comboBoxUnits->setEnabled(true); + + ui->labelGivenName->setEnabled(false); + ui->labelFamilyName->setEnabled(false); + ui->toolButtonOpenExist->setEnabled(false); + ui->lineEditPathExistM->setEnabled(false); + + if (ui->lineEditPathNewM->text().isEmpty() == false) + { + flagPath = true; + } + } + + + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagName && flagPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIndividualMeasurements::OpenTable() +{ + const QString filter(tr("Individual measurements (*.vit)")); + const QString path = qApp->getSettings()->GetPathIndividualMeasurements(); + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); + if (fileName.isEmpty()) + { + return; + } + + try + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fileName); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + fileName.clear(); + } + VIndividualMeasurements m(data); + m.setXMLContent(fileName); + ui->labelGivenName->setText(m.GivenName()); + ui->labelFamilyName->setText(m.FamilyName()); + ui->lineEditPathExistM->setText(fileName); + ui->lineEditPathExistM->setToolTip(fileName); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIndividualMeasurements::NewTable() +{ + QString dir = QDir::homePath()+"/measurements.vit"; + QString name = QFileDialog::getSaveFileName(this, tr("Where save measurements?"), dir, + tr("Individual measurements (*.vit)")); + + if (name.isEmpty()) + { + return; + } + + // what if the users did not specify a suffix...? + QFileInfo f( name ); + if (f.suffix().isEmpty() && f.suffix() != "vit") + { + name += ".vit"; + } + ui->lineEditPathNewM->setText(name); + ui->lineEditPathNewM->setToolTip(name); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogIndividualMeasurements::InitUnits() +{ + ui->comboBoxUnits->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); + ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); + ui->comboBoxUnits->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); + + // set default unit + const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->getSettings()->GetUnit()); + if (indexUnit != -1) + { + ui->comboBoxUnits->setCurrentIndex(indexUnit); + } +} diff --git a/src/app/dialogs/app/dialogindividualmeasurements.h b/src/app/dialogs/app/dialogindividualmeasurements.h new file mode 100644 index 000000000..c133c4799 --- /dev/null +++ b/src/app/dialogs/app/dialogindividualmeasurements.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file dialogindividualmeasurements.h + ** @author Roman Telezhynskyi + ** @date 22 2, 2014 + ** + ** @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 + ** 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 DIALOGINDIVIDUALMEASUREMENTS_H +#define DIALOGINDIVIDUALMEASUREMENTS_H + +#include + +class VContainer; + +namespace Ui +{ + class DialogIndividualMeasurements; +} + +class DialogIndividualMeasurements : public QDialog +{ + Q_OBJECT +public: + DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); + ~DialogIndividualMeasurements(); + QString name() const; + QString tablePath() const; +public slots: + void OpenTable(); + void NewTable(); + void CheckState(); + void DialogAccepted(); + void DialogRejected(); +private: + Q_DISABLE_COPY(DialogIndividualMeasurements) + Ui::DialogIndividualMeasurements *ui; + QString _name; + QString _tablePath; + VContainer *data; + void InitUnits(); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QString DialogIndividualMeasurements::name() const +{ + return _name; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QString DialogIndividualMeasurements::tablePath() const +{ + return _tablePath; +} + +#endif // DIALOGINDIVIDUALMEASUREMENTS_H diff --git a/src/app/dialogs/app/dialogindividualmeasurements.ui b/src/app/dialogs/app/dialogindividualmeasurements.ui new file mode 100644 index 000000000..68b90e10a --- /dev/null +++ b/src/app/dialogs/app/dialogindividualmeasurements.ui @@ -0,0 +1,288 @@ + + + DialogIndividualMeasurements + + + Qt::ApplicationModal + + + + 0 + 0 + 385 + 295 + + + + Individual measurements + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true + + + + + + + + Pattern piece name + + + + + + + + + + + + + + Exist measurements + + + false + + + buttonGroupPath + + + + + + + + + Path: + + + + + + + true + + + + + + + ... + + + + + + + + + + + + + + QLayout::SetMinimumSize + + + + + true + + + + 0 + 0 + + + + + 90 + 0 + + + + Given name: + + + + + + + + 1 + 0 + + + + + + + true + + + + + + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + + 90 + 0 + + + + Family name: + + + + + + + + 1 + 0 + + + + + + + true + + + + + + + + + + + + + New measurements + + + true + + + buttonGroupPath + + + + + + + + + Units: + + + + + + + + + + + + + + Path: + + + + + + + true + + + + + + + ... + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogIndividualMeasurements + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogIndividualMeasurements + reject() + + + 316 + 260 + + + 286 + 274 + + + + + + + + diff --git a/src/app/dialogs/app/dialogmeasurements.cpp b/src/app/dialogs/app/dialogmeasurements.cpp new file mode 100644 index 000000000..af84fc440 --- /dev/null +++ b/src/app/dialogs/app/dialogmeasurements.cpp @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file dialogpatterntype.cpp + ** @author Roman Telezhynskyi + ** @date 21 2, 2014 + ** + ** @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 + ** 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 "dialogmeasurements.h" +#include "ui_dialogmeasurements.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogMeasurements::DialogMeasurements(QWidget *parent) : + QDialog(parent), ui(new Ui::DialogMeasurements), result(MeasurementsType::Individual) +{ + ui->setupUi(this); + connect(ui->toolButtonStandard, &QToolButton::clicked, this, &DialogMeasurements::StandardMeasurements); + connect(ui->toolButtonIndividual, &QToolButton::clicked, this, &DialogMeasurements::IndividualMeasurements); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogMeasurements::~DialogMeasurements() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +MeasurementsType DialogMeasurements::type() const +{ + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMeasurements::StandardMeasurements() +{ + result = MeasurementsType::Standard; + accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMeasurements::IndividualMeasurements() +{ + result = MeasurementsType::Individual; + accept(); +} diff --git a/src/widgets/vapplication.h b/src/app/dialogs/app/dialogmeasurements.h similarity index 64% rename from src/widgets/vapplication.h rename to src/app/dialogs/app/dialogmeasurements.h index 03a099690..6b4bc3941 100644 --- a/src/widgets/vapplication.h +++ b/src/app/dialogs/app/dialogmeasurements.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file vapplication.h - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file dialogpatterntype.h + ** @author Roman Telezhynskyi + ** @date 21 2, 2014 ** ** @brief ** @copyright @@ -26,32 +26,30 @@ ** *************************************************************************/ -#ifndef VAPPLICATION_H -#define VAPPLICATION_H +#ifndef DIALOGMEASUREMENTS_H +#define DIALOGMEASUREMENTS_H -#include +#include +#include "../../options.h" -/** - * @brief The VApplication class - */ -class VApplication : public QApplication +namespace Ui +{ + class DialogMeasurements; +} + +class DialogMeasurements : public QDialog { Q_OBJECT public: - /** - * @brief VApplication - * @param argc - * @param argv - */ - VApplication(int &argc, char ** argv): QApplication(argc, argv){} - virtual ~VApplication() {} - /** - * @brief notify - * @param receiver - * @param event - * @return - */ - virtual bool notify(QObject * receiver, QEvent * event); + explicit DialogMeasurements(QWidget *parent = nullptr); + ~DialogMeasurements(); + MeasurementsType type() const; +private: + Q_DISABLE_COPY(DialogMeasurements) + Ui::DialogMeasurements *ui; + MeasurementsType result; + void StandardMeasurements(); + void IndividualMeasurements(); }; -#endif // VAPPLICATION_H +#endif // DIALOGMEASUREMENTS_H diff --git a/src/app/dialogs/app/dialogmeasurements.ui b/src/app/dialogs/app/dialogmeasurements.ui new file mode 100644 index 000000000..2f4d16d62 --- /dev/null +++ b/src/app/dialogs/app/dialogmeasurements.ui @@ -0,0 +1,170 @@ + + + DialogMeasurements + + + Qt::ApplicationModal + + + + 0 + 0 + 448 + 244 + + + + + 448 + 244 + + + + + 529 + 244 + + + + Measurements + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true + + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> + + + Qt::AlignCenter + + + + + + + + + + + + 166 + 123 + + + + + 166 + 123 + + + + Graduation + + + + :/icon/Graduation.png:/icon/Graduation.png + + + + 160 + 120 + + + + + + + + + 0 + 0 + + + + Use for creation pattern standard measurement table + + + true + + + + + + + + + + + + 166 + 123 + + + + + 166 + 123 + + + + Individual + + + + :/icon/individual.png:/icon/individual.png + + + + 160 + 120 + + + + + + + + + 0 + 0 + + + + Use for creation pattern individual measurements + + + true + + + + + + + + + + + + + toolButtonStandard + + + + + + diff --git a/src/app/dialogs/app/dialogpatternproperties.cpp b/src/app/dialogs/app/dialogpatternproperties.cpp new file mode 100644 index 000000000..51e68a418 --- /dev/null +++ b/src/app/dialogs/app/dialogpatternproperties.cpp @@ -0,0 +1,400 @@ +/************************************************************************ + ** + ** @file dialogpatternproperties.cpp + ** @author Roman Telezhynskyi + ** @date 18 2, 2014 + ** + ** @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 + ** 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 "dialogpatternproperties.h" +#include "ui_dialogpatternproperties.h" +#include +#include "../../xml/vpattern.h" +#include "../../core/vapplication.h" + +#define MAX_HEIGHTS 18 +#define MAX_SIZES 18 + +//--------------------------------------------------------------------------------------------------------------------- +DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) : + QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS), + sizesChecked(MAX_SIZES), heights (QMap()), sizes(QMap()), + data(QMap()), descriptionChanged(false), gradationChanged(false) +{ + ui->setupUi(this); + + SCASSERT(doc != nullptr); + + ui->lineEditAuthor->setText(doc->GetAuthor()); + connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited); + + ui->plainTextEditDescription->setPlainText(doc->GetDescription()); + connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited); + + ui->plainTextEditTechNotes->setPlainText(doc->GetNotes()); + connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited); + + connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok); + connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, + &DialogPatternProperties::Apply); + + QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCansel != nullptr); + connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close); + + ui->tabWidget->setCurrentIndex(0); + if (qApp->patternType() == MeasurementsType::Individual) + { + ui->tabWidget->setTabEnabled(1, false); + } + + InitHeights(); + InitSizes(); + + heights = doc->GetGradationHeights(); + sizes = doc->GetGradationSizes(); + + SetOptions(heights); + SetOptions(sizes); + + gradationChanged = false;//Set to default value after initialization +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPatternProperties::~DialogPatternProperties() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::Apply() +{ + switch (ui->tabWidget->currentIndex()) + { + case 0: + SaveDescription(); + descriptionChanged = false; + break; + case 1: + SaveGradation(); + gradationChanged = false; + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::Ok() +{ + if (descriptionChanged) + { + SaveDescription(); + descriptionChanged = false; + } + + if (gradationChanged) + { + SaveGradation(); + gradationChanged = false; + } + + close(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SelectAll(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + if (box == ui->checkBoxAllHeights) + { + if (state == Qt::Checked) + { + SetHeightsChecked(true); + } + else if (state == Qt::Unchecked) + { + SetHeightsChecked(false); + } + + if (data.contains(box)) + { + heights.insert(static_cast(data.value(box)), box->isChecked()); + } + } + + if (box == ui->checkBoxAllSizes) + { + if (state == Qt::Checked) + { + SetSizesChecked(true); + } + else if (state == Qt::Unchecked) + { + SetSizesChecked(false); + } + + if (data.contains(box)) + { + sizes.insert(static_cast(data.value(box)), box->isChecked()); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::CheckStateHeight(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + if (state == Qt::Checked) + { + ++heightsChecked; + if (heightsChecked == MAX_HEIGHTS) + { + ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes + ui->checkBoxAllHeights->setCheckState(Qt::Checked); + heights.insert(GHeights::ALL, true); + ui->checkBoxAllHeights->blockSignals(false); + } + } + else if (state == Qt::Unchecked) + { + if (heightsChecked == MAX_HEIGHTS) + { + ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes + ui->checkBoxAllHeights->setCheckState(Qt::Unchecked); + heights.insert(GHeights::ALL, false); + ui->checkBoxAllHeights->blockSignals(false); + } + --heightsChecked; + } + + if (data.contains(box)) + { + heights.insert(static_cast(data.value(box)), box->isChecked()); + } + + CheckApplyOk(); + gradationChanged = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::CheckStateSize(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + + if (state == Qt::Checked) + { + ++sizesChecked; + if (sizesChecked == MAX_SIZES) + { + ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes + ui->checkBoxAllSizes->setCheckState(Qt::Checked); + sizes.insert(GSizes::ALL, true); + ui->checkBoxAllSizes->blockSignals(false); + } + } + else if (state == Qt::Unchecked) + { + if (sizesChecked == MAX_SIZES) + { + ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes + ui->checkBoxAllSizes->setCheckState(Qt::Unchecked); + sizes.insert(GSizes::ALL, false); + ui->checkBoxAllSizes->blockSignals(false); + } + --sizesChecked; + } + + if (data.contains(box)) + { + sizes.insert(static_cast(data.value(box)), box->isChecked()); + } + + CheckApplyOk(); + gradationChanged = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::DescEdited() +{ + descriptionChanged = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SetHeightsChecked(bool enabled) +{ + ui->checkBoxH92->setChecked(enabled); + ui->checkBoxH98->setChecked(enabled); + ui->checkBoxH104->setChecked(enabled); + ui->checkBoxH110->setChecked(enabled); + ui->checkBoxH116->setChecked(enabled); + ui->checkBoxH122->setChecked(enabled); + ui->checkBoxH128->setChecked(enabled); + ui->checkBoxH134->setChecked(enabled); + ui->checkBoxH140->setChecked(enabled); + ui->checkBoxH146->setChecked(enabled); + ui->checkBoxH152->setChecked(enabled); + ui->checkBoxH158->setChecked(enabled); + ui->checkBoxH164->setChecked(enabled); + ui->checkBoxH170->setChecked(enabled); + ui->checkBoxH176->setChecked(enabled); + ui->checkBoxH182->setChecked(enabled); + ui->checkBoxH188->setChecked(enabled); + ui->checkBoxH194->setChecked(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SetSizesChecked(bool enabled) +{ + ui->checkBoxS22->setChecked(enabled); + ui->checkBoxS24->setChecked(enabled); + ui->checkBoxS26->setChecked(enabled); + ui->checkBoxS28->setChecked(enabled); + ui->checkBoxS30->setChecked(enabled); + ui->checkBoxS32->setChecked(enabled); + ui->checkBoxS34->setChecked(enabled); + ui->checkBoxS36->setChecked(enabled); + ui->checkBoxS38->setChecked(enabled); + ui->checkBoxS40->setChecked(enabled); + ui->checkBoxS42->setChecked(enabled); + ui->checkBoxS44->setChecked(enabled); + ui->checkBoxS46->setChecked(enabled); + ui->checkBoxS48->setChecked(enabled); + ui->checkBoxS50->setChecked(enabled); + ui->checkBoxS52->setChecked(enabled); + ui->checkBoxS54->setChecked(enabled); + ui->checkBoxS56->setChecked(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::InitHeights() +{ + Init(ui->checkBoxAllHeights, static_cast(GHeights::ALL), &DialogPatternProperties::SelectAll); + + Init(ui->checkBoxH92, static_cast(GHeights::H92), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH98, static_cast(GHeights::H98), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH104, static_cast(GHeights::H104), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH110, static_cast(GHeights::H110), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH116, static_cast(GHeights::H116), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH122, static_cast(GHeights::H122), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH128, static_cast(GHeights::H128), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH134, static_cast(GHeights::H134), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH140, static_cast(GHeights::H140), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH146, static_cast(GHeights::H146), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH152, static_cast(GHeights::H152), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH158, static_cast(GHeights::H158), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH164, static_cast(GHeights::H164), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH170, static_cast(GHeights::H170), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH176, static_cast(GHeights::H176), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH182, static_cast(GHeights::H182), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH188, static_cast(GHeights::H188), &DialogPatternProperties::CheckStateHeight); + Init(ui->checkBoxH194, static_cast(GHeights::H194), &DialogPatternProperties::CheckStateHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::InitSizes() +{ + Init(ui->checkBoxAllSizes, static_cast(GSizes::ALL), &DialogPatternProperties::SelectAll); + + Init(ui->checkBoxS22, static_cast(GSizes::S22), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS24, static_cast(GSizes::S24), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS26, static_cast(GSizes::S26), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS28, static_cast(GSizes::S28), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS30, static_cast(GSizes::S30), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS32, static_cast(GSizes::S32), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS34, static_cast(GSizes::S34), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS36, static_cast(GSizes::S36), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS38, static_cast(GSizes::S38), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS40, static_cast(GSizes::S40), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS42, static_cast(GSizes::S42), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS44, static_cast(GSizes::S44), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS46, static_cast(GSizes::S46), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS48, static_cast(GSizes::S48), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS50, static_cast(GSizes::S50), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS52, static_cast(GSizes::S52), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS54, static_cast(GSizes::S54), &DialogPatternProperties::CheckStateSize); + Init(ui->checkBoxS56, static_cast(GSizes::S56), &DialogPatternProperties::CheckStateSize); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::CheckApplyOk() +{ + bool enable = !(heightsChecked == 0 || sizesChecked == 0); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable); + ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SaveDescription() +{ + doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); + doc->SetDescription(ui->plainTextEditTechNotes->document()->toPlainText()); + doc->SetAuthor(ui->lineEditAuthor->text()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SaveGradation() +{ + doc->SetGradationHeights(heights); + doc->SetGradationSizes(sizes); + emit UpdateGradation(); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void DialogPatternProperties::Init(QCheckBox *check, int val, Func slot) +{ + connect(check, &QCheckBox::stateChanged, this, slot); + data.insert(check, val); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void DialogPatternProperties::SetOptions(const QMap &option) +{ + if (option.value(GVal::ALL) == false) + { + QMapIterator i(option); + while (i.hasNext()) + { + i.next(); + if (i.value() == false && i.key() != GVal::ALL) + { + QCheckBox *box = data.key(static_cast(i.key())); + if (box != nullptr) + { + box->setCheckState(Qt::Unchecked); + } + } + } + } +} diff --git a/src/app/dialogs/app/dialogpatternproperties.h b/src/app/dialogs/app/dialogpatternproperties.h new file mode 100644 index 000000000..8d09531a9 --- /dev/null +++ b/src/app/dialogs/app/dialogpatternproperties.h @@ -0,0 +1,84 @@ +/************************************************************************ + ** + ** @file dialogpatternproperties.h + ** @author Roman Telezhynskyi + ** @date 18 2, 2014 + ** + ** @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 + ** 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 DIALOGPATTERNPROPERTIES_H +#define DIALOGPATTERNPROPERTIES_H + +#include +#include "../../options.h" +#include + +class VPattern; +class QCheckBox; + +namespace Ui +{ + class DialogPatternProperties; +} + +class DialogPatternProperties : public QDialog +{ + Q_OBJECT +public: + DialogPatternProperties(VPattern *doc, QWidget *parent = nullptr); + virtual ~DialogPatternProperties(); +signals: + void UpdateGradation(); +public slots: + void Apply(); + void Ok(); + void SelectAll(int state); + void CheckStateHeight(int state); + void CheckStateSize(int state); + void DescEdited(); +private: + Q_DISABLE_COPY(DialogPatternProperties) + Ui::DialogPatternProperties *ui; + VPattern *doc; + char heightsChecked; + char sizesChecked; + QMap heights; + QMap sizes; + QMap data; + bool descriptionChanged; + bool gradationChanged; + + void SetHeightsChecked(bool enabled); + void SetSizesChecked(bool enabled); + void InitHeights(); + void InitSizes(); + template + void Init(QCheckBox *check, int val, Func slot); + template + void SetOptions(const QMap &option); + void CheckApplyOk(); + void SaveDescription(); + void SaveGradation(); +}; + +#endif // DIALOGPATTERNPROPERTIES_H diff --git a/src/app/dialogs/app/dialogpatternproperties.ui b/src/app/dialogs/app/dialogpatternproperties.ui new file mode 100644 index 000000000..fb8b10f30 --- /dev/null +++ b/src/app/dialogs/app/dialogpatternproperties.ui @@ -0,0 +1,886 @@ + + + DialogPatternProperties + + + + 0 + 0 + 657 + 562 + + + + Pattern properties + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + 1 + + + + Description + + + + + + + + Author name + + + + + + + + + + + + + + Pattern description + + + + + + + + + + + + + + + + + + For technical notes. + + + + + + + + + + + + + Heights and Sizes + + + + + + + + + + All heights (cm) + + + true + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QLayout::SetMaximumSize + + + + + true + + + + 0 + 0 + + + + 92 + + + true + + + + + + + true + + + + 0 + 0 + + + + 146 + + + true + + + + + + + true + + + + 0 + 0 + + + + 98 + + + true + + + + + + + true + + + + 0 + 0 + + + + 152 + + + true + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + 104 + + + true + + + + + + + true + + + + 0 + 0 + + + + 158 + + + true + + + + + + + true + + + + 0 + 0 + + + + 110 + + + true + + + + + + + true + + + + 0 + 0 + + + + 164 + + + true + + + + + + + true + + + + 0 + 0 + + + + 116 + + + true + + + + + + + true + + + + 0 + 0 + + + + 170 + + + true + + + + + + + true + + + + 0 + 0 + + + + 122 + + + true + + + + + + + true + + + + 0 + 0 + + + + 176 + + + true + + + + + + + true + + + + 0 + 0 + + + + 128 + + + true + + + + + + + true + + + + 0 + 0 + + + + 182 + + + true + + + + + + + true + + + + 0 + 0 + + + + 134 + + + true + + + + + + + true + + + + 0 + 0 + + + + 188 + + + true + + + + + + + true + + + + 0 + 0 + + + + 140 + + + true + + + + + + + true + + + + 0 + 0 + + + + 194 + + + true + + + + + + + + + + + + + + All sizes (cm) + + + true + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + true + + + + 0 + 0 + + + + 22 + + + true + + + + + + + true + + + + 0 + 0 + + + + 40 + + + true + + + + + + + true + + + + 0 + 0 + + + + 24 + + + true + + + + + + + true + + + + 0 + 0 + + + + 42 + + + true + + + + + + + true + + + + 0 + 0 + + + + 26 + + + true + + + + + + + true + + + + 0 + 0 + + + + 44 + + + true + + + + + + + true + + + + 0 + 0 + + + + 28 + + + true + + + + + + + true + + + + 0 + 0 + + + + 46 + + + true + + + + + + + true + + + + 0 + 0 + + + + 30 + + + true + + + + + + + true + + + + 0 + 0 + + + + 48 + + + true + + + + + + + true + + + + 0 + 0 + + + + 32 + + + true + + + + + + + true + + + + 0 + 0 + + + + 50 + + + true + + + + + + + true + + + + 0 + 0 + + + + 34 + + + true + + + + + + + true + + + + 0 + 0 + + + + 52 + + + true + + + + + + + true + + + + 0 + 0 + + + + 36 + + + true + + + + + + + true + + + + 0 + 0 + + + + 54 + + + true + + + + + + + true + + + + 0 + 0 + + + + 38 + + + true + + + + + + + true + + + + 0 + 0 + + + + 56 + + + true + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogPatternProperties + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPatternProperties + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/app/dialogpatternxmledit.cpp b/src/app/dialogs/app/dialogpatternxmledit.cpp new file mode 100644 index 000000000..6339ff47c --- /dev/null +++ b/src/app/dialogs/app/dialogpatternxmledit.cpp @@ -0,0 +1,1263 @@ +/************************************************************************ + ** + ** @file dialogpatternxmledit.cpp + ** @author Patrick Proy + ** @date 14 5, 2014 + ** + ** @brief Code file for the XML editor dialog + ** @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 + ** 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 "dialogpatternxmledit.h" +#include "ui_dialogpatternxmledit.h" + +#include +#include + +const short int DialogPatternXmlEdit::ChangeTypeDelete=1; +const short int DialogPatternXmlEdit::ChangeTypeAdd=2; +const short int DialogPatternXmlEdit::ChangeTypeModify=3; + + +//--------------------------------------------------------------------------------------------------------------------- +DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc) + :QDialog(parent), treeChange(false), currentNodeEdited(nullptr), currentNodeEditedStatus(0), + currentNodeEditedStack(nullptr), ui(new Ui::DialogPatternXmlEdit), doc(nullptr), root(QDomElement()), + rootNode(nullptr), rootBases(nullptr), rootBasesNum(0), xmlmodel(nullptr), changeStackRoot(nullptr), + changeStackLast(nullptr) +{ + ui->setupUi(this); + + this->xmlmodel = new VXMLTreeView(); + this->doc=xmldoc; + this->root = this->doc->documentElement(); + // disable edit trigers (no edition directly on tree) + ui->treeView_main->setEditTriggers(QTreeView::NoEditTriggers); + + ui->treeView_main->setWindowTitle("XML"); + + this->rootNode = this->xmlmodel->invisibleRootItem(); + + int drawnum=xmldoc->elementsByTagName("draw").size(); + this->rootBases = new VXMLTreeElement*[drawnum+1]; + this->rootBasesNum=1; + this->rootBases[0]=new VXMLTreeElement("Valentina", VXMLTreeElement::TypeRoot, root, false); + // TODO : OOM exception. + + + VXMLTreeElement* standard_base = new VXMLTreeElement("Valentina", VXMLTreeElement::TypeRoot, root, false); + ui->comboBox_Base_Selection->addItem(tr("All pattern pieces"), QVariant(0)); + + //rootBases[0]=(QDomNode) doc->DocumentNode; + this->rootNode->appendRow(standard_base); + + this->ReadNodes(this->root, standard_base, this->xmlmodel, false); + + ui->treeView_main->setModel(xmlmodel); + + //ui->treeView_main->expandAll(); + + // connectors + connect(ui->comboBox_Base_Selection, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPatternXmlEdit::BaseSelectionChanged); + connect(ui->treeView_main, &QTreeView::clicked, this, &DialogPatternXmlEdit::ElementClicked); + connect(ui->lineEdit_Name, &QLineEdit::textEdited, this, &DialogPatternXmlEdit::NameTextEdited); + connect(ui->lineEdit_Value, &QLineEdit::textEdited, this, &DialogPatternXmlEdit::ValueTextEdited); + connect(ui->pushButton_Set_Values, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonSetClicked); + connect(ui->pushButton_Cancel_Values, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonCancelClicked); + connect(ui->pushButton_Remove_attribute, &QPushButton::clicked, + this, &DialogPatternXmlEdit::ButtonDeleteAttributeClicked); + connect(ui->pushButton_Add_son, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonAddSonClicked); + connect(ui->pushButton_Add_attribute, &QPushButton::clicked, + this, &DialogPatternXmlEdit::ButtonAddAttributeClicked); + connect(ui->pushButton_Apply_Changes, &QPushButton::clicked, + this, &DialogPatternXmlEdit::ButtonApplyChangesClicked); + connect(ui->pushButton_Undo_Last_Change, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonUndoLastChange); + connect(ui->pushButton_Remove_Node, &QPushButton::clicked, this, &DialogPatternXmlEdit::ButtonDeleteNode); +} + +bool DialogPatternXmlEdit::CheckChanges(QString &message, QDomNode testRoot) +{ + Q_UNUSED(testRoot) + message="OK"; + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::ApplyAttributeChange(QDomNode domElement, QString name, QString value) +{ + if (domElement.isElement() == false) + { + return false; + } + domElement.toElement().setAttribute(name, value); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::ApplyNodeChange(QDomNode domElement, QString name, QString value) +{ + if (domElement.isElement() == false) + { + return false; + } + domElement.toElement().setNodeValue(value); + domElement.toElement().setTagName(name); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::ApplyNodeAdd(QDomNode domElement, VXMLTreeElement* treeElement, QString name, QString value) +{ + QDomElement newnode = domElement.ownerDocument().createElement(name); + //SCASSERT(newnode != nullptr); + newnode.setNodeValue(value); + domElement.appendChild(newnode); + treeElement->SetDocNode(newnode); + return true; +} + +bool DialogPatternXmlEdit::ApplyAttributeDelete(QDomNode domElement, QString name) +{ + if (domElement.isElement() == false) + { + return false; + } + domElement.toElement().removeAttribute(name); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::ApplyNodeDelete(QDomNode domElement) +{ + QDomNode mother=domElement.parentNode(); + mother.removeChild(domElement); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonDeleteNode() +{ + ChangesStackElement* newstack; + + // TODO : maybe assert functions here + if (this->currentNodeEdited == nullptr) + { + return; + } + if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode) + { + return; + } + + if (this->currentNodeEditedStatus != 0) + { + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete) + { // Change already done ??? ignore... + return; + } + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeAdd) + { // Attribute was previously added, just undo the change + if ( this->UndoChange(this->currentNodeEditedStack) == false ) + { // Error in undo... warn user + QMessageBox::warning(this, tr("No changes"), tr("Cannot delete previously created node")); + return; + } + this->ClearEditData(); + return; + } + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeModify) + { // Node was edited : remove change then continue to delete node + this->UndoChange(this->currentNodeEditedStack); + } + } + + // Modify display + QFont textfont=currentNodeEdited->font(); + textfont.setStrikeOut(true); + this->currentNodeEdited->setFont(textfont); + // + this->DeleteNodeAndSons(this->currentNodeEdited, true); + // Create change + newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete); + newstack->element= this->currentNodeEdited; + // Activate changes + this->treeChange=true; + ui->pushButton_Apply_Changes->setEnabled(true); + ui->pushButton_Undo_Last_Change->setEnabled(true); + // clear dialog + this->ClearEditData(); + return; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::DeleteNodeAndSons(VXMLTreeElement * currentNode, bool onlydeactivate) +{ + + QList stack; + VXMLTreeElement * currentNodeStack; + // First undo all changes on sons + stack << currentNode; + while (stack.isEmpty() == false) + { + //pop first element + currentNodeStack=stack.takeFirst(); + // clear all changes made in son node and not on current or it will loop + if (currentNodeStack != currentNode) + { + ChangesStackElement * local = this->changeStackRoot; + while (local != nullptr) + { + if (local->element == currentNodeStack) + { + this->UndoChange(local); + break; + } + local=local->next; + } + } + // add sons to stack + int index=currentNodeStack->rowCount(); + while (index > 0) + { + stack << static_cast (currentNodeStack->child(index-1)); + index--; + } + //stack.removeFirst(); + } + // Next set strike font on all + if (onlydeactivate==true) + { + stack << currentNode; + while (stack.isEmpty() == false) + { + //pop first element + currentNodeStack=stack.takeFirst(); + + currentNodeStack->SetSetlectable(false); + QFont textfont=currentNodeStack->font(); + textfont.setStrikeOut(true); + currentNodeStack->setFont(textfont); + // add sons to stack + int index=currentNodeStack->rowCount(); + while (index > 0) + { + stack << static_cast (currentNodeStack->child(index-1)); + index--; + } + } + } + + currentNode->SetSetlectable(true); + + if (onlydeactivate==false) + { // Remove node from parent + // Get parent node + QStandardItem * parent= currentNode->parent(); + int index=parent->rowCount(); + while (index >= 0) + { + if (static_cast (parent->child(index)) == currentNode) + { + break; + } + index--; + } + if (index < 0) + { + SCASSERT(index==0); + return false; + } + parent->removeRow(index); + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElement(short int typechange) +{ + ChangesStackElement* tmp; + + tmp= new ChangesStackElement; + //if (tmp==0) TODO + tmp->type=typechange; + tmp->changedText=tmp->changedValue=false; + + if (changeStackLast==nullptr ) + { + changeStackLast=changeStackRoot=tmp; + } + else + { + changeStackLast->next=tmp; + changeStackLast=changeStackLast->next; + } + changeStackLast->newValue=changeStackLast->newText=nullptr; + changeStackLast->oldValue=changeStackLast->oldText=nullptr; + changeStackLast->next=nullptr; + return changeStackLast; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPatternXmlEdit::UndoChange(DialogPatternXmlEdit::ChangesStackElement* current) +{ + SCASSERT(current != nullptr); + + VXMLTreeElement * currentNode = current->element; + + if (current->type == DialogPatternXmlEdit::ChangeTypeDelete) + { + if (currentNode->GetelementType()==VXMLTreeElement::TypeAttr) + { + // Attribute previously deleted -> restore + QFont textfont=currentNode->font(); + textfont.setStrikeOut(false); + currentNode->setFont(textfont); + this->RemoveChangeStackElement(current); + } + else if (currentNode->GetelementType()==VXMLTreeElement::TypeNode) + { + QList stack; + stack << currentNode; + while (stack.isEmpty() == false) + { + currentNode=stack.takeFirst(); + currentNode->SetSetlectable(true); + QFont textfont=currentNode->font(); + textfont.setStrikeOut(false); + currentNode->setFont(textfont); + + int index=currentNode->rowCount(); + while (index > 0) + { + stack << static_cast (currentNode->child(index-1)); + index--; + } + } + this->RemoveChangeStackElement(current); + } + } + else if (current->type == DialogPatternXmlEdit::ChangeTypeAdd) + { + if (currentNode->GetelementType()==VXMLTreeElement::TypeAttr) + { + // Get parent node + VXMLTreeElement * parent= static_cast (currentNode->parent()); + int index=parent->rowCount(); + while (index >= 0) + { + if (static_cast (parent->child(index)) == currentNode) + { + break; + } + index--; + } + if (index < 0) + { + SCASSERT(index==0); + return false; + } + parent->removeRow(index); + this->RemoveChangeStackElement(current); + } + else if (currentNode->GetelementType()==VXMLTreeElement::TypeNode) + { + if (this->DeleteNodeAndSons(currentNode, false) == false) + { + // TODO : error message. + return false; + } + this->RemoveChangeStackElement(current); + } + } + else if (current->type == DialogPatternXmlEdit::ChangeTypeModify) + { + if (current->changedText == true) + { + currentNode->SetTreeNodeName(*current->oldText); + } + if (current->changedValue == true) + { + currentNode->SetTreeNodeValue(*current->oldValue); + } + + QFont textfont=currentNode->font(); + textfont.setBold(false); + currentNode->setFont(textfont); + this->RemoveChangeStackElement(current); + } + // Check if last change was undone + if (this->changeStackLast == nullptr) + { + this->treeChange=false; + ui->pushButton_Apply_Changes->setEnabled(false); + ui->pushButton_Undo_Last_Change->setEnabled(false); + } + return true; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonUndoLastChange() +{ + ChangesStackElement* current=this->changeStackLast; + + if (current == nullptr) + { + QMessageBox::warning(this, tr("No changes"), tr("No changes left")); + this->ui->pushButton_Undo_Last_Change->setEnabled(false); + return; + } + if (this->UndoChange(current) == false) + { + QMessageBox::warning(this, tr("No changes"), tr("Cannot undo change")); + } + this->ClearEditData(); + +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonApplyChangesClicked() +{ + QString Changes=""; + QStringList stringtype; + stringtype << "node" << "attribute" << "root"; + QString nodetype; + ChangesStackElement* currentChange; + if (this->changeStackRoot==nullptr) + { + Changes="No Changes"; + } + else + { + currentChange=this->changeStackRoot; + do + { + nodetype=stringtype.at(currentChange->element->GetelementType()-1); + if (currentChange->type == DialogPatternXmlEdit::ChangeTypeAdd) + { + Changes += QString("Added type %1 : ").arg(nodetype); + Changes += currentChange->element->GettreeNodeName(); + Changes += "/"; + Changes += (currentChange->element->GettreeNodeValueSet()) ? + currentChange->element->GettreeNodeValue(): tr(""); + Changes += "\n"; + } + else + { + if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify) + { + Changes += QString("Modified type %1 : ").arg(nodetype); + Changes += (currentChange->changedText) ? *currentChange->newText : tr("Unchanged"); + Changes += "/"; + Changes += (currentChange->changedValue) ? *currentChange->newValue: tr("Unchanged"); + Changes += "\n"; + } + else + { + if (currentChange->type == DialogPatternXmlEdit::ChangeTypeDelete) + { + Changes += QString("Deleted type %1 : ").arg(nodetype); + Changes += currentChange->element->GettreeNodeName(); + Changes += "/"; + Changes += (currentChange->element->GettreeNodeValueSet()) ? + currentChange->element->GettreeNodeValue(): tr(""); + Changes += "\n"; + } + } + } + currentChange=currentChange->next; + } while (currentChange != nullptr); + } + QMessageBox::information(this, "Changes : ", Changes); + // TODO : clear stack and apply + + currentChange=this->changeStackRoot; + // copy DOM + QDomNode newroot = root.cloneNode(true); + + QString name, value; + while (currentChange != nullptr) + { + if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify) + { + name=(currentChange->changedText == false) ? currentChange->element->GettreeNodeName() + : *currentChange->newText; + value=(currentChange->changedValue == false) ? currentChange->element->GettreeNodeValue() + : *currentChange->newValue; + if (currentChange->element->GetelementType() == VXMLTreeElement::TypeAttr) + { + + this->ApplyAttributeChange(currentChange->element->GetDocNode(), name, value); + } + else if (currentChange->element->GetelementType() == VXMLTreeElement::TypeNode) + { + this->ApplyNodeChange(currentChange->element->GetDocNode(), name, value); + } + else + { + QMessageBox::warning(this, "Error in changes", "Invalid node type"); + return; + } + } + else if (currentChange->type == DialogPatternXmlEdit::ChangeTypeAdd) + { + name=(currentChange->changedText == false) ? currentChange->element->GettreeNodeName() + : *currentChange->newText; + value=(currentChange->changedValue == false) ? currentChange->element->GettreeNodeValue() + : *currentChange->newValue; + if (currentChange->element->GetelementType() == VXMLTreeElement::TypeAttr) + { + this->ApplyAttributeChange(currentChange->element->GetFatherElement()->GetDocNode(), name, value); + } + else if (currentChange->element->GetelementType() == VXMLTreeElement::TypeNode) + { + this->ApplyNodeAdd(currentChange->element->GetFatherElement()->GetDocNode(), currentChange->element, + name, value); + } + else + { + QMessageBox::warning(this, "Error in changes", "Invalid node type"); + return; + } + } + else if (currentChange->type == DialogPatternXmlEdit::ChangeTypeDelete) + { + if (currentChange->element->GetelementType() == VXMLTreeElement::TypeAttr) + { + name=(currentChange->changedText == false) ? currentChange->element->GettreeNodeName() + : *currentChange->newText; + this->ApplyAttributeDelete(currentChange->element->GetDocNode(), name); + } + else if (currentChange->element->GetelementType() == VXMLTreeElement::TypeNode) + { + this->ApplyNodeDelete(currentChange->element->GetDocNode().parentNode()); + } + else + { + QMessageBox::warning(this, "Error in changes", "Invalid node type"); + return; + } + } + currentChange=currentChange->next; + } + QString message; + if (this->CheckChanges(message, newroot) == false) + { + QMessageBox::warning(this, "Error in changes", message); + return; + } + this->doc->LiteParseTree(Document::LiteParse); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonCancelClicked() +{ + this->ClearEditData(); + if (this->currentNodeEditedStatus==DialogPatternXmlEdit::ChangeTypeDelete) + { + if (this->UndoChange(this->currentNodeEditedStack) == false) + { + QMessageBox::warning(this, "Error", "Cannot undo"); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt) +{ + ChangesStackElement* index = this->changeStackRoot; + + if (changeStackRoot == elmt) + { + if (elmt->newText != nullptr) + { + delete elmt->newText; + } + if (elmt->newValue != nullptr) + { + delete elmt->newValue; + } + if (elmt->oldText != nullptr) + { + delete elmt->oldText; + } + if (elmt->oldValue != nullptr) + { + delete elmt->oldValue; + } + this->changeStackRoot = elmt->next; + if (this->changeStackLast == elmt) + { + this->changeStackLast= elmt->next; + } + delete elmt; + return; + } + while (index->next!=nullptr) + { + if (index->next == elmt) + { + break; + } + index=index->next; + } + if (index->next == nullptr) + { + SCASSERT(index->next != nullptr); + return; + } + if (index->next->newText != nullptr) + { + delete index->next->newText; + } + if (index->next->newValue != nullptr) + { + delete index->next->newValue; + } + if (index->next->oldText != nullptr) + { + delete index->next->oldText; + } + if (index->next->oldValue != nullptr) + { + delete index->next->oldValue; + } + index->next=index->next->next; + if (this->changeStackLast == elmt) + { + this->changeStackLast= index; + } + delete elmt; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonDeleteAttributeClicked() +{ + ChangesStackElement* newstack; + + // TODO : maybe assert functions here + if (this->currentNodeEdited == nullptr) + { + return; + } + if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeAttr) + { + return; + } + + if (this->currentNodeEditedStatus != 0) + { + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete) + { // Change already done ??? ignore... + return; + } + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeAdd) + { // Attribute was previously added, just undo the change + if ( this->UndoChange(this->currentNodeEditedStack) == false ) + { // Error in undo... warn user + QMessageBox::warning(this, tr("No changes"), tr("Cannot delete previously created attribute")); + return; + } + this->ClearEditData(); + return; + } + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeModify) + { // Node was edited : remove change then continue to delete node + this->UndoChange(this->currentNodeEditedStack); + } + } + newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeDelete); + newstack->element= this->currentNodeEdited; + + QFont textfont=currentNodeEdited->font(); + textfont.setStrikeOut(true); + this->currentNodeEdited->setFont(textfont); + // Activate changes + this->treeChange=true; + ui->pushButton_Apply_Changes->setEnabled(true); + ui->pushButton_Undo_Last_Change->setEnabled(true); + // clear dialog + this->ClearEditData(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonAddSonClicked() +{ + ChangesStackElement* newstack; + bool ok; + //clear_edit_data(); + // TODO : maybe assert functions here + if (this->currentNodeEdited == nullptr) + { + return; + } + if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode) + { + return; + } + + + QString name = QInputDialog::getText(this, tr("Node Name"), tr("Name:"), QLineEdit::Normal, "", &ok); + if (ok==false) + { + return; + } + QString value = QInputDialog::getText(this, tr("Node Value (may be empty)"), tr("Value:"), + QLineEdit::Normal, "", &ok); + if (ok==false) + { + return; + } + + // create element tree and put father tree element to catch up with DOM tree. + QDomNode empty; + VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeNode, empty, true); + tElement->SetFatherElement(this->currentNodeEdited); + + if (value.isEmpty() == false) + { + tElement->SetTreeNodeValue(value); + } + currentNodeEdited->appendRow(tElement); + xmlmodel->appendchain(tElement); + QFont textfont=currentNodeEdited->font(); + textfont.setBold(true); + tElement->setFont(textfont); + + // Add to change stack + newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeAdd); + newstack->element=tElement; + newstack->newText=new QString(name); newstack->changedText=true; + if (value.isEmpty()) + { + newstack->changedValue=true;newstack->newValue=new QString(value); + } + // Activate changes + treeChange=true; + ui->pushButton_Apply_Changes->setEnabled(true); + ui->pushButton_Undo_Last_Change->setEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonAddAttributeClicked() +{ + ChangesStackElement* newstack; + bool ok; + QDomNode empty; // empty QNode to pas to create function : maybe a better way to do this ? + + // TODO : maybe assert functions here + if (this->currentNodeEdited == nullptr) + { + return; + } + if (this->currentNodeEdited->GetelementType() != VXMLTreeElement::TypeNode) + { + return; + } + + QString name = QInputDialog::getText(this, tr("Attribute Name"), + tr("Name:"), QLineEdit::Normal, + "", &ok); + if (ok==false) + { + return; + } + QString value = QInputDialog::getText(this, tr("Attribute Value"), + tr("Value:"), QLineEdit::Normal, + "", &ok); + if (ok==false) + { + return; + } + + // create element tree but do not add attribute in DOM (will be done in apply). + VXMLTreeElement* tElement = new VXMLTreeElement(name, VXMLTreeElement::TypeAttr, empty, true); + // set parent node. + tElement->SetFatherElement(this->currentNodeEdited); + + tElement->SetTreeNodeValue(value); + currentNodeEdited->appendRow(tElement); + xmlmodel->appendchain(tElement); + QFont textfont=currentNodeEdited->font(); + textfont.setBold(true); + tElement->setFont(textfont); + // Add to change stack + newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeAdd); + newstack->element= tElement; + newstack->type=VXMLTreeElement::TypeAttr; + newstack->newText=new QString(name); + newstack->newValue=new QString(value); + // Activate changes + treeChange=true; + ui->pushButton_Apply_Changes->setEnabled(true); + ui->pushButton_Undo_Last_Change->setEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ButtonSetClicked() +{ + QString name, value; + ChangesStackElement* newstack; + + if (this->currentNodeEdited == nullptr) + { + return; + } + name=ui->lineEdit_Name->text(); + value=ui->lineEdit_Value->text(); + bool nameedit, valueedit; + + nameedit = (name != currentNodeEdited->GettreeNodeName()) ? true : false; + valueedit= (value != currentNodeEdited->GettreeNodeValue()) ? true : false; + + if ( nameedit == true || valueedit == true ) + { + if (this->currentNodeEditedStatus != 0) + { // If node was created or edited previously, rewrite + if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete) + { // You shouldn't be able to edit a deleted node... + SCASSERT(this->currentNodeEditedStatus != DialogPatternXmlEdit::ChangeTypeDelete); + ClearEditData(); + return; + } + newstack=this->currentNodeEditedStack; + if (nameedit == true) + { + newstack->changedText=true; + *newstack->newText=name; + currentNodeEdited->SetTreeNodeName(name); + } + if (valueedit == true) + { + if (newstack->changedValue==true) + { + *newstack->newValue = value; + } + else + { + newstack->changedValue=true; + newstack->newValue= new QString(value); + newstack->oldValue= new QString(this->currentNodeEdited->GettreeNodeValue()); + } + currentNodeEdited->SetTreeNodeValue(value); + } + } + else + { + newstack = this->CreateStackElement(DialogPatternXmlEdit::ChangeTypeModify); + newstack->element= this->currentNodeEdited; + + if (nameedit == true) + { + newstack->changedText=true; + newstack->newText=new QString(name); + newstack->oldText=new QString(this->currentNodeEdited->GettreeNodeName()); + currentNodeEdited->SetTreeNodeName(name); + } + if (valueedit == true) + { + newstack->changedValue=true; + newstack->newValue= new QString(value); + newstack->oldValue= new QString(this->currentNodeEdited->GettreeNodeValue()); + currentNodeEdited->SetTreeNodeValue(value); + } + } + QFont textfont=currentNodeEdited->font(); + textfont.setBold(true); + currentNodeEdited->setFont(textfont); + treeChange=true; + ui->pushButton_Apply_Changes->setEnabled(true); + ui->pushButton_Undo_Last_Change->setEnabled(true); + ClearEditData(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::NameTextEdited(QString newtext) +{ + Q_UNUSED(newtext) + //QMessageBox::information(this, "nameTextEdited", QString("%1").arg(newtext)); + ui->pushButton_Set_Values->setEnabled(true); + ui->pushButton_Cancel_Values->setEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ValueTextEdited(QString newtext) +{ + Q_UNUSED(newtext) + //QMessageBox::information(this, "valueTextEdited", QString("%1").arg(newtext)); + ui->pushButton_Set_Values->setEnabled(true); + ui->pushButton_Cancel_Values->setEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ClearEditData() +{ + ui->lineEdit_Name->setText(""); + ui->lineEdit_Value->setText(""); + ui->lineEdit_Name->setEnabled(false); + ui->lineEdit_Value->setEnabled(false); + + ui->label_type_value->setText(tr("No selection")); + ui->pushButton_Set_Values->setEnabled(false); + ui->pushButton_Add_attribute->setEnabled(false); + ui->pushButton_Add_son->setEnabled(false); + ui->pushButton_Remove_attribute->setEnabled(false); + ui->pushButton_Cancel_Values->setEnabled(false); + ui->pushButton_Remove_Node->setEnabled(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ClearStack() +{ + ChangesStackElement * tmp; + while (changeStackRoot != nullptr) + { + if (changeStackRoot->newText != nullptr) + { + delete changeStackRoot->newText; + } + if (changeStackRoot->newValue != nullptr) + { + delete changeStackRoot->newValue; + } + tmp=changeStackRoot; + changeStackRoot=changeStackRoot->next; + delete tmp; + } + changeStackLast=nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::BaseSelectionChanged(int value) +{ + QDomNode newbase; + + int index; + + if (this->treeChange == true) + {//Changes have been made : warn ? + } + this->ClearStack(); + ui->pushButton_Apply_Changes->setEnabled(false); + + index = ui->comboBox_Base_Selection->itemData(value).toInt(); //.convert(QVariant::Int); + SCASSERT(value < rootBasesNum); + // QMessageBox::information(this, "test", QString("%1:%2").arg(value).arg(index)); + + // Clear all tree info and nodes + // TODO : Check + while (rootNode->rowCount() > 0) + { + rootNode->removeRow(0); + } + this->xmlmodel->ClearTree(); + + VXMLTreeElement* standard_base = new VXMLTreeElement( + rootBases[index]->GettreeNodeName(), + VXMLTreeElement::TypeRoot, + rootBases[index]->GetDocNode(), + false); + rootNode->appendRow(standard_base); + ReadNodes(rootBases[index]->GetDocNode(), standard_base, xmlmodel, true); + + ui->treeView_main->setModel(xmlmodel); + this->ClearEditData(); + // TODO : warn if changes ? + this->ClearStack(); + return; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ElementClicked ( const QModelIndex & index ) +{ + + // Get item (function returns parent of clicked item) + VXMLTreeElement *item = static_cast (index.internalPointer()); + + // Get child specified by index row/column + VXMLTreeElement * item2 = static_cast (item->child(index.row(), index.column())); + + // Clear all data and disable buttons + this->ClearEditData(); + // Check if element is selectable at this time + if (item2->IsSelectable() == false) + { + return; + } + // Check status of element in change stack + this->currentNodeEdited=item2; + this->currentNodeEditedStatus=0; + ChangesStackElement * local = this->changeStackRoot; + while (local != nullptr) + { + if (local->element == item2) + { + this->currentNodeEditedStatus=local->type; + this->currentNodeEditedStack=local; + if (local->type == DialogPatternXmlEdit::ChangeTypeDelete) + { + // Node is deleted, only enable cancel button + ui->pushButton_Cancel_Values->setEnabled(true); + return; + } + } + local=local->next; + } + // Fill the dialog and Activate the line edit + if (item2->GetelementType() != VXMLTreeElement::TypeRoot) + { + ui->lineEdit_Name->setText(currentNodeEdited->GettreeNodeName()); + ui->lineEdit_Name->setEnabled(true); + // Fill value + ui->lineEdit_Value->setText(currentNodeEdited->GettreeNodeValue()); + ui->lineEdit_Value->setEnabled(true); + } + if (item2->GetelementType() == VXMLTreeElement::TypeRoot) + { + ui->label_type_value->setText(tr("Root node"));; + ui->pushButton_Add_son->setEnabled(true); + } + else if (item2->GetelementType() == VXMLTreeElement::TypeNode) + { + ui->label_type_value->setText(tr("Node")); + ui->pushButton_Add_attribute->setEnabled(true); + ui->pushButton_Add_son->setEnabled(true); + ui->pushButton_Remove_Node->setEnabled(true); + } + else if (item2->GetelementType() == VXMLTreeElement::TypeAttr) + { + ui->label_type_value->setText(tr("Attribute")); + ui->pushButton_Remove_attribute->setEnabled(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPatternXmlEdit::~DialogPatternXmlEdit() +{ + this->ClearStack(); + this->xmlmodel->ClearTree(); + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternXmlEdit::ReadNodes(QDomNode dNode, VXMLTreeElement* root, VXMLTreeView* xmlmodel, bool refresh) +{ + + QDomNode tNode, tNode2; + VXMLTreeElement* tElement, *tElement2; + int totalOfChilds = dNode.childNodes().size(); + if (totalOfChilds == 0) + { + return; // empty xml + } + for (int i=0;iappendchain(tElement); + root->appendRow(tElement); + if (tNode.nodeName() == "draw") + { + for (int i = 0; i < tNode.attributes().size(); i++) + { + if ((tNode.attributes().item(i).nodeName() == "name") + && (refresh == false)) + { + ui->comboBox_Base_Selection->addItem(tNode.attributes().item(i).nodeValue(), + QVariant(rootBasesNum)); + rootBases[rootBasesNum]=new VXMLTreeElement( + QString("Drawing %1").arg(tNode.attributes().item(i).nodeValue()), + VXMLTreeElement::TypeRoot, tNode, false); + rootBasesNum++; + //QStandardItem* rootNode = (QStandardItem*) rootBases[rootBasesNum]->invisibleRootItem(); + //rootNode->appendRow(tElement); + } + } + } + } + } + + do + { + tElement=xmlmodel->getCurrent()->elmt; + tNode=tElement->GetDocNode(); + if (tElement->GetelementType() == VXMLTreeElement::TypeNode) + { + totalOfChilds = tNode.childNodes().size(); + for (int i=0;iappendchain(tElement2); + tElement->appendRow(tElement2); + } + } + + if (tNode.nodeType() == QDomNode::TextNode) + { + tElement->SetTreeNodeValue(tNode.nodeValue()); + } + + for (int i = 0; i < tNode.attributes().size(); i++) + { + tElement2 = new VXMLTreeElement(tNode.attributes().item(i).nodeName(), VXMLTreeElement::TypeAttr, + tNode, false); + tElement2->SetTreeNodeValue(tNode.attributes().item(i).nodeValue()); + tElement->appendRow(tElement2); + xmlmodel->appendchain(tElement2); + } + } + xmlmodel->SetCurrent(xmlmodel->getCurrent()->next); + } + while (xmlmodel->getCurrent() != 0); + return; +} + +//--------------------------------------------------------------------------------------------------------------------- +VXMLTreeView::VXMLTreeView(QObject *parent) + : QStandardItemModel(parent), items(nullptr), current(nullptr), last(nullptr) +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VXMLTreeView::ClearTree() +{ + + // TODO check if treeitems are deleted with the delete row command of QDom + + //clear the chain link + TreeElementchain * tmp; + while (items != nullptr) + { + tmp=items; + items=items->next; + delete tmp; + } + // reset chain counters + current=last=items=nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +VXMLTreeView::~VXMLTreeView() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VXMLTreeView::appendchain(VXMLTreeElement* elmt) +{ + if (last == nullptr) + { // first element + current = new TreeElementchain; + if (current == nullptr) + { + SCASSERT(current != nullptr); + // TODO : throw exception + } + current->elmt=elmt; + current->next=nullptr; + last=items=current; + return; + } + TreeElementchain* temp= new TreeElementchain; + if (temp == nullptr) + { + SCASSERT(temp != nullptr); + // TODO : throw exception + } + temp->elmt=elmt; + temp->next=nullptr; + last->next=temp; + last=temp; +} + +const short int VXMLTreeElement::TypeNode=1; +const short int VXMLTreeElement::TypeAttr=2; +const short int VXMLTreeElement::TypeRoot=3; + +//--------------------------------------------------------------------------------------------------------------------- +//TODO warning: conversion to 'short int' from 'int' may alter its value [-Wconversion] +//treeNodeValueSet(false), treeNodeName(name) +// ^ +VXMLTreeElement::VXMLTreeElement(QString name, short int nodetype, QDomNode source, bool editor) + : QStandardItem(name), DocNode(source), parentnode(nullptr), addedNode(editor), elementType(nodetype), + treeNodeValue(""), treeNodeValueSet(false), treeNodeName(name), selectable(true) +{ + if (editor == false) + { + this->DocNode=source; + } + this->setText(this->DisplayText()); + switch (this->elementType) + { + case VXMLTreeElement::TypeAttr: + this->setBackground(BACKGROUND_COLOR_ATTRIBUTE); + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VXMLTreeElement::~VXMLTreeElement() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VXMLTreeElement::SetTreeNodeValue(QString value) +{ + this->treeNodeValue=value; + this->treeNodeValueSet=true; + this->setText(this->DisplayText()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VXMLTreeElement::SetTreeNodeName(QString value) +{ + this->treeNodeName=value; + this->setText(this->DisplayText()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VXMLTreeElement::DisplayText() +{ + if (this->elementType == VXMLTreeElement::TypeRoot) + { + return this->treeNodeName; + } + return QString("%1 : %2").arg((this->treeNodeName)).arg(this->treeNodeValue); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VXMLTreeElement::GettreeNodeValue() +{ + // Only return value if it's really set. + if (this->treeNodeValueSet) + { + return this->treeNodeValue; + } + else + { + return QString(); + } +} diff --git a/src/app/dialogs/app/dialogpatternxmledit.h b/src/app/dialogs/app/dialogpatternxmledit.h new file mode 100644 index 000000000..cbdf94a1a --- /dev/null +++ b/src/app/dialogs/app/dialogpatternxmledit.h @@ -0,0 +1,379 @@ +/************************************************************************ + ** + ** @file dialogpatternxmledit.h + ** @author Patrick Proy + ** @date 14 5, 2014 + ** + ** @brief Include file for the XML editor dialog + ** @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 + ** 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 DIALOGPATTERNXMLEDIT_H +#define DIALOGPATTERNXMLEDIT_H + +#include +#include +#include "../../xml/vpattern.h" + +//******************************************************************************************** +/** + * @brief The vXMLTreeElement class : node/attribute of xml pattern. Used by vXMLTreeView + * + */ + +#define BACKGROUND_COLOR_ATTRIBUTE QBrush(Qt::GlobalColor::cyan) +#define BACKGROUND_COLOR_INACTIVE_NODE QBrush(Qt::GlobalColor::gray) +class VXMLTreeElement : public QStandardItem +{ + +public: + /** + * @brief vXMLTreeElement + * @param name : display name + * @param nodetype : node type (node, attribute, root) + * @param source : the source dom node + */ + explicit VXMLTreeElement (QString name, short int nodetype, QDomNode source, bool editor); + + explicit VXMLTreeElement (QString name, int nodetype); + + ~VXMLTreeElement (); + static const short int TypeNode; + static const short int TypeAttr; + static const short int TypeRoot; + /** + * @brief setNodeValue : set value of node (content or attribute) + * @param value : the value + */ + void SetTreeNodeValue(QString value); + /** + * @brief displayText : text to display + * @return text to display + */ + QString DisplayText(); + /** + * @brief getDocNode + * @return current document node + */ + QDomNode GetDocNode(); + /** + * @brief SetDocNode set tree element DomNode + */ + inline void SetDocNode(QDomNode node) + { + this->DocNode=node; + } + inline void SetAddedNode(bool state) {this->addedNode=state;} + inline bool GetAddedNode() {return this->addedNode;} + + QString GettreeNodeName(); + QString GettreeNodeValue(); + /** + * @brief GettreeNodeValueSet check if value has been set + * @return true if value is set + */ + bool GettreeNodeValueSet(); + void SetTreeNodeName(QString value); + /** + * @brief getelementType + * @return elementType value + */ + short int GetelementType(); + bool IsSelectable(); + void SetSetlectable(bool value); + + inline void SetFatherElement(VXMLTreeElement* parent) + { + this->parentnode=parent; + } + inline VXMLTreeElement* GetFatherElement() + { + return this->parentnode; + } + +private: + /** + * @brief DocNode : link to current document node + */ + QDomNode DocNode; + + /** + * @brief parentnode parent node of this element. If null then the DocNode must be valid + */ + VXMLTreeElement* parentnode; + + /** + * @brief addedNode : true if node is added by editor (implies empty DocNode) + */ + bool addedNode; + /** + * @brief type : element type (node, attribute, text value of node) + */ + short int elementType; + /** + * @brief nodeValue : Attribute or node value + */ + QString treeNodeValue; + /** + * @brief treeNodeValueSet : true if value has been set + */ + bool treeNodeValueSet; + /** + * @brief nodeValue : Attribute or node value + */ + QString treeNodeName; + /** + * @brief selectable : can item be selected to be changed (ex : false if father deleted). + */ + bool selectable; + Q_DISABLE_COPY(VXMLTreeElement) +}; + +inline bool VXMLTreeElement::IsSelectable() +{ + return this->selectable; +} + +inline void VXMLTreeElement::SetSetlectable(bool value) +{ + this->selectable=value; +} + +inline short int VXMLTreeElement::GetelementType() +{ + return this->elementType; +} + +inline QDomNode VXMLTreeElement::GetDocNode() +{ + return this->DocNode; +} + +inline QString VXMLTreeElement::GettreeNodeName() +{ + return this->treeNodeName; +} + +inline bool VXMLTreeElement::GettreeNodeValueSet() +{ + return this->treeNodeValueSet; +} + +//******************************************************************************************** +/** + * @brief The vXMLTreeView class : container to display/edit xml pattern + */ +class VXMLTreeView : public QStandardItemModel +{ +public: + explicit VXMLTreeView (QObject *parent = 0); + void appendchain(VXMLTreeElement* elmt); + + /** + * @brief The TreeElement struct : chained list of vXMLTreeElement + */ + typedef struct TreeElementchain + { + VXMLTreeElement* elmt; + TreeElementchain* next; + } TreeElementchain; + + TreeElementchain * getCurrent(); + void SetCurrent(TreeElementchain * value); + TreeElementchain * GetLast(); + TreeElementchain * GetItems(); + /** + * @brief clearTree : clear tree elements and listed items. + */ + void ClearTree(); + ~VXMLTreeView (); +private: + Q_DISABLE_COPY(VXMLTreeView) + + /** + * @brief items : root of chained list of vXMLTreeElement + */ + TreeElementchain * items; + /** + * @brief current : used to parse in iteration. + */ + TreeElementchain * current; + /** + * @brief last : used to parse in iteration. + */ + TreeElementchain * last; +}; + +inline VXMLTreeView::TreeElementchain * VXMLTreeView::getCurrent() +{ + return this->current; +} +inline void VXMLTreeView::SetCurrent(VXMLTreeView::TreeElementchain * value) +{ + this->current=value; +} +inline VXMLTreeView::TreeElementchain * VXMLTreeView::GetLast() +{ + return this->last; +} +inline VXMLTreeView::TreeElementchain * VXMLTreeView::GetItems() +{ + return this->items; +} + +//******************************************************************************************** + +namespace Ui +{ + class DialogPatternXmlEdit; +} +/** + * @brief The DialogPatternXmlEdit class : ui dialog for XML editing of pattern + */ +class DialogPatternXmlEdit : public QDialog +{ + Q_OBJECT + +public: + explicit DialogPatternXmlEdit(QWidget *parent = 0, VPattern *xmldoc = 0); + ~DialogPatternXmlEdit(); + + /** + * @brief clear_edit_data : clear input boxes and disables buttons. + */ + void ClearEditData(); + + void NameTextEdited(QString newtext); + void ValueTextEdited(QString newtext); + void ButtonSetClicked(); + void ButtonCancelClicked(); + void ButtonDeleteAttributeClicked(); + void ButtonAddSonClicked(); + void ButtonAddAttributeClicked(); + void ButtonApplyChangesClicked(); + void ButtonUndoLastChange(); + void ButtonDeleteNode(); + + // Stack of changes definition + typedef struct ChangesStackElement + { + short int type; + VXMLTreeElement *element; + QString *newText; + QString *oldText; + bool changedText; + QString *newValue; + QString *oldValue; + bool changedValue; + ChangesStackElement* next; + } ChangesStackElement; + + // Change stack functions + ChangesStackElement* CreateStackElement(short int typechange); + void RemoveChangeStackElement(ChangesStackElement* elmt); + void ClearStack(); + bool treeChange; + VXMLTreeElement* currentNodeEdited; + short int currentNodeEditedStatus; + ChangesStackElement* currentNodeEditedStack; + /** + * @brief UndoChange : undo change in change stack element + * @param current : change to undo + * @return true if undo has been done, false on error + */ + bool UndoChange(ChangesStackElement* current); + /** + * @brief DeleteNodeAndSons : delete node and all it's attribute and sons below + * @param currentNode : node to delete + * @param onlydeactivate : if true, dont delete just deactivate sons and attributes + * @return false if changes couldn't be done + */ + bool DeleteNodeAndSons(VXMLTreeElement *currentNode, bool onlydeactivate); + + /** + * @brief ApplyAttributeChange change or add attribute for node + * @param domElement : node containing attribute + * @return true on success + */ + bool ApplyAttributeChange(QDomNode domElement, QString name, QString value); + /** + * @brief ApplyNodeChange Change name or text content of node + * @param domElement node + * @param value text content of node + * @return true on success + */ + bool ApplyNodeChange(QDomNode domElement, QString name, QString value); + /** + * @brief ApplyNodeAdd add node as child of domElement and set DocNode of treeElement + * @param treeElement the XMLTreeElement of added node + * @return true on success + */ + bool ApplyNodeAdd(QDomNode domElement, VXMLTreeElement* treeElement, QString name, QString value); + /** + * @brief ApplyAttributeDelete delete attribute for node + * @param name attribute name + * @return true on success + */ + bool ApplyAttributeDelete(QDomNode domElement, QString name); + /** + * @brief ApplyNodeDelete delete node domElement + * @return true on success + */ + bool ApplyNodeDelete(QDomNode domElement); + /** + * @brief CheckChanges Check if changes made are OK + * @param message error message returned if false + * @param testRoot root of DOM to test + * @return true if validated, false otherwise + */ + bool CheckChanges(QString &message, QDomNode testRoot); +private slots: + void BaseSelectionChanged(int value); + void ElementClicked ( const QModelIndex & index ); + +private: + Q_DISABLE_COPY(DialogPatternXmlEdit) + Ui::DialogPatternXmlEdit *ui; + + VPattern *doc; + + QDomElement root; + QStandardItem *rootNode; + //typedef struct rootbases { vXMLTreeElement * root; QString name; } rootbases; + VXMLTreeElement ** rootBases; + qint16 rootBasesNum; + + void ReadNodes(QDomNode dNode, VXMLTreeElement* root, VXMLTreeView *xmlmodel, bool refresh); + VXMLTreeView* xmlmodel; + + + // Stack of changes + static const short int ChangeTypeDelete; + static const short int ChangeTypeAdd; + static const short int ChangeTypeModify; + + // Stack of changes + + ChangesStackElement* changeStackRoot; + ChangesStackElement* changeStackLast; +}; + +#endif // DIALOGPATTERNXMLEDIT_H diff --git a/src/app/dialogs/app/dialogpatternxmledit.ui b/src/app/dialogs/app/dialogpatternxmledit.ui new file mode 100644 index 000000000..a23c06ed5 --- /dev/null +++ b/src/app/dialogs/app/dialogpatternxmledit.ui @@ -0,0 +1,373 @@ + + + DialogPatternXmlEdit + + + + 0 + 0 + 664 + 459 + + + + + 1 + 1 + + + + + 400 + 300 + + + + + 0 + 0 + + + + Qt::DefaultContextMenu + + + XML Editor + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + false + + + false + + + + + + QLayout::SetMaximumSize + + + + + QLayout::SetDefaultConstraint + + + 0 + + + + + false + + + QAbstractItemView::SingleSelection + + + true + + + false + + + + + + + QLayout::SetMinimumSize + + + 9 + + + + + + 0 + 0 + + + + Value : + + + + + + + false + + + + + + + false + + + + + + + + 0 + 0 + + + + Name : + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 10 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + <No selection> + + + + + + + + 0 + 0 + + + + Type : + + + + + + + false + + + Add attribute + + + + + + + false + + + Add son + + + + + + + + + QLayout::SetNoConstraint + + + QFormLayout::ExpandingFieldsGrow + + + + + false + + + Remove attribute + + + + + + + false + + + Remove node + + + + + + + false + + + Qt::LeftToRight + + + Set + + + + + + + false + + + Qt::LeftToRight + + + Cancel + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + false + + + Apply changes + + + + + + + false + + + Undo last + + + + + + + Immediate apply + + + false + + + + + + + + + + 0 + 0 + + + + Base selection + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 5 + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + buttonBox + accepted() + DialogPatternXmlEdit + accept() + + + 248 + 254 + + + 157 + 274 + + + + + diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp new file mode 100644 index 000000000..356074ed7 --- /dev/null +++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp @@ -0,0 +1,200 @@ +/************************************************************************ + ** + ** @file dialogstandardmeasurements.cpp + ** @author Roman Telezhynskyi + ** @date 21 2, 2014 + ** + ** @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 + ** 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 "dialogstandardmeasurements.h" +#include "ui_dialogstandardmeasurements.h" +#include +#include +#include +#include "../../xml/vstandardmeasurements.h" +#include "../../core/vapplication.h" +#include "../../container/vcontainer.h" +#include + +Q_LOGGING_CATEGORY(vStMeasur, "v.st.measurements") + +//--------------------------------------------------------------------------------------------------------------------- +DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, + QWidget *parent) : + QDialog(parent), ui(new Ui::DialogStandardMeasurements), data(data), _name(patternPieceName), _tablePath(QString()) +{ + ui->setupUi(this); + + QRect position = this->frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); + + { + const QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + connect(bOk, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogAccepted); + } + { + const QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCansel != nullptr); + connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogRejected); + } + + qCDebug(vStMeasur)<<"Pattern piece name"<<_name; + ui->lineEditName->setText(_name); + + LoadStandardTables(); + + CheckState(); + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogStandardMeasurements::CheckState); + this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogStandardMeasurements::~DialogStandardMeasurements() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogStandardMeasurements::name() const +{ + return _name; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogStandardMeasurements::tablePath() const +{ + return _tablePath; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogStandardMeasurements::DialogAccepted() +{ + _name = ui->lineEditName->text(); + const qint32 index = ui->comboBoxTables->currentIndex(); + _tablePath = ui->comboBoxTables->itemData(index).toString(); + + try + { + VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath); + VStandardMeasurements m(data); + m.setXMLContent(_tablePath); + qApp->setPatternUnit(m.MUnit()); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + qDebug()<<"File error."<lineEditName->text().isEmpty() == false) + { + flagName = true; + } + + bool flagTable = false; + { + const QComboBox *box = ui->comboBoxTables; + SCASSERT(box != nullptr); + if (box->count() > 0 && box->currentIndex() != -1) + { + flagTable = true; + } + } + + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagTable && flagName); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogStandardMeasurements::LoadStandardTables() +{ + qCDebug(vStMeasur)<<"Loading standard table."; + QStringList filters{"*.vst"}; + QDir tablesDir(qApp->pathToTables()); + tablesDir.setNameFilters(filters); + tablesDir.setCurrent(qApp->pathToTables()); + + const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files); + if (allFiles.isEmpty() == true) + { + qCDebug(vStMeasur)<<"Can't find standard measurements in path"<pathToTables(); + ui->comboBoxTables->clear(); + CheckState(); + return; + } + + qCDebug(vStMeasur)<<"Was found"<STDescription(m.Id()); + if (trDesc.isEmpty() == false) + { + qCDebug(vStMeasur)<<"Adding user table from"<comboBoxTables->addItem(trDesc, QVariant(fi.absoluteFilePath())); + } + else if (m.Description().isEmpty() == false) + { + qCDebug(vStMeasur)<<"Adding table with id"<comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath())); + } + } + } + catch (VException &e) + { + qCDebug(vStMeasur)<<"File error."< + ** @date 21 2, 2014 + ** + ** @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 + ** 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 DIALOGSTANDARDMEASUREMENTS_H +#define DIALOGSTANDARDMEASUREMENTS_H + +#include + +class VContainer; + +namespace Ui +{ + class DialogStandardMeasurements; +} + +class DialogStandardMeasurements : public QDialog +{ + Q_OBJECT +public: + DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); + ~DialogStandardMeasurements(); + QString name() const; + QString tablePath() const; +public slots: + void DialogAccepted(); + void DialogRejected(); + void CheckState(); +private: + Q_DISABLE_COPY(DialogStandardMeasurements) + Ui::DialogStandardMeasurements *ui; + VContainer *data; + QString _name; + QString _tablePath; + void LoadStandardTables(); +}; + +#endif // DIALOGSTANDARDMEASUREMENTS_H diff --git a/src/app/dialogs/app/dialogstandardmeasurements.ui b/src/app/dialogs/app/dialogstandardmeasurements.ui new file mode 100644 index 000000000..208adf019 --- /dev/null +++ b/src/app/dialogs/app/dialogstandardmeasurements.ui @@ -0,0 +1,139 @@ + + + DialogStandardMeasurements + + + Qt::ApplicationModal + + + + 0 + 0 + 452 + 115 + + + + Standard table + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true + + + + + + + + + 0 + 0 + + + + + 206 + 0 + + + + Pattern piece name + + + 0 + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + Standard measurements table + + + + + + + + 0 + 0 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogStandardMeasurements + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogStandardMeasurements + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/app/dialogundo.cpp b/src/app/dialogs/app/dialogundo.cpp new file mode 100644 index 000000000..705adee55 --- /dev/null +++ b/src/app/dialogs/app/dialogundo.cpp @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file dialogundo.cpp + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 + ** + ** @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) 2014 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 "dialogundo.h" +#include "ui_dialogundo.h" +#include "../../core/vapplication.h" +#include "../../libs/ifc/exception/vexceptionundo.h" +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogUndo::DialogUndo(QWidget *parent) + :QDialog(parent), ui(new Ui::DialogUndo), result(UndoButton::Cancel) +{ + ui->setupUi(this); + + bool opening = qApp->getOpeningPattern(); + if (opening) + { + ui->pushButtonUndo->setDisabled(opening); + } + else + { + connect(ui->pushButtonUndo, &QPushButton::clicked, this, &DialogUndo::Undo); + } + connect(ui->pushButtonFix, &QPushButton::clicked, this, &DialogUndo::Fix); + connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel); + + setCursor(Qt::ArrowCursor); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogUndo::~DialogUndo() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogUndo::Undo() +{ + result = UndoButton::Undo; + accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogUndo::Fix() +{ + result = UndoButton::Fix; + accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogUndo::Cancel() +{ + result = UndoButton::Cancel; + reject(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogUndo::closeEvent(QCloseEvent *event) +{ + Cancel(); + event->accept(); +} diff --git a/src/app/dialogs/app/dialogundo.h b/src/app/dialogs/app/dialogundo.h new file mode 100644 index 000000000..d391e7696 --- /dev/null +++ b/src/app/dialogs/app/dialogundo.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file dialogundo.h + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 + ** + ** @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) 2014 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 DIALOGUNDO_H +#define DIALOGUNDO_H + +#include + +namespace Ui +{ + class DialogUndo; +} + +enum class UndoButton {Undo, Fix, Cancel}; + +class DialogUndo : public QDialog +{ + Q_OBJECT +public: + explicit DialogUndo(QWidget *parent = 0); + UndoButton Result() const; + ~DialogUndo(); +public slots: + void Undo(); + void Fix(); + void Cancel(); +protected: + virtual void closeEvent ( QCloseEvent * event ); +private: + Q_DISABLE_COPY(DialogUndo) + Ui::DialogUndo *ui; + UndoButton result; +}; + +inline UndoButton DialogUndo::Result() const +{ + return result; +} + +#endif // DIALOGUNDO_H diff --git a/src/app/dialogs/app/dialogundo.ui b/src/app/dialogs/app/dialogundo.ui new file mode 100644 index 000000000..21e4dcbad --- /dev/null +++ b/src/app/dialogs/app/dialogundo.ui @@ -0,0 +1,84 @@ + + + DialogUndo + + + Qt::WindowModal + + + + 0 + 0 + 387 + 145 + + + + + 387 + 145 + + + + + 387 + 145 + + + + Broken formula + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true + + + + + + + + Error while calculation formula. You can try undo last operation or fix broken formula. + + + true + + + + + + + + + &Undo + + + + + + + &Fix formula + + + + + + + &Cancel + + + + + + + + + + + + + + diff --git a/src/dialogs/dialogs.h b/src/app/dialogs/dialogs.h similarity index 50% rename from src/dialogs/dialogs.h rename to src/app/dialogs/dialogs.h index c205f2522..e83eedc77 100644 --- a/src/dialogs/dialogs.h +++ b/src/app/dialogs/dialogs.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file dialogs.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -29,21 +29,37 @@ #ifndef DIALOGS_H #define DIALOGS_H -#include "dialogalongline.h" -#include "dialogarc.h" -#include "dialogbisector.h" -#include "dialogdetail.h" -#include "dialogendline.h" -#include "dialoghistory.h" -#include "dialogincrements.h" -#include "dialogline.h" -#include "dialoglineintersect.h" -#include "dialognormal.h" -#include "dialogpointofcontact.h" -#include "dialogshoulderpoint.h" -#include "dialogsinglepoint.h" -#include "dialogspline.h" -#include "dialogsplinepath.h" -#include "dialogheight.h" +#include "tools/dialogalongline.h" +#include "tools/dialogarc.h" +#include "tools/dialogbisector.h" +#include "tools/dialogdetail.h" +#include "tools/dialogendline.h" +#include "tools/dialogline.h" +#include "tools/dialoglineintersect.h" +#include "tools/dialognormal.h" +#include "tools/dialogpointofcontact.h" +#include "tools/dialogshoulderpoint.h" +#include "tools/dialogsinglepoint.h" +#include "tools/dialogspline.h" +#include "tools/dialogsplinepath.h" +#include "tools/dialogheight.h" +#include "tools/dialogcutarc.h" +#include "tools/dialogcutspline.h" +#include "tools/dialogcutsplinepath.h" +#include "tools/dialoguniondetails.h" +#include "tools/dialogtriangle.h" +#include "tools/dialogpointofintersection.h" +#include "tools/dialoglineintersectaxis.h" +#include "tools/dialogcurveintersectaxis.h" + +#include "app/dialoghistory.h" +#include "app/dialogincrements.h" +#include "app/configdialog.h" +#include "app/dialogpatternproperties.h" +#include "app/dialogmeasurements.h" +#include "app/dialogindividualmeasurements.h" +#include "app/dialogstandardmeasurements.h" +#include "app/dialogaboutapp.h" +#include "app/dialogpatternxmledit.h" #endif // DIALOGS_H diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri new file mode 100644 index 000000000..8201e7386 --- /dev/null +++ b/src/app/dialogs/dialogs.pri @@ -0,0 +1,118 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/dialogs.h \ + $$PWD/tools/dialogtriangle.h \ + $$PWD/tools/dialogtool.h \ + $$PWD/tools/dialogsplinepath.h \ + $$PWD/tools/dialogspline.h \ + $$PWD/tools/dialogsinglepoint.h \ + $$PWD/tools/dialogshoulderpoint.h \ + $$PWD/tools/dialogpointofintersection.h \ + $$PWD/tools/dialogpointofcontact.h \ + $$PWD/tools/dialognormal.h \ + $$PWD/tools/dialoglineintersect.h \ + $$PWD/tools/dialogline.h \ + $$PWD/tools/dialogheight.h \ + $$PWD/tools/dialogendline.h \ + $$PWD/tools/dialogdetail.h \ + $$PWD/tools/dialogbisector.h \ + $$PWD/tools/dialogarc.h \ + $$PWD/tools/dialogalongline.h \ + $$PWD/tools/dialogcutspline.h \ + $$PWD/tools/dialogcutsplinepath.h \ + $$PWD/tools/dialoguniondetails.h \ + $$PWD/tools/dialogcutarc.h \ + $$PWD/tools/dialogeditwrongformula.h \ + $$PWD/tools/dialoglineintersectaxis.h \ + $$PWD/app/dialogincrements.h \ + $$PWD/app/dialoghistory.h \ + $$PWD/app/configdialog.h \ + $$PWD/app/configpages/pages.h \ + $$PWD/app/dialogpatternproperties.h \ + $$PWD/app/dialogmeasurements.h \ + $$PWD/app/dialogstandardmeasurements.h \ + $$PWD/app/dialogindividualmeasurements.h \ + $$PWD/app/dialogaboutapp.h \ + $$PWD/app/dialogpatternxmledit.h \ + $$PWD/app/configpages/configurationpage.h \ + $$PWD/app/configpages/patternpage.h \ + $$PWD/app/configpages/communitypage.h \ + $$PWD/app/configpages/pathpage.h \ + $$PWD/app/dialogundo.h \ + $$PWD/tools/dialogcurveintersectaxis.h + +SOURCES += \ + $$PWD/tools/dialogtriangle.cpp \ + $$PWD/tools/dialogtool.cpp \ + $$PWD/tools/dialogsplinepath.cpp \ + $$PWD/tools/dialogspline.cpp \ + $$PWD/tools/dialogsinglepoint.cpp \ + $$PWD/tools/dialogshoulderpoint.cpp \ + $$PWD/tools/dialogpointofintersection.cpp \ + $$PWD/tools/dialogpointofcontact.cpp \ + $$PWD/tools/dialognormal.cpp \ + $$PWD/tools/dialoglineintersect.cpp \ + $$PWD/tools/dialogline.cpp \ + $$PWD/tools/dialogheight.cpp \ + $$PWD/tools/dialogendline.cpp \ + $$PWD/tools/dialogdetail.cpp \ + $$PWD/tools/dialogbisector.cpp \ + $$PWD/tools/dialogarc.cpp \ + $$PWD/tools/dialogalongline.cpp \ + $$PWD/tools/dialogcutspline.cpp \ + $$PWD/tools/dialogcutsplinepath.cpp \ + $$PWD/tools/dialoguniondetails.cpp \ + $$PWD/tools/dialogcutarc.cpp \ + $$PWD/tools/dialogeditwrongformula.cpp \ + $$PWD/tools/dialoglineintersectaxis.cpp \ + $$PWD/app/dialogincrements.cpp \ + $$PWD/app/dialoghistory.cpp \ + $$PWD/app/configdialog.cpp \ + $$PWD/app/dialogpatternproperties.cpp \ + $$PWD/app/dialogmeasurements.cpp \ + $$PWD/app/dialogstandardmeasurements.cpp \ + $$PWD/app/dialogindividualmeasurements.cpp \ + $$PWD/app/dialogaboutapp.cpp \ + $$PWD/app/dialogpatternxmledit.cpp \ + $$PWD/app/configpages/configurationpage.cpp \ + $$PWD/app/configpages/patternpage.cpp \ + $$PWD/app/configpages/communitypage.cpp \ + $$PWD/app/configpages/pathpage.cpp \ + $$PWD/app/dialogundo.cpp \ + $$PWD/tools/dialogcurveintersectaxis.cpp + +FORMS += \ + $$PWD/tools/dialogtriangle.ui \ + $$PWD/tools/dialogsplinepath.ui \ + $$PWD/tools/dialogspline.ui \ + $$PWD/tools/dialogsinglepoint.ui \ + $$PWD/tools/dialogshoulderpoint.ui \ + $$PWD/tools/dialogpointofintersection.ui \ + $$PWD/tools/dialogpointofcontact.ui \ + $$PWD/tools/dialognormal.ui \ + $$PWD/tools/dialoglineintersect.ui \ + $$PWD/tools/dialogline.ui \ + $$PWD/tools/dialogheight.ui \ + $$PWD/tools/dialogendline.ui \ + $$PWD/tools/dialogdetail.ui \ + $$PWD/tools/dialogbisector.ui \ + $$PWD/tools/dialogarc.ui \ + $$PWD/tools/dialogalongline.ui \ + $$PWD/tools/dialogcutspline.ui \ + $$PWD/tools/dialogcutsplinepath.ui \ + $$PWD/tools/dialoguniondetails.ui \ + $$PWD/tools/dialogcutarc.ui \ + $$PWD/tools/dialogeditwrongformula.ui \ + $$PWD/tools/dialoglineintersectaxis.ui \ + $$PWD/app/dialogincrements.ui \ + $$PWD/app/dialoghistory.ui \ + $$PWD/app/dialogpatternproperties.ui \ + $$PWD/app/dialogmeasurements.ui \ + $$PWD/app/dialogstandardmeasurements.ui \ + $$PWD/app/dialogindividualmeasurements.ui \ + $$PWD/app/dialogaboutapp.ui \ + $$PWD/app/dialogpatternxmledit.ui \ + $$PWD/app/dialogundo.ui \ + $$PWD/tools/dialogcurveintersectaxis.ui diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp new file mode 100644 index 000000000..b818b2744 --- /dev/null +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -0,0 +1,264 @@ +/************************************************************************ + ** + ** @file dialogalongline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogalongline.h" +#include "ui_dialogalongline.h" +#include "../../visualization/vistoolalongline.h" +#include "../../tools/vabstracttool.h" +#include "../../widgets/vmaingraphicsscene.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogAlongLine create dialog + * @param data container with data + * @param parent parent widget + */ +DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), + typeLine(QString()), formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), + line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + ui->comboBoxLineType->setCurrentIndex(0); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogAlongLine::EvalFormula); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit); + connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogAlongLine::PointChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogAlongLine::PointChanged); + + line = new VisToolAlongLine(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::PointChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogAlongLine::~DialogAlongLine() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + const QString toolTip = tr("Select second point of line"); + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, toolTip)) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + if (flagError) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + else + { + emit ToolTip(toolTip); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); + + line->setPoint1Id(firstPointId); + line->setPoint2Id(secondPointId); + line->setLength(formula); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPointId set id second point of line + * @param value id + */ +void DialogAlongLine::setSecondPointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value); + line->setPoint2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPointId set id first point of line + * @param value id + */ +void DialogAlongLine::setFirstPointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogAlongLine::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogAlongLine::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogAlongLine::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h new file mode 100644 index 000000000..01dd498a5 --- /dev/null +++ b/src/app/dialogs/tools/dialogalongline.h @@ -0,0 +1,158 @@ +/************************************************************************ + ** + ** @file dialogalongline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGALONGLINE_H +#define DIALOGALONGLINE_H + +#include "dialogtool.h" + +class VisToolAlongLine; + +namespace Ui +{ + class DialogAlongLine; +} + +/** + * @brief The DialogAlongLine class dialog for ToolAlongLine. Help create point and edit option. + */ +class DialogAlongLine : public DialogTool +{ + Q_OBJECT +public: + DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogAlongLine(); + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + void PointChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogAlongLine) + + /** @brief ui keeps information about user interface */ + Ui::DialogAlongLine *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief formula formula */ + QString formula; + + /** @brief firstPointId id first point of line */ + quint32 firstPointId; + + /** @brief secondPointId id second point of line */ + quint32 secondPointId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + VisToolAlongLine *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogAlongLine::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogAlongLine::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogAlongLine::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPointId return id first point of line + * @return id + */ +inline quint32 DialogAlongLine::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPointId return id second point of line + * @return id + */ +inline quint32 DialogAlongLine::getSecondPointId() const +{ + return secondPointId; +} + +#endif // DIALOGALONGLINE_H diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui new file mode 100644 index 000000000..ccefaa068 --- /dev/null +++ b/src/app/dialogs/tools/dialogalongline.ui @@ -0,0 +1,502 @@ + + + DialogAlongLine + + + + 0 + 0 + 428 + 499 + + + + Point along line + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Insert variable into the formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + + 0 + 0 + + + + Value of length + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + Point label + + + + + + + + + + First point + + + + + + + First point of line + + + + + + + Second point + + + + + + + Second point of line + + + + + + + Type of line + + + + + + + + 0 + 0 + + + + Show line from first point to this point + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + lineEditNamePoint + comboBoxFirstPoint + comboBoxSecondPoint + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogAlongLine + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogAlongLine + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp new file mode 100644 index 000000000..045f0c2be --- /dev/null +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -0,0 +1,438 @@ +/************************************************************************ + ** + ** @file dialogarc.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogarc.h" +#include "ui_dialogarc.h" + +#include +#include + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../libs/ifc/xml/vdomdocument.h" +#include "../../visualization/vistoolarc.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogArc create dialog + * @param data container with data + * @param parent parent widget + */ +DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), + timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()), + f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), + angleF1(INT_MIN), angleF2(INT_MIN) +{ + ui->setupUi(this); + + InitVariables(ui); + + plainTextEditFormula = ui->plainTextEditFormula; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + this->formulaBaseHeightF1 = ui->plainTextEditF1->height(); + this->formulaBaseHeightF2 = ui->plainTextEditF2->height(); + + ui->plainTextEditFormula->installEventFilter(this); + ui->plainTextEditF1->installEventFilter(this); + ui->plainTextEditF2->installEventFilter(this); + + timerRadius = new QTimer(this); + connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); + + timerF1 = new QTimer(this); + connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF); + + timerF2 = new QTimer(this); + connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF); + + InitOkCancelApply(ui); + + FillComboBoxPoints(ui->comboBoxBasePoint); + + CheckState(); + + connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); + connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); + connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); + + connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius); + connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF); + connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF); + + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged); + connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArc::F1Changed); + connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, &DialogArc::F2Changed); + + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit); + connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit); + connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit); + + path = new VisToolArc(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::DeployF1TextEdit() +{ + DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::DeployF2TextEdit() +{ + DeployFormula(ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogArc::~DialogArc() +{ + if (qApp->getCurrentScene()->items().contains(path)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete path; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetCenter set id of center point + * @param value id + */ +void DialogArc::SetCenter(const quint32 &value) +{ + center = value; + ChangeCurrentData(ui->comboBoxBasePoint, center); + path->setPoint1Id(center); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetF2 set formula second angle of arc + * @param value formula + */ +void DialogArc::SetF2(const QString &value) +{ + f2 = qApp->FormulaToUser(value); + // increase height if needed. + if (f2.length() > 80) + { + this->DeployF2TextEdit(); + } + ui->plainTextEditF2->setPlainText(f2); + path->setF2(f2); + MoveCursorToEnd(ui->plainTextEditF2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetF1 set formula first angle of arc + * @param value formula + */ +void DialogArc::SetF1(const QString &value) +{ + f1 = qApp->FormulaToUser(value); + // increase height if needed. + if (f1.length() > 80) + { + this->DeployF1TextEdit(); + } + ui->plainTextEditF1->setPlainText(f1); + path->setF1(f1); + MoveCursorToEnd(ui->plainTextEditF1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetRadius set formula of radius + * @param value formula + */ +void DialogArc::SetRadius(const QString &value) +{ + radius = value; + // increase height if needed. + if (radius.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(radius); + path->setRadius(radius); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogArc::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxBasePoint, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); + scene->addItem(path); + path->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::SaveData() +{ + radius = ui->plainTextEditFormula->toPlainText(); + radius.replace("\n", " "); + f1 = ui->plainTextEditF1->toPlainText(); + f1.replace("\n", " "); + f2 = ui->plainTextEditF2->toPlainText(); + f2.replace("\n", " "); + center = getCurrentObjectId(ui->comboBoxBasePoint); + + path->setPoint1Id(center); + path->setRadius(radius); + path->setF1(f1); + path->setF2(f2); + path->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + ui->plainTextEditF1->blockSignals(true); + ui->plainTextEditF2->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ValChenged show description angles of lines + * @param row number of row + */ +void DialogArc::ValChenged(int row) +{ + if (ui->listWidget->count() == 0) + { + return; + } + QListWidgetItem *item = ui->listWidget->item( row ); + if (ui->radioButtonAngleLine->isChecked()) + { + qreal angle = *data->GetVariable(item->text())->GetValue(); + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(angle).arg(tr("Value of angle of line.")); + ui->labelDescription->setText(desc); + return; + } + DialogTool::ValChenged(row); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutRadius put variable into formula of radius + */ +void DialogArc::PutRadius() +{ + PutValHere(ui->plainTextEditFormula, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutF1 put variable into formula of first angle + */ +void DialogArc::PutF1() +{ + PutValHere(ui->plainTextEditF1, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutF2 put variable into formula of second angle + */ +void DialogArc::PutF2() +{ + PutValHere(ui->plainTextEditF2, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineAngles show variable angles of lines + */ +// cppcheck-suppress unusedFunction +void DialogArc::LineAngles() +{ + ShowLineAngles(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RadiusChanged after change formula of radius calculate value and show result + */ +void DialogArc::RadiusChanged() +{ + labelEditFormula = ui->labelEditRadius; + labelResultCalculation = ui->labelResultRadius; + ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief F1Changed after change formula of first angle calculate value and show result + */ +void DialogArc::F1Changed() +{ + labelEditFormula = ui->labelEditF1; + labelResultCalculation = ui->labelResultF1; + ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief F2Changed after change formula of second angle calculate value and show result + */ +void DialogArc::F2Changed() +{ + labelEditFormula = ui->labelEditF2; + labelResultCalculation = ui->labelResultF2; + ValFormulaChanged(flagF2, ui->plainTextEditF2, timerF2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckState if all is right enable button ok + */ +void DialogArc::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagRadius && flagF1 && flagF2); + SCASSERT(bApply != nullptr); + bApply->setEnabled(flagRadius && flagF1 && flagF2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EvalRadius calculate value of radius + */ +void DialogArc::EvalRadius() +{ + labelEditFormula = ui->labelEditRadius; + const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); + const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix); + + if (radius < 0) + { + flagRadius = false; + ChangeColor(labelEditFormula, Qt::red); + ui->labelResultRadius->setText(tr("Error")); + ui->labelResultRadius->setToolTip(tr("Radius can't be negative")); + + DialogArc::CheckState(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EvalF1 calculate value of angle + */ +void DialogArc::EvalF() +{ + labelEditFormula = ui->labelEditF1; + angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false); + + labelEditFormula = ui->labelEditF2; + angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false); + + CheckAngles(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowLineAngles show varibles angles of lines + */ +void DialogArc::ShowLineAngles() +{ + ui->listWidget->blockSignals(true); + ui->listWidget->clear(); + ui->listWidget->blockSignals(false); + const QMap > lineAnglesTable = data->DataAngleLines(); + QMap >::const_iterator i; + for (i = lineAnglesTable.constBegin(); i != lineAnglesTable.constEnd(); ++i) + { + QListWidgetItem *item = new QListWidgetItem(i.key()); + + item->setFont(QFont("Times", 12, QFont::Bold)); + ui->listWidget->addItem(item); + } + ui->listWidget->setCurrentRow (0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::CheckAngles() +{ + if (angleF1 == INT_MIN || angleF2 == INT_MIN) + { + return; + } + + if (qFuzzyCompare(angleF1 + 1, angleF2 + 1)) + { + flagF1 = false; + ChangeColor(ui->labelEditF1, Qt::red); + ui->labelResultF1->setText(tr("Error")); + ui->labelResultF1->setToolTip(tr("Angles equal")); + + flagF2 = false; + ChangeColor(ui->labelEditF2, Qt::red); + ui->labelResultF2->setText(tr("Error")); + ui->labelResultF2->setToolTip(tr("Angles equal")); + } + + DialogArc::CheckState(); +} diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h new file mode 100644 index 000000000..189e86abe --- /dev/null +++ b/src/app/dialogs/tools/dialogarc.h @@ -0,0 +1,179 @@ +/************************************************************************ + ** + ** @file dialogarc.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGARC_H +#define DIALOGARC_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogArc; +} + +class VisToolArc; + +/** + * @brief The DialogArc class dialog for ToolArc. Help create arc and edit option. + */ +class DialogArc : public DialogTool +{ + Q_OBJECT +public: + DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogArc(); + + quint32 GetCenter() const; + void SetCenter(const quint32 &value); + + QString GetRadius() const; + void SetRadius(const QString &value); + + QString GetF1() const; + void SetF1(const QString &value); + + QString GetF2() const; + void SetF2(const QString &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + void DeployF1TextEdit(); + void DeployF2TextEdit(); + virtual void ValChenged(int row); + void PutRadius(); + void PutF1(); + void PutF2(); + // cppcheck-suppress unusedFunction + void LineAngles(); + void RadiusChanged(); + void F1Changed(); + void F2Changed(); +protected: + virtual void CheckState(); + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogArc) + + /** @brief ui keeps information about user interface */ + Ui::DialogArc *ui; + + /** @brief flagRadius true if value of radius is correct */ + bool flagRadius; + + /** @brief flagF1 true if value of first angle is correct */ + bool flagF1; + + /** @brief flagF2 true if value of second angle is correct */ + bool flagF2; + + /** @brief timerRadius timer of check formula of radius */ + QTimer *timerRadius; + + /** @brief timerF1 timer of check formula of first angle */ + QTimer *timerF1; + + /** @brief timerF2 timer of check formula of second angle */ + QTimer *timerF2; + + /** @brief center id of center point */ + quint32 center; + + /** @brief radius formula of radius */ + QString radius; + + /** @brief f1 formula of first angle */ + QString f1; + + /** @brief f2 formula of second angle */ + QString f2; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + int formulaBaseHeightF1; + int formulaBaseHeightF2; + + VisToolArc *path; + + qreal angleF1; + qreal angleF2; + + void EvalRadius(); + void EvalF(); + void ShowLineAngles(); + void CheckAngles(); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetCenter return id of center point + * @return id id + */ +inline quint32 DialogArc::GetCenter() const +{ + return center; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetRadius return formula of radius + * @return formula + */ +inline QString DialogArc::GetRadius() const +{ + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF1 return formula first angle of arc + * @return formula + */ +inline QString DialogArc::GetF1() const +{ + return f1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF2 return formula second angle of arc + * @return formula + */ +inline QString DialogArc::GetF2() const +{ + return f2; +} + +#endif // DIALOGARC_H diff --git a/src/dialogs/dialogarc.ui b/src/app/dialogs/tools/dialogarc.ui similarity index 61% rename from src/dialogs/dialogarc.ui rename to src/app/dialogs/tools/dialogarc.ui index 65ab8d07b..4bf89a0cc 100644 --- a/src/dialogs/dialogarc.ui +++ b/src/app/dialogs/tools/dialogarc.ui @@ -6,21 +6,21 @@ 0 0 - 501 - 448 + 423 + 544 Arc - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - + @@ -74,29 +74,29 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula calculation of radius of arc + + + 40 + 20 + - + - Put variable into formula + Insert variable into the formula - ... + ... - - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -109,13 +109,13 @@ - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -144,7 +144,66 @@ Value of radius - _ + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true @@ -198,34 +257,34 @@ - First angle degree + First angle - - - - 0 - 0 - + + + Qt::Horizontal - - First angle of arc counterclockwise + + + 40 + 20 + - + - Put variable into formula + Insert variable into formula - ... + ... - - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -238,13 +297,13 @@ - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -273,7 +332,63 @@ Value of first angle - _ + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true @@ -327,34 +442,34 @@ - Second angle degree + Second angle - - - - 0 - 0 - + + + Qt::Horizontal - - Second angle of arc counterclockwise + + + 40 + 20 + - + - Put variable into formula + Insert marked variable into formula - ... + ... - - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -367,13 +482,13 @@ - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -402,7 +517,63 @@ Value of second angle - _ + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true @@ -447,8 +618,14 @@ + + + 0 + 0 + + - Size and growth + Size and height true @@ -456,14 +633,26 @@ - + + + + 0 + 0 + + - Standart table + Measurements + + + 0 + 0 + + Increments @@ -474,6 +663,12 @@ true + + + 0 + 0 + + Length of lines @@ -484,6 +679,12 @@ true + + + 0 + 0 + + Length of arcs @@ -494,16 +695,28 @@ true + + + 0 + 0 + + Length of curves - + true + + + 0 + 0 + + Angle of lines @@ -514,11 +727,25 @@ - - - Variables - - + + + + + Hide empty measurements + + + true + + + + + + + Variables + + + + @@ -527,6 +754,9 @@ + + true + @@ -535,35 +765,37 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - lineEditRadius - lineEditF1 - lineEditF2 + plainTextEditFormula + toolButtonPutHereRadius + toolButtonEqualRadius + pushButtonGrowLength + plainTextEditF1 + toolButtonPutHereF1 + toolButtonEqualF1 + pushButtonGrowLengthF1 + toolButtonPutHereF2 + toolButtonEqualF2 comboBoxBasePoint radioButtonSizeGrowth - radioButtonStandartTable + radioButtonStandardTable radioButtonIncrements radioButtonLengthLine radioButtonLengthArc radioButtonLengthSpline - radioButtonLineAngles + radioButtonAngleLine + checkBoxHideEmpty listWidget - toolButtonPutHereRadius - toolButtonPutHereF1 - toolButtonPutHereF2 - toolButtonEqualRadius - toolButtonEqualF1 - toolButtonEqualF2 buttonBox - + diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp new file mode 100644 index 000000000..791ca123c --- /dev/null +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -0,0 +1,299 @@ +/************************************************************************ + ** + ** @file dialogbisector.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogbisector.h" +#include "ui_dialogbisector.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolbisector.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogBisector create dialog + * @param data container with data + * @param parent parent widget + */ +DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), typeLine(QString()), + formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), thirdPointId(NULL_ID), formulaBaseHeight(0), + line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + FillComboBoxPoints(ui->comboBoxThirdPoint); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); + connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal); + + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogBisector::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogBisector::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogBisector::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogBisector::PointNameChanged); + connect(ui->comboBoxThirdPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogBisector::PointNameChanged); + + line = new VisToolBisector(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(getCurrentObjectId(ui->comboBoxThirdPoint)); + + QColor color = okColor; + if (set.size() != 3) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + ChangeColor(ui->labelThirdPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogBisector::~DialogBisector() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + { + if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) + { + number++; + line->setPoint2Id(id); + line->RefreshGeometry(); + } + } + break; + case 2: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxThirdPoint, "")) + { + line->setPoint3Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogBisector::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogBisector::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogBisector::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPointId set id of first point + * @param value id + */ +void DialogBisector::setFirstPointId(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPointId, value); + line->setPoint1Id(firstPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPointId set id of second point + * @param value id + */ +void DialogBisector::setSecondPointId(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPointId, value); + line->setPoint2Id(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setThirdPointId set id of third point + * @param value id + */ +void DialogBisector::setThirdPointId(const quint32 &value) +{ + setPointId(ui->comboBoxThirdPoint, thirdPointId, value); + line->setPoint3Id(thirdPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); + thirdPointId = getCurrentObjectId(ui->comboBoxThirdPoint); + + line->setPoint1Id(firstPointId); + line->setPoint2Id(secondPointId); + line->setPoint3Id(thirdPointId); + line->setLength(formula); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} diff --git a/src/app/dialogs/tools/dialogbisector.h b/src/app/dialogs/tools/dialogbisector.h new file mode 100644 index 000000000..2cc69c2ca --- /dev/null +++ b/src/app/dialogs/tools/dialogbisector.h @@ -0,0 +1,177 @@ +/************************************************************************ + ** + ** @file dialogbisector.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGBISECTOR_H +#define DIALOGBISECTOR_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogBisector; +} + +class VisToolBisector; + +/** + * @brief The DialogBisector class dialog for ToolBisector. Help create point and edit option. + */ +class DialogBisector : public DialogTool +{ + Q_OBJECT +public: + + DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogBisector(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + quint32 getThirdPointId() const; + void setThirdPointId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + virtual void PointNameChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogBisector) + + /** @brief ui keeps information about user interface */ + Ui::DialogBisector *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief formula formula */ + QString formula; + + /** @brief firstPointId id of first point */ + quint32 firstPointId; + + /** @brief secondPointId id of second point */ + quint32 secondPointId; + + /** @brief thirdPointId id of third point */ + quint32 thirdPointId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + VisToolBisector *line; + +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogBisector::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogBisector::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogBisector::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPointId return id of first point + * @return id + */ +inline quint32 DialogBisector::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPointId return id of second point + * @return id + */ +inline quint32 DialogBisector::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getThirdPointId return id of third point + * @return id + */ +inline quint32 DialogBisector::getThirdPointId() const +{ + return thirdPointId; +} + +#endif // DIALOGBISECTOR_H diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui new file mode 100644 index 000000000..3f81fc51f --- /dev/null +++ b/src/app/dialogs/tools/dialogbisector.ui @@ -0,0 +1,535 @@ + + + DialogBisector + + + + 0 + 0 + 428 + 532 + + + + Bisector + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Insert marked variable into the formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of length + + + + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + 0 + 0 + + + + First point + + + + + + + First point of angle + + + + + + + + 0 + 0 + + + + Second point + + + + + + + Second point of angle + + + + + + + + 0 + 0 + + + + Third point + + + + + + + Third point of angle + + + + + + + Type of line + + + + + + + Show line from second point to this point + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + + + + + + + + + + + true + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + lineEditNamePoint + comboBoxFirstPoint + comboBoxSecondPoint + comboBoxThirdPoint + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogBisector + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogBisector + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp new file mode 100644 index 000000000..17c5f87bd --- /dev/null +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp @@ -0,0 +1,281 @@ +/************************************************************************ + ** + ** @file dialogcurveintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 "dialogcurveintersectaxis.h" +#include "ui_dialogcurveintersectaxis.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolcurveintersectaxis.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), number(0), typeLine(QString()), + formulaAngle(QString()), basePointId(NULL_ID), curveId(NULL_ID), formulaBaseHeightAngle(0), line(nullptr) +{ + ui->setupUi(this); + + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeightAngle = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxAxisPoint); + FillComboBoxCurves(ui->comboBoxCurve); + FillComboBoxTypeLine(ui->comboBoxLineType); + + connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::PutAngle); + connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogCurveIntersectAxis::PutVal); + connect(ui->toolButtonEqualAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::EvalAngle); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCurveIntersectAxis::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCurveIntersectAxis::AngleTextChanged); + connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit); + connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle); + + line = new VisToolCurveIntersectAxis(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogCurveIntersectAxis::~DialogCurveIntersectAxis() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::getAngle() const +{ + return qApp->FormulaFromUser(formulaAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::setAngle(const QString &value) +{ + formulaAngle = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formulaAngle.length() > 80) + { + this->DeployAngleTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formulaAngle); + line->setAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogCurveIntersectAxis::getBasePointId() const +{ + return basePointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::setBasePointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxAxisPoint, basePointId, value); + line->setAxisPointId(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogCurveIntersectAxis::getCurveId() const +{ + return curveId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::setCurveId(const quint32 &value) +{ + setCurrentCurveId(ui->comboBoxCurve, curveId, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::ShowDialog(bool click) +{ + if (prepare) + { + if (click) + { + /*We will ignore click if poinet is in point circle*/ + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + const QSharedPointer point = data->GeometricObject(basePointId); + QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); + + //Radius of point circle, but little bigger. Need handle with hover sizes. + qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5; + if (line.length() <= radius) + { + return; + } + } + this->setModal(true); + this->setAngle(line->Angle());//Show in dialog angle what user choose + emit ToolTip(""); + timerFormula->start(); + this->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + switch (number) + { + case (0): + if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::SplinePath) + { + if (SetObject(id, ui->comboBoxCurve, tr("Select axis point"))) + { + number++; + line->VisualMode(id); + connect(line, &VisToolCurveIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); + } + } + break; + case (1): + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxAxisPoint, "")) + { + basePointId = id; + line->setAxisPointId(id); + line->RefreshGeometry(); + prepare = true; + } + } + break; + default: + break; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::PutAngle() +{ + PutValHere(ui->plainTextEditFormula, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::EvalAngle() +{ + Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::AngleTextChanged() +{ + ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::DeployAngleTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::ShowVisualization() +{ + if (prepare == false) + { + //TODO move to parent class! + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolCurveIntersectAxis::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + + formulaAngle = ui->plainTextEditFormula->toPlainText(); + formulaAngle.replace("\n", " "); + + basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); + curveId = getCurrentObjectId(ui->comboBoxCurve); + + line->setPoint1Id(curveId); + line->setAxisPointId(basePointId); + line->setAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.h b/src/app/dialogs/tools/dialogcurveintersectaxis.h new file mode 100644 index 000000000..9ab667062 --- /dev/null +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.h @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file dialogcurveintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 DIALOGCURVEINTERSECTAXIS_H +#define DIALOGCURVEINTERSECTAXIS_H + +#include "dialogtool.h" + +namespace Ui { +class DialogCurveIntersectAxis; +} + +class VisToolCurveIntersectAxis; + +class DialogCurveIntersectAxis : public DialogTool +{ + Q_OBJECT + +public: + DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogCurveIntersectAxis(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getAngle() const; + void setAngle(const QString &value); + + quint32 getBasePointId() const; + void setBasePointId(const quint32 &value); + + quint32 getCurveId() const; + void setCurveId(const quint32 &value); + + virtual void ShowDialog(bool click); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + void PutAngle(); + void EvalAngle(); + void AngleTextChanged(); + void DeployAngleTextEdit(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogCurveIntersectAxis) + Ui::DialogCurveIntersectAxis *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + QString formulaAngle; + quint32 basePointId; + quint32 curveId; + int formulaBaseHeightAngle; + + VisToolCurveIntersectAxis *line; +}; + +#endif // DIALOGCURVEINTERSECTAXIS_H diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.ui b/src/app/dialogs/tools/dialogcurveintersectaxis.ui new file mode 100644 index 000000000..4fe305a4f --- /dev/null +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.ui @@ -0,0 +1,520 @@ + + + DialogCurveIntersectAxis + + + + 0 + 0 + 419 + 499 + + + + Curve intersect axis + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Angle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of angle + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + 4 + 0 + + + + true + + + QPlainTextEdit::NoWrap + + + + + + + + 16 + 16 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 0 + 0 + + + + Axis point + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + Curve + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + 0 + 0 + + + + + + + + Type of line + + + + + + + Show line from first point to this point + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables + + + + + + + + + + + + 0 + 0 + + + + Qt::PlainText + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHereAngle + toolButtonEqualAngle + pushButtonGrowLengthAngle + comboBoxAxisPoint + comboBoxCurve + lineEditNamePoint + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogCurveIntersectAxis + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogCurveIntersectAxis + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp new file mode 100644 index 000000000..247e02dd2 --- /dev/null +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -0,0 +1,198 @@ +/************************************************************************ + ** + ** @file dialogcutarc.cpp + ** @author Roman Telezhynskyi + ** @date 7 1, 2014 + ** + ** @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 + ** 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 "dialogcutarc.h" +#include "ui_dialogcutarc.h" + +#include "../../geometry/varc.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolcutarc.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogCutArc create dialog. + * @param data container with data + * @param parent parent widget + */ +DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent) + : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), + arcId(NULL_ID), formulaBaseHeight(0), path(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxArcs(ui->comboBoxArc); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutArc::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutArc::PutVal); + + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutArc::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit); + + path = new VisToolCutArc(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); + scene->addItem(path); + path->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogCutArc::~DialogCutArc() +{ + if (qApp->getCurrentScene()->items().contains(path)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete path; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Arc) + { + if (SetObject(id, ui->comboBoxArc, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + arcId = getCurrentObjectId(ui->comboBoxArc); + + path->setPoint1Id(arcId); + path->setLength(formula); + path->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setArcId set id of arc + * @param value id + */ +void DialogCutArc::setArcId(const quint32 &value) +{ + setCurrentArcId(ui->comboBoxArc, arcId, value, ComboBoxCutArc::CutArc); + path->setPoint1Id(arcId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string with formula length + * @param value string with formula + */ +void DialogCutArc::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name point on arc + * @param value name + */ +void DialogCutArc::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string with formula length + * @return formula + */ +QString DialogCutArc::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h new file mode 100644 index 000000000..d2cf2f288 --- /dev/null +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -0,0 +1,114 @@ +/************************************************************************ + ** + ** @file dialogcutarc.h + ** @author Roman Telezhynskyi + ** @date 7 1, 2014 + ** + ** @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 + ** 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 DIALOGCUTARC_H +#define DIALOGCUTARC_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogCutArc; +} + +class VisToolCutArc; + +/** + * @brief The DialogCutArc class dialog for ToolCutArc. + */ +class DialogCutArc : public DialogTool +{ + Q_OBJECT +public: + + DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogCutArc(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getArcId() const; + void setArcId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogCutArc) + /** @brief ui keeps information about user interface */ + Ui::DialogCutArc *ui; + + /** @brief formula string with formula */ + QString formula; + + /** @brief arcId keep id of arc */ + quint32 arcId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + VisToolCutArc *path; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name point on arc + * @return name + */ +inline QString DialogCutArc::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getArcId return id of arc + * @return id + */ +inline quint32 DialogCutArc::getArcId() const +{ + return arcId; +} + +#endif // DIALOGCUTARC_H diff --git a/src/dialogs/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogcutarc.ui similarity index 55% rename from src/dialogs/dialogshoulderpoint.ui rename to src/app/dialogs/tools/dialogcutarc.ui index b1865211e..8313e5784 100644 --- a/src/dialogs/dialogshoulderpoint.ui +++ b/src/app/dialogs/tools/dialogcutarc.ui @@ -1,28 +1,25 @@ - DialogShoulderPoint - + DialogCutArc + 0 0 - 473 - 485 + 412 + 433 - Point of shoulder + Cut arc - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - - + - + @@ -74,28 +71,45 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula calculation of length of line + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -123,6 +137,9 @@ Value of length + + + _ @@ -131,211 +148,110 @@ - + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Name new point - - - - - - - - - - Put variable into formula - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - - - - 0 - 0 - - - - First point - - - - - - - - 0 - 0 - - - - - 145 - 0 - - - - - - - - - - - - - 0 - 0 - - - - Second point - - - - - - - - 0 - 0 - - - - - 143 - 0 - - - - - - - - - - - - - 0 - 0 - - - - Point of shoulder - - - - - - - - 0 - 0 - - - - - 145 - 0 - - - - - - - - - - - - - 0 - 0 - - - - Type of line - - - - - - - Show line from first point to our point - - - - - + + + + + + + 0 + 0 + + + + Arc + + + + + + + Selected curve + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + @@ -345,8 +261,14 @@ + + + 0 + 0 + + - Size and growth + Size and height true @@ -354,14 +276,26 @@ - + + + + 0 + 0 + + - Standart table + Measurements + + + 0 + 0 + + Increments @@ -372,6 +306,12 @@ true + + + 0 + 0 + + Length of lines @@ -382,8 +322,14 @@ true + + + 0 + 0 + + - Length of lines + Length of arcs @@ -392,21 +338,57 @@ true + + + 0 + 0 + + Length of curves + + + + true + + + + 0 + 0 + + + + Angle of lines + + + - - - Variables. Click twice to select. - - + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + @@ -415,6 +397,9 @@ + + true + @@ -423,38 +408,38 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - lineEditFormula + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + comboBoxArc lineEditNamePoint - comboBoxP1Line - comboBoxP2Line - comboBoxPShoulder - comboBoxLineType radioButtonSizeGrowth - radioButtonStandartTable + radioButtonStandardTable radioButtonIncrements radioButtonLengthLine radioButtonLengthArc radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty listWidget - toolButtonPutHere - toolButtonEqual buttonBox - + buttonBox accepted() - DialogShoulderPoint + DialogCutArc accept() @@ -470,7 +455,7 @@ buttonBox rejected() - DialogShoulderPoint + DialogCutArc reject() diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp new file mode 100644 index 000000000..7ed289dcc --- /dev/null +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -0,0 +1,181 @@ +/************************************************************************ + ** + ** @file dialogcutspline.cpp + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 "dialogcutspline.h" +#include "ui_dialogcutspline.h" + +#include "../../geometry/vspline.h" +#include "../../container/vcontainer.h" +#include "../../xml/vpattern.h" +#include "../../visualization/vistoolcutspline.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogCutSpline create dialog. + * @param data container with data + * @param parent parent widget + */ +DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), + splineId(NULL_ID), formulaBaseHeight(0), path(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxSplines(ui->comboBoxSpline); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSpline::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit); + + path = new VisToolCutSpline(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogCutSpline::~DialogCutSpline() +{ + if (qApp->getCurrentScene()->items().contains(path)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete path; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogCutSpline::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogCutSpline::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSplineId set id spline + * @param value id + */ +void DialogCutSpline::setSplineId(const quint32 &value) +{ + setCurrentSplineId(ui->comboBoxSpline, splineId, value, ComboBoxCutSpline::CutSpline); + path->setPoint1Id(splineId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Spline) + { + if (SetObject(id, ui->comboBoxSpline, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + splineId = getCurrentObjectId(ui->comboBoxSpline); + + path->setPoint1Id(splineId); + path->setLength(formula); + path->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); + scene->addItem(path); + path->RefreshGeometry(); + } +} diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h new file mode 100644 index 000000000..163d703c0 --- /dev/null +++ b/src/app/dialogs/tools/dialogcutspline.h @@ -0,0 +1,120 @@ +/************************************************************************ + ** + ** @file dialogcutspline.h + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 DIALOGCUTSPLINE_H +#define DIALOGCUTSPLINE_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogCutSpline; +} + +class VisToolCutSpline; + +/** + * @brief The DialogCutSpline class dialog for ToolCutSpline. + */ +class DialogCutSpline : public DialogTool +{ + Q_OBJECT +public: + DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogCutSpline(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getSplineId() const; + void setSplineId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogCutSpline) + + /** @brief ui keeps information about user interface */ + Ui::DialogCutSpline *ui; + + /** @brief formula string with formula */ + QString formula; + + /** @brief splineId keep id of spline */ + quint32 splineId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + VisToolCutSpline *path; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogCutSpline::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogCutSpline::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSplineId return id base point of line + * @return id + */ +inline quint32 DialogCutSpline::getSplineId() const +{ + return splineId; +} + +#endif // DIALOGCUTSPLINE_H diff --git a/src/dialogs/dialogbisector.ui b/src/app/dialogs/tools/dialogcutspline.ui similarity index 54% rename from src/dialogs/dialogbisector.ui rename to src/app/dialogs/tools/dialogcutspline.ui index c33b41537..3107db846 100644 --- a/src/dialogs/dialogbisector.ui +++ b/src/app/dialogs/tools/dialogcutspline.ui @@ -1,23 +1,23 @@ - DialogBisector - + DialogCutSpline + 0 0 - 480 - 485 + 412 + 433 - Bisector + Cut curve - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - + @@ -71,28 +71,45 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula calculation of length of bisector + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -120,6 +137,9 @@ Value of length + + + _ @@ -127,179 +147,111 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Name new point - - - - - - - - - - Put variable into formula - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - - - - 0 - 0 - - - - First point - - - - - - - First point of angle - - - - - - - - - - - - 0 - 0 - - - - Second point - - - - - - - Second point of angle - - - - - - - - - - - - 0 - 0 - - - - Third point - - - - - - - Third point of angle - - - - - - - - - - - Type line - - - - - - - Show line from second point to our point - - - - - + + + + + + + 0 + 0 + + + + Curve + + + + + + + Selected curve + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + @@ -309,8 +261,14 @@ + + + 0 + 0 + + - Size and growth + Size and height true @@ -318,14 +276,26 @@ - + + + + 0 + 0 + + - Standart table + Measurements + + + 0 + 0 + + Increments @@ -336,6 +306,12 @@ true + + + 0 + 0 + + Length of lines @@ -346,6 +322,12 @@ true + + + 0 + 0 + + Length of arcs @@ -356,21 +338,57 @@ true + + + 0 + 0 + + Length of curves + + + + true + + + + 0 + 0 + + + + Angle of lines + + + - - - Variables. Click twice to select. - - + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + @@ -379,49 +397,49 @@ + + true + - - - Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - lineEditFormula + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + comboBoxSpline lineEditNamePoint - comboBoxFirstPoint - comboBoxSecondPoint - comboBoxThirdPoint - comboBoxLineType radioButtonSizeGrowth - radioButtonStandartTable + radioButtonStandardTable radioButtonIncrements radioButtonLengthLine radioButtonLengthArc radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty listWidget - toolButtonPutHere - toolButtonEqual buttonBox - + buttonBox accepted() - DialogBisector + DialogCutSpline accept() @@ -437,7 +455,7 @@ buttonBox rejected() - DialogBisector + DialogCutSpline reject() diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp new file mode 100644 index 000000000..6367feae9 --- /dev/null +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -0,0 +1,181 @@ +/************************************************************************ + ** + ** @file dialogcutsplinrpath.cpp + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 "dialogcutsplinepath.h" +#include "ui_dialogcutsplinepath.h" + +#include "../../geometry/vsplinepath.h" +#include "../../container/vcontainer.h" +#include "../../xml/vpattern.h" +#include "../../visualization/vistoolcutsplinepath.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogCutSplinePath create dialog. + * @param data container with data + * @param parent parent widget + */ +DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), + splinePathId(NULL_ID), formulaBaseHeight(0), path(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxSplinesPath(ui->comboBoxSplinePath); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSplinePath::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit); + + path = new VisToolCutSplinePath(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogCutSplinePath::~DialogCutSplinePath() +{ + if (qApp->getCurrentScene()->items().contains(path)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete path; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogCutSplinePath::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogCutSplinePath::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSplineId set id spline + * @param value id + */ +void DialogCutSplinePath::setSplinePathId(const quint32 &value) +{ + setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, ComboBoxCutSpline::CutSpline); + path->setPoint1Id(splinePathId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::SplinePath) + { + if (SetObject(id, ui->comboBoxSplinePath, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + splinePathId = getCurrentObjectId(ui->comboBoxSplinePath); + + path->setPoint1Id(splinePathId); + path->setLength(formula); + path->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); + scene->addItem(path); + path->RefreshGeometry(); + } +} diff --git a/src/app/dialogs/tools/dialogcutsplinepath.h b/src/app/dialogs/tools/dialogcutsplinepath.h new file mode 100644 index 000000000..063cd316b --- /dev/null +++ b/src/app/dialogs/tools/dialogcutsplinepath.h @@ -0,0 +1,120 @@ +/************************************************************************ + ** + ** @file dialogcutsplinrpath.h + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 DIALOGCUTSPLINEPATH_H +#define DIALOGCUTSPLINEPATH_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogCutSplinePath; +} + +class VisToolCutSplinePath; + +/** + * @brief The DialogCutSplinePath class dialog for ToolCutSplinePath. + */ +class DialogCutSplinePath : public DialogTool +{ + Q_OBJECT +public: + DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogCutSplinePath(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getSplinePathId() const; + void setSplinePathId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogCutSplinePath) + + /** @brief ui keeps information about user interface */ + Ui::DialogCutSplinePath *ui; + + /** @brief formula string with formula */ + QString formula; + + /** @brief splinePathId keep id of splinePath */ + quint32 splinePathId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + VisToolCutSplinePath *path; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogCutSplinePath::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogCutSplinePath::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSplineId return id base point of line + * @return id + */ +inline quint32 DialogCutSplinePath::getSplinePathId() const +{ + return splinePathId; +} + +#endif // DIALOGCUTSPLINEPATH_H diff --git a/src/app/dialogs/tools/dialogcutsplinepath.ui b/src/app/dialogs/tools/dialogcutsplinepath.ui new file mode 100644 index 000000000..f5d497074 --- /dev/null +++ b/src/app/dialogs/tools/dialogcutsplinepath.ui @@ -0,0 +1,472 @@ + + + DialogCutSplinePath + + + + 0 + 0 + 412 + 433 + + + + Cut curve path + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of length + + + + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Curve + + + + + + + Selected curve path + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + comboBoxSplinePath + lineEditNamePoint + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogCutSplinePath + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogCutSplinePath + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogdetail.cpp b/src/app/dialogs/tools/dialogdetail.cpp new file mode 100644 index 000000000..4605084a4 --- /dev/null +++ b/src/app/dialogs/tools/dialogdetail.cpp @@ -0,0 +1,334 @@ +/************************************************************************ + ** + ** @file dialogdetail.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogdetail.h" + +#include + +#include "../../geometry/varc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/vsplinepath.h" +#include "../../container/vcontainer.h" +#include "../../libs/ifc/xml/vdomdocument.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogDetail create dialog + * @param data container with data + * @param parent parent widget + */ +DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(), details(VDetail()), supplement(true), closed(true) +{ + ui.setupUi(this); + labelEditNamePoint = ui.labelEditNameDetail; + ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + + bOk = ui.buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted); + QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCansel != nullptr); + connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected); + + flagName = true;//We have default name of detail. + ChangeColor(labelEditNamePoint, okColor); + CheckState(); + + connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged); + connect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogDetail::BiasXChanged); + connect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogDetail::BiasYChanged); + connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams); + connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed); + connect(ui.checkBoxReverse, &QCheckBox::clicked, this, &DialogDetail::ClickedReverse); + connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged); + + connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of objects (points, arcs, splines, spline paths) + * @param type type of object + */ +void DialogDetail::ChosenObject(quint32 id, const SceneObject &type) +{ + if (type != SceneObject::Line && type != SceneObject::Detail) + { + switch (type) + { + case (SceneObject::Arc): + NewItem(id, Tool::NodeArc, NodeDetail::Contour); + break; + case (SceneObject::Point): + NewItem(id, Tool::NodePoint, NodeDetail::Contour); + break; + case (SceneObject::Spline): + NewItem(id, Tool::NodeSpline, NodeDetail::Contour); + break; + case (SceneObject::SplinePath): + NewItem(id, Tool::NodeSplinePath, NodeDetail::Contour); + break; + case (SceneObject::Line): + case (SceneObject::Detail): + case (SceneObject::Unknown): + default: + qDebug()<setEnabled(true); + this->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::SaveData() +{ + details.Clear(); + for (qint32 i = 0; i < ui.listWidget->count(); ++i) + { + QListWidgetItem *item = ui.listWidget->item(i); + details.append( qvariant_cast(item->data(Qt::UserRole))); + } + details.setWidth(ui.doubleSpinBoxSeams->value()); + details.setName(ui.lineEditNameDetail->text()); + details.setSeamAllowance(supplement); + details.setClosed(closed); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewItem add new object (point, arc, spline or spline path) to list + * @param id id of object + * @param typeTool type of tool + * @param typeNode type of node in detail + * @param mx offset respect to x + * @param my offset respect to y + * @param reverse reverse list of points + */ +void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode, + qreal mx, qreal my, bool reverse) +{ + QString name; + switch (typeTool) + { + case (Tool::NodePoint): + { + const QSharedPointer point = data->GeometricObject(id); + name = point->name(); + break; + } + case (Tool::NodeArc): + { + const QSharedPointer arc = data->GeometricObject(id); + name = arc->name(); + break; + } + case (Tool::NodeSpline): + { + const QSharedPointer spl = data->GeometricObject(id); + name = spl->name(); + break; + } + case (Tool::NodeSplinePath): + { + const QSharedPointer splPath = data->GeometricObject(id); + name = splPath->name(); + break; + } + default: + qDebug()<<"Got wrong tools. Ignore."; + break; + } + + QListWidgetItem *item = new QListWidgetItem(name); + item->setFont(QFont("Times", 12, QFont::Bold)); + VNodeDetail node(id, typeTool, typeNode, mx, my, reverse); + item->setData(Qt::UserRole, QVariant::fromValue(node)); + ui.listWidget->addItem(item); + ui.listWidget->setCurrentRow(ui.listWidget->count()-1); + + ui.doubleSpinBoxBiasX->blockSignals(true); + ui.doubleSpinBoxBiasY->blockSignals(true); + + ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx())); + ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy())); + if (node.getTypeTool() == Tool::NodePoint) + { + ui.checkBoxReverse->setChecked(false); + ui.checkBoxReverse->setEnabled(false); + } + else + { + ui.checkBoxReverse->setEnabled(true); + ui.checkBoxReverse->setChecked(node.getReverse()); + } + + ui.doubleSpinBoxBiasX->blockSignals(false); + ui.doubleSpinBoxBiasY->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDetails set detail + * @param value detail + */ +void DialogDetail::setDetails(const VDetail &value) +{ + details = value; + ui.listWidget->clear(); + for (int i = 0; i < details.CountNode(); ++i) + { + NewItem(details.at(i).getId(), details.at(i).getTypeTool(), details.at(i).getTypeNode(), details.at(i).getMx(), + details.at(i).getMy(), details.at(i).getReverse()); + } + ui.lineEditNameDetail->setText(details.getName()); + ui.checkBoxSeams->setChecked(details.getSeamAllowance()); + ui.checkBoxClosed->setChecked(details.getClosed()); + ClickedClosed(details.getClosed()); + ClickedSeams(details.getSeamAllowance()); + ui.doubleSpinBoxSeams->setValue(details.getWidth()); + ui.listWidget->setCurrentRow(0); + ui.listWidget->setFocus(Qt::OtherFocusReason); + ui.toolButtonDelete->setEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief BiasXChanged changed value of offset for object respect to x + * @param d value in mm + */ +void DialogDetail::BiasXChanged(qreal d) +{ + qint32 row = ui.listWidget->currentRow(); + QListWidgetItem *item = ui.listWidget->item( row ); + SCASSERT(item != nullptr); + VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); + node.setMx(qApp->toPixel(d)); + item->setData(Qt::UserRole, QVariant::fromValue(node)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief BiasYChanged changed value of offset for object respect to y + * @param d value in mm + */ +void DialogDetail::BiasYChanged(qreal d) +{ + qint32 row = ui.listWidget->currentRow(); + QListWidgetItem *item = ui.listWidget->item( row ); + SCASSERT(item != nullptr); + VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); + node.setMy(qApp->toPixel(d)); + item->setData(Qt::UserRole, QVariant::fromValue(node)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClickedSeams save supplement of seams for detail + * @param checked 1 - need supplement, 0 - don't need supplement + */ +void DialogDetail::ClickedSeams(bool checked) +{ + supplement = checked; + ui.checkBoxClosed->setEnabled(checked); + ui.doubleSpinBoxSeams->setEnabled(checked); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClickedClosed save closed equdistant or not + * @param checked 1 - closed, 0 - don't closed + */ +void DialogDetail::ClickedClosed(bool checked) +{ + closed = checked; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::ClickedReverse(bool checked) +{ + qint32 row = ui.listWidget->currentRow(); + QListWidgetItem *item = ui.listWidget->item( row ); + SCASSERT(item != nullptr); + VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); + node.setReverse(checked); + item->setData(Qt::UserRole, QVariant::fromValue(node)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ObjectChanged changed new object (point, arc, spline or spline path) form list + * @param row number of row + */ +void DialogDetail::ObjectChanged(int row) +{ + if (ui.listWidget->count() == 0) + { + return; + } + const QListWidgetItem *item = ui.listWidget->item( row ); + const VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); + ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx())); + ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy())); + if (node.getTypeTool() == Tool::NodePoint) + { + ui.checkBoxReverse->setChecked(false); + ui.checkBoxReverse->setEnabled(false); + } + else + { + ui.checkBoxReverse->setEnabled(true); + ui.checkBoxReverse->setChecked(node.getReverse()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteItem delete item from list + */ +void DialogDetail::DeleteItem() +{ + qint32 row = ui.listWidget->currentRow(); + delete ui.listWidget->item( row ); +} + + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} diff --git a/src/app/dialogs/tools/dialogdetail.h b/src/app/dialogs/tools/dialogdetail.h new file mode 100644 index 000000000..8f8efe965 --- /dev/null +++ b/src/app/dialogs/tools/dialogdetail.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file dialogdetail.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGDETAIL_H +#define DIALOGDETAIL_H + +#include "ui_dialogdetail.h" +#include "dialogtool.h" +#include "../../geometry/vdetail.h" + +/** + * @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option. + */ +class DialogDetail : public DialogTool +{ + Q_OBJECT +public: + DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + + VDetail getDetails() const; + void setDetails(const VDetail &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + void BiasXChanged(qreal d); + void BiasYChanged(qreal d); + void ClickedSeams(bool checked); + void ClickedClosed(bool checked); + void ClickedReverse(bool checked); + void ObjectChanged(int row); + void DeleteItem(); + virtual void UpdateList(); +protected: + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + + /** @brief ui keeps information about user interface */ + Ui::DialogDetail ui; + + /** @brief details detail */ + VDetail details; + + /** @brief supplement keep option supplement of seams */ + bool supplement; + + /** @brief closed keep option about equdistant (closed or not) */ + bool closed; + + void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode, + qreal mx = 0, qreal my = 0, bool reverse = false); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getDetails return detail + * @return detail + */ +inline VDetail DialogDetail::getDetails() const +{ + return details; +} + +#endif // DIALOGDETAIL_H diff --git a/src/dialogs/dialogdetail.ui b/src/app/dialogs/tools/dialogdetail.ui similarity index 67% rename from src/dialogs/dialogdetail.ui rename to src/app/dialogs/tools/dialogdetail.ui index 08aba5839..212625aef 100644 --- a/src/dialogs/dialogdetail.ui +++ b/src/app/dialogs/tools/dialogdetail.ui @@ -6,15 +6,15 @@ 0 0 - 544 - 327 + 565 + 342 Detail - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -41,6 +41,12 @@ + + + 1 + 0 + + Bias X @@ -48,11 +54,30 @@ + + + 1 + 0 + + - -10000.000000000000000 + -900.990000000000009 - 10000.000000000000000 + 900.990000000000009 + + + 0.100000000000000 + + + 0.000000000000000 + + + + + + + cm @@ -64,7 +89,7 @@ - 0 + 1 0 @@ -75,11 +100,38 @@ + + + 1 + 0 + + - -10000.000000000000000 + -900.990000000000009 - 10000.000000000000000 + 900.990000000000009 + + + 0.100000000000000 + + + + + + + cm + + + + + + + + + + + Reverse @@ -88,7 +140,7 @@ - Option + Options @@ -154,6 +206,9 @@ 0 + + Detail + @@ -161,7 +216,7 @@ - Supplement for seams + Seam allowance true @@ -174,7 +229,7 @@ - 0 + 1 0 @@ -188,11 +243,33 @@ - - -10000.000000000000000 + + + 1 + 0 + + + + 900.990000000000009 + + + 0.100000000000000 - 10.000000000000000 + 1.000000000000000 + + + + + + + + 0 + 0 + + + + cm @@ -208,6 +285,16 @@ + + + + false + + + Delete + + + @@ -231,12 +318,18 @@ - lineEditNameDetail listWidget + doubleSpinBoxBiasX + doubleSpinBoxBiasY + lineEditNameDetail + checkBoxSeams + doubleSpinBoxSeams + checkBoxClosed + toolButtonDelete buttonBox - + diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp new file mode 100644 index 000000000..3987b12a7 --- /dev/null +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -0,0 +1,153 @@ +/************************************************************************ + ** + ** @file dialogeditwrongformula.cpp + ** @author Roman Telezhynskyi + ** @date 29 5, 2014 + ** + ** @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) 2014 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 "dialogeditwrongformula.h" +#include "ui_dialogeditwrongformula.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0), + checkZero(false), postfix(QString()), restoreCursor(false) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancel(ui); + flagFormula = false; + CheckState(); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); + + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); + + //Disable Qt::WaitCursor +#ifndef QT_NO_CURSOR + if (QApplication::overrideCursor() != nullptr) + { + if (QApplication::overrideCursor()->shape() == Qt::WaitCursor) + { + restoreCursor = true; + QApplication::restoreOverrideCursor(); + } + } +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogEditWrongFormula::~DialogEditWrongFormula() +{ +#ifndef QT_NO_CURSOR + if (restoreCursor) + { + QApplication::setOverrideCursor(Qt::WaitCursor); + } +#endif + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::DialogAccepted() +{ + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + emit DialogClosed(QDialog::Accepted); + accepted(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::DialogRejected() +{ + emit DialogClosed(QDialog::Rejected); + rejected(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::EvalFormula() +{ + SCASSERT(plainTextEditFormula != nullptr); + SCASSERT(labelResultCalculation != nullptr); + Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::setCheckZero(bool value) +{ + checkZero = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::setPostfix(const QString &value) +{ + postfix = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogEditWrongFormula::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h new file mode 100644 index 000000000..a2d389baf --- /dev/null +++ b/src/app/dialogs/tools/dialogeditwrongformula.h @@ -0,0 +1,85 @@ +/************************************************************************ + ** + ** @file dialogeditwrongformula.h + ** @author Roman Telezhynskyi + ** @date 29 5, 2014 + ** + ** @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) 2014 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 DIALOGEDITWRONGFORMULA_H +#define DIALOGEDITWRONGFORMULA_H + +#include "dialogtool.h" + +namespace Ui +{ +class DialogEditWrongFormula; +} + +/** + * @brief The DialogEditWrongFormula class dialog for editing wrong formula. + * + * When math parser find in formula error user can try fix issue. Dialog will show all variables that user can use in + * this formula. Dialog check fixed variant of formula. + * + * Don't implemant button "Apply" for this dialog!! + */ +class DialogEditWrongFormula : public DialogTool +{ + Q_OBJECT +public: + explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogEditWrongFormula(); + + QString getFormula() const; + void setFormula(const QString &value); + void setCheckZero(bool value); + void setPostfix(const QString &value); +public slots: + virtual void DialogAccepted(); + virtual void DialogRejected(); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + virtual void EvalFormula(); +protected: + virtual void CheckState(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogEditWrongFormula) + Ui::DialogEditWrongFormula *ui; + + /** @brief formula string with formula */ + QString formula; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + bool checkZero; + QString postfix; + bool restoreCursor; +}; + + +#endif // DIALOGEDITWRONGFORMULA_H diff --git a/src/dialogs/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogeditwrongformula.ui similarity index 58% rename from src/dialogs/dialogpointofcontact.ui rename to src/app/dialogs/tools/dialogeditwrongformula.ui index e4f1fba75..47d43dd6a 100644 --- a/src/dialogs/dialogpointofcontact.ui +++ b/src/app/dialogs/tools/dialogeditwrongformula.ui @@ -1,26 +1,29 @@ - DialogPointOfContact - + DialogEditWrongFormula + + + Qt::ApplicationModal + 0 0 - 476 - 450 + 390 + 365 - Point of contact + Edit formula - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - + + true - + @@ -69,33 +72,53 @@ - Radius + Formula - - - - 0 - 0 - + + + Qt::Horizontal + + + 40 + 20 + + + + + + - Formula calculation of radius of arc + Insert variable into formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -121,7 +144,10 @@ - Value of radius + Value of first angle + + + _ @@ -130,193 +156,79 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Name new point - - - - - - - - - - Put variable into formula - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - - - - 0 - 0 - - - - Center of arc - - - - - - - - 0 - 0 - - - - - 145 - 0 - - - - Slect point of center of arc - - - - - - - - - - - - 0 - 0 - - - - Top of the line - - - - - - - - 0 - 0 - - - - - 143 - 0 - - - - - - - - - - - - - 0 - 0 - - - - End of the line - - - - - - - - 0 - 0 - - - - - 145 - 0 - - - - - - - + + + + 0 + 0 + + Input data @@ -324,8 +236,14 @@ + + + 0 + 0 + + - Size and growth + Size and height true @@ -333,14 +251,26 @@ - + + + + 0 + 0 + + - Standart table + Measurements + + + 0 + 0 + + Increments @@ -351,6 +281,12 @@ true + + + 0 + 0 + + Length of lines @@ -361,6 +297,12 @@ true + + + 0 + 0 + + Length of arcs @@ -371,21 +313,57 @@ true + + + 0 + 0 + + Length of curves + + + + true + + + + 0 + 0 + + + + Angle of lines + + + - - - Variables. Click twice to select. - - + + + + + Hide empty measurements + + + true + + + + + + + Variables + + + + @@ -394,6 +372,9 @@ + + true + @@ -409,30 +390,29 @@ - lineEditFormula - lineEditNamePoint - comboBoxCenter - comboBoxFirstPoint - comboBoxSecondPoint + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength radioButtonSizeGrowth - radioButtonStandartTable + radioButtonStandardTable radioButtonIncrements radioButtonLengthLine radioButtonLengthArc radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty listWidget - toolButtonPutHere - toolButtonEqual buttonBox - + buttonBox accepted() - DialogPointOfContact + DialogEditWrongFormula accept() @@ -448,7 +428,7 @@ buttonBox rejected() - DialogPointOfContact + DialogEditWrongFormula reject() diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp new file mode 100644 index 000000000..8da548990 --- /dev/null +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -0,0 +1,310 @@ +/************************************************************************ + ** + ** @file dialogendline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogendline.h" +#include "ui_dialogendline.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolendline.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogEndLine create dialog + * @param data container with data + * @param parent parent widget + */ +DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), typeLine(QString()), + formulaLength(QString()), formulaAngle(QString()), basePointId(NULL_ID), formulaBaseHeight(0), + formulaBaseHeightAngle(0), line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + this->formulaBaseHeightAngle = ui->plainTextEditAngle->height(); + + ui->plainTextEditFormula->installEventFilter(this); + ui->plainTextEditAngle->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxBasePoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + + connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere); + connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogEndLine::PutAngle); + + connect(ui->toolButtonEqualLength, &QPushButton::clicked, this, &DialogEndLine::EvalFormula); + connect(ui->toolButtonEqualAngle, &QPushButton::clicked, this, &DialogEndLine::EvalAngle); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); + + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged); + connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogEndLine::AngleTextChanged); + + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit); + connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogEndLine::DeployAngleTextEdit); + + connect(timerFormula, &QTimer::timeout, this, &DialogEndLine::EvalAngle); + + line = new VisToolEndLine(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutAngle put variable into formula of angle + */ +void DialogEndLine::PutAngle() +{ + PutValHere(ui->plainTextEditAngle, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EvalAngle calculate value of angle + */ +void DialogEndLine::EvalAngle() +{ + labelEditFormula = ui->labelEditAngle; + Eval(ui->plainTextEditAngle->toPlainText(), flagError, ui->labelResultCalculationAngle, degreeSymbol, false); + labelEditFormula = ui->labelEditFormula; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::AngleTextChanged() +{ + labelEditFormula = ui->labelEditAngle; + ValFormulaChanged(flagError, ui->plainTextEditAngle, timerFormula); + labelEditFormula = ui->labelEditFormula; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::DeployAngleTextEdit() +{ + DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxBasePoint, "")) + { + basePointId = id; + line->VisualMode(id); + connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); + prepare = true; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogEndLine::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogEndLine::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogEndLine::setFormula(const QString &value) +{ + formulaLength = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formulaLength.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formulaLength); + line->setLength(formulaLength); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAngle set angle of line + * @param value angle in degree + */ +void DialogEndLine::setAngle(const QString &value) +{ + formulaAngle = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formulaAngle.length() > 80) + { + this->DeployAngleTextEdit(); + } + ui->plainTextEditAngle->setPlainText(formulaAngle); + line->setAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setBasePointId set id base point of line + * @param value id + */ +void DialogEndLine::setBasePointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxBasePoint, basePointId, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogEndLine::ShowDialog show dialog after finish working with visual part + * @param click true if need show dialog after click mouse + */ +void DialogEndLine::ShowDialog(bool click) +{ + if (prepare) + { + if (click) + { + /*We will ignore click if poinet is in point circle*/ + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + const QSharedPointer point = data->GeometricObject(basePointId); + QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); + + //Radius of point circle, but little bigger. Need handle with hover sizes. + qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5; + if (line.length() <= radius) + { + return; + } + } + this->setModal(true); + this->setAngle(line->Angle());//Show in dialog angle what user choose + emit ToolTip(""); + timerFormula->start(); + this->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::ShowVisualization() +{ + if (prepare == false) + { + //TODO move to parent class! + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + + formulaLength = ui->plainTextEditFormula->toPlainText(); + formulaLength.replace("\n", " "); + + formulaAngle = ui->plainTextEditAngle->toPlainText(); + formulaAngle.replace("\n", " "); + + basePointId = getCurrentObjectId(ui->comboBoxBasePoint); + + line->setPoint1Id(basePointId); + line->setLength(formulaLength); + line->setAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + ui->plainTextEditAngle->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogEndLine::~DialogEndLine() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h new file mode 100644 index 000000000..0747f4b65 --- /dev/null +++ b/src/app/dialogs/tools/dialogendline.h @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file dialogendline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGENDLINE_H +#define DIALOGENDLINE_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogEndLine; +} + +class VisToolEndLine; + +/** + * @brief The DialogEndLine class dialog for ToolEndLine. Help create point and edit option. + */ +class DialogEndLine : public DialogTool +{ + Q_OBJECT +public: + DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogEndLine(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + QString getAngle() const; + void setAngle(const QString &value); + + quint32 getBasePointId() const; + void setBasePointId(const quint32 &value); + virtual void ShowDialog(bool click); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + void PutAngle(); + void EvalAngle(); + void AngleTextChanged(); + void DeployAngleTextEdit(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogEndLine) + + /** @brief ui keeps information about user interface */ + Ui::DialogEndLine *ui; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief formula formula */ + QString formulaLength; + + /** @brief angle angle of line */ + QString formulaAngle; + + /** @brief basePointId id base point of line */ + quint32 basePointId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + int formulaBaseHeightAngle; + + VisToolEndLine *line; + + +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogEndLine::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogEndLine::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogEndLine::getFormula() const +{ + return qApp->FormulaFromUser(formulaLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAngle return formula angle of line + * @return angle formula + */ +inline QString DialogEndLine::getAngle() const +{ + return qApp->FormulaFromUser(formulaAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getBasePointId return id base point of line + * @return id + */ +inline quint32 DialogEndLine::getBasePointId() const +{ + return basePointId; +} + +#endif // DIALOGENDLINE_H diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui new file mode 100644 index 000000000..a34de47cc --- /dev/null +++ b/src/app/dialogs/tools/dialogendline.ui @@ -0,0 +1,694 @@ + + + DialogEndLine + + + + 0 + 0 + 417 + 538 + + + + + 0 + 0 + + + + Point in the end of a line + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of length + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + 4 + 0 + + + + true + + + QPlainTextEdit::NoWrap + + + + + + + + 16 + 16 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Angle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of angle + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + 4 + 0 + + + + true + + + QPlainTextEdit::NoWrap + + + + + + + + 16 + 16 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + 0 + 0 + + + + Base point + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + Type of line + + + + + + + Show line from first point to this point + + + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables + + + + + + + + + + + + 0 + 0 + + + + Qt::PlainText + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHereLength + toolButtonEqualLength + pushButtonGrowLength + plainTextEditAngle + toolButtonPutHereAngle + toolButtonEqualAngle + pushButtonGrowLengthAngle + comboBoxBasePoint + lineEditNamePoint + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogEndLine + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogEndLine + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp new file mode 100644 index 000000000..573906e79 --- /dev/null +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -0,0 +1,263 @@ +/************************************************************************ + ** + ** @file dialogheight.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogheight.h" +#include "ui_dialogheight.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../tools/vabstracttool.h" +#include "../visualization/vistoolheight.h" +#include "../widgets/vmaingraphicsscene.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogHeight create dialog + * @param data container with data + * @param parent parent widget + */ +DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), + typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr) +{ + ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + InitOkCancelApply(ui); + CheckState(); + + FillComboBoxPoints(ui->comboBoxBasePoint); + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); + FillComboBoxTypeLine(ui->comboBoxLineType); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); + connect(ui->comboBoxBasePoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogHeight::PointNameChanged); + connect(ui->comboBoxP1Line, static_cast(&QComboBox::currentIndexChanged), + this, &DialogHeight::PointNameChanged); + connect(ui->comboBoxP2Line, static_cast(&QComboBox::currentIndexChanged), + this, &DialogHeight::PointNameChanged); + + line = new VisToolHeight(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogHeight::~DialogHeight() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogHeight::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogHeight::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setBasePointId set id base point of height + * @param value id + */ +void DialogHeight::setBasePointId(const quint32 &value) +{ + setPointId(ui->comboBoxBasePoint, basePointId, value); + line->setPoint1Id(basePointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP1LineId set id first point of line + * @param value id + */ +void DialogHeight::setP1LineId(const quint32 &value) +{ + setPointId(ui->comboBoxP1Line, p1LineId, value); + line->setLineP1Id(p1LineId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP2LineId set id second point of line + * @param value id + */ +void DialogHeight::setP2LineId(const quint32 &value) +{ + setPointId(ui->comboBoxP2Line, p2LineId, value); + line->setLineP2Id(p2LineId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case (0): + if (SetObject(id, ui->comboBoxBasePoint, tr("Select first point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case (1): + if (getCurrentObjectId(ui->comboBoxBasePoint) != id) + { + if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + { + number++; + line->setLineP1Id(id); + line->RefreshGeometry(); + } + } + break; + case (2): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxP2Line, "")) + { + line->setLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogHeight::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + basePointId = getCurrentObjectId(ui->comboBoxBasePoint); + p1LineId = getCurrentObjectId(ui->comboBoxP1Line); + p2LineId = getCurrentObjectId(ui->comboBoxP2Line); + + line->setPoint1Id(basePointId); + line->setLineP1Id(p1LineId); + line->setLineP2Id(p2LineId); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogHeight::PointNameChanged() +{ + QSet set; + const quint32 basePointId = getCurrentObjectId(ui->comboBoxBasePoint); + const quint32 p1LineId = getCurrentObjectId(ui->comboBoxP1Line); + const quint32 p2LineId = getCurrentObjectId(ui->comboBoxP2Line); + + set.insert(basePointId); + set.insert(p1LineId); + set.insert(p2LineId); + + const QSharedPointer basePoint = data->GeometricObject(basePointId); + const QSharedPointer p1Line = data->GeometricObject(p1LineId); + const QSharedPointer p2Line = data->GeometricObject(p2LineId); + + QColor color = okColor; + if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), + basePoint->toQPointF()) == QPointF()) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelBasePoint, color); + ChangeColor(ui->labelFirstLinePoint, color); + ChangeColor(ui->labelSecondLinePoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogHeight::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogHeight::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} diff --git a/src/app/dialogs/tools/dialogheight.h b/src/app/dialogs/tools/dialogheight.h new file mode 100644 index 000000000..8c384b145 --- /dev/null +++ b/src/app/dialogs/tools/dialogheight.h @@ -0,0 +1,148 @@ +/************************************************************************ + ** + ** @file dialogheight.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGHEIGHT_H +#define DIALOGHEIGHT_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogHeight; +} + +class VisToolHeight; + +/** + * @brief The DialogHeight class dialog for ToolHeight. Help create point and edit option. + */ +class DialogHeight : public DialogTool +{ + Q_OBJECT +public: + DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogHeight(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + quint32 getBasePointId() const; + void setBasePointId(const quint32 &value); + + quint32 getP1LineId() const; + void setP1LineId(const quint32 &value); + + quint32 getP2LineId() const; + void setP2LineId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogHeight) + + /** @brief ui keeps information about user interface */ + Ui::DialogHeight *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief basePointId id base point of height */ + quint32 basePointId; + + /** @brief p1LineId id first point of line */ + quint32 p1LineId; + + /** @brief p2LineId id second point of line */ + quint32 p2LineId; + VisToolHeight *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogHeight::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogHeight::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getBasePointId return id base point of height + * @return id + */ +inline quint32 DialogHeight::getBasePointId() const +{ + return basePointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP1LineId return id first point of line + * @return id id + */ +inline quint32 DialogHeight::getP1LineId() const +{ + return p1LineId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP2LineId return id second point of line + * @return id + */ +inline quint32 DialogHeight::getP2LineId() const +{ + return p2LineId; +} + +#endif // DIALOGHEIGHT_H diff --git a/src/dialogs/dialogheight.ui b/src/app/dialogs/tools/dialogheight.ui similarity index 65% rename from src/dialogs/dialogheight.ui rename to src/app/dialogs/tools/dialogheight.ui index 9c4900050..be8edb8cf 100644 --- a/src/dialogs/dialogheight.ui +++ b/src/app/dialogs/tools/dialogheight.ui @@ -6,20 +6,27 @@ 0 0 - 247 - 220 + 285 + 212 - Dialog + Height + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + @@ -27,57 +34,16 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Name new point + Point label - + - - - - - - + + 0 @@ -89,19 +55,15 @@ - + First point of line - - - - - - + + 0 @@ -113,19 +75,15 @@ - + First point of line - - - - - - + + 0 @@ -137,25 +95,21 @@ - + First point of line - - - - - + - Type line + Type of line - + Show line from first point to our point @@ -170,13 +124,23 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + + lineEditNamePoint + comboBoxBasePoint + comboBoxP1Line + comboBoxP2Line + comboBoxLineType + buttonBox + + + + buttonBox diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp new file mode 100644 index 000000000..287055246 --- /dev/null +++ b/src/app/dialogs/tools/dialogline.cpp @@ -0,0 +1,202 @@ +/************************************************************************ + ** + ** @file dialogline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogline.h" +#include "ui_dialogline.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolline.h" +#include "../../core/vapplication.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogLine create dialog + * @param data container with data + * @param parent parent widget + */ +DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLine), number(0), firstPoint(NULL_ID), secondPoint(NULL_ID), + typeLine(QString()), line(nullptr) +{ + ui->setupUi(this); + InitOkCancelApply(ui); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + + number = 0; + + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLine::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLine::PointNameChanged); + + line = new VisToolLine(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogLine::~DialogLine() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPoint set id second point + * @param value id + */ +void DialogLine::setSecondPoint(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPoint, value); + line->setPoint2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogLine::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPoint set id first point + * @param value id + */ +void DialogLine::setFirstPoint(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPoint, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLine::PointNameChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLine::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variables. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLine::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLine::SaveData() +{ + qint32 index = ui->comboBoxFirstPoint->currentIndex(); + firstPoint = qvariant_cast(ui->comboBoxFirstPoint->itemData(index)); + index = ui->comboBoxSecondPoint->currentIndex(); + secondPoint = qvariant_cast(ui->comboBoxSecondPoint->itemData(index)); + typeLine = GetTypeLine(ui->comboBoxLineType); + + line->setPoint1Id(firstPoint); + line->setPoint2Id(secondPoint); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogLine::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + if (flagError) + { + number = 0; + prepare = true; + DialogAccepted(); + } + } + break; + default: + break; + } + } + } +} diff --git a/src/app/dialogs/tools/dialogline.h b/src/app/dialogs/tools/dialogline.h new file mode 100644 index 000000000..c08d061b0 --- /dev/null +++ b/src/app/dialogs/tools/dialogline.h @@ -0,0 +1,120 @@ +/************************************************************************ + ** + ** @file dialogline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGLINE_H +#define DIALOGLINE_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogLine; +} + +class VisToolLine; + +/** + * @brief The DialogLine class dialog for ToolLine. Help create line and edit option. + */ +class DialogLine : public DialogTool +{ + Q_OBJECT +public: + DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogLine(); + + quint32 getFirstPoint() const; + void setFirstPoint(const quint32 &value); + + quint32 getSecondPoint() const; + void setSecondPoint(const quint32 &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogLine) + + /** @brief ui keeps information about user interface */ + Ui::DialogLine *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief firstPoint id first point */ + quint32 firstPoint; + + /** @brief secondPoint id second point */ + quint32 secondPoint; + + /** @brief typeLine type of line */ + QString typeLine; + VisToolLine *line; + +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPoint return id first point + * @return id + */ +inline quint32 DialogLine::getFirstPoint() const +{ + return firstPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPoint return id second point + * @return id + */ +inline quint32 DialogLine::getSecondPoint() const +{ + return secondPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogLine::getTypeLine() const +{ + return typeLine; +} + +#endif // DIALOGLINE_H diff --git a/src/app/dialogs/tools/dialogline.ui b/src/app/dialogs/tools/dialogline.ui new file mode 100644 index 000000000..b02ea2911 --- /dev/null +++ b/src/app/dialogs/tools/dialogline.ui @@ -0,0 +1,191 @@ + + + DialogLine + + + Qt::ApplicationModal + + + + 0 + 0 + 286 + 151 + + + + + 286 + 151 + + + + + 286 + 151 + + + + Line + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + true + + + + + + + + + 90 + 0 + + + + First point + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + 90 + 0 + + + + Second point + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + 90 + 0 + + + + Type of line + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Show line from first point to this point + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + comboBoxFirstPoint + comboBoxSecondPoint + comboBoxLineType + buttonBox + + + + + + + buttonBox + accepted() + DialogLine + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogLine + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp new file mode 100644 index 000000000..ae45b1589 --- /dev/null +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -0,0 +1,392 @@ +/************************************************************************ + ** + ** @file dialoglineintersect.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialoglineintersect.h" +#include "ui_dialoglineintersect.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoollineintersect.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogLineIntersect create dialog + * @param data container with data + * @param parent parent widget + */ +DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), + p1Line1(NULL_ID), p2Line1(NULL_ID), p1Line2(NULL_ID), p2Line2(NULL_ID), flagPoint(true), line(nullptr) +{ + ui->setupUi(this); + number = 0; + InitOkCancelApply(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + FillComboBoxPoints(ui->comboBoxP1Line1); + FillComboBoxPoints(ui->comboBoxP2Line1); + FillComboBoxPoints(ui->comboBoxP1Line2); + FillComboBoxPoints(ui->comboBoxP2Line2); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); + connect(ui->comboBoxP1Line1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP2Line1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP1Line2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP2Line2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + + line = new VisToolLineIntersect(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogLineIntersect::~DialogLineIntersect() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line"))) + { + number++; + p1Line1 = id; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxP1Line1) != id) + { + if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) + { + number++; + p2Line1 = id; + line->setLine1P2Id(id); + line->RefreshGeometry(); + } + } + break; + case 2: + if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) + { + number++; + p1Line2 = id; + line->setLine2P1Id(id); + line->RefreshGeometry(); + } + break; + case 3: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP1Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP2Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line2)); + set.insert(id); + + if (set.size() >= 3) + { + if (SetObject(id, ui->comboBoxP2Line2, "")) + { + p2Line2 = id; + line->setLine2P2Id(id); + line->RefreshGeometry(); + prepare = true; + flagPoint = CheckIntersecion(); + CheckState(); + this->setModal(true); + this->show(); + connect(ui->comboBoxP1Line1, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P1Line1Changed); + connect(ui->comboBoxP2Line1, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P2Line1Changed); + connect(ui->comboBoxP1Line2, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P1Line2Changed); + connect(ui->comboBoxP2Line2, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P2Line2Changed); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersect::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + p1Line1 = getCurrentObjectId(ui->comboBoxP1Line1); + p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1); + p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2); + p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2); + + line->setPoint1Id(p1Line1); + line->setLine1P2Id(p2Line1); + line->setLine2P1Id(p1Line2); + line->setLine2P2Id(p2Line2); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief P1Line1Changed changed first point of first line + * @param index index in list + */ +void DialogLineIntersect::P1Line1Changed( int index) +{ + p1Line1 = qvariant_cast(ui->comboBoxP1Line1->itemData(index)); + flagPoint = CheckIntersecion(); + CheckState(); + + line->setPoint1Id(p1Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief P2Line1Changed changed second point of first line + * @param index index in list + */ +void DialogLineIntersect::P2Line1Changed(int index) +{ + p2Line1 = qvariant_cast(ui->comboBoxP2Line1->itemData(index)); + flagPoint = CheckIntersecion(); + CheckState(); + + line->setLine1P2Id(p2Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief P1Line2Changed changed first point of second line + * @param index index in list + */ +void DialogLineIntersect::P1Line2Changed(int index) +{ + p1Line2 = qvariant_cast(ui->comboBoxP1Line2->itemData(index)); + flagPoint = CheckIntersecion(); + CheckState(); + + line->setLine2P1Id(p1Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief P2Line2Changed changed second point of second line + * @param index index in list + */ +void DialogLineIntersect::P2Line2Changed(int index) +{ + p2Line2 = qvariant_cast(ui->comboBoxP2Line2->itemData(index)); + flagPoint = CheckIntersecion(); + CheckState(); + + line->setLine2P2Id(p2Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersect::PointNameChanged() +{ + QSet set; + const quint32 p1Line1Id = getCurrentObjectId(ui->comboBoxP1Line1); + const quint32 p2Line1Id = getCurrentObjectId(ui->comboBoxP2Line1); + const quint32 p1Line2Id = getCurrentObjectId(ui->comboBoxP1Line2); + const quint32 p2Line2Id = getCurrentObjectId(ui->comboBoxP2Line2); + + set.insert(p1Line1Id); + set.insert(p2Line1Id); + set.insert(p1Line2Id); + set.insert(p2Line2Id); + + const QSharedPointer p1Line1 = data->GeometricObject(p1Line1Id); + const QSharedPointer p2Line1 = data->GeometricObject(p2Line1Id); + const QSharedPointer p1Line2 = data->GeometricObject(p1Line2Id); + const QSharedPointer p2Line2 = data->GeometricObject(p2Line2Id); + + QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF()); + QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF()); + QPointF fPoint; + QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); + + QColor color = okColor; + if (set.size() < 3 || intersect == QLineF::NoIntersection) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelP1Line1, color); + ChangeColor(ui->labelP2Line1, color); + ChangeColor(ui->labelP1Line2, color); + ChangeColor(ui->labelP2Line2, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersect::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersect::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckState check state of dialog. Enable or disable button ok. + */ +void DialogLineIntersect::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagName && flagPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckIntersecion check intersection of points + * @return true - line have intersection, false = don't have + */ +bool DialogLineIntersect::CheckIntersecion() +{ + const QSharedPointer p1L1 = data->GeometricObject(p1Line1); + const QSharedPointer p2L1 = data->GeometricObject(p2Line1); + const QSharedPointer p1L2 = data->GeometricObject(p1Line2); + const QSharedPointer p2L2 = data->GeometricObject(p2Line2); + + QLineF line1(p1L1->toQPointF(), p2L1->toQPointF()); + QLineF line2(p1L2->toQPointF(), p2L2->toQPointF()); + QPointF fPoint; + QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + return true; + } + else + { + return false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP2Line2 set id second point of second line + * @param value id + */ +void DialogLineIntersect::setP2Line2(const quint32 &value) +{ + setPointId(ui->comboBoxP2Line2, p2Line2, value); + line->setLine2P2Id(p2Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP1Line2 set id first point of second line + * @param value id + */ +void DialogLineIntersect::setP1Line2(const quint32 &value) +{ + setPointId(ui->comboBoxP1Line2, p1Line2, value); + line->setLine2P1Id(p1Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP2Line1 set id second point of first line + * @param value id + */ +void DialogLineIntersect::setP2Line1(const quint32 &value) +{ + setPointId(ui->comboBoxP2Line1, p2Line1, value); + line->setLine1P2Id(p2Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP1Line1 set id first point of first line + * @param value id + */ +void DialogLineIntersect::setP1Line1(const quint32 &value) +{ + setPointId(ui->comboBoxP1Line1, p1Line1, value); + line->setPoint1Id(p1Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name of point + */ +void DialogLineIntersect::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialoglineintersect.h b/src/app/dialogs/tools/dialoglineintersect.h new file mode 100644 index 000000000..93f686f73 --- /dev/null +++ b/src/app/dialogs/tools/dialoglineintersect.h @@ -0,0 +1,159 @@ +/************************************************************************ + ** + ** @file dialoglineintersect.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGLINEINTERSECT_H +#define DIALOGLINEINTERSECT_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogLineIntersect; +} + +class VisToolLineIntersect; + +/** + * @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option. + */ +class DialogLineIntersect : public DialogTool +{ + Q_OBJECT +public: + DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogLineIntersect(); + + quint32 getP1Line1() const; + void setP1Line1(const quint32 &value); + + quint32 getP2Line1() const; + void setP2Line1(const quint32 &value); + + quint32 getP1Line2() const; + void setP1Line2(const quint32 &value); + + quint32 getP2Line2() const; + void setP2Line2(const quint32 &value); + + QString getPointName() const; + void setPointName(const QString &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + void P1Line1Changed( int index); + void P2Line1Changed( int index); + void P1Line2Changed( int index); + void P2Line2Changed( int index); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogLineIntersect) + + /** @brief ui keeps information about user interface */ + Ui::DialogLineIntersect *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief p1Line1 id first point of first line */ + quint32 p1Line1; + + /** @brief p2Line1 id second point of first line */ + quint32 p2Line1; + + /** @brief p1Line2 id first point of second line */ + quint32 p1Line2; + + /** @brief p2Line2 id second point of second line */ + quint32 p2Line2; + + /** @brief flagPoint keep state of point */ + bool flagPoint; + + VisToolLineIntersect *line; + + virtual void CheckState(); + bool CheckIntersecion(); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP1Line1 return id first point of first line + * @return id + */ +inline quint32 DialogLineIntersect::getP1Line1() const +{ + return p1Line1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP2Line1 return id second point of first line + * @return id + */ +inline quint32 DialogLineIntersect::getP2Line1() const +{ + return p2Line1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP1Line2 return id first point of second line + * @return id + */ +inline quint32 DialogLineIntersect::getP1Line2() const +{ + return p1Line2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP2Line2 return id second point of second line + * @return id + */ +inline quint32 DialogLineIntersect::getP2Line2() const +{ + return p2Line2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name of point + */ +inline QString DialogLineIntersect::getPointName() const +{ + return pointName; +} + +#endif // DIALOGLINEINTERSECT_H diff --git a/src/dialogs/dialoglineintersect.ui b/src/app/dialogs/tools/dialoglineintersect.ui similarity index 74% rename from src/dialogs/dialoglineintersect.ui rename to src/app/dialogs/tools/dialoglineintersect.ui index 25b5f8e95..53e5d3f89 100644 --- a/src/dialogs/dialoglineintersect.ui +++ b/src/app/dialogs/tools/dialoglineintersect.ui @@ -6,15 +6,15 @@ 0 0 - 384 + 367 196 - Point of line intersection + Intersection of lines - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -31,45 +31,8 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Name new point + Point label @@ -88,7 +51,7 @@ - + 0 @@ -104,7 +67,7 @@ - + Second point @@ -125,7 +88,7 @@ - + 0 @@ -141,7 +104,7 @@ - + Second point @@ -158,7 +121,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -173,7 +136,7 @@ buttonBox - + diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.cpp b/src/app/dialogs/tools/dialoglineintersectaxis.cpp new file mode 100644 index 000000000..7264e2a31 --- /dev/null +++ b/src/app/dialogs/tools/dialoglineintersectaxis.cpp @@ -0,0 +1,348 @@ +/************************************************************************ + ** + ** @file dialoglineintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 "dialoglineintersectaxis.h" +#include "ui_dialoglineintersectaxis.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoollineintersectaxis.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), number(0), typeLine(QString()), + formulaAngle(QString()), basePointId(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), + formulaBaseHeightAngle(0), line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeightAngle = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxAxisPoint); + FillComboBoxPoints(ui->comboBoxFirstLinePoint); + FillComboBoxPoints(ui->comboBoxSecondLinePoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + + connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle); + connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal); + connect(ui->toolButtonEqualAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::EvalAngle); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersectAxis::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogLineIntersectAxis::AngleTextChanged); + connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::DeployAngleTextEdit); + connect(timerFormula, &QTimer::timeout, this, &DialogLineIntersectAxis::EvalAngle); + connect(ui->comboBoxFirstLinePoint, + static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersectAxis::PointNameChanged); + connect(ui->comboBoxSecondLinePoint, + static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersectAxis::PointNameChanged); + connect(ui->comboBoxAxisPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersectAxis::PointNameChanged); + + line = new VisToolLineIntersectAxis(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogLineIntersectAxis::~DialogLineIntersectAxis() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogLineIntersectAxis::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogLineIntersectAxis::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogLineIntersectAxis::getAngle() const +{ + return qApp->FormulaFromUser(formulaAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setAngle(const QString &value) +{ + formulaAngle = qApp->FormulaToUser(value); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formulaAngle.length() > 80) + { + this->DeployAngleTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formulaAngle); + line->setAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogLineIntersectAxis::getBasePointId() const +{ + return basePointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setBasePointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxAxisPoint, basePointId, value); + line->setAxisPointId(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogLineIntersectAxis::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setFirstPointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxFirstLinePoint, firstPointId, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogLineIntersectAxis::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::setSecondPointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxSecondLinePoint, secondPointId, value); + line->setPoint2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::ShowDialog(bool click) +{ + if (prepare) + { + if (click) + { + /*We will ignore click if poinet is in point circle*/ + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + const QSharedPointer point = data->GeometricObject(basePointId); + QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); + + //Radius of point circle, but little bigger. Need handle with hover sizes. + qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5; + if (line.length() <= radius) + { + return; + } + } + this->setModal(true); + this->setAngle(line->Angle());//Show in dialog angle what user choose + emit ToolTip(""); + timerFormula->start(); + this->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case (0): + if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line"))) + { + number++; + line->VisualMode(id); + connect(line, &VisToolLineIntersectAxis::ToolTip, this, &DialogTool::ShowVisToolTip); + } + break; + case (1): + if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id) + { + if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point"))) + { + number++; + line->setPoint2Id(id); + line->RefreshGeometry(); + } + } + break; + case (2): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxAxisPoint, "")) + { + basePointId = id; + line->setAxisPointId(id); + line->RefreshGeometry(); + prepare = true; + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::PutAngle() +{ + PutValHere(ui->plainTextEditFormula, ui->listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::EvalAngle() +{ + Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::AngleTextChanged() +{ + ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::DeployAngleTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint)); + set.insert(getCurrentObjectId(ui->comboBoxAxisPoint)); + + QColor color = okColor; + if (set.size() != 3) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstLinePoint, color); + ChangeColor(ui->labelSecondLinePoint, color); + ChangeColor(ui->labelAxisPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::ShowVisualization() +{ + if (prepare == false) + { + //TODO move to parent class! + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLineIntersectAxis::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + + formulaAngle = ui->plainTextEditFormula->toPlainText(); + formulaAngle.replace("\n", " "); + + basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); + firstPointId = getCurrentObjectId(ui->comboBoxFirstLinePoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondLinePoint); + + line->setPoint1Id(firstPointId); + line->setPoint2Id(secondPointId); + line->setAxisPointId(basePointId); + line->setAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.h b/src/app/dialogs/tools/dialoglineintersectaxis.h new file mode 100644 index 000000000..73115d278 --- /dev/null +++ b/src/app/dialogs/tools/dialoglineintersectaxis.h @@ -0,0 +1,100 @@ +/************************************************************************ + ** + ** @file dialoglineintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 DIALOGLINEINTERSECTAXIS_H +#define DIALOGLINEINTERSECTAXIS_H + +#include "dialogtool.h" + +namespace Ui { +class DialogLineIntersectAxis; +} + +class VisToolLineIntersectAxis; + +class DialogLineIntersectAxis : public DialogTool +{ + Q_OBJECT + +public: + DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogLineIntersectAxis(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getAngle() const; + void setAngle(const QString &value); + + quint32 getBasePointId() const; + void setBasePointId(const quint32 &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowDialog(bool click); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + void PutAngle(); + void EvalAngle(); + void AngleTextChanged(); + void DeployAngleTextEdit(); + virtual void PointNameChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogLineIntersectAxis) + Ui::DialogLineIntersectAxis *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + QString formulaAngle; + quint32 basePointId; + quint32 firstPointId; + quint32 secondPointId; + int formulaBaseHeightAngle; + + VisToolLineIntersectAxis *line; +}; + +#endif // DIALOGLINEINTERSECTAXIS_H diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.ui b/src/app/dialogs/tools/dialoglineintersectaxis.ui new file mode 100644 index 000000000..31909167f --- /dev/null +++ b/src/app/dialogs/tools/dialoglineintersectaxis.ui @@ -0,0 +1,538 @@ + + + DialogLineIntersectAxis + + + + 0 + 0 + 457 + 532 + + + + Line intersect axis + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Angle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of angle + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + 4 + 0 + + + + true + + + QPlainTextEdit::NoWrap + + + + + + + + 16 + 16 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Axis point + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + First line point + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + Second line point + + + + + + + First point of line + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + 0 + 0 + + + + + + + + Type of line + + + + + + + Show line from first point to this point + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables + + + + + + + + + + + + 0 + 0 + + + + Qt::PlainText + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHereAngle + toolButtonEqualAngle + pushButtonGrowLengthAngle + comboBoxAxisPoint + comboBoxFirstLinePoint + comboBoxSecondLinePoint + lineEditNamePoint + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogLineIntersectAxis + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogLineIntersectAxis + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp new file mode 100644 index 000000000..2901361aa --- /dev/null +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -0,0 +1,270 @@ +/************************************************************************ + ** + ** @file dialognormal.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialognormal.h" +#include "ui_dialognormal.h" +#include "../visualization/vistoolnormal.h" +#include "../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogNormal create dialog + * @param data container with data + * @param parent parent widget + */ +DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), typeLine(QString()), + formula(QString()), angle(0), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + + InitArrow(ui); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogNormal::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogNormal::PutVal); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogNormal::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogNormal::PointNameChanged); + + line = new VisToolNormal(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::PointNameChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogNormal::~DialogNormal() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + { + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + angle = ui->doubleSpinBoxAngle->value(); + firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); + + line->setPoint1Id(firstPointId); + line->setPoint2Id(secondPointId); + line->setLength(formula); + line->setAngle(angle); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPointId set id of second point + * @param value id + */ +void DialogNormal::setSecondPointId(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPointId, value); + line->setPoint2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPointId set id of first point + * @param value id + */ +void DialogNormal::setFirstPointId(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPointId, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAngle set aditional angle of normal + * @param value angle in degree + */ +void DialogNormal::setAngle(const qreal &value) +{ + angle = value; + ui->doubleSpinBoxAngle->setValue(angle); + line->setAngle(angle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogNormal::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogNormal::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogNormal::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h new file mode 100644 index 000000000..0b346d473 --- /dev/null +++ b/src/app/dialogs/tools/dialognormal.h @@ -0,0 +1,176 @@ +/************************************************************************ + ** + ** @file dialognormal.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGNORMAL_H +#define DIALOGNORMAL_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogNormal; +} + +class VisToolNormal; + +/** + * @brief The DialogNormal class dialog for ToolNormal. Help create point and edit option. + */ +class DialogNormal : public DialogTool +{ + Q_OBJECT +public: + DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogNormal(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + qreal getAngle() const; + void setAngle(const qreal &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + virtual void PointNameChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogNormal) + + /** @brief ui keeps information about user interface */ + Ui::DialogNormal *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief formula formula */ + QString formula; + + /** @brief angle aditional angle of normal */ + qreal angle; + + /** @brief firstPointId id first point of line */ + quint32 firstPointId; + + /** @brief secondPointId id second point of line */ + quint32 secondPointId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + VisToolNormal *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogNormal::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogNormal::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogNormal::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAngle return aditional angle of normal + * @return angle in degree + */ +inline qreal DialogNormal::getAngle() const +{ + return angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPointId return id of first point + * @return id + */ +inline quint32 DialogNormal::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPointId return id of second point + * @return id + */ +inline quint32 DialogNormal::getSecondPointId() const +{ + return secondPointId; +} + +#endif // DIALOGNORMAL_H diff --git a/src/dialogs/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui similarity index 66% rename from src/dialogs/dialognormal.ui rename to src/app/dialogs/tools/dialognormal.ui index 2283dbe55..492531abe 100644 --- a/src/dialogs/dialognormal.ui +++ b/src/app/dialogs/tools/dialognormal.ui @@ -6,21 +6,21 @@ 0 0 - 488 - 594 + 517 + 645 Normal - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - + @@ -74,28 +74,48 @@ - - - - 0 - 0 - + + + Qt::Horizontal + + + 40 + 20 + + + + + + - Formula calculation of length of normal + Insert variable into formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + - Calculate formula + Calculate value - ... + ... - + :/icon/24x24/equal.png:/icon/24x24/equal.png @@ -124,7 +144,66 @@ Value of length - _ + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true @@ -135,8 +214,8 @@ - - + + @@ -144,77 +223,16 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Name new point + Point label - + - - - - Put variable into formula - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - + + 0 @@ -226,15 +244,11 @@ - + - - - - - - + + 0 @@ -246,7 +260,7 @@ - + @@ -291,11 +305,11 @@ - ... + ... - - :/icon/24x24/arrowRightUp.png:/icon/24x24/arrowRightUp.png + + :/icon/32x32/arrowRightUp.png:/icon/32x32/arrowRightUp.png @@ -308,11 +322,11 @@ - ... + ... - - :/icon/24x24/arrowLeftUp.png:/icon/24x24/arrowLeftUp.png + + :/icon/32x32/arrowLeftUp.png:/icon/32x32/arrowLeftUp.png @@ -325,11 +339,11 @@ - ... + ... - - :/icon/24x24/arrowLeft.png:/icon/24x24/arrowLeft.png + + :/icon/32x32/arrowLeft.png:/icon/32x32/arrowLeft.png @@ -342,11 +356,11 @@ - ... + ... - - :/icon/24x24/arrowRight.png:/icon/24x24/arrowRight.png + + :/icon/32x32/arrowRight.png:/icon/32x32/arrowRight.png @@ -365,11 +379,11 @@ - ... + ... - - :/icon/24x24/arrowUp.png:/icon/24x24/arrowUp.png + + :/icon/32x32/arrowUp.png:/icon/32x32/arrowUp.png @@ -382,11 +396,11 @@ - ... + ... - - :/icon/24x24/arrowDown.png:/icon/24x24/arrowDown.png + + :/icon/32x32/arrowDown.png:/icon/32x32/arrowDown.png @@ -399,11 +413,11 @@ - ... + ... - - :/icon/24x24/arrowLeftDown.png:/icon/24x24/arrowLeftDown.png + + :/icon/32x32/arrowLeftDown.png:/icon/32x32/arrowLeftDown.png @@ -416,11 +430,11 @@ - ... + ... - - :/icon/24x24/arrowRightDown.png:/icon/24x24/arrowRightDown.png + + :/icon/32x32/arrowRightDown.png:/icon/32x32/arrowRightDown.png @@ -444,6 +458,9 @@ 0 + + -360.000000000000000 + 360.000000000000000 @@ -460,14 +477,14 @@ - Type line + Type of line - Show line from first point to our point + Show line from first point to this point @@ -484,8 +501,14 @@ + + + 0 + 0 + + - Size and growth + Size and height true @@ -493,14 +516,26 @@ - + + + + 0 + 0 + + - Standart table + Measurements + + + 0 + 0 + + Increments @@ -511,6 +546,12 @@ true + + + 0 + 0 + + Length of lines @@ -521,6 +562,12 @@ true + + + 0 + 0 + + Length of arcs @@ -531,21 +578,57 @@ true + + + 0 + 0 + + Length of curves + + + + true + + + + 0 + 0 + + + + Angle of lines + + + - - - Variables. Click twice to select. - - + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + @@ -554,6 +637,9 @@ + + true + @@ -562,40 +648,43 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - lineEditFormula + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength lineEditNamePoint comboBoxFirstPoint comboBoxSecondPoint doubleSpinBoxAngle - toolButtonArrowRight - toolButtonArrowRightUp toolButtonArrowUp - toolButtonArrowLeftUp - toolButtonArrowLeft - toolButtonArrowLeftDown - toolButtonArrowDown + toolButtonArrowRightUp + toolButtonArrowRight toolButtonArrowRightDown + toolButtonArrowDown + toolButtonArrowLeftDown + toolButtonArrowLeft + toolButtonArrowLeftUp comboBoxLineType radioButtonSizeGrowth - radioButtonStandartTable + radioButtonStandardTable radioButtonIncrements radioButtonLengthLine radioButtonLengthArc radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty listWidget - toolButtonPutHere - toolButtonEqual buttonBox - + diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp new file mode 100644 index 000000000..27e6e3ae3 --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -0,0 +1,298 @@ +/************************************************************************ + ** + ** @file dialogpointofcontact.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogpointofcontact.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolpointofcontact.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogPointOfContact create dialog + * @param data container with data + * @param parent parent widget + */ +DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), + radius(QString()), center(NULL_ID), firstPoint(NULL_ID), secondPoint(NULL_ID), formulaBaseHeight(0), line(nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxPoints(ui->comboBoxCenter); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); + connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); + + if (qApp->patternType() == MeasurementsType::Standard) + { + SizeHeight(); + connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); + } + else + { + radioButtonSizeGrowth->setVisible(false); + Measurements(); + } + connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::Measurements); + connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); + connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); + connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogPointOfContact::LengthArcs); + connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogPointOfContact::LengthCurves); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfContact::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfContact::PointNameChanged); + connect(ui->comboBoxCenter, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfContact::PointNameChanged); + + line = new VisToolPointOfContact(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfContact::~DialogPointOfContact() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(getCurrentObjectId(ui->comboBoxCenter)); + + QColor color = okColor; + if (set.size() != 3) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + ChangeColor(ui->labelArcCenter, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + { + if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) + { + number++; + line->setLineP2Id(id); + line->RefreshGeometry(); + } + } + break; + case 2: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxCenter, "")) + { + line->setRadiusId(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + radius = ui->plainTextEditFormula->toPlainText(); + radius.replace("\n", " "); + center = getCurrentObjectId(ui->comboBoxCenter); + firstPoint = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPoint = getCurrentObjectId(ui->comboBoxSecondPoint); + + line->setPoint1Id(firstPoint); + line->setLineP2Id(secondPoint); + line->setRadiusId(center); + line->setRadius(radius); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfContact::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPoint set id second point + * @param value id + */ +void DialogPointOfContact::setSecondPoint(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPoint, value); + line->setLineP2Id(secondPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPoint set id first point + * @param value id + */ +void DialogPointOfContact::setFirstPoint(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPoint, value); + line->setPoint1Id(firstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetCenter set id of center point + * @param value id + */ +void DialogPointOfContact::setCenter(const quint32 &value) +{ + setPointId(ui->comboBoxCenter, center, value); + line->setRadiusId(center); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setRadius set formula radius of arc + * @param value formula + */ +void DialogPointOfContact::setRadius(const QString &value) +{ + radius = value; + // increase height if needed. + if (radius.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(radius); + line->setRadius(radius); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogPointOfContact::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialogpointofcontact.h b/src/app/dialogs/tools/dialogpointofcontact.h new file mode 100644 index 000000000..2b7126f3e --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofcontact.h @@ -0,0 +1,161 @@ +/************************************************************************ + ** + ** @file dialogpointofcontact.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGPOINTOFCONTACT_H +#define DIALOGPOINTOFCONTACT_H + +#include "ui_dialogpointofcontact.h" +#include "dialogtool.h" + +namespace Ui +{ + class DialogPointOfContact; +} + +class VisToolPointOfContact; + +/** + * @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option. + */ +class DialogPointOfContact : public DialogTool +{ + Q_OBJECT +public: + DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + virtual ~DialogPointOfContact(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getRadius() const; + void setRadius(const QString &value); + + quint32 getCenter() const; + void setCenter(const quint32 &value); + + quint32 getFirstPoint() const; + void setFirstPoint(const quint32 &value); + + quint32 getSecondPoint() const; + void setSecondPoint(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + virtual void PointNameChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogPointOfContact) + + /** @brief ui keeps information about user interface */ + Ui::DialogPointOfContact *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief radius radius of arc */ + QString radius; + + /** @brief center id center point of arc */ + quint32 center; + + /** @brief firstPoint id first point of line */ + quint32 firstPoint; + + /** @brief secondPoint id second point of line */ + quint32 secondPoint; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + + VisToolPointOfContact *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogPointOfContact::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getRadius return formula radius of arc + * @return formula + */ +inline QString DialogPointOfContact::getRadius() const +{ + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetCenter return id of center point + * @return id + */ +inline quint32 DialogPointOfContact::getCenter() const +{ + return center; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPoint return id first point + * @return id + */ +inline quint32 DialogPointOfContact::getFirstPoint() const +{ + return firstPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPoint return id second point + * @return id + */ +inline quint32 DialogPointOfContact::getSecondPoint() const +{ + return secondPoint; +} + +#endif // DIALOGPOINTOFCONTACT_H diff --git a/src/app/dialogs/tools/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogpointofcontact.ui new file mode 100644 index 000000000..e74fd80ca --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofcontact.ui @@ -0,0 +1,547 @@ + + + DialogPointOfContact + + + + 0 + 0 + 498 + 499 + + + + Point of contact + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Radius + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Insert variable into formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of radius + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + 0 + 0 + + + + Center of arc + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + Select point of center of arc + + + + + + + + 0 + 0 + + + + Top of the line + + + + + + + + 0 + 0 + + + + + 143 + 0 + + + + + + + + + 0 + 0 + + + + End of the line + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula. + + + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + lineEditNamePoint + comboBoxCenter + comboBoxFirstPoint + comboBoxSecondPoint + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogPointOfContact + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointOfContact + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp new file mode 100644 index 000000000..4474e067e --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -0,0 +1,201 @@ +/************************************************************************ + ** + ** @file dialogpointofintersection.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogpointofintersection.h" +#include "ui_dialogpointofintersection.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolpointofintersection.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogPointOfIntersection create dialog + * @param data container with data + * @param parent parent widget + */ +DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), + firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr) +{ + ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + InitOkCancelApply(ui); + CheckState(); + + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersection::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersection::PointNameChanged); + + line = new VisToolPointOfIntersection(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfIntersection::~DialogPointOfIntersection() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPointId set id of second point + * @param value id + */ +void DialogPointOfIntersection::setSecondPointId(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPointId, value); + line->setPoint2Id(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point horizontally"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + { + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersection::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); + + line->setPoint1Id(firstPointId); + line->setPoint2Id(secondPointId); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersection::PointNameChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersection::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersection::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPointId set id of first point + * @param value id + */ +void DialogPointOfIntersection::setFirstPointId(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPointId, value); + line->setPoint1Id(firstPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogPointOfIntersection::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialogpointofintersection.h b/src/app/dialogs/tools/dialogpointofintersection.h new file mode 100644 index 000000000..00fb7648b --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofintersection.h @@ -0,0 +1,116 @@ +/************************************************************************ + ** + ** @file dialogpointofintersection.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGPOINTOFINTERSECTION_H +#define DIALOGPOINTOFINTERSECTION_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogPointOfIntersection; +} + +class VisToolPointOfIntersection; + +/** + * @brief The DialogPointOfIntersection class dialog for ToolPointOfIntersection. Help create point and edit option. + */ +class DialogPointOfIntersection : public DialogTool +{ + Q_OBJECT +public: + DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogPointOfIntersection(); + + QString getPointName() const; + void setPointName(const QString &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogPointOfIntersection) + + /** @brief ui keeps information about user interface */ + Ui::DialogPointOfIntersection *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief firstPointId id first point of line */ + quint32 firstPointId; + + /** @brief secondPointId id second point of line */ + quint32 secondPointId; + VisToolPointOfIntersection *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogPointOfIntersection::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPointId return id of first point + * @return id + */ +inline quint32 DialogPointOfIntersection::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPointId return id of second point + * @return id + */ +inline quint32 DialogPointOfIntersection::getSecondPointId() const +{ + return secondPointId; +} + +#endif // DIALOGPOINTOFINTERSECTION_H diff --git a/src/dialogs/dialogpointofintersection.ui b/src/app/dialogs/tools/dialogpointofintersection.ui similarity index 56% rename from src/dialogs/dialogpointofintersection.ui rename to src/app/dialogs/tools/dialogpointofintersection.ui index 303aa8cc0..d79a9035a 100644 --- a/src/dialogs/dialogpointofintersection.ui +++ b/src/app/dialogs/tools/dialogpointofintersection.ui @@ -6,111 +6,83 @@ 0 0 - 293 - 180 + 285 + 146 - Dialog + Point of intersection + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - + + - + 0 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Name new point + Point label - - - - - - - - - + + - + 0 0 + + + + + + + 0 + 0 + + + + + 0 + 0 + + - Point vertically + vertical point - + First point of angle - - - - - - + + - + 0 0 - Point horizontally + horizontal point - + Second point of angle @@ -125,13 +97,21 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + + lineEditNamePoint + comboBoxFirstPoint + comboBoxSecondPoint + buttonBox + + + + buttonBox diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp new file mode 100644 index 000000000..d2c5d4521 --- /dev/null +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -0,0 +1,298 @@ +/************************************************************************ + ** + ** @file dialogshoulderpoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogshoulderpoint.h" +#include "ui_dialogshoulderpoint.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolshoulderpoint.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../tools/vabstracttool.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogShoulderPoint create dialog + * @param data container with data + * @param parent parent widget + */ +DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), + typeLine(QString()), formula(QString()), p1Line(NULL_ID), p2Line(NULL_ID), pShoulder(NULL_ID), formulaBaseHeight(0), + line (nullptr) +{ + ui->setupUi(this); + InitVariables(ui); + InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + ui->plainTextEditFormula->installEventFilter(this); + + InitOkCancelApply(ui); + flagFormula = false; + CheckState(); + + FillComboBoxTypeLine(ui->comboBoxLineType); + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); + FillComboBoxPoints(ui->comboBoxP3); + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogShoulderPoint::EvalFormula); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogShoulderPoint::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit); + connect(ui->comboBoxP1Line, static_cast(&QComboBox::currentIndexChanged), + this, &DialogShoulderPoint::PointNameChanged); + connect(ui->comboBoxP2Line, static_cast(&QComboBox::currentIndexChanged), + this, &DialogShoulderPoint::PointNameChanged); + connect(ui->comboBoxP3, static_cast(&QComboBox::currentIndexChanged), + this, &DialogShoulderPoint::PointNameChanged); + + line = new VisToolShoulderPoint(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP1Line)); + set.insert(getCurrentObjectId(ui->comboBoxP2Line)); + set.insert(getCurrentObjectId(ui->comboBoxP3)); + + QColor color = okColor; + if (set.size() != 3) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + ChangeColor(ui->labelThirdPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogShoulderPoint::~DialogShoulderPoint() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false) + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxP3, tr("Select first point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxP3) != id) + { + if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + { + number++; + line->setLineP1Id(id); + line->RefreshGeometry(); + } + } + break; + case 2: + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP3)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxP2Line, "")) + { + line->setLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); + p1Line = getCurrentObjectId(ui->comboBoxP1Line); + p2Line = getCurrentObjectId(ui->comboBoxP2Line); + pShoulder = getCurrentObjectId(ui->comboBoxP3); + + line->setPoint1Id(pShoulder); + line->setLineP1Id(p1Line); + line->setLineP2Id(p2Line); + line->setLength(formula); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormula->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPShoulder set id shoulder point + * @param value id + */ +void DialogShoulderPoint::setP3(const quint32 &value) +{ + setPointId(ui->comboBoxP3, pShoulder, value); + line->setPoint1Id(pShoulder); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP2Line set id second point of line + * @param value id + */ +void DialogShoulderPoint::setP2Line(const quint32 &value) +{ + setPointId(ui->comboBoxP2Line, p2Line, value); + line->setLineP2Id(p2Line); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP1Line set id first point of line + * @param value id + */ +void DialogShoulderPoint::setP1Line(const quint32 &value) +{ + setPointId(ui->comboBoxP1Line, p1Line, value); + line->setLineP1Id(p1Line); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string of formula + * @param value formula + */ +void DialogShoulderPoint::setFormula(const QString &value) +{ + formula = qApp->FormulaToUser(value); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); + line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeLine set type of line + * @param value type + */ +void DialogShoulderPoint::setTypeLine(const QString &value) +{ + typeLine = value; + SetupTypeLine(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyle(typeLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogShoulderPoint::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h new file mode 100644 index 000000000..47c1d489c --- /dev/null +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -0,0 +1,175 @@ +/************************************************************************ + ** + ** @file dialogshoulderpoint.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGSHOULDERPOINT_H +#define DIALOGSHOULDERPOINT_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogShoulderPoint; +} + +class VisToolShoulderPoint; + +/** + * @brief The DialogShoulderPoint class dialog for ToolShoulderPoint. Help create point and edit option. + */ +class DialogShoulderPoint : public DialogTool +{ + Q_OBJECT +public: + DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogShoulderPoint(); + + QString getPointName() const; + void setPointName(const QString &value); + + QString getTypeLine() const; + void setTypeLine(const QString &value); + + QString getFormula() const; + void setFormula(const QString &value); + + quint32 getP1Line() const; + void setP1Line(const quint32 &value); + + quint32 getP2Line() const; + void setP2Line(const quint32 &value); + + quint32 getP3() const; + void setP3(const quint32 &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); + virtual void PointNameChanged(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + virtual void closeEvent(QCloseEvent *event); +private: + Q_DISABLE_COPY(DialogShoulderPoint) + + /** @brief ui keeps information about user interface */ + Ui::DialogShoulderPoint *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief typeLine type of line */ + QString typeLine; + + /** @brief formula formula */ + QString formula; + + /** @brief p1Line id first point of line */ + quint32 p1Line; + + /** @brief p2Line id second point of line */ + quint32 p2Line; + + /** @brief pShoulder id shoulder point */ + quint32 pShoulder; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; + VisToolShoulderPoint *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogShoulderPoint::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @return type + */ +inline QString DialogShoulderPoint::getTypeLine() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string of formula + * @return formula + */ +inline QString DialogShoulderPoint::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP1Line return id first point of line + * @return id + */ +inline quint32 DialogShoulderPoint::getP1Line() const +{ + return p1Line; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP2Line return id second point of line + * @return id + */ +inline quint32 DialogShoulderPoint::getP2Line() const +{ + return p2Line; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPShoulder return id shoulder point + * @return id + */ +inline quint32 DialogShoulderPoint::getP3() const +{ + return pShoulder; +} + +#endif // DIALOGSHOULDERPOINT_H diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui new file mode 100644 index 000000000..996d5cbee --- /dev/null +++ b/src/app/dialogs/tools/dialogshoulderpoint.ui @@ -0,0 +1,571 @@ + + + DialogShoulderPoint + + + + 0 + 0 + 488 + 532 + + + + Point of shoulder + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Length + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Insert variable into formula + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of length + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + 0 + 0 + + + + First point + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + + + + + + 0 + 0 + + + + Second point + + + + + + + + 0 + 0 + + + + + 143 + 0 + + + + + + + + + 0 + 0 + + + + Third point + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + + + + + + 0 + 0 + + + + Type of line + + + + + + + + 0 + 0 + + + + Show line from first point to our point + + + + + + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Measurements + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + + + Hide empty measurements + + + true + + + + + + + Variables - Click twice to insert into formula + + + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + plainTextEditFormula + toolButtonPutHere + toolButtonEqual + pushButtonGrowLength + lineEditNamePoint + comboBoxP1Line + comboBoxP2Line + comboBoxP3 + comboBoxLineType + radioButtonSizeGrowth + radioButtonStandardTable + radioButtonIncrements + radioButtonLengthLine + radioButtonLengthArc + radioButtonLengthSpline + radioButtonAngleLine + checkBoxHideEmpty + listWidget + buttonBox + + + + + + + buttonBox + accepted() + DialogShoulderPoint + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogShoulderPoint + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/dialogs/tools/dialogsinglepoint.cpp b/src/app/dialogs/tools/dialogsinglepoint.cpp new file mode 100644 index 000000000..3c95d069c --- /dev/null +++ b/src/app/dialogs/tools/dialogsinglepoint.cpp @@ -0,0 +1,109 @@ +/************************************************************************ + ** + ** @file dialogsinglepoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogsinglepoint.h" +#include "ui_dialogsinglepoint.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogSinglePoint create dialog + * @param data container with data + * @param parent parent widget + */ +DialogSinglePoint::DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogSinglePoint), point(QPointF()) +{ + ui->setupUi(this); + ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize)); + ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize)); + labelEditNamePoint = ui->labelEditName; + InitOkCancel(ui); + + flagName = true; + CheckState(); + + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogTool::NamePointChanged); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePress get mouse position + * @param scenePos position of cursor + */ +void DialogSinglePoint::mousePress(const QPointF &scenePos) +{ + if (isInitialized == false) + { + ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y())); + this->show(); + } + else + { + ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y())); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSinglePoint::SaveData() +{ + point = QPointF(qApp->toPixel(ui->doubleSpinBoxX->value()), qApp->toPixel(ui->doubleSpinBoxY->value())); + pointName = ui->lineEditName->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSinglePoint::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setData set name and point + * @param name name of point + * @param point data for point + */ +void DialogSinglePoint::setData(const QString &name, const QPointF &point) +{ + pointName = name; + this->point = point; + isInitialized = true; + ui->lineEditName->setText(name); + ui->doubleSpinBoxX->setValue(qApp->fromPixel(point.x())); + ui->doubleSpinBoxY->setValue(qApp->fromPixel(point.y())); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogSinglePoint::~DialogSinglePoint() +{ + delete ui; +} diff --git a/src/dialogs/dialogsinglepoint.h b/src/app/dialogs/tools/dialogsinglepoint.h similarity index 60% rename from src/dialogs/dialogsinglepoint.h rename to src/app/dialogs/tools/dialogsinglepoint.h index ac667adc5..86e489ab9 100644 --- a/src/dialogs/dialogsinglepoint.h +++ b/src/app/dialogs/tools/dialogsinglepoint.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file dialogsinglepoint.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -43,53 +43,47 @@ class DialogSinglePoint : public DialogTool { Q_OBJECT public: - /** - * @brief DialogSinglePoint create dialog - * @param data container with data - * @param parent parent widget - */ - DialogSinglePoint(const VContainer *data, QWidget *parent = 0); - /** - * @brief setData set name and point - * @param name name of point - * @param point data for point - */ + DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogSinglePoint(); void setData(const QString &name, const QPointF &point); - /** - * @brief getName return name - * @return name - */ - inline QString getName()const {return name;} - /** - * @brief getPoint return point - * @return point - */ - inline QPointF getPoint()const {return point;} - ~DialogSinglePoint(); + QString getName()const; + QPointF getPoint()const; public slots: - /** - * @brief mousePress get mouse position - * @param scenePos position of cursor - */ void mousePress(const QPointF &scenePos); + virtual void UpdateList(); +protected: /** - * @brief DialogAccepted save data and emit signal about closed dialog. + * @brief SaveData Put dialog data in local variables */ - virtual void DialogAccepted(); + virtual void SaveData(); private: Q_DISABLE_COPY(DialogSinglePoint) - /** - * @brief ui keeps information about user interface - */ + + /** @brief ui keeps information about user interface */ Ui::DialogSinglePoint *ui; - /** - * @brief name name of point - */ - QString name; - /** - * @brief point data of point - */ + + /** @brief point data of point */ QPointF point; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getName return name + * @return name + */ +inline QString DialogSinglePoint::getName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPoint return point + * @return point + */ +inline QPointF DialogSinglePoint::getPoint() const +{ + return point; +} + #endif // DIALOGSINGLEPOINT_H diff --git a/src/dialogs/dialogsinglepoint.ui b/src/app/dialogs/tools/dialogsinglepoint.ui similarity index 77% rename from src/dialogs/dialogsinglepoint.ui rename to src/app/dialogs/tools/dialogsinglepoint.ui index eb2d385d1..aa0bcbc91 100644 --- a/src/dialogs/dialogsinglepoint.ui +++ b/src/app/dialogs/tools/dialogsinglepoint.ui @@ -3,7 +3,7 @@ DialogSinglePoint - Qt::WindowModal + Qt::ApplicationModal @@ -17,14 +17,14 @@ Single point - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - false + true @@ -73,45 +73,8 @@ 17 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Point name + Point label @@ -151,7 +114,7 @@ buttonBox - + diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp new file mode 100644 index 000000000..d60ae5b9c --- /dev/null +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -0,0 +1,294 @@ +/************************************************************************ + ** + ** @file dialogspline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogspline.h" +#include "ui_dialogspline.h" + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolspline.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogSpline create dialog + * @param data container with data + * @param parent parent widget + */ +DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), number(0), p1(NULL_ID), p4(NULL_ID), angle1(0), + angle2(0), kAsm1(1), kAsm2(1), kCurve(1), path(nullptr) +{ + ui->setupUi(this); + InitOkCancelApply(ui); + + FillComboBoxPoints(ui->comboBoxP1); + FillComboBoxPoints(ui->comboBoxP4); + connect(ui->comboBoxP1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogSpline::PointNameChanged); + connect(ui->comboBoxP4, static_cast(&QComboBox::currentIndexChanged), + this, &DialogSpline::PointNameChanged); + + path = new VisToolSpline(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogSpline::~DialogSpline() +{ + if (qApp->getCurrentScene()->items().contains(path)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete path; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP1 return id first point of spline + * @return id + */ +quint32 DialogSpline::getP1() const +{ + return p1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve"))) + { + number++; + path->VisualMode(id); + } + break; + case 1: + { + if (getCurrentObjectId(ui->comboBoxP1) != id) + { + const QSharedPointer point = data->GeometricObject(id); + qint32 index = ui->comboBoxP4->findText(point->name()); + if ( index != -1 ) + { // -1 for not found + ui->comboBoxP4->setCurrentIndex(index); + emit ToolTip(""); + index = ui->comboBoxP1->currentIndex(); + quint32 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); + + QPointF p1 = data->GeometricObject(p1Id)->toQPointF(); + QPointF p4 = data->GeometricObject(id)->toQPointF(); + + ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle())); + ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle())); + + path->setPoint4Id(id); + path->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + else + { + qWarning()<<"Can't find object by name"<name(); + } + } + break; + } + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::SaveData() +{ + p1 = getCurrentObjectId(ui->comboBoxP1); + p4 = getCurrentObjectId(ui->comboBoxP4); + angle1 = ui->spinBoxAngle1->value(); + angle2 = ui->spinBoxAngle2->value(); + kAsm1 = ui->doubleSpinBoxKasm1->value(); + kAsm2 = ui->doubleSpinBoxKasm2->value(); + kCurve = ui->doubleSpinBoxKcurve->value(); + + path->setPoint1Id(p1); + path->setPoint4Id(p4); + path->setAngle1(angle1); + path->setAngle2(angle2); + path->setKAsm1(kAsm1); + path->setKAsm2(kAsm2); + path->setKCurve(kCurve); + path->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP1)); + set.insert(getCurrentObjectId(ui->comboBoxP4)); + + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); + scene->addItem(path); + path->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setKCurve set coefficient curve + * @param value value. Can be >= 0. + */ +void DialogSpline::setKCurve(const qreal &value) +{ + kCurve = value; + ui->doubleSpinBoxKcurve->setValue(value); + path->setKCurve(kCurve); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setKAsm2 set second coefficient asymmetry + * @param value value. Can be >= 0. + */ +void DialogSpline::setKAsm2(const qreal &value) +{ + kAsm2 = value; + ui->doubleSpinBoxKasm2->setValue(value); + path->setKAsm2(kAsm2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setKAsm1 set first coefficient asymmetry + * @param value value. Can be >= 0. + */ +void DialogSpline::setKAsm1(const qreal &value) +{ + kAsm1 = value; + ui->doubleSpinBoxKasm1->setValue(value); + path->setKAsm1(kAsm1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAngle2 set second angle of spline + * @param value angle in degree + */ +void DialogSpline::setAngle2(const qreal &value) +{ + angle2 = value; + ui->spinBoxAngle2->setValue(static_cast(value)); + path->setAngle2(angle2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAngle1 set first angle of spline + * @param value angle in degree + */ +void DialogSpline::setAngle1(const qreal &value) +{ + angle1 = value; + ui->spinBoxAngle1->setValue(static_cast(value)); + path->setAngle1(angle1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP4 set id fourth point of spline + * @param value id + */ +void DialogSpline::setP4(const quint32 &value) +{ + setPointId(ui->comboBoxP4, p4, value); + path->setPoint4Id(p4); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setP1 set id first point of spline + * @param value id + */ +void DialogSpline::setP1(const quint32 &value) +{ + setPointId(ui->comboBoxP1, p1, value); + path->setPoint1Id(p1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getP4 return id fourth point of spline + * @return id + */ +quint32 DialogSpline::getP4() const +{ + return p4; +} diff --git a/src/app/dialogs/tools/dialogspline.h b/src/app/dialogs/tools/dialogspline.h new file mode 100644 index 000000000..20d97f396 --- /dev/null +++ b/src/app/dialogs/tools/dialogspline.h @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file dialogspline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGSPLINE_H +#define DIALOGSPLINE_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogSpline; +} + +class VisToolSpline; + +/** + * @brief The DialogSpline class dialog for ToolSpline. Help create spline and edit option. + */ +class DialogSpline : public DialogTool +{ + Q_OBJECT +public: + DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogSpline(); + + quint32 getP1() const; + void setP1(const quint32 &value); + + quint32 getP4() const; + void setP4(const quint32 &value); + + qreal getAngle1() const; + void setAngle1(const qreal &value); + + qreal getAngle2() const; + void setAngle2(const qreal &value); + + qreal getKAsm1() const; + void setKAsm1(const qreal &value); + + qreal getKAsm2() const; + void setKAsm2(const qreal &value); + + qreal getKCurve() const; + void setKCurve(const qreal &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogSpline) + + /** @brief ui keeps information about user interface */ + Ui::DialogSpline *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief p1 id first point of spline */ + quint32 p1; + + /** @brief p4 id fourth point of spline */ + quint32 p4; + + /** @brief angle1 first angle of spline in degree */ + qreal angle1; + + /** @brief angle2 second angle of spline in degree */ + qreal angle2; + + /** @brief kAsm1 first coefficient asymmetry */ + qreal kAsm1; + + /** @brief kAsm2 second coefficient asymmetry */ + qreal kAsm2; + + /** @brief kCurve coefficient curve */ + qreal kCurve; + + VisToolSpline *path; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAngle1 return first angle of spline + * @return angle in degree + */ +inline qreal DialogSpline::getAngle1() const +{ + return angle1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAngle2 return second angle of spline + * @return angle in degree + */ +inline qreal DialogSpline::getAngle2() const +{ + return angle2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getKAsm1 return first coefficient asymmetry + * @return value. Can be >= 0. + */ +inline qreal DialogSpline::getKAsm1() const +{ + return kAsm1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getKAsm2 return second coefficient asymmetry + * @return value. Can be >= 0. + */ +inline qreal DialogSpline::getKAsm2() const +{ + return kAsm2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getKCurve return coefficient curve + * @return value. Can be >= 0. + */ +inline qreal DialogSpline::getKCurve() const +{ + return kCurve; +} + +#endif // DIALOGSPLINE_H diff --git a/src/dialogs/dialogspline.ui b/src/app/dialogs/tools/dialogspline.ui similarity index 91% rename from src/dialogs/dialogspline.ui rename to src/app/dialogs/tools/dialogspline.ui index b347954e9..580268256 100644 --- a/src/dialogs/dialogspline.ui +++ b/src/app/dialogs/tools/dialogspline.ui @@ -14,7 +14,7 @@ Curve - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -28,7 +28,7 @@ - + First point @@ -53,6 +53,9 @@ + + 0.010000000000000 + 1.000000000000000 @@ -88,7 +91,7 @@ - + Second point @@ -113,6 +116,9 @@ + + 0.010000000000000 + 1.000000000000000 @@ -180,6 +186,9 @@ 0 + + 0.010000000000000 + 1.000000000000000 @@ -193,7 +202,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -201,16 +210,16 @@ comboBoxP1 - comboBoxP4 doubleSpinBoxKasm1 - doubleSpinBoxKasm2 spinBoxAngle1 + comboBoxP4 + doubleSpinBoxKasm2 spinBoxAngle2 doubleSpinBoxKcurve buttonBox - + diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp new file mode 100644 index 000000000..39daac404 --- /dev/null +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -0,0 +1,361 @@ +/************************************************************************ + ** + ** @file dialogsplinepath.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogsplinepath.h" +#include "ui_dialogsplinepath.h" +#include "../../geometry/vsplinepoint.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolsplinepath.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogSplinePath create dialog + * @param data container with data + * @param parent parent widget + */ +DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()), visPath(nullptr) +{ + ui->setupUi(this); + InitOkCancelApply(ui); + bOk->setEnabled(false); + + FillComboBoxPoints(ui->comboBoxPoint); + + connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChanged); + connect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogSplinePath::currentPointChanged); + connect(ui->doubleSpinBoxAngle1, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogSplinePath::Angle1Changed); + connect(ui->doubleSpinBoxAngle2, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogSplinePath::Angle2Changed); + connect(ui->doubleSpinBoxKasm1, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogSplinePath::KAsm1Changed); + connect(ui->doubleSpinBoxKasm2, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogSplinePath::KAsm2Changed); + + visPath = new VisToolSplinePath(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogSplinePath::~DialogSplinePath() +{ + if (qApp->getCurrentScene()->items().contains(visPath)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete visPath; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetPath set spline path + * @param value path + */ +void DialogSplinePath::SetPath(const VSplinePath &value) +{ + this->path = value; + ui->listWidget->blockSignals(true); + ui->listWidget->clear(); + for (qint32 i = 0; i < path.CountPoint(); ++i) + { + NewItem(path.at(i).P().id(), path.at(i).KAsm1(), path.at(i).Angle1(), path.at(i).KAsm2(), path.at(i).Angle2()); + } + ui->listWidget->setFocus(Qt::OtherFocusReason); + ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); + + visPath->setPath(path); + ui->listWidget->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type don't show this id in list + */ +void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type) +{ + if (type == SceneObject::Point) + { + NewItem(id, 1, 0, 1, 180); + emit ToolTip(tr("Select point of curve path")); + + SavePath(); + visPath->setPath(path); + if (path.CountPoint() == 1) + { + visPath->VisualMode(NULL_ID); + connect(visPath, &VisToolSplinePath::ToolTip, this, &DialogTool::ShowVisToolTip); + connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated); + } + else + { + visPath->RefreshGeometry(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::SaveData() +{ + SavePath(); + + visPath->setPath(path); + visPath->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PointChanged selected another point in list + * @param row number of row + */ +void DialogSplinePath::PointChanged(int row) +{ + if (ui->listWidget->count() == 0) + { + return; + } + QListWidgetItem *item = ui->listWidget->item( row ); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); + EnableFields(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief currentPointChanged changed point in combo box + * @param index index in list + */ +void DialogSplinePath::currentPointChanged(int index) +{ + quint32 id = qvariant_cast(ui->comboBoxPoint->itemData(index)); + qint32 row = ui->listWidget->currentRow(); + QListWidgetItem *item = ui->listWidget->item( row ); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + const QSharedPointer point = data->GeometricObject(id); + p.SetP(*point); + DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); + EnableFields(); + item->setData(Qt::UserRole, QVariant::fromValue(p)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Angle1Changed changed first angle + * @param index index in list + */ +void DialogSplinePath::Angle1Changed(qreal index) +{ + qint32 row = ui->listWidget->currentRow(); + QListWidgetItem *item = ui->listWidget->item( row ); + SCASSERT(item != nullptr); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + p.SetAngle1(index); + DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); + item->setData(Qt::UserRole, QVariant::fromValue(p)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Angle2Changed changed second angle + * @param index index in list + */ +void DialogSplinePath::Angle2Changed(qreal index) +{ + qint32 row = ui->listWidget->currentRow(); + QListWidgetItem *item = ui->listWidget->item( row ); + SCASSERT(item != nullptr); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + p.SetAngle2(index); + DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); + item->setData(Qt::UserRole, QVariant::fromValue(p)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief KAsm1Changed changed first coefficient asymmetry + * @param d value + */ +void DialogSplinePath::KAsm1Changed(qreal d) +{ + qint32 row = ui->listWidget->currentRow(); + QListWidgetItem *item = ui->listWidget->item( row ); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + p.SetKAsm1(d); + item->setData(Qt::UserRole, QVariant::fromValue(p)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief KAsm2Changed changed second coefficient asymmetry + * @param d value + */ +void DialogSplinePath::KAsm2Changed(qreal d) +{ + qint32 row = ui->listWidget->currentRow(); + QListWidgetItem *item = ui->listWidget->item( row ); + VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); + p.SetKAsm2(d); + item->setData(Qt::UserRole, QVariant::fromValue(p)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::ShowDialog(bool click) +{ + if (click == false) + { + if (path.CountPoint() >= 3) + { + emit ToolTip(""); + DialogAccepted(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::PathUpdated(const VSplinePath &path) +{ + SetPath(path); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visPath, &Visualization::SetFactor); + scene->addItem(visPath); + visPath->setMode(Mode::Show); + visPath->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewItem add point to list + * @param id id + * @param kAsm1 first coefficient asymmetry + * @param angle1 first angle in degree + * @param kAsm2 second coefficient asymmetry + * @param angle2 second angle in degree + */ +void DialogSplinePath::NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) +{ + const QSharedPointer point = data->GeometricObject(id); + QListWidgetItem *item = new QListWidgetItem(point->name()); + item->setFont(QFont("Times", 12, QFont::Bold)); + VSplinePoint p(*point.data(), kAsm1, angle1, kAsm2, angle2); + DataPoint(point->id(), kAsm1, angle1, kAsm2, angle2); + item->setData(Qt::UserRole, QVariant::fromValue(p)); + ui->listWidget->addItem(item); + ui->listWidget->setCurrentItem(item); + if (ui->listWidget->count() >= 2) + { + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + bOk->setEnabled(true); + } + EnableFields(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief dataPoint show data of point in fields + * @param id id + * @param kAsm1 first coefficient asymmetry + * @param angle1 first angle of spline + * @param kAsm2 second coefficient asymmetry + * @param angle2 second angle of spline + */ +void DialogSplinePath::DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) +{ + ui->comboBoxPoint->blockSignals(true); + ui->doubleSpinBoxAngle1->blockSignals(true); + ui->doubleSpinBoxAngle2->blockSignals(true); + ui->doubleSpinBoxKasm1->blockSignals(true); + ui->doubleSpinBoxKasm2->blockSignals(true); + + ChangeCurrentData(ui->comboBoxPoint, id); + ui->doubleSpinBoxKasm1->setValue(kAsm1); + ui->doubleSpinBoxKasm2->setValue(kAsm2); + ui->doubleSpinBoxAngle2->setValue(angle2); + ui->doubleSpinBoxAngle1->setValue(angle1); + + ui->comboBoxPoint->blockSignals(false); + ui->doubleSpinBoxAngle1->blockSignals(false); + ui->doubleSpinBoxAngle2->blockSignals(false); + ui->doubleSpinBoxKasm1->blockSignals(false); + ui->doubleSpinBoxKasm2->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EnableFields enable or disable fields + */ +void DialogSplinePath::EnableFields() +{ + ui->doubleSpinBoxKasm1->setEnabled(true); + ui->doubleSpinBoxAngle1->setEnabled(true); + ui->doubleSpinBoxKasm2->setEnabled(true); + ui->doubleSpinBoxAngle2->setEnabled(true); + qint32 row = ui->listWidget->currentRow(); + if (row == 0) + { + ui->doubleSpinBoxKasm1->setEnabled(false); + ui->doubleSpinBoxAngle1->setEnabled(false); + return; + } + if (row == ui->listWidget->count()-1) + { + ui->doubleSpinBoxKasm2->setEnabled(false); + ui->doubleSpinBoxAngle2->setEnabled(false); + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::SavePath() +{ + path.Clear(); + for (qint32 i = 0; i < ui->listWidget->count(); ++i) + { + QListWidgetItem *item = ui->listWidget->item(i); + path.append( qvariant_cast(item->data(Qt::UserRole))); + } + path.setKCurve(ui->doubleSpinBoxKcurve->value()); +} diff --git a/src/app/dialogs/tools/dialogsplinepath.h b/src/app/dialogs/tools/dialogsplinepath.h new file mode 100644 index 000000000..4316ddefd --- /dev/null +++ b/src/app/dialogs/tools/dialogsplinepath.h @@ -0,0 +1,98 @@ +/************************************************************************ + ** + ** @file dialogsplinepath.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGSPLINEPATH_H +#define DIALOGSPLINEPATH_H + +#include "dialogtool.h" +#include "../../geometry/vsplinepath.h" + +namespace Ui +{ + class DialogSplinePath; +} + +class VisToolSplinePath; + +/** + * @brief The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option. + */ +class DialogSplinePath : public DialogTool +{ + Q_OBJECT +public: + DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogSplinePath(); + + VSplinePath GetPath() const; + void SetPath(const VSplinePath &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + void PointChanged(int row); + void currentPointChanged( int index ); + void Angle1Changed(qreal index ); + void Angle2Changed( qreal index ); + void KAsm1Changed(qreal d); + void KAsm2Changed(qreal d); + virtual void UpdateList(); + virtual void ShowDialog(bool click); + void PathUpdated(const VSplinePath &path); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogSplinePath) + + /** @brief ui keeps information about user interface */ + Ui::DialogSplinePath *ui; + + /** @brief path spline path */ + VSplinePath path; + + VisToolSplinePath *visPath; + + void NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); + void DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); + void EnableFields(); + void SavePath(); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetPath return spline path + * @return path + */ +inline VSplinePath DialogSplinePath::GetPath() const +{ + return path; +} + +#endif // DIALOGSPLINEPATH_H diff --git a/src/dialogs/dialogsplinepath.ui b/src/app/dialogs/tools/dialogsplinepath.ui similarity index 87% rename from src/dialogs/dialogsplinepath.ui rename to src/app/dialogs/tools/dialogsplinepath.ui index 68c7c2795..44c1b3459 100644 --- a/src/dialogs/dialogsplinepath.ui +++ b/src/app/dialogs/tools/dialogsplinepath.ui @@ -11,10 +11,10 @@ - Curve path + Curved path - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -53,6 +53,9 @@ + + 0.010000000000000 + 1.000000000000000 @@ -73,9 +76,9 @@ - + - 360 + 360.000000000000000 @@ -95,6 +98,9 @@ + + 0.010000000000000 + 1.000000000000000 @@ -115,9 +121,9 @@ - + - 360 + 360.000000000000000 @@ -169,6 +175,9 @@ 0 + + 0.010000000000000 + 1.000000000000000 @@ -182,7 +191,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -191,15 +200,15 @@ comboBoxPoint doubleSpinBoxKasm1 - spinBoxAngle1 + doubleSpinBoxAngle1 doubleSpinBoxKasm2 - spinBoxAngle2 - doubleSpinBoxKcurve + doubleSpinBoxAngle2 listWidget + doubleSpinBoxKcurve buttonBox - + diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp new file mode 100644 index 000000000..2a0c7ae72 --- /dev/null +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -0,0 +1,1209 @@ +/************************************************************************ + ** + ** @file dialogtool.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogtool.h" +#include "../../container/calculator.h" +#include "../../container/vcontainer.h" +#include "../../geometry/varc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/vsplinepath.h" +#include "../../tools/vabstracttool.h" +#include "../../../libs/qmuparser/qmuparsererror.h" +#include "../../core/vapplication.h" +#include "../../core/vsettings.h" +#include "../../libs/ifc/xml/vdomdocument.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_LOGGING_CATEGORY(vDialog, "v.dialog") + +#define DIALOG_MAX_FORMULA_HEIGHT 64 + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogTool create dialog + * @param data container with data + * @param parent parent widget + */ +DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent) + :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), flagError(true), + timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr), + listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr), + labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), + radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), + radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr), + lineStyles(VAbstractTool::Styles()), okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), + toolId(toolId), prepare(false), pointName(QString()) +{ + SCASSERT(data != nullptr); + timerFormula = new QTimer(this); + connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula); + this->setWindowFlags(Qt::Tool | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint); +} + + +//--------------------------------------------------------------------------------------------------------------------- +DialogTool::~DialogTool() +{ + emit ToolTip(""); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle when dialog cloded + * @param event event + */ +void DialogTool::closeEvent(QCloseEvent *event) +{ + DialogRejected(); + event->accept(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief showEvent handle when window show + * @param event event + */ +void DialogTool::showEvent(QShowEvent *event) +{ + QDialog::showEvent( event ); + if ( event->spontaneous() ) + { + return; + } + if (isInitialized) + { + return; + } + isInitialized = true;//first show windows are held + ShowVisualization(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillComboBoxPoints fill comboBox list of points + * @param box comboBox + */ +void DialogTool::FillComboBoxPoints(QComboBox *box) const +{ + SCASSERT(box != nullptr); + const QHash > *objs = data->DataGObjects(); + QMap list; + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (i.key() != toolId) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation) + { + const QSharedPointer point = data->GeometricObject(i.key()); + list[point->name()] = i.key(); + } + } + } + FillList(box, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const +{ + SCASSERT(box != nullptr); + const QHash > *objs = data->DataGObjects(); + QHash >::const_iterator i; + QMap list; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (cut == ComboBoxCutArc::CutArc) + { + if (i.key() != toolId + 1 && i.key() != toolId + 2) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) + { + const QSharedPointer arc = data->GeometricObject(i.key()); + list[arc->name()] = i.key(); + } + } + } + else + { + if (i.key() != toolId) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) + { + const QSharedPointer arc = data->GeometricObject(i.key()); + list[arc->name()] = i.key(); + } + } + } + } + FillList(box, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillComboBoxSplines fill comboBox list of splines + * @param box comboBox + * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 + */ +void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const +{ + SCASSERT(box != nullptr); + const QHash > *objs = data->DataGObjects(); + QHash >::const_iterator i; + QMap list; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (cut == ComboBoxCutSpline::CutSpline) + { + if (i.key() != toolId + 1 && i.key() != toolId + 2) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) + { + const QSharedPointer spl = data->GeometricObject(i.key()); + list[spl->name()] = i.key(); + } + } + } + else + { + if (i.key() != toolId) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) + { + const QSharedPointer spl = data->GeometricObject(i.key()); + list[spl->name()] = i.key(); + } + } + } + } + FillList(box, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillComboBoxSplinesPath + * @param box comboBox + * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 + */ +void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const +{ + SCASSERT(box != nullptr); + const QHash > *objs = data->DataGObjects(); + QMap list; + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (cut == ComboBoxCutSpline::CutSpline) + { + if (i.key() != toolId + 1 && i.key() != toolId + 2) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) + { + const QSharedPointer splPath = data->GeometricObject(i.key()); + list[splPath->name()] = i.key(); + } + } + } + else + { + if (i.key() != toolId) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) + { + const QSharedPointer splPath = data->GeometricObject(i.key()); + list[splPath->name()] = i.key(); + } + } + } + } + FillList(box, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::FillComboBoxCurves(QComboBox *box) const +{ + SCASSERT(box != nullptr); + const QHash > *objs = data->DataGObjects(); + QMap list; + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (i.key() != toolId) + { + QSharedPointer obj = i.value(); + if ((obj->getType() == GOType::Arc || obj->getType() == GOType::Spline || + obj->getType() == GOType::SplinePath) && obj->getMode() == Draw::Calculation) + { + const QSharedPointer curve = data->GeometricObject(i.key()); + list[curve->name()] = i.key(); + } + } + } + FillList(box, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillComboBoxTypeLine fill comboBox list of type lines + * @param box comboBox + */ +void DialogTool::FillComboBoxTypeLine(QComboBox *box) const +{ + SCASSERT(box != nullptr); + box->addItems(lineStyles); + box->setCurrentIndex(1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeLine return type of line + * @param box combobox + * @return type + */ +QString DialogTool::GetTypeLine(const QComboBox *box) const +{ + switch (lineStyles.indexOf(box->currentText())) + { + case 0: //No line + return VAbstractTool::TypeLineNone; + break; + case 1: //Line + return VAbstractTool::TypeLineLine; + break; + case 2: //Dash Line + return VAbstractTool::TypeLineDashLine; + break; + case 3: //Dot Line + return VAbstractTool::TypeLineDotLine; + break; + case 4: //Dash Dot Line + return VAbstractTool::TypeLineDashDotLine; + break; + case 5: //Dash Dot Dot Line + return VAbstractTool::TypeLineDashDotDotLine; + break; + default: + return VAbstractTool::TypeLineLine; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetupTypeLine setupe type of line + * @param box combobox + * @param value string from pattern file + */ +void DialogTool::SetupTypeLine(QComboBox *box, const QString &value) +{ + QStringList styles = VAbstractTool::Styles(); + qint32 index = box->findText(lineStyles.at(styles.indexOf(value))); + if (index != -1) + { + box->setCurrentIndex(index); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangeCurrentData select item in combobox by id + * @param box combobox + * @param value id of item + */ +void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const +{ + qint32 index = box->findData(value); + if (index != -1) + { + box->setCurrentIndex(index); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutValHere put variable into line edit from list + * @param lineEdit lineEdit + * @param listWidget listWidget + */ +void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget) +{ + SCASSERT(lineEdit != nullptr); + SCASSERT(listWidget != nullptr); + QListWidgetItem *item = listWidget->currentItem(); + if (item != nullptr) + { + int pos = lineEdit->cursorPosition(); + lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); + lineEdit->setFocus(); + lineEdit->setCursorPosition(pos + item->text().size()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget) +{ + SCASSERT(plainTextEdit != nullptr); + SCASSERT(listWidget != nullptr); + QListWidgetItem *item = listWidget->currentItem(); + if (item != nullptr) + { + QTextCursor cursor = plainTextEdit->textCursor(); + cursor.insertText(item->text()); + plainTextEdit->setTextCursor(cursor); + plainTextEdit->setFocus(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit) +{ + SCASSERT(plainTextEdit != nullptr); + QTextCursor cursor = plainTextEdit->textCursor(); + cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); + plainTextEdit->setTextCursor(cursor); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogTool::eventFilter(QObject *object, QEvent *event) +{ + QPlainTextEdit *plainTextEdit = qobject_cast(object); + if (plainTextEdit != nullptr) + { + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + if ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return)) + { + // Ignore Enter key + return true; + } + } + } + else + { + // pass the event on to the parent class + return QDialog::eventFilter(object, event); + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ValFormulaChanged handle change formula + * @param flag flag state of formula + * @param edit LineEdit + * @param timer timer of formula + */ +void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) +{ + SCASSERT(edit != nullptr); + SCASSERT(timer != nullptr); + SCASSERT(labelEditFormula != nullptr); + SCASSERT(labelResultCalculation != nullptr); + if (edit->text().isEmpty()) + { + flag = false; + CheckState(); + ChangeColor(labelEditFormula, Qt::red); + labelResultCalculation->setText(tr("Error")); + labelResultCalculation->setToolTip(tr("Empty field")); + return; + } + timer->start(1000); +} +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *timer) +{ + SCASSERT(edit != nullptr); + SCASSERT(timer != nullptr); + SCASSERT(labelEditFormula != nullptr); + SCASSERT(labelResultCalculation != nullptr); + if (edit->toPlainText().isEmpty()) + { + flag = false; + CheckState(); + ChangeColor(labelEditFormula, Qt::red); + labelResultCalculation->setText(tr("Error")); + labelResultCalculation->setToolTip(tr("Empty field")); + return; + } + timer->setSingleShot(true); + timer->start(1000); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Eval evaluate formula and show result + * @param text formula + * @param flag flag state of formula + * @param label label for signal error + * @param postfix unit name + * @param checkZero true - if formula can't be equal zero + */ +qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero) +{ + SCASSERT(label != nullptr); + SCASSERT(labelEditFormula != nullptr); + + qreal result = INT_MIN;//Value can be 0, so use max imposible value + + if (text.isEmpty()) + { + flag = false; + ChangeColor(labelEditFormula, Qt::red); + label->setText(tr("Error")); + label->setToolTip(tr("Empty field")); + } + else + { + try + { + // Replace line return with spaces for calc if exist + QString formula = text; + formula.replace("\n", " "); + formula = qApp->FormulaFromUser(formula); + Calculator *cal = new Calculator(data); + result = cal->EvalFormula(formula); + delete cal; + + //if result equal 0 + if (checkZero && qFuzzyCompare(1 + result, 1 + 0)) + { + flag = false; + ChangeColor(labelEditFormula, Qt::red); + label->setText(tr("Error")); + label->setToolTip(tr("Value can't be 0")); + } + else + { + QLocale loc; + if (qApp->getSettings()->GetOsSeparator()) + { + loc = QLocale::system(); + } + else + { + loc = QLocale(QLocale::C); + } + label->setText(loc.toString(result) + postfix); + flag = true; + ChangeColor(labelEditFormula, okColor); + label->setToolTip(tr("Value")); + emit ToolTip(""); + } + } + catch (qmu::QmuParserError &e) + { + label->setText(tr("Error")); + flag = false; + ChangeColor(labelEditFormula, Qt::red); + emit ToolTip(tr("Parser error: %1").arg(e.GetMsg())); + label->setToolTip(tr("Parser error: %1").arg(e.GetMsg())); + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; + } + } + CheckState(); + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const +{ + SCASSERT(box != nullptr); + FillComboBoxPoints(box); + pointId = value; + ChangeCurrentData(box, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentSplineId set current spline id in combobox + * @param box combobox + * @param splineId save current spline id + * @param value spline id + * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 + */ +void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, + ComboBoxCutSpline cut) const +{ + SCASSERT(box != nullptr); + FillComboBoxSplines(box, cut); + splineId = value; + ChangeCurrentData(box, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentArcId + * @param box combobox + * @param arcId save current arc id + * @param value arc id + * @param cut if set to ComboMode::CutArc don't show id+1 and id+2 + */ +void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, ComboBoxCutArc cut) const +{ + SCASSERT(box != nullptr); + FillComboBoxArcs(box, cut); + arcId = value; + ChangeCurrentData(box, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentSplinePathId set current splinePath id in combobox + * @param box combobox + * @param splinePathId save current splinePath id + * @param value splinePath id + * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 + */ +void DialogTool::setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, + ComboBoxCutSpline cut) const +{ + SCASSERT(box != nullptr); + FillComboBoxSplinesPath(box, cut); + splinePathId = value; + ChangeCurrentData(box, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::setCurrentCurveId(QComboBox *box, quint32 &curveId, const quint32 &value) const +{ + SCASSERT(box != nullptr); + FillComboBoxCurves(box); + curveId = value; + ChangeCurrentData(box, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getCurrentPointId return current point id stored in combobox + * @param box combobox + * @return id or 0 if combobox is empty + */ +quint32 DialogTool::getCurrentObjectId(QComboBox *box) const +{ + SCASSERT(box != nullptr); + qint32 index = box->currentIndex(); + if (index != -1) + { + return qvariant_cast(box->itemData(index)); + } + else + { + return 0; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &toolTip) +{ + SCASSERT(box != nullptr); + const QSharedPointer obj = data->GetGObject(id); + SCASSERT(obj.isNull() == false); + const qint32 index = box->findText(obj->name()); + if ( index != -1 ) + { // -1 for not found + box->setCurrentIndex(index); + emit ToolTip(toolTip); + return true; + } + else + { + qWarning()<<"Can't find object by name"<name(); + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight) +{ + SCASSERT(formula != nullptr); + SCASSERT(buttonGrowLength != nullptr) + if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT) + { + formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); + //Set icon from theme (internal for Windows system) + buttonGrowLength->setIcon(QIcon::fromTheme("go-next", + QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); + } + else + { + formula->setFixedHeight(formulaBaseHeight); + //Set icon from theme (internal for Windows system) + buttonGrowLength->setIcon(QIcon::fromTheme("go-down", + QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); + } + + // I found that after change size of formula field, it was filed for angle formula, field for formula became black. + // This code prevent this. + setUpdatesEnabled(false); + repaint(); + setUpdatesEnabled(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FillList fill combobox list + * @param box combobox + * @param list list with ids and names + */ +void DialogTool::FillList(QComboBox *box, const QMap &list) const +{ + SCASSERT(box != nullptr); + box->clear(); + + QMapIterator iter(list); + while (iter.hasNext()) + { + iter.next(); + box->addItem(iter.key(), iter.value()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckState enable, when all is correct, or disable, when something wrong, button ok + */ +void DialogTool::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagFormula && flagName && flagError); + // In case dialog hasn't apply button + if ( bApply != nullptr) + { + bApply->setEnabled(bOk->isEnabled()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChosenObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogTool::ChosenObject(quint32 id, const SceneObject &type) +{ + Q_UNUSED(id); + Q_UNUSED(type); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NamePointChanged check name of point + */ +void DialogTool::NamePointChanged() +{ + SCASSERT(labelEditNamePoint != nullptr); + QLineEdit* edit = qobject_cast(sender()); + if (edit) + { + QString name = edit->text(); + name.replace(" ", ""); + QRegExpValidator v(QRegExp(nameRegExp), this); + int pos = 0; + if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) || + v.validate(name, pos) == QValidator::Invalid) + { + flagName = false; + ChangeColor(labelEditNamePoint, Qt::red); + } + else + { + flagName = true; + ChangeColor(labelEditNamePoint, okColor); + } + } + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::ChangeColor(QWidget *widget, const QColor &color) +{ + SCASSERT(widget != nullptr); + QPalette palette = widget->palette(); + palette.setColor(widget->foregroundRole(), color); + widget->setPalette(palette); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::setPointId(QComboBox *box, quint32 &pointId, const quint32 &value) +{ + SCASSERT(box != nullptr); + box->blockSignals(true); + setCurrentPointId(box, pointId, value); + box->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogAccepted save data and emit signal about closed dialog. + */ +void DialogTool::DialogAccepted() +{ + SaveData(); + emit DialogClosed(QDialog::Accepted); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::DialogApply() +{ + SaveData(); + emit DialogApplied(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogRejected emit signal dialog rejected + */ +void DialogTool::DialogRejected() +{ + emit DialogClosed(QDialog::Rejected); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief formula check formula + */ +void DialogTool::FormulaChanged() +{ + QPlainTextEdit* edit = qobject_cast(sender()); + if (edit) + { + ValFormulaChanged(flagFormula, edit, timerFormula); + } +} +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::FormulaChangedPlainText() +{ + QPlainTextEdit* edit = qobject_cast(sender()); + if (edit) + { + ValFormulaChanged(flagFormula, edit, timerFormula); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowUp set angle value 90 degree + */ +void DialogTool::ArrowUp() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(90); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowDown set angle value 270 degree + */ +void DialogTool::ArrowDown() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(270); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowLeft set angle value 180 degree + */ +void DialogTool::ArrowLeft() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(180); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowRight set angle value 0 degree + */ +void DialogTool::ArrowRight() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(0); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowLeftUp set angle value 135 degree + */ +void DialogTool::ArrowLeftUp() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(135); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowLeftDown set angle value 225 degree + */ +void DialogTool::ArrowLeftDown() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(225); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowRightUp set angle value 45 degree + */ +void DialogTool::ArrowRightUp() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(45); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowRightDown set angle value 315 degree + */ +void DialogTool::ArrowRightDown() +{ + SCASSERT(spinBoxAngle != nullptr); + spinBoxAngle->setValue(315); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EvalFormula evaluate formula + */ +void DialogTool::EvalFormula() +{ + SCASSERT(plainTextEditFormula != nullptr); + SCASSERT(labelResultCalculation != nullptr); + const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit()); + Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SizeHeight show in list base variables + */ +void DialogTool::SizeHeight() +{ + SCASSERT(listWidget != nullptr); + listWidget->blockSignals(true); + listWidget->clear(); + + { + QListWidgetItem *item = new QListWidgetItem(data->HeightName()); + item->setFont(QFont("Times", 12, QFont::Bold)); + listWidget->addItem(item); + } + + QListWidgetItem *item = new QListWidgetItem(data->SizeName()); + item->setFont(QFont("Times", 12, QFont::Bold)); + listWidget->addItem(item); + + listWidget->blockSignals(false); + listWidget->setCurrentRow (0); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Measurements show in list measurements + */ +void DialogTool::Measurements() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(true); + ShowVariable(data->DataMeasurements()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LengthLines show in list lengths of lines variables + */ +void DialogTool::LengthLines() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataLengthLines()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LengthArcs show in list lengths of arcs variables + */ +void DialogTool::LengthArcs() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataLengthArcs()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LengthCurves show in list lengths of curves variables + */ +void DialogTool::LengthCurves() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataLengthSplines()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::AngleLines() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataAngleLines()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Increments show in list increment variables + */ +void DialogTool::Increments() +{ + SCASSERT(checkBoxHideEmpty != nullptr); + checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataIncrements()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutHere put variable into edit + */ +void DialogTool::PutHere() +{ + PutValHere(plainTextEditFormula, listWidget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PutVal put variable into edit + * @param item chosen item of list widget + */ +void DialogTool::PutVal(QListWidgetItem *item) +{ + SCASSERT(plainTextEditFormula != nullptr); + SCASSERT(item != nullptr); + QTextCursor cursor = plainTextEditFormula->textCursor(); + cursor.insertText(item->text()); + plainTextEditFormula->setTextCursor(cursor); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ValChenged show description when current variable changed + * @param row number of row + */ +void DialogTool::ValChenged(int row) +{ + SCASSERT(listWidget != nullptr); + SCASSERT(labelDescription != nullptr); + SCASSERT(radioButtonSizeGrowth != nullptr); + SCASSERT(radioButtonStandardTable != nullptr); + SCASSERT(radioButtonIncrements != nullptr); + SCASSERT(radioButtonLengthLine != nullptr); + SCASSERT(radioButtonLengthArc != nullptr); + SCASSERT(radioButtonLengthCurve != nullptr); + if (listWidget->count() == 0) + { + return; + } + QListWidgetItem *item = listWidget->item( row ); + if (radioButtonSizeGrowth->isChecked()) + { + if (item->text()==data->HeightName()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height")); + labelDescription->setText(desc); + } + if (item->text()==data->SizeName()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size")); + labelDescription->setText(desc); + } + return; + } + if (radioButtonStandardTable->isChecked()) + { + QString name = qApp->VarFromUser(item->text()); + QSharedPointer stable = data->GetVariable(name); + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name)) + .arg(stable->GetGuiText()); + labelDescription->setText(desc); + return; + } + if (radioButtonIncrements->isChecked()) + { + QSharedPointer incr = data->GetVariable(item->text()); + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text())) + .arg(incr->GetDescription()); + labelDescription->setText(desc); + return; + } + if (radioButtonLengthLine->isChecked()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(tr("Line length")); + labelDescription->setText(desc); + return; + } + if (radioButtonLengthArc->isChecked()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(tr("Arc length")); + labelDescription->setText(desc); + return; + } + if (radioButtonLengthCurve->isChecked()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(tr("Curve length")); + labelDescription->setText(desc); + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateList update lists of variables + */ +void DialogTool::UpdateList() +{ + SCASSERT(radioButtonSizeGrowth != nullptr); + SCASSERT(radioButtonStandardTable != nullptr); + SCASSERT(radioButtonIncrements != nullptr); + SCASSERT(radioButtonLengthLine != nullptr); + SCASSERT(radioButtonLengthArc != nullptr); + SCASSERT(radioButtonLengthCurve != nullptr); + + if (radioButtonSizeGrowth->isChecked()) + { + SizeHeight(); + } + if (radioButtonStandardTable->isChecked()) + { + ShowVariable(data->DataMeasurements()); + } + if (radioButtonIncrements->isChecked()) + { + ShowVariable(data->DataIncrements()); + } + if (radioButtonLengthLine->isChecked()) + { + ShowVariable(data->DataLengthLines()); + } + if (radioButtonLengthArc->isChecked()) + { + ShowVariable(data->DataLengthArcs()); + } + if (radioButtonLengthCurve->isChecked()) + { + ShowVariable(data->DataLengthSplines()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogTool::GetToolId() const +{ + return toolId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::SetToolId(const quint32 &value) +{ + toolId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowVariable show variables in list + * @param var container with variables + */ +template +void DialogTool::ShowVariable(const QMap var) +{ + SCASSERT(listWidget != nullptr); + SCASSERT(checkBoxHideEmpty != nullptr); + listWidget->blockSignals(true); + listWidget->clear(); + + QMapIterator iMap(var); + while (iMap.hasNext()) + { + iMap.next(); + if (checkBoxHideEmpty->isEnabled() && checkBoxHideEmpty->isChecked() && iMap.value()->IsNotUsed()) + { + continue; //skip this measurement + } + if (iMap.value()->Filter(toolId) == false) + {// If we create this variable don't show + QListWidgetItem *item = new QListWidgetItem(iMap.key()); + item->setFont(QFont("Times", 12, QFont::Bold)); + listWidget->addItem(item); + } + } + listWidget->blockSignals(false); + listWidget->setCurrentRow (0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::ShowVisToolTip(const QString &toolTip) +{ + emit ToolTip(toolTip); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::ShowDialog(bool click) +{ + Q_UNUSED(click); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::SetAssociatedTool(VAbstractTool *tool) +{ + this->associatedTool=tool; + SetToolId(tool->getId()); +} diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h new file mode 100644 index 000000000..7bb48c2e3 --- /dev/null +++ b/src/app/dialogs/tools/dialogtool.h @@ -0,0 +1,351 @@ +/************************************************************************ + ** + ** @file dialogtool.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGTOOL_H +#define DIALOGTOOL_H + +#include +#include +#include +#include +#include +#include "../../core/vapplication.h" +#include +#include +#include + +Q_DECLARE_LOGGING_CATEGORY(vDialog) + +class QDoubleSpinBox; +class QLabel; +class QComboBox; +class QListWidgetItem; +class VContainer; +class QPlainTextEdit; +class VAbstractTool; + +enum class ComboBoxCutSpline : char { CutSpline, NoCutSpline }; +enum class ComboBoxCutArc : char { CutArc, NoCutArc}; + +/** + * @brief The DialogTool class parent for all dialog of tools. + */ +class DialogTool : public QDialog +{ + Q_OBJECT +public: + DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + virtual ~DialogTool(); + + VAbstractTool* GetAssociatedTool(); + void SetAssociatedTool(VAbstractTool* tool); + + virtual void ShowDialog(bool click); + + quint32 GetToolId() const; + void SetToolId(const quint32 &value); +signals: + /** + * @brief DialogClosed signal dialog closed + * @param result keep result + */ + void DialogClosed(int result); + /** + * @brief DialogApplied emit signal dialog apply changes + */ + void DialogApplied(); + /** + * @brief ToolTip emit tooltipe for tool + * @param toolTip text tooltipe + */ + void ToolTip(const QString &toolTip); +public slots: + void ShowVisToolTip(const QString &toolTip); + virtual void ChosenObject(quint32 id, const SceneObject &type); + void NamePointChanged(); + virtual void DialogAccepted(); + /** + * @brief DialogApply save data and emit signal DialogApplied. + */ + virtual void DialogApply(); + virtual void DialogRejected(); + void FormulaChanged(); + /** + * @brief FormulaChangedPlainText check formula (plain text editor editor) + */ + void FormulaChangedPlainText(); + void ArrowUp(); + void ArrowDown(); + void ArrowLeft(); + void ArrowRight(); + void ArrowLeftUp(); + void ArrowLeftDown(); + void ArrowRightUp(); + void ArrowRightDown(); + virtual void EvalFormula(); + void SizeHeight(); + void Measurements(); + void LengthLines(); + void LengthArcs(); + void LengthCurves(); + void AngleLines(); + void Increments(); + void PutHere(); + void PutVal(QListWidgetItem * item); + virtual void ValChenged(int row); + virtual void UpdateList(); + virtual void PointNameChanged(){} +protected: + Q_DISABLE_COPY(DialogTool) + + /** @brief data container with data */ + const VContainer *data; + + /** @brief isInitialized true if window is initialized */ + bool isInitialized; + + /** @brief flagName true if name is correct */ + bool flagName; + + /** @brief flagFormula true if formula correct */ + bool flagFormula; + + /** @brief flagError use this flag if for you do not enought @see flagName and @see flagFormula. + * + * In many cases you will need more flags fore checking if all data are valid. + * By default this flag is true. + */ + bool flagError; + + /** @brief timerFormula timer for check formula */ + QTimer *timerFormula; + + /** @brief bOk button ok */ + QPushButton *bOk; + + /** @brief bApply button apply */ + QPushButton *bApply; + + /** @brief spinBoxAngle spinbox for angle */ + QDoubleSpinBox *spinBoxAngle; + + /** @brief plainTextEditFormula formula */ + QPlainTextEdit *plainTextEditFormula; + /** @brief listWidget listWidget with variables */ + QListWidget *listWidget; + + /** @brief labelResultCalculation label with result of calculation */ + QLabel *labelResultCalculation; + + /** @brief labelDescription description of variable */ + QLabel *labelDescription; + + /** @brief labelEditNamePoint label used when need show wrong name of point */ + QLabel *labelEditNamePoint; + + /** @brief labelEditFormula label used when need show wrong formula */ + QLabel *labelEditFormula; + + /** @brief radioButtonSizeGrowth radio button for base variables */ + QRadioButton *radioButtonSizeGrowth; + + /** @brief radioButtonStandardTable radio button for standard table variables */ + QRadioButton *radioButtonStandardTable; + + /** @brief radioButtonIncrements radio button for increments variables */ + QRadioButton *radioButtonIncrements; + + /** @brief radioButtonLengthLine radio button for lengths od lines variables */ + QRadioButton *radioButtonLengthLine; + + /** @brief radioButtonLengthArc radio button for lengths of arcs variables */ + QRadioButton *radioButtonLengthArc; + + /** @brief radioButtonLengthCurve radio button for lengths of curves variables */ + QRadioButton *radioButtonLengthCurve; + + QRadioButton *radioButtonAngleLine; + + QCheckBox *checkBoxHideEmpty; + + /** @brief lineStyles list supported line styles. */ + QStringList lineStyles; + const QColor okColor; + const QColor errorColor; + /** + * @brief associatedTool vdrawtool associated with opened dialog. + */ + VAbstractTool *associatedTool; + quint32 toolId; + + /** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/ + bool prepare; + + /** @brief pointName name of point */ + QString pointName; + + virtual void closeEvent ( QCloseEvent * event ); + virtual void showEvent( QShowEvent *event ); + void FillComboBoxPoints(QComboBox *box)const; + void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const; + void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; + void FillComboBoxSplinesPath(QComboBox *box, + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; + void FillComboBoxCurves(QComboBox *box)const; + void FillComboBoxTypeLine(QComboBox *box) const; + virtual void CheckState(); + QString GetTypeLine(const QComboBox *box)const; + template + void ShowVariable(const QMap var); + void SetupTypeLine(QComboBox *box, const QString &value); + void ChangeCurrentData(QComboBox *box, const quint32 &value) const; + void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); + void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); + void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); + void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); + qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, + bool checkZero = true); + void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const; + void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; + void setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, + ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const; + void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; + void setCurrentCurveId(QComboBox *box, quint32 &curveId, const quint32 &value) const; + quint32 getCurrentObjectId(QComboBox *box) const; + bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip); + void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); + template + void InitArrow(T *ui) + { + SCASSERT(ui != nullptr); + spinBoxAngle = ui->doubleSpinBoxAngle; + connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, &DialogTool::ArrowDown); + connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, &DialogTool::ArrowUp); + connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, &DialogTool::ArrowLeft); + connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, &DialogTool::ArrowRight); + connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, &DialogTool::ArrowLeftUp); + connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, &DialogTool::ArrowLeftDown); + connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, &DialogTool::ArrowRightUp); + connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, &DialogTool::ArrowRightDown); + } + template + void InitVariables(T *ui) + { + listWidget = ui->listWidget; + labelDescription = ui->labelDescription; + radioButtonSizeGrowth = ui->radioButtonSizeGrowth; + radioButtonStandardTable = ui->radioButtonStandardTable; + radioButtonIncrements = ui->radioButtonIncrements; + radioButtonLengthLine = ui->radioButtonLengthLine; + radioButtonLengthArc = ui->radioButtonLengthArc; + radioButtonLengthCurve = ui->radioButtonLengthSpline; + radioButtonAngleLine = ui->radioButtonAngleLine; + checkBoxHideEmpty = ui->checkBoxHideEmpty; + + connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); + + if (qApp->patternType() == MeasurementsType::Standard) + { + SizeHeight(); + connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); + } + else + { + radioButtonSizeGrowth->setEnabled(false); + radioButtonStandardTable->setChecked(true); + Measurements(); + } + connect(radioButtonStandardTable, &QRadioButton::clicked, this, &DialogTool::Measurements); + connect(radioButtonIncrements, &QRadioButton::clicked, this, &DialogTool::Increments); + connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines); + connect(radioButtonLengthArc, &QRadioButton::clicked, this, &DialogTool::LengthArcs); + connect(radioButtonLengthCurve, &QRadioButton::clicked, this, &DialogTool::LengthCurves); + connect(radioButtonAngleLine, &QRadioButton::clicked, this, &DialogTool::AngleLines); + connect(checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogTool::Measurements); + } + template + /** + * @brief InitOkCancelApply initialise OK / Cancel and Apply buttons + * @param ui Dialog container + */ + void InitOkCancelApply(T *ui) + { + InitOkCancel(ui); + bApply = ui->buttonBox->button(QDialogButtonBox::Apply); + SCASSERT(bApply != nullptr); + connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply); + } + template + /** + * @brief InitOkCancel initialise OK and Cancel buttons + * @param ui Dialog container + */ + void InitOkCancel(T *ui) + { + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted); + + QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCancel != nullptr); + connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); + } + template + /** + * @brief InitFormulaUI initialise ui object for formula fild + * @param ui Dialog container + */ + void InitFormulaUI(T *ui) + { + labelResultCalculation = ui->labelResultCalculation; + plainTextEditFormula = ui->plainTextEditFormula; + labelEditFormula = ui->labelEditFormula; + } + + void ChangeColor(QWidget *widget, const QColor &color); + void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value); + virtual void ShowVisualization(){} + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(){} + void MoveCursorToEnd(QPlainTextEdit *plainTextEdit); + bool eventFilter(QObject *object, QEvent *event); +private: + void FillList(QComboBox *box, const QMap &list)const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline VAbstractTool *DialogTool::GetAssociatedTool() +{ + return this->associatedTool; +} + +#endif // DIALOGTOOL_H diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp new file mode 100644 index 000000000..a0a21e7a3 --- /dev/null +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -0,0 +1,277 @@ +/************************************************************************ + ** + ** @file dialogtriangle.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "dialogtriangle.h" +#include "ui_dialogtriangle.h" +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistooltriangle.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogTriangle create dialog + * @param data container with data + * @param parent parent widget + */ +DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), axisP1Id(NULL_ID), + axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr) +{ + ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + InitOkCancelApply(ui); + CheckState(); + + FillComboBoxPoints(ui->comboBoxAxisP1); + FillComboBoxPoints(ui->comboBoxAxisP2); + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged); + connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogTriangle::PointNameChanged); + connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), + this, &DialogTriangle::PointNameChanged); + connect(ui->comboBoxAxisP1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogTriangle::PointNameChanged); + connect(ui->comboBoxAxisP2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogTriangle::PointNameChanged); + + line = new VisToolTriangle(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogTriangle::~DialogTriangle() +{ + if (qApp->getCurrentScene()->items().contains(line)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete line; + } + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point) + { + switch (number) + { + case (0): + if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis"))) + { + number++; + line->VisualMode(id); + } + break; + case (1): + if (getCurrentObjectId(ui->comboBoxAxisP1) != id) + { + if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) + { + number++; + line->setPoint2Id(id); + line->RefreshGeometry(); + } + } + break; + case (2): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + line->setHypotenuseP1Id(id); + line->RefreshGeometry(); + } + } + } + break; + case (3): + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(id); + + if (set.size() == 4) + { + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setHypotenuseP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTriangle::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); + secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); + axisP1Id = getCurrentObjectId(ui->comboBoxAxisP1); + axisP2Id = getCurrentObjectId(ui->comboBoxAxisP2); + + line->setPoint1Id(axisP1Id); + line->setPoint2Id(axisP2Id); + line->setHypotenuseP1Id(firstPointId); + line->setHypotenuseP2Id(secondPointId); + line->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTriangle::PointNameChanged() +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + + QColor color = okColor; + if (set.size() < 3)//Need tree or more unique points for creation triangle + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelFirstPoint, color); + ChangeColor(ui->labelSecondPoint, color); + ChangeColor(ui->labelAxisP1, color); + ChangeColor(ui->labelAxisP2, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTriangle::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTriangle::ShowVisualization() +{ + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name of point + * @param value name + */ +void DialogTriangle::setPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setSecondPointId set id of second point + * @param value id + */ +void DialogTriangle::setSecondPointId(const quint32 &value) +{ + setPointId(ui->comboBoxSecondPoint, secondPointId, value); + line->setHypotenuseP2Id(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFirstPointId set id of first point + * @param value id + */ +void DialogTriangle::setFirstPointId(const quint32 &value) +{ + setPointId(ui->comboBoxFirstPoint, firstPointId, value); + line->setHypotenuseP1Id(firstPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAxisP2Id set id second point of axis + * @param value id + */ +void DialogTriangle::setAxisP2Id(const quint32 &value) +{ + setPointId(ui->comboBoxAxisP2, axisP2Id, value); + line->setPoint2Id(axisP2Id); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setAxisP1Id set id first point of axis + * @param value id + */ +void DialogTriangle::setAxisP1Id(const quint32 &value) +{ + setPointId(ui->comboBoxAxisP1, axisP1Id, value); + line->setPoint1Id(axisP1Id); +} diff --git a/src/app/dialogs/tools/dialogtriangle.h b/src/app/dialogs/tools/dialogtriangle.h new file mode 100644 index 000000000..9ca29765c --- /dev/null +++ b/src/app/dialogs/tools/dialogtriangle.h @@ -0,0 +1,149 @@ +/************************************************************************ + ** + ** @file dialogtriangle.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 DIALOGTRIANGLE_H +#define DIALOGTRIANGLE_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogTriangle; +} + +class VisToolTriangle; + +/** + * @brief The DialogTriangle class dialog for ToolTriangle. Help create point and edit option. + */ +class DialogTriangle : public DialogTool +{ + Q_OBJECT +public: + DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogTriangle(); + + quint32 getAxisP1Id() const; + void setAxisP1Id(const quint32 &value); + + quint32 getAxisP2Id() const; + void setAxisP2Id(const quint32 &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + QString getPointName() const; + void setPointName(const QString &value); +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void PointNameChanged(); + virtual void UpdateList(); +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); +private: + Q_DISABLE_COPY(DialogTriangle) + + /** @brief ui keeps information about user interface */ + Ui::DialogTriangle *ui; + + /** @brief number number of handled objects */ + qint32 number; + + /** @brief axisP1Id id first point of axis */ + quint32 axisP1Id; + + /** @brief axisP2Id id second point of axis */ + quint32 axisP2Id; + + /** @brief firstPointId id first point of line */ + quint32 firstPointId; + + /** @brief secondPointId id second point of line */ + quint32 secondPointId; + + VisToolTriangle *line; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAxisP1Id return id first point of axis + * @return id + */ +inline quint32 DialogTriangle::getAxisP1Id() const +{ + return axisP1Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getAxisP2Id return id second point of axis + * @return id + */ +inline quint32 DialogTriangle::getAxisP2Id() const +{ + return axisP2Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFirstPointId return id of first point + * @return id + */ +inline quint32 DialogTriangle::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSecondPointId return id of second point + * @return id + */ +inline quint32 DialogTriangle::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name of point + * @return name + */ +inline QString DialogTriangle::getPointName() const +{ + return pointName; +} + +#endif // DIALOGTRIANGLE_H diff --git a/src/dialogs/dialogtriangle.ui b/src/app/dialogs/tools/dialogtriangle.ui similarity index 58% rename from src/dialogs/dialogtriangle.ui rename to src/app/dialogs/tools/dialogtriangle.ui index 7e788b2f0..f56958fd4 100644 --- a/src/dialogs/dialogtriangle.ui +++ b/src/app/dialogs/tools/dialogtriangle.ui @@ -6,20 +6,24 @@ 0 0 - 267 - 220 + 285 + 212 - Dialog + Triangle + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - + + @@ -27,117 +31,88 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - Name new point + Point label - + - - - - - - + + + + + 0 + 0 + + First point of axis - + First point of line - - - - - - + + + + + 0 + 0 + + Second point of axis - + First point of line - - - - - - + + + + + 0 + 0 + + First point - + First point of line - - - - - - + + + + + 0 + 0 + + Second point - + First point of line @@ -152,13 +127,23 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + + lineEditNamePoint + comboBoxAxisP1 + comboBoxAxisP2 + comboBoxFirstPoint + comboBoxSecondPoint + buttonBox + + + + buttonBox diff --git a/src/app/dialogs/tools/dialoguniondetails.cpp b/src/app/dialogs/tools/dialoguniondetails.cpp new file mode 100644 index 000000000..80b08877c --- /dev/null +++ b/src/app/dialogs/tools/dialoguniondetails.cpp @@ -0,0 +1,168 @@ +/************************************************************************ + ** + ** @file dialoguniondetails.cpp + ** @author Roman Telezhynskyi + ** @date 23 12, 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 + ** 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 "dialoguniondetails.h" +#include "ui_dialoguniondetails.h" +#include "../../geometry/vdetail.h" +#include "../../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogUnionDetails create dialog + * @param data container with data + * @param parent parent widget + */ +DialogUnionDetails::DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(NULL_ID), d2(NULL_ID), + numberD(0), numberP(0), p1(NULL_ID), p2(NULL_ID) +{ + ui->setupUi(this); + InitOkCancel(ui); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogUnionDetails::~DialogUnionDetails() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save correct data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ +void DialogUnionDetails::ChosenObject(quint32 id, const SceneObject &type) +{ + if (numberD == 0) + { + ChoosedDetail(id, type, d1, indexD1); + } + else + { + ChoosedDetail(id, type, d2, indexD2); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogUnionDetails::UpdateList() +{ + /* + * Does nothing. We redefine this slot because it is only one now way block update list of variable. + * This dialog doesn't work with formula. Don't delete. Help avoid crash. + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckObject check if detail contain this id + * @param id id of item + * @param idDetail detail id + * @return true if contain + */ +bool DialogUnionDetails::CheckObject(const quint32 &id, const quint32 &idDetail) const +{ + if (idDetail == 0) + { + return false; + } + VDetail det = data->GetDetail(idDetail); + return det.Containes(id); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedDetail help save information about detail and points on detail + * @param id id selected object + * @param type type selected object + * @param idDetail id detail + * @param index index of edge + */ +void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, + int &index) +{ + if (idDetail == 0) + { + if (type == SceneObject::Detail) + { + idDetail = id; + emit ToolTip(tr("Select first point")); + return; + } + } + if (CheckObject(id, idDetail) == false) + { + return; + } + if (type == SceneObject::Point) + { + if (numberP == 0) + { + p1 = id; + ++numberP; + emit ToolTip(tr("Select second point")); + return; + } + if (numberP == 1) + { + if (id == p1) + { + emit ToolTip(tr("Select another second point")); + return; + } + VDetail d = data->GetDetail(idDetail); + if (d.OnEdge(p1, id)) + { + p2 = id; + index = d.Edge(p1, p2); + ++numberD; + if (numberD > 1) + { + ++numberP; + emit ToolTip(""); + this->setModal(true); + this->show(); + return; + } + else + { + numberP = 0; + p1 = 0; + p2 = 0; + emit ToolTip(tr("Select detail")); + return; + } + } + else + { + emit ToolTip(tr("Select another second point")); + return; + } + } + } +} diff --git a/src/app/dialogs/tools/dialoguniondetails.h b/src/app/dialogs/tools/dialoguniondetails.h new file mode 100644 index 000000000..01aff8904 --- /dev/null +++ b/src/app/dialogs/tools/dialoguniondetails.h @@ -0,0 +1,131 @@ +/************************************************************************ + ** + ** @file dialoguniondetails.h + ** @author Roman Telezhynskyi + ** @date 23 12, 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 + ** 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 DIALOGUNIONDETAILS_H +#define DIALOGUNIONDETAILS_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogUnionDetails; +} + +/** + * @brief The DialogUnionDetails class dialog for ToolUnionDetails. + */ +class DialogUnionDetails : public DialogTool +{ + Q_OBJECT +public: + DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogUnionDetails(); + + quint32 getD1() const; + quint32 getD2() const; + int getIndexD1() const; + int getIndexD2() const; +public slots: + void ChosenObject(quint32 id, const SceneObject &type); + virtual void UpdateList(); +private: + Q_DISABLE_COPY(DialogUnionDetails) + + /** @brief ui keeps information about user interface */ + Ui::DialogUnionDetails *ui; + + /** @brief indexD1 index edge first detail */ + int indexD1; + + /** @brief indexD2 index edge second detail */ + int indexD2; + + /** @brief d1 id first detail */ + quint32 d1; + + /** @brief d2 id second detail */ + quint32 d2; + + /** @brief numberD number of detail, what we already have */ + qint32 numberD; + + /** @brief numberP number of points, what we already have */ + qint32 numberP; + + /** @brief p1 id first point of detail */ + quint32 p1; + + /** @brief p2 id second point of detail */ + quint32 p2; + + bool CheckObject(const quint32 &id, const quint32 &idDetail) const; + void ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, + int &index); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getD1 return id first detail + * @return id + */ +inline quint32 DialogUnionDetails::getD1() const +{ + return d1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getD2 return id second detail + * @return id + */ +inline quint32 DialogUnionDetails::getD2() const +{ + return d2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getIndexD1 return index edge first detail + * @return index + */ +inline int DialogUnionDetails::getIndexD1() const +{ + return indexD1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getIndexD2 return index edge second detail + * @return index + */ +inline int DialogUnionDetails::getIndexD2() const +{ + return indexD2; +} + +#endif // DIALOGUNIONDETAILS_H diff --git a/src/dialogs/dialogline.ui b/src/app/dialogs/tools/dialoguniondetails.ui similarity index 56% rename from src/dialogs/dialogline.ui rename to src/app/dialogs/tools/dialoguniondetails.ui index b575f1d52..4729a4b5a 100644 --- a/src/dialogs/dialogline.ui +++ b/src/app/dialogs/tools/dialoguniondetails.ui @@ -1,53 +1,47 @@ - DialogLine - + DialogUnionDetails + + + Qt::NonModal + 0 0 - 217 - 137 + 244 + 78 + + + 244 + 78 + + + + + 244 + 78 + + - Line + Union details - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - + + false - - - - - First point - - - - - - - - - - - - - - Second point - - - - - - - + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + @@ -62,18 +56,16 @@ - comboBoxFirstPoint - comboBoxSecondPoint buttonBox - + buttonBox accepted() - DialogLine + DialogUnionDetails accept() @@ -89,7 +81,7 @@ buttonBox rejected() - DialogLine + DialogUnionDetails reject() diff --git a/doc/doxygen/Doxyfile b/src/app/doc/doxygen/Doxyfile similarity index 99% rename from doc/doxygen/Doxyfile rename to src/app/doc/doxygen/Doxyfile index 8f5c380a7..c640e0748 100644 --- a/doc/doxygen/Doxyfile +++ b/src/app/doc/doxygen/Doxyfile @@ -34,7 +34,7 @@ PROJECT_NAME = "Valentina" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.2 +PROJECT_NUMBER = 0.2.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -188,7 +188,7 @@ SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. -TAB_SIZE = 8 +TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". @@ -310,7 +310,7 @@ SUBGROUPING = YES # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). -INLINE_GROUPED_CLASSES = NO +INLINE_GROUPED_CLASSES = YES # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields or simple typedef fields will be shown @@ -601,7 +601,7 @@ CITE_BIB_FILES = # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. -QUIET = YES +QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank @@ -672,7 +672,7 @@ INPUT_ENCODING = UTF-8 # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl -FILE_PATTERNS = *.h +FILE_PATTERNS = *.h *.cpp # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -790,24 +790,24 @@ USE_MDFILE_AS_MAINPAGE = # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. -INLINE_SOURCES = NO +INLINE_SOURCES = YES # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. -STRIP_CODE_COMMENTS = YES +STRIP_CODE_COMMENTS = NO # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. -REFERENCED_BY_RELATION = NO +REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities @@ -1445,7 +1445,7 @@ MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) -MAN_EXTENSION = .3 +MAN_EXTENSION = .1 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity diff --git a/src/app/doc/doxygen/logo.png b/src/app/doc/doxygen/logo.png new file mode 100644 index 000000000..6813b0cfd Binary files /dev/null and b/src/app/doc/doxygen/logo.png differ diff --git a/src/app/geometry/geometry.pri b/src/app/geometry/geometry.pri new file mode 100644 index 000000000..708385de8 --- /dev/null +++ b/src/app/geometry/geometry.pri @@ -0,0 +1,34 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vsplinepoint.h \ + $$PWD/vsplinepath.h \ + $$PWD/vspline.h \ + $$PWD/vnodedetail.h \ + $$PWD/vdetail.h \ + $$PWD/varc.h \ + $$PWD/vgobject.h \ + $$PWD/vpointf.h \ + $$PWD/vequidistant.h \ + $$PWD/vabstractcurve.h \ + $$PWD/vnodedetail_p.h \ + $$PWD/vdetail_p.h \ + $$PWD/vgobject_p.h \ + $$PWD/varc_p.h \ + $$PWD/vspline_p.h \ + $$PWD/vsplinepoint_p.h \ + $$PWD/vsplinepath_p.h \ + $$PWD/vpointf_p.h + +SOURCES += \ + $$PWD/vsplinepoint.cpp \ + $$PWD/vsplinepath.cpp \ + $$PWD/vspline.cpp \ + $$PWD/vnodedetail.cpp \ + $$PWD/vdetail.cpp \ + $$PWD/varc.cpp \ + $$PWD/vgobject.cpp \ + $$PWD/vpointf.cpp \ + $$PWD/vequidistant.cpp \ + $$PWD/vabstractcurve.cpp diff --git a/src/app/geometry/vabstractcurve.cpp b/src/app/geometry/vabstractcurve.cpp new file mode 100644 index 000000000..423aac8c2 --- /dev/null +++ b/src/app/geometry/vabstractcurve.cpp @@ -0,0 +1,211 @@ +/************************************************************************ + ** + ** @file vabstractcurve.cpp + ** @author Roman Telezhynskyi + ** @date 25 6, 2014 + ** + ** @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) 2014 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 "vabstractcurve.h" + +#include +#include + +VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) + :VGObject(type, idObject, mode) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve) + :VGObject(curve) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve) +{ + if ( &curve == this ) + { + return *this; + } + VGObject::operator=(curve); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse) const +{ + QVector points = GetPoints(); + if (reverse) + { + points = GetReversePoints(points); + } + points = FromBegin(points, begin); + points = ToEnd(points, end); + return points; +} + + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractCurve::FromBegin(const QVector &points, const QPointF &begin) +{ + if (points.count() >= 2) + { + QVector segment; + bool theBegin = false; + for (qint32 i = 0; i < points.count()-1; ++i) + { + if (theBegin == false) + { + if (PointInSegment(begin, points.at(i), points.at(i+1))) + { + theBegin = true; + segment.append(begin); + if (i == points.count()-2) + { + segment.append(points.at(i+1)); + } + continue; + } + } + else + { + segment.append(points.at(i)); + if (i == points.count()-2) + { + segment.append(points.at(i+1)); + } + } + } + + if (segment.isEmpty()) + { + return points; + } + else + { + return segment; + } + } + else + { + return points; + } + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractCurve::ToEnd(const QVector &points, const QPointF &end) const +{ + QVector reversed = GetReversePoints(points); + reversed = FromBegin(reversed, end); + return GetReversePoints(reversed); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VAbstractCurve::GetPath(PathDirection direction) const +{ + QPainterPath path; + + QVector points = GetPoints(); + if (points.count() >= 2) + { + for (qint32 i = 0; i < points.count()-1; ++i) + { + path.moveTo(points.at(i)); + path.lineTo(points.at(i+1)); + } + + if (direction == PathDirection::Show && points.count() >= 3) + { + path.addPath(ShowDirection(points)); + } + } + else + { + qDebug()<<"points.count() < 2"< VAbstractCurve::IntersectLine(const QLineF &line) const +{ + QVector points = this->GetPoints(); + QVector intersections; + for ( qint32 i = 0; i < points.count()-1; ++i ) + { + QPointF crosPoint; + QLineF::IntersectType type = line.intersect(QLineF ( points.at(i), points.at(i+1)), &crosPoint); + if ( type == QLineF::BoundedIntersection ) + { + intersections.append(crosPoint); + } + } + return intersections; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VAbstractCurve::ShowDirection(const QVector &points) const +{ + QPainterPath path; + + if (points.count() >= 2) + { + /*Need find coordinate midle of curve. + Universal way is take all points and find sum.*/ + const qreal seek_length = GetLength()/2.0; + qreal found_length = 0; + QLineF arrow; + for (qint32 i = 1; i <= points.size()-1; ++i) + { + arrow = QLineF(points.at(i-1), points.at(i)); + found_length += arrow.length();//Length that we aready find + + if (seek_length <= found_length)// if have found more that need stop. + { + //subtract length in last line and you will find position of the middle point. + arrow.setLength(arrow.length() - (found_length - seek_length)); + break; + } + } + + //Reverse line because we want start arrow from this point + arrow = QLineF(arrow.p2(), arrow.p1()); + const qreal angle = arrow.angle();//we each time change line angle, better save original angle value + arrow.setLength(14);//arrow length in pixels + + arrow.setAngle(angle-35); + path.moveTo(arrow.p1()); + path.lineTo(arrow.p2()); + + arrow.setAngle(angle+35); + path.moveTo(arrow.p1()); + path.lineTo(arrow.p2()); + } + return path; +} diff --git a/src/app/geometry/vabstractcurve.h b/src/app/geometry/vabstractcurve.h new file mode 100644 index 000000000..057424687 --- /dev/null +++ b/src/app/geometry/vabstractcurve.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vabstractcurve.h + ** @author Roman Telezhynskyi + ** @date 25 6, 2014 + ** + ** @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) 2014 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 VABSTRACTCURVE_H +#define VABSTRACTCURVE_H + +#include "vgobject.h" +#include + +enum class PathDirection : char { Hide, Show }; + +class QPainterPath; +class QLineF; + +class VAbstractCurve :public VGObject +{ +public: + VAbstractCurve(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation); + VAbstractCurve(const VAbstractCurve &curve); + VAbstractCurve& operator= (const VAbstractCurve &curve); + + virtual QVector GetPoints() const =0; + QVector GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse = false) const; + + virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const; + virtual qreal GetLength() const =0; + virtual QVector IntersectLine(const QLineF &line) const; +protected: + QPainterPath ShowDirection(const QVector &points) const; +private: + static QVector FromBegin(const QVector &points, const QPointF &begin); + QVector ToEnd(const QVector &points, const QPointF &end) const; +}; + +#endif // VABSTRACTCURVE_H diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp new file mode 100644 index 000000000..2f9c434b8 --- /dev/null +++ b/src/app/geometry/varc.cpp @@ -0,0 +1,340 @@ +/************************************************************************ + ** + ** @file varc.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "varc.h" +#include "varc_p.h" +#include +#include +#include +#include +#include + +#include "../container/vformula.h" + + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VArc default constructor. + */ +VArc::VArc () + :VAbstractCurve(GOType::Arc), d (new VArcData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VArc constructor. + * @param center center point. + * @param radius arc radius. + * @param f1 start angle (degree). + * @param f2 end angle (degree). + */ +VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, + QString formulaF2, quint32 idObject, Draw mode) + : VAbstractCurve(GOType::Arc, idObject, mode), + d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2)) +{ + setName(QString (arc_+"%1").arg(this->GetCenter().name())); +} + +//--------------------------------------------------------------------------------------------------------------------- +VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2) + : VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2)) +{ + setName(QString (arc_+"%1").arg(this->GetCenter().name())); + d->formulaF1 = QString("%1").arg(f1); + d->formulaF2 = QString("%1").arg(f2); + d->formulaRadius = QString("%1").arg(radius); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VArc copy constructor + * @param arc arc + */ +VArc::VArc(const VArc &arc) + : VAbstractCurve(arc), d (arc.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator + * @param arc arc + * @return arc + */ +VArc &VArc::operator =(const VArc &arc) +{ + if ( &arc == this ) + { + return *this; + } + VAbstractCurve::operator=(arc); + d = arc.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VArc::~VArc() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetLength return arc length. + * @return length. + */ +qreal VArc::GetLength() const +{ + return (M_PI * d->radius)/180 * AngleArc(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1 return point associated with start angle. + * @return point. + */ +QPointF VArc::GetP1() const +{ + QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () ); + QLineF centerP1(GetCenter().toQPointF(), p1); + centerP1.setAngle(d->f1); + return centerP1.p2(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2 return point associated with end angle. + * @return точку point. + */ +QPointF VArc::GetP2 () const +{ + QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () ); + QLineF centerP2(GetCenter().toQPointF(), p2); + centerP2.setAngle(d->f2); + return centerP2.p2(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AngleArc calculate arc angle. + * @return angle in degree. + */ +qreal VArc::AngleArc() const +{ + if ((qFuzzyCompare(d->f1+1, 0+1) && qFuzzyCompare(d->f2, 360)) || + (qFuzzyCompare(d->f1, 360) && qFuzzyCompare(d->f2+1, 0+1))) + { + return 360; + } + QLineF l1(0, 0, 100, 100); + l1.setAngle(d->f1); + QLineF l2(0, 0, 100, 100); + l2.setAngle(d->f2); + return l1.angleTo(l2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetPoints return list of points needed for drawing arc. + * @return list of points + */ +QVector VArc::GetPoints() const +{ + QVector points; + qreal i = 0; + qreal angle = AngleArc(); + qint32 k = static_cast(angle); + qreal s = angle/(k/4); + do + { + QLineF line(d->center.toQPointF(), GetP1()); + line.setAngle(line.angle()+i); + points.append(line.p2()); + i = i + s; + if (i > angle) + { + QLineF line(d->center.toQPointF(), GetP1()); + line.setAngle(line.angle()+angle); + points.append(line.p2()); + } + } while (i <= angle); + // Detail points clockwise, but arc we draw counterclockwise. Main contour need reverse. + return GetReversePoints(points); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CutArc cut arc into two arcs. + * @param length length first arc. + * @param arc1 first arc. + * @param arc2 second arc. + * @return point cutting + */ +QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const +{ + //Always need return two arcs, so we must correct wrong length. + qreal len = 0; + if (length < this->GetLength()*0.02) + { + len = this->GetLength()*0.02; + } + else if ( length > this->GetLength()*0.98) + { + len = this->GetLength()*0.98; + } + else + { + len = length; + } + + qreal n = (len*180)/(M_PI*d->radius); + QLineF line(GetCenter().toQPointF(), GetP1()); + line.setAngle(line.angle()+n); + + arc1 = VArc (d->center, d->radius, d->formulaRadius, d->f1, d->formulaF1, line.angle(), + QString().setNum(line.angle()), getIdObject(), getMode()); + + arc2 = VArc (d->center, d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), d->f2, + d->formulaF2, getIdObject(), getMode()); + return line.p2(); +} + + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VArc::CutArc(const qreal &length) const +{ + VArc arc1; + VArc arc2; + return this->CutArc(length, arc1, arc2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId keep id arc in data. + * @param id id arc in data. + */ +void VArc::setId(const quint32 &id) +{ + VAbstractCurve::setId(id); + setName(QString (arc_+"%1_%2").arg(d->center.name()).arg(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF1 return start angle. + * @return angle in degree. + */ +QString VArc::GetFormulaF1() const +{ + return d->formulaF1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VArc::SetFormulaF1(const VFormula &value) +{ + d->formulaF1 = value.getFormula(FormulaType::FromUser); + d->f1 = value.getDoubleValue(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF1 return formula for start angle. + * @return string with formula. + */ +qreal VArc::GetF1() const +{ + return d->f1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF2 return end angle. + * @return angle in degree. + */ +QString VArc::GetFormulaF2() const +{ + return d->formulaF2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VArc::SetFormulaF2(const VFormula &value) +{ + d->formulaF2 = value.getFormula(FormulaType::FromUser); + d->f2 = value.getDoubleValue(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF2 return formula for end angle. + * @return string with formula. + */ +qreal VArc::GetF2() const +{ + return d->f2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetRadius return arc radius. + * @return radius. + */ +QString VArc::GetFormulaRadius() const +{ + return d->formulaRadius; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VArc::SetFormulaRadius(const VFormula &value) +{ + d->formulaRadius = value.getFormula(FormulaType::FromUser); + d->radius = value.getDoubleValue(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetRadius return formula for radius. + * @return string with formula. + */ +qreal VArc::GetRadius() const +{ + return d->radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetCenter return center point. + * @return center point. + */ +VPointF VArc::GetCenter() const +{ + return d->center; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VArc::SetCenter(const VPointF &value) +{ + d->center = value; +} diff --git a/src/app/geometry/varc.h b/src/app/geometry/varc.h new file mode 100644 index 000000000..53003724f --- /dev/null +++ b/src/app/geometry/varc.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file varc.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VARC_H +#define VARC_H + +#include "vabstractcurve.h" +#include "vpointf.h" +#include + +class QPainterPath; +class VArcData; +class VFormula; + +/** + * @brief VArc class for anticlockwise arc. + */ +class VArc: public VAbstractCurve +{ + Q_DECLARE_TR_FUNCTIONS(VArc) +public: + VArc (); + VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, + QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation); + VArc (VPointF center, qreal radius, qreal f1, qreal f2); + VArc(const VArc &arc); + VArc& operator= (const VArc &arc); + virtual ~VArc(); + + QString GetFormulaF1 () const; + void SetFormulaF1 (const VFormula &value); + qreal GetF1 () const; + + QString GetFormulaF2 () const; + void SetFormulaF2 (const VFormula &value); + qreal GetF2 () const; + + QString GetFormulaRadius () const; + void SetFormulaRadius (const VFormula &value); + qreal GetRadius () const; + + VPointF GetCenter () const; + void SetCenter (const VPointF &value); + + qreal GetLength () const; + QPointF GetP1() const; + QPointF GetP2 () const; + qreal AngleArc() const; + QVector GetPoints () const; + QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const; + QPointF CutArc (const qreal &length) const; + virtual void setId(const quint32 &id); +private: + QSharedDataPointer d; +}; + +#endif // VARC_H diff --git a/src/app/geometry/varc_p.h b/src/app/geometry/varc_p.h new file mode 100644 index 000000000..dd56deb94 --- /dev/null +++ b/src/app/geometry/varc_p.h @@ -0,0 +1,97 @@ +/************************************************************************ + ** + ** @file varc_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VARC_P_H +#define VARC_P_H + +#include +#include "../options.h" +#include "vpointf.h" + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VArcData : public QSharedData +{ +public: + + VArcData () + : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), + center(VPointF()) + {} + + VArcData (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, + QString formulaF2) + : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), + center(center) + {} + + VArcData(VPointF center, qreal radius, qreal f1, qreal f2) + : f1(f1), formulaF1(QString("%1").arg(f1)), f2(f2), formulaF2(QString("%1").arg(f2)), radius(radius), + formulaRadius(QString("%1").arg(radius)), center(center) + {} + + VArcData(const VArcData &arc) + : QSharedData(arc), f1(arc.f1), formulaF1(arc.formulaF1), f2(arc.f2), formulaF2(arc.formulaF2), + radius(arc.radius), formulaRadius(arc.formulaRadius), center(arc.center) + {} + + virtual ~VArcData(); + + /** @brief f1 start angle in degree. */ + qreal f1; + + /** @brief formulaF1 formula for start angle. */ + QString formulaF1; + + /** @brief f2 end angle in degree. */ + qreal f2; + + /** @brief formulaF2 formula for end angle. */ + QString formulaF2; + + /** @brief radius arc radius. */ + qreal radius; + + /** @brief formulaRadius formula for arc radius. */ + QString formulaRadius; + + /** @brief center center point of arc. */ + VPointF center; +}; + +VArcData::~VArcData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VARC_P_H diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp new file mode 100644 index 000000000..d0322f4d3 --- /dev/null +++ b/src/app/geometry/vdetail.cpp @@ -0,0 +1,399 @@ +/************************************************************************ + ** + ** @file vdetail.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vdetail.h" +#include "vdetail_p.h" +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +VDetail::VDetail() + :d(new VDetailData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VDetail::VDetail(const QString &name, const QVector &nodes) + :d(new VDetailData(name, nodes)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VDetail::VDetail(const VDetail &detail) + :d (detail.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VDetail &VDetail::operator =(const VDetail &detail) +{ + if ( &detail == this ) + { + return *this; + } + d = detail.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VDetail::~VDetail() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::Clear() +{ + d->nodes.clear(); + d->name.clear(); + d->mx = 0; + d->my = 0; + d->seamAllowance = true; + d->closed = true; + d->width = 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::ClearNodes() +{ + d->nodes.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDetail::Containes(const quint32 &id) const +{ + for (int i = 0; i < d->nodes.size(); ++i) + { + VNodeDetail node = d->nodes.at(i); + if (node.getId() == id) + { + return true; + } + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail &VDetail::operator [](int indx) +{ + return d->nodes[indx]; +} + +//--------------------------------------------------------------------------------------------------------------------- +const VNodeDetail &VDetail::at(int indx) const +{ + return d->nodes.at(indx); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VDetail::indexOfNode(const quint32 &id) const +{ + return indexOfNode(d->nodes, id); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VDetail::id() const +{ + return d->_id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setId(const quint32 &id) +{ + d->_id = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const +{ + QVector list = listNodePoint(); + if (list.size() < 3) + { + qDebug()<<"Not enough points."; + return false; + } + int i = indexOfNode(list, p1); + int j1 = 0, j2 = 0; + + if (i == list.size() - 1) + { + j1 = i-1; + j2 = 0; + } + else if (i == 0) + { + j1 = list.size() - 1; + j2 = i + 1; + } + else + { + j1 = i - 1; + j2 = i + 1; + } + + if (list.at(j1).getId() == p2 || list.at(j2).getId() == p2) + { + return true; + } + else + { + return false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +int VDetail::Edge(const quint32 &p1, const quint32 &p2) const +{ + if (OnEdge(p1, p2) == false) + { + qDebug()<<"Points don't on edge."; + return -1; + } + + QVector list = listNodePoint(); + int i = indexOfNode(list, p1); + int j = indexOfNode(list, p2); + + int min = qMin(i, j); + + if (min == 0 && (i == list.size() - 1 || j == list.size() - 1)) + { + return list.size() - 1; + } + else + { + return min; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2) const +{ + QVector list = listNodePoint(); + if (index > static_cast(list.size())) + { + qDebug()<<"Wrong edge index index ="<(index)); + if (index + 1 > static_cast(list.size()) - 1) + { + p2 = list.at(0); + } + else + { + p2 = list.at(static_cast(index+1)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VDetail VDetail::RemoveEdge(const quint32 &index) const +{ + VDetail det(*this); + det.ClearNodes(); + + QVector list = this->listNodePoint(); + quint32 edge = static_cast(list.size()); + quint32 k = 0; + for (quint32 i=0; iat(static_cast(k))); + ++k; + } + else + { + VNodeDetail p1; + VNodeDetail p2; + this->NodeOnEdge(i, p1, p2); + int j1 = this->indexOfNode(p1.getId()); + int j2 = this->indexOfNode(p2.getId()); + if (j2 == 0) + { + j2 = this->CountNode()-1; + if (j1 == j2) + { + det.append(this->at(j1)); + ++k; + continue; + } + } + for (int j=j1; jat(j)); + ++k; + } + } + } + return det; +} + +//--------------------------------------------------------------------------------------------------------------------- +QList VDetail::Missing(const VDetail &det) const +{ + if (d->nodes.size() == det.CountNode()) + { + return QList(); + } + + QSet set1; + for (qint32 i = 0; i < d->nodes.size(); ++i) + { + set1.insert(d->nodes.at(i).getId()); + } + + QSet set2; + for (qint32 j = 0; j < det.CountNode(); ++j) + { + set2.insert(det.at(j).getId()); + } + + QSet set3 = set1.subtract(set2); + + return set3.toList(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VDetail::listNodePoint() const +{ + QVector list; + for (int i = 0; i < d->nodes.size(); ++i) + { + if (d->nodes.at(i).getTypeTool() == Tool::NodePoint) + { + list.append(d->nodes.at(i)); + } + } + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VDetail::indexOfNode(const QVector &list, const quint32 &id) +{ + for (int i = 0; i < list.size(); ++i) + { + if (list.at(i).getId() == id) + { + return i; + } + } + qDebug()<<"Can't find node."; + return -1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::append(const VNodeDetail &node) +{ + d->nodes.append(node); +} + +//--------------------------------------------------------------------------------------------------------------------- +qint32 VDetail::CountNode() const +{ + return d->nodes.size(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VDetail::getName() const +{ + return d->name; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setName(const QString &value) +{ + d->name = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VDetail::getMx() const +{ + return d->mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setMx(const qreal &value) +{ + d->mx = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VDetail::getMy() const +{ + return d->my; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setMy(const qreal &value) +{ + d->my = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDetail::getSeamAllowance() const +{ + return d->seamAllowance; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setSeamAllowance(bool value) +{ + d->seamAllowance = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDetail::getClosed() const +{ + return d->closed; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setClosed(bool value) +{ + d->closed = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VDetail::getWidth() const +{ + return d->width; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setWidth(const qreal &value) +{ + d->width = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VDetail::getNodes() const +{ + return d->nodes; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::setNodes(const QVector &value) +{ + d->nodes = value; +} diff --git a/src/app/geometry/vdetail.h b/src/app/geometry/vdetail.h new file mode 100644 index 000000000..50a3ac12c --- /dev/null +++ b/src/app/geometry/vdetail.h @@ -0,0 +1,241 @@ +/************************************************************************ + ** + ** @file vdetail.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VDETAIL_H +#define VDETAIL_H + +#include "vnodedetail.h" +#include +#include + +class QString; +class VDetailData; + +/** + * @brief The VDetail class for path of object (points, arcs, splines). + */ +class VDetail +{ +public: + /** + * @brief VDetail default contructor. Create empty detail. + */ + VDetail(); + /** + * @brief VDetail constructor. + * @param name detail name. + * @param nodes list of nodes. + */ + VDetail(const QString &name, const QVector &nodes); + /** + * @brief VDetail copy constructor. + * @param detail detail. + */ + VDetail(const VDetail &detail); + /** + * @brief operator = assignment operator. + * @param detail detail. + * @return new detail. + */ + VDetail &operator=(const VDetail &detail); + ~VDetail(); + /** + * @brief append append in the end of list node. + * @param node new node. + */ + void append(const VNodeDetail &node); + /** + * @brief Clear detail full clear. + */ + void Clear(); + /** + * @brief ClearNodes clear list of nodes. + */ + void ClearNodes(); + /** + * @brief CountNode return count nodes. + * @return count. + */ + qint32 CountNode() const; + /** + * @brief Containes check if detail containe this id. + * @param id object id. + * @return true if containe. + */ + bool Containes(const quint32 &id)const; + /** + * @brief operator [] find node by index in list. + * @param indx index node in list. + * @return node + */ + VNodeDetail & operator[](int indx); + /** + * @brief at find node by index in list. + * @param indx index node in list. + * @return const node. + */ + const VNodeDetail & at ( int indx ) const; + /** + * @brief getName return detail name. + * @return name. + */ + QString getName() const; + /** + * @brief setName set detail name. + * @param value new name. + */ + void setName(const QString &value); + /** + * @brief getMx return bias for X axis. + * @return x bias. + */ + qreal getMx() const; + /** + * @brief setMx set bias for X axis. + * @param value new x bias. + */ + void setMx(const qreal &value); + /** + * @brief getMy get bias for y axis. + * @return y axis. + */ + qreal getMy() const; + /** + * @brief setMy set bias for y axis. + * @param value new y bias. + */ + void setMy(const qreal &value); + /** + * @brief getSeamAllowance keep status for seam allowance detail. + * @return true - need seam allowance, false - no need seam allowance. + */ + bool getSeamAllowance() const; + /** + * @brief setSeamAllowance set status for seam allowance detail. + * @param value true - need seam allowance, false - no need seam allowance. + */ + void setSeamAllowance(bool value); + /** + * @brief getClosed keep close status for detail equdistant. + * @return true - close equdistant, false - don't close equdistant. + */ + bool getClosed() const; + /** + * @brief setClosed set close status for detail equdistant. + * @param value true - close equdistant, false - don't close equdistant. + */ + void setClosed(bool value); + /** + * @brief getWidth return value detail seam allowance. + * @return value in mm. + */ + qreal getWidth() const; + /** + * @brief setWidth set value detail seam allowance. + * @param value width in mm. + */ + void setWidth(const qreal &value); + /** + * @brief getNodes return list of nodes. + * @return list of nodes. + */ + QVector getNodes() const; + /** + * @brief setNodes set list of nodes + * @param value list of nodes + */ + void setNodes(const QVector &value); + /** + * @brief indexOfNode return index in list node using id object. + * @param id object (arc, point, spline, splinePath) id. + * @return index in list or -1 id can't find. + */ + int indexOfNode(const quint32 &id) const; + /** + * @brief id return id detail in list data. + * @return id. + */ + quint32 id() const; + /** + * @brief setId set id detail in list data. + * @param id detail id. + */ + void setId(const quint32 &id); + /** + * @brief OnEdge checks if two poins located on the edge. Edge is line between two points. If between two points + * located arcs or splines ignore this. + * @param p1 id first point. + * @param p2 id second point. + * @return true - on edge, false - no. + */ + bool OnEdge(const quint32 &p1, const quint32 &p2)const; + /** + * @brief Edge return edge index in detail. Edge is line between two points. If between two points + * located arcs or splines ignore this. + * @param p1 id first point. + * @param p2 id second point. + * @return edge index or -1 if points don't located on edge + */ + int Edge(const quint32 &p1, const quint32 &p2)const; + /** + * @brief NodeOnEdge return nodes located on edge with index. + * @param index index of edge. + * @param p1 first node. + * @param p2 second node. + */ + void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const; + /** + * @brief RemoveEdge return detail without edge with index. + * @param index idex of edge. + * @return detail without edge with index. + */ + VDetail RemoveEdge(const quint32 &index) const; + /** + * @brief Missing find missing ids in detail. When we deleted object in detail and return this detail need + * understand, what nodes need make invisible. + * @param det changed detail. + * @return list with missing detail. + */ + QList Missing(const VDetail &det) const; +private: + QSharedDataPointer d; + /** + * @brief listNodePoint return list nodes only with points. + * @return list points node. + */ + QVector listNodePoint()const; + /** + * @brief indexOfNode return index in list node using id object. + * @param list list nodes detail. + * @param id object (arc, point, spline, splinePath) id. + * @return index in list or -1 id can't find. + */ + static int indexOfNode(const QVector &list, const quint32 &id); +}; + +#endif // VDETAIL_H diff --git a/src/app/geometry/vdetail_p.h b/src/app/geometry/vdetail_p.h new file mode 100644 index 000000000..cfb880992 --- /dev/null +++ b/src/app/geometry/vdetail_p.h @@ -0,0 +1,98 @@ +/************************************************************************ + ** + ** @file vdetail_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VDETAIL_P_H +#define VDETAIL_P_H + +#include +#include "../options.h" +#include "vnodedetail.h" + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VDetailData : public QSharedData +{ +public: + VDetailData() + :_id(NULL_ID), nodes(QVector()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true), + width(0) + {} + + VDetailData(const QString &name, const QVector &nodes) + :_id(NULL_ID), nodes(nodes), name(name), mx(0), my(0), seamAllowance(true), closed(true), width(0) + {} + + VDetailData(const VDetailData &detail) + :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), name(detail.name), mx(detail.mx), my(detail.my), + seamAllowance(detail.seamAllowance), closed(detail.closed), width(detail.width) + {} + + ~VDetailData() {} + + /** + * @brief _id id detail. + */ + quint32 _id; + /** + * @brief nodes list detail nodes. + */ + QVector nodes; + /** + * @brief name detail name. + */ + QString name; + /** + * @brief mx bias x axis. + */ + qreal mx; + /** + * @brief my bias y axis. + */ + qreal my; + /** + * @brief seamAllowance status seamAllowance detail. + */ + bool seamAllowance; + /** + * @brief closed status equdistant detail. + */ + bool closed; + /** + * @brief width value seamAllowance in mm. + */ + qreal width; +}; + +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif + +#endif // VDETAIL_P_H diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp new file mode 100644 index 000000000..16ed9a8aa --- /dev/null +++ b/src/app/geometry/vequidistant.cpp @@ -0,0 +1,444 @@ +/************************************************************************ + ** + ** @file vequidistant.cpp + ** @author Roman Telezhynskyi + ** @date 28 1, 2014 + ** + ** @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 + ** 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 "varc.h" +#include "vequidistant.h" +#include "vpointf.h" +#include "vspline.h" +#include "vsplinepath.h" +#include "../core/vapplication.h" +#include +#include +#include "../container/vcontainer.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +VEquidistant::VEquidistant(const VContainer *data) + :data(data) +{ + SCASSERT(data != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VEquidistant::ContourPath(const quint32 &idDetail) const +{ + SCASSERT(data != nullptr); + VDetail detail = data->GetDetail(idDetail); + QVector points; + QVector pointsEkv; + for (int i = 0; i< detail.CountNode(); ++i) + { + switch (detail.at(i).getTypeTool()) + { + case (Tool::NodePoint): + { + const QSharedPointer point = data->GeometricObject(detail.at(i).getId()); + points.append(point->toQPointF()); + if (detail.getSeamAllowance() == true) + { + QPointF pEkv = point->toQPointF(); + pEkv.setX(pEkv.x()+detail.at(i).getMx()); + pEkv.setY(pEkv.y()+detail.at(i).getMy()); + pointsEkv.append(pEkv); + } + } + break; + case (Tool::NodeArc): + case (Tool::NodeSpline): + case (Tool::NodeSplinePath): + { + const QSharedPointer curve=data->GeometricObject(detail.at(i).getId()); + + const QPointF begin = StartSegment(detail, i); + const QPointF end = EndSegment(detail, i); + + QVector nodePoints = curve->GetSegmentPoints(begin, end, detail.at(i).getReverse()); + points << nodePoints; + if (detail.getSeamAllowance() == true) + { + pointsEkv << biasPoints(nodePoints, detail.at(i).getMx(), detail.at(i).getMy()); + } + } + break; + default: + qDebug()<<"Get wrong tool type. Ignore."<< static_cast(detail.at(i).getTypeTool()); + break; + } + } + + QPainterPath path; + path.moveTo(points[0]); + for (qint32 i = 1; i < points.count(); ++i) + { + path.lineTo(points.at(i)); + } + path.lineTo(points.at(0)); + + pointsEkv = CorrectEquidistantPoints(pointsEkv); + pointsEkv = CheckLoops(pointsEkv); + + if (detail.getSeamAllowance() == true) + { + QPainterPath ekv; + if (detail.getClosed() == true) + { + ekv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(detail.getWidth())); + } + else + { + ekv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(detail.getWidth())); + } + path.addPath(ekv); + path.setFillRule(Qt::WindingFill); + } + return path; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VEquidistant::StartSegment(const VDetail &detail, const int &i) const +{ + QPointF begin; + if (detail.CountNode() > 1) + { + if (i == 0) + { + if (detail.at(detail.CountNode()-1).getTypeTool() == Tool::NodePoint) + { + begin = data->GeometricObject(detail.at(detail.CountNode()-1).getId())->toQPointF(); + } + } + else + { + if (detail.at(i-1).getTypeTool() == Tool::NodePoint) + { + begin = data->GeometricObject(detail.at(i-1).getId())->toQPointF(); + } + } + } + return begin; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VEquidistant::EndSegment(const VDetail &detail, const int &i) const +{ + QPointF end; + if (detail.CountNode() > 2) + { + if (i == detail.CountNode() - 1) + { + if (detail.at(0).getTypeTool() == Tool::NodePoint) + { + end = data->GeometricObject(detail.at(0).getId())->toQPointF(); + } + } + else + { + if (detail.at(i+1).getTypeTool() == Tool::NodePoint) + { + end = data->GeometricObject(detail.at(i+1).getId())->toQPointF(); + } + } + } + return end; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VEquidistant::biasPoints(const QVector &points, const qreal &mx, const qreal &my) +{ + QVector p; + for (qint32 i = 0; i < points.size(); ++i) + { + QPointF point = points.at(i); + point.setX(point.x() + mx); + point.setY(point.y() + my); + p.append(point); + } + return p; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VEquidistant::CorrectEquidistantPoints(const QVector &points) +{ + QVector correctPoints; + if (points.size()<4)//Better don't check if only three points. We can destroy equidistant. + { + qDebug()<<"Only three points."; + return points; + } + //Clear equivalent points + for (qint32 i = 0; i points, const EquidistantType &eqv, const qreal &width) +{ + QPainterPath ekv; + QVector ekvPoints; + if ( points.size() < 3 ) + { + qDebug()<<"Not enough points for building the equidistant.\n"; + return ekv; + } + if (width <= 0) + { + qDebug()<<"Width <= 0.\n"; + return ekv; + } + for (qint32 i = 0; i < points.size(); ++i ) + { + if (i != points.size()-1) + { + if (points.at(i) == points.at(i+1)) + { + points.remove(i+1); + } + } + else + { + if (points.at(i) == points.at(0)) + { + points.remove(i); + } + } + } + if (eqv == EquidistantType::CloseEquidistant) + { + points.append(points.at(0)); + } + for (qint32 i = 0; i < points.size(); ++i ) + { + if ( i == 0 && eqv == EquidistantType::CloseEquidistant) + {//first point, polyline closed + ekvPoints< VEquidistant::CheckLoops(const QVector &points) +{ + QVector ekvPoints; + /*If we got less than 4 points no need seek loops.*/ + if (points.size() < 4) + { + return ekvPoints; + } + bool closed = false; + if (points.at(0) == points.at(points.size()-1)) + { + closed = true; + } + qint32 i, j; + for (i = 0; i < points.size(); ++i) + { + /*Last three points no need check.*/ + if (i >= points.size()-3) + { + ekvPoints.append(points.at(i)); + continue; + } + QPointF crosPoint; + QLineF::IntersectType intersect = QLineF::NoIntersection; + QLineF line1(points.at(i), points.at(i+1)); + for (j = i+2; j < points.size()-1; ++j) + { + QLineF line2(points.at(j), points.at(j+1)); + intersect = line1.intersect(line2, &crosPoint); + if (intersect == QLineF::BoundedIntersection) + { + break; + } + } + if (intersect == QLineF::BoundedIntersection) + { + if (i == 0 && j+1 == points.size()-1 && closed) + { + /*We got closed contour.*/ + ekvPoints.append(points.at(i)); + } + else + { + /*We found loop.*/ + ekvPoints.append(points.at(i)); + ekvPoints.append(crosPoint); + i = j; + } + } + else + { + /*We did not found loop.*/ + ekvPoints.append(points.at(i)); + } + } + return ekvPoints; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) +{ + SCASSERT(width > 0); + QVector points; + if (line1.p2() != line2.p2()) + { + qDebug()<<"Last points of two lines must be equal."; + return QVector(); + } + QPointF CrosPoint; + QLineF bigLine1 = ParallelLine(line1, width ); + QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width ); + QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint ); + switch (type) + { + case (QLineF::BoundedIntersection): + points.append(CrosPoint); + return points; + break; + case (QLineF::UnboundedIntersection): + { + QLineF line( line1.p2(), CrosPoint ); + const qreal length = line.length(); + if (length > width*2.4) + { // Cutting too long an acute angle + line.setLength(width); // Not sure about width value here + QLineF cutLine(line.p2(), CrosPoint); // Cut line is a perpendicular + cutLine.setLength(length); // Decided take this length + + // We do not check intersection type because intersection must alwayse exist + QPointF px; + cutLine.setAngle(cutLine.angle()+90); + QLineF::IntersectType type = bigLine1.intersect( cutLine, &px ); + if (type == QLineF::NoIntersection) + { + qDebug()<<"Couldn't find intersection with cut line."; + } + points.append(px); + + cutLine.setAngle(cutLine.angle()-180); + type = bigLine2.intersect( cutLine, &px ); + if (type == QLineF::NoIntersection) + { + qDebug()<<"Couldn't find intersection with cut line."; + } + points.append(px); + } + else + { + points.append(CrosPoint); + return points; + } + break; + } + case (QLineF::NoIntersection): + /*If we have correct lines this means lines lie on a line.*/ + points.append(bigLine1.p2()); + return points; + break; + default: + break; + } + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VEquidistant::ParallelLine(const QLineF &line, qreal width) +{ + SCASSERT(width > 0); + QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()), + -90, width)); + return paralel; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VEquidistant::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width) +{ + SCASSERT(width > 0); + QLineF pLine = line; + pLine.setAngle( pLine.angle() + angle ); + pLine.setLength( width ); + return pLine.p2(); +} diff --git a/src/app/geometry/vequidistant.h b/src/app/geometry/vequidistant.h new file mode 100644 index 000000000..9e19df5d5 --- /dev/null +++ b/src/app/geometry/vequidistant.h @@ -0,0 +1,113 @@ +/************************************************************************ + ** + ** @file vequidistant.h + ** @author Roman Telezhynskyi + ** @date 28 1, 2014 + ** + ** @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 + ** 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 VEQUIDISTANT_H +#define VEQUIDISTANT_H + +#include "vdetail.h" + +class QPainterPath; +class VContainer; +class QPointF; +class QLineF; + +/** + * @brief The VEquidistant class calculate equidistant for detail. + */ +class VEquidistant +{ +public: + VEquidistant(const VContainer *data); + ~VEquidistant(){} + /** + * @brief ContourPath create painter path for detail. + * @param idDetail id of detail. + * @param data container with objects (points, arcs, splines). + * @return return painter path of contour detail. + */ + QPainterPath ContourPath(const quint32 &idDetail) const; +private: + Q_DISABLE_COPY(VEquidistant) + const VContainer *data; + /** + * @brief biasPoints bias point. + * @param points vector of points. + * @param mx offset respect to x. + * @param my offset respect to y. + * @return new vector biased points. + */ + static QVector biasPoints(const QVector &points, const qreal &mx, const qreal &my); + /** + * @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant. + * @param points list of points equdistant. + * @return corrected list. + */ + static QVector CorrectEquidistantPoints(const QVector &points); + /** + * @brief Equidistant create equidistant painter path for detail. + * @param points vector of points. + * @param eqv type of equidistant. + * @param width width of equidistant. + * @return return painter path of equidistant. + */ + static QPainterPath Equidistant(QVector points, const EquidistantType &eqv, const qreal &width); + /** + * @brief CheckLoops seek and delete loops in equidistant. + * @param points vector of points of equidistant. + * @return vector of points of equidistant. + */ + static QVector CheckLoops(const QVector &points); + /** + * @brief EkvPoint return vector of points of equidistant two lines. Last point of two lines must be equal. + * @param line1 first line. + * @param line2 second line. + * @param width width of equidistant. + * @return vector of points. + */ + static QVector EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width); + /** + * @brief ParallelLine create parallel line. + * @param line starting line. + * @param width width to parallel line. + * @return parallel line. + */ + static QLineF ParallelLine(const QLineF &line, qreal width ); + /** + * @brief SingleParallelPoint return point of parallel line. + * @param line starting line. + * @param angle angle in degree. + * @param width width to parallel line. + * @return point of parallel line. + */ + static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width); + + QPointF StartSegment(const VDetail &detail, const int &i) const; + QPointF EndSegment(const VDetail &detail, const int &i) const; +}; + +#endif // VEQUIDISTANT_H diff --git a/src/app/geometry/vgobject.cpp b/src/app/geometry/vgobject.cpp new file mode 100644 index 000000000..a191354c3 --- /dev/null +++ b/src/app/geometry/vgobject.cpp @@ -0,0 +1,419 @@ +/************************************************************************ + ** + ** @file vgobject.cpp + ** @author Roman Telezhynskyi + ** @date 27 12, 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 + ** 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 "vgobject.h" +#include "vgobject_p.h" + +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGObject default constructor. + */ +VGObject::VGObject() + :d(new VGObjectData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGObject constructor. + * @param type type graphical object. + * @param idObject id parent object. + * @param mode mode creation. Used in modeling mode. + */ +VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode) + :d(new VGObjectData(type, idObject, mode)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGObject copy constructor. + * @param obj object. + */ +VGObject::VGObject(const VGObject &obj) + :d (obj.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator. + * @param obj object + * @return object + */ +VGObject &VGObject::operator=(const VGObject &obj) +{ + if ( &obj == this ) + { + return *this; + } + d = obj.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VGObject::~VGObject() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getIdObject return parent id. + * @return parent id or 0 if object don't have parent. + */ +quint32 VGObject::getIdObject() const +{ + return d->idObject; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setIdObject set parent id. + * @param value parent id. + */ +void VGObject::setIdObject(const quint32 &value) +{ + d->idObject = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief name return name graphical object. + * @return name + */ +QString VGObject::name() const +{ + return d->_name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setName set name graphical object. + * @param name name graphical object. + */ +void VGObject::setName(const QString &name) +{ + d->_name = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getMode return mode creation. + * @return mode. + */ +Draw VGObject::getMode() const +{ + return d->mode; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMode set mode creation. + * @param value mode. + */ +void VGObject::setMode(const Draw &value) +{ + d->mode = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getType return object type. + * @return type. + */ +GOType VGObject::getType() const +{ + return d->type; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VGObject::setType(const GOType &type) +{ + d->type = type; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief id return id object. + * @return id + */ +quint32 VGObject::id() const +{ + return d->_id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId set id object. + * @param id id. + */ +void VGObject::setId(const quint32 &id) +{ + d->_id = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &angle) +{ + QLineF line = QLineF(); + line.setP1(p1); + line.setAngle(angle);// First set angle than length. Length can have negative value. + line.setLength(length); + return line; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect) +{ + QRectF rect = scRect; + if (rect.isValid() == false) + { + rect = QRectF(0, 0, 1200, 700); + } + if (rect.contains(firstPoint) == false) + { + // If point outside of scene rect create one around point and unite two rects. + QRectF rectangle(firstPoint.x()-rect.width()/2, firstPoint.y()-rect.height()/2, rect.width(), rect.height()); + rect = rect.united(rectangle); + } + const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2)); + const QLineF line = BuildLine(firstPoint, diagonal, angle); + + return LineIntersectRect(rect, line); +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VGObject::BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect) +{ + const QPointF endP1 = BuildRay(p, angle+180, scRect); + const QPointF endP2 = BuildRay(p, angle, scRect); + return QLineF(endP1, endP2); +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VGObject::BuildAxis(const QPointF &p1, const QPointF &p2, const QRectF &scRect) +{ + QLineF line(p1, p2); + return BuildAxis(p1, line.angle(), scRect); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineIntersectRect find point intersection line and rect. + * @param rec rect. + * @param line line. + * @return point intersection. + */ +QPointF VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) +{ + qreal x1, y1, x2, y2; + rec.getCoords(&x1, &y1, &x2, &y2); + QPointF point; + QLineF::IntersectType type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); + if ( type == QLineF::BoundedIntersection ) + { + return point; + } + type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); + if ( type == QLineF::BoundedIntersection ) + { + return point; + } + type = line.intersect(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); + if ( type == QLineF::BoundedIntersection ) + { + return point; + } + type = line.intersect(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); + if ( type == QLineF::BoundedIntersection ) + { + return point; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineIntersectCircle find point intersection line and circle. + * @param center arc center. + * @param radius arc radius. + * @param line line + * @param p1 first intersection point. + * @param p2 second intersection point. + * @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points. + */ +qint32 VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2) +{ + //coefficient for equation of segment + qreal a = 0, b = 0, c = 0; + LineCoefficients(line, &a, &b, &c); + // projection center of circle on to line + QPointF p = ClosestPoint (line, center); + // how many solutions? + qint32 flag = 0; + qreal d = QLineF (center, p).length(); + if (qFuzzyCompare(d, radius)) + { + flag = 1; + } + else + { + if (radius > d) + { + flag = 2; + } + else + { + return 0; + } + } + // find distance from projection to points of intersection + qreal k = qSqrt (qAbs(radius * radius - d * d)); + qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length(); + // add to projection a vectors aimed to points of intersection + p1 = addVector (p, QPointF (0, 0), QPointF (- b, a), k / t); + p2 = addVector (p, QPointF (0, 0), QPointF (b, - a), k / t); + return flag; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosestPoint find point projection of point onto line. + * @param line line. + * @return point on line or extended line if origin size too small. + */ +QPointF VGObject::ClosestPoint(const QLineF &line, const QPointF &point) +{ + qreal a = 0, b = 0, c = 0; + LineCoefficients(line, &a, &b, &c); + qreal x = point.x() + a; + qreal y = b + point.y(); + QLineF lin (point, QPointF(x, y)); + QPointF p; + QLineF::IntersectType intersect = line.intersect(lin, &p); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + return p; + } + else + { + return QPointF(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VGObject::addVector(const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k) +{ + return QPointF (p.x() + (p2.x() - p1.x()) * k, p.y() + (p2.y() - p1.y()) * k); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. + * @param line line + * @param a a value + * @param b b value + * @param c c value + */ +void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c) +{ + //coefficient for equation of segment + QPointF p1 = line.p1(); + *a = line.p2().y() - p1.y(); + *b = p1.x() - line.p2().x(); + *c = - *a * p1.x() - *b * p1.y(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VGObject::PointInSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) +{ + const qreal eps = 1e-8; + + qreal a = p2.y() - p1.y(); + qreal b = p1.x() - p2.x(); + qreal c = - a * p1.x() - b * p1.y(); + if (qAbs(a * t.x() + b * t.y() + c) > eps) + { + return false; + } + + return PointInBox (t, p1, p2); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VGObject::PointInBox(const QPointF &t, const QPointF &p1, const QPointF &p2) +{ + const qreal eps = 1e-8; + + return (qAbs (t.x() - qMin(p1.x(), p2.x())) <= eps || qMin(p1.x(), p2.x()) <= t.x()) && + (qAbs (qMax(p1.x(), p2.x()) - t.x()) <= eps || qMax(p1.x(), p2.x()) >= t.x()) && + (qAbs (t.y() - qMin(p1.y(), p2.y())) <= eps || qMin(p1.y(), p2.y()) <= t.y()) && + (qAbs (qMax(p1.y(), p2.y()) - t.y()) <= eps || qMax(p1.y(), p2.y()) >= t.y()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetReversePoint return revers container of points. + * @param points container with points. + * @return reverced points. + */ +QVector VGObject::GetReversePoints(const QVector &points) +{ + if (points.isEmpty()) + { + return points; + } + QVector reversePoints; + for (qint32 i = points.size() - 1; i >= 0; --i) + { + reversePoints.append(points.at(i)); + } + return reversePoints; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetLengthContour return length of contour. + * @param contour container with points of contour. + * @param newPoints point whos we try to add to contour. + * @return length length of contour. + */ +int VGObject::GetLengthContour(const QVector &contour, const QVector &newPoints) +{ + qreal length = 0; + QVector points; + points << contour << newPoints; + for (qint32 i = 0; i < points.size()-1; ++i) + { + QLineF line(points.at(i), points.at(i+1)); + length += line.length(); + } + return qFloor(length); +} diff --git a/src/app/geometry/vgobject.h b/src/app/geometry/vgobject.h new file mode 100644 index 000000000..e9a316a10 --- /dev/null +++ b/src/app/geometry/vgobject.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file vgobject.h + ** @author Roman Telezhynskyi + ** @date 27 12, 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 + ** 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 VGOBJECT_H +#define VGOBJECT_H + +#include "../options.h" +#include +#include +#include +#include + +class VGObjectData; +class QLineF; +class QPointF; +class QRectF; + +/** + * @brief The VGObject class keep information graphical objects. + */ +class VGObject +{ +public: + VGObject(); + VGObject(const GOType &type, const quint32 &idObject = 0, const Draw &mode = Draw::Calculation); + VGObject(const VGObject &obj); + VGObject& operator= (const VGObject &obj); + virtual ~VGObject(); + + quint32 getIdObject() const; + void setIdObject(const quint32 &value); + + virtual QString name() const; + void setName(const QString &name); + + Draw getMode() const; + void setMode(const Draw &value); + + GOType getType() const; + void setType(const GOType &type); + + quint32 id() const; + virtual void setId(const quint32 &id); + + static QLineF BuildLine(const QPointF &p1, const qreal& length, const qreal &angle); + static QPointF BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect); + static QLineF BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect); + static QLineF BuildAxis(const QPointF &p1, const QPointF &p2, const QRectF &scRect); + + static QPointF LineIntersectRect(const QRectF &rec, const QLineF &line); + static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, + QPointF &p2); + static QPointF ClosestPoint(const QLineF &line, const QPointF &point); + static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k); + static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c); + static bool PointInSegment (const QPointF &t, const QPointF &p1, const QPointF &p2); + static bool PointInBox (const QPointF &t, const QPointF &p1, const QPointF &p2); + + static QVector GetReversePoints(const QVector &points); + static int GetLengthContour(const QVector &contour, const QVector &newPoints); +private: + QSharedDataPointer d; +}; + +#endif // VGOBJECT_H diff --git a/src/app/geometry/vgobject_p.h b/src/app/geometry/vgobject_p.h new file mode 100644 index 000000000..b3dcac78a --- /dev/null +++ b/src/app/geometry/vgobject_p.h @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file vgobject_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VGOBJECT_P_H +#define VGOBJECT_P_H + +#include +#include "../options.h" + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VGObjectData : public QSharedData +{ +public: + VGObjectData() + :_id(NULL_ID), type(GOType::Unknown), idObject(NULL_ID), _name(QString()), mode(Draw::Calculation) + {} + + VGObjectData(const GOType &type, const quint32 &idObject, const Draw &mode) + :_id(NULL_ID), type(type), idObject(idObject), _name(QString()), mode(mode) + {} + + VGObjectData(const VGObjectData &obj) + :QSharedData(obj), _id(obj._id), type(obj.type), idObject(obj.idObject), _name(obj._name), mode(obj.mode) + {} + + virtual ~VGObjectData(); + + /** @brief _id id in container. Ned for arcs, spline and spline paths. */ + quint32 _id; + + /** @brief type type of graphical object */ + GOType type; + + /** @brief idObject id of parent object. Only for modeling. All another return 0. */ + quint32 idObject; + + /** @brief _name object name */ + QString _name; + + /** @brief mode object created in calculation or drawing mode */ + Draw mode; +}; + +VGObjectData::~VGObjectData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VGOBJECT_P_H diff --git a/src/app/geometry/vnodedetail.cpp b/src/app/geometry/vnodedetail.cpp new file mode 100644 index 000000000..80b54c6fa --- /dev/null +++ b/src/app/geometry/vnodedetail.cpp @@ -0,0 +1,146 @@ +/************************************************************************ + ** + ** @file vnodedetail.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vnodedetail.h" +#include "vnodedetail_p.h" + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail::VNodeDetail() + :d(new VNodeDetailData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail::VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my, bool reverse) + :d(new VNodeDetailData(id, typeTool, typeNode, mx, my, reverse)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail::VNodeDetail(const VNodeDetail &node) + :d (node.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node) +{ + if ( &node == this ) + { + return *this; + } + d = node.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeDetail::~VNodeDetail() +{} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VNodeDetail::getId() const +{ + return d->id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setId(const quint32 &value) +{ + d->id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +Tool VNodeDetail::getTypeTool() const +{ + return d->typeTool; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setTypeTool(const Tool &value) +{ + d->typeTool = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +NodeDetail VNodeDetail::getTypeNode() const +{ + return d->typeNode; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setTypeNode(const NodeDetail &value) +{ + d->typeNode = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VNodeDetail::getMx() const +{ + return d->mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setMx(const qreal &value) +{ + d->mx = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VNodeDetail::getMy() const +{ + return d->my; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setMy(const qreal &value) +{ + d->my = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VNodeDetail::getReverse() const +{ + if (getTypeTool() == Tool::NodePoint) + { + return false; + } + else + { + return d->reverse; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeDetail::setReverse(bool reverse) +{ + if (getTypeTool() == Tool::NodePoint) + { + d->reverse = false; + } + else + { + d->reverse = reverse; + } +} diff --git a/src/app/geometry/vnodedetail.h b/src/app/geometry/vnodedetail.h new file mode 100644 index 000000000..ab557f8bc --- /dev/null +++ b/src/app/geometry/vnodedetail.h @@ -0,0 +1,128 @@ +/************************************************************************ + ** + ** @file vnodedetail.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VNODEDETAIL_H +#define VNODEDETAIL_H + +#include "../options.h" +#include +#include + +class VNodeDetailData; + +/** + * @brief The VNodeDetail class keep information about detail node. + */ +class VNodeDetail +{ +public: + /** + * @brief VNodeDetail default constructor. + */ + VNodeDetail(); + /** + * @brief VNodeDetail constructor. + * @param id object id + * @param typeTool type tool + * @param typeNode type node + * @param mx object bias x axis + * @param my object bias y axis + */ + VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx = 0, qreal my = 0, bool reverse = false); + /** + * @brief VNodeDetail copy constructor + * @param node node + */ + VNodeDetail(const VNodeDetail &node); + /** + * @brief operator = assignment operator + * @param node node + * @return node + */ + VNodeDetail &operator=(const VNodeDetail &node); + ~VNodeDetail(); + /** + * @brief getId return object id. + * @return id. + */ + quint32 getId() const; + /** + * @brief setId set object id. + * @param value object id. + */ + void setId(const quint32 &value); + /** + * @brief getTypeTool return tool type. + * @return tool type. + */ + Tool getTypeTool() const; + /** + * @brief setTypeTool set tool type. + * @param value tool type. + */ + void setTypeTool(const Tool &value); + /** + * @brief getTypeNode return node type. + * @return node type. + */ + NodeDetail getTypeNode() const; + /** + * @brief setTypeNode set node type. + * @param value node type. + */ + void setTypeNode(const NodeDetail &value); + /** + * @brief getMx return object bias x axis. + * @return bias x axis. + */ + qreal getMx() const; + /** + * @brief setMx set object bias x axis. + * @param value bias x axis. + */ + void setMx(const qreal &value); + /** + * @brief getMy return object bias y axis. + * @return bias y axis. + */ + qreal getMy() const; + /** + * @brief setMy set object bias y axis. + * @param value bias y axis. + */ + void setMy(const qreal &value); + + bool getReverse() const; + void setReverse(bool reverse); +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(VNodeDetail) + +#endif // VNODEDETAIL_H diff --git a/src/app/geometry/vnodedetail_p.h b/src/app/geometry/vnodedetail_p.h new file mode 100644 index 000000000..3de2ea778 --- /dev/null +++ b/src/app/geometry/vnodedetail_p.h @@ -0,0 +1,88 @@ +/************************************************************************ + ** + ** @file vnodedetail_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VNODEDETAIL_P_H +#define VNODEDETAIL_P_H + +#include +#include "../options.h" + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VNodeDetailData : public QSharedData +{ +public: + VNodeDetailData() + :id(NULL_ID), typeTool(Tool::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0), reverse(false) + {} + + VNodeDetailData(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my, bool reverse) + :id(id), typeTool(typeTool), typeNode(typeNode), mx(mx), my(my), reverse(reverse) + {} + + VNodeDetailData (const VNodeDetailData& node) + :QSharedData(node), id(node.id), typeTool(node.typeTool), typeNode(node.typeNode), mx(node.mx), my(node.my), + reverse(node.reverse) + {} + + ~VNodeDetailData() {} + + /** + * @brief id object id. + */ + quint32 id; + /** + * @brief typeTool type of tool + */ + Tool typeTool; + /** + * @brief typeNode node type. + */ + NodeDetail typeNode; + /** + * @brief mx bias x axis. + */ + qreal mx; + /** + * @brief my bias y axis. + */ + qreal my; + /** + * @brief reverse true if need reverse points list for node. + */ + bool reverse; +}; + +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif + +#endif // VNODEDETAIL_P_H diff --git a/src/app/geometry/vpointf.cpp b/src/app/geometry/vpointf.cpp new file mode 100644 index 000000000..0a0088b46 --- /dev/null +++ b/src/app/geometry/vpointf.cpp @@ -0,0 +1,190 @@ +/************************************************************************ + ** + ** @file vpointf.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vpointf.h" +#include "vpointf_p.h" +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VPointF creat empty point + */ +VPointF::VPointF() + :VGObject(GOType::Point, 0, Draw::Calculation), d(new VPointFData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPointF::VPointF(const VPointF &point) + :VGObject(point), d(point.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPointF::VPointF(const QPointF &point) + :VGObject(VPointF()), d(new VPointFData(point)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VPointF create new point + * @param x x coordinate + * @param y y coordinate + * @param name point label + * @param mx offset name respect to x + * @param my offset name respect to y + */ +VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) + :VGObject(GOType::Point, idObject, mode), d(new VPointFData(x, y, mx, my)) +{ + setName(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VPointF create new point + * @param point point + * @param name point label + * @param mx offset name respect to x + * @param my offset name respect to y + */ +VPointF::VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) + :VGObject(GOType::Point, idObject, mode), d(new VPointFData(point, mx, my)) +{ + setName(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPointF::~VPointF() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator + * @param point point + * @return point + */ +VPointF &VPointF::operator =(const VPointF &point) +{ + if ( &point == this ) + { + return *this; + } + VGObject::operator=(point); + d = point.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief toQPointF convert to QPointF + * @return QPointF point + */ +QPointF VPointF::toQPointF() const +{ + return QPointF(d->_x, d->_y); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mx return offset name respect to x + * @return offset + */ +qreal VPointF::mx() const +{ + return d->_mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief my return offset name respect to y + * @return offset + */ +qreal VPointF::my() const +{ + return d->_my; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMx set offset name respect to x + * @param mx offset + */ +void VPointF::setMx(qreal mx) +{ + d->_mx = mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMy set offset name respect to y + * @param my offset + */ +void VPointF::setMy(qreal my) +{ + d->_my = my; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief x return x coordinate + * @return value + */ +qreal VPointF::x() const +{ + return d->_x; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setX set x coordinate + * @param value x coordinate + */ +void VPointF::setX(const qreal &value) +{ + d->_x = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief y return y coordinate + * @return value + */ +qreal VPointF::y() const +{ + return d->_y; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setY set y coordinate + * @param value y coordinate + */ +void VPointF::setY(const qreal &value) +{ + d->_y = value; +} diff --git a/src/widgets/vmaingraphicsscene.cpp b/src/app/geometry/vpointf.h similarity index 51% rename from src/widgets/vmaingraphicsscene.cpp rename to src/app/geometry/vpointf.h index 95c1a41b2..78b437310 100644 --- a/src/widgets/vmaingraphicsscene.cpp +++ b/src/app/geometry/vpointf.h @@ -1,7 +1,7 @@ /************************************************************************ ** - ** @file vmaingraphicsscene.cpp - ** @author Roman Telezhinsky + ** @file vpointf.h + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -26,35 +26,41 @@ ** *************************************************************************/ -#include "vmaingraphicsscene.h" +#ifndef VPOINTF_H +#define VPOINTF_H -#include +#include "vgobject.h" -VMainGraphicsScene::VMainGraphicsScene() - :QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1){} +class QPointF; +class QString; +class VPointFData; -VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent) - :QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1){} - -void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) +/** + * @brief The VPointF class keep data of point. + */ +class VPointF:public VGObject { - emit mouseMove(event->scenePos()); - QGraphicsScene::mouseMoveEvent(event); -} +public: + VPointF (); + VPointF (const VPointF &point ); + VPointF (const QPointF &point ); + VPointF (qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0, + const Draw &mode = Draw::Calculation); + VPointF (const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0, + const Draw &mode = Draw::Calculation); + virtual ~VPointF(); + VPointF &operator=(const VPointF &point); + qreal mx() const; + qreal my() const; + void setMx(qreal mx); + void setMy(qreal my); + QPointF toQPointF()const; + qreal x() const; + void setX(const qreal &value); + qreal y() const; + void setY(const qreal &value); +private: + QSharedDataPointer d; +}; -void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - emit mousePress(event->scenePos()); - QGraphicsScene::mousePressEvent(event); -} - -void VMainGraphicsScene::ChoosedItem(qint64 id, const Scene::Scenes &type) -{ - emit ChoosedObject(id, type); -} - -void VMainGraphicsScene::SetFactor(qreal factor) -{ - scaleFactor=scaleFactor*factor; - emit NewFactor(scaleFactor); -} +#endif // VPOINTF_H diff --git a/src/app/geometry/vpointf_p.h b/src/app/geometry/vpointf_p.h new file mode 100644 index 000000000..cefc69de9 --- /dev/null +++ b/src/app/geometry/vpointf_p.h @@ -0,0 +1,87 @@ +/************************************************************************ + ** + ** @file vpointf_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VPOINTF_P_H +#define VPOINTF_P_H + +#include +#include "../options.h" +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VPointFData : public QSharedData +{ +public: + + VPointFData() + : _mx(0), _my(0), _x(0), _y(0) + {} + + VPointFData(const VPointFData &point) + :QSharedData(point), _mx(point._mx), _my(point._my), _x(point._x), _y(point._y) + {} + + VPointFData(const QPointF &point) + :_mx(0), _my(0), _x(point.x()), _y(point.y()) + {} + + VPointFData(qreal x, qreal y, qreal mx, qreal my) + :_mx(mx), _my(my), _x(x), _y(y) + {} + + VPointFData(const QPointF &point, qreal mx, qreal my) + :_mx(mx), _my(my), _x(point.x()), _y(point.y()) + {} + + virtual ~VPointFData(); + + /** @brief _mx offset name respect to x */ + qreal _mx; + + /** @brief _my offset name respect to y */ + qreal _my; + + /** @brief _x x coordinate */ + qreal _x; + + /** @brief _y y coordinate */ + qreal _y; +}; + +VPointFData::~VPointFData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VPOINTF_P_H diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp new file mode 100644 index 000000000..e6d48a9d9 --- /dev/null +++ b/src/app/geometry/vspline.cpp @@ -0,0 +1,735 @@ +/************************************************************************ + ** + ** @file vspline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vspline.h" +#include "vspline_p.h" +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSpline default constructor + */ +VSpline::VSpline() + :VAbstractCurve(GOType::Spline), d(new VSplineData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSpline constructor. + * @param spline spline from which the copy. + */ +VSpline::VSpline ( const VSpline & spline ) + :VAbstractCurve(spline), d(spline.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSpline constructor. + * @param p1 first point spline. + * @param p4 last point spline. + * @param angle1 angle from first point to first control point. + * @param angle2 angle from second point to second control point. + * @param kCurve coefficient of curvature spline. + * @param kAsm1 coefficient of length first control line. + * @param kAsm2 coefficient of length second control line. + */ +VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, + quint32 idObject, Draw mode) + :VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve)) +{ + CreateName(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSpline constructor. + * @param p1 first point spline. + * @param p2 first control point. + * @param p3 second control point. + * @param p4 second point spline. + */ +VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject, Draw mode) + :VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4, kCurve)) +{ + CreateName(); +} + + +//--------------------------------------------------------------------------------------------------------------------- +VSpline::~VSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetLength return length of spline. + * @return length. + */ +qreal VSpline::GetLength () const +{ + return LengthBezier ( GetP1().toQPointF(), d->p2, d->p3, GetP4().toQPointF()); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VSpline::LengthT(qreal t) const +{ + if (t < 0 || t > 1) + { + qDebug()<<"Wrong value t."; + return 0; + } + QLineF seg1_2 ( GetP1 ().toQPointF(), GetP2 () ); + seg1_2.setLength(seg1_2.length () * t); + QPointF p12 = seg1_2.p2(); + + QLineF seg2_3 ( GetP2 (), GetP3 () ); + seg2_3.setLength(seg2_3.length () * t); + QPointF p23 = seg2_3.p2(); + + QLineF seg12_23 ( p12, p23 ); + seg12_23.setLength(seg12_23.length () * t); + QPointF p123 = seg12_23.p2(); + + QLineF seg3_4 ( GetP3 (), GetP4 ().toQPointF() ); + seg3_4.setLength(seg3_4.length () * t); + QPointF p34 = seg3_4.p2(); + + QLineF seg23_34 ( p23, p34 ); + seg23_34.setLength(seg23_34.length () * t); + QPointF p234 = seg23_34.p2(); + + QLineF seg123_234 ( p123, p234 ); + seg123_234.setLength(seg123_234.length () * t); + QPointF p1234 = seg123_234.p2(); + + return LengthBezier ( GetP1().toQPointF(), p12, p123, p1234); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CutSpline cut spline. GetPointP1() of base spline will return first point for first spline, GetPointP4() + * of base spline will return forth point of second spline. + * @param length length first spline + * @param spl1p2 second point of first spline + * @param spl1p3 third point of first spline + * @param spl2p2 second point of second spline + * @param spl2p3 third point of second spline + * @return point of cutting. This point is forth point of first spline and first point of second spline. + */ +QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3 ) const +{ + //Always need return two splines, so we must correct wrong length. + if (length < GetLength()*0.02) + { + length = GetLength()*0.02; + } + else if ( length > GetLength()*0.98) + { + length = GetLength()*0.98; + } + + // Very stupid way find correct value of t. + // Better first compare with t = 0.5. Find length of spline. + // If length larger, take t = 0.75 and so on. + // If length less, take t = 0.25 and so on. + qreal parT = 0; + qreal step = 0.001; + while (1) + { + parT = parT + step; + qreal splLength = LengthT(parT); + if (splLength >= length || parT > 1) + { + break; + } + } + + QLineF seg1_2 ( GetP1 ().toQPointF(), GetP2 () ); + seg1_2.setLength(seg1_2.length () * parT); + QPointF p12 = seg1_2.p2(); + + QLineF seg2_3 ( GetP2 (), GetP3 () ); + seg2_3.setLength(seg2_3.length () * parT); + QPointF p23 = seg2_3.p2(); + + QLineF seg12_23 ( p12, p23 ); + seg12_23.setLength(seg12_23.length () * parT); + QPointF p123 = seg12_23.p2(); + + QLineF seg3_4 ( GetP3 (), GetP4 ().toQPointF() ); + seg3_4.setLength(seg3_4.length () * parT); + QPointF p34 = seg3_4.p2(); + + QLineF seg23_34 ( p23, p34 ); + seg23_34.setLength(seg23_34.length () * parT); + QPointF p234 = seg23_34.p2(); + + QLineF seg123_234 ( p123, p234 ); + seg123_234.setLength(seg123_234.length () * parT); + QPointF p1234 = seg123_234.p2(); + + spl1p2 = p12; + spl1p3 = p123; + spl2p2 = p234; + spl2p3 = p34; + return p1234; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const +{ + QPointF spl1p2; + QPointF spl1p3; + QPointF spl2p2; + QPointF spl2p3; + QPointF cutPoint = CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 ); + + spl1 = VSpline(GetP1(), spl1p2, spl1p3, cutPoint, GetKcurve()); + spl2 = VSpline(cutPoint, spl2p2, spl2p3, GetP4(), GetKcurve()); + return cutPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetPoints return list with spline points. + * @return list of points. + */ +QVector VSpline::GetPoints () const +{ + return GetPoints(GetP1().toQPointF(), d->p2, d->p3, GetP4().toQPointF()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetPoints return list with spline points. + * @param p1 first spline point. + * @param p2 first control point. + * @param p3 second control point. + * @param p4 last spline point. + * @return list of points. + */ +QVector VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4) +{ + QVector pvector; + QVector x; + QVector y; + QVector& wx = x; + QVector& wy = y; + x.append ( p1.x () ); + y.append ( p1.y () ); + PointBezier_r ( p1.x (), p1.y (), p2.x (), p2.y (), + p3.x (), p3.y (), p4.x (), p4.y (), 0, wx, wy ); + x.append ( p4.x () ); + y.append ( p4.y () ); + for ( qint32 i = 0; i < x.count(); ++i ) + { + pvector.append( QPointF ( x.at(i), y.at(i)) ); + } + return pvector; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LengthBezier return spline length using 4 spline point. + * @param p1 first spline point + * @param p2 first control point. + * @param p3 second control point. + * @param p4 last spline point. + * @return length. + */ +qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ) +{ + QPainterPath splinePath; + QVector points = GetPoints (p1, p2, p3, p4); + splinePath.moveTo(points.at(0)); + for (qint32 i = 1; i < points.count(); ++i) + { + splinePath.lineTo(points.at(i)); + } + return splinePath.length(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PointBezier_r find spline point using four point of spline. + * @param x1 х coordinate first point. + * @param y1 у coordinate first point. + * @param x2 х coordinate first control point. + * @param y2 у coordinate first control point. + * @param x3 х coordinate second control point. + * @param y3 у coordinate second control point. + * @param x4 х coordinate last point. + * @param y4 у coordinate last point. + * @param level level of recursion. In the begin 0. + * @param px list х coordinat spline points. + * @param py list у coordinat spline points. + */ +void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, + qreal x3, qreal y3, qreal x4, qreal y4, + qint16 level, QVector &px, QVector &py) +{ + const double curve_collinearity_epsilon = 1e-30; + const double curve_angle_tolerance_epsilon = 0.01; + const double m_angle_tolerance = 0.0; + enum curve_recursion_limit_e { curve_recursion_limit = 32 }; + const double m_cusp_limit = 0.0; + double m_approximation_scale = 1.0; + double m_distance_tolerance_square; + + m_distance_tolerance_square = 0.5 / m_approximation_scale; + m_distance_tolerance_square *= m_distance_tolerance_square; + + if (level > curve_recursion_limit) + { + return; + } + + // Calculate all the mid-points of the line segments + //---------------------- + const double x12 = (x1 + x2) / 2; + const double y12 = (y1 + y2) / 2; + const double x23 = (x2 + x3) / 2; + const double y23 = (y2 + y3) / 2; + const double x34 = (x3 + x4) / 2; + const double y34 = (y3 + y4) / 2; + const double x123 = (x12 + x23) / 2; + const double y123 = (y12 + y23) / 2; + const double x234 = (x23 + x34) / 2; + const double y234 = (y23 + y34) / 2; + const double x1234 = (x123 + x234) / 2; + const double y1234 = (y123 + y234) / 2; + + + // Try to approximate the full cubic curve by a single straight line + //------------------ + const double dx = x4-x1; + const double dy = y4-y1; + + double d2 = fabs((x2 - x4) * dy - (y2 - y4) * dx); + double d3 = fabs((x3 - x4) * dy - (y3 - y4) * dx); + + switch ((static_cast(d2 > curve_collinearity_epsilon) << 1) + + static_cast(d3 > curve_collinearity_epsilon)) + { + case 0: + { + // All collinear OR p1==p4 + //---------------------- + double k = dx*dx + dy*dy; + if (k < 0.000000001) + { + d2 = CalcSqDistance(x1, y1, x2, y2); + d3 = CalcSqDistance(x4, y4, x3, y3); + } + else + { + k = 1 / k; + { + const double da1 = x2 - x1; + const double da2 = y2 - y1; + d2 = k * (da1*dx + da2*dy); + } + { + const double da1 = x3 - x1; + const double da2 = y3 - y1; + d3 = k * (da1*dx + da2*dy); + } + // cppcheck-suppress incorrectLogicOperator + if (d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1) + { + // Simple collinear case, 1---2---3---4 + // We can leave just two endpoints + return; + } + if (d2 <= 0) + { + d2 = CalcSqDistance(x2, y2, x1, y1); + } + else if (d2 >= 1) + { + d2 = CalcSqDistance(x2, y2, x4, y4); + } + else + { + d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy); + } + + if (d3 <= 0) + { + d3 = CalcSqDistance(x3, y3, x1, y1); + } + else if (d3 >= 1) + { + d3 = CalcSqDistance(x3, y3, x4, y4); + } + else + { + d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy); + } + } + if (d2 > d3) + { + if (d2 < m_distance_tolerance_square) + { + px.append(x2); + py.append(y2); + return; + } + } + else + { + if (d3 < m_distance_tolerance_square) + { + px.append(x3); + py.append(y3); + return; + } + } + break; + } + case 1: + { + // p1,p2,p4 are collinear, p3 is significant + //---------------------- + if (d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy)) + { + if (m_angle_tolerance < curve_angle_tolerance_epsilon) + { + px.append(x23); + py.append(y23); + return; + } + + // Angle Condition + //---------------------- + double da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2)); + if (da1 >= M_PI) + { + da1 = 2*M_PI - da1; + } + + if (da1 < m_angle_tolerance) + { + px.append(x2); + py.append(y2); + + px.append(x3); + py.append(y3); + return; + } + + if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) + { + if (da1 > m_cusp_limit) + { + px.append(x3); + py.append(y3); + return; + } + } + } + break; + } + case 2: + { + // p1,p3,p4 are collinear, p2 is significant + //---------------------- + if (d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy)) + { + if (m_angle_tolerance < curve_angle_tolerance_epsilon) + { + px.append(x23); + py.append(y23); + return; + } + + // Angle Condition + //---------------------- + double da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); + if (da1 >= M_PI) + { + da1 = 2*M_PI - da1; + } + + if (da1 < m_angle_tolerance) + { + px.append(x2); + py.append(y2); + + px.append(x3); + py.append(y3); + return; + } + + if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) + { + if (da1 > m_cusp_limit) + { + px.append(x2); + py.append(y2); + return; + } + } + } + break; + } + case 3: + { + // Regular case + //----------------- + if ((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy)) + { + // If the curvature doesn't exceed the distance_tolerance value + // we tend to finish subdivisions. + //---------------------- + if (m_angle_tolerance < curve_angle_tolerance_epsilon) + { + px.append(x23); + py.append(y23); + return; + } + + // Angle & Cusp Condition + //---------------------- + const double k = atan2(y3 - y2, x3 - x2); + double da1 = fabs(k - atan2(y2 - y1, x2 - x1)); + double da2 = fabs(atan2(y4 - y3, x4 - x3) - k); + if (da1 >= M_PI) + { + da1 = 2*M_PI - da1; + } + if (da2 >= M_PI) + { + da2 = 2*M_PI - da2; + } + + if (da1 + da2 < m_angle_tolerance) + { + // Finally we can stop the recursion + //---------------------- + + px.append(x23); + py.append(y23); + return; + } + + if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) + { + if (da1 > m_cusp_limit) + { + px.append(x2); + py.append(y2); + return; + } + + if (da2 > m_cusp_limit) + { + px.append(x3); + py.append(y3); + return; + } + } + } + break; + } + default: + break; + } + + // Continue subdivision + //---------------------- + PointBezier_r(x1, y1, x12, y12, x123, y123, x1234, y1234, static_cast(level + 1), px, py); + PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast(level + 1), px, py); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CalcSqDistance calculate squared distance. + * @param x1 х coordinate first point. + * @param y1 у coordinate first point. + * @param x2 х coordinate second point. + * @param y2 у coordinate second point. + * @return squared length. + */ +qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2) +{ + qreal dx = x2 - x1; + qreal dy = y2 - y1; + return dx * dx + dy * dy; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CreateName create spline name. + */ +void VSpline::CreateName() +{ + setName(QString(spl_+"%1_%2").arg(this->GetP1().name(), this->GetP4().name())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SplinePoints return list with spline points. + * @param p1 first spline point. + * @param p4 last spline point. + * @param angle1 angle from first point to first control point. + * @param angle2 angle from second point to second control point. + * @param kAsm1 coefficient of length first control line. + * @param kAsm2 coefficient of length second control line. + * @param kCurve coefficient of curvature spline. + * @return list with spline points. + */ +// cppcheck-suppress unusedFunction +QVector VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, + qreal kAsm2, qreal kCurve) +{ + QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); + p1pX.setAngle( angle1 ); + qreal L = 0, radius = 0, angle = 90; + radius = QLineF(QPointF(p1.x(), p4.y()), p4).length(); + L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); + QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y()); + p1p2.setAngle(angle1); + QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y()); + p4p3.setAngle(angle2); + QPointF p2 = p1p2.p2(); + QPointF p3 = p4p3.p2(); + return GetPoints(p1, p2, p3, p4); +} + +//--------------------------------------------------------------------------------------------------------------------- +VSpline &VSpline::operator =(const VSpline &spline) +{ + if ( &spline == this ) + { + return *this; + } + VAbstractCurve::operator=(spline); + d = spline.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1 return first spline point. + * @return first point. + */ +VPointF VSpline::GetP1() const +{ + return d->p1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2 return first control point. + * @return first control point. + */ +QPointF VSpline::GetP2() const +{ + return d->p2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP3 return second control point. + * @return second control point. + */ +QPointF VSpline::GetP3() const +{ + return d->p3; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP4 return last spline point. + * @return остання точка сплайну. + */ +VPointF VSpline::GetP4() const +{ + return d->p4; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle1 return first angle control line. + * @return angle. + */ +qreal VSpline::GetAngle1() const +{ + return d->angle1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle2 return second angle control line. + * @return angle. + */ +qreal VSpline::GetAngle2() const +{ + return d->angle2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKasm1 return coefficient of length first control line. + * @return coefficient. + */ +qreal VSpline::GetKasm1() const +{ + return d->kAsm1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKasm2 return coefficient of length second control line. + * @return coefficient. + */ +qreal VSpline::GetKasm2() const +{ + return d->kAsm2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKcurve return coefficient of curvature spline. + * @return coefficient + */ +qreal VSpline::GetKcurve() const +{ + return d->kCurve; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSpline::SetKcurve(qreal factor) +{ + if (factor > 0) + { + d->kCurve = factor; + } +} diff --git a/src/app/geometry/vspline.h b/src/app/geometry/vspline.h new file mode 100644 index 000000000..d363f8b0f --- /dev/null +++ b/src/app/geometry/vspline.h @@ -0,0 +1,85 @@ +/************************************************************************ + ** + ** @file vspline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VSPLINE_H +#define VSPLINE_H + +#include "vabstractcurve.h" +#include "vpointf.h" +#include +#include + +class QPainterPath; +class VSplineData; + +#define M_2PI 6.28318530717958647692528676655900576 + +/** + * @brief VSpline class that implements the spline. + */ +class VSpline :public VAbstractCurve +{ +public: + VSpline(); + VSpline (const VSpline &spline ); + VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, + quint32 idObject = 0, Draw mode = Draw::Calculation); + VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject = 0, + Draw mode = Draw::Calculation); + virtual ~VSpline(); + VSpline &operator=(const VSpline &spl); + VPointF GetP1 () const; + QPointF GetP2 () const; + QPointF GetP3 () const; + VPointF GetP4 () const; + qreal GetAngle1 () const; + qreal GetAngle2() const; + qreal GetLength () const; + qreal GetKasm1() const; + qreal GetKasm2() const; + qreal GetKcurve() const; + void SetKcurve(qreal factor); + qreal LengthT(qreal t) const; + QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const; + QPointF CutSpline ( qreal length, VSpline &spl1, VSpline &spl2) const; + QVector GetPoints () const; + // cppcheck-suppress unusedFunction + static QVector SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, + qreal kAsm2, qreal kCurve); +protected: + static QVector GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ); +private: + QSharedDataPointer d; + static qreal LengthBezier (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ); + static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4, + qint16 level, QVector &px, QVector &py); + static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2); + void CreateName(); +}; + +#endif // VSPLINE_H diff --git a/src/app/geometry/vspline_p.h b/src/app/geometry/vspline_p.h new file mode 100644 index 000000000..8ca4d8efd --- /dev/null +++ b/src/app/geometry/vspline_p.h @@ -0,0 +1,126 @@ +/************************************************************************ + ** + ** @file vspline_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VSPLINE_P_H +#define VSPLINE_P_H + +#include +#include "../options.h" +#include "vpointf.h" +#include +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VSplineData : public QSharedData +{ +public: + VSplineData() + :p1(VPointF()), p2(QPointF()), p3(QPointF()), p4(VPointF()), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1) + {} + + VSplineData ( const VSplineData &spline ) + :QSharedData(spline), p1(spline.p1), p2(spline.p2), p3(spline.p3), p4(spline.p4), angle1(spline.angle1), + angle2(spline.angle2), kAsm1(spline.kAsm1), kAsm2(spline.kAsm2), kCurve(spline.kCurve) + {} + + VSplineData (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve) + :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), + kCurve(kCurve) + { + qreal L = 0, radius = 0, angle = 90; + QPointF point1 = this->p1.toQPointF(); + QPointF point4 = this->p4.toQPointF(); + radius = QLineF(point1, point4).length()/1.414213;//1.414213=sqrt(2); + L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); + QLineF p1p2(this->p1.x(), this->p1.y(), this->p1.x() + L * kAsm1, this->p1.y()); + p1p2.setAngle(angle1); + QLineF p4p3(this->p4.x(), this->p4.y(), this->p4.x() + L * kAsm2, this->p4.y()); + p4p3.setAngle(angle2); + this->p2 = p1p2.p2(); + this->p3 = p4p3.p2(); + } + + VSplineData (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve) + :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1) + { + this->angle1 = QLineF ( this->p1.toQPointF(), this->p2 ).angle(); + this->angle2 = QLineF ( this->p4.toQPointF(), this->p3 ).angle(); + + qreal L = 0, radius = 0, angle = 90; + QPointF point1 = this->p1.toQPointF(); + QPointF point4 = this->p4.toQPointF(); + radius = QLineF(point1, point4).length()/1.414213;//1.414213=sqrt(2); + L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); + + this->kCurve = kCurve; + this->kAsm1 = QLineF ( this->p1.toQPointF(), this->p2 ).length()/L; + this->kAsm2 = QLineF ( this->p4.toQPointF(), this->p3 ).length()/L; + } + + virtual ~VSplineData(); + + /** @brief p1 first spline point. */ + VPointF p1; + + /** @brief p2 first control point. */ + QPointF p2; + + /** @brief p3 second control point. */ + QPointF p3; + + /** @brief p4 last spline point. */ + VPointF p4; + + /** @brief angle1 first angle control line. */ + qreal angle1; + + /** @brief angle2 second angle control line. */ + qreal angle2; + + /** @brief kAsm1 coefficient of length first control line. */ + qreal kAsm1; + + /** @brief kAsm2 coefficient of length second control line. */ + qreal kAsm2; + + /** @brief kCurve coefficient of curvature spline. */ + qreal kCurve; +}; + +VSplineData::~VSplineData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VSPLINE_P_H diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp new file mode 100644 index 000000000..d2c49976b --- /dev/null +++ b/src/app/geometry/vsplinepath.cpp @@ -0,0 +1,271 @@ +/************************************************************************ + ** + ** @file vsplinepath.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vsplinepath.h" +#include "vsplinepath_p.h" +#include "../libs/ifc/exception/vexception.h" + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode) + : VAbstractCurve(GOType::SplinePath, idObject, mode), d(new VSplinePathData(kCurve)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath::VSplinePath(const VSplinePath &splPath) + : VAbstractCurve(splPath), d(splPath.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath::~VSplinePath() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VSplinePath::append(const VSplinePoint &point) +{ + d->path.append(point); + QString name = splPath; + name.append(QString("_%1").arg(d->path.first().P().name())); + if (d->path.size() > 1) + { + name.append(QString("_%1").arg(d->path.last().P().name())); + } + setName(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +qint32 VSplinePath::Count() const +{ + if (d->path.size() == 0) + { + return 0; + } + else + { + return d->path.size() - 1; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VSpline VSplinePath::GetSpline(qint32 index) const +{ + if (Count()<1) + { + throw VException(tr("Not enough points to create the spline.")); + } + if (index < 1 || index > Count()) + { + throw VException(tr("This spline does not exist.")); + } + VSpline spl(d->path.at(index-1).P(), d->path.at(index).P(), d->path.at(index-1).Angle2(), + d->path.at(index).Angle1(), d->path.at(index-1).KAsm2(), d->path.at(index).KAsm1(), d->kCurve); + return spl; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VSplinePath::GetPath(PathDirection direction) const +{ + QPainterPath painterPath; + for (qint32 i = 1; i <= Count(); ++i) + { + VSpline spl(d->path.at(i-1).P(), d->path.at(i).P(), d->path.at(i-1).Angle2(), d->path.at(i).Angle1(), + d->path.at(i-1).KAsm2(), d->path.at(i).KAsm1(), d->kCurve); + painterPath.addPath(spl.GetPath(direction)); + } + return painterPath; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VSplinePath::GetPoints() const +{ + QVector pathPoints; + for (qint32 i = 1; i <= Count(); ++i) + { + VSpline spl(d->path.at(i-1).P(), d->path.at(i).P(), d->path.at(i-1).Angle2(), d->path.at(i).Angle1(), + d->path.at(i-1).KAsm2(), d->path.at(i).KAsm1(), d->kCurve); + pathPoints += spl.GetPoints(); + } + return pathPoints; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VSplinePath::GetLength() const +{ + qreal length = 0; + for (qint32 i = 1; i <= Count(); ++i) + { + VSpline spl(d->path.at(i-1).P(), d->path.at(i).P(), d->path.at(i-1).Angle2(), d->path.at(i).Angle1(), + d->path.at(i-1).KAsm2(), d->path.at(i).KAsm1(), d->kCurve); + length += spl.GetLength(); + } + return length; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point) +{ + if (indexSpline < 1 || indexSpline > Count()) + { + throw VException(tr("This spline does not exist.")); + } + if (pos == SplinePointPosition::FirstPoint) + { + d->path[indexSpline-1] = point; + } + else + { + d->path[indexSpline] = point; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const +{ + if (indexSpline < 1 || indexSpline > Count()) + { + throw VException(tr("This spline does not exist.")); + } + if (pos == SplinePointPosition::FirstPoint) + { + return d->path.at(indexSpline-1); + } + else + { + return d->path.at(indexSpline); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath &VSplinePath::operator =(const VSplinePath &path) +{ + if ( &path == this ) + { + return *this; + } + VAbstractCurve::operator=(path); + d = path.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePoint & VSplinePath::operator[](int indx) +{ + return d->path[indx]; +} + +//--------------------------------------------------------------------------------------------------------------------- +const VSplinePoint &VSplinePath::at(int indx) const +{ + return d->path[indx]; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, + QPointF &spl2p2, QPointF &spl2p3) const +{ + if (Count() < 2) + { + throw VException(tr("Can't cut spline path with one point")); + } + + //Always need return two spline paths, so we must correct wrong length. + qreal fullLength = GetLength(); + if (length < fullLength * 0.02) + { + length = fullLength * 0.02; + } + else if ( length > fullLength * 0.98) + { + length = fullLength * 0.98; + } + + fullLength = 0; + for (qint32 i = 1; i <= Count(); ++i) + { + VSpline spl = VSpline(d->path.at(i-1).P(), d->path.at(i).P(), d->path.at(i-1).Angle2(), d->path.at(i).Angle1(), + d->path.at(i-1).KAsm2(), d->path.at(i).KAsm1(), d->kCurve); + fullLength += spl.GetLength(); + if (fullLength > length) + { + p1 = i-1; + p2 = i; + return spl.CutSpline(length - (fullLength - spl.GetLength()), spl1p2, spl1p3, spl2p2, spl2p3); + } + } + return QPointF(); +} + +//--------------------------------------------------------------------------------------------------------------------- +qint32 VSplinePath::getMaxCountPoints() const +{ + return d->maxCountPoints; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSplinePath::setMaxCountPoints(const qint32 &value) +{ + d->maxCountPoints = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qint32 VSplinePath::CountPoint() const +{ + return d->path.size(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VSplinePath::GetSplinePath() const +{ + return d->path; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSplinePath::Clear() +{ + d->path.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VSplinePath::getKCurve() const +{ + return d->kCurve; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSplinePath::setKCurve(const qreal &value) +{ + if (value > 0) + { + d->kCurve = value; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +const QVector *VSplinePath::GetPoint() const +{ + return &d->path; +} diff --git a/src/app/geometry/vsplinepath.h b/src/app/geometry/vsplinepath.h new file mode 100644 index 000000000..e562be232 --- /dev/null +++ b/src/app/geometry/vsplinepath.h @@ -0,0 +1,192 @@ +/************************************************************************ + ** + ** @file vsplinepath.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VSPLINEPATH_H +#define VSPLINEPATH_H + +#include "vabstractcurve.h" +#include "vspline.h" +#include "vsplinepoint.h" +#include +#include +#include + +class VSplinePathData; + +/** + * @brief The VSplinePath class keep information about splinePath. + */ +class VSplinePath :public VAbstractCurve +{ + Q_DECLARE_TR_FUNCTIONS(VSplinePath) +public: + /** + * @brief VSplinePath constructor. + * @param kCurve coefficient of curvature spline path. + * @param idObject parent id. + * @param mode mode creation spline path. + */ + VSplinePath(qreal kCurve = 1, quint32 idObject = 0, Draw mode = Draw::Calculation); + /** + * @brief VSplinePath copy constructor. + * @param splPath spline path. + */ + VSplinePath(const VSplinePath& splPath); + virtual ~VSplinePath(); + /** + * @brief append add point in the end of list points. + * @param point new point. + */ + void append(const VSplinePoint &point); + /** + * @brief Count return count point. + * @return count. + */ + qint32 Count() const; + /** + * @brief CountPoint return count point. + * @return count. + */ + qint32 CountPoint() const; + /** + * @brief GetSpline return spline by index. + * @param index index spline in spline path. + * @return spline + */ + VSpline GetSpline(qint32 index) const; + /** + * @brief GetPath return QPainterPath which reprezent spline path. + * @return path. + */ + QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const; + /** + * @brief GetPathPoints return list of points what located on path. + * @return list. + */ + QVector GetPoints() const; + /** + * @brief GetSplinePath return list with spline points. + * @return list. + */ + QVector GetSplinePath() const; + /** + * @brief GetLength return length of spline path. + * @return length. + */ + qreal GetLength() const; + /** + * @brief UpdatePoint update spline point in list. + * @param indexSpline spline index in list. + * @param pos position point in spline. + * @param point point. + */ + void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point); + /** + * @brief GetSplinePoint return spline point from list. + * @param indexSpline spline index in list. + * @param pos position point in spline. + * @return spline point. + */ + VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const; + /** + * @brief Clear clear list of points. + */ + void Clear(); + /** + * @brief getKCurve return coefficient of curvature spline path. + * @return coefficient of curvature spline. + */ + qreal getKCurve() const; + /** + * @brief setKCurve set coefficient of curvature spline path. + * @param value coefficient of curvature spline path. + */ + void setKCurve(const qreal &value); + /** + * @brief GetPoint pointer to list spline point. + * @return list. + */ + const QVector *GetPoint() const; + /** + * @brief operator = assignment operator. + * @param path spline path. + * @return spline path. + */ + VSplinePath &operator=(const VSplinePath &path); + /** + * @brief operator [] return spline point by index. + * @param indx index in list. + * @return spline point. + */ + VSplinePoint &operator[](int indx); + /** + * @brief at return spline point by index. + * @param indx index in list. + * @return spline point. + */ + const VSplinePoint &at(int indx) const; + /** + * @brief CutSplinePath cut spline path into two. This method don't return two spline path. You must create spline + * paths by yourself. + * Example: + * QPointF spl1p2, spl1p3, spl2p2, spl2p3; + * qint32 p1 = 0, p2 = 0; + * QPointF point = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); + * + * VSplinePoint splP1 = splPath->at(p1); + * VSplinePoint splP2 = splPath->at(p2); + * VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve()); + * VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + * @param length length first spline path. + * @param p1 index first spline point in list. + * @param p2 index second spline point in list. + * @param spl1p2 first control point first spline. + * @param spl1p3 second control point first spline. + * @param spl2p2 first control point second spline. + * @param spl2p3 second control point second spline. + * @return cutting point. + */ + QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, + QPointF &spl2p3) const; + /** + * @brief getMaxCountPoints return max count of points what can have spline path. This method use tool union detail. + * Because cutting point can change position spline can have diffirent count of points. Need know max value. This + * value stored from cuted spline path. + * @return count. + */ + qint32 getMaxCountPoints() const; + /** + * @brief setMaxCountPoints set max count points from cuted spline path. + * @param value max count. + */ + void setMaxCountPoints(const qint32 &value); +private: + QSharedDataPointer d; +}; + +#endif // VSPLINEPATH_H diff --git a/src/app/geometry/vsplinepath_p.h b/src/app/geometry/vsplinepath_p.h new file mode 100644 index 000000000..c671c1f3e --- /dev/null +++ b/src/app/geometry/vsplinepath_p.h @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file vsplinepath_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VSPLINEPATH_P_H +#define VSPLINEPATH_P_H + +#include +#include "../options.h" +#include "vsplinepoint.h" + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VSplinePathData : public QSharedData +{ +public: + + VSplinePathData() + : path(QVector()), kCurve(1), maxCountPoints(0) + {} + + VSplinePathData(qreal kCurve) + : path(QVector()), kCurve(kCurve), maxCountPoints(0) + {} + + VSplinePathData(const VSplinePathData &splPath) + : QSharedData(splPath), path(splPath.path), kCurve(splPath.kCurve), maxCountPoints(splPath.maxCountPoints) + {} + + virtual ~VSplinePathData(); + + /** + * @brief path list spline point. + */ + QVector path; + /** + * @brief kCurve coefficient of curvature spline. + */ + qreal kCurve; + /** + * @brief maxCountPoints max count of points what can have spline path. + */ + qint32 maxCountPoints; +}; + +VSplinePathData::~VSplinePathData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VSPLINEPATH_P_H diff --git a/src/app/geometry/vsplinepoint.cpp b/src/app/geometry/vsplinepoint.cpp new file mode 100644 index 000000000..2928bece2 --- /dev/null +++ b/src/app/geometry/vsplinepoint.cpp @@ -0,0 +1,187 @@ +/************************************************************************ + ** + ** @file vsplinepoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vsplinepoint.h" +#include "vsplinepoint_p.h" +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSplinePoint default constructor. + */ +VSplinePoint::VSplinePoint() + :d(new VSplinePointData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSplinePoint constructor. + * @param pSpline spline point. + * @param kAsm1 coefficient of length first control line. + * @param angle1 first angle control line. + * @param kAsm2 coefficient of length second control line. + * @param angle2 second angle control line. + */ +VSplinePoint::VSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) + :d(new VSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2)) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSplinePoint copy constructor + * @param point point + */ +VSplinePoint::VSplinePoint(const VSplinePoint &point) + :d(point.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePoint &VSplinePoint::operator=(const VSplinePoint &point) +{ + if ( &point == this ) + { + return *this; + } + d = point.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePoint::~VSplinePoint() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetAngle1 set first angle of spline. + * @param value angle. + */ +void VSplinePoint::SetAngle1(const qreal &value) +{ + QLineF line(0, 0, 100, 0); + line.setAngle(value); + d->angle1 = line.angle(); + + line.setAngle(value+180); + d->angle2 = line.angle(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetAngle2 set second angle of spline. + * @param value angle. + */ +void VSplinePoint::SetAngle2(const qreal &value) +{ + QLineF line(0, 0, 100, 0); + line.setAngle(value); + d->angle2 = line.angle(); + + line.setAngle(value-180); + d->angle1 = line.angle(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief P return point. + * @return point. + */ +VPointF VSplinePoint::P() const +{ + return d->pSpline; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetP set point. + * @param value point. + */ +void VSplinePoint::SetP(const VPointF &value) +{ + d->pSpline = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Angle1 return first angle of spline. + * @return angle. + */ +qreal VSplinePoint::Angle1() const +{ + return d->angle1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Angle2 return second angle of spline. + * @return angle. + */ +qreal VSplinePoint::Angle2() const +{ + return d->angle2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief KAsm1 return coefficient of length first control line. + * @return coefficient. + */ +qreal VSplinePoint::KAsm1() const +{ + return d->kAsm1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetKAsm1 set coefficient of length first control line. + * @param value coefficient. + */ +void VSplinePoint::SetKAsm1(const qreal &value) +{ + d->kAsm1 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief KAsm2 return coefficient of length second control line. + * @return coefficient. + */ +qreal VSplinePoint::KAsm2() const +{ + return d->kAsm2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetKAsm2 set coefficient of length second control line. + * @param value coefficient. + */ +void VSplinePoint::SetKAsm2(const qreal &value) +{ + d->kAsm2 = value; +} diff --git a/src/app/geometry/vsplinepoint.h b/src/app/geometry/vsplinepoint.h new file mode 100644 index 000000000..ae9d569d5 --- /dev/null +++ b/src/app/geometry/vsplinepoint.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vsplinepoint.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VSPLINEPOINT_H +#define VSPLINEPOINT_H + +#include "vpointf.h" +#include + +class VSplinePointData; + +/** + * @brief The VSplinePoint class keep information about point in spline path. Each point have two angles and two + * coefficient. Point represent at the same time first and last point of spline. + */ +class VSplinePoint +{ +public: + VSplinePoint(); + VSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); + VSplinePoint(const VSplinePoint &point); + VSplinePoint &operator=(const VSplinePoint &point); + ~VSplinePoint(); + + VPointF P() const; + void SetP(const VPointF &value); + qreal Angle1() const; + void SetAngle1(const qreal &value); + void SetAngle2(const qreal &value); + qreal Angle2() const; + qreal KAsm1() const; + void SetKAsm1(const qreal &value); + qreal KAsm2() const; + void SetKAsm2(const qreal &value); +protected: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(VSplinePoint) + +#endif // VSPLINEPOINT_H diff --git a/src/app/geometry/vsplinepoint_p.h b/src/app/geometry/vsplinepoint_p.h new file mode 100644 index 000000000..4e7789358 --- /dev/null +++ b/src/app/geometry/vsplinepoint_p.h @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file vsplinepoint_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @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) 2014 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 VSPLINEPOINT_P_H +#define VSPLINEPOINT_P_H + +#include +#include "../options.h" +#include "vpointf.h" +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VSplinePointData : public QSharedData +{ +public: + + VSplinePointData() + :pSpline(VPointF()), angle1(0), angle2(180), kAsm1(1), kAsm2(1) + {} + + VSplinePointData(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) + :pSpline(pSpline), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2) + { + if (qFuzzyCompare(qAbs(angle1-angle2), 180) == false) + { + qWarning()<<"angle1 and angle2 are not equal."; + this->angle1 = angle1; + this->angle2 = angle1 + 180; + } + } + + VSplinePointData(const VSplinePointData &point) + :QSharedData(point), pSpline(point.pSpline), angle1(point.angle1), angle2(point.angle2), kAsm1(point.kAsm1), + kAsm2(point.kAsm2) + {} + + virtual ~VSplinePointData(); + + /** @brief pSpline point. */ + VPointF pSpline; + + /** @brief angle1 first angle spline. */ + qreal angle1; + + /** @brief angle2 second angle spline. */ + qreal angle2; + + /** @brief kAsm1 coefficient of length first control line. */ + qreal kAsm1; + + /** @brief kAsm2 coefficient of length second control line. */ + qreal kAsm2; +}; + +VSplinePointData::~VSplinePointData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VSPLINEPOINT_P_H diff --git a/src/app/main.cpp b/src/app/main.cpp new file mode 100644 index 000000000..fc19562e5 --- /dev/null +++ b/src/app/main.cpp @@ -0,0 +1,131 @@ +/************************************************************************ + ** + ** @file main.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "mainwindow.h" +#include "core/vapplication.h" +#include "core/vsettings.h" +#include "tablewindow.h" +#include "version.h" + +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(cursor); + Q_INIT_RESOURCE(icon); + Q_INIT_RESOURCE(schema); + Q_INIT_RESOURCE(theme); + Q_INIT_RESOURCE(flags); + + QT_REQUIRE_VERSION(argc, argv, "5.2.0"); + + VApplication app(argc, argv); + + app.setApplicationDisplayName(VER_PRODUCTNAME_STR); + app.setApplicationName(VER_INTERNALNAME_STR); + app.setOrganizationName(VER_COMPANYNAME_STR); + app.setOrganizationDomain(VER_COMPANYDOMAIN_STR); + // Setting the Application version + app.setApplicationVersion(APP_VERSION); + + app.OpenSettings(); + +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) + // Catch and send report + VApplication::DrMingw(); + app.CollectReports(); +#endif + + // Run creation log after sending crash report + app.StartLogging(); + + qDebug()<<"Version:"<getSettings()->GetLocale(); + qDebug()<<"Checked locale:"<translationsPath()); + app.installTranslator(&appTranslator); + + static const char * GENERIC_ICON_TO_CHECK = "document-open"; + if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) + { + //If there is no default working icon theme then we should + //use an icon theme that we provide via a .qrc file + //This case happens under Windows and Mac OS X + //This does not happen under GNOME or KDE + QIcon::setThemeName("win.icon.theme"); + } + + MainWindow w; + app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); + app.setMainWindow(&w); + TableWindow table; + QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen); + QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed); + + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::translate("main", "Pattern making program.")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file.")); + parser.process(app); + QStringList args = parser.positionalArguments(); + + //Before we load pattern show window. + w.show(); + + w.ReopenFilesAfterCrash(args); + + for (int i=0;i + ** @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 + ** 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 "mainwindow.h" +#include "ui_mainwindow.h" +#include "geometry/vspline.h" +#include "geometry/vequidistant.h" +#include "exception/vexceptionobjecterror.h" +#include "exception/vexceptionconversionerror.h" +#include "exception/vexceptionemptyparameter.h" +#include "exception/vexceptionwrongid.h" +#include "exception/vexceptionundo.h" +#include "version.h" +#include "xml/vstandardmeasurements.h" +#include "xml/vindividualmeasurements.h" +#include "core/vapplication.h" +#include "core/undoevent.h" +#include "core/vsettings.h" +#include "undocommands/renamepp.h" +#include "vtooloptionspropertybrowser.h" +#include "options.h" +#include "../libs/ifc/xml/vpatternconverter.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MainWindow constructor. + * @param parent parent widget. + */ +MainWindow::MainWindow(QWidget *parent) + :QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Tool::Arrow), + currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr), + isInitialized(false), dialogTable(nullptr), dialogTool(nullptr), dialogHistory(nullptr), + comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0), + currentToolBoxIndex(0), drawMode(true), recentFileActs(), + separatorAct(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr), + gradationSizes(nullptr), toolOptions(nullptr), lock(nullptr) +{ + for (int i = 0; i < MaxRecentFiles; ++i) + { + recentFileActs[i] = nullptr; + } + + CreateActions(); + CreateMenus(); + ToolBarDraws(); + InitToolButtons(); + + sceneDraw = new VMainGraphicsScene(); + currentScene = sceneDraw; + qApp->setCurrentScene(currentScene); + connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + sceneDetails = new VMainGraphicsScene(); + connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + + ui->view->setScene(currentScene); + + sceneDraw->setTransform(ui->view->transform()); + sceneDetails->setTransform(ui->view->transform()); + + connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); + policy.setHorizontalStretch(12); + ui->view->setSizePolicy(policy); + qApp->setSceneView(ui->view); + + helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working.")); + ui->statusBar->addWidget(helpLabel); + + ToolBarTools(); + + pattern = new VContainer(); + + doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); + connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); + connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); + connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); + connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); + connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout); + connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP); + qApp->setCurrentDocument(doc); + + connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); + + InitAutoSave(); + + ui->toolBox->setCurrentIndex(0); + + ReadSettings(); + PropertyBrowser(); + + setCurrentFile(""); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionNewPP add to scene new pattern piece. + */ +void MainWindow::ActionNewPP() +{ + qCDebug(vMainWindow)<<"New PP."; + QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); + qCDebug(vMainWindow)<<"Generated PP name:"<count() == 0) + { + qCDebug(vMainWindow)<<"First PP"; + DialogMeasurements measurements(this); + if (measurements.exec() == QDialog::Rejected) + { + qCDebug(vMainWindow)<<"Creation PP was canceled"; + return; + } + if (measurements.type() == MeasurementsType::Standard) + { + qCDebug(vMainWindow)<<"PP with standard measurements"; + qApp->setPatternType(MeasurementsType::Standard); + DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this); + if (stMeasurements.exec() == QDialog::Accepted) + { + patternPieceName = stMeasurements.name(); + qCDebug(vMainWindow)<<"PP name:"<setPatternType(MeasurementsType::Individual); + DialogIndividualMeasurements indMeasurements(pattern, patternPieceName, this); + if (indMeasurements.exec() == QDialog::Accepted) + { + patternPieceName = indMeasurements.name(); + qCDebug(vMainWindow)<<"PP name:"<view); + VAbstractTool::NewSceneRect(sceneDetails, ui->view); + ToolBarOption(); + } + else + { + qCDebug(vMainWindow)<<"PP count"<count(); + patternPieceName = PatternPieceName(patternPieceName); + qCDebug(vMainWindow)<<"PP name:"<MPath(); + } + if (doc->appendPP(patternPieceName) == false) + { + qCDebug(vMainWindow)<<"Error creating pattern piece with the name "<blockSignals(true); + comboBoxDraws->addItem(patternPieceName); + + pattern->ClearGObjects(); + //Create single point + ui->view->itemClicked(nullptr);//hide options previous tool + QString label = doc->GenerateLabel(LabelType::NewPatternPiece); + const quint32 id = pattern->AddGObject(new VPointF(30+comboBoxDraws->count()*5, 40, label, 5, 10)); + VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Source::FromGui, patternPieceName, path); + sceneDraw->addItem(spoint); + ui->view->itemClicked(spoint); + connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); + connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + tools->insert(id, spoint); + VDrawTool::AddRecord(id, Tool::SinglePoint, doc); + SetEnableTool(true); + SetEnableWidgets(true); + + const qint32 index = comboBoxDraws->findText(patternPieceName); + if ( index != -1 ) + { // -1 for not found + comboBoxDraws->setCurrentIndex(index); + } + else + { + comboBoxDraws->setCurrentIndex(0); + } + comboBoxDraws->blockSignals(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief OptionDraw help change name of pattern piece. + */ +void MainWindow::OptionDraw() +{ + const QString activDraw = doc->GetNameActivPP(); + const QString nameDraw = PatternPieceName(activDraw); + if (nameDraw.isEmpty()) + { + return; + } + RenamePP *renamePP = new RenamePP(doc, nameDraw, comboBoxDraws); + qApp->getUndoStack()->push(renamePP); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetToolButton set tool and show dialog. + * @param checked true if tool button checked. + * @param t tool type. + * @param cursor path tool cursor icon. + * @param toolTip first tooltipe. + * @param closeDialogSlot function what handle after close dialog. + */ +template +void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot) +{ + if (checked) + { + CancelTool(); + tool = t; + QPixmap pixmap(cursor); + QCursor cur(pixmap, 2, 3); + ui->view->setCursor(cur); + helpLabel->setText(toolTip); + ui->view->setShowToolOptions(false); + dialogTool = new Dialog(pattern, 0, this); + connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); + connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); + connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); + connect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); + ui->view->itemClicked(nullptr); + } + else + { + if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + { + SCASSERT(tButton != nullptr); + tButton->setChecked(true); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +template +/** + * @brief SetToolButtonWithApply set tool and show dialog. + * @param checked true if tool button checked. + * @param t tool type. + * @param cursor path tool cursor icon. + * @param toolTip first tooltipe. + * @param closeDialogSlot function to handle close of dialog. + * @param applyDialogSlot function to handle apply in dialog. + */ +void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot, Func2 applyDialogSlot) +{ + if (checked) + { + CancelTool(); + tool = t; + QPixmap pixmap(cursor); + QCursor cur(pixmap, 2, 3); + ui->view->setCursor(cur); + ui->view->setShowToolOptions(false); + helpLabel->setText(toolTip); + dialogTool = new Dialog(pattern, 0, this); + connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); + connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); + connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot); + connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); + connect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); + connect(ui->view, &VMainGraphicsView::MouseRelease, this, &MainWindow::ClickEndVisualization); + ui->view->itemClicked(nullptr); + } + else + { + if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + { + SCASSERT(tButton != nullptr); + tButton->setChecked(true); + } + } +} +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialog handle close dialog + * @param result result working dialog. + */ +template +void MainWindow::ClosedDialog(int result) +{ + SCASSERT(dialogTool != nullptr); + if (result == QDialog::Accepted) + { + QGraphicsItem *tool = dynamic_cast(DrawTool::Create(dialogTool, currentScene, doc, pattern)); + ui->view->itemClicked(tool); + } + ArrowTool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogWithApply handle close dialog that has apply button + * @param result result working dialog. + */ +template +void MainWindow::ClosedDialogWithApply(int result) +{ + SCASSERT(dialogTool != nullptr); + if (result == QDialog::Accepted) + { + // Only create tool if not already created with apply + if (dialogTool->GetAssociatedTool() == nullptr) + { + dialogTool->SetAssociatedTool( + dynamic_cast (DrawTool::Create(dialogTool, currentScene, doc, pattern))); + } + else + { // Or update associated tool with data + VDrawTool * vtool= static_cast(dialogTool->GetAssociatedTool()); + vtool->FullUpdateFromGuiApply(); + } + } + QGraphicsItem *tool = dynamic_cast(dialogTool->GetAssociatedTool()); + ui->view->itemClicked(tool); + if (dialogTool->GetAssociatedTool() != nullptr) + { + VDrawTool *vtool= static_cast(dialogTool->GetAssociatedTool()); + vtool->DialogLinkDestroy(); + } + ArrowTool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ApplyDialog handle apply in dialog + */ +template +void MainWindow::ApplyDialog() +{ + SCASSERT(dialogTool != nullptr); + + // Only create tool if not already created with apply + if (dialogTool->GetAssociatedTool() == nullptr) + { + dialogTool->SetAssociatedTool( + static_cast (DrawTool::Create(dialogTool, currentScene, doc, pattern))); + } + else + { // Or update associated tool with data + VDrawTool * vtool= static_cast(dialogTool->GetAssociatedTool()); + SCASSERT(vtool != nullptr); + vtool->FullUpdateFromGuiApply(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolEndLine handler tool endLine. + * @param checked true - button checked. + */ +void MainWindow::ToolEndLine(bool checked) +{ + SetToolButtonWithApply(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolLine handler tool line. + * @param checked true - button checked. + */ +void MainWindow::ToolLine(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolAlongLine handler tool alongLine. + * @param checked true - button checked. + */ +void MainWindow::ToolAlongLine(bool checked) +{ + SetToolButtonWithApply(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png", + tr("Select point"), &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolShoulderPoint handler tool shoulderPoint. + * @param checked true - button checked. + */ +void MainWindow::ToolShoulderPoint(bool checked) +{ + SetToolButtonWithApply(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png", + tr("Select point"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolNormal handler tool normal. + * @param checked true - button checked. + */ +void MainWindow::ToolNormal(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Normal, ":/cursor/normal_cursor.png", + tr("Select first point of line"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBisector handler tool bisector. + * @param checked true - button checked. + */ +void MainWindow::ToolBisector(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Bisector, ":/cursor/bisector_cursor.png", + tr("Select first point of angle"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolLineIntersect handler tool lineIntersect. + * @param checked true - button checked. + */ +void MainWindow::ToolLineIntersect(bool checked) +{ + SetToolButtonWithApply(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png", + tr("Select first point of first line"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolSpline handler tool spline. + * @param checked true - button checked. + */ +void MainWindow::ToolSpline(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Spline, ":/cursor/spline_cursor.png", + tr("Select first point curve"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutSpline handler tool CutSpline. + * @param checked true - button is checked + */ +void MainWindow::ToolCutSpline(bool checked) +{ + SetToolButtonWithApply(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png", + tr("Select simple curve"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolArc handler tool arc. + * @param checked true - button checked. + */ +void MainWindow::ToolArc(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Arc, ":/cursor/arc_cursor.png", + tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolSplinePath handler tool splinePath. + * @param checked true - button checked. + */ +void MainWindow::ToolSplinePath(bool checked) +{ + SetToolButtonWithApply(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png", + tr("Select point of curve path"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutSplinePath handler tool CutSplinePath. + * @param checked true - button is checked + */ +void MainWindow::ToolCutSplinePath(bool checked) +{ + SetToolButtonWithApply(checked, Tool::CutSplinePath, + ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolPointOfContact handler tool pointOfContact. + * @param checked true - button checked. + */ +void MainWindow::ToolPointOfContact(bool checked) +{ + SetToolButtonWithApply(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", + tr("Select first point of line"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolDetail handler tool detail. + * @param checked true - button checked. + */ +void MainWindow::ToolDetail(bool checked) +{ + SetToolButton(checked, Tool::Detail, "://cursor/new_detail_cursor.png", + tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogDetail actions after closing DialogDetail. + * @param result result of dialog working. + */ +void MainWindow::ClosedDialogDetail(int result) +{ + if (result == QDialog::Accepted) + { + VToolDetail::Create(dialogTool, sceneDetails, doc, pattern); + } + ArrowTool(); + doc->LiteParseTree(Document::LiteParse); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolHeight handler tool height. + * @param checked true - button checked. + */ +void MainWindow::ToolHeight(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolTriangle handler tool triangle. + * @param checked true - button checked. + */ +void MainWindow::ToolTriangle(bool checked) +{ + SetToolButtonWithApply(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", + tr("Select first point of axis"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolPointOfIntersection handler tool pointOfIntersection. + * @param checked true - button checked. + */ +void MainWindow::ToolPointOfIntersection(bool checked) +{ + SetToolButtonWithApply(checked, Tool::PointOfIntersection, + ":/cursor/pointofintersect_cursor.png", + tr("Select point vertically"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolUnionDetails handler tool unionDetails. + * @param checked true - button checked. + */ +void MainWindow::ToolUnionDetails(bool checked) +{ + SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png", + tr("Select detail"), &MainWindow::ClosedDialogUnionDetails); + //Must disconnect this signal here. + disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedDialogUnionDetails actions after closing DialogUnionDetails. + * @param result result of dialog working. + */ +void MainWindow::ClosedDialogUnionDetails(int result) +{ + ClosedDialog(result); + doc->LiteParseTree(Document::LiteParse); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolCutArc handler tool cutArc. + * @param checked true - button checked. + */ +void MainWindow::ToolCutArc(bool checked) +{ + SetToolButtonWithApply(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png", + tr("Select arc"), &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolLineIntersectAxis(bool checked) +{ + SetToolButtonWithApply(checked, Tool::LineIntersectAxis, + ":/cursor/line_intersect_axis_cursor.png", + tr("Select first point of line"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolCurveIntersectAxis(bool checked) +{ + SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, + ":/cursor/curve_intersect_axis_cursor.png", + tr("Select curve"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief About show widows about. + */ +void MainWindow::About() +{ + DialogAboutApp * about_dialog = new DialogAboutApp(this); + about_dialog->setAttribute(Qt::WA_DeleteOnClose, true); + about_dialog->show(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AboutQt show widows aboutQt. + */ +void MainWindow::AboutQt() +{ + QMessageBox::aboutQt(this, tr("About Qt")); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool.Tip show tools tooltip. + * @param toolTip tooltip text. + */ +void MainWindow::ShowToolTip(const QString &toolTip) +{ + helpLabel->setText(toolTip); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief tableClosed handle after close layout window. + */ +void MainWindow::tableClosed() +{ + show(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::OpenRecentFile() +{ + QAction *action = qobject_cast(sender()); + if (action) + { + const QString filePath = action->data().toString(); + if (filePath.isEmpty() == false) + { + LoadPattern(filePath); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PatternProperties() +{ + DialogPatternProperties proper(doc, this); + connect(&proper, &DialogPatternProperties::UpdateGradation, this, &MainWindow::UpdateGradation); + proper.exec(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::EditPatternCode() +{ + DialogPatternXmlEdit *Pattern = new DialogPatternXmlEdit (this, doc); + Pattern->setAttribute(Qt::WA_DeleteOnClose, true); + Pattern->show(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief showEvent handle after show window. + * @param event show event. + */ +void MainWindow::showEvent( QShowEvent *event ) +{ + QMainWindow::showEvent( event ); + if ( event->spontaneous() ) + { + return; + } + + if (isInitialized) + { + return; + } + // do your init stuff here + + MinimumScrollBar(); + + isInitialized = true;//first show windows are held +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle after close window. + * @param event close event. + */ +void MainWindow::closeEvent(QCloseEvent *event) +{ + qCDebug(vMainWindow)<<"Closing main window"; + if (MaybeSave()) + { + FileClosedCorrect(); + + event->accept(); + qApp->closeAllWindows(); + } + else + { + qCDebug(vMainWindow)<<"Closing canceled."; + event->ignore(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::customEvent(QEvent *event) +{ + if (event->type() == UNDO_EVENT) + { + qApp->getUndoStack()->undo(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBarOption enable option toolbar. + */ +void MainWindow::ToolBarOption() +{ + if (qApp->patternType() == MeasurementsType::Standard) + { + const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights()); + const QStringList listSizes = VMeasurement::ListSizes(doc->GetGradationSizes()); + + gradationHeights = SetGradationList(tr("Height: "), listHeights); + SetDefaultHeight(static_cast(GHeights::H176)); + connect(gradationHeights, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::ChangedHeight); + + gradationSizes = SetGradationList(tr("Size: "), listSizes); + SetDefaultSize(static_cast(GSizes::S50)); + connect(gradationSizes, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::ChangedSize); + + ui->toolBarOption->addSeparator(); + } + + mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(doc->UnitsToStr(qApp->patternUnit()))); + ui->toolBarOption->addWidget(mouseCoordinate); +} + +//--------------------------------------------------------------------------------------------------------------------- +QComboBox *MainWindow::SetGradationList(const QString &label, const QStringList &list) +{ + ui->toolBarOption->addWidget(new QLabel(label)); + + QComboBox *comboBox = new QComboBox; + comboBox->addItems(list); + ui->toolBarOption->addWidget(comboBox); + + return comboBox; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::SetDefaultHeight(int value) +{ + qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit()); + QString strVal = QString("%1").arg(val); + + qint32 index = gradationHeights->findText(strVal); + if (index != -1) + { + gradationHeights->setCurrentIndex(index); + } + else + { + pattern->SetHeight(gradationHeights->currentText().toInt()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::SetDefaultSize(int value) +{ + qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit()); + QString strVal = QString("%1").arg(val); + + qint32 index = gradationSizes->findText(strVal); + if (index != -1) + { + gradationSizes->setCurrentIndex(index); + } + else + { + pattern->SetSize(gradationSizes->currentText().toInt()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ToolBarDraws enable draw toolbar. + */ +void MainWindow::ToolBarDraws() +{ + QLabel *labelPtternPieceName = new QLabel(tr("Pattern Piece: ")); + ui->toolBarDraws->addWidget(labelPtternPieceName); + + comboBoxDraws = new QComboBox; + ui->toolBarDraws->addWidget(comboBoxDraws); + comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); + connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentPPChanged); + + ui->toolBarDraws->addAction(ui->actionOptionDraw); + ui->actionOptionDraw->setEnabled(false); + + ui->toolBarDraws->addAction(ui->actionTable); + ui->actionTable->setEnabled(false); + + ui->toolBarDraws->addAction(ui->actionHistory); + ui->actionHistory->setEnabled(false); + connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory); + + ui->toolBarDraws->addAction(ui->actionLayout); + connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout); + ui->actionLayout->setEnabled(false); +} + +void MainWindow::ToolBarTools() +{ + /*First we will try use Standard Shortcuts from Qt, but because keypad "-" and "+" not the same keys like in main + keypad, shortcut Ctrl+"-" or "+" from keypad will not working with standard shortcut (QKeySequence::ZoomIn or + QKeySequence::ZoomOut). For examle "+" is Qt::Key_Plus + Qt::KeypadModifier for keypad. + Also for me don't work Qt:CTRL and work Qt::ControlModifier.*/ + + QList zoomInShortcuts; + zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn)); + zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier)); + ui->actionZoomIn->setShortcuts(zoomInShortcuts); + connect(ui->actionZoomIn, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomIn); + + QList zoomOutShortcuts; + zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut)); + zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier)); + ui->actionZoomOut->setShortcuts(zoomOutShortcuts); + connect(ui->actionZoomOut, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomOut); + + QList zoomOriginalShortcuts; + zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0)); + zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier)); + ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts); + connect(ui->actionZoomOriginal, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomOriginal); + + QList zoomFitBestShortcuts; + zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal)); + ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts); + connect(ui->actionZoomFitBest, &QAction::triggered, ui->view, &VMainGraphicsView::ZoomFitBest); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::InitToolButtons() +{ + connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); + connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); + connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine); + connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint); + connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal); + connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector); + connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect); + connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); + connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); + connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); + connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); + connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); + connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); + connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); + connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection); + connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline); + connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath); + connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails); + connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc); + connect(ui->toolButtonLineIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolLineIntersectAxis); + connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); + connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief currentPPChanged change active pattern piece. + * @param index index in combobox. + */ +void MainWindow::currentPPChanged(int index) +{ + ChangePP(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseMove save mouse position and show user. + * @param scenePos position mouse. + */ +void MainWindow::mouseMove(const QPointF &scenePos) +{ + QString string = QString("%1, %2 (%3)").arg(static_cast(qApp->fromPixel(scenePos.x()))) + .arg(static_cast(qApp->fromPixel(scenePos.y()))) + .arg(doc->UnitsToStr(qApp->patternUnit())); + if (mouseCoordinate != nullptr) + { + mouseCoordinate->setText(string); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CancelTool cancel tool. + */ +void MainWindow::CancelTool() +{ + qCDebug(vMainWindow)<<"Canceling tool."; + delete dialogTool; + dialogTool = nullptr; + qCDebug(vMainWindow)<<"Dialog closed."; + switch ( tool ) + { + case Tool::Arrow: + ui->actionArrowTool->setChecked(false); + helpLabel->setText(""); + ui->actionStopTool->setEnabled(true); + break; + case Tool::SinglePoint: + Q_UNREACHABLE(); + //Nothing to do here because we can't create this tool from main window. + break; + case Tool::EndLine: + ui->toolButtonEndLine->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Line: + ui->toolButtonLine->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearFocus(); + break; + case Tool::AlongLine: + ui->toolButtonAlongLine->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::ShoulderPoint: + ui->toolButtonShoulderPoint->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Normal: + ui->toolButtonNormal->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Bisector: + ui->toolButtonBisector->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::LineIntersect: + ui->toolButtonLineIntersect->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Spline: + ui->toolButtonSpline->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Arc: + ui->toolButtonArc->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::SplinePath: + ui->toolButtonSplinePath->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::PointOfContact: + ui->toolButtonPointOfContact->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Detail: + ui->toolButtonNewDetail->setChecked(false); + break; + case Tool::Height: + ui->toolButtonHeight->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Triangle: + ui->toolButtonTriangle->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::PointOfIntersection: + ui->toolButtonPointOfIntersection->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::CutSpline: + ui->toolButtonSplineCutPoint->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::CutSplinePath: + ui->toolButtonSplinePathCutPoint->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::UnionDetails: + ui->toolButtonUnionDetails->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::CutArc: + ui->toolButtonArcCutPoint->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::LineIntersectAxis: + ui->toolButtonLineIntersectAxis->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::CurveIntersectAxis: + ui->toolButtonCurveIntersectAxis->setChecked(false); + ui->toolButtonArcIntersectAxis->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::NodePoint: + case Tool::NodeArc: + case Tool::NodeSpline: + case Tool::NodeSplinePath: + default: + qDebug()<<"Got wrong tool type. Ignored."; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArrowTool enable arrow tool. + */ +void MainWindow::ArrowTool() +{ + qCDebug(vMainWindow)<<"Arrow tool."; + CancelTool(); + ui->actionArrowTool->setChecked(true); + ui->actionStopTool->setEnabled(false); + tool = Tool::Arrow; + QCursor cur(Qt::ArrowCursor); + ui->view->setCursor(cur); + helpLabel->setText(""); + ui->view->setShowToolOptions(true); + qCDebug(vMainWindow)<<"Enabled arrow tool."; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key event. + */ +void MainWindow::keyPressEvent ( QKeyEvent * event ) +{ + switch (event->key()) + { + case Qt::Key_Escape: + ArrowTool(); + break; + case Qt::Key_Return: + EndVisualization(); + break; + case Qt::Key_Enter: + EndVisualization(); + break; + default: + break; + } + QMainWindow::keyPressEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveCurrentScene save scene options before set another. + */ +void MainWindow::SaveCurrentScene() +{ + /*Save transform*/ + currentScene->setTransform(ui->view->transform()); + /*Save scroll bars value for previous scene.*/ + QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); + currentScene->setHorScrollBar(horScrollBar->value()); + QScrollBar *verScrollBar = ui->view->verticalScrollBar(); + currentScene->setVerScrollBar(verScrollBar->value()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RestoreCurrentScene restore scene options after change. + */ +void MainWindow::RestoreCurrentScene() +{ + /*Set transform for current scene*/ + ui->view->setTransform(currentScene->transform()); + /*Set value for current scene scroll bar.*/ + QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); + horScrollBar->setValue(currentScene->getHorScrollBar()); + QScrollBar *verScrollBar = ui->view->verticalScrollBar(); + verScrollBar->setValue(currentScene->getVerScrollBar()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionDraw show draw scene. + * @param checked true - button checked. + */ +void MainWindow::ActionDraw(bool checked) +{ + if (checked) + { + qCDebug(vMainWindow)<<"Show draw scene"; + ui->actionDetails->setChecked(false); + SaveCurrentScene(); + + currentScene = sceneDraw; + ui->view->setScene(currentScene); + connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + RestoreCurrentScene(); + + mode = Draw::Calculation; + comboBoxDraws->setEnabled(true); + comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace + drawMode = true; + + SetEnableTool(true); + doc->setCurrentData(); + ui->toolBox->setCurrentIndex(currentToolBoxIndex); + + ui->actionHistory->setEnabled(true); + ui->actionOptionDraw->setEnabled(true); + ui->actionNewDraw->setEnabled(true); + } + else + { + ui->actionDraw->setChecked(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionDetails show details scene. + * @param checked true - button checked. + */ +void MainWindow::ActionDetails(bool checked) +{ + if (checked) + { + qCDebug(vMainWindow)<<"Show details scene"; + ui->actionDraw->setChecked(false); + SaveCurrentScene(); + + currentScene = sceneDetails; + ui->view->setScene(sceneDetails); + disconnect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + RestoreCurrentScene(); + + drawMode = false; + currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace + comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1); + comboBoxDraws->setEnabled(false); + + + mode = Draw::Modeling; + SetEnableTool(true); + currentToolBoxIndex = ui->toolBox->currentIndex(); + ui->toolBox->setCurrentIndex(4); + + ui->actionHistory->setEnabled(false); + ui->actionOptionDraw->setEnabled(false); + ui->actionNewDraw->setEnabled(false); + } + else + { + ui->actionDetails->setChecked(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveAs save as pattern file. + * @return true for successes saving. + */ +bool MainWindow::SaveAs() +{ + QString filters(tr("Pattern files (*.val)")); + QString dir; + if (curFile.isEmpty()) + { + dir = qApp->getSettings()->GetPathPattern() + "/" + tr("pattern") + ".val"; + } + else + { + dir = QFileInfo(curFile).absolutePath() + tr("/pattern.val"); + } + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters); + + if (fileName.isEmpty()) + { + return false; + } + QFileInfo f( fileName ); + if (f.suffix().isEmpty() && f.suffix() != "val") + { + fileName += ".val"; + } + const QString oldFileName = curFile; + QString error; + bool result = SavePattern(fileName, error); + if (result == false) + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save file")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } + if (oldFileName != curFile) + {// Now we have new file name after save as. + // But still have previous name in restore list. We should delete them. + QStringList restoreFiles = qApp->getSettings()->GetRestoreFileList(); + restoreFiles.removeAll(oldFileName); + qApp->getSettings()->SetRestoreFileList(restoreFiles); + } + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Save save pattern file. + * @return true for successes saving. + */ +bool MainWindow::Save() +{ + if (curFile.isEmpty()) + { + return SaveAs(); + } + else + { + QString error; + bool result = SavePattern(curFile, error); + if (result) + { + QString autofile = curFile +".autosave"; + QFile file(autofile); + file.remove(); + } + else + { + QMessageBox messageBox; + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save file")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + } + return result; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Open ask user select pattern file. + */ +void MainWindow::Open() +{ + qCDebug(vMainWindow)<<"Openning new file."; + const QString filter(tr("Pattern files (*.val)")); + //Get list last open files + const QStringList files = qApp->getSettings()->GetRecentFileList(); + QString dir; + if (files.isEmpty()) + { + dir = QDir::homePath(); + } + else + { + //Absolute path to last open file + dir = QFileInfo(files.first()).absolutePath(); + } + qCDebug(vMainWindow)<<"Run QFileDialog::getOpenFileName: dir ="<actionDetails->setChecked(false); + ui->actionDetails->setEnabled(false); + ui->actionDraw->setChecked(true); + ui->actionDraw->setEnabled(false); + qCDebug(vMainWindow)<<"Returned to Draw mode."; + setCurrentFile(QString()); + pattern->Clear(); + qCDebug(vMainWindow)<<"Clearing pattern."; + doc->clear(); + qCDebug(vMainWindow)<<"Clearing scenes."; + sceneDraw->clear(); + sceneDetails->clear(); + ArrowTool(); + comboBoxDraws->clear(); + ui->actionOptionDraw->setEnabled(false); + ui->actionSave->setEnabled(false); + ui->actionSaveAs->setEnabled(false); + ui->actionPattern_properties->setEnabled(false); + ui->actionZoomIn->setEnabled(false); + ui->actionZoomOut->setEnabled(false); + ui->actionZoomFitBest->setEnabled(false); + ui->actionZoomOriginal->setEnabled(false); + ui->actionHistory->setEnabled(false); + ui->actionTable->setEnabled(false); + ui->actionEdit_pattern_code->setEnabled(false); + SetEnableTool(false); + qApp->setPatternUnit(Unit::Cm); + qApp->setPatternType(MeasurementsType::Individual); + ui->toolBarOption->clear(); +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + Layout(); + +#ifdef Q_OS_WIN32 + qt_ntfs_permission_lookup--; // turn it off again +#endif /*Q_OS_WIN32*/ + qApp->getUndoStack()->clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::FileClosedCorrect() +{ + WriteSettings(); + + //File was closed correct. + QStringList restoreFiles = qApp->getSettings()->GetRestoreFileList(); + restoreFiles.removeAll(curFile); + qApp->getSettings()->SetRestoreFileList(restoreFiles); + + // Remove autosave file + QFile autofile(curFile +".autosave"); + if (autofile.exists()) + { + autofile.remove(); + } + qCDebug(vMainWindow)<<"File"<ClearPropertyBrowser(); + try + { + SetEnabledGUI(true); + doc->Parse(Document::FullParse); + } + catch (const VExceptionUndo &e) + { + Q_UNUSED(e); + /* If user want undo last operation before undo we need finish broken redo operation. For those we post event + * myself. Later in method customEvent call undo.*/ + QApplication::postEvent(this, new UndoEvent()); + return; + } + catch (const VExceptionObjectError &e) + { + e.CriticalMessageBox(tr("Error parsing file."), this); + SetEnabledGUI(false); + return; + } + catch (const VExceptionConversionError &e) + { + e.CriticalMessageBox(tr("Error can't convert value."), this); + SetEnabledGUI(false); + return; + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter."), this); + SetEnabledGUI(false); + return; + } + catch (const VExceptionWrongId &e) + { + e.CriticalMessageBox(tr("Error wrong id."), this); + SetEnabledGUI(false); + return; + } + catch (VException &e) + { + e.CriticalMessageBox(tr("Error parsing file."), this); + SetEnabledGUI(false); + return; + } + catch (const std::bad_alloc &) + { +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + QMessageBox::critical(this, tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."), QMessageBox::Ok, + QMessageBox::Ok); +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + SetEnabledGUI(false); + return; + } + + QString patternPiece = QString(); + if (comboBoxDraws->currentIndex() != -1) + { + patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); + } + comboBoxDraws->blockSignals(true); + comboBoxDraws->clear(); + comboBoxDraws->addItems(doc->getPatternPieces()); + comboBoxDraws->blockSignals(false); + ui->actionPattern_properties->setEnabled(true); + + GlobalChangePP(patternPiece); + + if (comboBoxDraws->count() > 0) + { + SetEnableTool(true); + } + else + { + SetEnableTool(false); + } + SetEnableWidgets(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::GlobalChangePP(const QString &patternPiece) +{ + const qint32 index = comboBoxDraws->findText(patternPiece); + try + { + if ( index != -1 ) + { // -1 for not found + ChangePP(index, false); + } + else + { + ChangePP(0, false); + } + } + catch (VExceptionBadId &e) + { + e.CriticalMessageBox(tr("Bad id."), this); + SetEnabledGUI(false); + return; + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter."), this); + SetEnabledGUI(false); + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::SetEnabledGUI(bool enabled) +{ + if (guiEnabled != enabled) + { + if (enabled == false) + { + ArrowTool(); + qApp->getUndoStack()->clear(); + } + comboBoxDraws->setEnabled(enabled); + ui->actionOptionDraw->setEnabled(enabled); + ui->actionSave->setEnabled(enabled); + ui->actionSaveAs->setEnabled(enabled); + ui->actionPattern_properties->setEnabled(enabled); + ui->actionEdit_pattern_code->setEnabled(enabled); + ui->actionZoomIn->setEnabled(enabled); + ui->actionZoomOut->setEnabled(enabled); + ui->actionArrowTool->setEnabled(enabled); + ui->actionHistory->setEnabled(enabled); + ui->actionNewDraw->setEnabled(enabled); + ui->actionDraw->setEnabled(enabled); + ui->actionDetails->setEnabled(enabled); + ui->actionTable->setEnabled(enabled); + ui->actionLayout->setEnabled(enabled); + ui->actionZoomFitBest->setEnabled(enabled); + ui->actionZoomOriginal->setEnabled(enabled); + guiEnabled = enabled; + + sceneDraw->SetDisable(!enabled); + ui->view->setEnabled(enabled); + + SetEnableTool(enabled); + ui->toolBarOption->setEnabled(enabled); + #ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::ArrowCursor); + #endif + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClickEndVisualization() +{ + EndVisualization(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::Layout() +{ + const QHash *details = pattern->DataDetails(); + if (details->size() > 0) + { + ui->actionLayout->setEnabled(true); + } + else + { + ui->actionLayout->setEnabled(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateGradation() +{ + UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights())); + UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateHeightsList(const QStringList &list) +{ + QString val; + if (gradationHeights->currentIndex() != -1) + { + val = gradationHeights->currentText(); + } + + gradationHeights->blockSignals(true); + gradationHeights->clear(); + gradationHeights->addItems(list); + gradationHeights->blockSignals(false); + + int index = gradationHeights->findText(val); + if (index != -1) + { + gradationHeights->setCurrentIndex(index); + } + else + { + ChangedHeight(list.at(0)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateSizesList(const QStringList &list) +{ + QString val; + if (gradationSizes->currentIndex() != -1) + { + val = gradationSizes->currentText(); + } + + gradationSizes->blockSignals(true); + gradationSizes->clear(); + gradationSizes->addItems(list); + gradationSizes->blockSignals(false); + + int index = gradationSizes->findText(val); + if (index != -1) + { + gradationSizes->setCurrentIndex(index); + } + else + { + ChangedSize(list.at(0)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewPattern create new empty pattern. + */ +void MainWindow::NewPattern() +{ + OpenNewValentina(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief haveChange enable action save if we have unsaved change. + */ +void MainWindow::PatternWasModified(bool saved) +{ + if (guiEnabled) + { + setWindowModified(!saved); + ui->actionSave->setEnabled(!saved); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedSize change new size value. + * @param text value size. + */ +void MainWindow::ChangedSize(const QString & text) +{ + pattern->SetSize(text.toInt()); + doc->LiteParseTree(Document::LiteParse); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedGrowth change new height value. + * @param text value height. + */ +void MainWindow::ChangedHeight(const QString &text) +{ + pattern->SetHeight(text.toInt()); + doc->LiteParseTree(Document::LiteParse); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetEnableWidgets enable action button. + * @param enable enable value. + */ +void MainWindow::SetEnableWidgets(bool enable) +{ + ui->actionSaveAs->setEnabled(enable); + ui->actionDraw->setEnabled(enable); + ui->actionDetails->setEnabled(enable); + ui->actionOptionDraw->setEnabled(enable); + if (enable == true && curFile.isEmpty() == false) + { + ui->actionSave->setEnabled(enable); + } + ui->actionTable->setEnabled(enable); + ui->actionHistory->setEnabled(enable); + ui->actionPattern_properties->setEnabled(enable); + ui->actionEdit_pattern_code->setEnabled(enable); + ui->actionZoomIn->setEnabled(enable); + ui->actionZoomOut->setEnabled(enable); + ui->actionZoomFitBest->setEnabled(enable); + ui->actionZoomOriginal->setEnabled(enable); + //Now we want allow user call context menu + ui->view->setEnabled(enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionTable show table with variables. + * @param checked true - button checked. + */ +void MainWindow::ActionTable(bool checked) +{ + if (checked) + { + dialogTable = new DialogIncrements(pattern, doc, this); + connect(dialogTable, &DialogIncrements::DialogClosed, this, &MainWindow::ClosedActionTable); + dialogTable->show(); + } + else + { + ui->actionTable->setChecked(true); + dialogTable->activateWindow(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedActionTable actions after closing table with variables. + */ +void MainWindow::ClosedActionTable() +{ + ui->actionTable->setChecked(false); + delete dialogTable; + dialogTable = nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionHistory show tool history. + * @param checked true - button checked. + */ +void MainWindow::ActionHistory(bool checked) +{ + if (checked) + { + dialogHistory = new DialogHistory(pattern, doc, this); + dialogHistory->setWindowFlags(Qt::Window); + connect(this, &MainWindow::RefreshHistory, dialogHistory, &DialogHistory::UpdateHistory); + connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory); + dialogHistory->show(); + } + else + { + ui->actionHistory->setChecked(true); + dialogHistory->activateWindow(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionLayout begin creation layout. + * @param checked true - button checked. + */ +void MainWindow::ActionLayout(bool checked) +{ + Q_UNUSED(checked); + ActionDetails(true);//Get all list of details. + QVector listDetails; + const QHash *details = pattern->DataDetails(); + if (details->count() == 0) + { + return; + } + hide();//Now we can hide window + QHashIterator idetail(*details); + while (idetail.hasNext()) + { + idetail.next(); + QPainterPath path = VEquidistant(pattern).ContourPath(idetail.key()); + listDetails.append(new VItem(path, listDetails.size())); + } + QString description = doc->GetDescription(); + + QString fileName; + curFile.isEmpty() ? fileName = "unnamed" : fileName = curFile; + emit ModelChosen(listDetails, fileName, description); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosedActionHistory actions after closing history window with variables. + */ +void MainWindow::ClosedActionHistory() +{ + ui->actionHistory->setChecked(false); + delete dialogHistory; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetEnableTool enable button. + * @param enable enable value. + */ +void MainWindow::SetEnableTool(bool enable) +{ + bool drawTools = false; + bool modelingTools = false; + if (mode == Draw::Calculation) + { + drawTools = enable; + } + else + { + modelingTools = enable; + } + //Drawing Tools + ui->toolButtonEndLine->setEnabled(drawTools); + ui->toolButtonLine->setEnabled(drawTools); + ui->toolButtonAlongLine->setEnabled(drawTools); + ui->toolButtonShoulderPoint->setEnabled(drawTools); + ui->toolButtonNormal->setEnabled(drawTools); + ui->toolButtonBisector->setEnabled(drawTools); + ui->toolButtonLineIntersect->setEnabled(drawTools); + ui->toolButtonSpline->setEnabled(drawTools); + ui->toolButtonArc->setEnabled(drawTools); + ui->toolButtonSplinePath->setEnabled(drawTools); + ui->toolButtonPointOfContact->setEnabled(drawTools); + ui->toolButtonNewDetail->setEnabled(drawTools); + ui->toolButtonHeight->setEnabled(drawTools); + ui->toolButtonTriangle->setEnabled(drawTools); + ui->toolButtonPointOfIntersection->setEnabled(drawTools); + ui->toolButtonSplineCutPoint->setEnabled(drawTools); + ui->toolButtonSplinePathCutPoint->setEnabled(drawTools); + ui->toolButtonArcCutPoint->setEnabled(drawTools); + ui->toolButtonLineIntersectAxis->setEnabled(drawTools); + ui->toolButtonCurveIntersectAxis->setEnabled(drawTools); + ui->toolButtonArcIntersectAxis->setEnabled(drawTools); + + //Modeling Tools + ui->toolButtonUnionDetails->setEnabled(modelingTools); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MinimumScrollBar set scroll bar to minimum. + */ +void MainWindow::MinimumScrollBar() +{ + QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); + horScrollBar->setValue(horScrollBar->minimum()); + QScrollBar *verScrollBar = ui->view->verticalScrollBar(); + verScrollBar->setValue(verScrollBar->minimum()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SavePattern save pattern file. + * @param fileName pattern file name. + * @return true if all is good. + */ +bool MainWindow::SavePattern(const QString &fileName, QString &error) +{ + qCDebug(vMainWindow)<<"Saving pattern file"<SaveDocument(fileName, error); + if (result) + { + if (tempInfo.suffix() != "autosave") + { + setCurrentFile(fileName); + helpLabel->setText(tr("File saved")); + qCDebug(vMainWindow)<<"File"<isWindowModified() == true) + { + QString autofile = curFile +".autosave"; + QString error; + SavePattern(autofile, error); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentFile the function is called to reset the state of a few variables when a file + * is loaded or saved, or when the user starts editing a new file (in which case fileName is empty). + * @param fileName file name. + */ +void MainWindow::setCurrentFile(const QString &fileName) +{ + qCDebug(vMainWindow)<<"Set current name to \""<getUndoStack()->setClean(); + + QString shownName = strippedName(curFile); + if (curFile.isEmpty()) + { + shownName = tr("untitled.val"); + } + else + { + qCDebug(vMainWindow)<<"Updating recent file list."; + QStringList files = qApp->getSettings()->GetRecentFileList(); + files.removeAll(fileName); + files.prepend(fileName); + while (files.size() > MaxRecentFiles) + { + files.removeLast(); + } + + qApp->getSettings()->SetRecentFileList(files); + UpdateRecentFileActions(); + + qCDebug(vMainWindow)<<"Updating restore file list."; + QStringList restoreFiles = qApp->getSettings()->GetRestoreFileList(); + restoreFiles.removeAll(fileName); + restoreFiles.prepend(fileName); + qApp->getSettings()->SetRestoreFileList(restoreFiles); + } + shownName+="[*]"; + setWindowTitle(shownName); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief strippedName the function call around curFile to exclude the path to the file. + * @param fullFileName full path to the file. + * @return file name. + */ +QString MainWindow::strippedName(const QString &fullFileName) +{ + return QFileInfo(fullFileName).fileName(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ReadSettings read setting for app. + */ +void MainWindow::ReadSettings() +{ + qCDebug(vMainWindow)<<"Reading settings."; + restoreGeometry(qApp->getSettings()->GetGeometry()); + restoreState(qApp->getSettings()->GetWindowState()); + + // Scene antialiasing + const bool graphOutputValue = qApp->getSettings()->GetGraphicalOutput(); + ui->view->setRenderHint(QPainter::Antialiasing, graphOutputValue); + ui->view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue); + + // Stack limit + qApp->getUndoStack()->setUndoLimit(qApp->getSettings()->GetUndoCount()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief WriteSettings save setting for app. + */ +void MainWindow::WriteSettings() +{ + qApp->getSettings()->SetGeometry(saveGeometry()); + qApp->getSettings()->SetWindowState(saveState()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MaybeSave The function is called to save pending changes. + * @return returns true in all cases, except when the user clicks Cancel. + */ +bool MainWindow::MaybeSave() +{ + if (this->isWindowModified() && guiEnabled) + { + QMessageBox::StandardButton ret; + ret = QMessageBox::warning(this, tr("Unsaved change"), tr("The pattern has been modified.\n" + "Do you want to save your changes?"), + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + if (ret == QMessageBox::Save) + { + return Save(); + } + else if (ret == QMessageBox::Cancel) + { + return false; + } + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateRecentFileActions() +{ + qCDebug(vMainWindow)<<"Updating recent file actions."; + const QStringList files = qApp->getSettings()->GetRecentFileList(); + const int numRecentFiles = qMin(files.size(), static_cast(MaxRecentFiles)); + + for (int i = 0; i < numRecentFiles; ++i) + { + QString text = QString("&%1. %2").arg(i + 1).arg(strippedName(files.at(i))); + recentFileActs[i]->setText(text); + recentFileActs[i]->setData(files.at(i)); + recentFileActs[i]->setVisible(true); + } + for (int j = numRecentFiles; j < MaxRecentFiles; ++j) + { + recentFileActs[j]->setVisible(false); + } + + separatorAct->setVisible(numRecentFiles > 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::CreateMenus() +{ + for (int i = 0; i < MaxRecentFiles; ++i) + { + ui->menuFile->insertAction(ui->actionPreferences, recentFileActs[i]); + } + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuFile->insertAction(ui->actionPreferences, separatorAct); + UpdateRecentFileActions(); + + //Add Undo/Redo actions. + QAction *undoAction = qApp->getUndoStack()->createUndoAction(this, tr("&Undo")); + undoAction->setShortcuts(QKeySequence::Undo); + undoAction->setIcon(QIcon::fromTheme("edit-undo")); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, undoAction); + ui->toolBarTools->addAction(undoAction); + + QAction *redoAction = qApp->getUndoStack()->createRedoAction(this, tr("&Redo")); + redoAction->setShortcuts(QKeySequence::Redo); + redoAction->setIcon(QIcon::fromTheme("edit-redo")); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, redoAction); + ui->toolBarTools->addAction(redoAction); + + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); + + //Add dock + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction()); + + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); + AddDocks(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::AddDocks() +{ + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction()); + + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PropertyBrowser() +{ + qCDebug(vMainWindow)<<"Initialization property browser."; + toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions); + + connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked); + connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MainWindow::OpenNewValentina(const QString &fileName) const +{ + if (this->isWindowModified() || curFile.isEmpty() == false) + { + VApplication::NewValentina(fileName); + return true; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::CreateActions() +{ + ui->setupUi(this); + + connect(ui->actionStopTool, &QAction::triggered, this, &MainWindow::ArrowTool); + connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ArrowTool); + connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); + connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); + connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewPP); + connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::OptionDraw); + connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::SaveAs); + connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save); + connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open); + connect(ui->actionNew, &QAction::triggered, this, &MainWindow::NewPattern); + connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable); + connect(ui->actionAbout_Qt, &QAction::triggered, this, &MainWindow::AboutQt); + connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About); + connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); + connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); + connect(ui->actionRepotBug, &QAction::triggered, this, &MainWindow::RepotBug); + connect(ui->actionOnlineHelp, &QAction::triggered, this, &MainWindow::OnlineHelp); + connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties); + ui->actionPattern_properties->setEnabled(false); + connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); + connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow); + ui->actionEdit_pattern_code->setEnabled(false); + + //Actions for recent files loaded by a main window application. + for (int i = 0; i < MaxRecentFiles; ++i) + { + recentFileActs[i] = new QAction(this); + recentFileActs[i]->setVisible(false); + connect(recentFileActs[i], &QAction::triggered, this, &MainWindow::OpenRecentFile); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::InitAutoSave() +{ + //Autosaving file each 1 minutes + delete autoSaveTimer; + autoSaveTimer = nullptr; + + autoSaveTimer = new QTimer(this); + autoSaveTimer->setTimerType(Qt::VeryCoarseTimer); + connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); + autoSaveTimer->stop(); + + if (qApp->getSettings()->GetAutosaveState()) + { + const qint32 autoTime = qApp->getSettings()->GetAutosaveTime(); + autoSaveTimer->start(autoTime*60000); + qCDebug(vMainWindow)<<"Autosaving each"<setAutoSaveTimer(autoSaveTimer); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString MainWindow::PatternPieceName(const QString &text) +{ + QInputDialog *dlg = new QInputDialog(this); + dlg->setInputMode( QInputDialog::TextInput ); + dlg->setLabelText(tr("Pattern piece:")); + dlg->setTextEchoMode(QLineEdit::Normal); + dlg->setWindowTitle(tr("Enter a new label for the pattern piece.")); + dlg->resize(300, 100); + dlg->setTextValue(text); + QString nameDraw; + while (1) + { + const bool bOk = dlg->exec(); + nameDraw = dlg->textValue(); + if (bOk == false || nameDraw.isEmpty()) + { + delete dlg; + return QString(); + } + if (comboBoxDraws->findText(nameDraw) == -1) + { + break;//repeate show dialog + } + } + delete dlg; + return nameDraw; +} + +//--------------------------------------------------------------------------------------------------------------------- +MainWindow::~MainWindow() +{ + CancelTool(); + + delete lock; // Unlock pattern file + delete pattern; + delete doc; + delete sceneDetails; + delete sceneDraw; + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LoadPattern open pattern file. + * @param fileName name of file. + */ +void MainWindow::LoadPattern(const QString &fileName) +{ + qCDebug(vMainWindow)<<"Loading new file"<setStaleLockTime(0); + if (lock->tryLock()) + { + qCDebug(vMainWindow) << "Pattern file"<error(); + if (lock->error() == QLockFile::LockFailedError) + { + qCCritical(vMainWindow) << tr("This file already opened in another window."); + Clear(); + return; + } + } + + // On this stage scene empty. Fit scene size to view size + VAbstractTool::NewSceneRect(sceneDraw, ui->view); + VAbstractTool::NewSceneRect(sceneDetails, ui->view); + +#ifdef Q_OS_WIN32 + qt_ntfs_permission_lookup++; // turn checking on +#endif /*Q_OS_WIN32*/ + + qApp->setOpeningPattern();//Begin opening file + try + { + VPatternConverter converter(fileName); + converter.Convert(); + + VDomDocument::ValidateXML(VPatternConverter::CurrentSchema, fileName); + doc->setXMLContent(fileName); + + qApp->setPatternUnit(doc->MUnit()); + qApp->setPatternType(doc->MType()); + QString path = doc->MPath(); + + path = CheckPathToMeasurements(path, qApp->patternType()); + if (path.isEmpty()) + { + Clear(); + return; + } + + if (qApp->patternType() == MeasurementsType::Standard) + { + VStandardMeasurements m(pattern); + VDomDocument::ValidateXML("://schema/standard_measurements.xsd", path); + m.setXMLContent(path); + if (m.MUnit() == Unit::Inch) + { + QMessageBox::critical(this, tr("Wrong units."), + tr("Application doesn't support standard table with inches.")); + qCDebug(vMainWindow)<<"Application doesn't support standard table with inches."; + Clear(); + return; + } + m.SetSize(); + m.SetHeight(); + } + else + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", path); + } + ToolBarOption(); + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), this); + Clear(); + return; + } + +#ifdef Q_OS_WIN32 + qt_ntfs_permission_lookup--; // turn it off again +#endif /*Q_OS_WIN32*/ + + FullParseFile(); + + if (guiEnabled) + { // No errors occurred + bool patternModified = this->isWindowModified(); + setCurrentFile(fileName); + if (patternModified) + { + //For situation where was fixed wrong formula need return for document status was modified. + PatternWasModified(!patternModified); + } + helpLabel->setText(tr("File loaded")); + qCDebug(vMainWindow)<<"File loaded."; + + qApp->setOpeningPattern();// End opening file + + //Fit scene size to best size for first show + ZoomFirstShow(); + + ui->actionDraw->setChecked(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList MainWindow::GetUnlokedRestoreFileList() const +{ + QStringList restoreFiles; + QStringList files = qApp->getSettings()->GetRestoreFileList(); + if (files.size() > 0) + { + for (int i = 0; i < files.size(); ++i) + { + // Seeking file that realy need reopen + QLockFile *lock = new QLockFile(files.at(i)+".lock"); + lock->setStaleLockTime(0); + if (lock->tryLock()) + { + restoreFiles.append(files.at(i)); + } + delete lock; + lock = nullptr; + } + + // Clearing list after filtering + for (int i = 0; i < restoreFiles.size(); ++i) + { + files.removeAll(restoreFiles.at(i)); + } + + qApp->getSettings()->SetRestoreFileList(files); + + } + return restoreFiles; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ReopenFilesAfterCrash(QStringList &args) +{ + const QStringList files = GetUnlokedRestoreFileList(); + if (files.size() > 0) + { + qCDebug(vMainWindow)<<"Reopen files after crash."; + + QStringList restoreFiles; + for (int i = 0; i < files.size(); ++i) + { + QFile file(files.at(i) +".autosave"); + if (file.exists()) + { + restoreFiles.append(files.at(i)); + } + } + + if (restoreFiles.size() > 0) + { + QMessageBox::StandardButton reply; + QString mes=QString(tr("Valentina didn't shut down correctly. " + "Do you want reopen files (%1) you had open?")).arg(restoreFiles.size()); + reply = QMessageBox::question(this, tr("Reopen files."), mes, QMessageBox::Yes|QMessageBox::No, + QMessageBox::Yes); + if (reply == QMessageBox::Yes) + { + qCDebug(vMainWindow)<<"User said Yes."; + + for (int i = 0; i < restoreFiles.size(); ++i) + { + QString error; + if (VDomDocument::SafeCopy(restoreFiles.at(i) +".autosave", restoreFiles.at(i), error)) + { + QFile autoFile(restoreFiles.at(i) +".autosave"); + autoFile.remove(); + LoadPattern(restoreFiles.at(i)); + args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him. + } + else + { + qCDebug(vMainWindow) << "Could not copy "<
%1

%3").arg(path) + .arg(tr("could not be found. Do you want to update the file location")); + QMessageBox::StandardButton res = QMessageBox::question(this, "Loading measurements file", text, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes); + if (res == QMessageBox::No) + { + return QString(); + } + else + { + QString filter; + if (patternType == MeasurementsType::Standard) + { + filter = tr("Standard measurements (*.vst)"); + } + else + { + filter = tr("Individual measurements (*.vit)"); + } + QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), qApp->pathToTables(), filter); + + if (mPath.isEmpty()) + { + return mPath; + } + else + { + if (patternType == MeasurementsType::Standard) + { + VDomDocument::ValidateXML("://schema/standard_measurements.xsd", mPath); + } + else + { + VDomDocument::ValidateXML("://schema/individual_measurements.xsd", mPath); + } + doc->SetPath(mPath); + PatternWasModified(false); + return mPath; + } + } + } + return path; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ChangePP(int index, bool zoomBestFit) +{ + if (index != -1) + { + doc->ChangeActivPP(comboBoxDraws->itemText(index)); + doc->LiteParseTree(Document::LiteParse); + emit RefreshHistory(); + if (drawMode) + { + ArrowTool(); + if (zoomBestFit) + { + ui->view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio); + ui->view->NewFactor(ui->view->transform().m11()); + } + } + toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::EndVisualization(bool click) +{ + if (dialogTool != nullptr) + { + dialogTool->ShowDialog(click); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ZoomFirstShow Fit scene size to best size for first show + */ +void MainWindow::ZoomFirstShow() +{ + /* If don't call ZoomFitBest() twice, after first scaling or moving pattern piece, scene change coordinate and whole + * pattern will be moved. Looks very ugly. It is best solution that i have now. + */ + ActionDetails(true); + ui->view->ZoomFitBest(); + + ActionDraw(true); + ui->view->ZoomFitBest(); + + VAbstractTool::NewSceneRect(sceneDraw, ui->view); + VAbstractTool::NewSceneRect(sceneDetails, ui->view); + + ActionDetails(true); + ui->view->ZoomFitBest(); + + ActionDraw(true); + ui->view->ZoomFitBest(); +} diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h new file mode 100644 index 000000000..0463bd06c --- /dev/null +++ b/src/app/mainwindow.h @@ -0,0 +1,265 @@ +/************************************************************************ + ** + ** @file mainwindow.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "widgets/vmaingraphicsscene.h" +#include "widgets/vmaingraphicsview.h" +#include "widgets/vitem.h" +#include "dialogs/dialogs.h" +#include "tools/vtooldetail.h" +#include "tools/vtooluniondetails.h" +#include "tools/drawTools/drawtools.h" +#include "xml/vdomdocument.h" + +namespace Ui +{ + class MainWindow; +} + +class VToolOptionsPropertyBrowser; + +/** + * @brief The MainWindow class main windows. + */ +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit MainWindow(QWidget *parent = nullptr); + virtual ~MainWindow(); + void LoadPattern(const QString &curFile); + void ReopenFilesAfterCrash(QStringList &args); +public slots: + void mouseMove(const QPointF &scenePos); + void ArrowTool(); + + void ActionDraw(bool checked); + void ActionDetails(bool checked); + void ActionNewPP(); + void ActionLayout(bool checked); + void ActionTable(bool checked); + void ActionHistory(bool checked); + + void tableClosed(); + void ClosedActionTable(); + void ClosedActionHistory(); + + bool SaveAs(); + bool Save(); + void Open(); + void Preferences(); + void RepotBug(); + void OnlineHelp(); + void NewPattern(); + void ShowToolTip(const QString &toolTip); + void OpenRecentFile(); + void Clear(); + void ResetWindow(); + + void currentPPChanged(int index); + void OptionDraw(); + void ChangedSize(const QString &text); + void ChangedHeight(const QString & text); + + void PatternWasModified(bool saved); + + void ToolEndLine(bool checked); + void ToolLine(bool checked); + void ToolAlongLine(bool checked); + void ToolShoulderPoint(bool checked); + void ToolNormal(bool checked); + void ToolBisector(bool checked); + void ToolLineIntersect(bool checked); + void ToolSpline(bool checked); + void ToolCutSpline(bool checked); + void ToolArc(bool checked); + void ToolSplinePath(bool checked); + void ToolCutSplinePath(bool checked); + void ToolPointOfContact(bool checked); + void ToolDetail(bool checked); + void ToolHeight(bool checked); + void ToolTriangle(bool checked); + void ToolPointOfIntersection(bool checked); + void ToolUnionDetails(bool checked); + void ToolCutArc(bool checked); + void ToolLineIntersectAxis(bool checked); + void ToolCurveIntersectAxis(bool checked); + + void ClosedDialogDetail(int result); + void ClosedDialogUnionDetails(int result); + + void About(); + void AboutQt(); + void PatternProperties(); + + /** + * @brief Edit XML code of pattern + */ + void EditPatternCode(); + void FullParseFile(); + void SetEnabledGUI(bool enabled); + void ClickEndVisualization(); + void Layout(); + void UpdateGradation(); + void GlobalChangePP(const QString &patternPiece); +signals: + /** + * @brief ModelChosen emit after calculation all details. + * @param listDetails list of details. + * @param description pattern description. + */ + void ModelChosen(QVector listDetails, const QString &curFile, const QString &description); + void RefreshHistory(); +protected: + virtual void keyPressEvent(QKeyEvent *event); + virtual void showEvent(QShowEvent *event); + virtual void closeEvent(QCloseEvent *event); + virtual void customEvent(QEvent * event); +private: + Q_DISABLE_COPY(MainWindow) + /** @brief ui keeps information about user interface */ + Ui::MainWindow *ui; + + /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */ + VContainer *pattern; + + /** @brief doc dom document container */ + VPattern *doc; + + /** @brief tool current tool */ + Tool tool; + + /** @brief currentScene pointer to current scene. */ + VMainGraphicsScene *currentScene; + + /** @brief sceneDraw draw scene. */ + VMainGraphicsScene *sceneDraw; + + /** @brief sceneDetails details scene. */ + VMainGraphicsScene *sceneDetails; + + /** @brief mouseCoordinate pointer to label who show mouse coordinate. */ + QLabel *mouseCoordinate; + + /** @brief helpLabel help show tooltip. */ + QLabel *helpLabel; + + /** @brief isInitialized true after first show window. */ + bool isInitialized; + + DialogIncrements *dialogTable; + DialogTool *dialogTool; + DialogHistory *dialogHistory; + + /** @brief comboBoxDraws comboc who show name of pattern peaces. */ + QComboBox *comboBoxDraws; + + /** @brief fileName name current pattern file. */ + QString curFile; + + /** @brief mode keep current draw mode. */ + Draw mode; + + /** @brief currentDrawIndex save current selected pattern peace. */ + qint32 currentDrawIndex; + + /** @brief currentToolBoxIndex save current set of tools. */ + qint32 currentToolBoxIndex; + + /** @brief drawMode true if we current draw scene. */ + bool drawMode; + + enum { MaxRecentFiles = 5 }; + QAction *recentFileActs[MaxRecentFiles]; + QAction *separatorAct; + QTimer *autoSaveTimer; + bool guiEnabled; + QComboBox *gradationHeights; + QComboBox *gradationSizes; + VToolOptionsPropertyBrowser *toolOptions; + QLockFile *lock; + + void ToolBarOption(); + void ToolBarDraws(); + void ToolBarTools(); + void InitToolButtons(); + void CancelTool(); + void SetEnableWidgets(bool enable); + void SetEnableTool(bool enable); + void SaveCurrentScene(); + void RestoreCurrentScene(); + void MinimumScrollBar(); + + template + void SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot); + template + void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot, Func2 applyDialogSlot); + template + void ClosedDialog(int result); + template + void ClosedDialogWithApply(int result); + template + void ApplyDialog(); + bool SavePattern(const QString &curFile, QString &error); + void AutoSavePattern(); + void setCurrentFile(const QString &fileName); + QString strippedName(const QString &fullFileName); + void ReadSettings(); + void WriteSettings(); + bool MaybeSave(); + void UpdateRecentFileActions(); + void CreateMenus(); + void CreateActions(); + void InitAutoSave(); + QString PatternPieceName(const QString &text); + QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType); + QComboBox *SetGradationList(const QString &label, const QStringList &list); + void ChangePP(int index, bool zoomBestFit = true); + /** + * @brief EndVisualization try show dialog after and working with tool visualization. + */ + void EndVisualization(bool click = false); + void ZoomFirstShow(); + void UpdateHeightsList(const QStringList &list); + void UpdateSizesList(const QStringList &list); + void SetDefaultHeight(int value); + void SetDefaultSize(int value); + + void AddDocks(); + void PropertyBrowser(); + bool OpenNewValentina(const QString &fileName = QString())const; + void FileClosedCorrect(); + QStringList GetUnlokedRestoreFileList()const; +}; + +#endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/app/mainwindow.ui similarity index 56% rename from src/mainwindow.ui rename to src/app/mainwindow.ui index 2ea6899fd..688b6463f 100644 --- a/src/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -14,7 +14,7 @@ Valentina - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -25,14 +25,14 @@ - - 1 + + 2 1 - 150 + 105 0 @@ -40,15 +40,15 @@ - 0 + 3 0 0 - 150 - 150 + 105 + 272 @@ -63,124 +63,23 @@ Point - - - - - false - - - Tool point on the end line. - - - ... - - - - :/icon/32x32/segment.png:/icon/32x32/segment.png - - - - 32 - 32 - - - - true - - - - - - - false - - - Tool point of shoulder. - - - ... - - - - :/icon/32x32/shoulder.png:/icon/32x32/shoulder.png - - - - 32 - 32 - - - - true - - - - - - - false - - - Tool point of contact. - - - ... - - - - :/icon/32x32/point_of_contact.png:/icon/32x32/point_of_contact.png - - - - 32 - 32 - - - - true - - - - - - - false - - - Tool point of bisector. - - - ... - - - - :/icon/32x32/bisector.png:/icon/32x32/bisector.png - - - - 32 - 32 - - - - true - - - - + + + QFormLayout::AllNonFixedFieldsGrow + + false - Tool point of normal. + Point along perpendicular - ... + ... - + :/icon/32x32/normal.png:/icon/32x32/normal.png @@ -194,20 +93,20 @@ - - + + false - Tool point along line. + Special point on shoulder. - ... + ... - - :/icon/32x32/along_line.png:/icon/32x32/along_line.png + + :/icon/32x32/shoulder.png:/icon/32x32/shoulder.png @@ -220,33 +119,7 @@ - - - - false - - - Tool point of height. - - - ... - - - - :/icon/32x32/height.png:/icon/32x32/height.png - - - - 32 - 32 - - - - true - - - - + false @@ -255,10 +128,10 @@ Tool triangle. - ... + ... - + :/icon/32x32/triangle.png:/icon/32x32/triangle.png @@ -272,17 +145,176 @@ - + + + + false + + + Perpendicular point along line + + + ... + + + + :/icon/32x32/height.png:/icon/32x32/height.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Point along bisector + + + ... + + + + :/icon/32x32/bisector.png:/icon/32x32/bisector.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Point at intersection of arc and line. + + + ... + + + + :/icon/32x32/point_of_contact.png:/icon/32x32/point_of_contact.png + + + + 32 + 32 + + + + true + + + + false + + Tool to make point from x & y of two other points. + + + ... + + + + :/icon/32x32/point_of_intersection.png:/icon/32x32/point_of_intersection.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Point at distance and angle + + + ... + + + + :/icon/32x32/segment.png:/icon/32x32/segment.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Point at distance along line + + + ... + + + + :/icon/32x32/along_line.png:/icon/32x32/along_line.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Point of intersection line and axis + ... - - :/icon/32x32/point_of_intersection.png:/icon/32x32/point_of_intersection.png + + :/icon/32x32/line_intersect_axis.png:/icon/32x32/line_intersect_axis.png @@ -302,7 +334,7 @@ 0 0 - 150 + 105 58 @@ -318,20 +350,20 @@ Line - + false - Tool line. + Line between points - ... + ... - + :/icon/32x32/line.png:/icon/32x32/line.png @@ -351,13 +383,13 @@ false - Tool point of line intersection. + Point at line intersection - ... + ... - + :/icon/32x32/intersect.png:/icon/32x32/intersect.png @@ -378,8 +410,8 @@ 0 0 - 150 - 58 + 105 + 156 @@ -394,20 +426,20 @@ Curve - + false - Tool curve. + Curve tool. - ... + ... - + :/icon/32x32/spline.png:/icon/32x32/spline.png @@ -421,20 +453,95 @@ - + false - Tool path curve. + Tool for path curve. + + + ... + + + + :/icon/32x32/splinePath.png:/icon/32x32/splinePath.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Tool for segmenting a curve. + + + ... + + + + :/icon/32x32/spline_cut_point.png:/icon/32x32/spline_cut_point.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Tool segment a pathed curve. + + + ... + + + + :/icon/32x32/splinePath_cut_point.png:/icon/32x32/splinePath_cut_point.png + + + + 32 + 32 + + + + true + + + + + + + false ... - - :/icon/32x32/splinePath.png:/icon/32x32/splinePath.png + + :/icon/32x32/curve_intersect_axis.png:/icon/32x32/curve_intersect_axis.png @@ -454,8 +561,8 @@ 0 0 - 150 - 58 + 105 + 104 @@ -470,21 +577,70 @@ Arc - + false - Tool arc. + Arc tool. + + + ... + + + + :/icon/32x32/arc.png:/icon/32x32/arc.png + + + + 32 + 32 + + + + true + + + + + + + false + + + Cut arc tool. + + + ... + + + + :/icon/32x32/arc_cut.png:/icon/32x32/arc_cut.png + + + + 32 + 32 + + + + true + + + + + + + false ... - - :/icon/32x32/arc.png:/icon/32x32/arc.png + + :/icon/32x32/arc_intersect_axis.png:/icon/32x32/arc_intersect_axis.png @@ -504,7 +660,7 @@ 0 0 - 150 + 105 58 @@ -520,17 +676,17 @@ Detail - + Tool new detail. - ... + ... - + :/icon/32x32/new_detail.png:/icon/32x32/new_detail.png @@ -544,19 +700,54 @@ + + + + false + + + Tool for union two details. + + + ... + + + + :/icon/32x32/union.png:/icon/32x32/union.png + + + + 32 + 32 + + + + true + + + - - - 10 + + + false - - QLayout::SetMaximumSize + + + 1 + 0 + - + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOn + + @@ -571,37 +762,65 @@ - File + &File + + + + - Help + &Help + + - + - Drawing + &Pattern piece - - + + + + + + + + + + + Measurements + + + + + + Window + + - + + + + + Toolbar files + TopToolBarArea @@ -611,7 +830,6 @@ - @@ -619,7 +837,7 @@ true - toolBar + ToolBar modes TopToolBarArea @@ -633,7 +851,7 @@ - toolBar_2 + Toolbar pattern TopToolBarArea @@ -645,7 +863,7 @@ - toolBar_3 + Toolbar options BottomToolBarArea @@ -654,6 +872,40 @@ false + + + true + + + Toolbar tools + + + TopToolBarArea + + + false + + + + + + + + + + + 125 + 41 + + + + Tool options + + + 2 + + + @@ -663,9 +915,15 @@ New + + &New + Create a new pattern + + Ctrl+N + @@ -676,6 +934,9 @@ Open + + &Open + Open file with pattern @@ -692,9 +953,15 @@ Save + + &Save + Save pattern + + Ctrl+S + @@ -706,11 +973,14 @@ - Save as + Save &As... Save not yet saved pattern + + Ctrl+Shift+S + @@ -723,7 +993,7 @@ false - + :/icon/32x32/draw.png:/icon/32x32/draw.png @@ -732,6 +1002,9 @@ Draw mode + + Ctrl+W + @@ -741,14 +1014,17 @@ false - + :/icon/32x32/kontur.png:/icon/32x32/kontur.png Details - Deatils mode + Details mode + + + Ctrl+E @@ -759,38 +1035,41 @@ true - + :/icon/32x32/arrow_cursor.png:/icon/32x32/arrow_cursor.png - Tools pointer + Pointer tools - Tools pointer + Pointer tools - + :/icon/32x32/new_draw.png:/icon/32x32/new_draw.png - New drawing + New pattern piece - Add new drawing + Add new pattern piece + + + Ctrl+Shift+N - + :/icon/32x32/option_draw.png:/icon/32x32/option_draw.png - Change the name of drawing + Change the label of pattern piece - Change the name of drawing + Change the label of pattern piece @@ -798,7 +1077,7 @@ true - + :/icon/32x32/table.png:/icon/32x32/table.png @@ -807,64 +1086,207 @@ Tables of variables + + Ctrl+T + true - + :/icon/32x32/history.png:/icon/32x32/history.png History + + Ctrl+H + - + :/icon/32x32/layout.png:/icon/32x32/layout.png - Layout + Export pattern (layout) Create layout + + Ctrl+L + - About Qt + About &Qt + + + + + - About Valentina + &About Valentina + + + + + - Exit + E&xit + + + Exit the application + + + Ctrl+Q + + + + + Preferences + + + + + Pattern properties + + + + + false + + + + + + + + Zoom in + + + zoom in + + + + + false + + + + + + + + Zoom out + + + Zoom out + + + + + Edit pattern XML code + + + + + false + + + + + + + + Original zoom + + + Original Zoom + + + + + false + + + + + + + + Zoom fit best + + + Ctrl+= + + + + + false + + + false + + + + + + + + Stop + + + Stop using tool + + + + + Repot Bug... + + + Report bug + + + + + Close window + + + + + + + + Online help + + + Show online help + + + VMainGraphicsView + QGraphicsView +
vmaingraphicsview.h
+
+
- toolButtonEndLine - toolButtonAlongLine - toolButtonBisector - toolButtonNormal - toolButtonShoulderPoint - toolButtonPointOfContact - toolButtonLine - toolButtonLineIntersect - toolButtonSpline toolButtonSplinePath - toolButtonArc - toolButtonNewDetail - +
diff --git a/src/app/options.cpp b/src/app/options.cpp new file mode 100644 index 000000000..0f102247f --- /dev/null +++ b/src/app/options.cpp @@ -0,0 +1,229 @@ +/************************************************************************ + ** + ** @file options.cpp + ** @author Roman Telezhynskyi + ** @date 12 5, 2014 + ** + ** @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) 2014 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 "options.h" +#include +#include + +//Same regexp in pattern.xsd shema file. Don't forget synchronize. +const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,`'\"]){1,1}([^-*/^+=\\s\\(\\)%:;!.,`'\"]){0,}$"); + +// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This +// furthermore blows up the binary sizes. +const QString degreeSymbol = QStringLiteral("°"); + +// Keep synchronize all names with initialization in VApllication class!!!!! +//measurements +//head and neck +const QString headGirth_M = QStringLiteral("head_girth"); +const QString midNeckGirth_M = QStringLiteral("mid_neck_girth"); +const QString neckBaseGirth_M = QStringLiteral("neck_base_girth"); +const QString headAndNeckLength_M = QStringLiteral("head_and_neck_length"); +//torso +const QString centerFrontWaistLength_M = QStringLiteral("center_front_waist_length"); +const QString centerBackWaistLength_M = QStringLiteral("center_back_waist_length"); +const QString shoulderLength_M = QStringLiteral("shoulder_length"); +const QString sideWaistLength_M = QStringLiteral("side_waist_length"); +const QString trunkLength_M = QStringLiteral("trunk_length"); +const QString shoulderGirth_M = QStringLiteral("shoulder_girth"); +const QString upperChestGirth_M = QStringLiteral("upper_chest_girth"); +const QString bustGirth_M = QStringLiteral("bust_girth"); +const QString underBustGirth_M = QStringLiteral("under_bust_girth"); +const QString waistGirth_M = QStringLiteral("waist_girth"); +const QString highHipGirth_M = QStringLiteral("high_hip_girth"); +const QString hipGirth_M = QStringLiteral("hip_girth"); +const QString upperFrontChestWidth_M = QStringLiteral("upper_front_chest_width"); +const QString frontChestWidth_M = QStringLiteral("front_chest_width"); +const QString acrossFrontShoulderWidth_M = QStringLiteral("across_front_shoulder_width"); +const QString acrossBackShoulderWidth_M = QStringLiteral("across_back_shoulder_width"); +const QString upperBackWidth_M = QStringLiteral("upper_back_width"); +const QString backWidth_M = QStringLiteral("back_width"); +const QString bustpointToBustpoint_M = QStringLiteral("bustpoint_to_bustpoint"); +const QString halterBustpointToBustpoint_M = QStringLiteral("halter_bustpoint_to_bustpoint"); +const QString neckToBustpoint_M = QStringLiteral("neck_to_bustpoint"); +const QString crotchLength_M = QStringLiteral("crotch_length"); +const QString riseHeight_M = QStringLiteral("rise_height"); +const QString shoulderDrop_M = QStringLiteral("shoulder_drop"); +const QString shoulderSlopeDegrees_M = QStringLiteral("shoulder_slope_degrees"); +const QString frontShoulderSlopeLength_M = QStringLiteral("front_shoulder_slope_length"); +const QString backShoulderSlopeLength_M = QStringLiteral("back_shoulder_slope_length"); +const QString frontShoulderToWaistLength_M = QStringLiteral("front_shoulder_to_waist_length"); +const QString backShoulderToWaistLength_M = QStringLiteral("back_shoulder_to_waist_length"); +const QString frontNeckArc_M = QStringLiteral("front_neck_arc"); +const QString backNeckArc_M = QStringLiteral("back_neck_arc"); +const QString frontUpperChestArc_M = QStringLiteral("front_upper_chest_arc"); +const QString backUpperChestArc_M = QStringLiteral("back_upper_chest_arc"); +const QString frontWaistArc_M = QStringLiteral("front_waist_arc"); +const QString backWaistArc_M = QStringLiteral("back_waist_arc"); +const QString frontUpperHipArc_M = QStringLiteral("front_upper_hip_arc"); +const QString backUpperHipArc_M = QStringLiteral("back_upper_hip_arc"); +const QString frontHipArc_M = QStringLiteral("front_hip_arc"); +const QString backHipArc_M = QStringLiteral("back_hip_arc"); +const QString chestSlope_M = QStringLiteral("chest_slope"); +const QString backSlope_M = QStringLiteral("back_slope"); +const QString frontWaistSlope_M = QStringLiteral("front_waist_slope"); +const QString backWaistSlope_M = QStringLiteral("back_waist_slope"); +const QString frontNeckToUpperChestHeight_M = QStringLiteral("front_neck_to_upper_chest_height"); +const QString frontNeckToBustHeight_M = QStringLiteral("front_neck_to_bust_height"); +const QString frontWaistToUpperChest_M = QStringLiteral("front_waist_to_upper_chest"); +const QString frontWaistToLowerBreast_M = QStringLiteral("front_waist_to_lower_breast"); +const QString backWaistToUpperChest_M = QStringLiteral("back_waist_to_upper_chest"); +const QString strapLength_M = QStringLiteral("strap_length"); +//arm +const QString armscyeGirth_M = QStringLiteral("armscye_girth"); +const QString elbowGirth_M = QStringLiteral("elbow_girth"); +const QString upperArmGirth_M = QStringLiteral("upper_arm_girth"); +const QString wristGirth_M = QStringLiteral("wrist_girth"); +const QString scyeDepth_M = QStringLiteral("scye_depth"); +const QString shoulderAndArmLength_M = QStringLiteral("shoulder_and_arm_length"); +const QString underarmLength_M = QStringLiteral("underarm_length"); +const QString cervicaleToWristLength_M = QStringLiteral("cervicale_to_wrist_length"); +const QString shoulderToElbowLength_M = QStringLiteral("shoulder_to_elbow_length"); +const QString armLength_M = QStringLiteral("arm_length"); +//hand +const QString handWidth_M = QStringLiteral("hand_width"); +const QString handLength_M = QStringLiteral("hand_length"); +const QString handGirth_M = QStringLiteral("hand_girth"); +//leg +const QString thighGirth_M = QStringLiteral("thigh_girth"); +const QString midThighGirth_M = QStringLiteral("mid_thigh_girth"); +const QString kneeGirth_M = QStringLiteral("knee_girth"); +const QString calfGirth_M = QStringLiteral("calf_girth"); +const QString ankleGirth_M = QStringLiteral("ankle_girth"); +const QString kneeHeight_M = QStringLiteral("knee_height"); +const QString ankleHeight_M = QStringLiteral("ankle_height"); +//foot +const QString footWidth_M = QStringLiteral("foot_width"); +const QString footLength_M = QStringLiteral("foot_length"); +//heights +const QString height_M = QStringLiteral("height"); +const QString cervicaleHeight_M = QStringLiteral("cervicale_height"); +const QString cervicaleToKneeHeight_M = QStringLiteral("cervicale_to_knee_height"); +const QString waistHeight_M = QStringLiteral("waist_height"); +const QString highHipHeight_M = QStringLiteral("high_hip_height"); +const QString hipHeight_M = QStringLiteral("hip_height"); +const QString waistToHipHeight_M = QStringLiteral("waist_to_hip_height"); +const QString waistToKneeHeight_M = QStringLiteral("waist_to_knee_height"); +const QString crotchHeight_M = QStringLiteral("crotch_height"); +//extended measurements +const QString size_M = QStringLiteral("size"); +const QString heightFrontNeckBasePoint_M = QStringLiteral("height_front_neck_base_point"); +const QString heightBaseNeckSidePoint_M = QStringLiteral("height_base_neck_side_point"); +const QString heightShoulderPoint_M = QStringLiteral("height_shoulder_point"); +const QString heightNipplePoint_M = QStringLiteral("height_nipple_point"); +const QString heightBackAngleAxilla_M = QStringLiteral("height_back_angle_axilla"); +const QString heightScapularPoint_M = QStringLiteral("height_scapular_point"); +const QString heightUnderButtockFolds_M = QStringLiteral("height_under_buttock_folds"); +const QString hipsExcludingProtrudingAbdomen_M = QStringLiteral("hips_excluding_protruding_abdomen"); +const QString girthFootInstep_M = QStringLiteral("girth_foot_instep"); +const QString sideWaistToFloor_M = QStringLiteral("side_waist_to_floor"); +const QString frontWaistToFloor_M = QStringLiteral("front_waist_to_floor"); +const QString arcThroughGroinArea_M = QStringLiteral("arc_through_groin_area"); +const QString waistToPlaneSeat_M = QStringLiteral("waist_to_plane_seat"); +const QString neckToRadialPoint_M = QStringLiteral("neck_to_radial_point"); +const QString neckToThirdFinger_M = QStringLiteral("neck_to_third_finger"); +const QString neckToFirstLineChestCircumference_M = QStringLiteral("neck_to_first_line_chest_circumference"); +const QString frontWaistLength_M = QStringLiteral("front_waist_length"); +const QString arcThroughShoulderJoint_M = QStringLiteral("arc_through_shoulder_joint"); +const QString neckToBackLineChestCircumference_M = QStringLiteral("neck_to_back_line_chest_circumference"); +const QString waistToNeckSide_M = QStringLiteral("waist_to_neck_side"); +const QString arcLengthUpperBody_M = QStringLiteral("arc_length_upper_body"); +const QString chestWidth_M = QStringLiteral("chest_width"); +const QString anteroposteriorDiameterHands_M = QStringLiteral("anteroposterior_diameter_hands"); +const QString heightClavicularPoint_M = QStringLiteral("height_clavicular_point"); +const QString heightArmholeSlash_M = QStringLiteral("height_armhole_slash"); +const QString slashShoulderHeight_M = QStringLiteral("slash_shoulder_height"); +const QString halfGirthNeck_M = QStringLiteral("half_girth_neck"); +const QString halfGirthNeckForShirts_M = QStringLiteral("half_girth_neck_for_shirts"); +const QString halfGirthChestFirst_M = QStringLiteral("half_girth_chest_first"); +const QString halfGirthChestSecond_M = QStringLiteral("half_girth_chest_second"); +const QString halfGirthChestThird_M = QStringLiteral("half_girth_chest_third"); +const QString halfGirthWaist_M = QStringLiteral("half_girth_waist"); +const QString halfGirthHipsConsideringProtrudingAbdomen_M += QStringLiteral("half_girth_hips_considering_protruding_abdomen"); +const QString halfGirthHipsExcludingProtrudingAbdomen_M += QStringLiteral("half_girth_hips_excluding_protruding_abdomen"); +const QString girthKneeFlexedFeet_M = QStringLiteral("girth_knee_flexed_feet"); +const QString neckTransverseDiameter_M = QStringLiteral("neck_transverse_diameter"); +const QString frontSlashShoulderHeight_M = QStringLiteral("front_slash_shoulder_height"); +const QString neckToFrontWaistLine_M = QStringLiteral("neck_to_front_waist_line"); +const QString handVerticalDiameter_M = QStringLiteral("hand_vertical_diameter"); +const QString neckToKneePoint_M = QStringLiteral("neck_to_knee_point"); +const QString waistToKnee_M = QStringLiteral("waist_to_knee"); +const QString shoulderHeight_M = QStringLiteral("shoulder_height"); +const QString headHeight_M = QStringLiteral("head_height"); +const QString bodyPosition_M = QStringLiteral("body_position"); +const QString arcBehindShoulderGirdle_M = QStringLiteral("arc_behind_shoulder_girdle"); +const QString neckToNeckBase_M = QStringLiteral("neck_to_neck_base"); +const QString depthWaistFirst_M = QStringLiteral("depth_waist_first"); +const QString depthWaistSecond_M = QStringLiteral("depth_waist_second"); + +//variables +const QString line_ = QStringLiteral("Line_"); +const QString angleLine_ = QStringLiteral("AngleLine_"); +const QString arc_ = QStringLiteral("Arc_"); +const QString spl_ = QStringLiteral("Spl_"); +const QString splPath = QStringLiteral("SplPath"); + +//functions +const QString sin_F = QStringLiteral("sin"); +const QString cos_F = QStringLiteral("cos"); +const QString tan_F = QStringLiteral("tan"); +const QString asin_F = QStringLiteral("asin"); +const QString acos_F = QStringLiteral("acos"); +const QString atan_F = QStringLiteral("atan"); +const QString sinh_F = QStringLiteral("sinh"); +const QString cosh_F = QStringLiteral("cosh"); +const QString tanh_F = QStringLiteral("tanh"); +const QString asinh_F = QStringLiteral("asinh"); +const QString acosh_F = QStringLiteral("acosh"); +const QString atanh_F = QStringLiteral("atanh"); +const QString log2_F = QStringLiteral("log2"); +const QString log10_F = QStringLiteral("log10"); +const QString log_F = QStringLiteral("log"); +const QString ln_F = QStringLiteral("ln"); +const QString exp_F = QStringLiteral("exp"); +const QString sqrt_F = QStringLiteral("sqrt"); +const QString sign_F = QStringLiteral("sign"); +const QString rint_F = QStringLiteral("rint"); +const QString abs_F = QStringLiteral("abs"); +const QString min_F = QStringLiteral("min"); +const QString max_F = QStringLiteral("max"); +const QString sum_F = QStringLiteral("sum"); +const QString avg_F = QStringLiteral("avg"); + +const QStringList builInFunctions = QStringList() << sin_F << cos_F << tan_F << asin_F << acos_F << atan_F + << sinh_F << cosh_F << tanh_F << asinh_F << acosh_F << atanh_F + << log2_F << log10_F << log_F << ln_F << exp_F << sqrt_F + << sign_F << rint_F << abs_F << min_F << max_F << sum_F + << avg_F; + +// Postfix operators +const QString cm_Oprt = QStringLiteral("cm"); +const QString mm_Oprt = QStringLiteral("mm"); +const QString in_Oprt = QStringLiteral("in"); diff --git a/src/app/options.h b/src/app/options.h new file mode 100644 index 000000000..6c640a075 --- /dev/null +++ b/src/app/options.h @@ -0,0 +1,319 @@ +/************************************************************************ + ** + ** @file options.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 + +#endif /*Q_OS_WIN32*/ + +class QString; +class QStringList; + +#define SceneSize 50000 +#define DefPointRadius 1.5//mm + +extern const QString nameRegExp; +extern const QString degreeSymbol; + +enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; +enum class Tool : unsigned char +{ + Arrow, + Point, + LinePoint, + AbstractSpline, + Cut, + SinglePoint, + EndLine, + Line, + AlongLine, + ShoulderPoint, + Normal, + Bisector, + LineIntersect, + Spline, + CutSpline, + CutArc, + Arc, + SplinePath, + CutSplinePath, + PointOfContact, + Detail, + NodePoint, + NodeArc, + NodeSpline, + NodeSplinePath, + Height, + Triangle, + LineIntersectAxis, + CurveIntersectAxis, + PointOfIntersection, + UnionDetails // 30 +}; + +enum class Vis : unsigned char +{ + ControlPointSpline = 31, // increase this value if need more positions in Tool enum + GraphicsSimpleTextItem, + SimpleSplinePath, + Line, + Path, + ToolAlongLine, + ToolArc, + ToolBisector, + ToolCutArc, + ToolEndLine, + ToolHeight, + ToolLine, + ToolLineIntersect, + ToolNormal, + ToolPointOfContact, + ToolPointOfIntersection, + ToolShoulderPoint, + ToolSpline, + ToolTriangle, + ToolCutSpline, + ToolSplinePath, + ToolCutSplinePath, + ToolLineIntersectAxis, + ToolCurveIntersectAxis +}; + +enum class Source : char { FromGui, FromFile, FromTool }; +enum class Draw : char { Calculation, Modeling }; +enum class NodeDetail : char { Contour, Modeling }; +enum class Contour : char { OpenContour, CloseContour }; +enum class EquidistantType : char { OpenEquidistant, CloseEquidistant }; +enum class GOType : char { Point, Arc, Spline, SplinePath, Unknown }; +enum class SplinePointPosition : char { FirstPoint, LastPoint }; +enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, LineAngle, Unknown }; + +enum class GHeights : unsigned char { ALL, + H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134, + H140=140, H146=146, H152=152, H158=158, H164=164, H170=170, H176=176, H182=182, + H188=188, H194=194}; + +enum class GSizes : unsigned char { ALL, + S22=22, S24=24, S26=26, S28=28, S30=30, S32=32, S34=34, S36=36, S38=38, S40=40, + S42=42, S44=44, S46=46, S48=48, S50=50, S52=52, S54=54, S56=56 }; + +// measurements +//head and neck +extern const QString headGirth_M; +extern const QString midNeckGirth_M; +extern const QString neckBaseGirth_M; +extern const QString headAndNeckLength_M; +//torso +extern const QString centerFrontWaistLength_M; +extern const QString centerBackWaistLength_M; +extern const QString shoulderLength_M; +extern const QString sideWaistLength_M; +extern const QString trunkLength_M; +extern const QString shoulderGirth_M; +extern const QString upperChestGirth_M; +extern const QString bustGirth_M; +extern const QString underBustGirth_M; +extern const QString waistGirth_M; +extern const QString highHipGirth_M; +extern const QString hipGirth_M; +extern const QString upperFrontChestWidth_M; +extern const QString frontChestWidth_M; +extern const QString acrossFrontShoulderWidth_M; +extern const QString acrossBackShoulderWidth_M; +extern const QString upperBackWidth_M; +extern const QString backWidth_M; +extern const QString bustpointToBustpoint_M; +extern const QString halterBustpointToBustpoint_M; +extern const QString neckToBustpoint_M; +extern const QString crotchLength_M; +extern const QString riseHeight_M; +extern const QString shoulderDrop_M; +extern const QString shoulderSlopeDegrees_M; +extern const QString frontShoulderSlopeLength_M; +extern const QString backShoulderSlopeLength_M; +extern const QString frontShoulderToWaistLength_M; +extern const QString backShoulderToWaistLength_M; +extern const QString frontNeckArc_M; +extern const QString backNeckArc_M; +extern const QString frontUpperChestArc_M; +extern const QString backUpperChestArc_M; +extern const QString frontWaistArc_M; +extern const QString backWaistArc_M; +extern const QString frontUpperHipArc_M; +extern const QString backUpperHipArc_M; +extern const QString frontHipArc_M; +extern const QString backHipArc_M; +extern const QString chestSlope_M; +extern const QString backSlope_M; +extern const QString frontWaistSlope_M; +extern const QString backWaistSlope_M; +extern const QString frontNeckToUpperChestHeight_M; +extern const QString frontNeckToBustHeight_M; +extern const QString frontWaistToUpperChest_M; +extern const QString frontWaistToLowerBreast_M; +extern const QString backWaistToUpperChest_M; +extern const QString strapLength_M; +//arm +extern const QString armscyeGirth_M; +extern const QString elbowGirth_M; +extern const QString upperArmGirth_M; +extern const QString wristGirth_M; +extern const QString scyeDepth_M; +extern const QString shoulderAndArmLength_M; +extern const QString underarmLength_M; +extern const QString cervicaleToWristLength_M; +extern const QString shoulderToElbowLength_M; +extern const QString armLength_M; +//hand +extern const QString handWidth_M; +extern const QString handLength_M; +extern const QString handGirth_M; +//leg +extern const QString thighGirth_M; +extern const QString midThighGirth_M; +extern const QString kneeGirth_M; +extern const QString calfGirth_M; +extern const QString ankleGirth_M; +extern const QString kneeHeight_M; +extern const QString ankleHeight_M; +//foot +extern const QString footWidth_M; +extern const QString footLength_M; +//heights +extern const QString height_M; +extern const QString cervicaleHeight_M; +extern const QString cervicaleToKneeHeight_M; +extern const QString waistHeight_M; +extern const QString highHipHeight_M; +extern const QString hipHeight_M; +extern const QString waistToHipHeight_M; +extern const QString waistToKneeHeight_M; +extern const QString crotchHeight_M; +//extended measurements +extern const QString size_M; +extern const QString heightFrontNeckBasePoint_M; +extern const QString heightBaseNeckSidePoint_M; +extern const QString heightShoulderPoint_M; +extern const QString heightNipplePoint_M; +extern const QString heightBackAngleAxilla_M; +extern const QString heightScapularPoint_M; +extern const QString heightUnderButtockFolds_M; +extern const QString hipsExcludingProtrudingAbdomen_M; +extern const QString girthFootInstep_M; +extern const QString sideWaistToFloor_M; +extern const QString frontWaistToFloor_M; +extern const QString arcThroughGroinArea_M; +extern const QString waistToPlaneSeat_M; +extern const QString neckToRadialPoint_M; +extern const QString neckToThirdFinger_M; +extern const QString neckToFirstLineChestCircumference_M; +extern const QString frontWaistLength_M; +extern const QString arcThroughShoulderJoint_M; +extern const QString neckToBackLineChestCircumference_M; +extern const QString waistToNeckSide_M; +extern const QString arcLengthUpperBody_M; +extern const QString chestWidth_M; +extern const QString anteroposteriorDiameterHands_M; +extern const QString heightClavicularPoint_M; +extern const QString heightArmholeSlash_M; +extern const QString slashShoulderHeight_M; +extern const QString halfGirthNeck_M; +extern const QString halfGirthNeckForShirts_M; +extern const QString halfGirthChestFirst_M; +extern const QString halfGirthChestSecond_M; +extern const QString halfGirthChestThird_M; +extern const QString halfGirthWaist_M; +extern const QString halfGirthHipsConsideringProtrudingAbdomen_M; +extern const QString halfGirthHipsExcludingProtrudingAbdomen_M; +extern const QString girthKneeFlexedFeet_M; +extern const QString neckTransverseDiameter_M; +extern const QString frontSlashShoulderHeight_M; +extern const QString neckToFrontWaistLine_M; +extern const QString handVerticalDiameter_M; +extern const QString neckToKneePoint_M; +extern const QString waistToKnee_M; +extern const QString shoulderHeight_M; +extern const QString headHeight_M; +extern const QString bodyPosition_M; +extern const QString arcBehindShoulderGirdle_M; +extern const QString neckToNeckBase_M; +extern const QString depthWaistFirst_M; +extern const QString depthWaistSecond_M; + +// variables name +extern const QString line_; +extern const QString angleLine_; +extern const QString arc_; +extern const QString spl_; +extern const QString splPath; + +// functions +extern const QString sin_F; +extern const QString cos_F; +extern const QString tan_F; +extern const QString asin_F; +extern const QString acos_F; +extern const QString atan_F; +extern const QString sinh_F; +extern const QString cosh_F; +extern const QString tanh_F; +extern const QString asinh_F; +extern const QString acosh_F; +extern const QString atanh_F; +extern const QString log2_F; +extern const QString log10_F; +extern const QString log_F; +extern const QString ln_F; +extern const QString exp_F; +extern const QString sqrt_F; +extern const QString sign_F; +extern const QString rint_F; +extern const QString abs_F; +extern const QString min_F; +extern const QString max_F; +extern const QString sum_F; +extern const QString avg_F; + +extern const QStringList builInFunctions; + +// Postfix operators +extern const QString cm_Oprt; +extern const QString mm_Oprt; +extern const QString in_Oprt; + +#endif // OPTIONS_H diff --git a/share/resources/cursor.qrc b/src/app/share/resources/cursor.qrc similarity index 61% rename from share/resources/cursor.qrc rename to src/app/share/resources/cursor.qrc index 785c3ddd8..1aec9decd 100644 --- a/share/resources/cursor.qrc +++ b/src/app/share/resources/cursor.qrc @@ -15,5 +15,14 @@ cursor/height_cursor.png cursor/triangle_cursor.png cursor/pointofintersect_cursor.png + cursor/spline_cut_point_cursor.png + cursor/splinepath_cut_point_cursor.png + cursor/union_cursor.png + cursor/arc_cut_cursor.png + cursor/cursor-arrow-closehand.png + cursor/cursor-arrow-openhand.png + cursor/line_intersect_axis_cursor.png + cursor/arc_intersect_axis_cursor.png + cursor/curve_intersect_axis_cursor.png diff --git a/share/resources/cursor/alongline_cursor.png b/src/app/share/resources/cursor/alongline_cursor.png similarity index 100% rename from share/resources/cursor/alongline_cursor.png rename to src/app/share/resources/cursor/alongline_cursor.png diff --git a/share/resources/cursor/arc_cursor.png b/src/app/share/resources/cursor/arc_cursor.png similarity index 100% rename from share/resources/cursor/arc_cursor.png rename to src/app/share/resources/cursor/arc_cursor.png diff --git a/src/app/share/resources/cursor/arc_cut_cursor.png b/src/app/share/resources/cursor/arc_cut_cursor.png new file mode 100644 index 000000000..62ca8f1cb Binary files /dev/null and b/src/app/share/resources/cursor/arc_cut_cursor.png differ diff --git a/src/app/share/resources/cursor/arc_intersect_axis_cursor.png b/src/app/share/resources/cursor/arc_intersect_axis_cursor.png new file mode 100644 index 000000000..f58f219db Binary files /dev/null and b/src/app/share/resources/cursor/arc_intersect_axis_cursor.png differ diff --git a/share/resources/cursor/bisector_cursor.png b/src/app/share/resources/cursor/bisector_cursor.png similarity index 100% rename from share/resources/cursor/bisector_cursor.png rename to src/app/share/resources/cursor/bisector_cursor.png diff --git a/src/app/share/resources/cursor/cursor-arrow-closehand.png b/src/app/share/resources/cursor/cursor-arrow-closehand.png new file mode 100644 index 000000000..ee9e40d22 Binary files /dev/null and b/src/app/share/resources/cursor/cursor-arrow-closehand.png differ diff --git a/src/app/share/resources/cursor/cursor-arrow-openhand.png b/src/app/share/resources/cursor/cursor-arrow-openhand.png new file mode 100644 index 000000000..01790642d Binary files /dev/null and b/src/app/share/resources/cursor/cursor-arrow-openhand.png differ diff --git a/src/app/share/resources/cursor/curve_intersect_axis_cursor.png b/src/app/share/resources/cursor/curve_intersect_axis_cursor.png new file mode 100644 index 000000000..4f4470024 Binary files /dev/null and b/src/app/share/resources/cursor/curve_intersect_axis_cursor.png differ diff --git a/share/resources/cursor/endline_cursor.png b/src/app/share/resources/cursor/endline_cursor.png similarity index 100% rename from share/resources/cursor/endline_cursor.png rename to src/app/share/resources/cursor/endline_cursor.png diff --git a/share/resources/cursor/height_cursor.png b/src/app/share/resources/cursor/height_cursor.png similarity index 100% rename from share/resources/cursor/height_cursor.png rename to src/app/share/resources/cursor/height_cursor.png diff --git a/share/resources/cursor/intersect_cursor.png b/src/app/share/resources/cursor/intersect_cursor.png similarity index 100% rename from share/resources/cursor/intersect_cursor.png rename to src/app/share/resources/cursor/intersect_cursor.png diff --git a/share/resources/cursor/line_cursor.png b/src/app/share/resources/cursor/line_cursor.png similarity index 100% rename from share/resources/cursor/line_cursor.png rename to src/app/share/resources/cursor/line_cursor.png diff --git a/src/app/share/resources/cursor/line_intersect_axis_cursor.png b/src/app/share/resources/cursor/line_intersect_axis_cursor.png new file mode 100644 index 000000000..65554bbe4 Binary files /dev/null and b/src/app/share/resources/cursor/line_intersect_axis_cursor.png differ diff --git a/src/app/share/resources/cursor/new_detail_cursor.png b/src/app/share/resources/cursor/new_detail_cursor.png new file mode 100644 index 000000000..9134b682d Binary files /dev/null and b/src/app/share/resources/cursor/new_detail_cursor.png differ diff --git a/share/resources/cursor/normal_cursor.png b/src/app/share/resources/cursor/normal_cursor.png similarity index 100% rename from share/resources/cursor/normal_cursor.png rename to src/app/share/resources/cursor/normal_cursor.png diff --git a/src/app/share/resources/cursor/pointcontact_cursor.png b/src/app/share/resources/cursor/pointcontact_cursor.png new file mode 100644 index 000000000..a2c0e212a Binary files /dev/null and b/src/app/share/resources/cursor/pointcontact_cursor.png differ diff --git a/share/resources/cursor/pointofintersect_cursor.png b/src/app/share/resources/cursor/pointofintersect_cursor.png similarity index 100% rename from share/resources/cursor/pointofintersect_cursor.png rename to src/app/share/resources/cursor/pointofintersect_cursor.png diff --git a/share/resources/cursor/shoulder_cursor.png b/src/app/share/resources/cursor/shoulder_cursor.png similarity index 100% rename from share/resources/cursor/shoulder_cursor.png rename to src/app/share/resources/cursor/shoulder_cursor.png diff --git a/share/resources/cursor/spline_cursor.png b/src/app/share/resources/cursor/spline_cursor.png similarity index 100% rename from share/resources/cursor/spline_cursor.png rename to src/app/share/resources/cursor/spline_cursor.png diff --git a/src/app/share/resources/cursor/spline_cut_point_cursor.png b/src/app/share/resources/cursor/spline_cut_point_cursor.png new file mode 100644 index 000000000..821da0a59 Binary files /dev/null and b/src/app/share/resources/cursor/spline_cut_point_cursor.png differ diff --git a/share/resources/cursor/splinepath_cursor.png b/src/app/share/resources/cursor/splinepath_cursor.png similarity index 100% rename from share/resources/cursor/splinepath_cursor.png rename to src/app/share/resources/cursor/splinepath_cursor.png diff --git a/src/app/share/resources/cursor/splinepath_cut_point_cursor.png b/src/app/share/resources/cursor/splinepath_cut_point_cursor.png new file mode 100644 index 000000000..226e6458a Binary files /dev/null and b/src/app/share/resources/cursor/splinepath_cut_point_cursor.png differ diff --git a/share/resources/cursor/triangle_cursor.png b/src/app/share/resources/cursor/triangle_cursor.png similarity index 100% rename from share/resources/cursor/triangle_cursor.png rename to src/app/share/resources/cursor/triangle_cursor.png diff --git a/src/app/share/resources/cursor/union_cursor.png b/src/app/share/resources/cursor/union_cursor.png new file mode 100644 index 000000000..687d2ca59 Binary files /dev/null and b/src/app/share/resources/cursor/union_cursor.png differ diff --git a/src/app/share/resources/flags.qrc b/src/app/share/resources/flags.qrc new file mode 100644 index 000000000..5a33e6161 --- /dev/null +++ b/src/app/share/resources/flags.qrc @@ -0,0 +1,14 @@ + + + flags/CzechRepublic.png + flags/France.png + flags/Germany.png + flags/Indonesia.png + flags/Israel.png + flags/Italy.png + flags/Netherlands.png + flags/Russia.png + flags/Ukraine.png + flags/UnitedStates.png + + diff --git a/src/app/share/resources/flags/CzechRepublic.png b/src/app/share/resources/flags/CzechRepublic.png new file mode 100644 index 000000000..73ac44241 Binary files /dev/null and b/src/app/share/resources/flags/CzechRepublic.png differ diff --git a/src/app/share/resources/flags/France.png b/src/app/share/resources/flags/France.png new file mode 100644 index 000000000..f27f41143 Binary files /dev/null and b/src/app/share/resources/flags/France.png differ diff --git a/src/app/share/resources/flags/Germany.png b/src/app/share/resources/flags/Germany.png new file mode 100644 index 000000000..0c229c322 Binary files /dev/null and b/src/app/share/resources/flags/Germany.png differ diff --git a/src/app/share/resources/flags/Indonesia.png b/src/app/share/resources/flags/Indonesia.png new file mode 100644 index 000000000..e938f433b Binary files /dev/null and b/src/app/share/resources/flags/Indonesia.png differ diff --git a/src/app/share/resources/flags/Israel.png b/src/app/share/resources/flags/Israel.png new file mode 100644 index 000000000..8a8d4a8f8 Binary files /dev/null and b/src/app/share/resources/flags/Israel.png differ diff --git a/src/app/share/resources/flags/Italy.png b/src/app/share/resources/flags/Italy.png new file mode 100644 index 000000000..8e9e7fa69 Binary files /dev/null and b/src/app/share/resources/flags/Italy.png differ diff --git a/src/app/share/resources/flags/Netherlands.png b/src/app/share/resources/flags/Netherlands.png new file mode 100644 index 000000000..0f98743cb Binary files /dev/null and b/src/app/share/resources/flags/Netherlands.png differ diff --git a/src/app/share/resources/flags/Russia.png b/src/app/share/resources/flags/Russia.png new file mode 100644 index 000000000..d9624ca1c Binary files /dev/null and b/src/app/share/resources/flags/Russia.png differ diff --git a/src/app/share/resources/flags/Ukraine.png b/src/app/share/resources/flags/Ukraine.png new file mode 100644 index 000000000..e46611fac Binary files /dev/null and b/src/app/share/resources/flags/Ukraine.png differ diff --git a/src/app/share/resources/flags/UnitedStates.png b/src/app/share/resources/flags/UnitedStates.png new file mode 100644 index 000000000..b269593a3 Binary files /dev/null and b/src/app/share/resources/flags/UnitedStates.png differ diff --git a/share/resources/icon.qrc b/src/app/share/resources/icon.qrc similarity index 53% rename from share/resources/icon.qrc rename to src/app/share/resources/icon.qrc index 66b939f04..073e985a0 100644 --- a/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -8,14 +8,6 @@ icon/32x32/option_draw.png icon/32x32/table.png icon/24x24/putHere.png - icon/24x24/arrowDown.png - icon/24x24/arrowUp.png - icon/24x24/arrowRightUp.png - icon/24x24/arrowRightDown.png - icon/24x24/arrowRight.png - icon/24x24/arrowLeftUp.png - icon/24x24/arrowLeftDown.png - icon/24x24/arrowLeft.png icon/24x24/equal.png icon/32x32/segment.png icon/32x32/line.png @@ -26,7 +18,6 @@ icon/32x32/intersect.png icon/32x32/spline.png icon/32x32/arc.png - icon/24x24/putHereLeft.png icon/32x32/splinePath.png icon/32x32/history.png icon/32x32/put_after.png @@ -37,5 +28,29 @@ icon/32x32/height.png icon/32x32/triangle.png icon/32x32/point_of_intersection.png + icon/32x32/spline_cut_point.png + icon/32x32/splinePath_cut_point.png + icon/32x32/union.png + icon/32x32/arc_cut.png + icon/config.png + icon/pattern_config.png + icon/Graduation.png + icon/individual.png + icon/community_config.png + icon/32x32/arrowLeft.png + icon/32x32/arrowRight.png + icon/32x32/arrowRightDown.png + icon/32x32/arrowDown.png + icon/32x32/arrowRightUp.png + icon/32x32/arrowLeftDown.png + icon/32x32/arrowUp.png + icon/32x32/arrowLeftUp.png + icon/32x32/putHereLeft.png + icon/path_config.png + icon/16x16/info.png + icon/16x16/measurement.png + icon/32x32/line_intersect_axis.png + icon/32x32/arc_intersect_axis.png + icon/32x32/curve_intersect_axis.png diff --git a/src/app/share/resources/icon/16x16/info.png b/src/app/share/resources/icon/16x16/info.png new file mode 100644 index 000000000..e7fb9d586 Binary files /dev/null and b/src/app/share/resources/icon/16x16/info.png differ diff --git a/src/app/share/resources/icon/16x16/measurement.png b/src/app/share/resources/icon/16x16/measurement.png new file mode 100644 index 000000000..7577e9ccf Binary files /dev/null and b/src/app/share/resources/icon/16x16/measurement.png differ diff --git a/share/resources/icon/16x16/mirror.png b/src/app/share/resources/icon/16x16/mirror.png similarity index 100% rename from share/resources/icon/16x16/mirror.png rename to src/app/share/resources/icon/16x16/mirror.png diff --git a/src/app/share/resources/icon/24x24/equal.png b/src/app/share/resources/icon/24x24/equal.png new file mode 100644 index 000000000..89a704c56 Binary files /dev/null and b/src/app/share/resources/icon/24x24/equal.png differ diff --git a/src/app/share/resources/icon/24x24/putHere.png b/src/app/share/resources/icon/24x24/putHere.png new file mode 100644 index 000000000..fadcb6032 Binary files /dev/null and b/src/app/share/resources/icon/24x24/putHere.png differ diff --git a/share/resources/icon/32x32/along_line.png b/src/app/share/resources/icon/32x32/along_line.png similarity index 100% rename from share/resources/icon/32x32/along_line.png rename to src/app/share/resources/icon/32x32/along_line.png diff --git a/share/resources/icon/32x32/arc.png b/src/app/share/resources/icon/32x32/arc.png similarity index 100% rename from share/resources/icon/32x32/arc.png rename to src/app/share/resources/icon/32x32/arc.png diff --git a/src/app/share/resources/icon/32x32/arc_cut.png b/src/app/share/resources/icon/32x32/arc_cut.png new file mode 100644 index 000000000..7b4f876b1 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arc_cut.png differ diff --git a/src/app/share/resources/icon/32x32/arc_intersect_axis.png b/src/app/share/resources/icon/32x32/arc_intersect_axis.png new file mode 100644 index 000000000..2ac02160c Binary files /dev/null and b/src/app/share/resources/icon/32x32/arc_intersect_axis.png differ diff --git a/src/app/share/resources/icon/32x32/arrowDown.png b/src/app/share/resources/icon/32x32/arrowDown.png new file mode 100644 index 000000000..199edf66d Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeft.png b/src/app/share/resources/icon/32x32/arrowLeft.png new file mode 100644 index 000000000..6fe84b8d9 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeft.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeftDown.png b/src/app/share/resources/icon/32x32/arrowLeftDown.png new file mode 100644 index 000000000..85ffeadce Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeftDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeftUp.png b/src/app/share/resources/icon/32x32/arrowLeftUp.png new file mode 100644 index 000000000..99070f5a0 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeftUp.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRight.png b/src/app/share/resources/icon/32x32/arrowRight.png new file mode 100644 index 000000000..113acb379 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRight.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRightDown.png b/src/app/share/resources/icon/32x32/arrowRightDown.png new file mode 100644 index 000000000..cb48bc3bc Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRightDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRightUp.png b/src/app/share/resources/icon/32x32/arrowRightUp.png new file mode 100644 index 000000000..877920aa7 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRightUp.png differ diff --git a/src/app/share/resources/icon/32x32/arrowUp.png b/src/app/share/resources/icon/32x32/arrowUp.png new file mode 100644 index 000000000..91cbc25ec Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowUp.png differ diff --git a/share/resources/icon/32x32/arrow_cursor.png b/src/app/share/resources/icon/32x32/arrow_cursor.png similarity index 100% rename from share/resources/icon/32x32/arrow_cursor.png rename to src/app/share/resources/icon/32x32/arrow_cursor.png diff --git a/share/resources/icon/32x32/bisector.png b/src/app/share/resources/icon/32x32/bisector.png similarity index 100% rename from share/resources/icon/32x32/bisector.png rename to src/app/share/resources/icon/32x32/bisector.png diff --git a/src/app/share/resources/icon/32x32/curve_intersect_axis.png b/src/app/share/resources/icon/32x32/curve_intersect_axis.png new file mode 100644 index 000000000..4090cc5dd Binary files /dev/null and b/src/app/share/resources/icon/32x32/curve_intersect_axis.png differ diff --git a/share/resources/icon/32x32/draw.png b/src/app/share/resources/icon/32x32/draw.png similarity index 100% rename from share/resources/icon/32x32/draw.png rename to src/app/share/resources/icon/32x32/draw.png diff --git a/share/resources/icon/32x32/height.png b/src/app/share/resources/icon/32x32/height.png similarity index 100% rename from share/resources/icon/32x32/height.png rename to src/app/share/resources/icon/32x32/height.png diff --git a/src/app/share/resources/icon/32x32/history.png b/src/app/share/resources/icon/32x32/history.png new file mode 100644 index 000000000..6f3b0cdc5 Binary files /dev/null and b/src/app/share/resources/icon/32x32/history.png differ diff --git a/share/resources/icon/32x32/intersect.png b/src/app/share/resources/icon/32x32/intersect.png similarity index 100% rename from share/resources/icon/32x32/intersect.png rename to src/app/share/resources/icon/32x32/intersect.png diff --git a/share/resources/icon/32x32/kontur.png b/src/app/share/resources/icon/32x32/kontur.png similarity index 100% rename from share/resources/icon/32x32/kontur.png rename to src/app/share/resources/icon/32x32/kontur.png diff --git a/share/resources/icon/32x32/layout.png b/src/app/share/resources/icon/32x32/layout.png similarity index 100% rename from share/resources/icon/32x32/layout.png rename to src/app/share/resources/icon/32x32/layout.png diff --git a/share/resources/icon/32x32/line.png b/src/app/share/resources/icon/32x32/line.png similarity index 100% rename from share/resources/icon/32x32/line.png rename to src/app/share/resources/icon/32x32/line.png diff --git a/src/app/share/resources/icon/32x32/line_intersect_axis.png b/src/app/share/resources/icon/32x32/line_intersect_axis.png new file mode 100644 index 000000000..3d3037f56 Binary files /dev/null and b/src/app/share/resources/icon/32x32/line_intersect_axis.png differ diff --git a/src/app/share/resources/icon/32x32/new_detail.png b/src/app/share/resources/icon/32x32/new_detail.png new file mode 100644 index 000000000..0e6dd328f Binary files /dev/null and b/src/app/share/resources/icon/32x32/new_detail.png differ diff --git a/src/app/share/resources/icon/32x32/new_draw.png b/src/app/share/resources/icon/32x32/new_draw.png new file mode 100644 index 000000000..ca1f5b2e0 Binary files /dev/null and b/src/app/share/resources/icon/32x32/new_draw.png differ diff --git a/share/resources/icon/32x32/normal.png b/src/app/share/resources/icon/32x32/normal.png similarity index 100% rename from share/resources/icon/32x32/normal.png rename to src/app/share/resources/icon/32x32/normal.png diff --git a/share/resources/icon/32x32/option_draw.png b/src/app/share/resources/icon/32x32/option_draw.png similarity index 100% rename from share/resources/icon/32x32/option_draw.png rename to src/app/share/resources/icon/32x32/option_draw.png diff --git a/src/app/share/resources/icon/32x32/point_of_contact.png b/src/app/share/resources/icon/32x32/point_of_contact.png new file mode 100644 index 000000000..551c53528 Binary files /dev/null and b/src/app/share/resources/icon/32x32/point_of_contact.png differ diff --git a/share/resources/icon/32x32/point_of_intersection.png b/src/app/share/resources/icon/32x32/point_of_intersection.png similarity index 100% rename from share/resources/icon/32x32/point_of_intersection.png rename to src/app/share/resources/icon/32x32/point_of_intersection.png diff --git a/src/app/share/resources/icon/32x32/putHereLeft.png b/src/app/share/resources/icon/32x32/putHereLeft.png new file mode 100644 index 000000000..396a819b1 Binary files /dev/null and b/src/app/share/resources/icon/32x32/putHereLeft.png differ diff --git a/share/resources/icon/32x32/put_after.png b/src/app/share/resources/icon/32x32/put_after.png similarity index 100% rename from share/resources/icon/32x32/put_after.png rename to src/app/share/resources/icon/32x32/put_after.png diff --git a/share/resources/icon/32x32/segment.png b/src/app/share/resources/icon/32x32/segment.png similarity index 100% rename from share/resources/icon/32x32/segment.png rename to src/app/share/resources/icon/32x32/segment.png diff --git a/share/resources/icon/32x32/shoulder.png b/src/app/share/resources/icon/32x32/shoulder.png similarity index 100% rename from share/resources/icon/32x32/shoulder.png rename to src/app/share/resources/icon/32x32/shoulder.png diff --git a/share/resources/icon/32x32/spline.png b/src/app/share/resources/icon/32x32/spline.png similarity index 100% rename from share/resources/icon/32x32/spline.png rename to src/app/share/resources/icon/32x32/spline.png diff --git a/share/resources/icon/32x32/splinePath.png b/src/app/share/resources/icon/32x32/splinePath.png similarity index 100% rename from share/resources/icon/32x32/splinePath.png rename to src/app/share/resources/icon/32x32/splinePath.png diff --git a/src/app/share/resources/icon/32x32/splinePath_cut_point.png b/src/app/share/resources/icon/32x32/splinePath_cut_point.png new file mode 100644 index 000000000..abda45b3f Binary files /dev/null and b/src/app/share/resources/icon/32x32/splinePath_cut_point.png differ diff --git a/src/app/share/resources/icon/32x32/spline_cut_point.png b/src/app/share/resources/icon/32x32/spline_cut_point.png new file mode 100644 index 000000000..8b713665d Binary files /dev/null and b/src/app/share/resources/icon/32x32/spline_cut_point.png differ diff --git a/share/resources/icon/32x32/table.png b/src/app/share/resources/icon/32x32/table.png similarity index 100% rename from share/resources/icon/32x32/table.png rename to src/app/share/resources/icon/32x32/table.png diff --git a/src/app/share/resources/icon/32x32/triangle.png b/src/app/share/resources/icon/32x32/triangle.png new file mode 100644 index 000000000..9027f9b13 Binary files /dev/null and b/src/app/share/resources/icon/32x32/triangle.png differ diff --git a/src/app/share/resources/icon/32x32/union.png b/src/app/share/resources/icon/32x32/union.png new file mode 100644 index 000000000..5c8ad9c88 Binary files /dev/null and b/src/app/share/resources/icon/32x32/union.png differ diff --git a/src/app/share/resources/icon/64x64/icon64x64.ico b/src/app/share/resources/icon/64x64/icon64x64.ico new file mode 100644 index 000000000..5f3be666b Binary files /dev/null and b/src/app/share/resources/icon/64x64/icon64x64.ico differ diff --git a/src/app/share/resources/icon/64x64/icon64x64.png b/src/app/share/resources/icon/64x64/icon64x64.png new file mode 100644 index 000000000..dffdc9960 Binary files /dev/null and b/src/app/share/resources/icon/64x64/icon64x64.png differ diff --git a/src/app/share/resources/icon/Graduation.png b/src/app/share/resources/icon/Graduation.png new file mode 100644 index 000000000..461bc95d1 Binary files /dev/null and b/src/app/share/resources/icon/Graduation.png differ diff --git a/src/app/share/resources/icon/community_config.png b/src/app/share/resources/icon/community_config.png new file mode 100644 index 000000000..cde5b3931 Binary files /dev/null and b/src/app/share/resources/icon/community_config.png differ diff --git a/src/app/share/resources/icon/config.png b/src/app/share/resources/icon/config.png new file mode 100644 index 000000000..a95ff55f9 Binary files /dev/null and b/src/app/share/resources/icon/config.png differ diff --git a/src/app/share/resources/icon/individual.png b/src/app/share/resources/icon/individual.png new file mode 100644 index 000000000..9081d75c2 Binary files /dev/null and b/src/app/share/resources/icon/individual.png differ diff --git a/src/app/share/resources/icon/logo.svg b/src/app/share/resources/icon/logo.svg new file mode 100644 index 000000000..9c099f2a7 --- /dev/null +++ b/src/app/share/resources/icon/logo.svg @@ -0,0 +1,28855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/app/share/resources/icon/path_config.png b/src/app/share/resources/icon/path_config.png new file mode 100644 index 000000000..e8747b0e4 Binary files /dev/null and b/src/app/share/resources/icon/path_config.png differ diff --git a/src/app/share/resources/icon/pattern_config.png b/src/app/share/resources/icon/pattern_config.png new file mode 100644 index 000000000..4f5fb8004 Binary files /dev/null and b/src/app/share/resources/icon/pattern_config.png differ diff --git a/src/app/share/resources/icon/svg/arc_intersect_axis.svg b/src/app/share/resources/icon/svg/arc_intersect_axis.svg new file mode 100644 index 000000000..56b8273f9 --- /dev/null +++ b/src/app/share/resources/icon/svg/arc_intersect_axis.svg @@ -0,0 +1,50 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/app/share/resources/icon/svg/curve_intersect_axis.svg b/src/app/share/resources/icon/svg/curve_intersect_axis.svg new file mode 100644 index 000000000..49d6e0ccd --- /dev/null +++ b/src/app/share/resources/icon/svg/curve_intersect_axis.svg @@ -0,0 +1,49 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/app/share/resources/icon/svg/line_intersect_axis.svg b/src/app/share/resources/icon/svg/line_intersect_axis.svg new file mode 100644 index 000000000..7a1ddf3e9 --- /dev/null +++ b/src/app/share/resources/icon/svg/line_intersect_axis.svg @@ -0,0 +1,59 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/app/share/resources/icon/svg/point_of_contact.svg b/src/app/share/resources/icon/svg/point_of_contact.svg new file mode 100644 index 000000000..2bc59916a --- /dev/null +++ b/src/app/share/resources/icon/svg/point_of_contact.svg @@ -0,0 +1,92 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/application-exit.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/application-exit.png new file mode 100755 index 000000000..2ea3e9c29 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/application-exit.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-new.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-new.png new file mode 100644 index 000000000..2cab19daf Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-new.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-open.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-open.png new file mode 100644 index 000000000..4eb86be58 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-open.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save-as.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save-as.png new file mode 100644 index 000000000..3c4f56d07 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save-as.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save.png new file mode 100644 index 000000000..3c4f56d07 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-save.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-delete.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-delete.png new file mode 100755 index 000000000..b6cfee111 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-delete.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png new file mode 100644 index 000000000..0bf5159f6 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png new file mode 100644 index 000000000..c6ddff49d Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-down.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-down.png new file mode 100644 index 000000000..a74287892 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-down.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-next.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-next.png new file mode 100644 index 000000000..5883d9dca Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/go-next.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/help-contents.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/help-contents.png new file mode 100644 index 000000000..0aa517949 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/help-contents.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-add.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-add.png new file mode 100644 index 000000000..c9a2182fb Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-add.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-remove.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-remove.png new file mode 100644 index 000000000..12cd06799 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/list-remove.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-left.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-left.png new file mode 100644 index 000000000..c6ddff49d Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/object-rotate-left.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/preferences-other.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/preferences-other.png new file mode 100644 index 000000000..e72bd7147 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/preferences-other.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/process-stop.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/process-stop.png new file mode 100644 index 000000000..c3469ca1b Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/process-stop.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png new file mode 100644 index 000000000..fbba7abda Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-in.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-in.png new file mode 100644 index 000000000..3eedd5c68 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-in.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png new file mode 100644 index 000000000..61a4118ae Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-original.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-out.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-out.png new file mode 100644 index 000000000..d62b76c1c Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/zoom-out.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/application-exit.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/application-exit.png new file mode 100755 index 000000000..cb17223d5 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/application-exit.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-new.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-new.png new file mode 100755 index 000000000..e0388997b Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-new.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-open.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-open.png new file mode 100755 index 000000000..57fe97be8 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-open.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save-as.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save-as.png new file mode 100755 index 000000000..9cd361f3f Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save-as.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save.png new file mode 100755 index 000000000..ba66561a0 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/document-save.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-delete.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-delete.png new file mode 100755 index 000000000..6d9d20dc2 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-delete.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png new file mode 100755 index 000000000..6bac7ca71 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png new file mode 100755 index 000000000..c30db971d Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-down.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-down.png new file mode 100755 index 000000000..d53d924b9 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-down.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-next.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-next.png new file mode 100755 index 000000000..989e8d435 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/go-next.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/help-contents.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/help-contents.png new file mode 100644 index 000000000..be8096301 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/help-contents.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-add.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-add.png new file mode 100755 index 000000000..acbeb2db8 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-add.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-remove.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-remove.png new file mode 100755 index 000000000..57adbf536 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/list-remove.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-left.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-left.png new file mode 100644 index 000000000..938acb0d4 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/object-rotate-left.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/preferences-other.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/preferences-other.png new file mode 100644 index 000000000..a3af44259 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/preferences-other.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/process-stop.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/process-stop.png new file mode 100755 index 000000000..95cc6e0e1 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/process-stop.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png new file mode 100644 index 000000000..80a56b918 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png new file mode 100644 index 000000000..fe0fb3a8e Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-in.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png new file mode 100644 index 000000000..37c2c8f86 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-original.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png new file mode 100644 index 000000000..f605abbbf Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/zoom-out.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/application-exit.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/application-exit.png new file mode 100755 index 000000000..de2113a16 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/application-exit.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-new.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-new.png new file mode 100755 index 000000000..18a64739c Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-new.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-open.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-open.png new file mode 100644 index 000000000..f5e6806e3 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-open.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save-as.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save-as.png new file mode 100755 index 000000000..ad62d0c5f Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save-as.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save.png new file mode 100644 index 000000000..3e6f2ad17 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-save.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-delete.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-delete.png new file mode 100644 index 000000000..a488342ec Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-delete.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png new file mode 100644 index 000000000..353989137 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png new file mode 100644 index 000000000..938acb0d4 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-down.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-down.png new file mode 100755 index 000000000..e44828414 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-down.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-next.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-next.png new file mode 100644 index 000000000..8eabaafe8 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/go-next.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/help-contents.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/help-contents.png new file mode 100644 index 000000000..756c0d5fc Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/help-contents.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-add.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-add.png new file mode 100755 index 000000000..839d90587 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-add.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-remove.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-remove.png new file mode 100644 index 000000000..8cca6552b Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/list-remove.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-left.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-left.png new file mode 100644 index 000000000..938acb0d4 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/object-rotate-left.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/preferences-other.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/preferences-other.png new file mode 100644 index 000000000..116c278d9 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/preferences-other.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/process-stop.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/process-stop.png new file mode 100644 index 000000000..fc2c75622 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/process-stop.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png new file mode 100644 index 000000000..3b4a67890 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-fit-best.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-in.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-in.png new file mode 100644 index 000000000..64606208e Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-in.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png new file mode 100644 index 000000000..23faebbc1 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-original.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-out.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-out.png new file mode 100644 index 000000000..61fc868ea Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/zoom-out.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/index.theme b/src/app/share/resources/icons/win.icon.theme/index.theme new file mode 100755 index 000000000..2f0b86327 --- /dev/null +++ b/src/app/share/resources/icons/win.icon.theme/index.theme @@ -0,0 +1,25 @@ +[Icon Theme] +Name=win.icon.theme +Comment=win.icon.theme for valentina +Inherits=gnome,hicolor +Example=x-directory-normal + +#Directories +Directories=16x16/actions,24x24/actions,32x32/actions + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[24x24/actions] +Size=24 +Context=Actions +Type=Fixed + +[32x32/actions] +Size=32 +Context=Actions +Type=Fixed + + diff --git a/src/app/share/resources/measurements.qrc b/src/app/share/resources/measurements.qrc new file mode 100644 index 000000000..ca34fddcf --- /dev/null +++ b/src/app/share/resources/measurements.qrc @@ -0,0 +1,5 @@ + + + tables/individual/individual.vit + + diff --git a/src/app/share/resources/tables/individual/individual.vit b/src/app/share/resources/tables/individual/individual.vit new file mode 100644 index 000000000..9763dac52 --- /dev/null +++ b/src/app/share/resources/tables/individual/individual.vit @@ -0,0 +1,163 @@ + + + 0.2.0 + + + + 1900-01-01 + male + username@example.com + + + cm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/share/resources/tables/standard/GOST_man_ru.vst b/src/app/share/resources/tables/standard/GOST_man_ru.vst new file mode 100644 index 000000000..def58741e --- /dev/null +++ b/src/app/share/resources/tables/standard/GOST_man_ru.vst @@ -0,0 +1,158 @@ + + + 0.3.0 + Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см + 0 + mm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/share/resources/theme.qrc b/src/app/share/resources/theme.qrc new file mode 100644 index 000000000..9a816625f --- /dev/null +++ b/src/app/share/resources/theme.qrc @@ -0,0 +1,65 @@ + + + icons/win.icon.theme/index.theme + icons/win.icon.theme/16x16/actions/document-new.png + icons/win.icon.theme/24x24/actions/document-new.png + icons/win.icon.theme/32x32/actions/document-new.png + icons/win.icon.theme/16x16/actions/document-open.png + icons/win.icon.theme/24x24/actions/document-open.png + icons/win.icon.theme/32x32/actions/document-open.png + icons/win.icon.theme/16x16/actions/document-save.png + icons/win.icon.theme/24x24/actions/document-save.png + icons/win.icon.theme/32x32/actions/document-save.png + icons/win.icon.theme/16x16/actions/document-save-as.png + icons/win.icon.theme/24x24/actions/document-save-as.png + icons/win.icon.theme/32x32/actions/document-save-as.png + icons/win.icon.theme/16x16/actions/go-next.png + icons/win.icon.theme/24x24/actions/go-next.png + icons/win.icon.theme/32x32/actions/go-next.png + icons/win.icon.theme/16x16/actions/object-rotate-left.png + icons/win.icon.theme/24x24/actions/object-rotate-left.png + icons/win.icon.theme/32x32/actions/object-rotate-left.png + icons/win.icon.theme/16x16/actions/process-stop.png + icons/win.icon.theme/24x24/actions/process-stop.png + icons/win.icon.theme/32x32/actions/process-stop.png + icons/win.icon.theme/16x16/actions/zoom-in.png + icons/win.icon.theme/24x24/actions/zoom-in.png + icons/win.icon.theme/32x32/actions/zoom-in.png + icons/win.icon.theme/16x16/actions/zoom-out.png + icons/win.icon.theme/24x24/actions/zoom-out.png + icons/win.icon.theme/32x32/actions/zoom-out.png + icons/win.icon.theme/16x16/actions/list-remove.png + icons/win.icon.theme/24x24/actions/list-remove.png + icons/win.icon.theme/32x32/actions/list-remove.png + icons/win.icon.theme/16x16/actions/list-add.png + icons/win.icon.theme/24x24/actions/list-add.png + icons/win.icon.theme/32x32/actions/list-add.png + icons/win.icon.theme/16x16/actions/edit-redo.png + icons/win.icon.theme/24x24/actions/edit-redo.png + icons/win.icon.theme/32x32/actions/edit-redo.png + icons/win.icon.theme/16x16/actions/edit-undo.png + icons/win.icon.theme/24x24/actions/edit-undo.png + icons/win.icon.theme/32x32/actions/edit-undo.png + icons/win.icon.theme/16x16/actions/go-down.png + icons/win.icon.theme/24x24/actions/go-down.png + icons/win.icon.theme/32x32/actions/go-down.png + icons/win.icon.theme/16x16/actions/zoom-fit-best.png + icons/win.icon.theme/24x24/actions/zoom-fit-best.png + icons/win.icon.theme/32x32/actions/zoom-fit-best.png + icons/win.icon.theme/16x16/actions/zoom-original.png + icons/win.icon.theme/24x24/actions/zoom-original.png + icons/win.icon.theme/32x32/actions/zoom-original.png + icons/win.icon.theme/16x16/actions/application-exit.png + icons/win.icon.theme/24x24/actions/application-exit.png + icons/win.icon.theme/32x32/actions/application-exit.png + icons/win.icon.theme/16x16/actions/preferences-other.png + icons/win.icon.theme/24x24/actions/preferences-other.png + icons/win.icon.theme/32x32/actions/preferences-other.png + icons/win.icon.theme/16x16/actions/edit-delete.png + icons/win.icon.theme/24x24/actions/edit-delete.png + icons/win.icon.theme/32x32/actions/edit-delete.png + icons/win.icon.theme/16x16/actions/help-contents.png + icons/win.icon.theme/24x24/actions/help-contents.png + icons/win.icon.theme/32x32/actions/help-contents.png + + diff --git a/src/app/share/resources/valentina.rc b/src/app/share/resources/valentina.rc new file mode 100644 index 000000000..61e183aca --- /dev/null +++ b/src/app/share/resources/valentina.rc @@ -0,0 +1,34 @@ +IDI_ICON1 ICON DISCARDABLE "icon/64x64/icon64x64.ico" + +#include +#include "../../version.h" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", VER_COMPANYNAME_STR + VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR + VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR + VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR + VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR + VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04E4 //U.S. English + END +END diff --git a/src/stable.cpp b/src/app/stable.cpp similarity index 95% rename from src/stable.cpp rename to src/app/stable.cpp index 57b3c2027..243b23938 100644 --- a/src/stable.cpp +++ b/src/app/stable.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file stable.cpp - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief diff --git a/src/app/stable.h b/src/app/stable.h new file mode 100644 index 000000000..695fe3df7 --- /dev/null +++ b/src/app/stable.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file stable.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 STABLE_H +#define STABLE_H + +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for Valentina.\n") +#endif + +/* Add C includes here */ + +#if defined __cplusplus +/* Add C++ includes here */ +#include + +/*In all cases we need include core header for getting defined values*/ +#ifdef QT_CORE_LIB +# include +#endif + +#ifdef QT_GUI_LIB +# include +#endif + +#ifdef QT_XML_LIB +# include +#endif + +//In Windows you can't use same header in all modes. +#if !defined(Q_OS_WIN) +# ifdef QT_WIDGETS_LIB +# include +# endif + +# ifdef QT_SVG_LIB +# include +# endif + +# ifdef QT_PRINTSUPPORT_LIB +# include +# endif + + //Build doesn't work, if include this headers on Windows. +# ifdef QT_XMLPATTERNS_LIB +# include +# endif + +# ifdef QT_NETWORK_LIB +# include +# endif +#endif/*Q_OS_WIN*/ + +#endif /*__cplusplus*/ + +#endif // STABLE_H diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp new file mode 100644 index 000000000..525c5fe2c --- /dev/null +++ b/src/app/tablewindow.cpp @@ -0,0 +1,676 @@ +/************************************************************************ + ** + ** @file tablewindow.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "tablewindow.h" +#include "ui_tablewindow.h" +#include "widgets/vtablegraphicsview.h" +#include +#include +#include "core/vapplication.h" +#include +#include "../../libs/vobj/vobjpaintdevice.h" + +#ifdef Q_OS_WIN +# define PDFTOPS "pdftops.exe" +#else +# define PDFTOPS "pdftops" +#endif + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TableWindow constructor. + * @param parent parent widget. + */ +TableWindow::TableWindow(QWidget *parent) + :QMainWindow(parent), numberDetal(nullptr), colission(nullptr), ui(new Ui::TableWindow), + listDetails(QVector()), outItems(false), collidingItems(false), tableScene(nullptr), + paper(nullptr), shadowPaper(nullptr), listOutItems(nullptr), listCollidingItems(QList()), + indexDetail(0), sceneRect(QRectF()), fileName(QString()), description(QString()) +{ + ui->setupUi(this); + numberDetal = new QLabel(tr("0 details left."), this); + colission = new QLabel(tr("Collisions not found."), this); + ui->statusBar->addWidget(numberDetal); + ui->statusBar->addWidget(colission); + outItems = collidingItems = false; + sceneRect = QRectF(0, 0, qApp->toPixel(823, Unit::Mm), qApp->toPixel(1171, Unit::Mm)); + tableScene = new QGraphicsScene(sceneRect); + QBrush brush; + brush.setStyle( Qt::SolidPattern ); + brush.setColor( QColor( Qt::gray ) ); + tableScene->setBackgroundBrush( brush ); + + ui->view->setScene(tableScene); + ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); + ui->horizontalLayout->addWidget(ui->view); + connect(tableScene, &QGraphicsScene::selectionChanged, ui->view, &VTableGraphicsView::selectionChanged); + connect(ui->actionTurn, &QAction::triggered, ui->view, &VTableGraphicsView::rotateItems); + connect(ui->actionMirror, &QAction::triggered, ui->view, &VTableGraphicsView::MirrorItem); + connect(ui->actionZoomIn, &QAction::triggered, ui->view, &VTableGraphicsView::ZoomIn); + connect(ui->actionZoomOut, &QAction::triggered, ui->view, &VTableGraphicsView::ZoomOut); + connect(ui->actionStop, &QAction::triggered, this, &TableWindow::StopTable); + connect(ui->actionSave, &QAction::triggered, this, &TableWindow::saveScene); + connect(ui->actionNext, &QAction::triggered, this, &TableWindow::GetNextDetail); + connect(ui->actionAdd, &QAction::triggered, this, &TableWindow::AddLength); + connect(ui->actionRemove, &QAction::triggered, this, &TableWindow::RemoveLength); + connect(ui->view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); +} + +//--------------------------------------------------------------------------------------------------------------------- +TableWindow::~TableWindow() +{ + delete tableScene; + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddPaper add to the scene paper and shadow. + */ +void TableWindow::AddPaper() +{ + qreal x1, y1, x2, y2; + sceneRect.getCoords(&x1, &y1, &x2, &y2); + shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); + shadowPaper->setBrush(QBrush(Qt::black)); + tableScene->addItem(shadowPaper); + paper = new QGraphicsRectItem(QRectF(x1, y1, x2, y2)); + paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + paper->setBrush(QBrush(Qt::white)); + tableScene->addItem(paper); + qDebug()<rect().size().toSize(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddDetail show on scene next detail. + */ +void TableWindow::AddDetail() +{ + if (indexDetailclearSelection(); + VItem* Detail = listDetails[indexDetail]; + SCASSERT(Detail != nullptr); + connect(Detail, &VItem::itemOut, this, &TableWindow::itemOut); + connect(Detail, &VItem::itemColliding, this, &TableWindow::itemColliding); + connect(this, &TableWindow::LengthChanged, Detail, &VItem::LengthChanged); + Detail->setPen(QPen(Qt::black, 1)); + Detail->setBrush(QBrush(Qt::white)); + Detail->setPos(paper->boundingRect().center()); + Detail->setFlag(QGraphicsItem::ItemIsMovable, true); + Detail->setFlag(QGraphicsItem::ItemIsSelectable, true); + Detail->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + Detail->setPaper(paper); + tableScene->addItem(Detail); + Detail->setSelected(true); + indexDetail++; + if (indexDetail==listDetails.count()) + { + ui->actionSave->setEnabled(true); + } + } + numberDetal->setText(QString(tr("%1 details left.")).arg(listDetails.count()-indexDetail)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ModelChosen show window when user want create new layout. + * @param listDetails list of details. + * @param description pattern description. + */ +/* + * Get details for creation layout. + */ +void TableWindow::ModelChosen(QVector listDetails, const QString &fileName, const QString &description) +{ + this->description = description; + + QString file; + if (fileName.isEmpty()) + { + file = tr("untitled"); + } + else + { + file = fileName; + } + QFileInfo fi( file ); + this->fileName = fi.baseName(); + + this->listDetails = listDetails; + listOutItems = new QBitArray(this->listDetails.count()); + AddPaper(); + indexDetail = 0; + AddDetail(); + show(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle after close window. + * @param event close event. + */ +void TableWindow::closeEvent(QCloseEvent *event) +{ + event->ignore(); + StopTable(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief moveToCenter move screen to the center of window. + */ +void TableWindow::moveToCenter() +{ + QRect rect = frameGeometry(); + rect.moveCenter(QDesktopWidget().availableGeometry().center()); + move(rect.topLeft()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief showEvent handle after show window. + * @param event show event. + */ +void TableWindow::showEvent ( QShowEvent * event ) +{ + QMainWindow::showEvent(event); + moveToCenter(); + ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief StopTable stop creation layout. + */ +void TableWindow::StopTable() +{ + hide(); + tableScene->clear(); + delete listOutItems; + listDetails.clear(); + sceneRect = QRectF(0, 0, qApp->toPixel(823, Unit::Mm), qApp->toPixel(1171, Unit::Mm)); + tableScene->setSceneRect(sceneRect); + emit closed(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief saveScene save created layout. + */ +void TableWindow::saveScene() +{ + QMap extByMessage; + extByMessage[ tr("Svg files (*.svg)") ] = ".svg"; + extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf"; + extByMessage[ tr("Images (*.png)") ] = ".png"; + extByMessage[ tr("Wavefront OBJ (*.obj)") ] = ".obj"; + + QProcess proc; + proc.start(PDFTOPS); + if (proc.waitForFinished(15000)) + { + extByMessage[ tr("PS files (*.ps)") ] = ".ps"; + extByMessage[ tr("EPS files (*.eps)") ] = ".eps"; + } + else + { + qWarning()< i(extByMessage); + while (i.hasNext()) + { + i.next(); + saveMessage += i.key(); + if (i.hasNext()) + { + saveMessage += ";;"; + } + } + + QString sf; + // the save function + QString dir = QDir::homePath()+"/"+fileName; + QString name = QFileDialog::getSaveFileName(this, tr("Save layout"), dir, saveMessage, &sf); + + if (name.isEmpty()) + { + return; + } + + // what if the user did not specify a suffix...? + QString suf = extByMessage.value(sf); + suf.replace(".", ""); + QFileInfo f( name ); + if (f.suffix().isEmpty() || f.suffix() != suf) + { + name += extByMessage.value(sf); + } + + QBrush *brush = new QBrush(); + brush->setColor( QColor( Qt::white ) ); + tableScene->setBackgroundBrush( *brush ); + tableScene->clearSelection(); // Selections would also render to the file, so need delete them + shadowPaper->setVisible(false); + paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); + QFileInfo fi( name ); + QStringList suffix = QStringList() << "svg" << "png" << "pdf" << "eps" << "ps" << "obj"; + switch (suffix.indexOf(fi.suffix())) + { + case 0: //svg + paper->setVisible(false); + SvgFile(name); + paper->setVisible(true); + break; + case 1: //png + PngFile(name); + break; + case 2: //pdf + PdfFile(name); + break; + case 3: //eps + EpsFile(name); + break; + case 4: //ps + PsFile(name); + break; + case 5: //obj + paper->setVisible(false); + ObjFile(name); + paper->setVisible(true); + break; + default: + qDebug() << "Can't recognize file suffix. File file "<setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + brush->setColor( QColor( Qt::gray ) ); + brush->setStyle( Qt::SolidPattern ); + tableScene->setBackgroundBrush( *brush ); + shadowPaper->setVisible(true); + delete brush; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChect turn off rotation button if don't selected detail. + * @param flag true - enable button. + */ +void TableWindow::itemChect(bool flag) +{ + ui->actionTurn->setDisabled(flag); + ui->actionMirror->setDisabled(flag); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief checkNext disable next detail button if exist colission or out details. + */ +void TableWindow::checkNext() +{ + if (outItems == true && collidingItems == true) + { + colission->setText(tr("Collisions not found.")); + if (indexDetail==listDetails.count()) + { + ui->actionSave->setEnabled(true); + ui->actionNext->setDisabled(true); + } + else + { + ui->actionNext->setDisabled(false); + ui->actionSave->setEnabled(false); + } + } + else + { + colission->setText(tr("Collisions found.")); + ui->actionNext->setDisabled(true); + ui->actionSave->setEnabled(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemOut handled if detail moved out paper sheet. + * @param number Number detail in list. + * @param flag set state of detail. True if detail moved out paper sheet. + */ +void TableWindow::itemOut(int number, bool flag) +{ + listOutItems->setBit(number, flag); + for ( int i = 0; i < listOutItems->count(); ++i ) + { + if (listOutItems->at(i)==true) + { + outItems=false; + qDebug()<<"itemOut::outItems="< list, int number) +{ + //qDebug()<<"number="<1) + { + for ( int i = 0; i < listCollidingItems.count(); ++i ) + { + QList lis = listCollidingItems.at(i)->collidingItems(); + if (lis.size()-2 <= 0) + { + VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(i) ); + SCASSERT(bitem != nullptr); + bitem->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + listCollidingItems.removeAt(i); + } + } + } + else if (listCollidingItems.size()==1) + { + VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(0) ); + SCASSERT(bitem != nullptr); + bitem->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + listCollidingItems.clear(); + collidingItems = true; + } + } + else + { + collidingItems = true; + } + } + else + { + collidingItems = true; + } + } + else if (number==1) + { + if (list.contains(paper)==true) + { + list.removeAt(list.indexOf(paper)); + } + if (list.contains(shadowPaper)==true) + { + list.removeAt(list.indexOf(shadowPaper)); + } + for ( int i = 0; i < list.count(); ++i ) + { + if (listCollidingItems.contains(list.at(i))==false) + { + listCollidingItems.append(list.at(i)); + } + } + collidingItems = false; + } + qDebug()<<"itemColliding::outItems="<sceneRect(); + rect.setHeight(rect.height()+qApp->toPixel(279, Unit::Mm)); + tableScene->setSceneRect(rect); + rect = shadowPaper->rect(); + rect.setHeight(rect.height()+qApp->toPixel(279, Unit::Mm)); + shadowPaper->setRect(rect); + rect = paper->rect(); + rect.setHeight(rect.height()+qApp->toPixel(279, Unit::Mm)); + paper->setRect(rect); + ui->actionRemove->setEnabled(true); + emit LengthChanged(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveLength reduce the length of paper sheet. You can reduce to the minimal value only. + */ +void TableWindow::RemoveLength() +{ + if (sceneRect.height() <= tableScene->sceneRect().height() - 100) + { + QRectF rect = tableScene->sceneRect(); + rect.setHeight(rect.height()-qApp->toPixel(279, Unit::Mm)); + tableScene->setSceneRect(rect); + rect = shadowPaper->rect(); + rect.setHeight(rect.height()-qApp->toPixel(279, Unit::Mm)); + shadowPaper->setRect(rect); + rect = paper->rect(); + rect.setHeight(rect.height()-qApp->toPixel(279, Unit::Mm)); + paper->setRect(rect); + if (fabs(sceneRect.height() - tableScene->sceneRect().height()) < 0.01) + { + ui->actionRemove->setDisabled(true); + } + emit LengthChanged(); + } + else + { + ui->actionRemove->setDisabled(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key event. + */ +void TableWindow::keyPressEvent ( QKeyEvent * event ) +{ + if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ) + { + if (ui->actionNext->isEnabled() == true ) + { + AddDetail(); + qDebug()<<"Added detail."; + } + } + QMainWindow::keyPressEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SvgFile save layout to svg file. + * @param name name layout file. + */ +void TableWindow::SvgFile(const QString &name) const +{ + QSvgGenerator generator; + generator.setFileName(name); + generator.setSize(paper->rect().size().toSize()); + generator.setViewBox(paper->rect()); + generator.setTitle("Valentina pattern"); + generator.setDescription(description); + generator.setResolution(static_cast(qApp->PrintDPI)); + QPainter painter; + painter.begin(&generator); + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + tableScene->render(&painter); + painter.end(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PngFile save layout to png file. + * @param name name layout file. + */ +void TableWindow::PngFile(const QString &name) const +{ + QRectF r = paper->rect(); + qreal x=0, y=0, w=0, h=0; + r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents + // Create the image with the exact size of the shrunk scene + QImage image(QSize(static_cast(w), static_cast(h)), QImage::Format_ARGB32); + image.fill(Qt::transparent); // Start all pixels transparent + QPainter painter(&image); + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + tableScene->render(&painter); + image.save(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PdfFile save layout to pdf file. + * @param name name layout file. + */ +void TableWindow::PdfFile(const QString &name) const +{ + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(name); + QRectF r = paper->rect(); + qreal x=0, y=0, w=0, h=0; + r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents + printer.setResolution(static_cast(qApp->PrintDPI)); + printer.setPaperSize ( QSizeF(qApp->fromPixel(w, Unit::Mm), qApp->fromPixel(h, Unit::Mm)), QPrinter::Millimeter ); + QPainter painter; + if (painter.begin( &printer ) == false) + { // failed to open file + qCritical("Can't open printer %s", qPrintable(name)); + return; + } + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + tableScene->render(&painter); + painter.end(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EpsFile save layout to eps file. + * @param name name layout file. + */ +void TableWindow::EpsFile(const QString &name) const +{ + QTemporaryFile tmp; + if (tmp.open()) + { + PdfFile(tmp.fileName()); + QStringList params = QStringList() << "-eps" << tmp.fileName() << name; + PdfToPs(params); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PsFile save layout to ps file. + * @param name name layout file. + */ +void TableWindow::PsFile(const QString &name) const +{ + QTemporaryFile tmp; + if (tmp.open()) + { + PdfFile(tmp.fileName()); + QStringList params = QStringList() << tmp.fileName() << name; + PdfToPs(params); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format. + * @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when + * need create eps file. + */ +void TableWindow::PdfToPs(const QStringList ¶ms) const +{ +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + QProcess proc; + proc.start(PDFTOPS, params); + proc.waitForFinished(15000); +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + + QFile f(params.last()); + if (f.exists() == false) + { + QString msg = QString(tr("Creating file '%1' failed! %2")).arg(params.last()).arg(proc.errorString()); + QMessageBox msgBox(QMessageBox::Critical, tr("Critical error!"), msg, QMessageBox::Ok | QMessageBox::Default); + msgBox.exec(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::ObjFile(const QString &name) const +{ + VObjPaintDevice generator; + generator.setFileName(name); + generator.setSize(paper->rect().size().toSize()); + generator.setResolution(static_cast(qApp->PrintDPI)); + QPainter painter; + painter.begin(&generator); + tableScene->render(&painter); + painter.end(); +} diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h new file mode 100644 index 000000000..319cdf1d6 --- /dev/null +++ b/src/app/tablewindow.h @@ -0,0 +1,146 @@ +/************************************************************************ + ** + ** @file tablewindow.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 TABLEWINDOW_H +#define TABLEWINDOW_H + +#include +#include +#include "widgets/vitem.h" + +namespace Ui +{ + class TableWindow; +} + +/** + * @brief TableWindow class layout window. + */ +class TableWindow : public QMainWindow +{ + Q_OBJECT +public: + /** @brief numberDetal show count details, what need placed. */ + QLabel* numberDetal; + + /** @brief colission show if exist colissions. */ + QLabel* colission; + + explicit TableWindow(QWidget *parent = nullptr); + ~TableWindow(); +public slots: + + void ModelChosen(QVector listDetails, const QString &fileName, const QString &description); + + void StopTable(); + + void saveScene(); + + void GetNextDetail(); + + void itemChect(bool flag); + + void itemOut(int number, bool flag); + + void itemColliding(QList list, int number); + + void AddLength(); + + void RemoveLength(); +signals: + /** + * @brief closed emit if window is closing. + */ + void closed(); + /** + * @brief LengthChanged emit if changing length of paper sheet. + */ + void LengthChanged(); +protected: + + void closeEvent(QCloseEvent *event); + + void moveToCenter(); + + void showEvent ( QShowEvent * event ); + + void keyPressEvent ( QKeyEvent * event ); +private: + Q_DISABLE_COPY(TableWindow) + /** @brief ui keeps information about user interface */ + Ui::TableWindow* ui; + + /** @brief listDetails list of details. */ + QVector listDetails; + + /** @brief outItems true if we have details out paper sheet. */ + bool outItems; + + /** @brief collidingItems true if we have colission details. */ + bool collidingItems; + + /** @brief currentScene pointer to scene. */ + QGraphicsScene* tableScene; + + /** @brief paper paper sheet. */ + QGraphicsRectItem* paper; + + /** @brief shadowPaper paper sheet shadow. */ + QGraphicsRectItem* shadowPaper; + + /** @brief listOutItems list state out each detail. */ + QBitArray* listOutItems; + + /** @brief listCollidingItems list colissed details. */ + QList listCollidingItems; + + /** @brief indexDetail index next detail in list what will be shown. */ + qint32 indexDetail; + + /** @brief sceneRect minimal size of a paper. */ + QRectF sceneRect; + + /** @brief fileName keep name of pattern file. */ + QString fileName; + + /** @brief description pattern description */ + QString description; + + void checkNext(); + void AddPaper(); + void AddDetail(); + void SvgFile(const QString &name)const; + void PngFile(const QString &name)const; + void PdfFile(const QString &name)const; + void EpsFile(const QString &name)const; + void PsFile(const QString &name)const; + void PdfToPs(const QStringList ¶ms)const; + void ObjFile(const QString &name)const; +}; + +#endif // TABLEWINDOW_H diff --git a/src/tablewindow.ui b/src/app/tablewindow.ui similarity index 90% rename from src/tablewindow.ui rename to src/app/tablewindow.ui index 89e7eb289..8f237a1d5 100644 --- a/src/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -14,7 +14,7 @@ Create a layout - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -37,6 +37,9 @@ 9 + + +
@@ -111,7 +114,7 @@ Turn - Turn the detail 180 degrees + Turn the detail 90 degrees @@ -137,7 +140,7 @@ Enlarge letter - Enlarge the length of sheet + Enlarge the length of the sheet @@ -161,7 +164,7 @@ false - + :/icon/16x16/mirror.png:/icon/16x16/mirror.png @@ -198,8 +201,15 @@ + + + VTableGraphicsView + QGraphicsView +
vtablegraphicsview.h
+
+
- +
diff --git a/src/tools/drawTools/drawtools.h b/src/app/tools/drawTools/drawtools.h similarity index 88% rename from src/tools/drawTools/drawtools.h rename to src/app/tools/drawTools/drawtools.h index b0102c570..50930c440 100644 --- a/src/tools/drawTools/drawtools.h +++ b/src/app/tools/drawTools/drawtools.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file drawtools.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -44,5 +44,10 @@ #include "vtoolheight.h" #include "vtooltriangle.h" #include "vtoolpointofintersection.h" +#include "vtoolcutspline.h" +#include "vtoolcutsplinepath.h" +#include "vtoolcutarc.h" +#include "vtoollineintersectaxis.h" +#include "vtoolcurveintersectaxis.h" #endif // DRAWTOOLS_H diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp new file mode 100644 index 000000000..aa6efbe7e --- /dev/null +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -0,0 +1,221 @@ +/************************************************************************ + ** + ** @file vabstractspline.cpp + ** @author Roman Telezhynskyi + ** @date 4 3, 2014 + ** + ** @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 + ** 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 "vabstractspline.h" +#include + +const QString VAbstractSpline::TagName = QStringLiteral("spline"); + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) + :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector()), + sceneType(SceneObject::Unknown), isHovered(false) +{ + ignoreFullUpdate = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractSpline::~VAbstractSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsPathItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractSpline::getTagName() const +{ + return VAbstractSpline::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VAbstractSpline::FullUpdateFromFile() +{ + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::Disable(bool disable) +{ + DisableItem(this, disable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VAbstractSpline::ChangedActivDraw(const QString &newName) +{ + VDrawTool::ChangedActivDraw(newName); + const bool selectable = (nameActivDraw == newName); + this->setEnabled(selectable); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + emit setEnabledPoint(selectable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container + * @param color highlight color. + * @param enable enable or disable highlight. + */ +void VAbstractSpline::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +{ + ShowItem(this, id, color, enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VAbstractSpline::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverEnterEvent handle hover enter events. + * @param event hover enter event. + */ +// cppcheck-suppress unusedFunction +void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, Qt::RoundCap)); + this->setPath(ToolPath(PathDirection::Show)); + isHovered = true; + QGraphicsPathItem::hoverEnterEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +// cppcheck-suppress unusedFunction +void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPath(ToolPath()); + isHovered = false; + QGraphicsPathItem::hoverLeaveEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange hadle item change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (value == true) + { + // do stuff if selected + this->setFocus(); + } + else + { + // do stuff if not selected + } + } + + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ +void VAbstractSpline::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + DeleteTool(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsItem::keyReleaseEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, sceneType); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const +{ + const QSharedPointer curve = VAbstractTool::data.GeometricObject(id); + QPainterPath path; + path.addPath(curve->GetPath(direction)); + path.setFillRule( Qt::WindingFill ); + return path; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::ShowFoot(bool show) +{ + for (int i = 0; i < controlPoints.size(); ++i) + { + controlPoints.at(i)->setVisible(show); + } +} diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h new file mode 100644 index 000000000..2c39f033f --- /dev/null +++ b/src/app/tools/drawTools/vabstractspline.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file vabstractspline.h + ** @author Roman Telezhynskyi + ** @date 4 3, 2014 + ** + ** @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 + ** 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 VABSTRACTSPLINE_H +#define VABSTRACTSPLINE_H + +#include "vdrawtool.h" +#include +#include "../../visualization/vcontrolpointspline.h" + +class VAbstractSpline:public VDrawTool, public QGraphicsPathItem +{ + Q_OBJECT +public: + VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); + virtual ~VAbstractSpline(); + static const QString TagName; + virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::AbstractSpline)}; + virtual QString getTagName() const; + void ShowFoot(bool show); +public slots: + virtual void FullUpdateFromFile (); + void Disable(bool disable); +signals: + /** + * @brief RefreshLine refresh control line. + * @param indexSpline position spline in spline list. + * @param pos position point in spline. + * @param controlPoint new position control point. + * @param splinePoint new position spline point. + */ + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, + const QPointF &controlPoint, const QPointF &splinePoint); + /** + * @brief setEnabledPoint disable control points. + * @param enable enable or diasable points. + */ + void setEnabledPoint(bool enable); +protected: + /** + * @brief controlPoints list pointers of control points. + */ + QVector controlPoints; + SceneObject sceneType; + bool isHovered; + /** + * @brief RefreshGeometry refresh item on scene. + */ + virtual void RefreshGeometry ()=0; + virtual void ChangedActivDraw ( const QString &newName ); + virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void SetFactor(qreal factor); + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void keyReleaseEvent(QKeyEvent * event); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; +private: + Q_DISABLE_COPY(VAbstractSpline) +}; + +#endif // VABSTRACTSPLINE_H diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp new file mode 100644 index 000000000..0902db7ba --- /dev/null +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -0,0 +1,287 @@ +/************************************************************************ + ** + ** @file vdrawtool.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vdrawtool.h" + +#include +#include "../dialogs/tools/dialogeditwrongformula.h" +#include "../dialogs/app/dialogundo.h" +#include "../container/calculator.h" +#include "../../undocommands/addtocalc.h" +#include "../../undocommands/savetooloptions.h" +#include "../../libs/ifc/exception/vexceptionundo.h" + +qreal VDrawTool::factor = 1; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDrawTool constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + */ +VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) + :VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false), + nameActivDraw(doc->GetNameActivPP()), dialog(nullptr) +{ + connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); + connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); + connect(this->doc, &VPattern::ShowTool, this, &VDrawTool::ShowTool); +} + +//--------------------------------------------------------------------------------------------------------------------- +VDrawTool::~VDrawTool() +{ + delete dialog; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container. + * @param color highlight color. + * @param enable enable or disable highlight. + */ +void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +{ + Q_UNUSED(id); + Q_UNUSED(color); + Q_UNUSED(enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. name new active pattern peace. + */ +void VDrawTool::ChangedActivDraw(const QString &newName) +{ + if (nameActivDraw == newName) + { + currentColor = baseColor; + } + else + { + currentColor = Qt::gray; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedNameDraw save new name active pattern peace. + * @param oldName old name. + * @param newName new name active pattern peace. new name. + */ +void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) +{ + if (nameActivDraw == oldName) + { + nameActivDraw = newName; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiOk refresh tool data after change in options. + * @param result keep result working dialog. + */ +void VDrawTool::FullUpdateFromGuiOk(int result) +{ + if (result == QDialog::Accepted) + { + SaveDialogChange(); + } + delete dialog; + dialog=nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog + */ +void VDrawTool::FullUpdateFromGuiApply() +{ + SaveDialogChange(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::SaveDialogChange() +{ + qCDebug(vTool)<<"Saving tool options after using dialog"; + QDomElement oldDomElement = doc->elementById(QString().setNum(id)); + if (oldDomElement.isElement()) + { + QDomElement newDomElement = oldDomElement.cloneNode().toElement(); + SaveDialog(newDomElement); + + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); + connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(saveOptions); + } + else + { + qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VDrawTool::AddToFile() +{ + QDomElement domElement = doc->createElement(getTagName()); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(domElement, obj); + AddToCalculation(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VDrawTool::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(domElement, obj); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogLinkDestroy removes dialog pointer + */ +void VDrawTool::DialogLinkDestroy() +{ + this->dialog=nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VDrawTool::SetFactor(qreal factor) +{ + VApplication::CheckFactor(this->factor, factor); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckFormula check formula. + * + * Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In + * successes case return result calculation and fixed formula string. If formula ok don't touch formula. + * + * @param toolId [in] tool's id. + * @param formula [in|out] string with formula. + * @param data [in] container with variables. Need for math parser. + * @throw QmuParserError. + * @return result of calculation formula. + */ +qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContainer *data) +{ + SCASSERT(data != nullptr) + qreal result = 0; + Calculator *cal = nullptr; + try + { + cal = new Calculator(data); + result = cal->EvalFormula(formula); + delete cal; + } + catch (qmu::QmuParserError &e) + { + //Q_UNUSED(e) + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; + delete cal; + + DialogUndo *dialogUndo = new DialogUndo(qApp->getMainWindow()); + if (dialogUndo->exec() == QDialog::Accepted) + { + UndoButton resultUndo = dialogUndo->Result(); + delete dialogUndo; + if (resultUndo == UndoButton::Fix) + { + DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow()); + dialog->setWindowTitle(tr("Edit wrong formula")); + dialog->setFormula(formula); + if (dialog->exec() == QDialog::Accepted) + { + formula = dialog->getFormula(); + /* Need delete dialog here because parser in dialog don't allow use correct separator for parsing + * here. */ + delete dialog; + Calculator *cal1 = new Calculator(data); + result = cal1->EvalFormula(formula); + delete cal1; /* Here can be memory leak, but dialog already check this formula and probability + * very low. */ + } + else + { + delete dialog; + throw; + } + } + else + { + QString what = QString("Undo wrong formula %1").arg(formula); + throw VExceptionUndo(what); + } + } + else + { + delete dialogUndo; + throw; + } + } + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToCalculation add tool to calculation tag in pattern file. + * @param domElement tag in xml tree. + */ +void VDrawTool::AddToCalculation(const QDomElement &domElement) +{ + AddToCalc *addToCal = new AddToCalc(domElement, doc); + connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addToCal); +} diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h new file mode 100644 index 000000000..14044c766 --- /dev/null +++ b/src/app/tools/drawTools/vdrawtool.h @@ -0,0 +1,182 @@ +/************************************************************************ + ** + ** @file vdrawtool.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VDRAWTOOL_H +#define VDRAWTOOL_H + +#include "../vabstracttool.h" +#include +#include +#include +#include "../../dialogs/tools/dialogtool.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" + +/** + * @brief The VDrawTool abstract class for all draw tool. + */ +class VDrawTool : public VAbstractTool +{ + Q_OBJECT +public: + + VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); + virtual ~VDrawTool(); + + /** @brief factor scene scale factor. */ + static qreal factor; + + /** @brief setDialog set dialog when user want change tool option. */ + virtual void setDialog() {} + virtual void DialogLinkDestroy(); + static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data); +public slots: + virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ChangedActivDraw(const QString &newName); + void ChangedNameDraw(const QString &oldName, const QString &newName); + virtual void FullUpdateFromGuiOk(int result); + virtual void FullUpdateFromGuiApply(); + virtual void SetFactor(qreal factor); +protected: + + /** @brief ignoreFullUpdate ignore or not full updates. */ + bool ignoreFullUpdate; + + /** @brief nameActivDraw name of tool's pattern peace. */ + QString nameActivDraw; + + /** @brief dialog dialog options.*/ + DialogTool *dialog; + + void AddToCalculation(const QDomElement &domElement); + + /** @brief SaveDialog save options into file after change in dialog. */ + virtual void SaveDialog(QDomElement &domElement)=0; + void SaveDialogChange(); + virtual void AddToFile(); + virtual void RefreshDataInFile(); + + template + /** + * @brief ContextMenu show context menu for tool. + * @param tool tool. + * @param event context menu event. + * @param showRemove true - tool have option delete. + */ + void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true) + { + SCASSERT(tool != nullptr); + SCASSERT(event != nullptr); + + QMenu menu; + QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + QAction *actionRemove = nullptr; + actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + if (showRemove) + { + if (_referens > 1) + { + actionRemove->setEnabled(false); + } + else + { + actionRemove->setEnabled(true); + } + } + else + { + actionRemove->setEnabled(false); + } + + QAction *selectedAction = menu.exec(event->screenPos()); + if (selectedAction == actionOption) + { + qApp->getSceneView()->itemClicked(nullptr); + dialog = new Dialog(getData(), id, qApp->getMainWindow()); + dialog->setModal(true); + + connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk); + connect(dialog, &DialogTool::DialogApplied, tool, &Tool::FullUpdateFromGuiApply); + if (ignoreFullUpdate == false) + { + connect(doc, &VPattern::FullUpdateFromFile, dialog, &DialogTool::UpdateList); + } + + tool->setDialog(); + + dialog->show(); + } + if (selectedAction == actionRemove) + { + DeleteTool(); + return; //Leave this method immediately after call!!! + } + } + template + /** + * @brief ShowItem highlight tool. + * @param item tool. + * @param id object id in container. + * @param color highlight color. + * @param enable enable or disable highlight. + */ + void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable) + { + SCASSERT(item != nullptr); + if (id == item->id) + { + if (enable == false) + { + currentColor = baseColor; + } + else + { + currentColor = color; + } + item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + } + } + template + void DisableItem(Item *item, bool disable) + { + SCASSERT(item != nullptr); + if (disable) + { + currentColor = Qt::gray; + } + else + { + currentColor = baseColor; + } + item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + } +private: + Q_DISABLE_COPY(VDrawTool) +}; + +#endif // VDRAWTOOL_H diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp new file mode 100644 index 000000000..597618386 --- /dev/null +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -0,0 +1,329 @@ +/************************************************************************ + ** + ** @file vtoolalongline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolalongline.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogalongline.h" +#include "../../geometry/vpointf.h" +#include "../../libs/ifc/exception/vexceptionobjecterror.h" +#include "../../visualization/vistoolalongline.h" + +const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolAlongLine constuctor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with length formula. + * @param firstPointId id first point of line. + * @param secondPointId id second point of line. + * @param typeLine line type. line type. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, + const quint32 &firstPointId, const quint32 &secondPointId, + const QString &typeLine, const Source &typeCreation, + QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId) +{ + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolAlongLine::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + formulaLength = domElement.attribute(AttrLength, ""); + basePointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolAlongLine * visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolAlongLine::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. handle context menu event. + * @param event context menu event. + */ +//cppcheck-suppress unusedFunction +void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu handle context menu event. + * @param event context menu event. + */ +void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolAlongLine::RemoveReferens() +{ + doc->DecrementReferens(secondPointId); + VToolLinePoint::RemoveReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolAlongLine::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogAlongLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); + doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrFirstPoint, basePointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolAlongLine::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolAlongLine::setSecondPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolAlongLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolAlongLine *visual = new VisToolAlongLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolAlongLine * visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolAlongLine::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogAlongLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setFormula(formulaLength); + dialogTool->setFirstPointId(basePointId); + dialogTool->setSecondPointId(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog options. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogAlongLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + QString formula = dialogTool->getFormula(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + VToolAlongLine *point=nullptr; + point = Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. point name. + * @param typeLine line type. + * @param formula string with length formula. + * @param firstPointId id first point of line. + * @param secondPointId id second point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF()); + + line.setLength(qApp->toPixel(CheckFormula(_id, formula, data))); + + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject( new VPointF(line.p2(), pointName, mx, my)); + data->AddLine(firstPointId, id); + data->AddLine(id, secondPointId); + } + else + { + data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); + data->AddLine(firstPointId, id); + data->AddLine(id, secondPointId); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::AlongLine, doc); + if (parse == Document::FullParse) + { + VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, + secondPointId, typeLine, typeCreation); + scene->addItem(point); + connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolAlongLine::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h new file mode 100644 index 000000000..09b44ef31 --- /dev/null +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -0,0 +1,72 @@ +/************************************************************************ + ** + ** @file vtoolalongline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLALONGLINE_H +#define VTOOLALONGLINE_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolAlongLine class tool for creation point along line. + */ +class VToolAlongLine : public VToolLinePoint +{ + Q_OBJECT +public: + + VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &typeLine, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::AlongLine)}; + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief secondPointId id second point of line. */ + quint32 secondPointId; +}; + +#endif // VTOOLALONGLINE_H diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp new file mode 100644 index 000000000..5e245d2e3 --- /dev/null +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -0,0 +1,390 @@ +/************************************************************************ + ** + ** @file vtoolarc.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolarc.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogarc.h" +#include "../../geometry/varc.h" +#include "../container/vformula.h" +#include "../../visualization/vistoolarc.h" + +#include + +const QString VToolArc::TagName = QStringLiteral("arc"); +const QString VToolArc::ToolType = QStringLiteral("simple"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolArc constuctor. + * @param doc dom document container + * @param data container with variables + * @param id object id in container + * @param typeCreation way we create this tool. + * @param parent parent object + */ +VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) + :VAbstractSpline(doc, data, id, parent) +{ + sceneType = SceneObject::Arc; + + this->setPath(ToolPath()); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolArc::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + dialogTool->SetCenter(arc->GetCenter().id()); + dialogTool->SetF1(arc->GetFormulaF1()); + dialogTool->SetF2(arc->GetFormulaF2()); + dialogTool->SetRadius(arc->GetFormulaRadius()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool + * @param dialog dialog options. + * @param scene pointer to scene. + * @param doc dom document container + * @param data container with variables + */ +VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 center = dialogTool->GetCenter(); + QString radius = dialogTool->GetRadius(); + QString f1 = dialogTool->GetF1(); + QString f2 = dialogTool->GetF2(); + VToolArc* point = nullptr; + point=Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param center id arc center point. + * @param radius arc radius. + * @param f1 start angle of arc. + * @param f2 end angle of arc. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) +{ + qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; + + calcRadius = qApp->toPixel(CheckFormula(_id, radius, data)); + + calcF1 = CheckFormula(_id, f1, data); + calcF2 = CheckFormula(_id, f2, data); + + VPointF c = *data->GeometricObject(center); + VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(arc); + data->AddCurveLength(id); + } + else + { + data->UpdateGObject(id, arc); + data->AddCurveLength(id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Arc, doc); + if (parse == Document::FullParse) + { + VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); + scene->addItem(toolArc); + connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArc::Disable); + doc->AddTool(id, toolArc); + doc->IncrementReferens(center); + return toolArc; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolArc::getTagName() const +{ + return VToolArc::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolArc::getCenter() const +{ + QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + SCASSERT(arc.isNull() == false); + + return arc->GetCenter().id(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::setCenter(const quint32 &value) +{ + if (value != NULL_ID) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); + + QSharedPointer point = VAbstractTool::data.GeometricObject(value); + arc->SetCenter(*point.data()); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolArc::getFormulaRadius() const +{ + QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + SCASSERT(arc.isNull() == false); + + VFormula radius(arc->GetFormulaRadius(), getData()); + radius.setCheckZero(true); + radius.setToolId(id); + radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::setFormulaRadius(const VFormula &value) +{ + if (value.error() == false) + { + if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); + arc->SetFormulaRadius(value); + SaveOption(obj); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolArc::getFormulaF1() const +{ + QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + SCASSERT(arc.isNull() == false); + + VFormula f1(arc->GetFormulaF1(), getData()); + f1.setCheckZero(false); + f1.setToolId(id); + f1.setPostfix(degreeSymbol); + return f1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::setFormulaF1(const VFormula &value) +{ + if (value.error() == false) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); + + if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF2() + 1)==false)// Angles can't be equal + { + arc->SetFormulaF1(value); + SaveOption(obj); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolArc::getFormulaF2() const +{ + QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + SCASSERT(arc.isNull() == false); + + VFormula f2(arc->GetFormulaF2(), getData()); + f2.setCheckZero(false); + f2.setToolId(id); + f2.setPostfix(degreeSymbol); + return f2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::setFormulaF2(const VFormula &value) +{ + if (value.error() == false) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); + if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF1() + 1)==false)// Angles can't be equal + { + arc->SetFormulaF2(value); + SaveOption(obj); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolArc * visual = new VisToolArc(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + + visual->setPoint1Id(arc->GetCenter().id()); + visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius())); + visual->setF1(arc->GetFormulaF1()); + visual->setF2(arc->GetFormulaF2()); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolArc *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolArc::RemoveReferens() +{ + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + doc->DecrementReferens(arc->GetCenter().id()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolArc::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); + doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); + doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); + doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer arc = qSharedPointerDynamicCast(obj); + SCASSERT(arc.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrCenter, arc->GetCenter().id()); + doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius()); + doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1()); + doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolArc::RefreshGeometry() +{ + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPath(ToolPath()); + + if (vis != nullptr) + { + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + VisToolArc *visual = qobject_cast(vis); + + visual->setPoint1Id(arc->GetCenter().id()); + visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius())); + visual->setF1(arc->GetFormulaF1()); + visual->setF2(arc->GetFormulaF2()); + visual->RefreshGeometry(); + } +} diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h new file mode 100644 index 000000000..b8264694b --- /dev/null +++ b/src/app/tools/drawTools/vtoolarc.h @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file vtoolarc.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLARC_H +#define VTOOLARC_H + +#include "vabstractspline.h" + +class VFormula; + +/** + * @brief The VToolArc class tool for creation arc. + */ +class VToolArc :public VAbstractSpline +{ + Q_OBJECT +public: + VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static const QString TagName; + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Arc)}; + virtual QString getTagName() const; + + quint32 getCenter() const; + void setCenter(const quint32 &value); + + VFormula getFormulaRadius() const; + void setFormulaRadius(const VFormula &value); + + VFormula getFormulaF1() const; + void setFormulaF1(const VFormula &value); + + VFormula getFormulaF2() const; + void setFormulaF2(const VFormula &value); + + virtual void ShowVisualization(bool show); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + void RefreshGeometry(); +}; + +#endif // VTOOLARC_H diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp new file mode 100644 index 000000000..3a4eefa53 --- /dev/null +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -0,0 +1,395 @@ +/************************************************************************ + ** + ** @file vtoolbisector.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolbisector.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogbisector.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolbisector.h" + +const QString VToolBisector::ToolType = QStringLiteral("bisector"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolBisector constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula length of bisector. + * @param firstPointId id first point of angle. + * @param secondPointId id second point of angle. + * @param thirdPointId id third point of angle. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(NULL_ID), + thirdPointId(NULL_ID) +{ + this->firstPointId = firstPointId; + this->thirdPointId = thirdPointId; + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VToolBisector::BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint) +{ + QLineF line1(secondPoint, firstPoint); + QLineF line2(secondPoint, thirdPoint); + qreal angle = line1.angleTo(line2); + if (angle>180) + { + angle = 360 - angle; + return line1.angle()-angle/2; + } + else + { + return line1.angle()+angle/2; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find bisector point. + * @param firstPoint first point of angle. + * @param secondPoint second point of angle. + * @param thirdPoint third point of angle. + * @param length bisector length. + * @return bisector point. + */ +QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, + const QPointF &thirdPoint, const qreal &length) +{ + QLineF line1(secondPoint, firstPoint); + line1.setAngle(BisectorAngle(firstPoint, secondPoint, thirdPoint)); + line1.setLength(length); + return line1.p2(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolBisector::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogBisector *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setFormula(formulaLength); + dialogTool->setFirstPointId(firstPointId); + dialogTool->setSecondPointId(basePointId); + dialogTool->setThirdPointId(thirdPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogBisector *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + QString formula = dialogTool->getFormula(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const quint32 thirdPointId = dialogTool->getThirdPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + VToolBisector *point = nullptr; + point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula. + * @param firstPointId id first point of angle. + * @param secondPointId id second point of angle. + * @param thirdPointId id third point of angle. + * @param typeLine line type. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer thirdPoint = data->GeometricObject(thirdPointId); + + const qreal result = CheckFormula(_id, formula, data); + + QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), + thirdPoint->toQPointF(), qApp->toPixel(result)); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Bisector, doc); + if (parse == Document::FullParse) + { + VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, + thirdPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + doc->IncrementReferens(thirdPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolBisector::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + formulaLength = domElement.attribute(AttrLength, ""); + firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + basePointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt(); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolBisector *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(basePointId); + visual->setPoint3Id(thirdPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolBisector::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolBisector::RemoveReferens() +{ + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(thirdPointId); + VToolLinePoint::RemoveReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolBisector::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogBisector *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, basePointId); + doc->SetAttribute(tag, AttrThirdPoint, thirdPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolBisector::getThirdPointId() const +{ + return thirdPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::setThirdPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + thirdPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolBisector * visual = new VisToolBisector(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(basePointId); + visual->setPoint3Id(thirdPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolBisector *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolBisector::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::setFirstPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h new file mode 100644 index 000000000..42ac58091 --- /dev/null +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -0,0 +1,83 @@ +/************************************************************************ + ** + ** @file vtoolbisector.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLBISECTOR_H +#define VTOOLBISECTOR_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolBisector class tool for creation bisector point. + */ +class VToolBisector : public VToolLinePoint +{ + Q_OBJECT +public: + + VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + static qreal BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint); + static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, + const qreal& length); + virtual void setDialog(); + static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, + const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Bisector)}; + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getThirdPointId() const; + void setThirdPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief firstPointId id first point of angle. */ + quint32 firstPointId; + + /** @brief thirdPointId id third point of angle. */ + quint32 thirdPointId; +}; + +#endif // VTOOLBISECTOR_H diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp new file mode 100644 index 000000000..ad60c3af9 --- /dev/null +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp @@ -0,0 +1,315 @@ +/************************************************************************ + ** + ** @file vtoolcurveintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 "vtoolcurveintersectaxis.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogcurveintersectaxis.h" +#include "../../dialogs/tools/dialogeditwrongformula.h" +#include "../../geometry/vpointf.h" +#include "./../visualization/vistoolcurveintersectaxis.h" + +const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersectAxis"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, + const QString &typeLine, const QString &formulaAngle, + const quint32 &basePointId, const quint32 &curveId, + const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), + curveId(curveId) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolCurveIntersectAxis::~VToolCurveIntersectAxis() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::setDialog() +{ + SCASSERT(dialog != nullptr); + dialog->setModal(true); + DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setAngle(formulaAngle); + dialogTool->setBasePointId(basePointId); + dialogTool->setCurveId(curveId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); + QString formulaAngle = dialogTool->getAngle(); + const quint32 basePointId = dialogTool->getBasePointId(); + const quint32 curveId = dialogTool->getCurveId(); + + VToolCurveIntersectAxis *point = nullptr; + point=Create(0, pointName, typeLine, formulaAngle, basePointId, curveId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName, + const QString &typeLine, QString &formulaAngle, + const quint32 &basePointId, const quint32 &curveId, + const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer basePoint = data->GeometricObject(basePointId); + qreal angle = CheckFormula(_id, formulaAngle, data); + const QSharedPointer curve = data->GeometricObject(curveId); + + QPointF fPoint = FindPoint(basePoint->toQPointF(), angle, curve); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(basePointId, id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(basePointId, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc); + if (parse == Document::FullParse) + { + VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, formulaAngle, basePointId, + curveId, typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(basePointId); + doc->IncrementReferens(curveId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, + const QSharedPointer &curve) +{ + QLineF axis = VGObject::BuildAxis(point, angle, qApp->getCurrentScene()->sceneRect()); + QVector points = curve->IntersectLine(axis); + + if (points.size() > 0) + { + if (points.size() == 1) + { + return points.at(0); + } + + QMap lengths; + + for ( qint32 i = 0; i < points.size(); ++i ) + { + lengths.insert(QLineF(points.at(i), point).length(), i); + } + + QMap::const_iterator i = lengths.constBegin(); + if (i != lengths.constEnd()) + { + return points.at(i.value()); + } + } + + return QPointF(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolCurveIntersectAxis::getFormulaAngle() const +{ + VFormula fAngle(formulaAngle, getData()); + fAngle.setCheckZero(false); + fAngle.setToolId(id); + fAngle.setPostfix(degreeSymbol); + return fAngle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::setFormulaAngle(const VFormula &value) +{ + if (value.error() == false) + { + formulaAngle = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolCurveIntersectAxis::getCurveId() const +{ + return curveId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::setCurveId(const quint32 &value) +{ + if (value != NULL_ID) + { + curveId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolCurveIntersectAxis * visual = new VisToolCurveIntersectAxis(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(curveId); + visual->setAxisPointId(basePointId); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolCurveIntersectAxis *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); + curveId = domElement.attribute(AttrCurve, "").toUInt(); + formulaAngle = domElement.attribute(AttrAngle, ""); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolCurveIntersectAxis *visual = qobject_cast(vis); + visual->setPoint1Id(curveId); + visual->setAxisPointId(basePointId); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrAngle, formulaAngle); + doc->SetAttribute(tag, AttrBasePoint, basePointId); + doc->SetAttribute(tag, AttrCurve, curveId); +} diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.h b/src/app/tools/drawTools/vtoolcurveintersectaxis.h new file mode 100644 index 000000000..fedd78c8b --- /dev/null +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.h @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file vtoolcurveintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 VTOOLCURVEINTERSECTAXIS_H +#define VTOOLCURVEINTERSECTAXIS_H + +#include "vtoollinepoint.h" + +class VToolCurveIntersectAxis : public VToolLinePoint +{ + Q_OBJECT +public: + VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual ~VToolCurveIntersectAxis(); + virtual void setDialog(); + + static VToolCurveIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + + static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer &curve); + + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::CurveIntersectAxis)}; + + VFormula getFormulaAngle() const; + void setFormulaAngle(const VFormula &value); + + quint32 getCurveId() const; + void setCurveId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolCurveIntersectAxis) + QString formulaAngle; + quint32 curveId; +}; + +#endif // VTOOLCURVEINTERSECTAXIS_H diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp new file mode 100644 index 000000000..ff2365dcd --- /dev/null +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -0,0 +1,150 @@ +/************************************************************************ + ** + ** @file vtoolcut.cpp + ** @author Roman Telezhynskyi + ** @date 25 6, 2014 + ** + ** @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) 2014 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 "vtoolcut.h" +#include "../../geometry/vpointf.h" +#include "../../container/vformula.h" + +//--------------------------------------------------------------------------------------------------------------------- +VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, + const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, + QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr), + curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id) +{ + Q_ASSERT_X(curveCutId > 0, Q_FUNC_INFO, "curveCutId <= 0"); + Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0"); + Q_ASSERT_X(curve2id > 0, Q_FUNC_INFO, "curve2id <= 0"); + + firstCurve = new VSimpleCurve(curve1id, ¤tColor, SimpleCurvePoint::ForthPoint, &factor); + firstCurve->setParentItem(this); + connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); + connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); + + secondCurve = new VSimpleCurve(curve2id, ¤tColor, SimpleCurvePoint::FirstPoint, &factor); + secondCurve->setParentItem(this); + connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); + connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VToolCut::ChangedActivDraw(const QString &newName) +{ + VToolPoint::ChangedActivDraw(newName); + const bool flag = (nameActivDraw == newName); + this->setEnabled(flag); + firstCurve->ChangedActivDraw(flag); + secondCurve->ChangedActivDraw(flag); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction) +{ + VSimpleCurve* simpleCurve = qobject_cast(sender()); + if (simpleCurve) + { + RefreshCurve(simpleCurve, id, curvePosition, direction); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolCut::getCurveCutId() const +{ + return curveCutId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::setCurveCutId(const quint32 &value) +{ + if (value != NULL_ID) + { + curveCutId = value; + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolCut::getFormula() const +{ + VFormula val(formula, getData()); + val.setCheckZero(true); + val.setToolId(id); + val.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); + return val; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::setFormula(const VFormula &value) +{ + if (value.error() == false) + { + formula = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolCut::RefreshGeometry() +{ + RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); + RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement referens value for used objects. + */ +void VToolCut::RemoveReferens() +{ + doc->DecrementReferens(curveCutId); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve) +{ + Q_ASSERT_X(attrCurve.isEmpty() == false, Q_FUNC_INFO, "attribute name is empty"); + + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + formula = domElement.attribute(AttrLength, ""); + curveCutId = domElement.attribute(attrCurve, "").toUInt(); + } + RefreshGeometry(); +} diff --git a/src/app/tools/drawTools/vtoolcut.h b/src/app/tools/drawTools/vtoolcut.h new file mode 100644 index 000000000..f99e82847 --- /dev/null +++ b/src/app/tools/drawTools/vtoolcut.h @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file vtoolcut.h + ** @author Roman Telezhynskyi + ** @date 25 6, 2014 + ** + ** @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) 2014 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 VTOOLCUT_H +#define VTOOLCUT_H + +#include "vtoolpoint.h" +#include "../../visualization/vsimplecurve.h" + +class VFormula; + +class VToolCut : public VToolPoint +{ + Q_OBJECT +public: + VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &curveCutId, + const quint32 &curve1id, const quint32 &curve2id, QGraphicsItem * parent = nullptr); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Cut)}; + + VFormula getFormula() const; + void setFormula(const VFormula &value); + + quint32 getCurveCutId() const; + void setCurveCutId(const quint32 &value); + +public slots: + virtual void ChangedActivDraw(const QString &newName); + virtual void CurveChoosed(quint32 id)=0; + void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); +protected: + /** @brief formula keep formula of length */ + QString formula; + + /** @brief firstCurve first curve after cutting. */ + VSimpleCurve *firstCurve; + + /** @brief secondCurve second curve after cutting. */ + VSimpleCurve *secondCurve; + + quint32 curveCutId; + quint32 curve1id; + quint32 curve2id; + + virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction = PathDirection::Hide)=0; + void RefreshGeometry(); + virtual void RemoveReferens(); + void FullUpdateCurveFromFile(const QString &attrCurve); +private: + Q_DISABLE_COPY(VToolCut) +}; + +#endif // VTOOLCUT_H diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp new file mode 100644 index 000000000..1bdb9d222 --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -0,0 +1,316 @@ +/************************************************************************ + ** + ** @file vtoolcutarc.cpp + ** @author Roman Telezhynskyi + ** @date 7 1, 2014 + ** + ** @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 + ** 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 "vtoolcutarc.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogcutarc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/varc.h" +#include "../../visualization/vistoolcutarc.h" + +const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); +const QString VToolCutArc::AttrArc = QStringLiteral("arc"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutArc constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first arc. + * @param arcId id arc in data container. + * @param arc1id id first cutting arc. + * @param arc2id id second cutting arc. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, + const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, + const Source &typeCreation, QGraphicsItem * parent) + :VToolCut(doc, data, id, formula, arcId, arc1id, arc2id, parent) +{ + RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); + RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolCutArc::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogCutArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + dialogTool->setFormula(formula); + dialogTool->setArcId(curveCutId); + dialogTool->setPointName(point->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogCutArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QString pointName = dialogTool->getPointName(); + QString formula = dialogTool->getFormula(); + const quint32 arcId = dialogTool->getArcId(); + VToolCutArc* point = nullptr; + point=Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first arc. + * @param arcId id arc in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + const QSharedPointer arc = data->GeometricObject(arcId); + + const qreal result = CheckFormula(_id, formula, data); + + VArc arc1; + VArc arc2; + QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2); + + quint32 id = _id; + quint32 arc1id = 0; + quint32 arc2id = 0; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(point, pointName, mx, my)); + arc1id = data->AddGObject(new VArc(arc1)); + arc2id = data->AddGObject(new VArc(arc2)); + + data->AddCurveLength(arc1id, id); + data->AddCurveLength(arc2id, id); + } + else + { + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + arc1id = id + 1; + arc2id = id + 2; + + data->UpdateGObject(arc1id, new VArc(arc1)); + data->UpdateGObject(arc2id, new VArc(arc2)); + + data->AddCurveLength(arc1id, id); + data->AddCurveLength(arc2id, id); + + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + + VDrawTool::AddRecord(id, Tool::CutArc, doc); + if (parse == Document::FullParse) + { + VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->AddTool(arc1id, point); + doc->AddTool(arc2id, point); + doc->IncrementReferens(arcId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutArc::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolCutArc * visual = new VisToolCutArc(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolCutArc *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolCutArc::FullUpdateFromFile() +{ + FullUpdateCurveFromFile(AttrArc); + + if (vis != nullptr) + { + VisToolCutArc *visual = qobject_cast(vis); + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CurveChoosed send signal about selection from cutted arc. + * @param id object id in container. + */ +void VToolCutArc::CurveChoosed(quint32 id) +{ + emit ChoosedTool(id, SceneObject::Arc); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolCutArc::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogCutArc *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshCurve refresh curve on scene. + * @param curve curve. + * @param curveId curve id. + */ +void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction) +{ + const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveId); + QPainterPath path; + path.addPath(arc->GetPath(direction)); + path.setFillRule( Qt::WindingFill ); + if (curvePosition == SimpleCurvePoint::FirstPoint) + { + path.translate(-arc->GetP1().x(), -arc->GetP1().y()); + } + else + { + path.translate(-arc->GetP2().x(), -arc->GetP2().y()); + } + curve->setPath(path); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrArc, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h new file mode 100644 index 000000000..2e852cdca --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vtoolcutarc.h + ** @author Roman Telezhynskyi + ** @date 7 1, 2014 + ** + ** @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 + ** 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 VTOOLCUTARC_H +#define VTOOLCUTARC_H + +#include "vtoolcut.h" + +/** + * @brief The VToolCutArc class tool for cutting arc. + */ +class VToolCutArc : public VToolCut +{ + Q_OBJECT +public: + VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId, + const quint32 &arc1id, const quint32 &arc2id, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + static const QString AttrArc; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::CutArc)}; + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void CurveChoosed(quint32 id); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolCutArc) +}; + +#endif // VTOOLCUTARC_H diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp new file mode 100644 index 000000000..eed9eba7a --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -0,0 +1,327 @@ +/************************************************************************ + ** + ** @file vtoolcutspline.cpp + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 "vtoolcutspline.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogcutspline.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolcutspline.h" +#include "vabstractspline.h" +#include "../../geometry/vspline.h" + +const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); +const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first spline. + * @param splineId id spline in data container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, + const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, + const Source &typeCreation, QGraphicsItem *parent) + :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, parent) +{ + RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); + RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolCutSpline::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogCutSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + dialogTool->setFormula(formula); + dialogTool->setSplineId(curveCutId); + dialogTool->setPointName(point->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogCutSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QString pointName = dialogTool->getPointName(); + QString formula = dialogTool->getFormula(); + const quint32 splineId = dialogTool->getSplineId(); + VToolCutSpline* point = nullptr; + point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first spline. + * @param splineId id spline in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splineId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer spl = data->GeometricObject(splineId); + + const qreal result = CheckFormula(_id, formula, data); + + QPointF spl1p2, spl1p3, spl2p2, spl2p3; + QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); + + quint32 id = _id; + quint32 spl1id = 0; + quint32 spl2id = 0; + if (typeCreation == Source::FromGui) + { + VPointF *p = new VPointF(point, pointName, mx, my); + id = data->AddGObject(p); + + VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); + spl1id = data->AddGObject(spline1); + data->AddCurveLength(spl1id, id); + + VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve()); + spl2id = data->AddGObject(spline2); + data->AddCurveLength(spl2id, id); + } + else + { + VPointF *p = new VPointF(point, pointName, mx, my); + data->UpdateGObject(id, p); + + spl1id = id + 1; + spl2id = id + 2; + + VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); + data->UpdateGObject(spl1id, spline1); + data->AddCurveLength(spl1id, id); + + VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve()); + data->UpdateGObject(spl2id, spline2); + data->AddCurveLength(spl2id, id); + + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::CutSpline, doc); + if (parse == Document::FullParse) + { + VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->AddTool(spl1id, point); + doc->AddTool(spl2id, point); + doc->IncrementReferens(splineId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSpline::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolCutSpline * visual = new VisToolCutSpline(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolCutSpline * visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } + if (VAbstractSpline *parentCurve = qobject_cast(doc->getTool(curveCutId))) + { + parentCurve->ShowFoot(show); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolCutSpline::FullUpdateFromFile() +{ + FullUpdateCurveFromFile(AttrSpline); + + if (vis != nullptr) + { + VisToolCutSpline *visual = qobject_cast(vis); + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CurveChoosed send signal about selection from spline. + * @param id object id in container. + */ +void VToolCutSpline::CurveChoosed(quint32 id) +{ + emit ChoosedTool(id, SceneObject::Spline); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolCutSpline::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogCutSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshCurve refresh curve on scene. + * @param curve curve. + * @param curveId curve id. + */ +void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction) +{ + const QSharedPointer spl = VAbstractTool::data.GeometricObject(curveId); + QPainterPath path; + path.addPath(spl->GetPath(direction)); + path.setFillRule( Qt::WindingFill ); + if (curvePosition == SimpleCurvePoint::FirstPoint) + { + path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y()); + } + else + { + path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y()); + } + curve->setPath(path); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrSpline, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h new file mode 100644 index 000000000..d1b184edc --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vtoolcutspline.h + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 VTOOLCUTSPLINE_H +#define VTOOLCUTSPLINE_H + +#include "vtoolcut.h" + +/** + * @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two. + */ +class VToolCutSpline : public VToolCut +{ + Q_OBJECT +public: + + VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, + const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + static const QString AttrSpline; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::CutSpline)}; + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void CurveChoosed(quint32 id); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolCutSpline) +}; + +#endif // VTOOLCUTSPLINE_H diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp new file mode 100644 index 000000000..92678b185 --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -0,0 +1,378 @@ +/************************************************************************ + ** + ** @file vtoolcutsplinepath.cpp + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 "vtoolcutsplinepath.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogcutsplinepath.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolcutsplinepath.h" +#include "vabstractspline.h" + +#include "../../geometry/vsplinepath.h" + +const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath"); +const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first splinePath. + * @param splinePathId id splinePath (we cut this splinePath) in data container. + * @param splPath1id id first splinePath after cutting. + * @param splPath2id id second splinePath after cutting. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, + const QString &formula, const quint32 &splinePathId, + const quint32 &splPath1id, const quint32 &splPath2id, + const Source &typeCreation, QGraphicsItem *parent) + :VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, parent) +{ + RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); + RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolCutSplinePath::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogCutSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + dialogTool->setFormula(formula); + dialogTool->setSplinePathId(curveCutId); + dialogTool->setPointName(point->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogCutSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QString pointName = dialogTool->getPointName(); + QString formula = dialogTool->getFormula(); + const quint32 splinePathId = dialogTool->getSplinePathId(); + VToolCutSplinePath* point = nullptr; + point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first splinePath. + * @param splinePathId id of splinePath in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splinePathId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer splPath = data->GeometricObject(splinePathId); + SCASSERT(splPath != nullptr); + + const qreal result = CheckFormula(_id, formula, data); + + quint32 id = _id; + QPointF spl1p2, spl1p3, spl2p2, spl2p3; + qint32 p1 = 0, p2 = 0; + + const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); + VPointF *p = new VPointF(point, pointName, mx, my); + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(p); + } + else + { + data->UpdateGObject(id, p); + } + + quint32 splPath1id = id + 1; + quint32 splPath2id = id + 2; + + VSplinePoint splP1 = splPath->at(p1); + VSplinePoint splP2 = splPath->at(p2); + const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve()); + const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + + VSplinePath *splPath1 = new VSplinePath(); + VSplinePath *splPath2 = new VSplinePath(); + + for (qint32 i = 0; i < splPath->CountPoint(); i++) + { + if (i <= p1 && i < p2) + { + if (i == p1) + { + splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(), + spl1.GetAngle1())); + VSplinePoint cutPoint; + cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(), spl1.GetAngle2()+180); + splPath1->append(cutPoint); + continue; + } + splPath1->append(splPath->at(i)); + } + else + { + if (i == p2) + { + const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, + spl2.GetKasm1(), spl2.GetAngle1()); + splPath2->append(cutPoint); + splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(), + spl2.GetAngle2()+180)); + continue; + } + splPath2->append(splPath->at(i)); + } + } + splPath1->setKCurve(splPath->getKCurve()); + splPath2->setKCurve(splPath->getKCurve()); + + splPath1->setMaxCountPoints(splPath->CountPoint()); + splPath2->setMaxCountPoints(splPath->CountPoint()); + + if (typeCreation == Source::FromGui) + { + splPath1id = data->AddGObject(splPath1); + data->AddCurveLength(splPath1id, id); + + splPath2id = data->AddGObject(splPath2); + data->AddCurveLength(splPath2id, id); + } + else + { + data->UpdateGObject(splPath1id, splPath1); + data->AddCurveLength(splPath1id, id); + + data->UpdateGObject(splPath2id, splPath2); + data->AddCurveLength(splPath2id, id); + + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + + VDrawTool::AddRecord(id, Tool::CutSplinePath, doc); + if (parse == Document::FullParse) + { + VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, + splPath2id, typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->AddTool(splPath1id, point); + doc->AddTool(splPath2id, point); + doc->IncrementReferens(splinePathId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSplinePath::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolCutSplinePath *visual = new VisToolCutSplinePath(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolCutSplinePath *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } + if (VAbstractSpline *parentCurve = qobject_cast(doc->getTool(curveCutId))) + { + parentCurve->ShowFoot(show); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolCutSplinePath::FullUpdateFromFile() +{ + FullUpdateCurveFromFile(AttrSplinePath); + + if (vis != nullptr) + { + VisToolCutSplinePath *visual = qobject_cast(vis); + visual->setPoint1Id(curveCutId); + visual->setLength(qApp->FormulaToUser(formula)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CurveChoosed send signal about selection splinePath. + * @param id object id in container. + */ +void VToolCutSplinePath::CurveChoosed(quint32 id) +{ + emit ChoosedTool(id, SceneObject::SplinePath); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolCutSplinePath::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogCutSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshCurve refresh curve on scene. + * @param curve curve. + * @param curveId curve id. + */ +void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction) +{ + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(curveId); + QPainterPath path; + path.addPath(splPath->GetPath(direction)); + path.setFillRule( Qt::WindingFill ); + if (curvePosition == SimpleCurvePoint::FirstPoint) + { + VSpline spl = splPath->GetSpline(1); + path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y()); + } + else + { + VSpline spl = splPath->GetSpline(splPath->Count()); + path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y()); + } + curve->setPath(path); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrSplinePath, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h new file mode 100644 index 000000000..6f5db493c --- /dev/null +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -0,0 +1,71 @@ +/************************************************************************ + ** + ** @file vtoolcutsplinepath.h + ** @author Roman Telezhynskyi + ** @date 15 12, 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 + ** 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 VTOOLCUTSPLINEPATH_H +#define VTOOLCUTSPLINEPATH_H + +#include "vtoolcut.h" + +/** + * @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on + * two. + */ +class VToolCutSplinePath : public VToolCut +{ + Q_OBJECT +public: + + VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, + const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splinePathId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); + static const QString ToolType; + static const QString AttrSplinePath; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::CutSplinePath)}; + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void CurveChoosed(quint32 id); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, + PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolCutSplinePath) +}; + +#endif // VTOOLCUTSPLINEPATH_H diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp new file mode 100644 index 000000000..4a41806f3 --- /dev/null +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -0,0 +1,314 @@ +/************************************************************************ + ** + ** @file vtoolendline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolendline.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogendline.h" +#include "../../dialogs/tools/dialogeditwrongformula.h" +#include "../../geometry/vpointf.h" +#include "./../visualization/vistoolendline.h" + +const QString VToolEndLine::ToolType = QStringLiteral("endLine"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolEndLine constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formulaLength string with formula length of line. + * @param formulaAngle formula angle of line. + * @param basePointId id first point of line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId, + const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, formulaLength, basePointId, 0, parent), formulaAngle(formulaAngle) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolEndLine::~VToolEndLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolEndLine::setDialog() +{ + SCASSERT(dialog != nullptr); + dialog->setModal(true); + DialogEndLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setFormula(formulaLength); + dialogTool->setAngle(formulaAngle); + dialogTool->setBasePointId(basePointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogEndLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); + QString formulaLength = dialogTool->getFormula(); + QString formulaAngle = dialogTool->getAngle(); + const quint32 basePointId = dialogTool->getBasePointId(); + + VToolEndLine *point = nullptr; + point=Create(0, pointName, typeLine, formulaLength, formulaAngle, basePointId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param typeLine line type. + * @param formulaLength string with formula length of line. + * @param formulaAngle formula angle of line. + * @param basePointId id first point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + const QSharedPointer basePoint = data->GeometricObject(basePointId); + QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); + + line.setAngle(CheckFormula(_id, formulaAngle, data)); //First set angle. + line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data))); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(line.p2(), pointName, mx, my)); + data->AddLine(basePointId, id); + } + else + { + data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); + data->AddLine(basePointId, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::EndLine, doc); + if (parse == Document::FullParse) + { + VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formulaLength, formulaAngle, basePointId, + typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(basePointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolEndLine::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + formulaLength = domElement.attribute(AttrLength, ""); + basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); + formulaAngle = domElement.attribute(AttrAngle, ""); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolEndLine *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolEndLine::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogEndLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrAngle, formulaAngle); + doc->SetAttribute(tag, AttrBasePoint, basePointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolEndLine::getFormulaAngle() const +{ + VFormula fAngle(formulaAngle, getData()); + fAngle.setCheckZero(false); + fAngle.setToolId(id); + fAngle.setPostfix(degreeSymbol); + return fAngle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolEndLine::setFormulaAngle(const VFormula &value) +{ + if (value.error() == false) + { + formulaAngle = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolEndLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolEndLine * visual = new VisToolEndLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolEndLine *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h new file mode 100644 index 000000000..b60014931 --- /dev/null +++ b/src/app/tools/drawTools/vtoolendline.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file vtoolendline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLENDLINE_H +#define VTOOLENDLINE_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolEndLine class tool for creation point on the line end. + */ +class VToolEndLine : public VToolLinePoint +{ + Q_OBJECT +public: + + VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual ~VToolEndLine(); + virtual void setDialog(); + static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::EndLine)}; + + VFormula getFormulaAngle() const; + void setFormulaAngle(const VFormula &value); + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + QString formulaAngle; +}; + +#endif // VTOOLENDLINE_H diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp new file mode 100644 index 000000000..25ea2a864 --- /dev/null +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -0,0 +1,340 @@ +/************************************************************************ + ** + ** @file vtoolheight.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolheight.h" +#include "../../dialogs/tools/dialogheight.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolheight.h" + +const QString VToolHeight::ToolType = QStringLiteral("height"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolHeight constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param basePointId id base point of projection. + * @param p1LineId id first point of line. + * @param p2LineId id second point of line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, + const Source &typeCreation, QGraphicsItem * parent) + :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) +{ + ignoreFullUpdate = true; + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolHeight::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogHeight *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setBasePointId(basePointId); + dialogTool->setP1LineId(p1LineId); + dialogTool->setP2LineId(p2LineId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogHeight *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); + const quint32 basePointId = dialogTool->getBasePointId(); + const quint32 p1LineId = dialogTool->getP1LineId(); + const quint32 p2LineId = dialogTool->getP2LineId(); + + VToolHeight *point = nullptr; + point = Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param typeLine line type. + * @param basePointId id base point of projection. + * @param p1LineId id first point of line. + * @param p2LineId id second point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine, + const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + const QSharedPointer basePoint = data->GeometricObject(basePointId); + const QSharedPointer p1Line = data->GeometricObject(p1LineId); + const QSharedPointer p2Line = data->GeometricObject(p2LineId); + + QPointF pHeight = FindPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), basePoint->toQPointF()); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(pHeight, pointName, mx, my)); + data->AddLine(basePointId, id); + data->AddLine(p1LineId, id); + data->AddLine(p2LineId, id); + } + else + { + data->UpdateGObject(id, new VPointF(pHeight, pointName, mx, my)); + data->AddLine(basePointId, id); + data->AddLine(p1LineId, id); + data->AddLine(p2LineId, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Height, doc); + if (parse == Document::FullParse) + { + VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, + typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(basePointId); + doc->IncrementReferens(p1LineId); + doc->IncrementReferens(p2LineId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find projection base point onto line. + * @param line line + * @param point base point. + * @return point onto line. + */ +QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point) +{ + return VGObject::ClosestPoint(line, point); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolHeight::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); + p1LineId = domElement.attribute(AttrP1Line, "").toUInt(); + p2LineId = domElement.attribute(AttrP2Line, "").toUInt(); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolHeight *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setLineP1Id(p1LineId); + visual->setLineP2Id(p2LineId); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolHeight::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogHeight *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrBasePoint, basePointId); + doc->SetAttribute(tag, AttrP1Line, p1LineId); + doc->SetAttribute(tag, AttrP2Line, p2LineId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolHeight::getP2LineId() const +{ + return p2LineId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::setP2LineId(const quint32 &value) +{ + if (value != NULL_ID) + { + p2LineId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolHeight * visual = new VisToolHeight(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setLineP1Id(p1LineId); + visual->setLineP2Id(p2LineId); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolHeight *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolHeight::getP1LineId() const +{ + return p1LineId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::setP1LineId(const quint32 &value) +{ + if (value != NULL_ID) + { + p1LineId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoolheight.h b/src/app/tools/drawTools/vtoolheight.h new file mode 100644 index 000000000..79dcfe08f --- /dev/null +++ b/src/app/tools/drawTools/vtoolheight.h @@ -0,0 +1,78 @@ +/************************************************************************ + ** + ** @file vtoolheight.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLHEIGHT_H +#define VTOOLHEIGHT_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolHeight class tool for creation point of height. Help find point of projection onto line. + */ +class VToolHeight: public VToolLinePoint +{ + Q_OBJECT +public: + + VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId, + const quint32 &p1LineId, const quint32 &p2LineId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolHeight *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine, + const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static QPointF FindPoint(const QLineF &line, const QPointF &point); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Height)}; + + quint32 getP1LineId() const; + void setP1LineId(const quint32 &value); + + quint32 getP2LineId() const; + void setP2LineId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief p1LineId id first point of line. */ + quint32 p1LineId; + + /** @brief p2LineId id second point of line. */ + quint32 p2LineId; +}; + +#endif // VTOOLHEIGHT_H diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp new file mode 100644 index 000000000..ec85c2b29 --- /dev/null +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -0,0 +1,481 @@ +/************************************************************************ + ** + ** @file vtoolline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolline.h" +#include "../../dialogs/tools/dialogline.h" +#include +#include "../../geometry/vpointf.h" +#include "../../dialogs/tools/dialogline.h" +#include "../../visualization/vistoolline.h" + +const QString VToolLine::TagName = QStringLiteral("line"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLine constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param firstPoint id first line point. + * @param secondPoint id second line point. + * @param typeLine line type. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, + const QString &typeLine, const Source &typeCreation, QGraphicsItem *parent) + :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint) +{ + this->typeLine = typeLine; + ignoreFullUpdate = true; + //Line + const QSharedPointer first = data->GeometricObject(firstPoint); + const QSharedPointer second = data->GeometricObject(secondPoint); + this->setLine(QLineF(first->toQPointF(), second->toQPointF())); + this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolLine::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + dialogTool->setFirstPoint(firstPoint); + dialogTool->setSecondPoint(secondPoint); + dialogTool->setTypeLine(typeLine); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 firstPoint = dialogTool->getFirstPoint(); + const quint32 secondPoint = dialogTool->getSecondPoint(); + const QString typeLine = dialogTool->getTypeLine(); + + VToolLine *line = nullptr; + line = Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Source::FromGui); + if (line != nullptr) + { + line->dialog=dialogTool; + } + return line; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param firstPoint id first line point. + * @param secondPoint id second line point. + * @param typeLine line type. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, + const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + SCASSERT(scene != nullptr); + SCASSERT(doc != nullptr); + SCASSERT(data != nullptr); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->getNextId(); + data->AddLine(firstPoint, secondPoint); + } + else + { + data->UpdateId(id); + data->AddLine(firstPoint, secondPoint); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Line, doc); + if (parse == Document::FullParse) + { + VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation); + scene->addItem(line); + connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable); + doc->AddTool(id, line); + doc->IncrementReferens(firstPoint); + doc->IncrementReferens(secondPoint); + return line; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsLineItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLine::getTagName() const +{ + return VToolLine::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolLine::FullUpdateFromFile() +{ + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolLine *visual = qobject_cast(vis); + visual->setPoint1Id(firstPoint); + visual->setPoint2Id(secondPoint); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container + * @param color highlight color. + * @param enable enable or disable highlight. + */ +void VToolLine::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +{ + ShowItem(this, id, color, enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolLine::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::Disable(bool disable) +{ + DisableItem(this, disable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VToolLine::ChangedActivDraw(const QString &newName) +{ + VDrawTool::ChangedActivDraw(newName); + this->setEnabled(nameActivDraw == newName); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VToolLine::AddToFile() +{ + QDomElement domElement = doc->createElement(TagName); + QSharedPointer obj = QSharedPointer (); + SaveOptions(domElement, obj); + AddToCalculation(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VToolLine::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + QSharedPointer obj = QSharedPointer (); + SaveOptions(domElement, obj); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverEnterEvent handle hover enter events. + * @param event hover enter event. + */ +void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle(typeLine))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolLine::RemoveReferens() +{ + doc->DecrementReferens(firstPoint); + doc->DecrementReferens(secondPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (value == true) + { + // do stuff if selected + this->setFocus(); + } + else + { + // do stuff if not selected + } + } + + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key realse events. + * @param event key realse event. + */ +void VToolLine::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + DeleteTool(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsItem::keyReleaseEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolLine::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogLine *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + Q_UNUSED(obj) + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrFirstPoint, firstPoint); + doc->SetAttribute(tag, AttrSecondPoint, secondPoint); + doc->SetAttribute(tag, AttrTypeLine, typeLine); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLine::getSecondPoint() const +{ + return secondPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::setSecondPoint(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPoint = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolLine * visual = new VisToolLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPoint); + visual->setPoint2Id(secondPoint); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolLine *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::setTypeLine(const QString &value) +{ + typeLine = value; + + QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLine::getFirstPoint() const +{ + return firstPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::setFirstPoint(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPoint = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolLine::RefreshGeometry() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + firstPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); + } + const QSharedPointer first = VAbstractTool::data.GeometricObject(firstPoint); + const QSharedPointer second = VAbstractTool::data.GeometricObject(secondPoint); + this->setLine(QLineF(first->toQPointF(), second->toQPointF())); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); +} diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h new file mode 100644 index 000000000..1d852957a --- /dev/null +++ b/src/app/tools/drawTools/vtoolline.h @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file vtoolline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLLINE_H +#define VTOOLLINE_H + +#include "vdrawtool.h" +#include + +/** + * @brief The VToolLine class tool for creation line. + */ +class VToolLine: public VDrawTool, public QGraphicsLineItem +{ + Q_OBJECT +public: + VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, + const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, + const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); + static const QString TagName; + virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Line)}; + virtual QString getTagName() const; + quint32 getFirstPoint() const; + void setFirstPoint(const quint32 &value); + + quint32 getSecondPoint() const; + void setSecondPoint(const quint32 &value); + + virtual void ShowVisualization(bool show); + virtual void setTypeLine(const QString &value); +public slots: + virtual void FullUpdateFromFile(); + virtual void ChangedActivDraw(const QString &newName); + virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void SetFactor(qreal factor); + void Disable(bool disable); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile(); + virtual void RefreshDataInFile(); + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); + virtual void RemoveReferens(); + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void keyReleaseEvent(QKeyEvent * event); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief firstPoint id first line point. */ + quint32 firstPoint; + + /** @brief secondPoint id second line point. */ + quint32 secondPoint; + + void RefreshGeometry(); +}; + +#endif // VTOOLLINE_H diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp new file mode 100644 index 000000000..973836f6a --- /dev/null +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -0,0 +1,399 @@ +/************************************************************************ + ** + ** @file vtoollineintersect.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoollineintersect.h" +#include "../../dialogs/tools/dialoglineintersect.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoollineintersect.h" + +const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLineIntersect constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param p1Line1 id first point first line. + * @param p2Line1 id second point first line. + * @param p1Line2 id first point second line. + * @param p2Line2 id second point second line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, + const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2, + const quint32 &p2Line2, const Source &typeCreation, + QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), + p2Line2(p2Line2) +{ + ignoreFullUpdate = true; + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolLineIntersect::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogLineIntersect *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setP1Line1(p1Line1); + dialogTool->setP2Line1(p2Line1); + dialogTool->setP1Line2(p1Line2); + dialogTool->setP2Line2(p2Line2); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogLineIntersect *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 p1Line1Id = dialogTool->getP1Line1(); + const quint32 p2Line1Id = dialogTool->getP2Line1(); + const quint32 p1Line2Id = dialogTool->getP1Line2(); + const quint32 p2Line2Id = dialogTool->getP2Line2(); + const QString pointName = dialogTool->getPointName(); + VToolLineIntersect* point = nullptr; + point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param p1Line1Id id first point first line. + * @param p2Line1Id id second point first line. + * @param p1Line2Id id first point second line. + * @param p2Line2Id id second point second line. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, + const quint32 &p1Line2Id, const quint32 &p2Line2Id, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer p1Line1 = data->GeometricObject(p1Line1Id); + const QSharedPointer p2Line1 = data->GeometricObject(p2Line1Id); + const QSharedPointer p1Line2 = data->GeometricObject(p1Line2Id); + const QSharedPointer p2Line2 = data->GeometricObject(p2Line2Id); + + QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF()); + QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF()); + QPointF fPoint; + QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(p1Line1Id, id); + data->AddLine(id, p2Line1Id); + data->AddLine(p1Line2Id, id); + data->AddLine(id, p2Line2Id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(p1Line1Id, id); + data->AddLine(id, p2Line1Id); + data->AddLine(p1Line2Id, id); + data->AddLine(id, p2Line2Id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::LineIntersect, doc); + if (parse == Document::FullParse) + { + VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, + p2Line2Id, typeCreation); + scene->addItem(point); + connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(p1Line1Id); + doc->IncrementReferens(p2Line1Id); + doc->IncrementReferens(p1Line2Id); + doc->IncrementReferens(p2Line2Id); + return point; + } + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolLineIntersect::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + p1Line1 = domElement.attribute(AttrP1Line1, "").toUInt(); + p2Line1 = domElement.attribute(AttrP2Line1, "").toUInt(); + p1Line2 = domElement.attribute(AttrP1Line2, "").toUInt(); + p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt(); + } + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolLineIntersect *visual = qobject_cast(vis); + visual->setPoint1Id(p1Line1); + visual->setLine1P2Id(p2Line1); + visual->setLine2P1Id(p1Line2); + visual->setLine2P2Id(p2Line2); + vis->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolLineIntersect::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolLineIntersect::RemoveReferens() +{ + doc->DecrementReferens(p1Line1); + doc->DecrementReferens(p2Line1); + doc->DecrementReferens(p1Line2); + doc->DecrementReferens(p2Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolLineIntersect::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogLineIntersect *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->getP1Line1())); + doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->getP2Line1())); + doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); + doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrP1Line1, p1Line1); + doc->SetAttribute(tag, AttrP2Line1, p2Line1); + doc->SetAttribute(tag, AttrP1Line2, p1Line2); + doc->SetAttribute(tag, AttrP2Line2, p2Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersect::getP2Line2() const +{ + return p2Line2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::setP2Line2(const quint32 &value) +{ + if (value != NULL_ID) + { + p2Line2 = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolLineIntersect * visual = new VisToolLineIntersect(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(p1Line1); + visual->setLine1P2Id(p2Line1); + visual->setLine2P1Id(p1Line2); + visual->setLine2P2Id(p2Line2); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolLineIntersect *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersect::getP1Line2() const +{ + return p1Line2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::setP1Line2(const quint32 &value) +{ + if (value != NULL_ID) + { + p1Line2 = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersect::getP2Line1() const +{ + return p2Line1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::setP2Line1(const quint32 &value) +{ + if (value != NULL_ID) + { + p2Line1 = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersect::getP1Line1() const +{ + return p1Line1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::setP1Line1(const quint32 &value) +{ + if (value != NULL_ID) + { + p1Line1 = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoollineintersect.h b/src/app/tools/drawTools/vtoollineintersect.h new file mode 100644 index 000000000..dd28d16b9 --- /dev/null +++ b/src/app/tools/drawTools/vtoollineintersect.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file vtoollineintersect.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLLINEINTERSECT_H +#define VTOOLLINEINTERSECT_H + +#include "vtoolpoint.h" + +/** + * @brief The VToolLineIntersect class help find point intersection lines. + */ +class VToolLineIntersect:public VToolPoint +{ + Q_OBJECT +public: + VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1, + const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolLineIntersect *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolLineIntersect *Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, + const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::LineIntersect)}; + + quint32 getP1Line1() const; + void setP1Line1(const quint32 &value); + + quint32 getP2Line1() const; + void setP2Line1(const quint32 &value); + + quint32 getP1Line2() const; + void setP1Line2(const quint32 &value); + + quint32 getP2Line2() const; + void setP2Line2(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief p1Line1 id first point first line. */ + quint32 p1Line1; + + /** @brief p2Line1 id second point first line. */ + quint32 p2Line1; + + /** @brief p1Line2 id first point second line. */ + quint32 p1Line2; + + /** @brief p2Line2 id second point second line.*/ + quint32 p2Line2; +}; + +#endif // VTOOLLINEINTERSECT_H diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.cpp b/src/app/tools/drawTools/vtoollineintersectaxis.cpp new file mode 100644 index 000000000..c9f28c18e --- /dev/null +++ b/src/app/tools/drawTools/vtoollineintersectaxis.cpp @@ -0,0 +1,335 @@ +/************************************************************************ + ** + ** @file vtoollineintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 "vtoollineintersectaxis.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialoglineintersectaxis.h" +#include "../../dialogs/tools/dialogeditwrongformula.h" +#include "../../geometry/vpointf.h" +#include "./../visualization/vistoollineintersectaxis.h" + +const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAxis"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, + const QString &typeLine, const QString &formulaAngle, + const quint32 &basePointId, const quint32 &firstPointId, + const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), + firstPointId(firstPointId), secondPointId(secondPointId) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolLineIntersectAxis::~VToolLineIntersectAxis() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::setDialog() +{ + SCASSERT(dialog != nullptr); + dialog->setModal(true); + DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setAngle(formulaAngle); + dialogTool->setBasePointId(basePointId); + dialogTool->setFirstPointId(firstPointId); + dialogTool->setSecondPointId(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); + QString formulaAngle = dialogTool->getAngle(); + const quint32 basePointId = dialogTool->getBasePointId(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + + VToolLineIntersectAxis *point = nullptr; + point=Create(0, pointName, typeLine, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10, scene, doc, + data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName, + const QString &typeLine, QString &formulaAngle, + const quint32 &basePointId, const quint32 &firstPointId, + const quint32 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer basePoint = data->GeometricObject(basePointId); + QLineF axis = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); + axis.setAngle(CheckFormula(_id, formulaAngle, data)); + + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + QLineF line(firstPoint->toQPointF(), secondPoint->toQPointF()); + + QPointF fPoint = FindPoint(axis, line); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(basePointId, id); + data->AddLine(firstPointId, id); + data->AddLine(id, secondPointId); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(basePointId, id); + data->AddLine(firstPointId, id); + data->AddLine(id, secondPointId); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc); + if (parse == Document::FullParse) + { + VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, formulaAngle, + basePointId, firstPointId, secondPointId, + typeCreation); + scene->addItem(point); + connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(basePointId); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line) +{ + QPointF fPoint; + QLineF::IntersectType intersect = axis.intersect(line, &fPoint); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + return fPoint; + } + else + { + return QPointF(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolLineIntersectAxis::getFormulaAngle() const +{ + VFormula fAngle(formulaAngle, getData()); + fAngle.setCheckZero(false); + fAngle.setToolId(id); + fAngle.setPostfix(degreeSymbol); + return fAngle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::setFormulaAngle(const VFormula &value) +{ + if (value.error() == false) + { + formulaAngle = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersectAxis::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::setFirstPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersectAxis::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::setSecondPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolLineIntersectAxis * visual = new VisToolLineIntersectAxis(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->setAxisPointId(basePointId); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolLineIntersectAxis *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); + firstPointId = domElement.attribute(AttrP1Line, "").toUInt(); + secondPointId = domElement.attribute(AttrP2Line, "").toUInt(); + formulaAngle = domElement.attribute(AttrAngle, ""); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolLineIntersectAxis *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->setAxisPointId(basePointId); + visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getSecondPointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrAngle, formulaAngle); + doc->SetAttribute(tag, AttrBasePoint, basePointId); + doc->SetAttribute(tag, AttrP1Line, firstPointId); + doc->SetAttribute(tag, AttrP2Line, secondPointId); +} diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.h b/src/app/tools/drawTools/vtoollineintersectaxis.h new file mode 100644 index 000000000..b7ddb00d7 --- /dev/null +++ b/src/app/tools/drawTools/vtoollineintersectaxis.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file vtoollineintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 VTOOLLINEINTERSECTAXIS_H +#define VTOOLLINEINTERSECTAXIS_H + +#include "vtoollinepoint.h" + +class VToolLineIntersectAxis : public VToolLinePoint +{ + Q_OBJECT +public: + VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId, + const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual ~VToolLineIntersectAxis(); + virtual void setDialog(); + + static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formulaAngle, const quint32 &basePointId, + const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + + static QPointF FindPoint(const QLineF &axis, const QLineF &line); + + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::LineIntersectAxis)}; + + VFormula getFormulaAngle() const; + void setFormulaAngle(const VFormula &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolLineIntersectAxis) + QString formulaAngle; + quint32 firstPointId; + quint32 secondPointId; +}; + +#endif // VTOOLLINEINTERSECTAXIS_H diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp new file mode 100644 index 000000000..67983917c --- /dev/null +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -0,0 +1,163 @@ +/************************************************************************ + ** + ** @file vtoollinepoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoollinepoint.h" +#include "../../geometry/vpointf.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLinePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with length formula. + * @param basePointId id base line point. + * @param angle line angle. + * @param parent parent object. + */ +VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, + const QString &typeLine, const QString &formula, const quint32 &basePointId, + const qreal &angle, QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId), + mainLine(nullptr) +{ + this->typeLine = typeLine; + Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); + QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); + QPointF point2 = data->GeometricObject(id)->toQPointF(); + mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); + mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); + mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolLinePoint::~VToolLinePoint() +{ + delete mainLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VToolLinePoint::ChangedActivDraw(const QString &newName) +{ + VToolPoint::ChangedActivDraw(newName); + this->setEnabled(nameActivDraw == newName); + mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolLinePoint::RefreshGeometry() +{ + mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); + QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); + mainLine->setLine(QLineF(basePoint - point, QPointF())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolLinePoint::RemoveReferens() +{ + doc->DecrementReferens(basePointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolLinePoint::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VToolLinePoint::getAngle() const +{ + return angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLinePoint::setAngle(const qreal &value) +{ + angle = value; + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLinePoint::getBasePointId() const +{ + return basePointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLinePoint::setBasePointId(const quint32 &value) +{ + if (value != NULL_ID) + { + basePointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolLinePoint::getFormulaLength() const +{ + VFormula fLength(formulaLength, this->getData()); + fLength.setCheckZero(true); + fLength.setToolId(id); + fLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); + + return fLength; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLinePoint::setFormulaLength(const VFormula &value) +{ + if (value.error() == false) + { + formulaLength = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/tools/drawTools/vtoollinepoint.h b/src/app/tools/drawTools/vtoollinepoint.h similarity index 53% rename from src/tools/drawTools/vtoollinepoint.h rename to src/app/tools/drawTools/vtoollinepoint.h index 0cfcfb093..3c29e248e 100644 --- a/src/tools/drawTools/vtoollinepoint.h +++ b/src/app/tools/drawTools/vtoollinepoint.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vtoollinepoint.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -30,68 +30,47 @@ #define VTOOLLINEPOINT_H #include "vtoolpoint.h" +#include "../container/vformula.h" /** - * @brief The VToolLinePoint class + * @brief The VToolLinePoint class parent for all tools what create point with line. */ class VToolLinePoint : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolLinePoint - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param basePointId - * @param angle - * @param parent - */ - VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qint64 &basePointId, const qreal &angle, - QGraphicsItem * parent = 0); + VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr); + virtual ~VToolLinePoint(); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::LinePoint)}; + VFormula getFormulaLength() const; + void setFormulaLength(const VFormula &value); + + quint32 getBasePointId() const; + void setBasePointId(const quint32 &value); + + qreal getAngle() const; + void setAngle(const qreal &value); + public slots: - /** - * @brief ChangedActivDraw - * @param newName - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief SetFactor - * @param factor - */ virtual void SetFactor(qreal factor); protected: - /** - * @brief typeLine - */ - QString typeLine; - /** - * @brief formula - */ - QString formula; - /** - * @brief angle - */ + /** @brief formula string with length formula. */ + QString formulaLength; + + /** @brief angle line angle. */ qreal angle; - /** - * @brief basePointId - */ - qint64 basePointId; - /** - * @brief mainLine - */ + + /** @brief basePointId id base line point. */ + quint32 basePointId; + + /** @brief mainLine line item. */ QGraphicsLineItem *mainLine; - /** - * @brief RefreshGeometry - */ + virtual void RefreshGeometry(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens() {doc->DecrementReferens(basePointId);} + virtual void RemoveReferens(); private: Q_DISABLE_COPY(VToolLinePoint) }; diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp new file mode 100644 index 000000000..abf347a7f --- /dev/null +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -0,0 +1,355 @@ +/************************************************************************ + ** + ** @file vtoolnormal.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolnormal.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialognormal.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolnormal.h" + +const QString VToolNormal::ToolType = QStringLiteral("normal"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolNormal constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula normal length. + * @param angle additional angle. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formula, const qreal &angle, const quint32 &firstPointId, + const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), + secondPointId(secondPointId) +{ + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolNormal::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogNormal *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setFormula(formulaLength); + dialogTool->setAngle(angle); + dialogTool->setFirstPointId(basePointId); + dialogTool->setSecondPointId(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogNormal *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + QString formula = dialogTool->getFormula(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + const qreal angle = dialogTool->getAngle(); + VToolNormal *point = nullptr; + point=Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula normal length. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeLine line type. + * @param pointName point name. + * @param angle additional angle. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &typeLine, const QString &pointName, + const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) +{ + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + + const qreal result = CheckFormula(_id, formula, data); + + QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), + qApp->toPixel(result), angle); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Normal, doc); + if (parse == Document::FullParse) + { + VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, + firstPointId, secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint return normal point. + * @param firstPoint first line point. + * @param secondPoint second line point. + * @param length normal length. + * @param angle additional angle. + * @return normal point. + */ +QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, + const qreal &angle) +{ + QLineF line(firstPoint, secondPoint); + QLineF normal = line.normalVector(); + normal.setAngle(normal.angle()+angle); + normal.setLength(length); + return normal.p2(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolNormal::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + formulaLength = domElement.attribute(AttrLength, ""); + basePointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + angle = domElement.attribute(AttrAngle, "").toDouble(); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolNormal *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setAngle(angle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolNormal::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolNormal::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolNormal::RemoveReferens() +{ + doc->DecrementReferens(secondPointId); + VToolLinePoint::RemoveReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolNormal::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogNormal *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrAngle, angle); + doc->SetAttribute(tag, AttrFirstPoint, basePointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolNormal::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolNormal::setSecondPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolNormal::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolNormal * visual = new VisToolNormal(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setAngle(angle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolNormal *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h new file mode 100644 index 000000000..3c85cb439 --- /dev/null +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -0,0 +1,74 @@ +/************************************************************************ + ** + ** @file vtoolnormal.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLNORMAL_H +#define VTOOLNORMAL_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolNormal class tool for creation point on normal. Normal begin from first point of line. + */ +class VToolNormal : public VToolLinePoint +{ + Q_OBJECT +public: + VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &typeLine, const QString &pointName, + const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); + static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, + const qreal &angle = 0); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Normal)}; + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief secondPointId id second line point. */ + quint32 secondPointId; +}; + +#endif // VTOOLNORMAL_H diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp new file mode 100644 index 000000000..53025c402 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -0,0 +1,331 @@ +/************************************************************************ + ** + ** @file vtoolpoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolpoint.h" +#include +#include "../../geometry/vpointf.h" +#include "../../visualization/vgraphicssimpletextitem.h" +#include "../../undocommands/movelabel.h" + +const QString VToolPoint::TagName = QStringLiteral("point"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param parent parent object. + */ +VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) + :VDrawTool(doc, data, id), QGraphicsEllipseItem(parent), radius(DefPointRadius), namePoint(nullptr), + lineName(nullptr) +{ + radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm); + namePoint = new VGraphicsSimpleTextItem(this); + connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu); + connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolPoint::DeleteFromLabel); + namePoint->setBrush(Qt::black); + lineName = new QGraphicsLineItem(this); + lineName->setPen(QPen(Qt::black)); + connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); + this->setBrush(QBrush(Qt::NoBrush)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPoint::~VToolPoint() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsEllipseItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolPoint::name() const +{ + return VAbstractTool::data.GeometricObject(id)->name(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::setName(const QString &name) +{ + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + obj->setName(name); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolPoint::getTagName() const +{ + return VToolPoint::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NameChangePosition handle change posion point label. + * @param pos new position. + */ +void VToolPoint::NameChangePosition(const QPointF &pos) +{ + VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); + QPointF p = pos - this->pos(); + point->setMx(p.x()); + point->setMy(p.y()); + RefreshLine(); + UpdateNamePosition(point->mx(), point->my()); + VAbstractTool::data.UpdateGObject(id, point); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateNamePosition save new position label to the pattern file. + * @param mx label bias x axis. + * @param my label bias y axis. + */ +void VToolPoint::UpdateNamePosition(qreal mx, qreal my) +{ + MoveLabel *moveLabel = new MoveLabel(doc, mx, my, id, this->scene()); + connect(moveLabel, &MoveLabel::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveLabel); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VToolPoint::ChangedActivDraw(const QString &newName) +{ + VDrawTool::ChangedActivDraw(newName); + this->setEnabled(nameActivDraw == newName); + namePoint->setBrush(QBrush(currentColor)); + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container. + * @param color highlight color. + * @param enable enable or disable highlight. + */ +void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +{ + ShowItem(this, id, color, enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolPoint::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + Q_UNUSED(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::Disable(bool disable) +{ + DisableItem(this, disable); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::DeleteFromLabel() +{ + DeleteTool(); //Leave this method immediately after call!!! +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::Point); + } + QGraphicsEllipseItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverEnterEvent handle hover enter events. + * @param event hover enter event. + */ +void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); + QGraphicsEllipseItem::hoverEnterEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshPointGeometry refresh point on scene. + * @param point point. + */ +void VToolPoint::RefreshPointGeometry(const VPointF &point) +{ + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + QRectF rec = QRectF(0, 0, radius*2, radius*2); + rec.translate(-rec.center().x(), -rec.center().y()); + this->setRect(rec); + this->setPos(point.toQPointF()); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + namePoint->blockSignals(true); + QFont font = namePoint->font(); + font.setPointSize(static_cast(namePoint->FontSize()/factor)); + namePoint->setFont(font); + namePoint->setText(point.name()); + namePoint->setPos(QPointF(point.mx(), point.my())); + namePoint->blockSignals(false); + RefreshLine(); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshLine refresh line to label on scene. + */ +void VToolPoint::RefreshLine() +{ + QRectF nRec = namePoint->sceneBoundingRect(); + nRec.translate(- scenePos()); + if (this->rect().intersects(nRec) == false) + { + QRectF nameRec = namePoint->sceneBoundingRect(); + QPointF p1, p2; + VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2); + QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); + lineName->setLine(QLineF(p1, pRec - scenePos())); + if (currentColor == Qt::gray) + { + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + } + else + { + lineName->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); + } + + if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm)) + { + lineName->setVisible(false); + } + else + { + lineName->setVisible(true); + } + } + else + { + lineName->setVisible(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange hadle item change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + if (value == true) + { + // do stuff if selected + this->setFocus(); + } + else + { + // do stuff if not selected + } + } + + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ +void VToolPoint::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + DeleteTool(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsEllipseItem::keyReleaseEvent ( event ); +} diff --git a/src/tools/drawTools/vtoolpoint.h b/src/app/tools/drawTools/vtoolpoint.h similarity index 54% rename from src/tools/drawTools/vtoolpoint.h rename to src/app/tools/drawTools/vtoolpoint.h index e902fce32..218753e31 100644 --- a/src/tools/drawTools/vtoolpoint.h +++ b/src/app/tools/drawTools/vtoolpoint.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vtoolpoint.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -30,99 +30,51 @@ #define VTOOLPOINT_H #include "vdrawtool.h" -#include "../../widgets/vgraphicssimpletextitem.h" +#include + +class VPointF; +class VGraphicsSimpleTextItem; /** - * @brief The VToolPoint class + * @brief The VToolPoint class parent for all tools what create points. */ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem { Q_OBJECT public: - /** - * @brief VToolPoint - * @param doc dom document container - * @param data - * @param id - * @param parent - */ - VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); - virtual ~VToolPoint(){} - /** - * @brief TagName - */ + VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); + virtual ~VToolPoint(); + virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + QString name() const; + void setName(const QString &name); + virtual QString getTagName() const; static const QString TagName; public slots: - /** - * @brief NameChangePosition - * @param pos - */ void NameChangePosition(const QPointF &pos); - /** - * @brief ChangedActivDraw - * @param newName - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result) = 0; - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor - * @param factor - */ + virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); + void Disable(bool disable); + void DeleteFromLabel(); protected: - /** - * @brief radius - */ + /** @brief radius radius circle. */ qreal radius; - /** - * @brief namePoint - */ + + /** @brief namePoint point label. */ VGraphicsSimpleTextItem *namePoint; - /** - * @brief lineName - */ + + /** @brief lineName line what we see if label moved too away from point. */ QGraphicsLineItem *lineName; - /** - * @brief UpdateNamePosition - * @param mx - * @param my - */ + virtual void UpdateNamePosition(qreal mx, qreal my); - /** - * @brief mouseReleaseEvent - * @param event - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RefreshPointGeometry - * @param point - */ virtual void RefreshPointGeometry(const VPointF &point); - /** - * @brief RefreshLine - */ void RefreshLine(); + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void keyReleaseEvent(QKeyEvent * event); private: Q_DISABLE_COPY(VToolPoint) }; diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp new file mode 100644 index 000000000..96e4eabe7 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -0,0 +1,423 @@ +/************************************************************************ + ** + ** @file vtoolpointofcontact.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolpointofcontact.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogpointofcontact.h" +#include "../../geometry/vpointf.h" +#include "../../container/vformula.h" +#include "../../visualization/vistoolpointofcontact.h" +#include + +const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPointOfContact constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param radius string with formula radius arc. + * @param center id center arc point. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, + const QString &radius, const quint32 ¢er, + const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem *parent) + : VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId), + secondPointId(secondPointId) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolPointOfContact::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogPointOfContact *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setRadius(arcRadius); + dialogTool->setCenter(center); + dialogTool->setFirstPoint(firstPointId); + dialogTool->setSecondPoint(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint return point intersection line and arc. + * @param radius string with formula arc radius. + * @param center center arc point. + * @param firstPoint first line point. + * @param secondPoint second line point. + * @return point intersection. + */ +QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, + const QPointF &secondPoint) +{ + QPointF p1, p2; + qint32 res = VGObject::LineIntersectCircle(center, radius, QLineF(firstPoint, secondPoint), p1, p2); + switch (res) + { + case 0: + return QPointF(); + break; + case 1: + return p1; + break; + case 2: + if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length()) + { + return p1; + } + else + { + return p2; + } + break; + default: + qDebug() << "Unxpected value" << res; + return QPointF(); + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogPointOfContact *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + QString radius = dialogTool->getRadius(); + const quint32 center = dialogTool->getCenter(); + const quint32 firstPointId = dialogTool->getFirstPoint(); + const quint32 secondPointId = dialogTool->getSecondPoint(); + const QString pointName = dialogTool->getPointName(); + VToolPointOfContact *point = nullptr; + point=Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param radius string with formula radius arc. + * @param center id center arc point. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er, + const quint32 &firstPointId, const quint32 &secondPointId, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer centerP = data->GeometricObject(center); + const QSharedPointer firstP = data->GeometricObject(firstPointId); + const QSharedPointer secondP = data->GeometricObject(secondPointId); + + const qreal result = CheckFormula(_id, radius, data); + + QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(), + firstP->toQPointF(), secondP->toQPointF()); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + data->AddLine(secondPointId, id); + data->AddLine(center, id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(firstPointId, id); + data->AddLine(secondPointId, id); + data->AddLine(center, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::PointOfContact, doc); + if (parse == Document::FullParse) + { + VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, + firstPointId, secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(center); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolPointOfContact::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + arcRadius = domElement.attribute(AttrRadius, ""); + center = domElement.attribute(AttrCenter, "").toUInt(); + firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + } + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolPointOfContact *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setLineP2Id(secondPointId); + visual->setRadiusId(center); + visual->setRadius(qApp->FormulaToUser(arcRadius)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolPointOfContact::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolPointOfContact::RemoveReferens() +{ + doc->DecrementReferens(center); + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolPointOfContact::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogPointOfContact *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrRadius, arcRadius); + doc->SetAttribute(tag, AttrCenter, center); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfContact::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::setSecondPointId(const quint32 &value) +{ + secondPointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolPointOfContact * visual = new VisToolPointOfContact(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setLineP2Id(secondPointId); + visual->setRadiusId(center); + visual->setRadius(qApp->FormulaToUser(arcRadius)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolPointOfContact *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfContact::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::setFirstPointId(const quint32 &value) +{ + firstPointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfContact::getCenter() const +{ + return center; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::setCenter(const quint32 &value) +{ + if (value != NULL_ID) + { + center = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolPointOfContact::getArcRadius() const +{ + VFormula radius(arcRadius, this->getData()); + radius.setCheckZero(true); + radius.setToolId(id); + radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); + + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::setArcRadius(const VFormula &value) +{ + if (value.error() == false) + { + arcRadius = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h new file mode 100644 index 000000000..1cbc84815 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file vtoolpointofcontact.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLPOINTOFCONTACT_H +#define VTOOLPOINTOFCONTACT_H + +#include "vtoolpoint.h" + +class VFormula; + +/** + * @brief The VToolPointOfContact class tool for creation point intersection line and arc. + */ +class VToolPointOfContact : public VToolPoint +{ + Q_OBJECT +public: + VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, const QString &arcRadius, + const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static QPointF FindPoint(const qreal &arcRadius, const QPointF ¢er, const QPointF &firstPoint, + const QPointF &secondPoint); + static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolPointOfContact* Create(const quint32 _id, QString &arcRadius, const quint32 ¢er, + const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::PointOfContact) }; + + VFormula getArcRadius() const; + void setArcRadius(const VFormula &value); + + quint32 getCenter() const; + void setCenter(const quint32 &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief radius string with formula radius arc. */ + QString arcRadius; + + /** @brief center id center arc point. */ + quint32 center; + + /** @brief firstPointId id first line point. */ + quint32 firstPointId; + + /** @brief secondPointId id second line point. */ + quint32 secondPointId; +}; + +#endif // VTOOLPOINTOFCONTACT_H diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp new file mode 100644 index 000000000..52ef71132 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -0,0 +1,312 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersection.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolpointofintersection.h" +#include "../../dialogs/tools/dialogpointofintersection.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolpointofintersection.h" + +const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPointOfIntersection constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, + const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId) +{ + ignoreFullUpdate = true; + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolPointOfIntersection::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersection *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setFirstPointId(firstPointId); + dialogTool->setSecondPointId(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolPointOfIntersection *VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersection *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString pointName = dialogTool->getPointName(); + VToolPointOfIntersection *point = nullptr; + point = Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, + Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName, + const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) +{ + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + + QPointF point(firstPoint->x(), secondPoint->y()); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(point, pointName, mx, my)); + } + else + { + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::PointOfIntersection, doc); + if (parse == Document::FullParse) + { + VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, + secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolPointOfIntersection::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + } + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolPointOfIntersection *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolPointOfIntersection::RemoveReferens() +{ + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersection *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersection::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::setSecondPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolPointOfIntersection * visual = new VisToolPointOfIntersection(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolPointOfIntersection *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersection::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::setFirstPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoolpointofintersection.h b/src/app/tools/drawTools/vtoolpointofintersection.h new file mode 100644 index 000000000..80e2980de --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofintersection.h @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersection.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLPOINTOFINTERSECTION_H +#define VTOOLPOINTOFINTERSECTION_H + +#include "vtoolpoint.h" + +/** + * @brief The VToolPointOfIntersection class tool for creation point intersection two lines. + */ +class VToolPointOfIntersection : public VToolPoint +{ + Q_OBJECT +public: + VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId, + const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolPointOfIntersection *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId, + const quint32 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::PointOfIntersection) }; + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolPointOfIntersection) + /** @brief firstPointId id first line point. */ + quint32 firstPointId; + + /** @brief secondPointId id second line point. */ + quint32 secondPointId; +}; + +#endif // VTOOLPOINTOFINTERSECTION_H diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp new file mode 100644 index 000000000..33d29bae5 --- /dev/null +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -0,0 +1,399 @@ +/************************************************************************ + ** + ** @file vtoolshoulderpoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolshoulderpoint.h" +#include "../../container/calculator.h" +#include "../../dialogs/tools/dialogshoulderpoint.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistoolshoulderpoint.h" + +const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolShoulderPoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula length. + * @param p1Line id first line point. + * @param p2Line id second line point. + * @param pShoulder id shoulder point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formula, const quint32 &p1Line, const quint32 &p2Line, + const quint32 &pShoulder, const Source &typeCreation, + QGraphicsItem * parent) + :VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolShoulderPoint::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogShoulderPoint *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setTypeLine(typeLine); + dialogTool->setFormula(formulaLength); + dialogTool->setP1Line(basePointId); + dialogTool->setP2Line(p2Line); + dialogTool->setP3(pShoulder); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find point. + * @param p1Line first line point. + * @param p2Line second line point. + * @param pShoulder shoulder point. + * @param length length form shoulder point to our. + * @return point. + */ +//TODO find better way calculate point. +QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, + const qreal &length) +{ + QLineF line = QLineF(p1Line, p2Line); + qreal toolLength = length; + qreal dist = line.length(); + if (dist>toolLength) + { + qDebug()<<"Correction of length in shoulder point tool. Parameter length too small."; + toolLength = dist; + } + if (qFuzzyCompare(dist, toolLength)) + { + return line.p2(); + } + qreal step = 0.01; + while (1) + { + line.setLength(line.length()+step); + QLineF line2 = QLineF(pShoulder, line.p2()); + if (line2.length()>=toolLength) + { + return line.p2(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogShoulderPoint *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool); + QString formula = dialogTool->getFormula(); + const quint32 p1Line = dialogTool->getP1Line(); + const quint32 p2Line = dialogTool->getP2Line(); + const quint32 pShoulder = dialogTool->getP3(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + VToolShoulderPoint * point = nullptr; + point=Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula length. + * @param p1Line id first line point. + * @param p2Line id second line point. + * @param pShoulder id shoulder point. + * @param typeLine line type. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line, + const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const QSharedPointer firstPoint = data->GeometricObject(p1Line); + const QSharedPointer secondPoint = data->GeometricObject(p2Line); + const QSharedPointer shoulderPoint = data->GeometricObject(pShoulder); + + const qreal result = CheckFormula(_id, formula, data); + + QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), + shoulderPoint->toQPointF(), qApp->toPixel(result)); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + data->AddLine(p1Line, id); + data->AddLine(p2Line, id); + } + else + { + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->AddLine(p1Line, id); + data->AddLine(p2Line, id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::ShoulderPoint, doc); + if (parse == Document::FullParse) + { + VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, + p1Line, p2Line, pShoulder, + typeCreation); + scene->addItem(point); + connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(p1Line); + doc->IncrementReferens(p2Line); + doc->IncrementReferens(pShoulder); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolShoulderPoint::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + typeLine = domElement.attribute(AttrTypeLine, ""); + formulaLength = domElement.attribute(AttrLength, ""); + basePointId = domElement.attribute(AttrP1Line, "").toUInt(); + p2Line = domElement.attribute(AttrP2Line, "").toUInt(); + pShoulder = domElement.attribute(AttrPShoulder, "").toUInt(); + } + RefreshGeometry(); + + if (vis != nullptr) + { + VisToolShoulderPoint *visual = qobject_cast(vis); + visual->setPoint1Id(pShoulder); + visual->setLineP1Id(basePointId); + visual->setLineP2Id(p2Line); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolShoulderPoint::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolShoulderPoint::RemoveReferens() +{ + doc->DecrementReferens(p2Line); + doc->DecrementReferens(pShoulder); + VToolLinePoint::RemoveReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolShoulderPoint::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogShoulderPoint *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1Line())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); + doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getP3())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrP1Line, basePointId); + doc->SetAttribute(tag, AttrP2Line, p2Line); + doc->SetAttribute(tag, AttrPShoulder, pShoulder); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolShoulderPoint::getPShoulder() const +{ + return pShoulder; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::setPShoulder(const quint32 &value) +{ + if (value != NULL_ID) + { + pShoulder = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolShoulderPoint * visual = new VisToolShoulderPoint(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(pShoulder); + visual->setLineP1Id(basePointId); + visual->setLineP2Id(p2Line); + visual->setLength(qApp->FormulaToUser(formulaLength)); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolShoulderPoint *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolShoulderPoint::getP2Line() const +{ + return p2Line; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::setP2Line(const quint32 &value) +{ + if (value != NULL_ID) + { + p2Line = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h new file mode 100644 index 000000000..ef8c08df6 --- /dev/null +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -0,0 +1,81 @@ +/************************************************************************ + ** + ** @file vtoolshoulderpoint.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLSHOULDERPOINT_H +#define VTOOLSHOULDERPOINT_H + +#include "vtoollinepoint.h" + +/** + * @brief The VToolShoulderPoint class tool for creation point on shoulder. This tool for special situation, when you + * want find point along line, but have only length from another point (shoulder). + */ +class VToolShoulderPoint : public VToolLinePoint +{ + Q_OBJECT +public: + VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, + const qreal &length); + static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, + const quint32 &pShoulder, const QString &typeLine, const QString &pointName, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::ShoulderPoint) }; + + quint32 getP2Line() const; + void setP2Line(const quint32 &value); + + quint32 getPShoulder() const; + void setPShoulder(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + /** @brief p2Line id second line point. */ + quint32 p2Line; + + /** @brief pShoulder id shoulder line point. */ + quint32 pShoulder; +}; + +#endif // VTOOLSHOULDERPOINT_H diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp new file mode 100644 index 000000000..a90ed60da --- /dev/null +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -0,0 +1,348 @@ +/************************************************************************ + ** + ** @file vtoolsinglepoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolsinglepoint.h" +#include "../../dialogs/tools/dialogsinglepoint.h" +#include "../../visualization/vgraphicssimpletextitem.h" +#include "../../undocommands/movespoint.h" +#include "../../undocommands/addpatternpiece.h" +#include "../../undocommands/deletepatternpiece.h" +#include "../../geometry/vpointf.h" + +#include + +const QString VToolSinglePoint::ToolType = QStringLiteral("single"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolSinglePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + const QString &namePP, const QString &mPath, QGraphicsItem * parent ) + :VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath) +{ + baseColor = Qt::red; + currentColor = baseColor; + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + ignoreFullUpdate = true; + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, false); + setColorLabel(Qt::black); + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolSinglePoint::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogSinglePoint *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setData(p->name(), p->toQPointF()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::ShowVisualization(bool show) +{ + Q_UNUSED(show); //don't have any visualization for base point yet +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VToolSinglePoint::AddToFile() +{ + Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty"); + + QDomElement sPoint = doc->createElement(TagName); + + // Create SPoint tag + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(sPoint, obj); + + //Create pattern piece structure + QDomElement patternPiece = doc->createElement(VPattern::TagDraw); + doc->SetAttribute(patternPiece, AttrName, namePP); + + QDomElement calcElement = doc->createElement(VPattern::TagCalculation); + calcElement.appendChild(sPoint); + + patternPiece.appendChild(calcElement); + patternPiece.appendChild(doc->createElement(VPattern::TagModeling)); + patternPiece.appendChild(doc->createElement(VPattern::TagDetails)); + + AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP, mPath); + connect(addPP, &AddPatternPiece::ClearScene, doc, &VPattern::ClearScene); + connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addPP); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle tool change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionChange && scene()) + { + // value - this is new position. + QPointF newPos = value.toPointF(); + QRectF rect = scene()->sceneRect(); + if (rect.contains(newPos) == false) + { + // Save element into rect of scene. + newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left()))); + newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top()))); + return newPos; + } + } + if (change == ItemPositionHasChanged && scene()) + { + // value - this is new position. + QPointF newPos = value.toPointF(); + + MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene()); + connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSP); + } + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement referens parents objects. + */ +void VToolSinglePoint::decrementReferens() +{ + if (_referens > 1) + { + --_referens; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::DeleteTool(bool ask) +{ + if (_referens <= 1) + { + qApp->getSceneView()->itemClicked(nullptr); + if (ask) + { + if (ConfirmDeletion() == QMessageBox::Cancel) + { + return; + } + } + + DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw); + connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(deletePP); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolSinglePoint::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogSinglePoint *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + QPointF p = dialogTool->getPoint(); + QString name = dialogTool->getName(); + doc->SetAttribute(domElement, AttrName, name); + doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(p.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + VToolPoint::hoverEnterEvent(event); + + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + VToolPoint::hoverLeaveEvent(event); + + //Disable cursor-arrow-openhand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + } + VToolPoint::mousePressEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + //Disable cursor-arrow-closehand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + } + VToolPoint::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setColorLabel change color for label and label line. + * @param color new color. + */ +void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) +{ + namePoint->setBrush(color); + lineName->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrX, qApp->fromPixel(point->x())); + doc->SetAttribute(tag, AttrY, qApp->fromPixel(point->y())); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) +{ +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + + quint32 ref = _referens; // store referens + _referens = 1; // make available delete pattern piece + if (doc->CountPP() > 1) + { + ContextMenu(this, event); + } + else + { + ContextMenu(this, event, false); + } + _referens = ref; // restore referens. If not restore garbage collector delete point!!! +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolSinglePoint::FullUpdateFromFile() +{ + VPointF point = *VAbstractTool::data.GeometricObject(id); + RefreshPointGeometry(point); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ +void VToolSinglePoint::ChangedActivDraw(const QString &newName) +{ + VToolPoint::ChangedActivDraw(newName); + if (nameActivDraw == newName) + { + this->setEnabled(true); + setColorLabel(Qt::black); + } + else + { + this->setEnabled(false); + setColorLabel(Qt::gray); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ +void VToolSinglePoint::SetFactor(qreal factor) +{ + VDrawTool::SetFactor(factor); + RefreshPointGeometry(*(VAbstractTool::data.GeometricObject(id))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + if (doc->CountPP() > 1) + { + ContextMenu(this, event); + } + else + { + ContextMenu(this, event, false); + } +} diff --git a/src/tools/drawTools/vtoolsinglepoint.h b/src/app/tools/drawTools/vtoolsinglepoint.h similarity index 57% rename from src/tools/drawTools/vtoolsinglepoint.h rename to src/app/tools/drawTools/vtoolsinglepoint.h index 8079d2ce7..2e9aa14f1 100644 --- a/src/tools/drawTools/vtoolsinglepoint.h +++ b/src/app/tools/drawTools/vtoolsinglepoint.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vtoolsinglepoint.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -30,84 +30,49 @@ #define VTOOLSINGLEPOINT_H #include "vtoolpoint.h" -#include "../../dialogs/dialogsinglepoint.h" /** - * @brief The VToolSinglePoint class + * @brief The VToolSinglePoint class tool for creation pattern base point. Obly base point can move. All object + * pattern peace depend on base point. */ class VToolSinglePoint : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolSinglePoint - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0 ); - /** - * @brief setDialog - */ + VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr ); virtual void setDialog(); - /** - * @brief ToolType - */ static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::SinglePoint)}; + virtual void ShowVisualization(bool show); public slots: - /** - * @brief FullUpdateFromFile - */ virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief ChangedActivDraw - * @param newName - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief SetFactor - * @param factor - */ virtual void SetFactor(qreal factor); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); signals: /** - * @brief FullUpdateTree + * @brief FullUpdateTree handle if need update pattern file. */ - void FullUpdateTree(); + void LiteUpdateTree(); protected: - /** - * @brief contextMenuEvent - * @param event - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ virtual void AddToFile(); - /** - * @brief itemChange - * @param change - * @param value - * @return - */ QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief decrementReferens - */ virtual void decrementReferens(); + virtual void DeleteTool(bool ask = true); + virtual void SaveDialog(QDomElement &domElement); + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: - /** - * @brief dialogSinglePoint - */ - QSharedPointer dialogSinglePoint; + QString namePP; + QString mPath; + void setColorLabel(const Qt::GlobalColor & color); + }; #endif // VTOOLSINGLEPOINT_H diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp new file mode 100644 index 000000000..96eddc313 --- /dev/null +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -0,0 +1,398 @@ +/************************************************************************ + ** + ** @file vtoolspline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolspline.h" +#include "../../geometry/vspline.h" +#include "../../dialogs/tools/dialogspline.h" +#include "../../undocommands/movespline.h" +#include "../../visualization/vistoolspline.h" + +const QString VToolSpline::ToolType = QStringLiteral("simple"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem *parent) + :VAbstractSpline(doc, data, id, parent) +{ + sceneType = SceneObject::Spline; + + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + this->setPath(ToolPath()); + + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(), + spl->GetP1().toQPointF(), this); + connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this, + &VToolSpline::ControlPointChangePosition); + connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine); + connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint); + controlPoints.append(controlPoint1); + + VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(), + spl->GetP4().toQPointF(), this); + connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this, + &VToolSpline::ControlPointChangePosition); + connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine); + connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint); + controlPoints.append(controlPoint2); + + ShowFoot(false); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSpline::~VToolSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolSpline::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + dialogTool->setP1(spl->GetP1().id()); + dialogTool->setP4(spl->GetP4().id()); + dialogTool->setAngle1(spl->GetAngle1()); + dialogTool->setAngle2(spl->GetAngle2()); + dialogTool->setKAsm1(spl->GetKasm1()); + dialogTool->setKAsm2(spl->GetKasm2()); + dialogTool->setKCurve(spl->GetKcurve()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 p1 = dialogTool->getP1(); + const quint32 p4 = dialogTool->getP4(); + const qreal kAsm1 = dialogTool->getKAsm1(); + const qreal kAsm2 = dialogTool->getKAsm2(); + const qreal angle1 = dialogTool->getAngle1(); + const qreal angle2 = dialogTool->getAngle2(); + const qreal kCurve = dialogTool->getKCurve(); + VToolSpline *spl = nullptr; + spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, + Source::FromGui); + if (spl != nullptr) + { + spl->dialog=dialogTool; + } + return spl; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param p1 id first spline point. + * @param p4 id last spline point. + * @param kAsm1 coefficient of length first control line. + * @param kAsm2 coefficient of length second control line. + * @param angle1 angle from first point to first control point. + * @param angle2 angle from second point to second control point. + * @param kCurve coefficient of curvature spline. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, + const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + VPointF point1 = *data->GeometricObject(p1); + VPointF point4 = *data->GeometricObject(p4); + VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(spline); + data->AddCurveLength(id); + } + else + { + data->UpdateGObject(id, spline); + data->AddCurveLength(id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Spline, doc); + if (parse == Document::FullParse) + { + VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); + scene->addItem(spl); + connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable); + doc->AddTool(id, spl); + doc->IncrementReferens(p1); + doc->IncrementReferens(p4); + return spl; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +VSpline VToolSpline::getSpline() const +{ + QSharedPointer spline = VAbstractTool::data.GeometricObject(id); + return *spline.data(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSpline::setSpline(const VSpline &spl) +{ + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer spline = qSharedPointerDynamicCast(obj); + *spline.data() = spl; + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSpline::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolSpline *visual = new VisToolSpline(getData(), this); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + visual->setPoint1Id(spl->GetP1().id()); + visual->setPoint4Id(spl->GetP4().id()); + visual->setAngle1(spl->GetAngle1()); + visual->setAngle2(spl->GetAngle2()); + visual->setKAsm1(spl->GetKasm1()); + visual->setKAsm2(spl->GetKasm2()); + visual->setKCurve(spl->GetKcurve()); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolSpline *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } + ShowFoot(show); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ControlPointChangePosition handle change position control point. + * @param indexSpline position spline in spline list. + * @param position position point in spline. + * @param pos new position. + */ +void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos) +{ + Q_UNUSED(indexSpline); + const QSharedPointer spline = VAbstractTool::data.GeometricObject(id); + VSpline spl; + if (position == SplinePointPosition::FirstPoint) + { + spl = VSpline(spline->GetP1(), pos, spline->GetP3(), spline->GetP4(), spline->GetKcurve()); + } + else + { + spl = VSpline(spline->GetP1(), spline->GetP2(), pos, spline->GetP4(), spline->GetKcurve()); + } + + MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene()); + connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSpl); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolSpline::RemoveReferens() +{ + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + doc->DecrementReferens(spl->GetP1().id()); + doc->DecrementReferens(spl->GetP4().id()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolSpline::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogSpline *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + + VPointF point1 = *VAbstractTool::data.GeometricObject(dialogTool->getP1()); + VPointF point4 = *VAbstractTool::data.GeometricObject(dialogTool->getP4()); + VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(), + dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve()); + + controlPoints[0]->blockSignals(true); + controlPoints[1]->blockSignals(true); + + controlPoints[0]->setPos(spl.GetP2()); + controlPoints[1]->setPos(spl.GetP3()); + + controlPoints[0]->blockSignals(false); + controlPoints[1]->blockSignals(false); + + spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve()); + + doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); + doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); + doc->SetAttribute(domElement, AttrAngle1, spl.GetAngle1()); + doc->SetAttribute(domElement, AttrAngle2, spl.GetAngle2()); + doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); + doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); + doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer spl = qSharedPointerDynamicCast(obj); + SCASSERT(spl.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrPoint1, spl->GetP1().id()); + doc->SetAttribute(tag, AttrPoint4, spl->GetP4().id()); + doc->SetAttribute(tag, AttrAngle1, spl->GetAngle1()); + doc->SetAttribute(tag, AttrAngle2, spl->GetAngle2()); + doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1()); + doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2()); + doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolSpline::RefreshGeometry() +{ + //this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + if (isHovered) + { + this->setPath(ToolPath(PathDirection::Show)); + } + else + { + this->setPath(ToolPath()); + } + + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + QPointF splinePoint = VAbstractTool::data.GeometricObject(spl->GetP1().id())->toQPointF(); + QPointF controlPoint = spl->GetP2(); + emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint); + splinePoint = VAbstractTool::data.GeometricObject(spl->GetP4().id())->toQPointF(); + controlPoint = spl->GetP3(); + emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint); + + controlPoints[0]->blockSignals(true); + controlPoints[1]->blockSignals(true); + + controlPoints[0]->setPos(spl->GetP2()); + controlPoints[1]->setPos(spl->GetP3()); + + controlPoints[0]->blockSignals(false); + controlPoints[1]->blockSignals(false); + + if (vis != nullptr) + { + VisToolSpline *visual = qobject_cast(vis); + visual->setPoint1Id(spl->GetP1().id()); + visual->setPoint4Id(spl->GetP4().id()); + visual->setAngle1(spl->GetAngle1()); + visual->setAngle2(spl->GetAngle2()); + visual->setKAsm1(spl->GetKasm1()); + visual->setKAsm2(spl->GetKasm2()); + visual->setKCurve(spl->GetKcurve()); + visual->RefreshGeometry(); + } +} diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h new file mode 100644 index 000000000..214b14687 --- /dev/null +++ b/src/app/tools/drawTools/vtoolspline.h @@ -0,0 +1,71 @@ +/************************************************************************ + ** + ** @file vtoolspline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLSPLINE_H +#define VTOOLSPLINE_H + +#include "vabstractspline.h" + +/** + * @brief The VToolSpline class tool for creation spline. I mean bezier curve. + */ +class VToolSpline:public VAbstractSpline +{ + Q_OBJECT +public: + VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem * parent = nullptr ); + virtual ~VToolSpline(); + virtual void setDialog(); + static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, + const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Spline)}; + + VSpline getSpline()const; + void setSpline(const VSpline &spl); + + virtual void ShowVisualization(bool show); +public slots: + void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolSpline) + void RefreshGeometry (); +}; + +#endif // VTOOLSPLINE_H diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp new file mode 100644 index 000000000..3a53d0193 --- /dev/null +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -0,0 +1,459 @@ +/************************************************************************ + ** + ** @file vtoolsplinepath.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolsplinepath.h" +#include "../../dialogs/tools/dialogsplinepath.h" +#include "../../undocommands/movesplinepath.h" +#include "../../visualization/vistoolsplinepath.h" + +const QString VToolSplinePath::ToolType = QStringLiteral("path"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem *parent) + :VAbstractSpline(doc, data, id, parent) +{ + sceneType = SceneObject::SplinePath; + + this->setPath(ToolPath()); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + + const QSharedPointer splPath = data->GeometricObject(id); + for (qint32 i = 1; i<=splPath->Count(); ++i) + { + VSpline spl = splPath->GetSpline(i); + VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(), + spl.GetP1().toQPointF(), this); + connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, + &VToolSplinePath::ControlPointChangePosition); + connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); + connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); + controlPoints.append(controlPoint); + + controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(), + this); + connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, + &VToolSplinePath::ControlPointChangePosition); + connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); + connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); + controlPoints.append(controlPoint); + } + + ShowFoot(false); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolSplinePath::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); + dialogTool->SetPath(*splPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VSplinePath *path = new VSplinePath(dialogTool->GetPath()); + for (qint32 i = 0; i < path->CountPoint(); ++i) + { + doc->IncrementReferens((*path)[i].P().id()); + } + VToolSplinePath* spl = nullptr; + spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui); + if (spl != nullptr) + { + spl->dialog=dialogTool; + } + return spl; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param path spline path. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(path); + data->AddCurveLength(id); + } + else + { + data->UpdateGObject(id, path); + data->AddCurveLength(id); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::SplinePath, doc); + if (parse == Document::FullParse) + { + VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation); + scene->addItem(spl); + connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable); + doc->AddTool(id, spl); + return spl; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ControlPointChangePosition handle change position control point. + * @param indexSpline position spline in spline list. + * @param position position point in spline. + * @param pos new position. + */ +void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos) +{ + VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject(id); + VSplinePath newSplPath = oldSplPath; + VSpline spl = newSplPath.GetSpline(indexSpline); + if (position == SplinePointPosition::FirstPoint) + { + spl = VSpline(spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); + } + else + { + spl = VSpline(spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); + } + + UpdateControlPoints(spl, newSplPath, indexSpline); + + MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id, this->scene()); + connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSplPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateControlPoints update position points control points in file. + * @param spl spline what was changed. + * @param splPath spline path. + * @param indexSpline index spline in spline path. + */ +void VToolSplinePath::UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const +{ + VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::FirstPoint); + p.SetAngle2(spl.GetAngle1()); + p.SetKAsm2(spl.GetKasm1()); + splPath.UpdatePoint(indexSpline, SplinePointPosition::FirstPoint, p); + + p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::LastPoint); + p.SetAngle2(spl.GetAngle2()-180); + p.SetKAsm1(spl.GetKasm2()); + splPath.UpdatePoint(indexSpline, SplinePointPosition::LastPoint, p); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath) +{ + for (qint32 i = 1; i<=splPath.Count(); ++i) + { + VSpline spl = splPath.GetSpline(i); + qint32 j = i*2; + + controlPoints[j-2]->blockSignals(true); + controlPoints[j-1]->blockSignals(true); + + controlPoints[j-2]->setPos(spl.GetP2()); + controlPoints[j-1]->setPos(spl.GetP3()); + + controlPoints[j-2]->blockSignals(false); + controlPoints[j-1]->blockSignals(false); + + spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(), + splPath.getKCurve()); + UpdateControlPoints(spl, splPath, i); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdatePathPoint update spline path in pattern file. + * @param doc dom document container. + * @param node tag in file. + * @param path spline path. + */ +void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path) +{ + SCASSERT(doc != nullptr) + QDomNodeList nodeList = node.childNodes(); + qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + QDomElement domElement = nodeList.at(i).toElement(); + if (domElement.isNull() == false) + { + VSplinePoint p = path.at(i); + doc->SetAttribute(domElement, AttrPSpline, p.P().id()); + doc->SetAttribute(domElement, AttrKAsm1, p.KAsm1()); + doc->SetAttribute(domElement, AttrKAsm2, p.KAsm2()); + doc->SetAttribute(domElement, AttrAngle, p.Angle2()); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath VToolSplinePath::getSplinePath() const +{ + QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); + return *splPath.data(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::setSplinePath(const VSplinePath &splPath) +{ + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer splinePath = qSharedPointerDynamicCast(obj); + *splinePath.data() = splPath; + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolSplinePath *visual = new VisToolSplinePath(getData(), this); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + + QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); + visual->setPath(*splPath.data()); + visual->setMode(Mode::Show); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolSplinePath *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } + ShowFoot(show); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VToolSplinePath::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement() == false) + { + qDebug()<<"Can't find element with id="<(id); + RefreshSplinePath(splPath); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + UpdatePathPoint(doc, domElement, splPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddPathPoint write path point to pattern file. + * @param domElement dom element. + * @param splPoint spline path point. + */ +void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint) +{ + QDomElement pathPoint = doc->createElement(AttrPathPoint); + + doc->SetAttribute(pathPoint, AttrPSpline, splPoint.P().id()); + doc->SetAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); + doc->SetAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); + doc->SetAttribute(pathPoint, AttrAngle, splPoint.Angle2()); + + domElement.appendChild(pathPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolSplinePath::RemoveReferens() +{ + VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); + for (qint32 i = 0; i < splPath.Count(); ++i) + { + doc->DecrementReferens(splPath.at(i).P().id()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolSplinePath::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogSplinePath *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + + VSplinePath splPath = dialogTool->GetPath(); + RefreshSplinePath(splPath); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + UpdatePathPoint(doc, domElement, splPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer splPath = qSharedPointerDynamicCast(obj); + SCASSERT(splPath.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrKCurve, splPath->getKCurve()); + + doc->RemoveAllChild(tag); + for (qint32 i = 0; i < splPath->CountPoint(); ++i) + { + AddPathPoint(tag, splPath->at(i)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VToolSplinePath::RefreshGeometry() +{ + if (isHovered) + { + this->setPath(ToolPath(PathDirection::Show)); + } + else + { + this->setPath(ToolPath()); + } + + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); + for (qint32 i = 1; i<=splPath->Count(); ++i) + { + VSpline spl = splPath->GetSpline(i); + QPointF splinePoint = spl.GetP1().toQPointF(); + QPointF controlPoint = spl.GetP2(); + emit RefreshLine(i, SplinePointPosition::FirstPoint, controlPoint, splinePoint); + splinePoint = spl.GetP4().toQPointF(); + controlPoint = spl.GetP3(); + emit RefreshLine(i, SplinePointPosition::LastPoint, controlPoint, splinePoint); + + qint32 j = i*2; + + controlPoints[j-2]->blockSignals(true); + controlPoints[j-1]->blockSignals(true); + + controlPoints[j-2]->setPos(spl.GetP2()); + controlPoints[j-1]->setPos(spl.GetP3()); + + controlPoints[j-2]->blockSignals(false); + controlPoints[j-1]->blockSignals(false); + } + + if (vis != nullptr) + { + VisToolSplinePath *visual = qobject_cast(vis); + QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); + visual->setPath(*splPath.data()); + visual->setMode(Mode::Show); + visual->RefreshGeometry(); + } +} diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h new file mode 100644 index 000000000..3943a4626 --- /dev/null +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -0,0 +1,88 @@ +/************************************************************************ + ** + ** @file vtoolsplinepath.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLSPLINEPATH_H +#define VTOOLSPLINEPATH_H + +#include "vabstractspline.h" + +/** + * @brief The VToolSplinePath class tool for creation spline path. + */ +class VToolSplinePath:public VAbstractSpline +{ + Q_OBJECT +public: + VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static const QString ToolType; + static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::SplinePath)}; + + VSplinePath getSplinePath()const; + void setSplinePath(const VSplinePath &splPath); + + virtual void ShowVisualization(bool show); +signals: + /** + * @brief RefreshLine refresh control line. + * @param indexSpline position spline in spline list. + * @param pos position point in spline. + * @param controlPoint new position control point. + * @param splinePoint new position spline point. + */ + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, + const QPointF &splinePoint); + /** + * @brief setEnabledPoint disable control points. + * @param enable enable or diasable points. + */ + void setEnabledPoint(bool enable); +public slots: + + void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RefreshDataInFile(); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + void RefreshGeometry(); + void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); + void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const; + void RefreshSplinePath(VSplinePath &splPath); +}; + +#endif // VTOOLSPLINEPATH_H diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp new file mode 100644 index 000000000..6afce72ce --- /dev/null +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -0,0 +1,415 @@ +/************************************************************************ + ** + ** @file vtooltriangle.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtooltriangle.h" +#include "../../dialogs/tools/dialogtriangle.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vistooltriangle.h" +#include + +const QString VToolTriangle::ToolType = QStringLiteral("triangle"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolTriangle constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param axisP1Id id first axis point. + * @param axisP2Id id second axis point. + * @param firstPointId id first triangle point, what lies on the hypotenuse. + * @param secondPointId id second triangle point, what lies on the hypotenuse. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, + const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), + secondPointId(secondPointId) +{ + ignoreFullUpdate = true; + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolTriangle::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogTriangle *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->setAxisP1Id(axisP1Id); + dialogTool->setAxisP2Id(axisP2Id); + dialogTool->setFirstPointId(firstPointId); + dialogTool->setSecondPointId(secondPointId); + dialogTool->setPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @return the created tool + */ +VToolTriangle* VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogTriangle *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 axisP1Id = dialogTool->getAxisP1Id(); + const quint32 axisP2Id = dialogTool->getAxisP2Id(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString pointName = dialogTool->getPointName(); + VToolTriangle* point = nullptr; + point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param axisP1Id id first axis point. + * @param axisP2Id id second axis point. + * @param firstPointId id first triangle point, what lies on the hypotenuse. + * @param secondPointId id second triangle point, what lies on the hypotenuse. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ +VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, + const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + const QSharedPointer axisP1 = data->GeometricObject(axisP1Id); + const QSharedPointer axisP2 = data->GeometricObject(axisP2Id); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + + QPointF point = FindPoint(axisP1->toQPointF(), axisP2->toQPointF(), firstPoint->toQPointF(), + secondPoint->toQPointF()); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(point, pointName, mx, my)); + } + else + { + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Triangle, doc); + if (parse == Document::FullParse) + { + VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, + secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + doc->AddTool(id, point); + doc->IncrementReferens(axisP1Id); + doc->IncrementReferens(axisP2Id); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find point intersection two foots right triangle. + * @param axisP1 first axis point. + * @param axisP2 second axis point. + * @param firstPoint first triangle point, what lies on the hypotenuse. + * @param secondPoint second triangle point, what lies on the hypotenuse. + * @return point intersection two foots right triangle. + */ +QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, + const QPointF &secondPoint) +{ + QLineF axis(axisP1, axisP2); + QLineF hypotenuse(firstPoint, secondPoint); + + QPointF startPoint; + QLineF::IntersectType intersect = axis.intersect(hypotenuse, &startPoint); + if (intersect != QLineF::UnboundedIntersection && intersect != QLineF::BoundedIntersection) + { + return QPointF(); + } + + qreal step = 1; + + QLineF line; + line.setP1(startPoint); + line.setAngle(axis.angle()); + line.setLength(step); + + int c = qFloor(hypotenuse.length()); + while (1) + { + line.setLength(line.length()+step); + int a = qFloor(QLineF(line.p2(), firstPoint).length()); + int b = qFloor(QLineF(line.p2(), secondPoint).length()); + if (c*c <= (a*a + b*b)) + { + return line.p2(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolTriangle::FullUpdateFromFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + axisP1Id = domElement.attribute(AttrAxisP1, "").toUInt(); + axisP2Id = domElement.attribute(AttrAxisP2, "").toUInt(); + firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); + secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); + } + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolTriangle * visual = qobject_cast(vis); + visual->setPoint1Id(axisP1Id); + visual->setPoint2Id(axisP2Id); + visual->setHypotenuseP1Id(firstPointId); + visual->setHypotenuseP2Id(secondPointId); + visual->RefreshGeometry(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ +void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolTriangle::RemoveReferens() +{ + doc->DecrementReferens(axisP1Id); + doc->DecrementReferens(axisP2Id); + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ +void VToolTriangle::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogTriangle *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->getAxisP1Id())); + doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->getAxisP2Id())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrAxisP1, axisP1Id); + doc->SetAttribute(tag, AttrAxisP2, axisP2Id); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolTriangle::getSecondPointId() const +{ + return secondPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::setSecondPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolTriangle * visual = new VisToolTriangle(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(axisP1Id); + visual->setPoint2Id(axisP2Id); + visual->setHypotenuseP1Id(firstPointId); + visual->setHypotenuseP2Id(secondPointId); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolTriangle * visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolTriangle::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::setFirstPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolTriangle::getAxisP2Id() const +{ + return axisP2Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::setAxisP2Id(const quint32 &value) +{ + if (value != NULL_ID) + { + axisP2Id = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolTriangle::getAxisP1Id() const +{ + return axisP1Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::setAxisP1Id(const quint32 &value) +{ + if (value != NULL_ID) + { + axisP1Id = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtooltriangle.h b/src/app/tools/drawTools/vtooltriangle.h new file mode 100644 index 000000000..5ae0743dc --- /dev/null +++ b/src/app/tools/drawTools/vtooltriangle.h @@ -0,0 +1,93 @@ +/************************************************************************ + ** + ** @file vtooltriangle.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLTRIANGLE_H +#define VTOOLTRIANGLE_H + +#include "vtoolpoint.h" + +/** + * @brief The VToolTriangle class for tool that find point intersection two foots right triangle + * (triangle with 90 degree). + */ +class VToolTriangle : public VToolPoint +{ + Q_OBJECT +public: + VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, const quint32 &axisP2Id, + const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolTriangle *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolTriangle *Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, + const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, + const QPointF &secondPoint); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Triangle)}; + + quint32 getAxisP1Id() const; + void setAxisP1Id(const quint32 &value); + + quint32 getAxisP2Id() const; + void setAxisP2Id(const quint32 &value); + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getSecondPointId() const; + void setSecondPointId(const quint32 &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); + virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolTriangle) + /** @brief axisP1Id id first axis point. */ + quint32 axisP1Id; + + /** @brief axisP2Id id second axis point. */ + quint32 axisP2Id; + + /** @brief firstPointId id first triangle point, what lies on the hypotenuse. */ + quint32 firstPointId; + + /** @brief secondPointId id second triangle point, what lies on the hypotenuse. */ + quint32 secondPointId; +}; + +#endif // VTOOLTRIANGLE_H diff --git a/src/tools/nodeDetails/nodedetails.h b/src/app/tools/nodeDetails/nodedetails.h similarity index 96% rename from src/tools/nodeDetails/nodedetails.h rename to src/app/tools/nodeDetails/nodedetails.h index d230f7456..fbdf2b2ba 100644 --- a/src/tools/nodeDetails/nodedetails.h +++ b/src/app/tools/nodeDetails/nodedetails.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file nodedetails.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp new file mode 100644 index 000000000..13ea1b71b --- /dev/null +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -0,0 +1,145 @@ +/************************************************************************ + ** + ** @file vabstractnode.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vabstractnode.h" +#include +#include "../../xml/vpattern.h" +#include "../../undocommands/adddetnode.h" +#include "../../core/vapplication.h" + +const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); +const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VAbstractNode constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idNode object id in containerNode. + * @param idTool id tool. + * @param parent parent object. + */ +VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, + const quint32 &idTool, QObject *parent) + : VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool) +{ + _referens = 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::DeleteNode() +{ + if (_referens <= 1) + { + RemoveReferens();//deincrement referens + } +} + +void VAbstractNode::RestoreNode() +{ + if (_referens <= 1) + { + RestoreReferens(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::ShowVisualization(bool show) +{ + Q_UNUSED(show) +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToModeling add tag to modeling tag current pattern peace. + * @param domElement tag. + */ +void VAbstractNode::AddToModeling(const QDomElement &domElement) +{ + AddDetNode *addNode = new AddDetNode(domElement, doc); + qApp->getUndoStack()->push(addNode); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement reference for all parent objects. + */ +void VAbstractNode::decrementReferens() +{ + if (_referens > 0) + { + --_referens; + } + if (_referens <= 0) + { + doc->DecrementReferens(idNode); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + QDomNode element = domElement.parentNode(); + if (element.isNull() == false) + { + element.removeChild(domElement); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::RemoveReferens() +{ + if (idTool != 0) + { + doc->DecrementReferens(idTool); + } + else + { + doc->DecrementReferens(idNode); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::RestoreReferens() +{ + if (idTool != 0) + { + doc->IncrementReferens(idTool); + } + else + { + doc->IncrementReferens(idNode); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + Q_UNUSED(tag) + Q_UNUSED(obj) +} diff --git a/src/tools/nodeDetails/vabstractnode.h b/src/app/tools/nodeDetails/vabstractnode.h similarity index 57% rename from src/tools/nodeDetails/vabstractnode.h rename to src/app/tools/nodeDetails/vabstractnode.h index b2190c760..61f505ccc 100644 --- a/src/tools/nodeDetails/vabstractnode.h +++ b/src/app/tools/nodeDetails/vabstractnode.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vabstractnode.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -32,58 +32,32 @@ #include "../vabstracttool.h" /** - * @brief The VAbstractNode class + * @brief The VAbstractNode class parent class for all detail node. */ class VAbstractNode : public VAbstractTool { Q_OBJECT public: - /** - * @brief VAbstractNode - * @param doc dom document container - * @param data - * @param id - * @param idNode - * @param typeobject - * @param parent - */ - VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, - Draw::Draws typeobject, QObject *parent = 0 ); + VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, + const quint32 &idTool, QObject *parent = nullptr); virtual ~VAbstractNode() {} - /** - * @brief AttrIdObject - */ static const QString AttrIdObject; - /** - * @brief AttrTypeObject - */ - static const QString AttrTypeObject; - /** - * @brief TypeObjectCalculation - */ - static const QString TypeObjectCalculation; - /** - * @brief TypeObjectModeling - */ - static const QString TypeObjectModeling; + static const QString AttrIdTool; + virtual void DeleteNode(); + virtual void RestoreNode(); + virtual void ShowVisualization(bool show); protected: - /** - * @brief idNode - */ - qint64 idNode; - /** - * @brief typeobject - */ - Draw::Draws typeobject; - /** - * @brief AddToModeling - * @param domElement - */ + /** @brief idNodenode id. */ + quint32 idNode; + + /** @brief idTool id tool. */ + quint32 idTool; + void AddToModeling(const QDomElement &domElement); - /** - * @brief decrementReferens - */ virtual void decrementReferens(); + virtual void RemoveReferens(); + virtual void RestoreReferens(); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); }; #endif // VABSTRACTNODE_H diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp new file mode 100644 index 000000000..d7c0aeb68 --- /dev/null +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -0,0 +1,225 @@ +/************************************************************************ + ** + ** @file vnodearc.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vnodearc.h" + +#include "../../core/vapplication.h" +#include "../../geometry/varc.h" +#include +#include + +const QString VNodeArc::TagName = QStringLiteral("arc"); +const QString VNodeArc::ToolType = QStringLiteral("modeling"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodeArc constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idArc object id in containerArc. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent + * @param parent parent object. + */ +VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, + const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent) + :VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent) +{ + RefreshGeometry(); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idArc object id in containerArc. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent + */ +void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) +{ + VAbstractTool::AddRecord(id, Tool::NodeArc, doc); + if (parse == Document::FullParse) + { + VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent); + doc->AddTool(id, arc); + if (idTool != 0) + { + doc->IncrementReferens(idTool); + //Some nodes we don't show on scene. Tool that create this nodes must free memory. + VDataTool *tool = doc->getTool(idTool); + SCASSERT(tool != nullptr); + arc->setParent(tool); + } + else + { + doc->IncrementReferens(idArc); + } + } + else + { + doc->UpdateToolData(id, data); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ +void VNodeArc::DeleteNode() +{ + VAbstractNode::DeleteNode(); + this->setVisible(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeArc::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeArc::getTagName() const +{ + return VNodeArc::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VNodeArc::FullUpdateFromFile() +{ + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VNodeArc::AddToFile() +{ + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VNodeArc::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::Arc); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ +void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VNodeArc::RefreshGeometry() +{ +// const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); +// QPainterPath path; +// path.addPath(arc->GetPath()); +// path.setFillRule( Qt::WindingFill ); +// this->setPath(path); +} diff --git a/src/tools/nodeDetails/vnodearc.h b/src/app/tools/nodeDetails/vnodearc.h similarity index 55% rename from src/tools/nodeDetails/vnodearc.h rename to src/app/tools/nodeDetails/vnodearc.h index b99abd458..5341a3f99 100644 --- a/src/tools/nodeDetails/vnodearc.h +++ b/src/app/tools/nodeDetails/vnodearc.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vnodearc.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -31,75 +31,36 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** - * @brief The VNodeArc class + * @brief The VNodeArc class arc detail node. */ class VNodeArc :public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeArc - * @param doc dom document container - * @param data - * @param id - * @param idArc - * @param typeobject - * @param typeCreation - * @param parent - */ - VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief Create - * @param doc dom document container - * @param data - * @param id - * @param idArc - * @param typeobject - * @param parse - * @param typeCreation - */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Draw::Draws &typeobject, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ + VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); + + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; - /** - * @brief ToolType - */ static const QString ToolType; + virtual void DeleteNode(); + virtual void RestoreNode(); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::NodeArc)}; + virtual QString getTagName() const; public slots: - /** - * @brief FullUpdateFromFile - */ virtual void FullUpdateFromFile(); protected: - /** - * @brief AddToFile - */ virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ + virtual void RefreshDataInFile(); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry - */ void RefreshGeometry(); }; diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp new file mode 100644 index 000000000..19a930f5c --- /dev/null +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -0,0 +1,304 @@ +/************************************************************************ + ** + ** @file vnodepoint.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vnodepoint.h" + +#include "../../core/vapplication.h" +#include "../../geometry/vpointf.h" +#include "../../visualization/vgraphicssimpletextitem.h" +#include +#include +#include + +const QString VNodePoint::TagName = QStringLiteral("point"); +const QString VNodePoint::ToolType = QStringLiteral("modeling"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idPoint object id in containerPoint. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent + * @param parent parent object. + */ +VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation, + const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent) + :VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(0), + namePoint(nullptr), lineName(nullptr) +{ + radius = (1.5/*mm*/ / 25.4) * VApplication::PrintDPI; + namePoint = new VGraphicsSimpleTextItem(this); + lineName = new QGraphicsLineItem(this); + connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, + &VNodePoint::NameChangePosition); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + this->setBrush(QBrush(Qt::NoBrush)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setAcceptHoverEvents(true); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idPoint object id in containerPoint. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent + */ +void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) +{ + VAbstractTool::AddRecord(id, Tool::NodePoint, doc); + if (parse == Document::FullParse) + { + //TODO Need create garbage collector and remove all nodes, what we don't use. + //Better check garbage before each saving file. Check only modeling tags. + VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent); + doc->AddTool(id, point); + if (idTool != 0) + { + doc->IncrementReferens(idTool); + //Some nodes we don't show on scene. Tool that create this nodes must free memory. + VDataTool *tool = doc->getTool(idTool); + SCASSERT(tool != nullptr); + point->setParent(tool); + } + else + { + doc->IncrementReferens(idPoint); + } + } + else + { + doc->UpdateToolData(id, data); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ +void VNodePoint::DeleteNode() +{ + VAbstractNode::DeleteNode(); + this->setVisible(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VNodePoint::getTagName() const +{ + return VNodePoint::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VNodePoint::FullUpdateFromFile() +{ + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VNodePoint::AddToFile() +{ + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VNodePoint::RefreshDataInFile() +{ + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::Point); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ +void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NameChangePosition label change position. + * @param pos new position. + */ +void VNodePoint::NameChangePosition(const QPointF &pos) +{ + VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); + QPointF p = pos - this->pos(); + point->setMx(p.x()); + point->setMy(p.y()); + RefreshLine(); + UpdateNamePosition(point->mx(), point->my()); + VAbstractTool::data.UpdateGObject(id, point); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateNamePosition update label position in file. + * @param mx label bias x axis. + * @param my label bias y axis. + */ +void VNodePoint::UpdateNamePosition(qreal mx, qreal my) +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my))); + emit toolhaveChange(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshPointGeometry refresh point on scene. + * @param point point position. + */ +void VNodePoint::RefreshPointGeometry(const VPointF &point) +{ + QRectF rec = QRectF(0, 0, radius*2, radius*2); + rec.translate(-rec.center().x(), -rec.center().y()); + this->setRect(rec); + this->setPos(point.toQPointF()); + + namePoint->blockSignals(true); + namePoint->setText(point.name()); + namePoint->setPos(QPointF(point.mx(), point.my())); + namePoint->blockSignals(false); + + RefreshLine(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshLine refresh label line on scene. + */ +void VNodePoint::RefreshLine() +{ + QRectF nameRec = namePoint->sceneBoundingRect(); + QPointF p1, p2; + VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); + QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); + lineName->setLine(QLineF(p1, pRec - scenePos())); + if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm)) + { + lineName->setVisible(false); + } + else + { + lineName->setVisible(true); + } +} diff --git a/src/tools/nodeDetails/vnodepoint.h b/src/app/tools/nodeDetails/vnodepoint.h similarity index 53% rename from src/tools/nodeDetails/vnodepoint.h rename to src/app/tools/nodeDetails/vnodepoint.h index fcc63b362..23e666aa8 100644 --- a/src/tools/nodeDetails/vnodepoint.h +++ b/src/app/tools/nodeDetails/vnodepoint.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vnodepoint.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -30,103 +30,54 @@ #define VNODEPOINT_H #include "vabstractnode.h" -#include "../../widgets/vgraphicssimpletextitem.h" +#include "../../xml/vpattern.h" +#include + +class VPointF; +class VGraphicsSimpleTextItem; +class QGraphicsLineItem; +class QGraphicsItem; /** - * @brief The VNodePoint class + * @brief The VNodePoint class point detail node. */ class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem { Q_OBJECT public: - /** - * @brief VNodePoint - * @param doc dom document container - * @param data - * @param id - * @param idPoint - * @param typeobject - * @param typeCreation - * @param parent - */ - VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0 ); - /** - * @brief Create - * @param doc dom document container - * @param data - * @param id - * @param idPoint - * @param typeobject - * @param parse - * @param typeCreation - */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, const Draw::Draws &typeobject, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ + + VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr ); + + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; - /** - * @brief ToolType - */ static const QString ToolType; + virtual void DeleteNode(); + virtual void RestoreNode(); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::NodePoint)}; + virtual QString getTagName() const; public slots: - /** - * @brief FullUpdateFromFile - */ virtual void FullUpdateFromFile(); - /** - * @brief NameChangePosition - * @param pos - */ void NameChangePosition(const QPointF &pos); protected: - /** - * @brief radius - */ + /** @brief radius radius circle. */ qreal radius; - /** - * @brief namePoint - */ + + /** @brief namePoint label name. */ VGraphicsSimpleTextItem *namePoint; - /** - * @brief lineName - */ + + /** @brief lineName pointer to label line. */ QGraphicsLineItem *lineName; - /** - * @brief AddToFile - */ + virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ + virtual void RefreshDataInFile(); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief UpdateNamePosition - * @param mx - * @param my - */ virtual void UpdateNamePosition(qreal mx, qreal my); - /** - * @brief RefreshPointGeometry - * @param point - */ virtual void RefreshPointGeometry(const VPointF &point); - /** - * @brief RefreshLine - */ void RefreshLine(); private: Q_DISABLE_COPY(VNodePoint) diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp new file mode 100644 index 000000000..a83545287 --- /dev/null +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -0,0 +1,228 @@ +/************************************************************************ + ** + ** @file vnodespline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vnodespline.h" + +#include "../../core/vapplication.h" +#include "../../geometry/vspline.h" +#include +#include + +const QString VNodeSpline::TagName = QStringLiteral("spline"); +const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodeSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param typeCreation way we create this tool. + * @param idTool id node. + * @param qoParent QObject parent. + * @param parent QGraphicsItem parent. + */ +VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, + const Source &typeCreation, const quint32 &idTool, QObject *qoParent, + QGraphicsItem * parent) + :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) +{ + RefreshGeometry(); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool id node. + * @return pointer to node. + */ +VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) +{ + VAbstractTool::AddRecord(id, Tool::NodeSpline, doc); + VNodeSpline *spl = nullptr; + if (parse == Document::FullParse) + { + spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, parent); + doc->AddTool(id, spl); + if (idTool != 0) + { + doc->IncrementReferens(idTool); + //Some nodes we don't show on scene. Tool that create this nodes must free memory. + VDataTool *tool = doc->getTool(idTool); + SCASSERT(tool != nullptr); + spl->setParent(tool); + } + else + { + doc->IncrementReferens(idSpline); + } + } + else + { + doc->UpdateToolData(id, data); + } + return spl; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ +void VNodeSpline::DeleteNode() +{ + VAbstractNode::DeleteNode(); + this->setVisible(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSpline::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeSpline::getTagName() const +{ + return VNodeSpline::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VNodeSpline::FullUpdateFromFile() +{ + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VNodeSpline::AddToFile() +{ + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VNodeSpline::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::Spline); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ +void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VNodeSpline::RefreshGeometry() +{ +// const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); +// QPainterPath path; +// path.addPath(spl->GetPath()); +// path.setFillRule( Qt::WindingFill ); +// this->setPath(path); +} diff --git a/src/tools/nodeDetails/vnodespline.h b/src/app/tools/nodeDetails/vnodespline.h similarity index 54% rename from src/tools/nodeDetails/vnodespline.h rename to src/app/tools/nodeDetails/vnodespline.h index 016992a35..4ae2225f5 100644 --- a/src/tools/nodeDetails/vnodespline.h +++ b/src/app/tools/nodeDetails/vnodespline.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vnodespline.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -31,77 +31,36 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** - * @brief The VNodeSpline class + * @brief The VNodeSpline class spline detail node. */ class VNodeSpline:public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeSpline - * @param doc dom document container - * @param data - * @param id - * @param idSpline - * @param typeobject - * @param typeCreation - * @param parent - */ - VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief Create - * @param doc dom document container - * @param data - * @param id - * @param idSpline - * @param typeobject - * @param parse - * @param typeCreation - * @return - */ - static VNodeSpline *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, - const Draw::Draws &typeobject, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief TagName - */ + VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); + + static VNodeSpline *Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; - /** - * @brief ToolType - */ static const QString ToolType; + virtual void DeleteNode(); + virtual void RestoreNode(); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::NodeSpline)}; + virtual QString getTagName() const; public slots: - /** - * @brief FullUpdateFromFile - */ virtual void FullUpdateFromFile (); protected: - /** - * @brief AddToFile - */ virtual void AddToFile (); - /** - * @brief mouseReleaseEvent - * @param event - */ + virtual void RefreshDataInFile(); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry - */ void RefreshGeometry (); }; diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp new file mode 100644 index 000000000..a2654e473 --- /dev/null +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -0,0 +1,231 @@ +/************************************************************************ + ** + ** @file vnodesplinepath.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vnodesplinepath.h" + +#include "../../core/vapplication.h" +#include "../../geometry/vsplinepath.h" +#include +#include + +const QString VNodeSplinePath::TagName = QStringLiteral("spline"); +const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodeSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent. + * @param parent parent object. + */ +VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, + const Source &typeCreation, const quint32 &idTool, QObject *qoParent, + QGraphicsItem * parent) + :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) +{ + RefreshGeometry(); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); + + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent. + */ +void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) +{ + VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc); + if (parse == Document::FullParse) + { + VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, parent); + doc->AddTool(id, splPath); + const QSharedPointer path = data->GeometricObject(id); + const QVector *points = path->GetPoint(); + for (qint32 i = 0; isize(); ++i) + { + if (idTool != 0) + { + doc->IncrementReferens(idTool); + //Some nodes we don't show on scene. Tool that create this nodes must free memory. + VDataTool *tool = doc->getTool(idTool); + SCASSERT(tool != nullptr); + splPath->setParent(tool); + } + else + { + doc->IncrementReferens(points->at(i).P().id()); + } + } + } + else + { + doc->UpdateToolData(id, data); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ +void VNodeSplinePath::DeleteNode() +{ + VAbstractNode::DeleteNode(); + this->setVisible(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSplinePath::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeSplinePath::getTagName() const +{ + return VNodeSplinePath::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VNodeSplinePath::FullUpdateFromFile() +{ + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VNodeSplinePath::AddToFile() +{ + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != 0) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VNodeSplinePath::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); + if (idTool != 0) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::SplinePath); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ +void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ +void VNodeSplinePath::RefreshGeometry() +{ +// const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); +// QPainterPath path; +// path.addPath(splPath->GetPath()); +// path.setFillRule( Qt::WindingFill ); +// this->setPath(path); +} diff --git a/src/tools/nodeDetails/vnodesplinepath.h b/src/app/tools/nodeDetails/vnodesplinepath.h similarity index 55% rename from src/tools/nodeDetails/vnodesplinepath.h rename to src/app/tools/nodeDetails/vnodesplinepath.h index 831e9860d..d92bed5a3 100644 --- a/src/tools/nodeDetails/vnodesplinepath.h +++ b/src/app/tools/nodeDetails/vnodesplinepath.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vnodesplinepath.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -31,75 +31,35 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** - * @brief The VNodeSplinePath class + * @brief The VNodeSplinePath class spline path detail node. */ class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeSplinePath - * @param doc dom document container - * @param data - * @param id - * @param idSpline - * @param typeobject - * @param typeCreation - * @param parent - */ - VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, - Draw::Draws typeobject, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief Create - * @param doc dom document container - * @param data - * @param id - * @param idSpline - * @param typeobject - * @param parse - * @param typeCreation - */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, const Draw::Draws &typeobject, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ + VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = 0); static const QString TagName; - /** - * @brief ToolType - */ static const QString ToolType; + virtual void DeleteNode(); + virtual void RestoreNode(); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::SplinePath)}; + virtual QString getTagName() const; public slots: - /** - * @brief FullUpdateFromFile - */ virtual void FullUpdateFromFile(); protected: - /** - * @brief AddToFile - */ virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ + virtual void RefreshDataInFile(); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry - */ void RefreshGeometry(); }; diff --git a/src/tools/tools.h b/src/app/tools/tools.h similarity index 95% rename from src/tools/tools.h rename to src/app/tools/tools.h index 69adbf1ce..2802f71ce 100644 --- a/src/tools/tools.h +++ b/src/app/tools/tools.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file tools.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief diff --git a/src/app/tools/tools.pri b/src/app/tools/tools.pri new file mode 100644 index 000000000..9e4c233b4 --- /dev/null +++ b/src/app/tools/tools.pri @@ -0,0 +1,77 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vtooldetail.h \ + $$PWD/vdatatool.h \ + $$PWD/vabstracttool.h \ + $$PWD/tools.h \ + $$PWD/drawTools/vtooltriangle.h \ + $$PWD/drawTools/vtoolsplinepath.h \ + $$PWD/drawTools/vtoolspline.h \ + $$PWD/drawTools/vtoolsinglepoint.h \ + $$PWD/drawTools/vtoolshoulderpoint.h \ + $$PWD/drawTools/vtoolpointofintersection.h \ + $$PWD/drawTools/vtoolpointofcontact.h \ + $$PWD/drawTools/vtoolpoint.h \ + $$PWD/drawTools/vtoolnormal.h \ + $$PWD/drawTools/vtoollinepoint.h \ + $$PWD/drawTools/vtoollineintersect.h \ + $$PWD/drawTools/vtoolline.h \ + $$PWD/drawTools/vtoolheight.h \ + $$PWD/drawTools/vtoolendline.h \ + $$PWD/drawTools/vtoolbisector.h \ + $$PWD/drawTools/vtoolarc.h \ + $$PWD/drawTools/vtoolalongline.h \ + $$PWD/drawTools/vdrawtool.h \ + $$PWD/drawTools/drawtools.h \ + $$PWD/nodeDetails/vnodesplinepath.h \ + $$PWD/nodeDetails/vnodespline.h \ + $$PWD/nodeDetails/vnodepoint.h \ + $$PWD/nodeDetails/vnodearc.h \ + $$PWD/nodeDetails/vabstractnode.h \ + $$PWD/nodeDetails/nodedetails.h \ + $$PWD/drawTools/vtoolcutspline.h \ + $$PWD/drawTools/vtoolcutsplinepath.h \ + $$PWD/vtooluniondetails.h \ + $$PWD/drawTools/vtoolcutarc.h \ + $$PWD/drawTools/vabstractspline.h \ + $$PWD/drawTools/vtoolcut.h \ + $$PWD/drawTools/vtoollineintersectaxis.h \ + $$PWD/drawTools/vtoolcurveintersectaxis.h + +SOURCES += \ + $$PWD/vtooldetail.cpp \ + $$PWD/vdatatool.cpp \ + $$PWD/vabstracttool.cpp \ + $$PWD/drawTools/vtooltriangle.cpp \ + $$PWD/drawTools/vtoolsplinepath.cpp \ + $$PWD/drawTools/vtoolspline.cpp \ + $$PWD/drawTools/vtoolsinglepoint.cpp \ + $$PWD/drawTools/vtoolshoulderpoint.cpp \ + $$PWD/drawTools/vtoolpointofintersection.cpp \ + $$PWD/drawTools/vtoolpointofcontact.cpp \ + $$PWD/drawTools/vtoolpoint.cpp \ + $$PWD/drawTools/vtoolnormal.cpp \ + $$PWD/drawTools/vtoollinepoint.cpp \ + $$PWD/drawTools/vtoollineintersect.cpp \ + $$PWD/drawTools/vtoolline.cpp \ + $$PWD/drawTools/vtoolheight.cpp \ + $$PWD/drawTools/vtoolendline.cpp \ + $$PWD/drawTools/vtoolbisector.cpp \ + $$PWD/drawTools/vtoolarc.cpp \ + $$PWD/drawTools/vtoolalongline.cpp \ + $$PWD/drawTools/vdrawtool.cpp \ + $$PWD/nodeDetails/vnodesplinepath.cpp \ + $$PWD/nodeDetails/vnodespline.cpp \ + $$PWD/nodeDetails/vnodepoint.cpp \ + $$PWD/nodeDetails/vnodearc.cpp \ + $$PWD/nodeDetails/vabstractnode.cpp \ + $$PWD/drawTools/vtoolcutspline.cpp \ + $$PWD/drawTools/vtoolcutsplinepath.cpp \ + $$PWD/vtooluniondetails.cpp \ + $$PWD/drawTools/vtoolcutarc.cpp \ + $$PWD/drawTools/vabstractspline.cpp \ + $$PWD/drawTools/vtoolcut.cpp \ + $$PWD/drawTools/vtoollineintersectaxis.cpp \ + $$PWD/drawTools/vtoolcurveintersectaxis.cpp diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp new file mode 100644 index 000000000..67037a51a --- /dev/null +++ b/src/app/tools/vabstracttool.cpp @@ -0,0 +1,309 @@ +/************************************************************************ + ** + ** @file vabstracttool.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vabstracttool.h" +#include +#include +#include "../undocommands/deltool.h" +#include "../core/vapplication.h" +#include "../geometry/vpointf.h" +#include "../undocommands/savetooloptions.h" +#include "../widgets/vmaingraphicsview.h" +#include + +const QString VAbstractTool::AttrType = QStringLiteral("type"); +const QString VAbstractTool::AttrMx = QStringLiteral("mx"); +const QString VAbstractTool::AttrMy = QStringLiteral("my"); +const QString VAbstractTool::AttrName = QStringLiteral("name"); +const QString VAbstractTool::AttrX = QStringLiteral("x"); +const QString VAbstractTool::AttrY = QStringLiteral("y"); +const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine"); +const QString VAbstractTool::AttrLength = QStringLiteral("length"); +const QString VAbstractTool::AttrBasePoint = QStringLiteral("basePoint"); +const QString VAbstractTool::AttrFirstPoint = QStringLiteral("firstPoint"); +const QString VAbstractTool::AttrSecondPoint = QStringLiteral("secondPoint"); +const QString VAbstractTool::AttrThirdPoint = QStringLiteral("thirdPoint"); +const QString VAbstractTool::AttrCenter = QStringLiteral("center"); +const QString VAbstractTool::AttrRadius = QStringLiteral("radius"); +const QString VAbstractTool::AttrAngle = QStringLiteral("angle"); +const QString VAbstractTool::AttrAngle1 = QStringLiteral("angle1"); +const QString VAbstractTool::AttrAngle2 = QStringLiteral("angle2"); +const QString VAbstractTool::AttrP1Line = QStringLiteral("p1Line"); +const QString VAbstractTool::AttrP2Line = QStringLiteral("p2Line"); +const QString VAbstractTool::AttrP1Line1 = QStringLiteral("p1Line1"); +const QString VAbstractTool::AttrP2Line1 = QStringLiteral("p2Line1"); +const QString VAbstractTool::AttrP1Line2 = QStringLiteral("p1Line2"); +const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2"); +const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder"); +const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1"); +const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4"); +const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1"); +const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2"); +const QString VAbstractTool::AttrKCurve = QStringLiteral("kCurve"); +const QString VAbstractTool::AttrPathPoint = QStringLiteral("pathPoint"); +const QString VAbstractTool::AttrPSpline = QStringLiteral("pSpline"); +const QString VAbstractTool::AttrAxisP1 = QStringLiteral("axisP1"); +const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2"); +const QString VAbstractTool::AttrCurve = QStringLiteral("curve"); + +const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); +const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); +const QString VAbstractTool::TypeLineDashLine = QStringLiteral("dashLine"); +const QString VAbstractTool::TypeLineDotLine = QStringLiteral("dotLine"); +const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLine"); +const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VAbstractTool container. + * @param doc dom document container. + * @param data container with data. + * @param id object id in container. + * @param parent parent object. + */ +VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) + :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine), + vis(nullptr) +{ + SCASSERT(doc != nullptr); + connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); + connect(this->doc, &VPattern::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); + connect(this, &VAbstractTool::LiteUpdateTree, this->doc, &VPattern::LiteParseTree); +} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractTool::~VAbstractTool() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. + * @param sc scene. + * @param view view. + */ +void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view) +{ + QRectF rect = sc->itemsBoundingRect(); + + QRect rec0 = view->rect(); + rec0 = QRect(0, 0, rec0.width()-2, rec0.height()-2); + + QTransform t = view->transform(); + + QRectF rec1; + if (t.m11() < 1) + { + qreal width = rec0.width()/t.m11(); + qreal height = rec0.height()/t.m22(); + rec1 = QRect(0, 0, static_cast(width), static_cast(height)); + + rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y()); + QPolygonF polygone = view->mapToScene(rec1.toRect()); + rec1 = polygone.boundingRect(); + } + else + { + rec1 = rec0; + } + rec1 = rec1.united(rect.toRect()); + sc->setSceneRect(rec1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteTool full delete object form scene and file. + */ +void VAbstractTool::DeleteTool(bool ask) +{ + if (_referens <= 1) + { + qApp->getSceneView()->itemClicked(nullptr); + if (ask) + { + if (ConfirmDeletion() == QMessageBox::Cancel) + { + return; + } + } + DelTool *delTool = new DelTool(doc, id); + connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(delTool); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineStyle return pen style for current line style. + * @return pen style. + */ +Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine) +{ + QStringList styles = Styles(); + switch (styles.indexOf(typeLine)) + { + case 0: // TypeLineNone + return Qt::NoPen; + break; + case 1: // TypeLineLine + return Qt::SolidLine; + break; + case 2: // TypeLineDashLine + return Qt::DashLine; + break; + case 3: // TypeLineDotLine + return Qt::DotLine; + break; + case 4: // TypeLineDashDotLine + return Qt::DashDotLine; + break; + case 5: // TypeLineDashDotDotLine + return Qt::DashDotDotLine; + break; + default: + return Qt::SolidLine; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractTool::getLineType() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::setTypeLine(const QString &value) +{ + typeLine = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +QMap VAbstractTool::PointsList() const +{ + const QHash > *objs = data.DataGObjects(); + QMap list; + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) + { + if (i.key() != id) + { + QSharedPointer obj = i.value(); + if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation) + { + const QSharedPointer point = data.GeometricObject(i.key()); + list[point->name()] = i.key(); + } + } + } + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VAbstractTool::ConfirmDeletion() +{ + QMessageBox msgBox; + msgBox.setText(tr("Confirm the deletion.")); + msgBox.setInformativeText(tr("Do you really want delete?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Question); + return msgBox.exec(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::SaveOption(QSharedPointer &obj) +{ + qCDebug(vTool)<<"Saving tool options"; + QDomElement oldDomElement = doc->elementById(QString().setNum(id)); + if (oldDomElement.isElement()) + { + QDomElement newDomElement = oldDomElement.cloneNode().toElement(); + + SaveOptions(newDomElement, obj); + + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); + connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(saveOptions); + } + else + { + qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Styles return list of all line styles. + * @return list of all line styles. + */ +const QStringList VAbstractTool::Styles() +{ + QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << + TypeLineDashDotLine << TypeLineDashDotDotLine; + return styles; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddRecord add record about tool in history. + * @param id object id in container + * @param toolType tool type + * @param doc dom document container + */ +void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VPattern *doc) +{ + QVector *history = doc->getHistory(); + VToolRecord record = VToolRecord(id, toolType, doc->GetNameActivPP()); + if (history->contains(record)) + { + return; + } + + quint32 cursor = doc->getCursor(); + if (cursor <= 0) + { + history->append(record); + } + else + { + qint32 index = 0; + for (qint32 i = 0; isize(); ++i) + { + VToolRecord rec = history->at(i); + if (rec.getId() == cursor) + { + index = i; + break; + } + } + history->insert(index+1, record); + } +} diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h new file mode 100644 index 000000000..f69a1339b --- /dev/null +++ b/src/app/tools/vabstracttool.h @@ -0,0 +1,182 @@ +/************************************************************************ + ** + ** @file vabstracttool.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VABSTRACTTOOL_H +#define VABSTRACTTOOL_H + +#include "vdatatool.h" +#include "../xml/vpattern.h" + +class QDomElement; +class QLineF; +class QPointF; +class QGraphicsScene; +class QGraphicsView; +class QGraphicsItem; +class QRectF; +class Visualization; + +/** + * @brief The VAbstractTool abstract class for all tools. + */ +class VAbstractTool: public VDataTool +{ + Q_OBJECT +public: + VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); + virtual ~VAbstractTool(); + static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view); + quint32 getId() const; + static const QString AttrType; + static const QString AttrMx; + static const QString AttrMy; + static const QString AttrName; + static const QString AttrX; + static const QString AttrY; + static const QString AttrTypeLine; + static const QString AttrLength; + static const QString AttrBasePoint; + static const QString AttrFirstPoint; + static const QString AttrSecondPoint; + static const QString AttrThirdPoint; + static const QString AttrCenter; + static const QString AttrRadius; + static const QString AttrAngle; + static const QString AttrAngle1; + static const QString AttrAngle2; + static const QString AttrP1Line; + static const QString AttrP2Line; + static const QString AttrP1Line1; + static const QString AttrP2Line1; + static const QString AttrP1Line2; + static const QString AttrP2Line2; + static const QString AttrPShoulder; + static const QString AttrPoint1; + static const QString AttrPoint4; + static const QString AttrKAsm1; + static const QString AttrKAsm2; + static const QString AttrKCurve; + static const QString AttrPathPoint; + static const QString AttrPSpline; + static const QString AttrAxisP1; + static const QString AttrAxisP2; + static const QString AttrCurve; + static const QString TypeLineNone; + static const QString TypeLineLine; + static const QString TypeLineDashLine; + static const QString TypeLineDotLine; + static const QString TypeLineDashDotLine; + static const QString TypeLineDashDotDotLine; + static const QStringList Styles(); + static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc); + static Qt::PenStyle LineStyle(const QString &typeLine); + const VContainer *getData() const; + + QString getLineType() const; + virtual void setTypeLine(const QString &value); + QMap PointsList() const; + virtual QString getTagName() const =0; + virtual void ShowVisualization(bool show) =0; +public slots: + /** + * @brief FullUpdateFromFile update tool data form file. + */ + virtual void FullUpdateFromFile()=0; +signals: + /** + * @brief toolhaveChange emit if tool create change that need save. + */ + void toolhaveChange(); + /** + * @brief ChoosedTool emit if object was clicked. + * @param id object id in container. + * @param type type of scene object. + */ + void ChoosedTool(quint32 id, SceneObject type); + /** + * @brief FullUpdateTree emit if need reparse pattern file. + */ + void LiteUpdateTree(const Document &parse); +protected: + /** @brief doc dom document container */ + VPattern *doc; + + /** @brief id object id. */ + const quint32 id; + + /** @brief baseColor base color for tool. */ + Qt::GlobalColor baseColor; + + /** @brief currentColor current tool color. */ + Qt::GlobalColor currentColor; + + /** @brief typeLine line type. */ + QString typeLine; + + Visualization *vis; + + /** + * @brief AddToFile add tag with informations about tool into file. + */ + virtual void AddToFile()=0; + /** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ + virtual void RefreshDataInFile()=0; + /** + * @brief RemoveReferens decrement value of reference. + */ + virtual void RemoveReferens(){} + virtual void DeleteTool(bool ask = true); + static int ConfirmDeletion(); + void SaveOption(QSharedPointer &obj); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj)=0; +private: + Q_DISABLE_COPY(VAbstractTool) +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getId return object id. + * @return id. + */ +inline quint32 VAbstractTool::getId() const +{ + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getData return pointer to data container. + * @return container. + */ +inline const VContainer *VAbstractTool::getData() const +{ + return &data; +} +#endif // VABSTRACTTOOL_H diff --git a/src/app/tools/vdatatool.cpp b/src/app/tools/vdatatool.cpp new file mode 100644 index 000000000..aea1651f7 --- /dev/null +++ b/src/app/tools/vdatatool.cpp @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vdatatool.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vdatatool.h" + +Q_LOGGING_CATEGORY(vTool, "v.tool") + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDataTool constructor. + * @param data container with variables + * @param parent parent object + */ +VDataTool::VDataTool(VContainer *data, QObject *parent) + : QObject(parent), data(*data), _referens(1) +{ + SCASSERT(data != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +VDataTool::~VDataTool() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator. + * @param tool tool + * @return tool + */ +VDataTool &VDataTool::operator =(const VDataTool &tool) +{ + if ( &tool == this ) + { + return *this; + } + data = tool.getData(); + _referens = tool.referens(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement referens. + */ +void VDataTool::decrementReferens() +{ + if (_referens > 0) + { + --_referens; + } +} diff --git a/src/app/tools/vdatatool.h b/src/app/tools/vdatatool.h new file mode 100644 index 000000000..e0798c7cb --- /dev/null +++ b/src/app/tools/vdatatool.h @@ -0,0 +1,102 @@ +/************************************************************************ + ** + ** @file vdatatool.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VDATATOOL_H +#define VDATATOOL_H + +#include "../container/vcontainer.h" +#include + +Q_DECLARE_LOGGING_CATEGORY(vTool) + +class QObject; + +//We need QObject class because we use qobject_cast. +/** + * @brief The VDataTool class need for getting access to data container of tool. + */ +class VDataTool : public QObject +{ + Q_OBJECT +public: + VDataTool(VContainer *data, QObject *parent = nullptr); + virtual ~VDataTool(); + VDataTool &operator= (const VDataTool &tool); + VContainer getData() const; + void setData(const VContainer *value); + virtual quint32 referens() const; + virtual void incrementReferens(); + virtual void decrementReferens(); +protected: + /** @brief data container with data */ + VContainer data; + + /** @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. */ + quint32 _referens; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getData return data container. + * @return container. + */ +inline VContainer VDataTool::getData() const +{ + return data; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setData set data container. + * @param value container. + */ +inline void VDataTool::setData(const VContainer *value) +{ + data = *value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief referens return count of referens. + * @return count count of referens. + */ +inline quint32 VDataTool::referens() const +{ + return _referens; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief incrementReferens increment referens. + */ +inline void VDataTool::incrementReferens() +{ + ++_referens; +} + +#endif // VDATATOOL_H diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp new file mode 100644 index 000000000..9205c334f --- /dev/null +++ b/src/app/tools/vtooldetail.cpp @@ -0,0 +1,550 @@ +/************************************************************************ + ** + ** @file vtooldetail.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtooldetail.h" +#include "nodeDetails/nodedetails.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" +#include "../geometry/vequidistant.h" +#include "../widgets/vmaingraphicsscene.h" +#include "../dialogs/tools/dialogtool.h" +#include "../dialogs/tools/dialogdetail.h" +#include +#include +#include +#include +#include +#include "../undocommands/savedetailoptions.h" +#include "../undocommands/movedetail.h" +#include "../undocommands/adddet.h" +#include "../undocommands/deletedetail.h" + +const QString VToolDetail::TagName = QStringLiteral("detail"); +const QString VToolDetail::TagNode = QStringLiteral("node"); + +const QString VToolDetail::AttrSupplement = QStringLiteral("supplement"); +const QString VToolDetail::AttrClosed = QStringLiteral("closed"); +const QString VToolDetail::AttrWidth = QStringLiteral("width"); +const QString VToolDetail::AttrIdObject = QStringLiteral("idObject"); +const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType"); +const QString VToolDetail::AttrReverse = QStringLiteral("reverse"); + +const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); +const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); + +const QString VToolDetail::NodeArc = QStringLiteral("NodeArc"); +const QString VToolDetail::NodePoint = QStringLiteral("NodePoint"); +const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline"); +const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolDetail constructor. + * @param doc dom document container + * @param data container with variables + * @param id object id in container + * @param typeCreation way we create this tool. + * @param scene pointer to scene. + * @param parent parent object + */ +VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, + VMainGraphicsScene *scene, QGraphicsItem *parent) + :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialog(nullptr), sceneDetails(scene) +{ + VDetail detail = data->GetDetail(id); + for (int i = 0; i< detail.CountNode(); ++i) + { + switch (detail.at(i).getTypeTool()) + { + case (Tool::NodePoint): + InitTool(scene, detail.at(i)); + break; + case (Tool::NodeArc): + InitTool(scene, detail.at(i)); + break; + case (Tool::NodeSpline): + InitTool(scene, detail.at(i)); + break; + case (Tool::NodeSplinePath): + InitTool(scene, detail.at(i)); + break; + default: + qDebug()<<"Get wrong tool type. Ignore."; + break; + } + doc->IncrementReferens(detail.at(i).getId()); + } + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + RefreshGeometry(); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) + { + AddToFile(); + if (typeCreation != Source::FromTool) + { + qApp->getUndoStack()->endMacro(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolDetail::~VToolDetail() +{ + delete dialog; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ +void VToolDetail::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogDetail *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VDetail detail = VAbstractTool::data.GetDetail(id); + dialogTool->setDetails(detail); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ +void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogDetail *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VDetail detail = dialogTool->getDetails(); + VDetail det; + qApp->getUndoStack()->beginMacro("add detail"); + for (int i = 0; i< detail.CountNode(); ++i) + { + quint32 id = 0; + switch (detail.at(i).getTypeTool()) + { + case (Tool::NodePoint): + { + id = CreateNode(data, detail.at(i).getId()); + VNodePoint::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeArc): + { + id = CreateNode(data, detail.at(i).getId()); + VNodeArc::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeSpline): + { + id = CreateNode(data, detail.at(i).getId()); + VNodeSpline::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeSplinePath): + { + id = CreateNode(data, detail.at(i).getId()); + VNodeSplinePath::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); + } + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<AddDetail(newDetail); + } + else + { + data->UpdateDetail(id, newDetail); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VAbstractTool::AddRecord(id, Tool::Detail, doc); + if (parse == Document::FullParse) + { + VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene); + scene->addItem(detail); + connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + QHash* tools = doc->getTools(); + tools->insert(id, detail); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Remove full delete detail. + */ +void VToolDetail::Remove(bool ask) +{ + DeleteTool(ask); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ +void VToolDetail::FullUpdateFromFile() +{ + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiOk refresh tool data after change in options. + * @param result keep result working dialog. + */ +void VToolDetail::FullUpdateFromGuiOk(int result) +{ + if (result == QDialog::Accepted) + { + SCASSERT(dialog != nullptr); + DialogDetail *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VDetail newDet = dialogTool->getDetails(); + VDetail oldDet = VAbstractTool::data.GetDetail(id); + + SaveDetailOptions *saveCommand = new SaveDetailOptions(oldDet, newDet, doc, id, this->scene()); + connect(saveCommand, &SaveDetailOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(saveCommand); + } + delete dialog; + dialog = nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VToolDetail::AddToFile() +{ + VDetail detail = VAbstractTool::data.GetDetail(id); + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrName, detail.getName()); + doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx())); + doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy())); + doc->SetAttribute(domElement, AttrSupplement, static_cast(detail.getSeamAllowance())); + doc->SetAttribute(domElement, AttrClosed, static_cast(detail.getClosed())); + doc->SetAttribute(domElement, AttrWidth, detail.getWidth()); + + for (int i = 0; i < detail.CountNode(); ++i) + { + AddNode(doc, domElement, detail.at(i)); + } + + AddDet *addDet = new AddDet(domElement, doc); + connect(addDet, &AddDet::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addDet); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VToolDetail::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + VDetail det = VAbstractTool::data.GetDetail(id); + doc->SetAttribute(domElement, AttrName, det.getName()); + doc->SetAttribute(domElement, AttrSupplement, QString().setNum(static_cast(det.getSeamAllowance()))); + doc->SetAttribute(domElement, AttrClosed, QString().setNum(static_cast(det.getClosed()))); + doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); + doc->RemoveAllChild(domElement); + for (int i = 0; i < det.CountNode(); ++i) + { + AddNode(doc, domElement, det.at(i)); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle detail change. + * @param change change + * @param value value + * @return new value. + */ +QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionHasChanged && scene()) + { + // value - this is new position. + QPointF newPos = value.toPointF(); + + MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, this->scene()); + connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveDet); + } + + if (change == QGraphicsItem::ItemSelectedChange) + { + if (value == true) + { + // do stuff if selected + this->setFocus(); + } + else + { + // do stuff if not selected + } + } + + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ +void VToolDetail::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + DeleteTool(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsItem::keyReleaseEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + Q_UNUSED(tag) + Q_UNUSED(obj) +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit ChoosedTool(id, SceneObject::Detail); + } + QGraphicsItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + QMenu menu; + QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + if (_referens > 1) + { + actionRemove->setEnabled(false); + } + else + { + actionRemove->setEnabled(true); + } + QAction *selectedAction = menu.exec(event->screenPos()); + if (selectedAction == actionOption) + { + dialog = new DialogDetail(getData(), id, qApp->getMainWindow()); + dialog->setModal(true); + connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject, + dialog, &DialogTool::ChosenObject); + connect(dialog, &DialogTool::DialogClosed, this, &VToolDetail::FullUpdateFromGuiOk); + setDialog(); + dialog->show(); + } + if (selectedAction == actionRemove) + { + DeleteTool(); + return; //Leave this method immediately after call!!! + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolDetail::RemoveReferens() +{ + VDetail detail = VAbstractTool::data.GetDetail(id); + for (int i = 0; i< detail.CountNode(); ++i) + { + doc->DecrementReferens(detail.at(i).getId()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddNode add node to the file. + * @param domElement tag in xml tree. + * @param node node of detail. + */ +void VToolDetail::AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node) +{ + QDomElement nod = doc->createElement(TagNode); + + doc->SetAttribute(nod, AttrIdObject, node.getId()); + doc->SetAttribute(nod, AttrMx, qApp->fromPixel(node.getMx())); + doc->SetAttribute(nod, AttrMy, qApp->fromPixel(node.getMy())); + + if (node.getTypeTool() != Tool::NodePoint) + { + doc->SetAttribute(nod, AttrReverse, static_cast(node.getReverse())); + } + + if (node.getTypeNode() == NodeDetail::Contour) + { + doc->SetAttribute(nod, AttrNodeType, NodeTypeContour); + } + else + { + doc->SetAttribute(nod, AttrNodeType, NodeTypeModeling); + } + switch (node.getTypeTool()) + { + case (Tool::NodeArc): + doc->SetAttribute(nod, AttrType, NodeArc); + break; + case (Tool::NodePoint): + doc->SetAttribute(nod, AttrType, NodePoint); + break; + case (Tool::NodeSpline): + doc->SetAttribute(nod, AttrType, NodeSpline); + break; + case (Tool::NodeSplinePath): + doc->SetAttribute(nod, AttrType, NodeSplinePath); + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + QPainterPath path = VEquidistant(this->getData()).ContourPath(id); + this->setPath(path); + + VDetail detail = VAbstractTool::data.GetDetail(id); + this->setPos(detail.getMx(), detail.getMy()); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::DeleteTool(bool ask) +{ + DeleteDetail *delDet = new DeleteDetail(doc, id); + if (ask) + { + if (ConfirmDeletion() == QMessageBox::Cancel) + { + return; + } + /* If UnionDetails tool delete detail no need emit FullParsing.*/ + connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VPattern::NeedFullParsing); + } + qApp->getUndoStack()->push(delDet); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +//cppcheck-suppress unusedFunction +void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) +{ + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + Tool *tool = qobject_cast(tools->value(node.getId())); + SCASSERT(tool != nullptr); + connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + tool->setParentItem(this); + doc->IncrementReferens(node.getId()); +} diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h new file mode 100644 index 000000000..f5aeefe06 --- /dev/null +++ b/src/app/tools/vtooldetail.h @@ -0,0 +1,121 @@ +/************************************************************************ + ** + ** @file vtooldetail.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLDETAIL_H +#define VTOOLDETAIL_H + +#include "vabstracttool.h" +#include +#include "../xml/vpattern.h" + +class VMainGraphicsScene; +class DialogTool; + +/** + * @brief The VToolDetail class for working with detail. + */ +class VToolDetail: public VAbstractTool, public QGraphicsPathItem +{ + Q_OBJECT +public: + VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, + VMainGraphicsScene *scene, QGraphicsItem * parent = nullptr); + ~VToolDetail(); + + virtual void setDialog(); + template + /** + * @brief CreateNode create new node for detail. + * @param data container. + * @param id id parent object. + * @return id for new object. + */ + static quint32 CreateNode(VContainer *data, const quint32 &id) + { + //We can't use exist object. Need create new. + T *node = new T(*data->GeometricObject(id).data()); + node->setMode(Draw::Modeling); + return data->AddGObject(node); + } + + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static const QString TagName; + static const QString TagNode; + static const QString AttrSupplement; + static const QString AttrClosed; + static const QString AttrWidth; + static const QString AttrIdObject; + static const QString AttrNodeType; + static const QString AttrReverse; + static const QString NodeTypeContour; + static const QString NodeTypeModeling; + static const QString NodeArc; + static const QString NodePoint; + static const QString NodeSpline; + static const QString NodeSplinePath; + void Remove(bool ask); + static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::Detail)}; + virtual QString getTagName() const; + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile (); + virtual void FullUpdateFromGuiOk(int result); +protected: + virtual void AddToFile (); + virtual void RefreshDataInFile(); + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void RemoveReferens(); + virtual void keyReleaseEvent(QKeyEvent * event); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolDetail) + /** @brief dialog dialog options. */ + DialogTool *dialog; + + /** @brief sceneDetails pointer to the scene. */ + VMainGraphicsScene *sceneDetails; + + void RefreshGeometry (); + template + /** + * @brief InitTool initial node item on scene + * @param scene pointer to scene. + * @param node node of detail. + */ + void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node); + virtual void DeleteTool(bool ask = true); +}; + +#endif // VTOOLDETAIL_H diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp new file mode 100644 index 000000000..d59f93e40 --- /dev/null +++ b/src/app/tools/vtooluniondetails.cpp @@ -0,0 +1,844 @@ +/************************************************************************ + ** + ** @file vtooluniondetails.cpp + ** @author Roman Telezhynskyi + ** @date 26 12, 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 + ** 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 "vtooluniondetails.h" +#include "nodeDetails/nodedetails.h" +#include "vtooldetail.h" +#include "../geometry/vpointf.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" +#include "../dialogs/tools/dialoguniondetails.h" +#include "../undocommands/adduniondetails.h" + +const QString VToolUnionDetails::TagName = QStringLiteral("tools"); +const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails"); +const QString VToolUnionDetails::TagDetail = QStringLiteral("det"); +const QString VToolUnionDetails::TagNode = QStringLiteral("node"); +const QString VToolUnionDetails::AttrIndexD1 = QStringLiteral("indexD1"); +const QString VToolUnionDetails::AttrIndexD2 = QStringLiteral("indexD2"); +const QString VToolUnionDetails::AttrIdObject = QStringLiteral("idObject"); +const QString VToolUnionDetails::AttrNodeType = QStringLiteral("nodeType"); +const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour"); +const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling"); + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolUnionDetails costructor. + * @param doc dom document container. + * @param data dom document container. + * @param id object id in container. + * @param d1 first detail. + * @param d2 second detail. + * @param indexD1 index edge in first detail. + * @param indexD2 index edge in second detail. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, + const VDetail &d2, const quint32 &indexD1, const quint32 &indexD2, + const Source &typeCreation, QObject *parent) + :VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToNewDetail create united detail adding one node per time. + * @param tool tool that make union. + * @param doc dom document container. + * @param data container with variables. + * @param newDetail united detail. + * @param det detail what we union. + * @param i index node in detail. + * @param idTool id tool union details. + * @param dx bias node x axis. + * @param dy bias node y axis. + * @param pRotate point rotation. + * @param angle angle rotation. + */ +void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail, + const VDetail &det, const int &i, const quint32 &idTool, const qreal &dx, + const qreal &dy, const quint32 &pRotate, const qreal &angle) +{ + quint32 id = 0, idObject = 0; + switch (det.at(i).getTypeTool()) + { + case (Tool::NodePoint): + { + if ( qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && (pRotate == 0)) + { + id = det.at(i).getId(); + } + else + { + VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); + point->setMode(Draw::Modeling); + BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + idObject = data->AddGObject(point); + VPointF *point1 = new VPointF(*point); + point1->setMode(Draw::Modeling); + id = data->AddGObject(point1); + VNodePoint::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); + } + } + break; + case (Tool::NodeArc): + { + if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) + { + id = det.at(i).getId(); + } + else + { + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); + VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0); + BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + VPointF *center = new VPointF(arc->GetCenter()); + BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + QLineF l1(center->toQPointF(), p1.toQPointF()); + QLineF l2(center->toQPointF(), p2.toQPointF()); + center->setMode(Draw::Modeling); + quint32 idCenter = data->AddGObject(center); + Q_UNUSED(idCenter); + VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), + l1.angle(), QString().setNum(l1.angle()), l2.angle(), + QString().setNum(l2.angle())); + arc1->setMode(Draw::Modeling); + idObject = data->AddGObject(arc1); + + VArc *arc2 = new VArc(*arc1); + arc2->setMode(Draw::Modeling); + id = data->AddGObject(arc2); + + VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); + } + } + break; + case (Tool::NodeSpline): + { + if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) + { + id = det.at(i).getId(); + } + else + { + const QSharedPointer spline = data->GeometricObject(det.at(i).getId()); + + VPointF *p1 = new VPointF(spline->GetP1()); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + //quint32 idP1 = data->AddGObject(p1); + + VPointF p2 = VPointF(spline->GetP2()); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + + VPointF p3 = VPointF(spline->GetP3()); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + + VPointF *p4 = new VPointF(spline->GetP4()); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + //quint32 idP4 = data->AddGObject(p4); + + VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0, + Draw::Modeling); + idObject = data->AddGObject(spl); + + VSpline *spl1 = new VSpline(*spl); + spl1->setMode(Draw::Modeling); + id = data->AddGObject(spl1); + VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); + + delete p4; + delete p1; + } + } + break; + case (Tool::NodeSplinePath): + { + if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) + { + id = det.at(i).getId(); + } + else + { + VSplinePath *path = new VSplinePath(); + path->setMode(Draw::Modeling); + const QSharedPointer splinePath = data->GeometricObject(det.at(i).getId()); + qint32 k = splinePath->getMaxCountPoints(); + for (qint32 i = 1; i <= splinePath->Count(); ++i) + { + VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(), + splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(), + splinePath->at(i).KAsm1(), splinePath->getKCurve()); + + VPointF *p1 = new VPointF(spline.GetP1()); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + //quint32 idP1 = data->AddGObject(p1); + --k; + + VPointF p2 = VPointF(spline.GetP2()); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + VPointF p3 = VPointF(spline.GetP3()); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + VPointF *p4 = new VPointF(spline.GetP4()); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + //quint32 idP4 = data->AddGObject(p4); + --k; + + VSpline spl = VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline.GetKcurve()); + if (i==1) + { + path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1()+180, + splinePath->at(i-1).KAsm2(), spl.GetAngle1())); + } + path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2(), + splinePath->at(i).KAsm2(), spl.GetAngle2()+180)); + delete p4; + delete p1; + } + while (k>=0) + { + data->getNextId(); + --k; + } + idObject = data->AddGObject(path); + + VSplinePath *path1 = new VSplinePath(*path); + path1->setMode(Draw::Modeling); + id = data->AddGObject(path1); + VNodeSplinePath::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); + } + } + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<GeometricObject(det.at(i).getId())); + point->setMode(Draw::Modeling); + BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + ++idCount; + data->UpdateGObject(idDetail+idCount, point); + + ++idCount; + } + } + break; + case (Tool::NodeArc): + { + if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) + { + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); + VPointF p1 = VPointF(arc->GetP1()); + BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + VPointF p2 = VPointF(arc->GetP2()); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + VPointF *center = new VPointF(arc->GetCenter()); + BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + QLineF l1(center->toQPointF(), p1.toQPointF()); + QLineF l2(center->toQPointF(), p2.toQPointF()); + ++idCount; + center->setMode(Draw::Modeling); + data->UpdateGObject(idDetail+idCount, center); + VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(), + QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())); + arc1->setMode(Draw::Modeling); + ++idCount; + data->UpdateGObject(idDetail+idCount, arc1); + + ++idCount; + } + } + break; + case (Tool::NodeSpline): + { + if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) + { + const QSharedPointer spline = data->GeometricObject(det.at(i).getId()); + + VPointF *p1 = new VPointF(spline->GetP1()); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + ++idCount; + data->UpdateGObject(idDetail+idCount, p1); + + VPointF p2 = VPointF(spline->GetP2()); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + + VPointF p3 = VPointF(spline->GetP3()); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + + VPointF *p4 = new VPointF(spline->GetP4()); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + ++idCount; + data->UpdateGObject(idDetail+idCount, p4); + + VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0, + Draw::Modeling); + + ++idCount; + data->UpdateGObject(idDetail+idCount, spl); + + ++idCount; + } + } + break; + case (Tool::NodeSplinePath): + { + if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) + { + VSplinePath *path = new VSplinePath(); + path->setMode(Draw::Modeling); + const QSharedPointer splinePath = data->GeometricObject(det.at(i).getId()); + SCASSERT(splinePath != nullptr); + qint32 k = splinePath->getMaxCountPoints(); + for (qint32 i = 1; i <= splinePath->Count(); ++i) + { + VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(), + splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(), + splinePath->at(i).KAsm1(), splinePath->getKCurve()); + + VPointF *p1 = new VPointF(spline.GetP1()); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + ++idCount; + data->UpdateGObject(idDetail+idCount, p1); + --k; + + VPointF p2 = VPointF(spline.GetP2()); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + VPointF p3 = VPointF(spline.GetP3()); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + + VPointF *p4 = new VPointF(spline.GetP4()); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + angle); + ++idCount; + data->UpdateGObject(idDetail+idCount, p4); + --k; + + VSpline spl = VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline.GetKcurve()); + if (i==1) + { + path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1()+180, + splinePath->at(i-1).KAsm2(), spl.GetAngle1())); + } + path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2(), + splinePath->at(i).KAsm2(), spl.GetAngle2()+180)); + } + + while (k>=0) + { + data->getNextId(); + --k; + ++idCount; + } + + ++idCount; + data->UpdateGObject(idDetail+idCount, path); + + ++idCount; + } + } + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<setX(point->x()+dx); + point->setY(point->y()+dy); + QLineF line(pRotate, point->toQPointF()); + line.setAngle(line.angle()+angle); + point->setX(line.p2().x()); + point->setY(line.p2().y()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolUnionDetails::getTagName() const +{ + return VToolUnionDetails::TagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolUnionDetails::ShowVisualization(bool show) +{ + Q_UNUSED(show) +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param doc dom document container. + * @param data container with variables. + */ +VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogUnionDetails *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VDetail d1 = data->GetDetail(dialogTool->getD1()); + VDetail d2 = data->GetDetail(dialogTool->getD2()); + quint32 indexD1 = static_cast(dialogTool->getIndexD1()); + quint32 indexD2 = static_cast(dialogTool->getIndexD2()); + qApp->getUndoStack()->beginMacro("union details"); + VToolUnionDetails* tool = nullptr; + tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, + Document::FullParse, Source::FromGui); + qApp->getUndoStack()->endMacro(); + return tool; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param d1 first detail. + * @param d2 second detail. + * @param d1id id first detail. + * @param d2id id second detail. + * @param indexD1 index edge in first detail. + * @param indexD2 index edge in second detail. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, + const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1, + const quint32 &indexD2, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) +{ + VToolUnionDetails *unionDetails = 0; + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->getNextId(); + } + else + { + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VAbstractTool::AddRecord(id, Tool::UnionDetails, doc); + if (parse == Document::FullParse) + { + //Scene doesn't show this tool, so doc will destroy this object. + unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, doc); + QHash* tools = doc->getTools(); + tools->insert(id, unionDetails); + for (int i = 0; i < d1.CountNode(); ++i) + { + doc->IncrementReferens(d1.at(i).getId()); + } + for (int i = 0; i < d2.CountNode(); ++i) + { + doc->IncrementReferens(d2.at(i).getId()); + } + + } + VNodeDetail det1p1; + VNodeDetail det1p2; + d1.NodeOnEdge(indexD1, det1p1, det1p2); + Q_UNUSED(det1p2); + + VPointF point1; + VPointF point2; + PointsOnEdge(d1, indexD1, point1, point2, data); + + VPointF point3; + VPointF point4; + PointsOnEdge(d2, indexD2, point3, point4, data); + + const qreal dx = point1.x() - point4.x(); + const qreal dy = point1.y() - point4.y(); + + point3.setX(point3.x()+dx); + point3.setY(point3.y()+dy); + + point4.setX(point4.x()+dx); + point4.setY(point4.y()+dy); + + const qreal angle = QLineF(point4.toQPointF(), point3.toQPointF()).angleTo(QLineF(point1.toQPointF(), + point2.toQPointF())); + qint32 pointsD2 = 0; //Keeps count points second detail, what we already add. + + if (typeCreation == Source::FromGui) + { + qint32 j = 0, i = 0; + VDetail newDetail; + do + { + AddToNewDetail(unionDetails, doc, data, newDetail, d1.RemoveEdge(indexD1), i, id); + ++i; + if (i > d1.indexOfNode(det1p1.getId()) && pointsD2 < d2.RemoveEdge(indexD2).CountNode()-2) + { + do + { + FindJ(pointsD2, d2, indexD2, j); + if (pointsD2 == d2.RemoveEdge(indexD2).CountNode() -2) + { + break; + } + if (j >= d2.RemoveEdge(indexD2).CountNode()) + { + j=0; + } + AddToNewDetail(unionDetails, doc, data, newDetail, d2.RemoveEdge(indexD2), j, id, dx, dy, + det1p1.getId(), angle); + ++pointsD2; + ++j; + } while (pointsD2 < d2.RemoveEdge(indexD2).CountNode()); + } + } while (i < d1.RemoveEdge(indexD1).CountNode()); + + newDetail.setName("Detail"); + newDetail.setWidth(d1.getWidth()); + VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool); + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + + { + VToolDetail *toolDet = qobject_cast(tools->value(d1id)); + SCASSERT(toolDet != nullptr); + bool ask = false; + toolDet->Remove(ask); + } + + VToolDetail *toolDet = qobject_cast(tools->value(d2id)); + SCASSERT(toolDet != nullptr); + bool ask = false; + toolDet->Remove(ask); + } + else + { + quint32 idCount = 0; + qint32 j = 0, i = 0; + do + { + UpdatePoints(id, data, d1.RemoveEdge(indexD1), i, idCount); + ++i; + if (i > d1.indexOfNode(det1p1.getId()) && pointsD2 < d2.RemoveEdge(indexD2).CountNode()-2) + { + do + { + FindJ(pointsD2, d2, indexD2, j); + if (pointsD2 == d2.RemoveEdge(indexD2).CountNode()-2) + { + break; + } + if (j >= d2.RemoveEdge(indexD2).CountNode()) + { + j=0; + } + UpdatePoints(id, data, d2.RemoveEdge(indexD2), j, idCount, dx, dy, det1p1.getId(), angle); + ++pointsD2; + ++j; + } while (pointsD2 < d2.RemoveEdge(indexD2).CountNode()); + } + } while (iGeometricObject(det2p1.getId())); + p2 = VPointF(*data->GeometricObject(det2p2.getId())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolUnionDetails::FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j) +{ + if (pointsD2 == 0) + { + VNodeDetail node1; + VNodeDetail node2; + d2.NodeOnEdge(indexD2, node1, node2); + int k = d2.RemoveEdge(indexD2).indexOfNode(node2.getId()); + if (k == d2.RemoveEdge(indexD2).CountNode()-1) + { + j = 0; + } + else + { + j = d2.RemoveEdge(indexD2).indexOfNode(node2.getId())+1; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetDetailFromFile parse detail from file. + * @param doc dom document container. + * @param domElement tag in xml tree. + * @return detail stored in file. + */ +QVector VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomElement &domElement) +{ + QVector vector; + QDomNodeList detailList = domElement.childNodes(); + qint32 num = detailList.size(); + for (qint32 i = 0; i < num; ++i) + { + QDomElement element = detailList.at(i).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VToolUnionDetails::TagDetail) + { + VDetail d; + QDomNodeList nodeList = element.childNodes(); + qint32 num = nodeList.size(); + for (qint32 j = 0; j < num; ++j) + { + QDomElement element = nodeList.at(j).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VToolUnionDetails::TagNode) + { + quint32 id = doc->GetParametrUInt(element, VToolDetail::AttrIdObject, NULL_ID_STR); + qreal mx = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); + qreal my = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); + const bool reversed = doc->GetParametrUInt(element, VToolDetail::AttrReverse, "0"); + Tool tool = Tool::NodePoint; + NodeDetail nodeType = NodeDetail::Contour; + QString t = doc->GetParametrString(element, "type", "NodePoint"); + if (t == "NodePoint") + { + tool = Tool::NodePoint; + } + else if (t == "NodeArc") + { + tool = Tool::NodeArc; + } + else if (t == "NodeSpline") + { + tool = Tool::NodeSpline; + } + else if (t == "NodeSplinePath") + { + tool = Tool::NodeSplinePath; + } + d.append(VNodeDetail(id, tool, nodeType, mx, my, reversed)); + } + } + } + vector.append(d); + } + } + } + return vector; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VToolUnionDetails::AddToFile() +{ + QDomElement domElement = doc->createElement(TagName); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIndexD1, indexD1); + doc->SetAttribute(domElement, AttrIndexD2, indexD2); + + AddDetail(domElement, d1); + AddDetail(domElement, d2); + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VToolUnionDetails::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIndexD1, indexD1); + doc->SetAttribute(domElement, AttrIndexD2, indexD2); + + QDomNode domNode = domElement.firstChild(); + domNode = UpdateDetail(domNode, d1); + UpdateDetail(domNode, d2); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolUnionDetails::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + Q_UNUSED(tag) + Q_UNUSED(obj) +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddDetail add detail to xml file. + * @param domElement tag in xml tree. + * @param d detail. + */ +void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d) +{ + QDomElement det = doc->createElement(TagDetail); + + for (int i = 0; i < d.CountNode(); ++i) + { + AddNode(det, d.at(i)); + } + + domElement.appendChild(det); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddNode add node to xml file. + * @param domElement tag in xml tree. + * @param node node. + */ +void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node) +{ + //Right now method similar to method in class VToolDetail. + VToolDetail::AddNode(doc, domElement, node); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateDetail update detail in xml tree. + * @param domNode dom node. + * @param d detail. + * @return return next detail tag in xml tree if exist. + */ +QDomNode VToolUnionDetails::UpdateDetail(const QDomNode &domNode, const VDetail &d) +{ + //QDomNode domNode = domElement.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == VToolUnionDetails::TagDetail) + { + doc->removeAllChilds(domElement);//delete all nodes in detail + for (int i = 0; i < d.CountNode(); ++i) + { + AddNode(domElement, d.at(i));//rewrite nodes of detail + } + break; + } + } + } + } + return domNode.nextSibling(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToModeling add tool to xml tree. + * @param domElement tag in xml tree. + */ +void VToolUnionDetails::AddToModeling(const QDomElement &domElement) +{ + AddUnionDetails *addUnion = new AddUnionDetails(domElement, doc); + connect(addUnion, &AddUnionDetails::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addUnion); +} diff --git a/src/app/tools/vtooluniondetails.h b/src/app/tools/vtooluniondetails.h new file mode 100644 index 000000000..2685bf049 --- /dev/null +++ b/src/app/tools/vtooluniondetails.h @@ -0,0 +1,110 @@ +/************************************************************************ + ** + ** @file vtooluniondetails.h + ** @author Roman Telezhynskyi + ** @date 26 12, 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 + ** 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 VTOOLUNIONDETAILS_H +#define VTOOLUNIONDETAILS_H + +#include "vabstracttool.h" +#include "../xml/vpattern.h" + +class VPointF; +class VMainGraphicsScene; +class DialogTool; + +/** + * @brief The VToolUnionDetails class tool union details. + */ +class VToolUnionDetails : public VAbstractTool +{ + Q_OBJECT +public: + VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2, + const quint32 &indexD1, const quint32 &indexD2, const Source &typeCreation, + QObject *parent = nullptr); + /** + * @brief setDialog set dialog when user want change tool option. + */ + virtual void setDialog() {} + static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolUnionDetails *Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, + const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data); + static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j); + static QVector GetDetailFromFile(VPattern *doc, const QDomElement &domElement); + static const QString TagName; + static const QString ToolType; + static const QString TagDetail; + static const QString TagNode; + static const QString AttrIndexD1; + static const QString AttrIndexD2; + static const QString AttrIdObject; + static const QString AttrNodeType; + static const QString NodeTypeContour; + static const QString NodeTypeModeling; + static void AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail, + const VDetail &det, const int &i, const quint32 &idTool, const qreal &dx = 0, + const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0); + static void UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const int &i, + quint32 &idCount, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0, + const qreal &angle = 0); + static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate, + const qreal &angle); + virtual QString getTagName() const; + virtual void ShowVisualization(bool show); +public slots: + /** + * @brief FullUpdateFromFile update tool data form file. + */ + virtual void FullUpdateFromFile (){} +protected: + virtual void AddToFile(); + virtual void RefreshDataInFile(); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); +private: + Q_DISABLE_COPY(VToolUnionDetails) + /** @brief d1 first detail. */ + VDetail d1; + + /** @brief d2 second detail. */ + VDetail d2; + + /** @brief indexD1 index edge in first detail. */ + quint32 indexD1; + + /** @brief indexD2 index edge in second detail. */ + quint32 indexD2; + + void AddDetail(QDomElement &domElement, VDetail &d); + void AddNode(QDomElement &domElement, const VNodeDetail &node); + QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d); + void AddToModeling(const QDomElement &domElement); +}; + +#endif // VTOOLUNIONDETAILS_H diff --git a/src/app/undocommands/adddet.cpp b/src/app/undocommands/adddet.cpp new file mode 100644 index 000000000..de773f50d --- /dev/null +++ b/src/app/undocommands/adddet.cpp @@ -0,0 +1,93 @@ +/************************************************************************ + ** + ** @file adddet.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @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) 2014 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 "adddet.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : VUndoCommand(xml, doc, parent) +{ + setText(tr("Add detail")); + nodeId = doc->GetParametrId(xml); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddDet::~AddDet() +{} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void AddDet::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement element; + if (doc->GetActivNodeElement(VPattern::TagDetails, element)) + { + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + if (element.removeChild(domElement).isNull()) + { + qCDebug(vUndo)<<"Can't delete node"; + return; + } + } + else + { + qCDebug(vUndo)<<"Can't get node by id = "<GetActivNodeElement(VPattern::TagDetails, element)) + { + element.appendChild(xml); + } + else + { + qCDebug(vUndo)<<"Can't find tag"< + ** @date 15 6, 2014 + ** + ** @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) 2014 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 ADDDET_H +#define ADDDET_H + +#include "vundocommand.h" + +class VPattern; + +class AddDet : public VUndoCommand +{ + Q_OBJECT +public: + AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddDet(); + // cppcheck-suppress unusedFunction + virtual void undo(); + // cppcheck-suppress unusedFunction + virtual void redo(); +private: + Q_DISABLE_COPY(AddDet) +}; + +#endif // ADDDET_H diff --git a/src/app/undocommands/adddetnode.cpp b/src/app/undocommands/adddetnode.cpp new file mode 100644 index 000000000..fc483ed0c --- /dev/null +++ b/src/app/undocommands/adddetnode.cpp @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file adddetnode.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @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) 2014 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 "adddetnode.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : VUndoCommand(xml, doc, parent) +{ + setText(QObject::tr("Add node")); + nodeId = doc->GetParametrId(xml); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddDetNode::~AddDetNode() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddDetNode::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement modelingElement; + if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + if (modelingElement.removeChild(domElement).isNull()) + { + qCDebug(vUndo)<<"Can't delete node."; + return; + } + } + else + { + qCDebug(vUndo)<<"Can't get node by id = "<GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.appendChild(xml); + } + else + { + qCDebug(vUndo)<<"Can't find tag"< - ** @date November 15, 2013 + ** @file adddetnode.h + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,18 +26,21 @@ ** *************************************************************************/ -#include "vexceptionbadid.h" +#ifndef ADDDETNODE_H +#define ADDDETNODE_H -QString VExceptionBadId::ErrorMessage() const +#include "vundocommand.h" + +class AddDetNode : public VUndoCommand { - QString error; - if (key.isEmpty()) - { - error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id); - } - else - { - error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key); - } - return error; -} + Q_OBJECT +public: + AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddDetNode(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(AddDetNode) +}; + +#endif // ADDDETNODE_H diff --git a/src/app/undocommands/addpatternpiece.cpp b/src/app/undocommands/addpatternpiece.cpp new file mode 100644 index 000000000..cad8e21b1 --- /dev/null +++ b/src/app/undocommands/addpatternpiece.cpp @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file addpatternpiece.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 "addpatternpiece.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath, + QUndoCommand *parent) + : VUndoCommand(xml, doc, parent), namePP(namePP), mPath(mPath) +{ + SCASSERT(namePP.isEmpty() == false); + SCASSERT(mPath.isEmpty() == false); + setText(tr("Add pattern piece %1").arg(namePP)); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddPatternPiece::~AddPatternPiece() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddPatternPiece::undo() +{ + qCDebug(vUndo)<<"Undo."; + + if (doc->CountPP() <= 1) + { + emit ClearScene(); + } + else + { + QDomElement rootElement = doc->documentElement(); + QDomElement patternPiece = doc->GetPPElement(namePP); + rootElement.removeChild(patternPiece); + emit NeedFullParsing(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddPatternPiece::redo() +{ + qCDebug(vUndo)<<"Redo."; + + if (doc->CountPP() == 0 && mPath.isEmpty() == false) + { + doc->CreateEmptyFile(mPath); + } + + QDomElement rootElement = doc->documentElement(); + + rootElement.appendChild(xml); + + RedoFullParsing(); +} diff --git a/src/app/undocommands/addpatternpiece.h b/src/app/undocommands/addpatternpiece.h new file mode 100644 index 000000000..035816de7 --- /dev/null +++ b/src/app/undocommands/addpatternpiece.h @@ -0,0 +1,49 @@ +/************************************************************************ + ** + ** @file addpatternpiece.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 ADDPATTERNPIECE_H +#define ADDPATTERNPIECE_H + +#include "vundocommand.h" + +class AddPatternPiece : public VUndoCommand +{ + Q_OBJECT +public: + AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath, + QUndoCommand *parent = 0); + virtual ~AddPatternPiece(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(AddPatternPiece) + QString namePP; + QString mPath; +}; + +#endif // ADDPATTERNPIECE_H diff --git a/src/app/undocommands/addtocalc.cpp b/src/app/undocommands/addtocalc.cpp new file mode 100644 index 000000000..87f205c1f --- /dev/null +++ b/src/app/undocommands/addtocalc.cpp @@ -0,0 +1,136 @@ +/************************************************************************ + ** + ** @file addtocalc.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 "addtocalc.h" +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../core/vapplication.h" +#include "../widgets/vmaingraphicsscene.h" +#include "../widgets/vmaingraphicsview.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddToCalc::AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP()), cursor(doc->getCursor()) +{ + setText(tr("Add object")); + nodeId = doc->GetParametrId(xml); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddToCalc::~AddToCalc() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddToCalc::undo() +{ + qCDebug(vUndo)<<"Undo."; + + doc->ChangeActivPP(nameActivDraw);//User will not see this change + doc->setCursor(cursor); + + QDomElement calcElement; + if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement)) + { + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + if (calcElement.removeChild(domElement).isNull()) + { + qCDebug(vUndo)<<"Can't delete node."; + return; + } + } + else + { + qCDebug(vUndo)<<"Can't get tool by id = "< 0) + { + doc->setCursor(0); + } + emit NeedFullParsing(); + VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddToCalc::redo() +{ + qCDebug(vUndo)<<"Redo."; + + doc->ChangeActivPP(nameActivDraw);//User will not see this change + doc->setCursor(cursor); + + QDomElement calcElement; + if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement)) + { + if (cursor <= 0) + { + calcElement.appendChild(xml); + } + else + { + QDomElement refElement = doc->elementById(QString().setNum(cursor)); + if (refElement.isElement()) + { + calcElement.insertAfter(xml, refElement); + doc->setCursor(0); + } + else + { + qCDebug(vUndo)<<"Can not find the element after which you want to insert."; + return; + } + } + } + else + { + qCDebug(vUndo)<<"Can't find tag Calculation."; + return; + } + RedoFullParsing(); + VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddToCalc::RedoFullParsing() +{ + if (redoFlag) + { + emit NeedFullParsing(); + doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo + } + redoFlag = true; +} diff --git a/src/app/undocommands/addtocalc.h b/src/app/undocommands/addtocalc.h new file mode 100644 index 000000000..81d589d82 --- /dev/null +++ b/src/app/undocommands/addtocalc.h @@ -0,0 +1,50 @@ +/************************************************************************ + ** + ** @file addtocalc.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 ADDTOCALC_H +#define ADDTOCALC_H + +#include "vundocommand.h" + +class AddToCalc : public VUndoCommand +{ + Q_OBJECT +public: + AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddToCalc(); + virtual void undo(); + virtual void redo(); +protected: + virtual void RedoFullParsing(); +private: + Q_DISABLE_COPY(AddToCalc) + const QString nameActivDraw; + quint32 cursor; +}; + +#endif // ADDTOCALC_H diff --git a/src/app/undocommands/adduniondetails.cpp b/src/app/undocommands/adduniondetails.cpp new file mode 100644 index 000000000..9f5a8549e --- /dev/null +++ b/src/app/undocommands/adduniondetails.cpp @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file adduniondetails.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @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) 2014 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 "adduniondetails.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : VUndoCommand(xml, doc, parent) +{ + setText(tr("Add union details")); + nodeId = doc->GetParametrId(xml); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddUnionDetails::~AddUnionDetails() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddUnionDetails::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement modelingElement; + if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + if (modelingElement.removeChild(domElement).isNull()) + { + qCDebug(vUndo)<<"Can't delete node."; + return; + } + } + else + { + qCDebug(vUndo)<<"Can't get node by id = "<GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.appendChild(xml); + } + else + { + qCDebug(vUndo)<<"Can't find tag"< + ** @date 15 6, 2014 + ** + ** @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) 2014 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 ADDUNIONDETAILS_H +#define ADDUNIONDETAILS_H + +#include "vundocommand.h" + +class AddUnionDetails : public VUndoCommand +{ + Q_OBJECT +public: + AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddUnionDetails(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(AddUnionDetails) +}; + +#endif // ADDUNIONDETAILS_H diff --git a/src/app/undocommands/deletedetail.cpp b/src/app/undocommands/deletedetail.cpp new file mode 100644 index 000000000..a67794df3 --- /dev/null +++ b/src/app/undocommands/deletedetail.cpp @@ -0,0 +1,100 @@ +/************************************************************************ + ** + ** @file deletedetail.cpp + ** @author Roman Telezhynskyi + ** @date 16 6, 2014 + ** + ** @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) 2014 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 "deletedetail.h" +#include "../xml/vpattern.h" +#include "../tools/vtooldetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID) +{ + setText(tr("Delete tool")); + nodeId = id; + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + xml = domElement.cloneNode().toElement(); + parentNode = domElement.parentNode(); + QDomNode previousDetail = domElement.previousSibling(); + if (previousDetail.isNull()) + { + siblingId = NULL_ID; + } + else + { + // Better save id of previous detail instead of reference to node. + siblingId = doc->GetParametrUInt(previousDetail.toElement(), VPattern::AttrId, NULL_ID_STR); + } + } + else + { + qCDebug(vUndo)<<"Can't get detail by id ="<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + parentNode.removeChild(domElement); + + // UnionDetails delete two old details and create one new. + // So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly. + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + VToolDetail *toolDet = qobject_cast(tools->value(nodeId)); + SCASSERT(toolDet != nullptr); + toolDet->hide(); + + emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail. + } + else + { + qCDebug(vUndo)<<"Can't get detail by id = "< + ** @date 16 6, 2014 + ** + ** @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) 2014 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 DELETEDETAIL_H +#define DELETEDETAIL_H + +#include "vundocommand.h" +class QGraphicsItem; + +class DeleteDetail : public VUndoCommand +{ + Q_OBJECT +public: + DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent = 0); + virtual ~DeleteDetail(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(DeleteDetail) + QDomNode parentNode; + quint32 siblingId; +}; + +#endif // DELETEDETAIL_H diff --git a/src/app/undocommands/deletepatternpiece.cpp b/src/app/undocommands/deletepatternpiece.cpp new file mode 100644 index 000000000..4a3ba85bf --- /dev/null +++ b/src/app/undocommands/deletepatternpiece.cpp @@ -0,0 +1,73 @@ +/************************************************************************ + ** + ** @file deletepatternpiece.cpp + ** @author Roman Telezhynskyi + ** @date 14 6, 2014 + ** + ** @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) 2014 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 "deletepatternpiece.h" +#include "../xml/vpattern.h" +#include "addpatternpiece.h" + +//--------------------------------------------------------------------------------------------------------------------- +DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), namePP(namePP), patternPiece(QDomElement()), mPath(QString()), + previousPPName(QString()) +{ + setText(tr("Delete pattern piece %1").arg(namePP)); + + QDomElement patternP = doc->GetPPElement(namePP); + patternPiece = patternP.cloneNode().toElement(); + mPath = doc->MPath(); + QDomNode previousPP = patternP.previousSibling();//find previous pattern piece + previousPPName = doc->GetParametrString(previousPP.toElement(), VPattern::AttrName, ""); +} + +//--------------------------------------------------------------------------------------------------------------------- +DeletePatternPiece::~DeletePatternPiece() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void DeletePatternPiece::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement rootElement = doc->documentElement(); + QDomNode previousPP = doc->GetPPElement(previousPPName); + rootElement.insertAfter(patternPiece, previousPP); + + emit NeedFullParsing(); + doc->ChangedActivPP(namePP); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DeletePatternPiece::redo() +{ + qCDebug(vUndo)<<"Redo."; + + QDomElement rootElement = doc->documentElement(); + QDomElement patternPiece = doc->GetPPElement(namePP); + rootElement.removeChild(patternPiece); + emit NeedFullParsing(); +} diff --git a/src/app/undocommands/deletepatternpiece.h b/src/app/undocommands/deletepatternpiece.h new file mode 100644 index 000000000..4c4c21564 --- /dev/null +++ b/src/app/undocommands/deletepatternpiece.h @@ -0,0 +1,50 @@ +/************************************************************************ + ** + ** @file deletepatternpiece.h + ** @author Roman Telezhynskyi + ** @date 14 6, 2014 + ** + ** @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) 2014 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 DELETEPATTERNPIECE_H +#define DELETEPATTERNPIECE_H + +#include "vundocommand.h" + +class DeletePatternPiece : public VUndoCommand +{ + Q_OBJECT +public: + DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent = 0); + virtual ~DeletePatternPiece(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(DeletePatternPiece) + QString namePP; + QDomElement patternPiece; + QString mPath; + QString previousPPName; +}; + +#endif // DELETEPATTERNPIECE_H diff --git a/src/app/undocommands/deltool.cpp b/src/app/undocommands/deltool.cpp new file mode 100644 index 000000000..161bb88a8 --- /dev/null +++ b/src/app/undocommands/deltool.cpp @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file deltool.cpp + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @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) 2014 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 "deltool.h" +#include "../xml/vpattern.h" +#include +#include "../tools/vtooldetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID), + nameActivDraw(doc->GetNameActivPP()) +{ + setText(tr("Delete tool")); + nodeId = id; + siblingId = doc->SiblingNodeId(nodeId); + parentNode = doc->ParentNodeById(nodeId); + xml = doc->CloneNodeById(nodeId); +} + +//--------------------------------------------------------------------------------------------------------------------- +DelTool::~DelTool() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void DelTool::undo() +{ + qCDebug(vUndo)<<"Undo."; + + UndoDeleteAfterSibling(parentNode, siblingId); + emit NeedFullParsing(); + doc->SetCurrentPP(nameActivDraw); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DelTool::redo() +{ + qCDebug(vUndo)<<"Redo."; + + QDomElement domElement = doc->NodeById(nodeId); + parentNode.removeChild(domElement); + emit NeedFullParsing(); + doc->SetCurrentPP(nameActivDraw); +} diff --git a/src/app/undocommands/deltool.h b/src/app/undocommands/deltool.h new file mode 100644 index 000000000..df8c12377 --- /dev/null +++ b/src/app/undocommands/deltool.h @@ -0,0 +1,50 @@ +/************************************************************************ + ** + ** @file deltool.h + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @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) 2014 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 DELTOOL_H +#define DELTOOL_H + +#include "vundocommand.h" +class QGraphicsItem; + +class DelTool : public VUndoCommand +{ + Q_OBJECT +public: + DelTool(VPattern *doc, quint32 id, QUndoCommand *parent = 0); + virtual ~DelTool(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(DelTool) + QDomNode parentNode; + quint32 siblingId; + const QString nameActivDraw; +}; + +#endif // DELTOOL_H diff --git a/src/app/undocommands/movedetail.cpp b/src/app/undocommands/movedetail.cpp new file mode 100644 index 000000000..8d5b42b16 --- /dev/null +++ b/src/app/undocommands/movedetail.cpp @@ -0,0 +1,139 @@ +/************************************************************************ + ** + ** @file movedetail.cpp + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @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) 2014 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 "movedetail.h" +#include +#include +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene) +{ + setText(QObject::tr("Move detail")); + nodeId = id; + + SCASSERT(scene != nullptr); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); + oldY = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")); + } + else + { + qCDebug(vUndo)<<"Can't find detail with id ="<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + SaveCoordinates(domElement, oldX, oldY); + + emit NeedLiteParsing(Document::LiteParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find detail with id ="<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + SaveCoordinates(domElement, newX, newY); + + if (redoFlag) + { + emit NeedLiteParsing(Document::LiteParse); + } + redoFlag = true; + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find detail with id ="<(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getDetId(); + + if (id != nodeId) + { + return false; + } + + newX = moveCommand->getNewX(); + newY = moveCommand->getNewY(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveDetail::id() const +{ + return static_cast(UndoCommand::MoveDetail); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveDetail::SaveCoordinates(QDomElement &domElement, double x, double y) +{ + doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(x))); + doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(y))); +} diff --git a/src/app/undocommands/movedetail.h b/src/app/undocommands/movedetail.h new file mode 100644 index 000000000..54b439b5d --- /dev/null +++ b/src/app/undocommands/movedetail.h @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file movedetail.h + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @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) 2014 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 MOVEDETAIL_H +#define MOVEDETAIL_H + +#include "vundocommand.h" + +class QGraphicsScene; + +class MoveDetail : public VUndoCommand +{ + Q_OBJECT +public: + MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveDetail(); + virtual void undo(); + virtual void redo(); + // cppcheck-suppress unusedFunction + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getDetId() const; + double getNewX() const; + double getNewY() const; +private: + Q_DISABLE_COPY(MoveDetail) + double oldX; + double oldY; + double newX; + double newY; + QGraphicsScene *scene; + void SaveCoordinates(QDomElement &domElement, double x, double y); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveDetail::getDetId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveDetail::getNewX() const +{ + return newX; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveDetail::getNewY() const +{ + return newY; +} + +#endif // MOVEDETAIL_H diff --git a/src/app/undocommands/movelabel.cpp b/src/app/undocommands/movelabel.cpp new file mode 100644 index 000000000..eaada78e2 --- /dev/null +++ b/src/app/undocommands/movelabel.cpp @@ -0,0 +1,133 @@ +/************************************************************************ + ** + ** @file movelabel.cpp + ** @author Roman Telezhynskyi + ** @date 25 12, 2014 + ** + ** @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) 2014 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 "movelabel.h" +#include +#include +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveLabel::MoveLabel(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldMx(0.0), oldMy(0.0), newMx(x), newMy(y), scene(scene) +{ + setText(tr("Move point label")); + nodeId = id; + qCDebug(vUndo)<<"Point id"<elementById(QString().setNum(id)); + if (domElement.isElement()) + { + oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); + oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")); + + qCDebug(vUndo)<<"Label old Mx"<(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getPointId(); + + if (id != nodeId) + { + return false; + } + + qCDebug(vUndo)<<"Mergin undo."; + newMx = moveCommand->getNewMx(); + newMy = moveCommand->getNewMy(); + qCDebug(vUndo)<<"Label new Mx"<(UndoCommand::MoveLabel); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveLabel::Do(double mx, double my) +{ + qCDebug(vUndo)<<"New mx"<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(mx))); + doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(my))); + + emit NeedLiteParsing(Document::LitePPParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find point with id ="< + ** @date 25 12, 2014 + ** + ** @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) 2014 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 MOVELABEL_H +#define MOVELABEL_H + +#include "vundocommand.h" + +class QGraphicsScene; + +class MoveLabel : public VUndoCommand +{ + Q_OBJECT +public: + MoveLabel(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveLabel(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getPointId() const; + double getNewMx() const; + double getNewMy() const; + void Do(double mx, double my); +private: + Q_DISABLE_COPY(MoveLabel) + double oldMx; + double oldMy; + double newMx; + double newMy; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveLabel::getPointId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveLabel::getNewMx() const +{ + return newMx; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveLabel::getNewMy() const +{ + return newMy; +} + +#endif // MOVELABEL_H diff --git a/src/app/undocommands/movespline.cpp b/src/app/undocommands/movespline.cpp new file mode 100644 index 000000000..a59ac23c8 --- /dev/null +++ b/src/app/undocommands/movespline.cpp @@ -0,0 +1,110 @@ +/************************************************************************ + ** + ** @file movespline.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 "movespline.h" +#include "../tools/vabstracttool.h" +#include +#include +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldSpline(*oldSpl), newSpline(newSpl), scene(scene) +{ + setText(tr("Move spline")); + nodeId = id; + + SCASSERT(scene != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveSpline::~MoveSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSpline::undo() +{ + qCDebug(vUndo)<<"Undo."; + + Do(oldSpline); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSpline::redo() +{ + qCDebug(vUndo)<<"Redo."; + + Do(newSpline); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveSpline::mergeWith(const QUndoCommand *command) +{ + const MoveSpline *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSplineId(); + + if (id != nodeId) + { + return false; + } + + newSpline = moveCommand->getNewSpline(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSpline::id() const +{ + return static_cast(UndoCommand::MoveSpline); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSpline::Do(const VSpline &spl) +{ + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(spl.GetAngle1())); + doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(spl.GetAngle2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(spl.GetKasm1())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(spl.GetKasm2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(spl.GetKcurve())); + + emit NeedLiteParsing(Document::LiteParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find spline with id ="< + ** @date 9 6, 2014 + ** + ** @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) 2014 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 MOVESPLINE_H +#define MOVESPLINE_H + +#include "vundocommand.h" +#include "../geometry/vspline.h" + +class QGraphicsScene; + +class MoveSpline : public VUndoCommand +{ + Q_OBJECT +public: + MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveSpline(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSplineId() const; + VSpline getNewSpline() const; +private: + Q_DISABLE_COPY(MoveSpline) + VSpline oldSpline; + VSpline newSpline; + QGraphicsScene *scene; + void Do(const VSpline &spl); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSpline::getSplineId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VSpline MoveSpline::getNewSpline() const +{ + return newSpline; +} + +#endif // MOVESPLINE_H diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp new file mode 100644 index 000000000..1e756ad8a --- /dev/null +++ b/src/app/undocommands/movesplinepath.cpp @@ -0,0 +1,105 @@ +/************************************************************************ + ** + ** @file movesplinepath.cpp + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @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) 2014 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 "movesplinepath.h" +#include +#include "../tools/drawTools/vtoolsplinepath.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, + const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldSplinePath(oldSplPath), newSplinePath(newSplPath), scene(scene) +{ + setText(tr("Move spline path")); + nodeId = id; + + SCASSERT(scene != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveSplinePath::~MoveSplinePath() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSplinePath::undo() +{ + qCDebug(vUndo)<<"Undo."; + + Do(oldSplinePath); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSplinePath::redo() +{ + qCDebug(vUndo)<<"Redo."; + + Do(newSplinePath); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveSplinePath::mergeWith(const QUndoCommand *command) +{ + const MoveSplinePath *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSplinePathId(); + + if (id != nodeId) + { + return false; + } + + newSplinePath = moveCommand->getNewSplinePath(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSplinePath::id() const +{ + return static_cast(UndoCommand::MoveSplinePath); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSplinePath::Do(const VSplinePath &splPath) +{ + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.getKCurve())); + VToolSplinePath::UpdatePathPoint(doc, domElement, splPath); + + emit NeedLiteParsing(Document::LiteParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find spline path with id ="< + ** @date 11 6, 2014 + ** + ** @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) 2014 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 MOVESPLINEPATH_H +#define MOVESPLINEPATH_H + +#include "vundocommand.h" +#include "../geometry/vsplinepath.h" + +class QGraphicsScene; + +class MoveSplinePath : public VUndoCommand +{ + Q_OBJECT +public: + MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent = 0); + virtual ~MoveSplinePath(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSplinePathId() const; + VSplinePath getNewSplinePath() const; +private: + Q_DISABLE_COPY(MoveSplinePath) + VSplinePath oldSplinePath; + VSplinePath newSplinePath; + QGraphicsScene *scene; + void Do(const VSplinePath &splPath); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSplinePath::getSplinePathId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VSplinePath MoveSplinePath::getNewSplinePath() const +{ + return newSplinePath; +} + +#endif // MOVESPLINEPATH_H diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp new file mode 100644 index 000000000..dbc04eaf6 --- /dev/null +++ b/src/app/undocommands/movespoint.cpp @@ -0,0 +1,133 @@ +/************************************************************************ + ** + ** @file movespoint.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @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) 2014 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 "movespoint.h" +#include +#include +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene) +{ + setText(tr("Move single point")); + nodeId = id; + qCDebug(vUndo)<<"SPoint id"<elementById(QString().setNum(id)); + if (domElement.isElement()) + { + oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrX, "0.0")); + oldY = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrY, "0.0")); + + qCDebug(vUndo)<<"SPoint oldX"<(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSPointId(); + + if (id != nodeId) + { + return false; + } + + qCDebug(vUndo)<<"Mergin undo."; + newX = moveCommand->getNewX(); + newY = moveCommand->getNewY(); + qCDebug(vUndo)<<"SPoint newX"<(UndoCommand::MoveSPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSPoint::Do(double x, double y) +{ + qCDebug(vUndo)<<"Move to x"<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(x))); + doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(y))); + + emit NeedLiteParsing(Document::LitePPParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find spoint with id ="< + ** @date 9 6, 2014 + ** + ** @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) 2014 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 MOVESPOINT_H +#define MOVESPOINT_H + +#include "vundocommand.h" + +class QGraphicsScene; + +class MoveSPoint : public VUndoCommand +{ + Q_OBJECT +public: + MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveSPoint(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSPointId() const; + double getNewX() const; + double getNewY() const; + void Do(double x, double y); +private: + Q_DISABLE_COPY(MoveSPoint) + double oldX; + double oldY; + double newX; + double newY; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSPoint::getSPointId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveSPoint::getNewX() const +{ + return newX; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveSPoint::getNewY() const +{ + return newY; +} + +#endif // MOVESPOINT_H diff --git a/src/app/undocommands/renamepp.cpp b/src/app/undocommands/renamepp.cpp new file mode 100644 index 000000000..05255daf7 --- /dev/null +++ b/src/app/undocommands/renamepp.cpp @@ -0,0 +1,97 @@ +/************************************************************************ + ** + ** @file renamepp.cpp + ** @author Roman Telezhynskyi + ** @date 17 7, 2014 + ** + ** @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) 2014 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 "renamepp.h" + +#include +#include "../options.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +RenamePP::RenamePP(VPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent) + :VUndoCommand(QDomElement(), doc, parent), combo(combo), newPPname(newPPname), oldPPname(QString()) +{ + setText(tr("Rename pattern piece")); + SCASSERT(combo != nullptr); + oldPPname = doc->GetNameActivPP(); +} + +//--------------------------------------------------------------------------------------------------------------------- +RenamePP::~RenamePP() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void RenamePP::undo() +{ + qCDebug(vUndo)<<"Undo."; + + ChangeName(newPPname, oldPPname); +} + +//--------------------------------------------------------------------------------------------------------------------- +void RenamePP::redo() +{ + qCDebug(vUndo)<<"Redo."; + + ChangeName(oldPPname, newPPname); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool RenamePP::mergeWith(const QUndoCommand *command) +{ + const RenamePP *renameCommand = static_cast(command); + SCASSERT(renameCommand != nullptr); + + const QString oldName = renameCommand->getOldPPname(); + if (newPPname != oldName) + { + return false; + } + + newPPname = renameCommand->getNewPPname(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int RenamePP::id() const +{ + return static_cast(UndoCommand::RenamePP); +} + +//--------------------------------------------------------------------------------------------------------------------- +void RenamePP::ChangeName(const QString &oldName, const QString &newName) +{ + if (doc->ChangeNamePP(oldName, newName)) + { + combo->setItemText(combo->findText(oldName), newName); + } + else + { + qCWarning(vUndo)<<"Can't change pattern piece name"; + } +} diff --git a/src/app/undocommands/renamepp.h b/src/app/undocommands/renamepp.h new file mode 100644 index 000000000..36183986f --- /dev/null +++ b/src/app/undocommands/renamepp.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file renamepp.h + ** @author Roman Telezhynskyi + ** @date 17 7, 2014 + ** + ** @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) 2014 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 RENAMEPP_H +#define RENAMEPP_H + +#include "vundocommand.h" +class QComboBox; + +class RenamePP :public VUndoCommand +{ + Q_OBJECT +public: + RenamePP(VPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = 0); + virtual ~RenamePP(); + + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + QString getNewPPname() const; + QString getOldPPname() const; +private: + Q_DISABLE_COPY(RenamePP) + QComboBox *combo; + QString newPPname; + QString oldPPname; + void ChangeName(const QString &oldName, const QString &newName); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QString RenamePP::getNewPPname() const +{ + return newPPname; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QString RenamePP::getOldPPname() const +{ + return oldPPname; +} + +#endif // RENAMEPP_H diff --git a/src/app/undocommands/savedetailoptions.cpp b/src/app/undocommands/savedetailoptions.cpp new file mode 100644 index 000000000..4dcb7d8d7 --- /dev/null +++ b/src/app/undocommands/savedetailoptions.cpp @@ -0,0 +1,149 @@ +/************************************************************************ + ** + ** @file savedetailoptions.cpp + ** @author Roman Telezhynskyi + ** @date 12 6, 2014 + ** + ** @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) 2014 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 "savedetailoptions.h" +#include "../tools/nodeDetails/vabstractnode.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldDet(oldDet), newDet(newDet), scene(scene) +{ + setText(tr("Save detail option")); + nodeId = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +SaveDetailOptions::~SaveDetailOptions() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveDetailOptions::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + SaveDet(domElement, oldDet); + doc->RemoveAllChild(domElement); + for (int i = 0; i < oldDet.CountNode(); ++i) + { + VToolDetail::AddNode(doc, domElement, oldDet.at(i)); + } + QVector nodes = oldDet.getNodes(); + QHash* tools = doc->getTools(); + if (nodes.size()>0) + { + for (qint32 i = 0; i < nodes.size(); ++i) + { + VAbstractNode *node = qobject_cast(tools->value(nodes.at(i).getId())); + node->RestoreNode(); + doc->IncrementReferens(nodes.at(i).getId()); + } + } + emit NeedLiteParsing(Document::LiteParse); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qCDebug(vUndo)<<"Can't find detail with id ="<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + SaveDet(domElement, newDet); + doc->RemoveAllChild(domElement); + for (int i = 0; i < newDet.CountNode(); ++i) + { + VToolDetail::AddNode(doc, domElement, newDet.at(i)); + } + QList list = oldDet.Missing(newDet); + QHash* tools = doc->getTools(); + if (list.size()>0) + { + for (qint32 i = 0; i < list.size(); ++i) + { + VAbstractNode *node = qobject_cast(tools->value(list.at(i))); + node->DeleteNode(); + doc->DecrementReferens(list.at(i)); + } + } + emit NeedLiteParsing(Document::LiteParse); + + QList listV = scene->views(); + VAbstractTool::NewSceneRect(scene, listV[0]); + } + else + { + qCDebug(vUndo)<<"Can't find detail with id ="<(command); + SCASSERT(saveCommand != nullptr); + const quint32 id = saveCommand->getDetId(); + + if (id != nodeId) + { + return false; + } + + newDet = saveCommand->getNewDet(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SaveDetailOptions::id() const +{ + return static_cast(UndoCommand::SaveDetailOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveDetailOptions::SaveDet(QDomElement &domElement, const VDetail &det) +{ + doc->SetAttribute(domElement, VAbstractTool::AttrName, det.getName()); + doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(det.getSeamAllowance())); + doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed())); + doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth())); +} diff --git a/src/app/undocommands/savedetailoptions.h b/src/app/undocommands/savedetailoptions.h new file mode 100644 index 000000000..cfb1ab0f8 --- /dev/null +++ b/src/app/undocommands/savedetailoptions.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file savedetailoptions.h + ** @author Roman Telezhynskyi + ** @date 12 6, 2014 + ** + ** @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) 2014 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 SAVEDETAILOPTIONS_H +#define SAVEDETAILOPTIONS_H + +#include "vundocommand.h" +#include "../tools/vtooldetail.h" + +class QGraphicsScene; + +class SaveDetailOptions : public VUndoCommand +{ + Q_OBJECT +public: + SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent = 0); + virtual ~SaveDetailOptions(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getDetId() const; + VDetail getNewDet() const; +private: + Q_DISABLE_COPY(SaveDetailOptions) + const VDetail oldDet; + VDetail newDet; + QGraphicsScene *scene; + void SaveDet(QDomElement &domElement, const VDetail &det); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SaveDetailOptions::getDetId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VDetail SaveDetailOptions::getNewDet() const +{ + return newDet; +} + +#endif // SAVEDETAILOPTIONS_H diff --git a/src/app/undocommands/savetooloptions.cpp b/src/app/undocommands/savetooloptions.cpp new file mode 100644 index 000000000..a57416c3e --- /dev/null +++ b/src/app/undocommands/savetooloptions.cpp @@ -0,0 +1,104 @@ +/************************************************************************ + ** + ** @file savetooloptions.cpp + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @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) 2014 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 "savetooloptions.h" +#include "../options.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldXml(oldXml), newXml(newXml) +{ + setText(tr("Save tool option")); + nodeId = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +SaveToolOptions::~SaveToolOptions() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveToolOptions::undo() +{ + qCDebug(vUndo)<<"Undo."; + + QDomElement domElement = doc->elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + domElement.parentNode().replaceChild(oldXml, domElement); + + emit NeedLiteParsing(Document::LiteParse); + } + else + { + qCDebug(vUndo)<<"Can't find tool with id ="<elementById(QString().setNum(nodeId)); + if (domElement.isElement()) + { + domElement.parentNode().replaceChild(newXml, domElement); + + emit NeedLiteParsing(Document::LiteParse); + } + else + { + qCDebug(vUndo)<<"Can't find tool with id ="<(command); + SCASSERT(saveCommand != nullptr); + const quint32 id = saveCommand->getToolId(); + + if (id != nodeId) + { + return false; + } + + newXml = saveCommand->getNewXml(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SaveToolOptions::id() const +{ + return static_cast(UndoCommand::SaveToolOptions); +} diff --git a/src/app/undocommands/savetooloptions.h b/src/app/undocommands/savetooloptions.h new file mode 100644 index 000000000..4ac44c7e6 --- /dev/null +++ b/src/app/undocommands/savetooloptions.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file savetooloptions.h + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @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) 2014 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 SAVETOOLOPTIONS_H +#define SAVETOOLOPTIONS_H + +#include "vundocommand.h" + +class SaveToolOptions : public VUndoCommand +{ + Q_OBJECT +public: + SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, + QUndoCommand *parent = 0); + virtual ~SaveToolOptions(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + QDomElement getNewXml() const; + quint32 getToolId() const; +private: + Q_DISABLE_COPY(SaveToolOptions) + const QDomElement oldXml; + QDomElement newXml; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QDomElement SaveToolOptions::getNewXml() const +{ + return newXml; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SaveToolOptions::getToolId() const +{ + return nodeId; +} + +#endif // SAVETOOLOPTIONS_H diff --git a/src/app/undocommands/undocommands.pri b/src/app/undocommands/undocommands.pri new file mode 100644 index 000000000..255bd8719 --- /dev/null +++ b/src/app/undocommands/undocommands.pri @@ -0,0 +1,42 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/addtocalc.h \ + $$PWD/addpatternpiece.h \ + $$PWD/movespoint.h \ + $$PWD/movespline.h \ + $$PWD/movesplinepath.h \ + $$PWD/savetooloptions.h \ + $$PWD/savedetailoptions.h \ + $$PWD/movedetail.h \ + $$PWD/deltool.h \ + $$PWD/deletepatternpiece.h \ + $$PWD/adddetnode.h \ + $$PWD/adddet.h \ + $$PWD/adduniondetails.h \ + $$PWD/deletedetail.h \ + $$PWD/vundocommand.h \ + $$PWD/renamepp.h \ + $$PWD/movelabel.h + + +SOURCES += \ + $$PWD/addtocalc.cpp \ + $$PWD/addpatternpiece.cpp \ + $$PWD/movespoint.cpp \ + $$PWD/movespline.cpp \ + $$PWD/movesplinepath.cpp \ + $$PWD/savetooloptions.cpp \ + $$PWD/savedetailoptions.cpp \ + $$PWD/movedetail.cpp \ + $$PWD/deltool.cpp \ + $$PWD/deletepatternpiece.cpp \ + $$PWD/adddetnode.cpp \ + $$PWD/adddet.cpp \ + $$PWD/adduniondetails.cpp \ + $$PWD/deletedetail.cpp \ + $$PWD/vundocommand.cpp \ + $$PWD/renamepp.cpp \ + $$PWD/movelabel.cpp + diff --git a/src/app/undocommands/vundocommand.cpp b/src/app/undocommands/vundocommand.cpp new file mode 100644 index 000000000..f02f3c426 --- /dev/null +++ b/src/app/undocommands/vundocommand.cpp @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file vundocommand.cpp + ** @author Roman Telezhynskyi + ** @date 16 7, 2014 + ** + ** @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) 2014 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 "vundocommand.h" +#include "../xml/vpattern.h" + +Q_LOGGING_CATEGORY(vUndo, "v.undo") + +//--------------------------------------------------------------------------------------------------------------------- +VUndoCommand::VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + :QObject(), QUndoCommand(parent), xml(xml), doc(doc), nodeId(NULL_ID), redoFlag(false) +{ + SCASSERT(doc != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +VUndoCommand::~VUndoCommand() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VUndoCommand::RedoFullParsing() +{ + if (redoFlag) + { + emit NeedFullParsing(); + } + redoFlag = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VUndoCommand::UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const +{ + if (siblingId == NULL_ID) + { + parentNode.appendChild(xml); + } + else + { + const QDomElement refElement = doc->NodeById(siblingId); + parentNode.insertAfter(xml, refElement); + } +} diff --git a/src/app/undocommands/vundocommand.h b/src/app/undocommands/vundocommand.h new file mode 100644 index 000000000..ef5971fb1 --- /dev/null +++ b/src/app/undocommands/vundocommand.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vundocommand.h + ** @author Roman Telezhynskyi + ** @date 16 7, 2014 + ** + ** @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) 2014 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 VUNDOCOMMAND_H +#define VUNDOCOMMAND_H + +#include +#include +#include +#include "../xml/vpattern.h" + +Q_DECLARE_LOGGING_CATEGORY(vUndo) + +enum class UndoCommand: char { AddPatternPiece, + AddToCalc, + MoveSpline, + MoveSplinePath, + MoveSPoint, + SaveToolOptions, + SaveDetailOptions, + MoveDetail, + DeleteTool, + DeletePatternPiece, + RenamePP, + MoveLabel + }; + +class VPattern; + +class VUndoCommand : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~VUndoCommand(); +signals: + void ClearScene(); + void NeedFullParsing(); + void NeedLiteParsing(const Document &parse); +protected: + QDomElement xml; + VPattern *doc; + quint32 nodeId; + bool redoFlag; + virtual void RedoFullParsing(); + void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const; +private: + Q_DISABLE_COPY(VUndoCommand) +}; + +#endif // VUNDOCOMMAND_H diff --git a/src/app/version.cpp b/src/app/version.cpp new file mode 100644 index 000000000..70d0c93fe --- /dev/null +++ b/src/app/version.cpp @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file version.cpp + ** @author Roman Telezhynskyi + ** @date 16 4, 2014 + ** + ** @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 + ** 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 "version.h" +#include +#include +#include + +extern const int MAJOR_VERSION = 0; +extern const int MINOR_VERSION = 2; +extern const int DEBUG_VERSION = 9; + +extern const QString APP_VERSION(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) + .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); + +//--------------------------------------------------------------------------------------------------------------------- +QString compilerString() +{ +#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too + QString isAppleString; +#if defined(__apple_build_version__) // Apple clang has other version numbers + isAppleString = QLatin1String(" (Apple)"); +#endif + return QLatin1String("Clang " ) + QString::number(__clang_major__) + QLatin1Char('.') + + QString::number(__clang_minor__) + isAppleString; +#elif defined(Q_CC_GNU) + return QLatin1String("GCC " ) + QLatin1String(__VERSION__); +#elif defined(Q_CC_MSVC) + if (_MSC_VER >= 1800) // 1800: MSVC 2013 (yearly release cycle) + return QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); + if (_MSC_VER >= 1500) // 1500: MSVC 2008, 1600: MSVC 2010, ... (2-year release cycle) + return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); +#endif + return QLatin1String(""); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString buildCompatibilityString() +{ + return QCoreApplication::tr("Based on Qt %1 (%2, %3 bit)").arg(QLatin1String(qVersion()), compilerString(), + QString::number(QSysInfo::WordSize)); +} diff --git a/src/app/version.h b/src/app/version.h new file mode 100644 index 000000000..892e19d68 --- /dev/null +++ b/src/app/version.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file version.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VERSION_H +#define VERSION_H + +class QString; + +extern const int MAJOR_VERSION; +extern const int MINOR_VERSION; +extern const int DEBUG_VERSION; + +extern const QString APP_VERSION; + +// Change version number in version.cpp too. + +#define VER_FILEVERSION 0,2,9,0 +#define VER_FILEVERSION_STR "0.2.9.0\0" + +#define VER_PRODUCTVERSION VER_FILEVERSION +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR + +#define VER_COMPANYNAME_STR "ValentinaTeam" +#define VER_FILEDESCRIPTION_STR "Patternmaking program." +#define VER_INTERNALNAME_STR "Valentina" +#define VER_LEGALCOPYRIGHT_STR "Copyright © 2014-2015 Valentina Team" +#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved" +#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR +#define VER_ORIGINALFILENAME_STR "valentina.exe" +#define VER_PRODUCTNAME_STR "Valentina" + +#define VER_COMPANYDOMAIN_STR "www.valentina-project.org" + +QString compilerString(); +QString buildCompatibilityString(); + +#endif // VERSION_H diff --git a/src/app/visualization/vcontrolpointspline.cpp b/src/app/visualization/vcontrolpointspline.cpp new file mode 100644 index 000000000..31c22d7aa --- /dev/null +++ b/src/app/visualization/vcontrolpointspline.cpp @@ -0,0 +1,185 @@ +/************************************************************************ + ** + ** @file vcontrolpointspline.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vcontrolpointspline.h" +#include "../tools/vabstracttool.h" + +#include +#include +#include +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VControlPointSpline constructor. + * @param indexSpline index spline in list. + * @param position position point in spline. + * @param controlPoint control point. + * @param splinePoint spline point. + * @param parent parent object. + */ +VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, + const QPointF &controlPoint, const QPointF &splinePoint, + QGraphicsItem *parent) + :QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position) +{ + //create circle + radius = (1.5/*mm*/ / 25.4) * VApplication::PrintDPI; + QRectF rec = QRectF(0, 0, radius*2, radius*2); + rec.translate(-rec.center().x(), -rec.center().y()); + this->setRect(rec); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + this->setBrush(QBrush(Qt::NoBrush)); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setAcceptHoverEvents(true); + this->setPos(controlPoint); + this->setZValue(100); + + QPointF p1, p2; + VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); + controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this); + controlLine->setPen(QPen(Qt::red, qApp->toPixel(qApp->widthHairLine()))); + controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsEllipseItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverEnterEvent handle hover enter events. + * @param event hover move event. + */ +void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + QGraphicsEllipseItem::hoverEnterEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + //Disable cursor-arrow-openhand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + QGraphicsEllipseItem::hoverLeaveEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionChange && scene()) + { + // value - new position. + QPointF newPos = value.toPointF(); + emit ControlPointChangePosition(indexSpline, position, newPos); + } + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + } + QGraphicsEllipseItem::mousePressEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + //Disable cursor-arrow-closehand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + } + QGraphicsEllipseItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshLine refresh line control point. + * @param indexSpline index spline in list. + * @param pos position point in spline. + * @param controlPoint control point. + * @param splinePoint spline point. + */ +void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, + const QPointF &controlPoint, const QPointF &splinePoint) +{ + if (this->indexSpline == indexSpline && this->position == pos) + { + QPointF p1, p2; + VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); + controlLine->setLine(QLineF(splinePoint-controlPoint, p1)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEnabledPoint disable or enable control point. + * @param enable true - enable. + */ +void VControlPointSpline::setEnabledPoint(bool enable) +{ + if (enable == true) + { + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setAcceptHoverEvents(true); + } + else + { + this->setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine()))); + this->setFlag(QGraphicsItem::ItemIsSelectable, false); + this->setFlag(QGraphicsItem::ItemIsMovable, false); + this->setAcceptHoverEvents(false); + } +} diff --git a/src/app/visualization/vcontrolpointspline.h b/src/app/visualization/vcontrolpointspline.h new file mode 100644 index 000000000..e72c78951 --- /dev/null +++ b/src/app/visualization/vcontrolpointspline.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file vcontrolpointspline.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VCONTROLPOINTSPLINE_H +#define VCONTROLPOINTSPLINE_H + +#include +#include +#include "../geometry/vsplinepath.h" + +/** + * @brief The VControlPointSpline class control spline point. + */ +class VControlPointSpline : public QObject, public QGraphicsEllipseItem +{ + Q_OBJECT +public: + VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint, + const QPointF &splinePoint, QGraphicsItem * parent = nullptr); + virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ControlPointSpline)}; +signals: + /** + * @brief ControlPointChangePosition emit when control point change position. + * @param indexSpline index spline in list. + * @param position position point in spline. + * @param pos new posotion. + */ + void ControlPointChangePosition(const qint32 &indexSpline, SplinePointPosition position, + const QPointF &pos); +public slots: + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, + const QPointF &splinePoint); + void setEnabledPoint(bool enable); +protected: + /** @brief radius radius circle. */ + qreal radius; + + /** @brief controlLine pointer to line control point. */ + QGraphicsLineItem *controlLine; + + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); + QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); +private: + Q_DISABLE_COPY(VControlPointSpline) + /** @brief indexSpline index spline in list.. */ + qint32 indexSpline; + + /** @brief position position point in spline. */ + SplinePointPosition position; +}; + +#endif // VCONTROLPOINTSPLINE_H diff --git a/src/app/visualization/vgraphicssimpletextitem.cpp b/src/app/visualization/vgraphicssimpletextitem.cpp new file mode 100644 index 000000000..49921e86b --- /dev/null +++ b/src/app/visualization/vgraphicssimpletextitem.cpp @@ -0,0 +1,174 @@ +/************************************************************************ + ** + ** @file vgraphicssimpletextitem.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vgraphicssimpletextitem.h" +#include +#include +#include +#include +#include +#include + +#include "../core/vapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGraphicsSimpleTextItem default constructor. + * @param parent parent object. + */ +VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) + :QGraphicsSimpleTextItem(parent), fontSize(0) +{ + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true); + this->setAcceptHoverEvents(true); + QFont font = this->font(); + font.setPointSize(font.pointSize()+20); + fontSize = font.pointSize(); + this->setFont(font); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGraphicsSimpleTextItem constructor. + * @param text text. + * @param parent parent object. + */ +VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent ) + :QGraphicsSimpleTextItem(text, parent), fontSize(0) +{ + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setAcceptHoverEvents(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsSimpleTextItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ +QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionChange && scene()) + { + QPointF newPos = value.toPointF() + this->parentItem()->pos(); + emit NameChangePosition(newPos); + } + return QGraphicsItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverEnterEvent handle hover enter events. + * @param event hover enter event. + */ +void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + this->setBrush(Qt::green); + + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png"), 1, 1); + QGraphicsSimpleTextItem::hoverEnterEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + this->setBrush(Qt::black); + + //Disable cursor-arrow-openhand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-openhand.png")); + QGraphicsSimpleTextItem::hoverLeaveEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ +void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + emit ShowContextMenu(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + VApplication::setOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png"), 1, 1); + } + QGraphicsSimpleTextItem::mousePressEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + //Disable cursor-arrow-closehand + VApplication::restoreOverrideCursor(QStringLiteral("://cursor/cursor-arrow-closehand.png")); + } + QGraphicsSimpleTextItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsSimpleTextItem::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + emit DeleteTool(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsSimpleTextItem::keyReleaseEvent ( event ); +} diff --git a/src/app/visualization/vgraphicssimpletextitem.h b/src/app/visualization/vgraphicssimpletextitem.h new file mode 100644 index 000000000..daf3c9297 --- /dev/null +++ b/src/app/visualization/vgraphicssimpletextitem.h @@ -0,0 +1,85 @@ +/************************************************************************ + ** + ** @file vgraphicssimpletextitem.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VGRAPHICSSIMPLETEXTITEM_H +#define VGRAPHICSSIMPLETEXTITEM_H + +#include +#include +#include "../options.h" + +/** + * @brief The VGraphicsSimpleTextItem class pointer label. + */ +class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem +{ + Q_OBJECT +public: + VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr); + VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr ); + + qint32 FontSize()const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::GraphicsSimpleTextItem)}; +signals: + /** + * @brief NameChangePosition emit when label change position. + * @param pos new posotion. + */ + void NameChangePosition(const QPointF &pos); + /** + * @brief ShowContextMenu emit when need show tool context menu. + * @param event context menu event. + */ + void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); + void DeleteTool(); +protected: + QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event ); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent *event ); + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void keyReleaseEvent ( QKeyEvent * event ); +private: + /** @brief fontSize label font size. */ + qint32 fontSize; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FontSize return label font size. + * @return font size. + */ +inline qint32 VGraphicsSimpleTextItem::FontSize() const +{ + return fontSize; +} + +#endif // VGRAPHICSSIMPLETEXTITEM_H diff --git a/src/app/visualization/visline.cpp b/src/app/visualization/visline.cpp new file mode 100644 index 000000000..6a8371f22 --- /dev/null +++ b/src/app/visualization/visline.cpp @@ -0,0 +1,130 @@ +/************************************************************************ + ** + ** @file visline.cpp + ** @author Roman Telezhynskyi + ** @date 21 7, 2014 + ** + ** @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) 2014 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 "visline.h" +#include "../tools/drawTools/vdrawtool.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +VisLine::VisLine(const VContainer *data, QGraphicsItem *parent) + :Visualization(data), QGraphicsLineItem(parent) +{ + this->setZValue(1);// Show on top real tool + InitPen(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisLine::~VisLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VisLine::CorrectAngle(const qreal &angle) const +{ + qreal ang = angle; + if (angle > 360) + { + ang = angle - 360 * qFloor(angle/360); + } + + switch (qFloor((qAbs(ang)+22.5)/45)) + { + case 0: // <22.5 + return 0; + case 1: // <67.5 + return 45; + case 2: // <112.5 + return 90; + case 3: // <157.5 + return 135; + case 4: // <202.5 + return 180; + case 5: // <247.5 + return 225; + case 6: // < 292.5 + return 270; + case 7: // <337.5 + return 315; + default: // <360 + return 0; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const +{ + if (this->scene() == nullptr) + { + QLineF line = QLineF(firstPoint, Visualization::scenePos); + line.setAngle(angle); + return line.p2();// We can't find ray because item doesn't have scene. We will return cursor position on scene. + } + + QRectF scRect = this->scene()->sceneRect(); + if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) + { + return VGObject::BuildRay(firstPoint, CorrectAngle(angle), scRect); + } + else + { + return VGObject::BuildRay(firstPoint, angle, scRect); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VisLine::Ray(const QPointF &firstPoint) const +{ + QLineF line = QLineF(firstPoint, Visualization::scenePos); + return Ray(firstPoint, line.angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VisLine::Axis(const QPointF &p, const qreal &angle) const +{ + QPointF endP1 = Ray(p, angle+180); + QPointF endP2 = Ray(p, angle); + return QLineF(endP1, endP2); +} + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const +{ + QLineF line(p1, p2); + return Axis(p1, line.angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisLine::InitPen() +{ + this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisLine::AddOnScene() +{ + AddItem(this); +} diff --git a/src/app/visualization/visline.h b/src/app/visualization/visline.h new file mode 100644 index 000000000..d22389c3a --- /dev/null +++ b/src/app/visualization/visline.h @@ -0,0 +1,59 @@ +/************************************************************************ + ** + ** @file visline.h + ** @author Roman Telezhynskyi + ** @date 21 7, 2014 + ** + ** @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) 2014 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 VISLINE_H +#define VISLINE_H + +#include "visualization.h" +#include +#include + +class VContainer; + +class VisLine: public Visualization, public QGraphicsLineItem +{ + Q_OBJECT +public: + VisLine(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisLine(); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::Line)}; +protected: + qreal CorrectAngle(const qreal &angle) const; + QPointF Ray(const QPointF &firstPoint, const qreal &angle) const; + QPointF Ray(const QPointF &firstPoint) const; + QLineF Axis(const QPointF &p, const qreal &angle) const; + QLineF Axis(const QPointF &p1, const QPointF &p2) const; + virtual void InitPen(); + virtual void AddOnScene(); +private: + Q_DISABLE_COPY(VisLine) +}; + +#endif // VISLINE_H diff --git a/src/app/visualization/vispath.cpp b/src/app/visualization/vispath.cpp new file mode 100644 index 000000000..715d4000d --- /dev/null +++ b/src/app/visualization/vispath.cpp @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file vispath.cpp + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 "vispath.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisPath::VisPath(const VContainer *data, QGraphicsItem *parent) + :Visualization(data), QGraphicsPathItem(parent) +{ + this->setZValue(1);// Show on top real tool + InitPen(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisPath::~VisPath() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisPath::InitPen() +{ + this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisPath::AddOnScene() +{ + AddItem(this); +} diff --git a/src/version.h b/src/app/visualization/vispath.h similarity index 62% rename from src/version.h rename to src/app/visualization/vispath.h index e4a035cfd..4ac4e6fcb 100644 --- a/src/version.h +++ b/src/app/visualization/vispath.h @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file version.h - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file vispath.h + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,16 +26,26 @@ ** *************************************************************************/ -#ifndef VERSION_H -#define VERSION_H +#ifndef VISPATH_H +#define VISPATH_H -#include +#include "visualization.h" +#include -extern const int MAJOR_VERSION = 0; -extern const int MINOR_VERSION = 2; -extern const int DEBUG_VERSION = 2; +class VisPath : public Visualization, public QGraphicsPathItem +{ + Q_OBJECT +public: + VisPath(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisPath(); -extern const QString APP_VERSION(QStringLiteral("%1.%2.%3").arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(DEBUG_VERSION)); -extern const QString WARRANTY("The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE " - "WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE."); -#endif // VERSION_H + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::Path)}; +protected: + virtual void InitPen(); + virtual void AddOnScene(); +private: + Q_DISABLE_COPY(VisPath) +}; + +#endif // VISPATH_H diff --git a/src/app/visualization/vistoolalongline.cpp b/src/app/visualization/vistoolalongline.cpp new file mode 100644 index 000000000..4287bac2e --- /dev/null +++ b/src/app/visualization/vistoolalongline.cpp @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file vistoolalongline.cpp + ** @author Roman Telezhynskyi + ** @date 24 7, 2014 + ** + ** @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) 2014 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 "vistoolalongline.h" +#include "../container/vcontainer.h" +#include "../geometry/vpointf.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), + length(0) +{ + this->mainColor = Qt::red; + this->setZValue(2);// Show on top real tool + + lineP1 = InitPoint(supportColor, this); + lineP2 = InitPoint(supportColor, this); + line = InitItem(supportColor, this); + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolAlongLine::~VisToolAlongLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolAlongLine::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolAlongLine::setLength(const QString &expression) +{ + length = FindLength(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolAlongLine::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(lineP1, first->toQPointF(), supportColor); + + if (point2Id <= NULL_ID) + { + DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(lineP2, second->toQPointF(), supportColor); + + DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + QLineF mainLine = VGObject::BuildLine(first->toQPointF(), length, line->line().angle()); + DrawLine(this, mainLine, mainColor, lineStyle); + + DrawPoint(point, mainLine.p2(), mainColor); + } + } + } +} diff --git a/src/app/visualization/vistoolalongline.h b/src/app/visualization/vistoolalongline.h new file mode 100644 index 000000000..45d6d61e3 --- /dev/null +++ b/src/app/visualization/vistoolalongline.h @@ -0,0 +1,58 @@ +/************************************************************************ + ** + ** @file vistoolalongline.h + ** @author Roman Telezhynskyi + ** @date 24 7, 2014 + ** + ** @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) 2014 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 VISTOOLALONGLINE_H +#define VISTOOLALONGLINE_H + +#include "visline.h" + +class VContainer; + +class VisToolAlongLine :public VisLine +{ + Q_OBJECT +public: + VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolAlongLine(); + + virtual void RefreshGeometry(); + void setPoint2Id(const quint32 &value); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolAlongLine)}; +private: + Q_DISABLE_COPY(VisToolAlongLine) + quint32 point2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP2; + QGraphicsLineItem *line; + qreal length; +}; + +#endif // VISTOOLALONGLINE_H diff --git a/src/app/visualization/vistoolarc.cpp b/src/app/visualization/vistoolarc.cpp new file mode 100644 index 000000000..dc0ee62b0 --- /dev/null +++ b/src/app/visualization/vistoolarc.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file vistoolarc.cpp + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 "vistoolarc.h" +#include "../geometry/vpointf.h" +#include "../geometry/varc.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent) + :VisPath(data, parent), arcCenter(nullptr), radius(0), f1(0), f2(0) +{ + arcCenter = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolArc::~VisToolArc() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArc::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(arcCenter, first->toQPointF(), supportColor); + + if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && f2 >= 0 && qFuzzyCompare(1 + f1, 1 + f2) == false) + { + VArc arc = VArc (*first, radius, f1, f2); + DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArc::setRadius(const QString &expression) +{ + radius = FindLength(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArc::setF1(const QString &expression) +{ + f1 = FindVal(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArc::setF2(const QString &expression) +{ + f2 = FindVal(expression); +} diff --git a/src/app/visualization/vistoolarc.h b/src/app/visualization/vistoolarc.h new file mode 100644 index 000000000..5e44d0f1a --- /dev/null +++ b/src/app/visualization/vistoolarc.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file vistoolarc.h + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 VISTOOLARC_H +#define VISTOOLARC_H + + +#include "vispath.h" + +class VisToolArc : public VisPath +{ + Q_OBJECT +public: + VisToolArc(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolArc(); + + virtual void RefreshGeometry(); + void setRadius(const QString &expression); + void setF1(const QString &expression); + void setF2(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolArc)}; +private: + Q_DISABLE_COPY(VisToolArc) + QGraphicsEllipseItem *arcCenter; + qreal radius; + qreal f1; + qreal f2; +}; + +#endif // VISTOOLARC_H diff --git a/src/app/visualization/vistoolbisector.cpp b/src/app/visualization/vistoolbisector.cpp new file mode 100644 index 000000000..c98bb7fb5 --- /dev/null +++ b/src/app/visualization/vistoolbisector.cpp @@ -0,0 +1,122 @@ +/************************************************************************ + ** + ** @file vistoolbisector.cpp + ** @author Roman Telezhynskyi + ** @date 24 7, 2014 + ** + ** @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) 2014 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 "vistoolbisector.h" +#include "../geometry/vpointf.h" +#include "../container/vcontainer.h" +#include "../tools/drawTools/vtoolbisector.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), point2Id(NULL_ID), point3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), + line1(nullptr), line2P2(nullptr), line2(nullptr), length(0) +{ + line1P1 = InitPoint(supportColor, this); + line1P2 = InitPoint(supportColor, this); + line1 = InitItem(supportColor, this); + + line2P2 = InitPoint(supportColor, this); + line2 = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolBisector::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolBisector::setPoint3Id(const quint32 &value) +{ + point3Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolBisector::setLength(const QString &expression) +{ + length = FindLength(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolBisector::~VisToolBisector() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolBisector::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(line1P1, first->toQPointF(), supportColor); + + if (point2Id <= NULL_ID) + { + DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(line1P2, second->toQPointF(), supportColor); + + DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (point3Id <= NULL_ID) + { + DrawLine(line2, QLineF(second->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(point3Id); + DrawPoint(line2P2, third->toQPointF(), supportColor); + + DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + qreal angle = VToolBisector::BisectorAngle(first->toQPointF(), second->toQPointF(), + third->toQPointF()); + QLineF mainLine = VGObject::BuildLine(second->toQPointF(), length, angle); + DrawLine(this, mainLine, mainColor, lineStyle); + + DrawPoint(point, mainLine.p2(), mainColor); + } + else + { + qreal angle = VToolBisector::BisectorAngle(first->toQPointF(), second->toQPointF(), + third->toQPointF()); + QPointF endRay = Ray(second->toQPointF(), angle); + QLineF mainLine = VGObject::BuildLine(second->toQPointF(), + QLineF(second->toQPointF(), endRay).length(), angle); + DrawLine(this, mainLine, mainColor, lineStyle); + } + } + } + } +} diff --git a/src/app/visualization/vistoolbisector.h b/src/app/visualization/vistoolbisector.h new file mode 100644 index 000000000..be85db27b --- /dev/null +++ b/src/app/visualization/vistoolbisector.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vistoolbisector.h + ** @author Roman Telezhynskyi + ** @date 24 7, 2014 + ** + ** @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) 2014 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 VISTOOLBISECTOR_H +#define VISTOOLBISECTOR_H + +#include "visline.h" + +class VisToolBisector :public VisLine +{ + Q_OBJECT +public: + VisToolBisector(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolBisector(); + + virtual void RefreshGeometry(); + void setPoint2Id(const quint32 &value); + void setPoint3Id(const quint32 &value); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolBisector)}; +private: + Q_DISABLE_COPY(VisToolBisector) + quint32 point2Id; + quint32 point3Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *line1P1; + QGraphicsEllipseItem *line1P2; + QGraphicsLineItem *line1; + QGraphicsEllipseItem *line2P2; + QGraphicsLineItem *line2; + qreal length; +}; + +#endif // VISTOOLBISECTOR_H diff --git a/src/app/visualization/vistoolcurveintersectaxis.cpp b/src/app/visualization/vistoolcurveintersectaxis.cpp new file mode 100644 index 000000000..d3cabc903 --- /dev/null +++ b/src/app/visualization/vistoolcurveintersectaxis.cpp @@ -0,0 +1,104 @@ +/************************************************************************ + ** + ** @file vistoolcurveintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 "vistoolcurveintersectaxis.h" +#include "../container/vcontainer.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vtoolcurveintersectaxis.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), axisPointId(NULL_ID), angle(-1), point(nullptr), basePoint(nullptr), baseLine(nullptr), + axisLine(nullptr), visCurve(nullptr) +{ + this->mainColor = Qt::red; + + visCurve = InitItem(Qt::darkGreen, this); + basePoint = InitPoint(supportColor, this); + baseLine = InitItem(supportColor, this); + axisLine = InitItem(supportColor, this); + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCurveIntersectAxis::~VisToolCurveIntersectAxis() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCurveIntersectAxis::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer curve = Visualization::data->GeometricObject(point1Id); + DrawPath(visCurve, curve->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (axisPointId > NULL_ID) + { + QLineF axis; + const QSharedPointer first = Visualization::data->GeometricObject(axisPointId); + if (qFuzzyCompare(angle, -1)) + { + axis = Axis(first->toQPointF(), Visualization::scenePos); + } + else + { + axis = Axis(first->toQPointF(), angle); + } + DrawPoint(basePoint, first->toQPointF(), mainColor); + DrawLine(axisLine, axis, supportColor, Qt::DashLine); + + QPointF p = VToolCurveIntersectAxis::FindPoint(first->toQPointF(), axis.angle(), curve); + QLineF axis_line(first->toQPointF(), p); + DrawLine(this, axis_line, mainColor, lineStyle); + + DrawPoint(point, p, mainColor); + + Visualization::toolTip = QString(tr("Intersection curve and axis: angle = %1°; Shift - " + "sticking angle, Enter - finish creation")) + .arg(this->line().angle()); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VisToolCurveIntersectAxis::Angle() const +{ + return QString("%1").arg(this->line().angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCurveIntersectAxis::setAngle(const QString &expression) +{ + angle = FindVal(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value) +{ + axisPointId = value; +} diff --git a/src/app/visualization/vistoolcurveintersectaxis.h b/src/app/visualization/vistoolcurveintersectaxis.h new file mode 100644 index 000000000..d6481bf48 --- /dev/null +++ b/src/app/visualization/vistoolcurveintersectaxis.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file vistoolcurveintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 21 10, 2014 + ** + ** @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) 2014 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 VISTOOLCURVEINTERSECTAXIS_H +#define VISTOOLCURVEINTERSECTAXIS_H + +#include "visline.h" + +class QGraphicsEllipseItem; + +class VisToolCurveIntersectAxis : public VisLine +{ + Q_OBJECT +public: + VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolCurveIntersectAxis(); + + virtual void RefreshGeometry(); + + QString Angle() const; + void setAngle(const QString &expression); + void setAxisPointId(const quint32 &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; +private: + Q_DISABLE_COPY(VisToolCurveIntersectAxis) + quint32 axisPointId; + qreal angle; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *basePoint; + QGraphicsLineItem *baseLine; + QGraphicsLineItem *axisLine; + QGraphicsPathItem *visCurve; +}; + +#endif // VISTOOLCURVEINTERSECTAXIS_H diff --git a/src/app/visualization/vistoolcutarc.cpp b/src/app/visualization/vistoolcutarc.cpp new file mode 100644 index 000000000..ba770361e --- /dev/null +++ b/src/app/visualization/vistoolcutarc.cpp @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vistoolcutarc.cpp + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 "vistoolcutarc.h" +#include "../geometry/varc.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent) + :VisPath(data, parent), point(nullptr), arc1(nullptr), arc2(nullptr), length(0) +{ + arc1 = InitItem(Qt::darkGreen, this); + arc1->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + arc2 = InitItem(Qt::darkRed, this); + arc2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + + point = InitPoint(mainColor, this); + point->setZValue(2); + point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutArc::~VisToolCutArc() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutArc::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer arc = Visualization::data->GeometricObject(point1Id); + DrawPath(this, arc->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + VArc ar1; + VArc ar2; + QPointF p = arc->CutArc(length, ar1, ar2); + DrawPoint(point, p, mainColor); + + DrawPath(arc1, ar1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + DrawPath(arc2, ar2.GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutArc::setLength(const QString &expression) +{ + length = FindLength(expression); +} diff --git a/src/app/visualization/vistoolcutarc.h b/src/app/visualization/vistoolcutarc.h new file mode 100644 index 000000000..84aa695be --- /dev/null +++ b/src/app/visualization/vistoolcutarc.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file vistoolcutarc.h + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 VISTOOLCUTARC_H +#define VISTOOLCUTARC_H + +#include "vispath.h" + +class VisToolCutArc : public VisPath +{ + Q_OBJECT +public: + VisToolCutArc(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolCutArc(); + + virtual void RefreshGeometry(); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolCutArc)}; +protected: + Q_DISABLE_COPY(VisToolCutArc) + QGraphicsEllipseItem *point; + QGraphicsPathItem *arc1; + QGraphicsPathItem *arc2; + qreal length; +}; + +#endif // VISTOOLCUTARC_H diff --git a/src/app/visualization/vistoolcutspline.cpp b/src/app/visualization/vistoolcutspline.cpp new file mode 100644 index 000000000..204d1f740 --- /dev/null +++ b/src/app/visualization/vistoolcutspline.cpp @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vistoolcutspline.cpp + ** @author Roman Telezhynskyi + ** @date 6 9, 2014 + ** + ** @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) 2014 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 "vistoolcutspline.h" +#include "../geometry/vspline.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent) + :VisPath(data, parent), point(nullptr), spl1(nullptr), spl2(nullptr), length(0) +{ + spl1 = InitItem(Qt::darkGreen, this); + spl1->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + spl2 = InitItem(Qt::darkRed, this); + spl2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + + point = InitPoint(mainColor, this); + point->setZValue(2); + point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutSpline::~VisToolCutSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSpline::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer spl = Visualization::data->GeometricObject(point1Id); + DrawPath(this, spl->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + VSpline sp1; + VSpline sp2; + QPointF p = spl->CutSpline(length, sp1, sp2); + DrawPoint(point, p, mainColor); + + DrawPath(spl1, sp1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + DrawPath(spl2, sp2.GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSpline::setLength(const QString &expression) +{ + length = FindLength(expression); +} diff --git a/src/app/visualization/vistoolcutspline.h b/src/app/visualization/vistoolcutspline.h new file mode 100644 index 000000000..5967f3ba5 --- /dev/null +++ b/src/app/visualization/vistoolcutspline.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file vistoolcutspline.h + ** @author Roman Telezhynskyi + ** @date 6 9, 2014 + ** + ** @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) 2014 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 VISTOOLCUTSPLINE_H +#define VISTOOLCUTSPLINE_H + +#include "vispath.h" + +class VisToolCutSpline : public VisPath +{ + Q_OBJECT +public: + VisToolCutSpline(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolCutSpline(); + + virtual void RefreshGeometry(); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolCutSpline)}; +protected: + Q_DISABLE_COPY(VisToolCutSpline) + QGraphicsEllipseItem *point; + QGraphicsPathItem *spl1; + QGraphicsPathItem *spl2; + qreal length; +}; + +#endif // VISTOOLCUTSPLINE_H diff --git a/src/app/visualization/vistoolcutsplinepath.cpp b/src/app/visualization/vistoolcutsplinepath.cpp new file mode 100644 index 000000000..fcea7e2ee --- /dev/null +++ b/src/app/visualization/vistoolcutsplinepath.cpp @@ -0,0 +1,122 @@ +/************************************************************************ + ** + ** @file vistoolcutsplinepath.cpp + ** @author Roman Telezhynskyi + ** @date 7 9, 2014 + ** + ** @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) 2014 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 "vistoolcutsplinepath.h" +#include "../container/vcontainer.h" +#include "../geometry/vsplinepath.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent) + :VisPath(data, parent), point(nullptr), splPath1(nullptr), splPath2(nullptr), length(0) +{ + splPath1 = InitItem(Qt::darkGreen, this); + splPath1->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + splPath2 = InitItem(Qt::darkRed, this); + splPath2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + + point = InitPoint(mainColor, this); + point->setZValue(2); + point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolCutSplinePath::~VisToolCutSplinePath() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSplinePath::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer splPath = Visualization::data->GeometricObject(point1Id); + DrawPath(this, splPath->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + QPointF spl1p2, spl1p3, spl2p2, spl2p3; + qint32 p1 = 0, p2 = 0; + + // TODO make refactoring. CutSplPath repeat twice. Here and in VToolCutSpline. + const QPointF cutPoint = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); + VPointF p = VPointF(cutPoint); + + VSplinePoint splP1 = splPath->at(p1); + VSplinePoint splP2 = splPath->at(p2); + const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, p, splPath->getKCurve()); + const VSpline spl2 = VSpline(p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + + VSplinePath spPath1 = VSplinePath(); + VSplinePath spPath2 = VSplinePath(); + + for (qint32 i = 0; i < splPath->CountPoint(); i++) + { + if (i <= p1 && i < p2) + { + if (i == p1) + { + spPath1.append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(), + spl1.GetAngle1())); + VSplinePoint cutPoint; + cutPoint = VSplinePoint(p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(), + spl1.GetAngle2()+180); + spPath1.append(cutPoint); + continue; + } + spPath1.append(splPath->at(i)); + } + else + { + if (i == p2) + { + const VSplinePoint cutPoint = VSplinePoint(p, spl1.GetKasm2(), spl2.GetAngle1()+180, + spl2.GetKasm1(), spl2.GetAngle1()); + spPath2.append(cutPoint); + spPath2.append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(), + spl2.GetAngle2()+180)); + continue; + } + spPath2.append(splPath->at(i)); + } + } + + spPath1.setKCurve(splPath->getKCurve()); + spPath2.setKCurve(splPath->getKCurve()); + + DrawPoint(point, cutPoint, mainColor); + + DrawPath(splPath1, spPath1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + DrawPath(splPath2, spPath2.GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSplinePath::setLength(const QString &expression) +{ + length = FindLength(expression); +} diff --git a/src/app/visualization/vistoolcutsplinepath.h b/src/app/visualization/vistoolcutsplinepath.h new file mode 100644 index 000000000..6dd4bdfcb --- /dev/null +++ b/src/app/visualization/vistoolcutsplinepath.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file vistoolcutsplinepath.h + ** @author Roman Telezhynskyi + ** @date 7 9, 2014 + ** + ** @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) 2014 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 VISTOOLCUTSPLINEPATH_H +#define VISTOOLCUTSPLINEPATH_H + +#include "vispath.h" + +class VisToolCutSplinePath : public VisPath +{ + Q_OBJECT +public: + VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolCutSplinePath(); + + virtual void RefreshGeometry(); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolCutSpline)}; +protected: + Q_DISABLE_COPY(VisToolCutSplinePath) + QGraphicsEllipseItem *point; + QGraphicsPathItem *splPath1; + QGraphicsPathItem *splPath2; + qreal length; +}; + +#endif // VISTOOLCUTSPLINEPATH_H diff --git a/src/app/visualization/vistoolendline.cpp b/src/app/visualization/vistoolendline.cpp new file mode 100644 index 000000000..0bd977362 --- /dev/null +++ b/src/app/visualization/vistoolendline.cpp @@ -0,0 +1,84 @@ +/************************************************************************ + ** + ** @file vistoolendline.cpp + ** @author Roman Telezhynskyi + ** @date 21 7, 2014 + ** + ** @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) 2014 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 "vistoolendline.h" +#include "../geometry/vpointf.h" +#include "../container/vcontainer.h" +#include "../tools/vabstracttool.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VisToolEndLine::VisToolEndLine(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), length(0), angle(0), point(nullptr) +{ + this->mainColor = Qt::red; + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolEndLine::~VisToolEndLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolEndLine::RefreshGeometry() +{ + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + QLineF line; + if (qFuzzyCompare(1 + length, 1 + 0)) + { + line = QLineF(first->toQPointF(), Ray(first->toQPointF())); + } + else + { + line = VGObject::BuildLine(first->toQPointF(), length, angle); + DrawPoint(point, line.p2(), mainColor); + } + DrawLine(this, line, mainColor, lineStyle); + Visualization::toolTip = QString(tr("Point at distance and angle: angle = %1°; Shift - " + "sticking angle, Enter - finish creation")).arg(this->line().angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VisToolEndLine::Angle() const +{ + return QString("%1").arg(this->line().angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolEndLine::setAngle(const QString &expression) +{ + angle = FindVal(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolEndLine::setLength(const QString &expression) +{ + length = FindLength(expression); +} diff --git a/src/app/visualization/vistoolendline.h b/src/app/visualization/vistoolendline.h new file mode 100644 index 000000000..7b44f697f --- /dev/null +++ b/src/app/visualization/vistoolendline.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file vistoolendline.h + ** @author Roman Telezhynskyi + ** @date 21 7, 2014 + ** + ** @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) 2014 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 VISTOOLENDLINE_H +#define VISTOOLENDLINE_H + +#include "visline.h" + +class QGraphicsEllipseItem; + +class VisToolEndLine : public VisLine +{ + Q_OBJECT +public: + VisToolEndLine(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolEndLine(); + + virtual void RefreshGeometry(); + QString Angle() const; + void setAngle(const QString &expression); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolEndLine)}; +private: + Q_DISABLE_COPY(VisToolEndLine) + qreal length; + qreal angle; + QGraphicsEllipseItem *point; +}; + +#endif // VISTOOLENDLINE_H diff --git a/src/app/visualization/vistoolheight.cpp b/src/app/visualization/vistoolheight.cpp new file mode 100644 index 000000000..60f0456c0 --- /dev/null +++ b/src/app/visualization/vistoolheight.cpp @@ -0,0 +1,121 @@ +/************************************************************************ + ** + ** @file vistoolheight.cpp + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 "vistoolheight.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vtoolheight.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), lineP1Id(NULL_ID), lineP2Id(NULL_ID), point(nullptr), base_point(nullptr), lineP1(nullptr), + lineP2(nullptr), line(nullptr), line_intersection(nullptr) +{ + base_point = InitPoint(supportColor, this); + lineP1 = InitPoint(supportColor, this); + lineP2 = InitPoint(supportColor, this); + line = InitItem(supportColor, this); + line_intersection = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolHeight::~VisToolHeight() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolHeight::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(base_point, first->toQPointF(), supportColor); + + if (lineP1Id <= NULL_ID) + { + DrawLine(this, QLineF(first->toQPointF(), Visualization::scenePos), mainColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); + DrawPoint(lineP1, second->toQPointF(), supportColor); + + QLineF base_line; + if (lineP2Id <= NULL_ID) + { + base_line = QLineF(second->toQPointF(), Visualization::scenePos); + DrawLine(line, base_line, supportColor); + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); + DrawPoint(lineP2, third->toQPointF(), supportColor); + + base_line = QLineF(second->toQPointF(), third->toQPointF()); + } + + DrawLine(line, base_line, supportColor); + + QPointF height = VToolHeight::FindPoint(base_line, first->toQPointF()); + DrawPoint(point, height, mainColor); + + QLineF height_line(first->toQPointF(), height); + DrawLine(this, height_line, mainColor, lineStyle); + + ShowIntersection(height_line, base_line); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolHeight::setLineP1Id(const quint32 &value) +{ + lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolHeight::setLineP2Id(const quint32 &value) +{ + lineP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line) +{ + QPointF p; + QLineF::IntersectType intersect = height_line.intersect(base_line, &p); + if (intersect == QLineF::UnboundedIntersection) + { + line_intersection->setVisible(true); + DrawLine(line_intersection, QLineF(base_line.p1(), height_line.p2()), supportColor, Qt::DashLine); + } + else if (intersect == QLineF::BoundedIntersection) + { + line_intersection->setVisible(false); + } +} diff --git a/src/app/visualization/vistoolheight.h b/src/app/visualization/vistoolheight.h new file mode 100644 index 000000000..0b17b78bb --- /dev/null +++ b/src/app/visualization/vistoolheight.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file vistoolheight.h + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 VISTOOLHEIGHT_H +#define VISTOOLHEIGHT_H + +#include "visline.h" + +class VisToolHeight : public VisLine +{ + Q_OBJECT +public: + VisToolHeight(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolHeight(); + + virtual void RefreshGeometry(); + + void setLineP1Id(const quint32 &value); + void setLineP2Id(const quint32 &value); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolHeight)}; +private: + Q_DISABLE_COPY(VisToolHeight) + //base point in parent class + quint32 lineP1Id;//first point of line + quint32 lineP2Id;//second point of line + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *base_point; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP2; + QGraphicsLineItem *line; + QGraphicsLineItem *line_intersection; + void ShowIntersection(const QLineF &height_line, const QLineF &base_line); +}; + +#endif // VISTOOLHEIGHT_H diff --git a/src/app/visualization/vistoolline.cpp b/src/app/visualization/vistoolline.cpp new file mode 100644 index 000000000..edcd4e763 --- /dev/null +++ b/src/app/visualization/vistoolline.cpp @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file vgraphicslineitem.cpp + ** @author Roman Telezhynskyi + ** @date 15 7, 2014 + ** + ** @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) 2014 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 "vistoolline.h" +#include "../container/vcontainer.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vdrawtool.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLine::VisToolLine(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), point2Id(NULL_ID) +{ + this->mainColor = Qt::red; +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLine::~VisToolLine() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLine::RefreshGeometry() +{ + QLineF line; + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + if (point2Id == NULL_ID) + { + line = QLineF(first->toQPointF(), Visualization::scenePos); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + line = QLineF(first->toQPointF(), second->toQPointF()); + } + DrawLine(this, line, mainColor, lineStyle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLine::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style) +{ + SCASSERT (lineItem != nullptr); + + lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style)); + lineItem->setLine(line); +} diff --git a/src/app/visualization/vistoolline.h b/src/app/visualization/vistoolline.h new file mode 100644 index 000000000..b46c1a49c --- /dev/null +++ b/src/app/visualization/vistoolline.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file vgraphicslineitem.h + ** @author Roman Telezhynskyi + ** @date 15 7, 2014 + ** + ** @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) 2014 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 VGRAPHICSLINEITEM_H +#define VGRAPHICSLINEITEM_H + +#include "visline.h" + +class VisToolLine : public VisLine +{ + Q_OBJECT +public: + VisToolLine(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolLine(); + + virtual void RefreshGeometry(); + void setPoint2Id(const quint32 &value); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolLine)}; +protected: + virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); +private: + Q_DISABLE_COPY(VisToolLine) + quint32 point2Id; +}; + +#endif // VGRAPHICSLINEITEM_H diff --git a/src/app/visualization/vistoollineintersect.cpp b/src/app/visualization/vistoollineintersect.cpp new file mode 100644 index 000000000..8b732e55a --- /dev/null +++ b/src/app/visualization/vistoollineintersect.cpp @@ -0,0 +1,130 @@ +/************************************************************************ + ** + ** @file vistoollineintersect.cpp + ** @author Roman Telezhynskyi + ** @date 14 8, 2014 + ** + ** @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) 2014 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 "vistoollineintersect.h" +#include "../geometry/vpointf.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), line1P2Id(NULL_ID), line2P1Id(NULL_ID), line2P2Id(NULL_ID), point(nullptr), + line1P1(nullptr), line1P2(nullptr), line1(nullptr), line2P1(nullptr), line2P2(nullptr) +{ + line1P1 = InitPoint(supportColor, this); + line1P2 = InitPoint(supportColor, this); + line1 = InitItem(supportColor, this); + + line2P1 = InitPoint(supportColor, this); + line2P2 = InitPoint(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLineIntersect::~VisToolLineIntersect() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersect::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(line1P1, first->toQPointF(), supportColor); + + if (line1P2Id <= NULL_ID) + { + DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(line1P2Id); + DrawPoint(line1P2, second->toQPointF(), supportColor); + + DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (line2P1Id <= NULL_ID) + { + return; + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(line2P1Id); + DrawPoint(line2P1, third->toQPointF(), supportColor); + + if (line2P2Id <= NULL_ID) + { + DrawLine(this, QLineF(third->toQPointF(), Visualization::scenePos), supportColor); + + QLineF l1(first->toQPointF(), second->toQPointF()); + QLineF l2(third->toQPointF(), Visualization::scenePos); + QPointF fPoint; + QLineF::IntersectType intersect = l1.intersect(l2, &fPoint); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + DrawPoint(point, fPoint, mainColor); + } + } + else + { + const QSharedPointer forth = Visualization::data->GeometricObject(line2P2Id); + DrawPoint(line2P2, forth->toQPointF(), supportColor); + + DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor); + + QLineF l1(first->toQPointF(), second->toQPointF()); + QLineF l2(third->toQPointF(), forth->toQPointF()); + QPointF fPoint; + QLineF::IntersectType intersect = l1.intersect(l2, &fPoint); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + DrawPoint(point, fPoint, mainColor); + } + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersect::setLine1P2Id(const quint32 &value) +{ + line1P2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersect::setLine2P1Id(const quint32 &value) +{ + line2P1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersect::setLine2P2Id(const quint32 &value) +{ + line2P2Id = value; +} diff --git a/src/app/visualization/vistoollineintersect.h b/src/app/visualization/vistoollineintersect.h new file mode 100644 index 000000000..b69d03ff7 --- /dev/null +++ b/src/app/visualization/vistoollineintersect.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file vistoollineintersect.h + ** @author Roman Telezhynskyi + ** @date 14 8, 2014 + ** + ** @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) 2014 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 VISTOOLLINEINTERSECT_H +#define VISTOOLLINEINTERSECT_H + +#include "visline.h" + +class VisToolLineIntersect :public VisLine +{ + Q_OBJECT +public: + VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolLineIntersect(); + + virtual void RefreshGeometry(); + + void setLine1P2Id(const quint32 &value); + void setLine2P1Id(const quint32 &value); + void setLine2P2Id(const quint32 &value); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolLineIntersect)}; +private: + Q_DISABLE_COPY(VisToolLineIntersect) + quint32 line1P2Id; + quint32 line2P1Id; + quint32 line2P2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *line1P1; + QGraphicsEllipseItem *line1P2; + QGraphicsLineItem *line1; + QGraphicsEllipseItem *line2P1; + QGraphicsEllipseItem *line2P2; +}; + +#endif // VISTOOLLINEINTERSECT_H diff --git a/src/app/visualization/vistoollineintersectaxis.cpp b/src/app/visualization/vistoollineintersectaxis.cpp new file mode 100644 index 000000000..371d46cad --- /dev/null +++ b/src/app/visualization/vistoollineintersectaxis.cpp @@ -0,0 +1,142 @@ +/************************************************************************ + ** + ** @file vislineintersectaxis.cpp + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 "vistoollineintersectaxis.h" +#include "../container/vcontainer.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vtoollineintersectaxis.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), point2Id(NULL_ID), axisPointId(NULL_ID), angle(-1), point(nullptr), lineP1(nullptr), + lineP2(nullptr), basePoint(nullptr), baseLine(nullptr), axisLine(nullptr), line_intersection(nullptr) +{ + this->mainColor = Qt::red; + + lineP1 = InitPoint(supportColor, this); + lineP2 = InitPoint(supportColor, this); + basePoint = InitPoint(supportColor, this); + baseLine = InitItem(supportColor, this); + axisLine = InitItem(supportColor, this); + line_intersection = InitItem(supportColor, this); + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolLineIntersectAxis::~VisToolLineIntersectAxis() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersectAxis::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(lineP1, first->toQPointF(), supportColor); + + if (point2Id <= NULL_ID) + { + DrawLine(baseLine, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(lineP2, second->toQPointF(), supportColor); + + const QLineF base_line(first->toQPointF(), second->toQPointF()); + DrawLine(baseLine, base_line, supportColor); + + if (axisPointId > NULL_ID) + { + QLineF axis; + const QSharedPointer third = Visualization::data->GeometricObject(axisPointId); + if (qFuzzyCompare(angle, -1)) + { + axis = Axis(third->toQPointF(), Visualization::scenePos); + } + else + { + axis = Axis(third->toQPointF(), angle); + } + DrawPoint(basePoint, third->toQPointF(), mainColor); + DrawLine(axisLine, axis, supportColor, Qt::DashLine); + + QPointF p = VToolLineIntersectAxis::FindPoint(axis, base_line); + QLineF axis_line(third->toQPointF(), p); + DrawLine(this, axis_line, mainColor, lineStyle); + + DrawPoint(point, p, mainColor); + ShowIntersection(axis_line, base_line); + + Visualization::toolTip = QString(tr("Intersection line and axis: angle = %1°; Shift - " + "sticking angle, Enter - finish creation")) + .arg(this->line().angle()); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VisToolLineIntersectAxis::Angle() const +{ + return QString("%1").arg(this->line().angle()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersectAxis::setAngle(const QString &expression) +{ + angle = FindVal(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersectAxis::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value) +{ + axisPointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line) +{ + QPointF p; + QLineF::IntersectType intersect = axis_line.intersect(base_line, &p); + if (intersect == QLineF::UnboundedIntersection) + { + line_intersection->setVisible(true); + DrawLine(line_intersection, QLineF(base_line.p1(), axis_line.p2()), supportColor, Qt::DashLine); + } + else if (intersect == QLineF::BoundedIntersection || intersect == QLineF::NoIntersection) + { + line_intersection->setVisible(false); + } +} diff --git a/src/app/visualization/vistoollineintersectaxis.h b/src/app/visualization/vistoollineintersectaxis.h new file mode 100644 index 000000000..f9f0f370e --- /dev/null +++ b/src/app/visualization/vistoollineintersectaxis.h @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file vistoollineintersectaxis.h + ** @author Roman Telezhynskyi + ** @date 19 10, 2014 + ** + ** @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) 2014 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 VISTOOLLINEINTERSECTAXIS_H +#define VISTOOLLINEINTERSECTAXIS_H + +#include "visline.h" + +class QGraphicsEllipseItem; + +class VisToolLineIntersectAxis : public VisLine +{ + Q_OBJECT +public: + VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolLineIntersectAxis(); + + virtual void RefreshGeometry(); + + QString Angle() const; + void setAngle(const QString &expression); + void setPoint2Id(const quint32 &value); + void setAxisPointId(const quint32 &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; +private: + Q_DISABLE_COPY(VisToolLineIntersectAxis) + quint32 point2Id; + quint32 axisPointId; + qreal angle; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP2; + QGraphicsEllipseItem *basePoint; + QGraphicsLineItem *baseLine; + QGraphicsLineItem *axisLine; + QGraphicsLineItem *line_intersection; + void ShowIntersection(const QLineF &axis_line, const QLineF &base_line); +}; + +#endif // VISTOOLLINEINTERSECTAXIS_H diff --git a/src/app/visualization/vistoolnormal.cpp b/src/app/visualization/vistoolnormal.cpp new file mode 100644 index 000000000..e9b5402c5 --- /dev/null +++ b/src/app/visualization/vistoolnormal.cpp @@ -0,0 +1,116 @@ +/************************************************************************ + ** + ** @file vistoolnormal.cpp + ** @author Roman Telezhynskyi + ** @date 12 8, 2014 + ** + ** @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) 2014 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 "vistoolnormal.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vtoolnormal.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), + length(0), angle(0) +{ + this->mainColor = Qt::red; + + lineP1 = InitPoint(supportColor, this); + lineP2 = InitPoint(supportColor, this); + line = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolNormal::~VisToolNormal() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolNormal::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(lineP1, first->toQPointF(), supportColor); + + if (point2Id <= NULL_ID) + { + QLineF line_mouse(first->toQPointF(), Visualization::scenePos); + DrawLine(line, line_mouse, supportColor); + + QLineF normal = line_mouse.normalVector(); + QPointF endRay = Ray(normal.p1(), normal.angle()); + DrawLine(this, QLineF(normal.p1(), endRay), mainColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(lineP2, second->toQPointF(), supportColor); + + QLineF line_mouse(first->toQPointF(), second->toQPointF()); + DrawLine(line, line_mouse, supportColor); + + if (qFuzzyCompare(1 + length, 1 + 0)) + { + QLineF normal = line_mouse.normalVector(); + QPointF endRay = Ray(normal.p1(), normal.angle()); + DrawLine(this, QLineF(normal.p1(), endRay), mainColor); + } + else + { + QPointF fPoint = VToolNormal::FindPoint(first->toQPointF(), second->toQPointF(), length, angle); + QLineF mainLine = QLineF(first->toQPointF(), fPoint); + DrawLine(this, mainLine, mainColor, lineStyle); + + DrawPoint(point, mainLine.p2(), mainColor); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolNormal::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolNormal::setLength(const QString &expression) +{ + length = FindLength(expression); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VisToolNormal::getAngle() const +{ + return angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolNormal::setAngle(const qreal &value) +{ + angle = value; +} diff --git a/src/app/visualization/vistoolnormal.h b/src/app/visualization/vistoolnormal.h new file mode 100644 index 000000000..1593d03f5 --- /dev/null +++ b/src/app/visualization/vistoolnormal.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file vistoolnormal.h + ** @author Roman Telezhynskyi + ** @date 12 8, 2014 + ** + ** @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) 2014 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 VISTOOLNORMAL_H +#define VISTOOLNORMAL_H + +#include "visline.h" + +class VisToolNormal : public VisLine +{ + Q_OBJECT +public: + VisToolNormal(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolNormal(); + + virtual void RefreshGeometry(); + + void setPoint2Id(const quint32 &value); + void setLength(const QString &expression); + qreal getAngle() const; + void setAngle(const qreal &value); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolNormal)}; +private: + Q_DISABLE_COPY(VisToolNormal) + quint32 point2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP2; + QGraphicsLineItem *line; + qreal length; + qreal angle; + +}; + +#endif // VISTOOLNORMAL_H diff --git a/src/app/visualization/vistoolpointofcontact.cpp b/src/app/visualization/vistoolpointofcontact.cpp new file mode 100644 index 000000000..e1db720eb --- /dev/null +++ b/src/app/visualization/vistoolpointofcontact.cpp @@ -0,0 +1,107 @@ +/************************************************************************ + ** + ** @file vistoolpointofcontact.cpp + ** @author Roman Telezhynskyi + ** @date 14 8, 2014 + ** + ** @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) 2014 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 "vistoolpointofcontact.h" +#include "../geometry/vpointf.h" +#include "../tools/drawTools/vtoolpointofcontact.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), lineP2Id(NULL_ID), radiusId(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), + arc_point(nullptr), circle(nullptr), radius(0) +{ + arc_point = InitPoint(supportColor, this); + lineP1 = InitPoint(supportColor, this); + lineP2 = InitPoint(supportColor, this); + circle = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfContact::~VisToolPointOfContact() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfContact::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(lineP1, first->toQPointF(), supportColor); + + if (lineP2Id <= NULL_ID) + { + DrawLine(this, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(lineP2Id); + DrawPoint(lineP2, second->toQPointF(), supportColor); + DrawLine(this, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (radiusId <= NULL_ID) + { + return; + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(radiusId); + DrawPoint(arc_point, third->toQPointF(), supportColor); + + if (qFuzzyCompare(1 + radius, 1 + 0) == false) + { + QPointF fPoint = VToolPointOfContact::FindPoint(radius, third->toQPointF(), first->toQPointF(), + second->toQPointF()); + DrawPoint(point, fPoint, mainColor); + + circle->setRect(PointRect(radius)); + DrawPoint(circle, third->toQPointF(), supportColor, Qt::DashLine); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfContact::setLineP2Id(const quint32 &value) +{ + lineP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfContact::setRadiusId(const quint32 &value) +{ + radiusId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfContact::setRadius(const QString &expression) +{ + radius = FindLength(expression); +} diff --git a/src/app/visualization/vistoolpointofcontact.h b/src/app/visualization/vistoolpointofcontact.h new file mode 100644 index 000000000..4edc79ea0 --- /dev/null +++ b/src/app/visualization/vistoolpointofcontact.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vistoolpointofcontact.h + ** @author Roman Telezhynskyi + ** @date 14 8, 2014 + ** + ** @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) 2014 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 VISTOOLPOINTOFCONTACT_H +#define VISTOOLPOINTOFCONTACT_H + +#include "visline.h" + +class VisToolPointOfContact : public VisLine +{ + Q_OBJECT +public: + VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolPointOfContact(); + + virtual void RefreshGeometry(); + void setLineP2Id(const quint32 &value); + void setRadiusId(const quint32 &value); + void setRadius(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPointOfContact)}; +private: + Q_DISABLE_COPY(VisToolPointOfContact) + quint32 lineP2Id; + quint32 radiusId; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP2; + QGraphicsEllipseItem *arc_point; + QGraphicsEllipseItem *circle; + qreal radius; + +}; + +#endif // VISTOOLPOINTOFCONTACT_H diff --git a/src/app/visualization/vistoolpointofintersection.cpp b/src/app/visualization/vistoolpointofintersection.cpp new file mode 100644 index 000000000..85c84af8a --- /dev/null +++ b/src/app/visualization/vistoolpointofintersection.cpp @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersection.cpp + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 "vistoolpointofintersection.h" +#include "../geometry/vpointf.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), axisP1(nullptr), axisP2(nullptr), axis2(nullptr) +{ + axisP1 = InitPoint(supportColor, this); + axisP2 = InitPoint(supportColor, this); + axis2 = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfIntersection::~VisToolPointOfIntersection() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersection::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(axisP1, first->toQPointF(), supportColor); + + QLineF axisL1 = Axis(first->toQPointF(), 90); + DrawLine(this, axisL1, supportColor, Qt::DashLine); + + QLineF axisL2; + if (point2Id <= NULL_ID) + { + axisL2 = Axis(Visualization::scenePos, 180); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(axisP2, second->toQPointF(), supportColor); + axisL2 = Axis(second->toQPointF(), 180); + ShowIntersection(axisL1, axisL2); + } + DrawLine(axis2, axisL2, supportColor, Qt::DashLine); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersection::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2) +{ + QPointF p; + QLineF::IntersectType intersect = axis1.intersect(axis2, &p); + if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) + { + point->setVisible(true); + DrawPoint(point, p, mainColor); + } + else + { + point->setVisible(false); + } +} diff --git a/src/app/visualization/vistoolpointofintersection.h b/src/app/visualization/vistoolpointofintersection.h new file mode 100644 index 000000000..a2c594f75 --- /dev/null +++ b/src/app/visualization/vistoolpointofintersection.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersection.h + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 VISTOOLPOINTOFINTERSECTION_H +#define VISTOOLPOINTOFINTERSECTION_H + +#include "visline.h" + +class VisToolPointOfIntersection : public VisLine +{ + Q_OBJECT +public: + VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolPointOfIntersection(); + + virtual void RefreshGeometry(); + + void setPoint2Id(const quint32 &value); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; +private: + Q_DISABLE_COPY(VisToolPointOfIntersection) + quint32 point2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *axisP1;//axis1 is class themself + QGraphicsEllipseItem *axisP2; + QGraphicsLineItem *axis2;//axis1 is class themself + + void ShowIntersection(const QLineF &axis1, const QLineF &axis2); +}; + +#endif // VISTOOLPOINTOFINTERSECTION_H diff --git a/src/app/visualization/vistoolshoulderpoint.cpp b/src/app/visualization/vistoolshoulderpoint.cpp new file mode 100644 index 000000000..c6863176a --- /dev/null +++ b/src/app/visualization/vistoolshoulderpoint.cpp @@ -0,0 +1,122 @@ +/************************************************************************ + ** + ** @file vistoolshoulderpoint.cpp + ** @author Roman Telezhynskyi + ** @date 25 7, 2014 + ** + ** @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) 2014 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 "vistoolshoulderpoint.h" +#include "../tools/drawTools/vtoolshoulderpoint.h" +#include "../geometry/vpointf.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), lineP1Id(NULL_ID), lineP2Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), + line1(nullptr), line2P2(nullptr), line2(nullptr), line3(nullptr), length(0) +{ + line1P1 = InitPoint(supportColor, this); + line1P2 = InitPoint(supportColor, this); + line1 = InitItem(supportColor, this); + + line2P2 = InitPoint(supportColor, this); + line2 = InitItem(supportColor, this); + line3 = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolShoulderPoint::~VisToolShoulderPoint() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolShoulderPoint::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(line1P1, first->toQPointF(), supportColor); + + if (lineP1Id <= NULL_ID) + { + DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); + DrawPoint(line1P2, second->toQPointF(), supportColor); + + DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (lineP2Id <= NULL_ID) + { + DrawLine(line2, QLineF(second->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); + DrawPoint(line2P2, third->toQPointF(), supportColor); + + DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor); + + if (qFuzzyCompare(1 + length, 1 + 0) == false) + { + QPointF fPoint = VToolShoulderPoint::FindPoint(second->toQPointF(), third->toQPointF(), + first->toQPointF(), length); + QLineF mainLine = QLineF(second->toQPointF(), fPoint); + DrawLine(this, mainLine, mainColor, lineStyle); + + DrawPoint(point, mainLine.p2(), mainColor); + DrawLine(line3, QLineF(first->toQPointF(), mainLine.p2()), supportColor, Qt::DashLine); + } + else + { + qreal angle = QLineF(second->toQPointF(), third->toQPointF()).angle(); + QPointF endRay = Ray(second->toQPointF(), angle); + QLineF mainLine = VGObject::BuildLine(second->toQPointF(), + QLineF(second->toQPointF(), endRay).length(), angle); + DrawLine(this, mainLine, mainColor, lineStyle); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolShoulderPoint::setLineP1Id(const quint32 &value) +{ + lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolShoulderPoint::setLineP2Id(const quint32 &value) +{ + lineP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolShoulderPoint::setLength(const QString &expression) +{ + length = FindLength(expression); +} diff --git a/src/app/visualization/vistoolshoulderpoint.h b/src/app/visualization/vistoolshoulderpoint.h new file mode 100644 index 000000000..bfda38bc5 --- /dev/null +++ b/src/app/visualization/vistoolshoulderpoint.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file vistoolshoulderpoint.h + ** @author Roman Telezhynskyi + ** @date 25 7, 2014 + ** + ** @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) 2014 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 VISTOOLSHOULDERPOINT_H +#define VISTOOLSHOULDERPOINT_H + +#include "visline.h" + +class VisToolShoulderPoint : public VisLine +{ + Q_OBJECT +public: + VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolShoulderPoint(); + + virtual void RefreshGeometry(); + void setLineP1Id(const quint32 &value); + void setLineP2Id(const quint32 &value); + void setLength(const QString &expression); + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolShoulderPoint)}; +private: + Q_DISABLE_COPY(VisToolShoulderPoint) + quint32 lineP1Id; + quint32 lineP2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *line1P1; + QGraphicsEllipseItem *line1P2; + QGraphicsLineItem *line1; + QGraphicsEllipseItem *line2P2; + QGraphicsLineItem *line2; + QGraphicsLineItem *line3; + qreal length; +}; + +#endif // VISTOOLSHOULDERPOINT_H diff --git a/src/app/visualization/vistoolspline.cpp b/src/app/visualization/vistoolspline.cpp new file mode 100644 index 000000000..92562e751 --- /dev/null +++ b/src/app/visualization/vistoolspline.cpp @@ -0,0 +1,114 @@ +/************************************************************************ + ** + ** @file vistoolspline.cpp + ** @author Roman Telezhynskyi + ** @date 18 8, 2014 + ** + ** @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) 2014 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 "vistoolspline.h" +#include "../geometry/vpointf.h" +#include "../geometry/vspline.h" +#include "../container/vcontainer.h" + +const int EMPTY_ANGLE = -1; + +//--------------------------------------------------------------------------------------------------------------------- +VisToolSpline::VisToolSpline(const VContainer *data, QGraphicsItem *parent) + : VisPath(data, parent), point4Id(NULL_ID), lineP1(nullptr), lineP4(nullptr), line(nullptr), angle1(EMPTY_ANGLE), + angle2(EMPTY_ANGLE), kAsm1(1), kAsm2(1), kCurve(1) +{ + lineP1 = InitPoint(supportColor, this); + lineP4 = InitPoint(supportColor, this); + line = InitItem(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolSpline::~VisToolSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(lineP1, first->toQPointF(), supportColor); + + if (point4Id <= NULL_ID) + { + DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), mainColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point4Id); + DrawPoint(lineP4, second->toQPointF(), supportColor); + + if (qFuzzyCompare(angle1, EMPTY_ANGLE) || qFuzzyCompare(angle2, EMPTY_ANGLE)) + { + DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), mainColor); + } + else + { + VSpline spline(*first, *second, angle1, angle2, kAsm1, kAsm2, kCurve); + DrawPath(this, spline.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setPoint4Id(const quint32 &value) +{ + point4Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setAngle1(const qreal &value) +{ + angle1 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setAngle2(const qreal &value) +{ + angle2 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setKAsm1(const qreal &value) +{ + kAsm1 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setKAsm2(const qreal &value) +{ + kAsm2 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpline::setKCurve(const qreal &value) +{ + kCurve = value; +} diff --git a/src/app/visualization/vistoolspline.h b/src/app/visualization/vistoolspline.h new file mode 100644 index 000000000..56c12d021 --- /dev/null +++ b/src/app/visualization/vistoolspline.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file vistoolspline.h + ** @author Roman Telezhynskyi + ** @date 18 8, 2014 + ** + ** @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) 2014 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 VISTOOLSPLINE_H +#define VISTOOLSPLINE_H + +#include "vispath.h" + +class VisToolSpline : public VisPath +{ + Q_OBJECT +public: + VisToolSpline(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolSpline(); + + virtual void RefreshGeometry(); + + void setPoint4Id(const quint32 &value); + void setAngle1(const qreal &value); + void setAngle2(const qreal &value); + void setKAsm1(const qreal &value); + void setKAsm2(const qreal &value); + void setKCurve(const qreal &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolSpline)}; +protected: + Q_DISABLE_COPY(VisToolSpline) + quint32 point4Id; + QGraphicsEllipseItem *lineP1; + QGraphicsEllipseItem *lineP4; + QGraphicsLineItem *line; + qreal angle1; + qreal angle2; + qreal kAsm1; + qreal kAsm2; + qreal kCurve; +}; + +#endif // VISTOOLSPLINE_H diff --git a/src/app/visualization/vistoolsplinepath.cpp b/src/app/visualization/vistoolsplinepath.cpp new file mode 100644 index 000000000..108f73c54 --- /dev/null +++ b/src/app/visualization/vistoolsplinepath.cpp @@ -0,0 +1,135 @@ +/************************************************************************ + ** + ** @file vistoolsplinepath.cpp + ** @author Roman Telezhynskyi + ** @date 7 9, 2014 + ** + ** @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) 2014 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 "vistoolsplinepath.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent) + : VisPath(data, parent), points(QVector()), line(nullptr), path(VSplinePath()), + mode(Mode::Creation) +{ + line = InitItem(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolSplinePath::~VisToolSplinePath() +{ + qDeleteAll(points.begin(), points.end()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSplinePath::RefreshGeometry() +{ + if (path.CountPoint() > 0) + { + QVector pathPoints = path.GetSplinePath(); + if (path.CountPoint() == 1) + { + QGraphicsEllipseItem *point = this->getPoint(0); + DrawPoint(point, pathPoints.at(0).P().toQPointF(), supportColor); + + if (mode == Mode::Creation) + { + QLineF sceneLine = QLineF(pathPoints.at(0).P().toQPointF(), Visualization::scenePos); + DrawLine(line, sceneLine, mainColor, lineStyle); + + path[0].SetAngle2(sceneLine.angle()); + emit PathChanged(path); + } + } + else + { + for (int i = 0; i < pathPoints.size(); ++i) + { + QGraphicsEllipseItem *point = this->getPoint(static_cast(i)); + DrawPoint(point, pathPoints.at(i).P().toQPointF(), supportColor); + } + + if (mode == Mode::Creation) + { + QLineF sceneLine = QLineF(pathPoints.at(pathPoints.size() - 1).P().toQPointF(), + Visualization::scenePos); + DrawLine(line, sceneLine, mainColor, lineStyle); + + path[pathPoints.size() - 1].SetAngle2(sceneLine.angle()); + emit PathChanged(path); + } + + DrawPath(this, path.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap); + } + if (path.CountPoint() < 3) + { + Visualization::toolTip = tr("Curved path: select three or more points"); + } + else + { + Visualization::toolTip = tr("Curved path: select three or more points, " + "Enter - finish creation"); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSplinePath::setPath(const VSplinePath &value) +{ + path = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +VSplinePath VisToolSplinePath::getPath() +{ + return path; +} + +//--------------------------------------------------------------------------------------------------------------------- +Mode VisToolSplinePath::getMode() const +{ + return mode; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSplinePath::setMode(const Mode &value) +{ + mode = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGraphicsEllipseItem *VisToolSplinePath::getPoint(unsigned int i) +{ + if (static_cast(points.size() - 1) >= i && points.isEmpty() == false) + { + return points.at(static_cast(i)); + } + else + { + QGraphicsEllipseItem * point = InitPoint(supportColor, this); + points.append(point); + return point; + } + return nullptr; +} diff --git a/src/app/visualization/vistoolsplinepath.h b/src/app/visualization/vistoolsplinepath.h new file mode 100644 index 000000000..be9dc2b3c --- /dev/null +++ b/src/app/visualization/vistoolsplinepath.h @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file vistoolsplinepath.h + ** @author Roman Telezhynskyi + ** @date 7 9, 2014 + ** + ** @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) 2014 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 VISTOOLSPLINEPATH_H +#define VISTOOLSPLINEPATH_H + +#include "vispath.h" +#include "../geometry/vsplinepath.h" + +enum class Mode : char {Creation, Show}; + +class VisToolSplinePath : public VisPath +{ + Q_OBJECT +public: + VisToolSplinePath(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolSplinePath(); + + virtual void RefreshGeometry(); + + void setPath(const VSplinePath &value); + VSplinePath getPath(); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolSplinePath)}; + + Mode getMode() const; + void setMode(const Mode &value); +signals: + void PathChanged(const VSplinePath &path); + +protected: + Q_DISABLE_COPY(VisToolSplinePath) + QVector points; + QGraphicsLineItem *line; + VSplinePath path; + Mode mode; + + QGraphicsEllipseItem * getPoint(unsigned int i); +}; + +#endif // VISTOOLSPLINEPATH_H diff --git a/src/app/visualization/vistooltriangle.cpp b/src/app/visualization/vistooltriangle.cpp new file mode 100644 index 000000000..d646a9056 --- /dev/null +++ b/src/app/visualization/vistooltriangle.cpp @@ -0,0 +1,185 @@ +/************************************************************************ + ** + ** @file vistooltriangle.cpp + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 "vistooltriangle.h" +#include "../geometry/vpointf.h" +#include "../container/vcontainer.h" +#include "../tools/drawTools/vtooltriangle.h" +#include + +//--------------------------------------------------------------------------------------------------------------------- +VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent) + :VisLine(data, parent), point2Id(NULL_ID), hypotenuseP1Id(NULL_ID), hypotenuseP2Id(NULL_ID), point(nullptr), + axisP1(nullptr), axisP2(nullptr), axis(nullptr), hypotenuseP1(nullptr), hypotenuseP2(nullptr), foot1(nullptr), + foot2(nullptr) +{ + axisP1 = InitPoint(supportColor, this); + axisP2 = InitPoint(supportColor, this); + axis = InitItem(supportColor, this); + hypotenuseP1 = InitPoint(supportColor, this); + hypotenuseP2 = InitPoint(supportColor, this); + foot1 = InitItem(supportColor, this); + foot2 = InitItem(supportColor, this); + + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolTriangle::~VisToolTriangle() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::RefreshGeometry() +{ + if (point1Id > NULL_ID) + { + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + DrawPoint(axisP1, first->toQPointF(), supportColor); + + if (point2Id <= NULL_ID) + { + DrawAimedAxis(axis, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); + } + else + { + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + DrawPoint(axisP2, second->toQPointF(), supportColor); + + DrawAimedAxis(axis, QLineF(first->toQPointF(), second->toQPointF()), supportColor); + + if (hypotenuseP1Id <= NULL_ID) + { + return; + } + else + { + const QSharedPointer third = Visualization::data->GeometricObject(hypotenuseP1Id); + DrawPoint(hypotenuseP1, third->toQPointF(), supportColor); + + if (hypotenuseP2Id <= NULL_ID) + { + DrawLine(this, QLineF(third->toQPointF(), Visualization::scenePos), supportColor, Qt::DashLine); + + QPointF trPoint = VToolTriangle::FindPoint(first->toQPointF(), second->toQPointF(), + third->toQPointF(), Visualization::scenePos); + DrawPoint(point, trPoint, mainColor); + + DrawLine(foot1, QLineF(third->toQPointF(), trPoint), supportColor, Qt::DashLine); + DrawLine(foot2, QLineF(Visualization::scenePos, trPoint), supportColor, Qt::DashLine); + } + else + { + const QSharedPointer forth = Visualization::data->GeometricObject(hypotenuseP2Id); + DrawPoint(hypotenuseP2, forth->toQPointF(), supportColor); + + DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor, Qt::DashLine); + + QPointF trPoint = VToolTriangle::FindPoint(first->toQPointF(), second->toQPointF(), + third->toQPointF(), forth->toQPointF()); + DrawPoint(point, trPoint, mainColor); + + DrawLine(foot1, QLineF(third->toQPointF(), trPoint), supportColor, Qt::DashLine); + DrawLine(foot2, QLineF(forth->toQPointF(), trPoint), supportColor, Qt::DashLine); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::setPoint2Id(const quint32 &value) +{ + point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::setHypotenuseP1Id(const quint32 &value) +{ + hypotenuseP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::setHypotenuseP2Id(const quint32 &value) +{ + hypotenuseP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color, + Qt::PenStyle style) +{ + SCASSERT (item != nullptr); + + item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, style)); + + QPainterPath path; + path.moveTo(line.p1()); + path.lineTo(line.p2()); + + qreal arrow_step = 60/factor; + qreal arrow_size = 10/factor; + + if (line.length() < arrow_step) + { + DrawArrow(line, path, arrow_size); + } + + QLineF axis; + axis.setP1(line.p1()); + axis.setAngle(line.angle()); + axis.setLength(arrow_step); + + int steps = qFloor(line.length()/arrow_step); + for (int i=0; isetPath(path); + item->setVisible(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolTriangle::DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size) +{ + QLineF arrowPart1; + arrowPart1.setP1(axis.p2()); + arrowPart1.setLength(arrow_size); + arrowPart1.setAngle(axis.angle()+180+35); + + path.moveTo(arrowPart1.p1()); + path.lineTo(arrowPart1.p2()); + + QLineF arrowPart2; + arrowPart2.setP1(axis.p2()); + arrowPart2.setLength(arrow_size); + arrowPart2.setAngle(axis.angle()+180-35); + + path.moveTo(arrowPart2.p1()); + path.lineTo(arrowPart2.p2()); +} diff --git a/src/app/visualization/vistooltriangle.h b/src/app/visualization/vistooltriangle.h new file mode 100644 index 000000000..a15defaf7 --- /dev/null +++ b/src/app/visualization/vistooltriangle.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vistooltriangle.h + ** @author Roman Telezhynskyi + ** @date 13 8, 2014 + ** + ** @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) 2014 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 VISTOOLTRIANGLE_H +#define VISTOOLTRIANGLE_H + +#include "visline.h" + +class VisToolTriangle : public VisLine +{ + Q_OBJECT +public: + VisToolTriangle(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolTriangle(); + + virtual void RefreshGeometry(); + + void setPoint2Id(const quint32 &value); + void setHypotenuseP1Id(const quint32 &value); + void setHypotenuseP2Id(const quint32 &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolTriangle)}; +private: + Q_DISABLE_COPY(VisToolTriangle) + quint32 point2Id;//axis second point + quint32 hypotenuseP1Id; + quint32 hypotenuseP2Id; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *axisP1; + QGraphicsEllipseItem *axisP2; + QGraphicsPathItem *axis; + QGraphicsEllipseItem *hypotenuseP1; + QGraphicsEllipseItem *hypotenuseP2; + QGraphicsLineItem *foot1; + QGraphicsLineItem *foot2; + + void DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); + void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size); +}; + +#endif // VISTOOLTRIANGLE_H diff --git a/src/app/visualization/visualization.cpp b/src/app/visualization/visualization.cpp new file mode 100644 index 000000000..fe86684f4 --- /dev/null +++ b/src/app/visualization/visualization.cpp @@ -0,0 +1,193 @@ +/************************************************************************ + ** + ** @file visualization.cpp + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 "visualization.h" +#include "../tools/drawTools/vdrawtool.h" +#include "../container/calculator.h" + +#include + +Q_LOGGING_CATEGORY(vVis, "v.visualization") + +//--------------------------------------------------------------------------------------------------------------------- +Visualization::Visualization(const VContainer *data) + :QObject(), data(data), factor(VDrawTool::factor), scenePos(QPointF()), + mainColor(Qt::red), supportColor(Qt::magenta), lineStyle(Qt::SolidLine), point1Id(NULL_ID), toolTip(QString()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +Visualization::~Visualization() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::setPoint1Id(const quint32 &value) +{ + point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::setLineStyle(const Qt::PenStyle &value) +{ + lineStyle = value; + InitPen(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::setScenePos(const QPointF &value) +{ + scenePos = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::VisualMode(const quint32 &pointId) +{ + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + + this->point1Id = pointId; + this->scenePos = scene->getScenePos(); + RefreshGeometry(); + + AddOnScene(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::setMainColor(const QColor &value) +{ + mainColor = value; + InitPen(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::SetFactor(qreal factor) +{ + VApplication::CheckFactor(this->factor, factor); + RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::MousePos(const QPointF &scenePos) +{ + this->scenePos = scenePos; + RefreshGeometry(); + if (toolTip.isEmpty() == false) + { + emit ToolTip(toolTip); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent) const +{ + QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent); + point->setZValue(1); + point->setBrush(QBrush(Qt::NoBrush)); + point->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor)); + point->setRect(PointRect(qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm))); + point->setFlags(QGraphicsItem::ItemStacksBehindParent); + point->setVisible(false); + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +QRectF Visualization::PointRect(const qreal &radius) const +{ + QRectF rec = QRectF(0, 0, radius*2, radius*2); + rec.translate(-rec.center().x(), -rec.center().y()); + return rec; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal Visualization::FindLength(const QString &expression) +{ + return qApp->toPixel(FindVal(expression)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal Visualization::FindVal(const QString &expression) +{ + qreal val = 0; + if (expression.isEmpty()) + { + val = 0; + } + else + { + try + { + // Replace line return with spaces for calc if exist + QString formula = expression; + formula.replace("\n", " "); + formula = qApp->FormulaFromUser(formula); + Calculator *cal = new Calculator(Visualization::data); + val = cal->EvalFormula(formula); + delete cal; + } + catch (qmu::QmuParserError &e) + { + val = 0; + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; + } + } + return val; +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style) +{ + SCASSERT (point != nullptr); + + point->setPos(pos); + point->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style)); + point->setVisible(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style) +{ + SCASSERT (lineItem != nullptr); + + lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, style)); + lineItem->setLine(line); + lineItem->setVisible(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void Visualization::DrawPath(QGraphicsPathItem *pathItem, const QPainterPath &path, const QColor &color, + Qt::PenStyle style, Qt::PenCapStyle cap) +{ + SCASSERT (pathItem != nullptr); + + pathItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style, cap)); + pathItem->setPath(path); + pathItem->setVisible(true); +} diff --git a/src/app/visualization/visualization.h b/src/app/visualization/visualization.h new file mode 100644 index 000000000..c63527d24 --- /dev/null +++ b/src/app/visualization/visualization.h @@ -0,0 +1,111 @@ +/************************************************************************ + ** + ** @file visualization.h + ** @author Roman Telezhynskyi + ** @date 15 8, 2014 + ** + ** @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) 2014 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 VISUALIZATION_H +#define VISUALIZATION_H + +#include +#include +#include "../core/vapplication.h" +#include "../widgets/vmaingraphicsscene.h" +#include + +Q_DECLARE_LOGGING_CATEGORY(vVis) + +class VContainer; + +class Visualization : public QObject +{ + Q_OBJECT +public: + Visualization(const VContainer *data); + virtual ~Visualization(); + + virtual void RefreshGeometry()=0; + + void setPoint1Id(const quint32 &value); + void setLineStyle(const Qt::PenStyle &value); + void setScenePos(const QPointF &value); + void VisualMode(const quint32 &pointId); + void setMainColor(const QColor &value); +signals: + void ToolTip(const QString &toolTip); +public slots: + void SetFactor(qreal factor); + void MousePos(const QPointF &scenePos); +protected: + const VContainer *data; + qreal factor; + QPointF scenePos; + QColor mainColor; + QColor supportColor; + Qt::PenStyle lineStyle; + quint32 point1Id; + QString toolTip; + + virtual void InitPen()=0; + virtual void AddOnScene()=0; + + QGraphicsEllipseItem *InitPoint(const QColor &color, QGraphicsItem *parent) const; + QRectF PointRect(const qreal &radius) const; + qreal FindLength(const QString &expression); + qreal FindVal(const QString &expression); + void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); + virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); + void DrawPath(QGraphicsPathItem *pathItem, const QPainterPath &path, const QColor &color, + Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); + + template + void AddItem(Item *item) + { + SCASSERT(item != nullptr); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + + scene->addItem(item); + connect(scene, &VMainGraphicsScene::NewFactor, item, &Visualization::SetFactor); + connect(scene, &VMainGraphicsScene::mouseMove, item, &Visualization::MousePos); + } + + template + Item *InitItem(const QColor &color, QGraphicsItem *parent) + { + Item *item = new Item(parent); + item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor)); + item->setZValue(1); + item->setFlags(QGraphicsItem::ItemStacksBehindParent); + item->setVisible(false); + return item; + } +private: + Q_DISABLE_COPY(Visualization) +}; + +#endif // VISUALIZATION_H diff --git a/src/app/visualization/visualization.pri b/src/app/visualization/visualization.pri new file mode 100644 index 000000000..aa73530fe --- /dev/null +++ b/src/app/visualization/visualization.pri @@ -0,0 +1,56 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vgraphicssimpletextitem.h \ + $$PWD/vcontrolpointspline.h \ + $$PWD/vsimplecurve.h \ + $$PWD/visline.h \ + $$PWD/vistoolline.h \ + $$PWD/vistoolendline.h \ + $$PWD/vistoolalongline.h \ + $$PWD/vistoolbisector.h \ + $$PWD/vistoolshoulderpoint.h \ + $$PWD/vistoolnormal.h \ + $$PWD/vistoolheight.h \ + $$PWD/vistoolpointofintersection.h \ + $$PWD/vistooltriangle.h \ + $$PWD/vistoolpointofcontact.h \ + $$PWD/vistoollineintersect.h \ + $$PWD/visualization.h \ + $$PWD/vistoolarc.h \ + $$PWD/vispath.h \ + $$PWD/vistoolcutarc.h \ + $$PWD/vistoolspline.h \ + $$PWD/vistoolcutspline.h \ + $$PWD/vistoolsplinepath.h \ + $$PWD/vistoolcutsplinepath.h \ + $$PWD/vistoollineintersectaxis.h \ + $$PWD/vistoolcurveintersectaxis.h + +SOURCES += \ + $$PWD/vgraphicssimpletextitem.cpp \ + $$PWD/vcontrolpointspline.cpp \ + $$PWD/vsimplecurve.cpp \ + $$PWD/visline.cpp \ + $$PWD/vistoolline.cpp \ + $$PWD/vistoolendline.cpp \ + $$PWD/vistoolalongline.cpp \ + $$PWD/vistoolbisector.cpp \ + $$PWD/vistoolshoulderpoint.cpp \ + $$PWD/vistoolnormal.cpp \ + $$PWD/vistoolheight.cpp \ + $$PWD/vistoolpointofintersection.cpp \ + $$PWD/vistooltriangle.cpp \ + $$PWD/vistoolpointofcontact.cpp \ + $$PWD/vistoollineintersect.cpp \ + $$PWD/visualization.cpp \ + $$PWD/vistoolarc.cpp \ + $$PWD/vispath.cpp \ + $$PWD/vistoolcutarc.cpp \ + $$PWD/vistoolspline.cpp \ + $$PWD/vistoolcutspline.cpp \ + $$PWD/vistoolsplinepath.cpp \ + $$PWD/vistoolcutsplinepath.cpp \ + $$PWD/vistoollineintersectaxis.cpp \ + $$PWD/vistoolcurveintersectaxis.cpp diff --git a/src/app/visualization/vsimplecurve.cpp b/src/app/visualization/vsimplecurve.cpp new file mode 100644 index 000000000..92ba03fba --- /dev/null +++ b/src/app/visualization/vsimplecurve.cpp @@ -0,0 +1,132 @@ +/************************************************************************ + ** + ** @file vsimplecurve.cpp + ** @author Roman Telezhynskyi + ** @date 17 12, 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 + ** 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 "vsimplecurve.h" +#include "../core/vapplication.h" +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSimpleSpline constructor. + * @param id spline id. + * @param factor scene scale factor. + * @param currentColor current color. + * @param parent parent object. + */ +VSimpleCurve::VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint pointPosition, qreal *factor, + QObject *parent) + :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor), + curvePosition(pointPosition) +{ + if (factor == nullptr) + { + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + } + else + { + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/ *factor)); + } + setFlag(QGraphicsItem::ItemIsSelectable, true); + setAcceptHoverEvents(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSimpleCurve::ChangedActivDraw(const bool &flag) +{ + setFlag(QGraphicsItem::ItemIsSelectable, flag); + setAcceptHoverEvents(flag); + setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + /* From question on StackOverflow + * https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected + * + * There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way + * I can think of is derive your own items from the build-in ones and override the paint() function:*/ + QStyleOptionGraphicsItem myOption(*option); + myOption.state &= ~QStyle::State_Selected; + QGraphicsPathItem::paint(painter, &myOption, widget); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + emit Choosed(id); + } + QGraphicsPathItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ +void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + if (factor == nullptr) + { + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine()))); + } + else + { + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); + } + emit HoverPath(id, curvePosition, PathDirection::Show); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ +void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + if (factor == nullptr) + { + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine()))); + } + else + { + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); + } + + emit HoverPath(id, curvePosition, PathDirection::Hide); +} diff --git a/src/app/visualization/vsimplecurve.h b/src/app/visualization/vsimplecurve.h new file mode 100644 index 000000000..d33afb269 --- /dev/null +++ b/src/app/visualization/vsimplecurve.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vsimplecurve.h + ** @author Roman Telezhynskyi + ** @date 17 12, 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 + ** 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 VSIMPLECURVE_H +#define VSIMPLECURVE_H + +#include +#include "../geometry/vabstractcurve.h" + +enum class SimpleCurvePoint : char { FirstPoint, ForthPoint }; + +/** + * @brief The VSimpleSpline class for simple spline. This object used when we cut spline and want show peaces. + */ +class VSimpleCurve : public QObject, public QGraphicsPathItem +{ + Q_OBJECT +public: + VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint curvePosition, + qreal *factor = nullptr, QObject *parent = 0); + void ChangedActivDraw(const bool &flag); + virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::SimpleSplinePath)}; +signals: + /** + * @brief Choosed send id when clicked. + * @param id spline id. + */ + void Choosed(quint32 id); + void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); +protected: + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); +private: + Q_DISABLE_COPY(VSimpleCurve) + /** @brief id spline id. */ + quint32 id; + + /** @brief factor scale factor. */ + qreal *factor; + + /** @brief currentColor current color. */ + Qt::GlobalColor *currentColor; + + SimpleCurvePoint curvePosition; +}; + +#endif // VSIMPLECURVE_H diff --git a/src/app/widgets/doubledelegate.cpp b/src/app/widgets/doubledelegate.cpp new file mode 100644 index 000000000..981ad3d0d --- /dev/null +++ b/src/app/widgets/doubledelegate.cpp @@ -0,0 +1,134 @@ +/************************************************************************ + ** + ** @file doubledelegate.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "doubledelegate.h" +#include +#include "../options.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and + * style option are used to control how the editor widget appears. + * @param parent parent widget. + * @param option item options. + * @param index index of data item. + * @return editor to be used for editing the data item. + */ +//cppcheck-suppress unusedFunction +DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(QObject *parent): QItemDelegate(parent), lastValue(-10001.0) +{ + //Little hack. Help save value in const method. + connect(this, &DoubleSpinBoxDelegate::NewLastValue, this, &DoubleSpinBoxDelegate::SetLastValue); +} + +QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index ) const +{ + Q_UNUSED(option); + Q_UNUSED(index); + emit NewLastValue(-10001.0);//Here need reset value to default because we begin work with new item + QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + editor->setMinimum(-10000.0); + editor->setMaximum(10000.0); + connect(editor, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBoxDelegate::commitAndCloseEditor); + return editor; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by + * the model index. + * @param editor editor. + * @param index index of data item. + */ +//cppcheck-suppress unusedFunction +void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const +{ + qreal value = index.model()->data(index, Qt::EditRole).toDouble(); + + QDoubleSpinBox *spinBox = qobject_cast(editor); + SCASSERT(spinBox != nullptr); + spinBox->setValue(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. + * @param editor editor. + * @param model model. + * @param index index of data item. + */ +//cppcheck-suppress unusedFunction +void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const +{ + QDoubleSpinBox *spinBox = qobject_cast(editor); + SCASSERT(spinBox != nullptr); + spinBox->interpretText(); + qreal value = spinBox->value(); + + model->setData(index, value, Qt::EditRole); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option + * given. + * @param editor editor. + * @param option item options. + * @param index index of data item. + */ +//cppcheck-suppress unusedFunction +void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + Q_UNUSED(index) + editor->setGeometry(option.rect); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief commitAndCloseEditor commit value if changed. + */ +void DoubleSpinBoxDelegate::commitAndCloseEditor() +{ + QDoubleSpinBox *spinBox = qobject_cast(sender()); + SCASSERT(spinBox != nullptr); + qreal value = spinBox->value(); + if (qFuzzyCompare ( lastValue, value ) == false) + { + lastValue = value; + emit commitData(spinBox); + } + emit closeEditor(spinBox); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DoubleSpinBoxDelegate::SetLastValue(const qreal &newLastValue) +{ + lastValue = newLastValue; +} diff --git a/src/widgets/doubledelegate.h b/src/app/widgets/doubledelegate.h similarity index 71% rename from src/widgets/doubledelegate.h rename to src/app/widgets/doubledelegate.h index c69a53e29..68557de9d 100644 --- a/src/widgets/doubledelegate.h +++ b/src/app/widgets/doubledelegate.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file doubledelegate.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -32,45 +32,35 @@ #include /** - * @brief The DoubleSpinBoxDelegate class + * @brief The DoubleSpinBoxDelegate class a delegate that allows the user to change double values from the model + * using a double spin box widget. */ class DoubleSpinBoxDelegate : public QItemDelegate { Q_OBJECT public: - /** - * @brief DoubleSpinBoxDelegate - * @param parent - */ - DoubleSpinBoxDelegate(QObject *parent = 0): QItemDelegate(parent){} /** - * @brief createEditor - * @param parent - * @param option - * @param index - * @return + * @brief DoubleSpinBoxDelegate constructor. + * @param parent parent object. */ + DoubleSpinBoxDelegate(QObject *parent = nullptr); QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - /** - * @brief setEditorData - * @param editor - * @param index - */ void setEditorData(QWidget *editor, const QModelIndex &index) const; - /** - * @brief setModelData - * @param editor - * @param model - * @param index - */ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - /** - * @brief updateEditorGeometry - * @param editor - * @param option - * @param index - */ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; +signals: + /** + * @brief NewLastValue help reset last value in const method (hack). + * @param text text. + */ + void NewLastValue(const qreal &newLastValue) const; +public slots: + void commitAndCloseEditor(); +private slots: + void SetLastValue(const qreal &newLastValue); +private: + /** @brief lastValue last saved value. */ + qreal lastValue; }; #endif diff --git a/src/app/widgets/textdelegate.cpp b/src/app/widgets/textdelegate.cpp new file mode 100644 index 000000000..296dd1507 --- /dev/null +++ b/src/app/widgets/textdelegate.cpp @@ -0,0 +1,153 @@ +/************************************************************************ + ** + ** @file textdelegate.cpp + ** @author Roman Telezhynskyi + ** @date 29 1, 2014 + ** + ** @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 + ** 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 "textdelegate.h" +#include +#include "../options.h" +#include "../container/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TextDelegate constructor. + * @param parent parent widget. + */ +TextDelegate::TextDelegate(const QString ®ex, VContainer *data, QObject *parent) + : QItemDelegate(parent), lastText(QString("Name_")), regex(regex), data(data) +{ + SCASSERT(data); + //Little hack. Help save lineedit text in const method. + connect(this, &TextDelegate::SaveText, this, &TextDelegate::InitText); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and + * style option are used to control how the editor widget appears. + * @param parent parent widget. + * @param option item options. + * @param index index of data item. + * @return editor to be used for editing the data item. + */ +QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + Q_UNUSED(option); + Q_UNUSED(index); + QLineEdit *editor = new QLineEdit(parent); + //Same regex pattern in xsd file + editor->setValidator( new QRegExpValidator(QRegExp(regex)) ); + connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); + return editor; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by + * the model index. + * @param editor editor. + * @param index index of data item. + */ +void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const +{ + QString text = index.model()->data(index, Qt::EditRole).toString(); + + QLineEdit *lineEdit = qobject_cast(editor); + SCASSERT(lineEdit != nullptr); + if ( lastText != text && text.isEmpty() == false) + { + //Here need save text, but this method is const, so, we use signal instead. + emit SaveText(text); + } + lineEdit->setText(text); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. + * @param editor editor. + * @param model model. + * @param index index of data item. + */ +void TextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const +{ + QLineEdit *lineEdit = qobject_cast(editor); + SCASSERT(lineEdit != nullptr); + QString text = lineEdit->text(); + if (text.isEmpty()) + { + text = lastText; + } + + model->setData(index, text, Qt::EditRole); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option + * given. + * @param editor editor. + * @param option item options. + * @param index index of data item. + */ +void TextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + Q_UNUSED(index) + editor->setGeometry(option.rect); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief commitAndCloseEditor commit value if changed. + */ +void TextDelegate::commitAndCloseEditor() +{ + QLineEdit *lineEdit = qobject_cast(sender()); + SCASSERT(lineEdit != nullptr); + QString text = lineEdit->text(); + if ( lastText != text && text.isEmpty() == false && data->IsUnique(text)) + { + lastText = text; + emit commitData(lineEdit); + } + else if (text.isEmpty() == false) + { + lineEdit->setText(lastText); + emit commitData(lineEdit); + } + emit closeEditor(lineEdit); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief InitText initialize text. + * @param text text. + */ +void TextDelegate::InitText(const QString &text) +{ + lastText = text; +} diff --git a/src/app/widgets/textdelegate.h b/src/app/widgets/textdelegate.h new file mode 100644 index 000000000..974579ed7 --- /dev/null +++ b/src/app/widgets/textdelegate.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file textdelegate.h + ** @author Roman Telezhynskyi + ** @date 29 1, 2014 + ** + ** @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 + ** 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 TEXTDELEGATE_H +#define TEXTDELEGATE_H + +#include + +class VContainer; +/** + * @brief The TextDelegate class a delegate that allows the user to change text values from the model + * using a edit line widget. + */ +class TextDelegate : public QItemDelegate +{ + Q_OBJECT +public: + TextDelegate(const QString ®ex, VContainer *data, QObject *parent = nullptr); + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; +signals: + /** + * @brief SaveText help save text value of lineedit. + * @param text text. + */ + void SaveText(const QString &text) const; +public slots: + void commitAndCloseEditor(); +private slots: + void InitText(const QString &text); +private: + Q_DISABLE_COPY(TextDelegate) + + /** @brief lastValue last saved value. */ + QString lastText; + + QString regex; + VContainer *data; +}; + +#endif // TEXTDELEGATE_H diff --git a/src/app/widgets/vformulaproperty.cpp b/src/app/widgets/vformulaproperty.cpp new file mode 100644 index 000000000..444a9fca6 --- /dev/null +++ b/src/app/widgets/vformulaproperty.cpp @@ -0,0 +1,220 @@ +/************************************************************************ + ** + ** @file vformulaproperty.cpp + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 "vformulaproperty.h" +#include "vformulapropertyeditor.h" + +#include "../../libs/vpropertyexplorer/vproperty_p.h" +#include "vformulapropertyeditor.h" +#include "../../libs/vpropertyexplorer/vproperties.h" +#include "../container/vformula.h" + +enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2}; + +using namespace VPE; + +//--------------------------------------------------------------------------------------------------------------------- +VFormulaProperty::VFormulaProperty(const QString &name) + : VProperty(name, static_cast(VFormula::FormulaTypeId())) +{ + d_ptr->type = Property::Complex; + + VStringProperty* tmpValue = new VStringProperty(tr("Value")); + addChild(tmpValue); + tmpValue->setUpdateBehaviour(true, false); + tmpValue->setReadOnly(true); + tmpValue->setTypeForParent(static_cast(ChildType::Value)); + + VStringProperty* tmpFormula = new VStringProperty(tr("Formula")); + addChild(tmpFormula); + tmpFormula->setUpdateBehaviour(true, false); + tmpFormula->setTypeForParent(static_cast(ChildType::Formula)); + + setValue(0); +} + +//--------------------------------------------------------------------------------------------------------------------- +//! Get the data how it should be displayed +QVariant VFormulaProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + return getValue(); + } + else + { + return VProperty::data(column, role); + } +} + +Qt::ItemFlags VFormulaProperty::flags(int column) const +{ + if (column == DPC_Name || column == DPC_Data) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + else + { + return Qt::NoItemFlags; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + + VFormula formula = VProperty::d_ptr->VariantValue.value(); + VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); + + tmpEditor->setFormula(formula); + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +//--------------------------------------------------------------------------------------------------------------------- +//! Sets the property's data to the editor (returns false, if the standard delegate should do that) +bool VFormulaProperty::setEditorData(QWidget* editor) +{ + VFormulaPropertyEditor* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + VFormula formula = VProperty::d_ptr->VariantValue.value(); + tmpWidget->setFormula(formula); + } + else + return false; + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +//! Gets the data from the widget +QVariant VFormulaProperty::getEditorData(const QWidget *editor) const +{ + const VFormulaPropertyEditor* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + QVariant value; + value.setValue(tmpWidget->getFormula()); + return value; + } + + return QVariant(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VFormulaProperty::type() const +{ + return "formula"; +} + +//--------------------------------------------------------------------------------------------------------------------- +VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const +{ + if (!container) + { + container = new VFormulaProperty(getName()); + + if (!include_children) + { + QList tmpChildren = container->getChildren(); + foreach (VProperty* tmpChild, tmpChildren) + { + container->removeChild(tmpChild); + delete tmpChild; + } + } + } + + return VProperty::clone(false, container); // Child + +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormulaProperty::setValue(const QVariant &value) +{ + VFormula tmpFormula = value.value(); + setFormula(tmpFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVariant VFormulaProperty::getValue() const +{ + VFormula tmpFormula = getFormula(); + QVariant value; + value.setValue(tmpFormula); + return value; +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VFormulaProperty::getFormula() const +{ + return VProperty::d_ptr->VariantValue.value(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormulaProperty::setFormula(const VFormula &formula) +{ + if (d_ptr->Children.count() < 2) + { + return; + } + + QVariant value; + value.setValue(formula); + value.convert(VFormula::FormulaTypeId()); + VProperty::d_ptr->VariantValue = value; + + QVariant tmpValue(formula.getStringValue()); + tmpValue.convert(QVariant::String); + + QVariant tmpFormula(formula.getFormula()); + tmpFormula.convert(QVariant::String); + + VProperty::d_ptr->Children.at(0)->setValue(tmpValue); + VProperty::d_ptr->Children.at(1)->setValue(tmpFormula); + + if (VProperty::d_ptr->editor != nullptr) + { + setEditorData(VProperty::d_ptr->editor); + } +} + +void VFormulaProperty::ValueChildChanged(const QVariant &value, int typeForParent) +{ + if (typeForParent == static_cast(ChildType::Formula)) + { + VFormula newFormula = getFormula(); + newFormula.setFormula(value.toString()); + setFormula(newFormula); + } +} diff --git a/src/app/widgets/vformulaproperty.h b/src/app/widgets/vformulaproperty.h new file mode 100644 index 000000000..90c177aed --- /dev/null +++ b/src/app/widgets/vformulaproperty.h @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file vformulaproperty.h + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 VFORMULAPROPERTY_H +#define VFORMULAPROPERTY_H + +#include "../../libs/vpropertyexplorer/vproperty.h" + +class VFormula; + +class VFormulaProperty : public VPE::VProperty +{ + Q_OBJECT +public: + VFormulaProperty(const QString &name); + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns item flags + Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns the value of the property as a QVariant + virtual QVariant getValue() const; + + //! Returns the formula + virtual VFormula getFormula() const; + + //! Sets the formula + virtual void setFormula(const VFormula &formula); + +public slots: + virtual void ValueChildChanged(const QVariant &value, int typeForParent); + +}; + +#endif // VFORMULAPROPERTY_H diff --git a/src/app/widgets/vformulapropertyeditor.cpp b/src/app/widgets/vformulapropertyeditor.cpp new file mode 100644 index 000000000..7030ae7fa --- /dev/null +++ b/src/app/widgets/vformulapropertyeditor.cpp @@ -0,0 +1,128 @@ +/************************************************************************ + ** + ** @file vformulapropertyeditor.cpp + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 "vformulapropertyeditor.h" + +#include +#include +#include +#include +#include + +#include "../../libs/vpropertyexplorer/vproperty.h" +#include "../dialogs/tools/dialogeditwrongformula.h" + +using namespace VPE; + +// VFormulaPropertyEditor +//--------------------------------------------------------------------------------------------------------------------- +VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) + : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr), Spacer(nullptr) +{ + setAutoFillBackground(true); + + // Create the tool button + ToolButton = new QToolButton(this); + ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); + ToolButton->setText("..."); + ToolButton->setFixedWidth(20); + ToolButton->installEventFilter(this); + setFocusProxy(ToolButton); // Make the ToolButton the focus proxy + setFocusPolicy(ToolButton->focusPolicy()); + connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked())); + + // Create the text label + TextLabel = new QLabel(this); + TextLabel->setText(formula.getStringValue()); + + // Spacer (this is needed for proper display of the label and button) + Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored); + + // The layout (a horizontal layout) + QHBoxLayout* layout = new QHBoxLayout(this); + layout->setSpacing(3); + layout->setMargin(0); + layout->addWidget(TextLabel); + layout->addItem(Spacer); + layout->addWidget(ToolButton); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormulaPropertyEditor::setFormula(const VFormula& formula) +{ + if (this->formula != formula) + { + this->formula = formula; + TextLabel->setText(this->formula.getStringValue()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VFormulaPropertyEditor::onToolButtonClicked() +{ + DialogEditWrongFormula* tmpWidget = new DialogEditWrongFormula(formula.getData(), formula.getToolId(), + qApp->getMainWindow()); + tmpWidget->setCheckZero(formula.getCheckZero()); + tmpWidget->setPostfix(formula.getPostfix()); + tmpWidget->setFormula(formula.getFormula(FormulaType::FromUser)); + + if (tmpWidget->exec() == QDialog::Accepted) + { + formula.setFormula(tmpWidget->getFormula(), FormulaType::ToUser); + TextLabel->setText(formula.getStringValue()); + delete tmpWidget; + emit dataChangedByUser(formula, this); + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( this, event ); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) +{ + if (obj == ToolButton && ev->type() == QEvent::KeyPress) + { + // Ignore the event, so that eventually the delegate gets the event. + ev->ignore(); + return true; + } + + return QWidget::eventFilter(obj, ev); +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormulaPropertyEditor::~VFormulaPropertyEditor() +{ + // +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VFormulaPropertyEditor::getFormula() const +{ + return formula; +} diff --git a/src/app/widgets/vformulapropertyeditor.h b/src/app/widgets/vformulapropertyeditor.h new file mode 100644 index 000000000..e7a1ab291 --- /dev/null +++ b/src/app/widgets/vformulapropertyeditor.h @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file vformulapropertyeditor.h + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @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) 2014 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 VFORMULAPROPERTYEDITOR_H +#define VFORMULAPROPERTYEDITOR_H + +#include +#include +#include +#include +#include + +#include "../container/vformula.h" + +class VFormulaPropertyEditor : public QWidget +{ + Q_OBJECT + +public: + //! Constructor taking a widget as parent + VFormulaPropertyEditor(QWidget *parent); + + //! Destructor + virtual ~VFormulaPropertyEditor(); + + //! Returns the formula currently set + VFormula getFormula() const; + + //! Needed for proper event handling + bool eventFilter(QObject *obj, QEvent *ev); + +signals: + //! This is emitted, when the user changes the color + void dataChangedByUser(const VFormula &getFormula, VFormulaPropertyEditor* editor); + + void dataChanged(); + +public slots: + //! Sets the color of the widget + void setFormula(const VFormula &formula); + +private slots: + void onToolButtonClicked(); + +private: + Q_DISABLE_COPY(VFormulaPropertyEditor) + VFormula formula; + QToolButton* ToolButton; + QLabel* TextLabel; + QSpacerItem* Spacer; +}; + + +#endif // VFORMULAPROPERTYEDITOR_H diff --git a/src/widgets/vitem.cpp b/src/app/widgets/vitem.cpp similarity index 56% rename from src/widgets/vitem.cpp rename to src/app/widgets/vitem.cpp index 9eea52f22..b70c06833 100644 --- a/src/widgets/vitem.cpp +++ b/src/app/widgets/vitem.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vitem.cpp - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -27,20 +27,48 @@ *************************************************************************/ #include "vitem.h" -#include "../options.h" #include #include +#include "../core/vapplication.h" +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem constructor. + * @param path detail path. + * @param numInList index in list of details. + * @param parent parent object. + */ VItem::VItem (const QPainterPath & path, int numInList, QGraphicsItem * parent ) - :QGraphicsPathItem ( path, parent ), numInOutList(numInList), paper(0) -{ -} + :QGraphicsPathItem ( path, parent ), numInOutList(numInList), paper(nullptr) +{} +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem default constructor. + */ +VItem::VItem():numInOutList(0), paper(nullptr) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem constructor. + * @param numInList index in list of details. + * @param parent parent object. + */ +VItem::VItem(int numInList, QGraphicsItem *parent):QGraphicsPathItem (parent), numInOutList(numInList), + paper(nullptr) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief checkItemChange check item change. If detail create colission or moved out paper emit signal. + */ void VItem::checkItemChange() { QRectF rect; - if(paper == 0){ + if (paper == nullptr) + { qDebug()<<"Don't set paper for detail!!!!"; rect = this->scene()->sceneRect(); } @@ -51,34 +79,37 @@ void VItem::checkItemChange() QRectF myrect = sceneBoundingRect(); if ( rect.contains( myrect )==true ) { - qDebug()<<"Не виходить за рамки листа"; - setPen(QPen(Qt::black, widthMainLine)); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); emit itemOut( numInOutList, false ); } else { - qDebug()<<"Виходить за рамки листа"; - setPen(QPen(Qt::red, widthMainLine)); + setPen(QPen(Qt::red, qApp->toPixel(qApp->widthMainLine()))); emit itemOut( numInOutList, true ); } QList list = QGraphicsItem::collidingItems (); if ( list.size() - 2 > 0 ) { list.append( this ); - setPen(QPen(Qt::red, widthMainLine)); - qDebug()<<"Деталь перетинається з іншими деталями "<toPixel(qApp->widthMainLine()))); + emit itemColliding( list, 1 );//Detail intersect with other details. } else { QList itemList; itemList.append( this ); - qDebug()<<"Деталь більше не перетинається з іншими деталями "< +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsScene default constructor. + */ +VMainGraphicsScene::VMainGraphicsScene() + :QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()), scenePos(QPointF()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsScene constructor. + * @param sceneRect scene rect. + * @param parent parent object. + */ +VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent) + :QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()), + scenePos(QPointF()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseMoveEvent handle mouse move events. + * @param event mouse move event. + */ +void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) +{ + scenePos = event->scenePos(); + emit mouseMove(event->scenePos()); + QGraphicsScene::mouseMoveEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent mouse press events. + * @param event mouse press event + */ +void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + emit mousePress(event->scenePos()); + QGraphicsScene::mousePressEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VMainGraphicsScene::getScenePos() const +{ + return scenePos; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief transform return view transformation. + * @return view transformation. + */ +QTransform VMainGraphicsScene::transform() const +{ + return _transform; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTransform set view transformation. + * @param transform view transformation. + */ +void VMainGraphicsScene::setTransform(const QTransform &transform) +{ + _transform = transform; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::SetDisable(bool disable) +{ + emit DisableItem(disable); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedItem emit ChoosedObject signal. + * @param id object id. + * @param type object scene type. + */ +void VMainGraphicsScene::ChoosedItem(quint32 id, const SceneObject &type) +{ + emit ChoosedObject(id, type); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. scene scale factor. + */ +void VMainGraphicsScene::SetFactor(qreal factor) +{ + scaleFactor=scaleFactor*factor; + emit NewFactor(scaleFactor); +} diff --git a/src/app/widgets/vmaingraphicsscene.h b/src/app/widgets/vmaingraphicsscene.h new file mode 100644 index 000000000..96288c0ca --- /dev/null +++ b/src/app/widgets/vmaingraphicsscene.h @@ -0,0 +1,136 @@ +/************************************************************************ + ** + ** @file vmaingraphicsscene.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VMAINGRAPHICSSCENE_H +#define VMAINGRAPHICSSCENE_H + +#include +#include "../options.h" + +/** + * @brief The VMainGraphicsScene class main scene. + */ +class VMainGraphicsScene : public QGraphicsScene +{ + Q_OBJECT +public: + VMainGraphicsScene(); + VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr); + qint32 getHorScrollBar() const; + void setHorScrollBar(const qint32 &value); + qint32 getVerScrollBar() const; + void setVerScrollBar(const qint32 &value); + QTransform transform() const; + void setTransform(const QTransform &transform); + void SetDisable(bool enabled); + QPointF getScenePos() const; +public slots: + void ChoosedItem(quint32 id, const SceneObject &type); + void SetFactor(qreal factor); +protected: + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); +signals: + /** + * @brief mouseMove send new mouse position. + * @param scenePos new mouse position. + */ + void mouseMove(const QPointF &scenePos); + /** + * @brief mousePress send new mouse press position. + * @param scenePos new mouse press position. + */ + void mousePress(QPointF scenePos); + /** + * @brief ChoosedObject send option choosed object. + * @param id object id. + * @param type object scene type. + */ + void ChoosedObject(quint32 id, SceneObject type); + /** + * @brief NewFactor send new scale factor. + * @param factor scene scale factor. + */ + void NewFactor(qreal factor); + void DisableItem(bool disable); +private: + /** @brief horScrollBar value horizontal scroll bar. */ + qint32 horScrollBar; + + /** @brief verScrollBar value vertical scroll bar. */ + qint32 verScrollBar; + + /** @brief scaleFactor scale factor. */ + qreal scaleFactor; + + /** @brief _transform view transform value. */ + QTransform _transform; + QPointF scenePos; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getHorScrollBar return scene horizontal scrollbar. + * @return horizontal scrollbar. + */ +inline qint32 VMainGraphicsScene::getHorScrollBar() const +{ + return horScrollBar; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setHorScrollBar set scene horizontal scrollbar. + * @param value horizontal scrollbar. + */ +inline void VMainGraphicsScene::setHorScrollBar(const qint32 &value) +{ + horScrollBar = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getVerScrollBar return scene vertical scrollbar. + * @return vertical scrollbar. + */ +inline qint32 VMainGraphicsScene::getVerScrollBar() const +{ + return verScrollBar; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setVerScrollBar set scene vertical scrollbar. + * @param value vertical scrollbar. + */ +inline void VMainGraphicsScene::setVerScrollBar(const qint32 &value) +{ + verScrollBar = value; +} + +#endif // VMAINGRAPHICSSCENE_H diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp new file mode 100644 index 000000000..198c95f53 --- /dev/null +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -0,0 +1,289 @@ +/************************************************************************ + ** + ** @file vmaingraphicsview.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vmaingraphicsview.h" + +#include +#include +#include +#include +#include "../tools/vabstracttool.h" +#include "../visualization/vsimplecurve.h" + +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view) + : QObject(view), _view(view), _modifiers(Qt::ControlModifier), _zoom_factor_base(1.0015), + target_scene_pos(QPointF()), target_viewport_pos(QPointF()), anim(nullptr), _numScheduledScalings(0) +{ + _view->viewport()->installEventFilter(this); + _view->setMouseTracking(true); + anim = new QTimeLine(300, this); + anim->setUpdateInterval(20); + connect(anim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::scrollingTime, Qt::UniqueConnection); + connect(anim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished, Qt::UniqueConnection); +} + +//--------------------------------------------------------------------------------------------------------------------- +void GraphicsViewZoom::gentle_zoom(double factor) +{ + _view->scale(factor, factor); + _view->centerOn(target_scene_pos); + QPointF delta_viewport_pos = target_viewport_pos - QPointF(_view->viewport()->width() / 2.0, + _view->viewport()->height() / 2.0); + QPointF viewport_center = _view->mapFromScene(target_scene_pos) - delta_viewport_pos; + _view->centerOn(_view->mapToScene(viewport_center.toPoint())); + emit zoomed(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void GraphicsViewZoom::set_modifiers(Qt::KeyboardModifiers modifiers) +{ + _modifiers = modifiers; +} + +//--------------------------------------------------------------------------------------------------------------------- +void GraphicsViewZoom::set_zoom_factor_base(double value) +{ + _zoom_factor_base = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void GraphicsViewZoom::scrollingTime(qreal x) +{ + Q_UNUSED(x); + qreal factor = 1.0; + if (_numScheduledScalings < 0) + { + factor = factor*13.8; + } + else + { + factor = factor*-13.8; + } + _view->verticalScrollBar()->setValue(qRound(_view->verticalScrollBar()->value() + factor)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void GraphicsViewZoom::animFinished() +{ + if (_numScheduledScalings > 0) + { + _numScheduledScalings--; + } + else + { + _numScheduledScalings++; + } + anim->stop(); + + /* + * In moust cases cursor position on view doesn't change, but for scene after scrolling position will be different. + * We are goint to check changes and save new value. + * If don't do that we will zoom using old value cursor position on scene. It is not what we expect. + * Almoust the same we do in method GraphicsViewZoom::eventFilter. + */ + QPoint pos = _view->mapFromGlobal(QCursor::pos()); + QPointF delta = target_scene_pos - _view->mapToScene(pos); + if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5) + { + target_viewport_pos = pos; + target_scene_pos = _view->mapToScene(pos); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseMove) + { + /* + * Here we are saving cursor position on view and scene. + * This data need for gentle_zoom(). + * Almoust the same we do in method GraphicsViewZoom::animFinished. + */ + QMouseEvent* mouse_event = static_cast(event); + QPointF delta = target_viewport_pos - mouse_event->pos(); + if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5) + { + target_viewport_pos = mouse_event->pos(); + target_scene_pos = _view->mapToScene(mouse_event->pos()); + } + } + else if (event->type() == QEvent::Wheel) + { + QWheelEvent* wheel_event = static_cast(event); + if (QApplication::keyboardModifiers() == _modifiers) + { + if (wheel_event->orientation() == Qt::Vertical) + { + double angle = wheel_event->angleDelta().y(); + double factor = qPow(_zoom_factor_base, angle); + gentle_zoom(factor); + return true; + } + } + else + { + int numSteps = wheel_event->delta() / 8 / 15; // see QWheelEvent documentation + + _numScheduledScalings += numSteps; + if (_numScheduledScalings * numSteps < 0) + { // if user moved the wheel in another direction, we reset + _numScheduledScalings = numSteps; // previously scheduled scalings + } + + if (anim->state() != QTimeLine::Running) + { + anim->start(); + } + return true; + } + } + Q_UNUSED(object) + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsView constructor. + * @param parent parent object. + */ +VMainGraphicsView::VMainGraphicsView(QWidget *parent) + :QGraphicsView(parent), zoom(nullptr), showToolOptions(true) +{ + zoom = new GraphicsViewZoom(this); + this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); + this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + this->setInteractive(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomIn() +{ + scale(1.1, 1.1); + VAbstractTool::NewSceneRect(this->scene(), this); + emit NewFactor(1.1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomOut() +{ + scale(1.0/1.1, 1.0/1.1); + VAbstractTool::NewSceneRect(this->scene(), this); + emit NewFactor(1.0/1.1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomOriginal() +{ + QTransform trans = this->transform(); + trans.setMatrix(1.0, trans.m12(), trans.m13(), trans.m21(), 1.0, trans.m23(), trans.m31(), trans.m32(), + trans.m33()); + this->setTransform(trans); + emit NewFactor(1.0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::ZoomFitBest() +{ + QRectF rect = this->scene()->itemsBoundingRect(); + + if (rect.isEmpty()) + { + return; + } + + this->fitInView(rect, Qt::KeepAspectRatio); + emit NewFactor(this->transform().m11()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent handle mouse press events. + * @param mousePress mouse press event. + */ +void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) +{ + if (mousePress->button() & Qt::LeftButton) + { + switch (QGuiApplication::keyboardModifiers()) + { + case Qt::ControlModifier: + QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag); + break; + case Qt::NoModifier: + if (showToolOptions) + { + QList list = items(mousePress->pos()); + if (list.size() == 0) + { + emit itemClicked(nullptr); + break; + } + for (int i = 0; i < list.size(); ++i) + { + if (list.at(i)->type() <= VSimpleCurve::Type && list.at(i)->type() > QGraphicsItem::UserType) + { + emit itemClicked(list.at(i)); + break; + } + } + } + break; + default: + break; + } + } + QGraphicsView::mousePressEvent(mousePress); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ +void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsView::mouseReleaseEvent ( event ); + QGraphicsView::setDragMode( QGraphicsView::RubberBandDrag ); + if (event->button() == Qt::LeftButton) + { + emit MouseRelease(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::setShowToolOptions(bool value) +{ + showToolOptions = value; +} diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h new file mode 100644 index 000000000..706648197 --- /dev/null +++ b/src/app/widgets/vmaingraphicsview.h @@ -0,0 +1,134 @@ +/************************************************************************ + ** + ** @file vmaingraphicsview.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VMAINGRAPHICSVIEW_H +#define VMAINGRAPHICSVIEW_H + +#include +#include + +/*! + * This class adds ability to zoom QGraphicsView using mouse wheel. The point under cursor + * remains motionless while it's possible. + * + * Note that it becomes not possible when the scene's + * size is not large enough comparing to the viewport size. QGraphicsView centers the picture + * when it's smaller than the view. And QGraphicsView's scrolls boundaries don't allow to + * put any picture point at any viewport position. + * + * When the user starts scrolling, this class remembers original scene position and + * keeps it until scrolling is completed. It's better than getting original scene position at + * each scrolling step because that approach leads to position errors due to before-mentioned + * positioning restrictions. + * + * When zommed using scroll, this class emits zoomed() signal. + * + * Usage: + * + * new Graphics_view_zoom(view); + * + * The object will be deleted automatically when the view is deleted. + * + * You can set keyboard modifiers used for zooming using set_modified(). Zooming will be + * performed only on exact match of modifiers combination. The default modifier is Ctrl. + * + * You can change zoom velocity by calling set_zoom_factor_base(). + * Zoom coefficient is calculated as zoom_factor_base^angle_delta + * (see QWheelEvent::angleDelta). + * The default zoom factor base is 1.0015. + */ + +class QTimeLine; + +class GraphicsViewZoom : public QObject +{ + Q_OBJECT +public: + GraphicsViewZoom(QGraphicsView* view); + void gentle_zoom(double factor); + void set_modifiers(Qt::KeyboardModifiers modifiers); + void set_zoom_factor_base(double value); +signals: + void zoomed(); +public slots: + void scrollingTime(qreal x); + void animFinished(); +private: + QGraphicsView* _view; + Qt::KeyboardModifiers _modifiers; + double _zoom_factor_base; + QPointF target_scene_pos; + QPointF target_viewport_pos; + QTimeLine *anim; + + bool eventFilter(QObject* object, QEvent* event); +private: + Q_DISABLE_COPY(GraphicsViewZoom) + /** @brief _numScheduledScalings keep number scheduled scalings. */ + qint32 _numScheduledScalings; +}; + +/** + * @brief The VMainGraphicsView class main scene view. + */ +class VMainGraphicsView : public QGraphicsView +{ + Q_OBJECT +public: + + explicit VMainGraphicsView(QWidget *parent = nullptr); + void setShowToolOptions(bool value); + +signals: + /** + * @brief NewFactor send new scale factor. + * @param factor scene scale factor. + */ + void NewFactor(qreal factor); + /** + * @brief MouseRelease help catch mouse release event. + * + * Usefull when you need show dialog after working with tool visualization. + */ + void MouseRelease(); + void itemClicked(QGraphicsItem *item); +public slots: + void ZoomIn(); + void ZoomOut(); + void ZoomOriginal(); + void ZoomFitBest(); +protected: + void mousePressEvent(QMouseEvent *mousePress); + void mouseReleaseEvent(QMouseEvent *event); +private: + Q_DISABLE_COPY(VMainGraphicsView) + GraphicsViewZoom* zoom; + bool showToolOptions; +}; + +#endif // VMAINGRAPHICSVIEW_H diff --git a/src/widgets/vtablegraphicsview.cpp b/src/app/widgets/vtablegraphicsview.cpp similarity index 72% rename from src/widgets/vtablegraphicsview.cpp rename to src/app/widgets/vtablegraphicsview.cpp index 5b6b3c01c..e2028e54a 100644 --- a/src/widgets/vtablegraphicsview.cpp +++ b/src/app/widgets/vtablegraphicsview.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vtablegraphicsview.cpp - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -29,31 +29,42 @@ #include "vtablegraphicsview.h" #include -#include +#include +#include #include +#include +#include "../options.h" -VTableGraphicsView::VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent) - :QGraphicsView(pScene, parent) +//--------------------------------------------------------------------------------------------------------------------- +VTableGraphicsView::VTableGraphicsView(QWidget *parent) + :QGraphicsView(parent) { QGraphicsView::setResizeAnchor(QGraphicsView::AnchorUnderMouse); - connect(pScene, &QGraphicsScene::selectionChanged, this, &VTableGraphicsView::selectionChanged); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief selectionChanged handle selection change. + */ void VTableGraphicsView::selectionChanged() { QList listSelectedItems = scene()->selectedItems(); if ( listSelectedItems.isEmpty() == true ) { - qDebug() << tr("detail don't find"); + qDebug() << tr("can't find detail"); emit itemChect(true); } else { - qDebug() << tr("detail find"); + qDebug() << tr("detail found"); emit itemChect(false); } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MirrorItem mirror detail. + */ void VTableGraphicsView::MirrorItem() { QList list = scene()->selectedItems(); @@ -62,7 +73,7 @@ void VTableGraphicsView::MirrorItem() for ( qint32 i = 0; i < list.count(); ++i ) { QGraphicsItem *item = list.at(i); - Q_ASSERT(item != 0); + SCASSERT(item != nullptr); QRectF itemRectOld = item->sceneBoundingRect(); //Get the current transform QTransform transform(item->transform()); @@ -94,11 +105,16 @@ void VTableGraphicsView::MirrorItem() } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief wheelEvent handle wheel events. + * @param event wheel event. + */ void VTableGraphicsView::wheelEvent(QWheelEvent *event) { if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) { - // Если нажата клавиша CTRL этот код выполнится + // If was pressed button CTRL this code will execute if ((event->delta())>0) { ZoomIn(); @@ -114,6 +130,11 @@ void VTableGraphicsView::wheelEvent(QWheelEvent *event) } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent handle mouse press events. + * @param mousePress mouse press event. + */ void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress) { if (mousePress->button() & Qt::LeftButton) @@ -131,12 +152,22 @@ void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress) } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VTableGraphicsView::mouseReleaseEvent(QMouseEvent *event) { QGraphicsView::mouseReleaseEvent ( event ); QGraphicsView::setDragMode( QGraphicsView::RubberBandDrag ); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key press event. + */ void VTableGraphicsView::keyPressEvent(QKeyEvent *event) { switch (event->key()) @@ -162,6 +193,10 @@ void VTableGraphicsView::keyPressEvent(QKeyEvent *event) QGraphicsView::keyPressEvent ( event ); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief rotateIt rotate selected details on 180 degree. + */ void VTableGraphicsView::rotateIt() { QList list = scene()->selectedItems(); @@ -170,13 +205,18 @@ void VTableGraphicsView::rotateIt() for ( qint32 i = 0; i < list.count(); ++i ) { QGraphicsItem *item = list.at(i); - Q_ASSERT(item != 0); + SCASSERT(item != nullptr); item->setTransformOriginPoint(item->boundingRect().center()); - item->setRotation(item->rotation() + 180); + item->setRotation(item->rotation() + 90); } } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MoveItem move selected detail. + * @param move type of move. + */ void VTableGraphicsView::MoveItem(VTableGraphicsView::typeMove_e move) { qreal dx = 0, dy = 0; diff --git a/src/app/widgets/vtablegraphicsview.h b/src/app/widgets/vtablegraphicsview.h new file mode 100644 index 000000000..6b523c71f --- /dev/null +++ b/src/app/widgets/vtablegraphicsview.h @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file vtablegraphicsview.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTABLEGRAPHICSVIEW_H +#define VTABLEGRAPHICSVIEW_H + +#include + +/** + * @brief The VTableGraphicsView class table layout view. + */ +class VTableGraphicsView : public QGraphicsView +{ + Q_OBJECT +public: + /** + * @brief The typeMove_e enum type items moves. + */ + enum typeMove_e { Left, Right, Up, Down }; + + VTableGraphicsView(QWidget *parent = nullptr); +signals: + /** + * @brief itemChect emit after change selection state detail. + * @param flag false - selected, true - don't selected. + */ + void itemChect( bool flag ); +public slots: + void selectionChanged(); + void rotateItems(); + void MirrorItem(); + void ZoomIn(); + void ZoomOut(); +protected: + void wheelEvent ( QWheelEvent * event ); + void mousePressEvent(QMouseEvent *mousePress); + void mouseReleaseEvent ( QMouseEvent * event ); + void keyPressEvent ( QKeyEvent * event ); + void rotateIt(); + void MoveItem( VTableGraphicsView::typeMove_e move ); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief rotateItems handle rotatation detail. + */ +inline void VTableGraphicsView::rotateItems() +{ + rotateIt(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ZoomIn zoom in paper scale. + */ +inline void VTableGraphicsView::ZoomIn() +{ + scale(1.1, 1.1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ZoomOut zoom out paper scale. + */ +inline void VTableGraphicsView::ZoomOut() +{ + scale(1/1.1, 1/1.1); +} + +#endif // VTABLEGRAPHICSVIEW_H diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp new file mode 100644 index 000000000..b3cae144e --- /dev/null +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -0,0 +1,1456 @@ +/************************************************************************ + ** + ** @file vtooloptionspropertybrowser.cpp + ** @author Roman Telezhynskyi + ** @date 22 8, 2014 + ** + ** @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) 2014 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 "vtooloptionspropertybrowser.h" +#include "../tools/drawTools/drawtools.h" +#include "../core/vapplication.h" +#include "vmaingraphicsview.h" +#include "../visualization/vgraphicssimpletextitem.h" +#include "../visualization/vcontrolpointspline.h" +#include "../../libs/vpropertyexplorer/vproperties.h" +#include "vformulaproperty.h" +#include "../container/vformula.h" + +#include +#include + +using namespace VPE; + +//--------------------------------------------------------------------------------------------------------------------- +VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) + :QObject(parent), PropertyModel(nullptr), formView(nullptr), currentItem(nullptr), + propertyToId(QMap()), + idToProperty(QMap()) +{ + PropertyModel = new VPropertyModel(this); + formView = new VPropertyFormView(PropertyModel, parent); + formView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QScrollArea *scroll = new QScrollArea(parent); + scroll->setWidgetResizable(true); + scroll->setWidget(formView); + + parent->setWidget(scroll); + + connect(PropertyModel, &VPropertyModel::onDataChangedByEditor, this, &VToolOptionsPropertyBrowser::userChangedData); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ClearPropertyBrowser() +{ + PropertyModel->clear(); + propertyToId.clear(); + idToProperty.clear(); + currentItem = nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) +{ + switch (item->type()) + { + case VToolSinglePoint::Type: + ShowOptionsToolSinglePoint(item); + break; + case VToolEndLine::Type: + ShowOptionsToolEndLine(item); + break; + case VToolAlongLine::Type: + ShowOptionsToolAlongLine(item); + break; + case VToolArc::Type: + ShowOptionsToolArc(item); + break; + case VToolBisector::Type: + ShowOptionsToolBisector(item); + break; + case VToolCutArc::Type: + ShowOptionsToolCutArc(item); + break; + case VToolCutSpline::Type: + ShowOptionsToolCutSpline(item); + break; + case VToolCutSplinePath::Type: + ShowOptionsToolCutSplinePath(item); + break; + case VToolHeight::Type: + ShowOptionsToolHeight(item); + break; + case VToolLine::Type: + ShowOptionsToolLine(item); + break; + case VToolLineIntersect::Type: + ShowOptionsToolLineIntersect(item); + break; + case VToolNormal::Type: + ShowOptionsToolNormal(item); + break; + case VToolPointOfContact::Type: + ShowOptionsToolPointOfContact(item); + break; + case VToolPointOfIntersection::Type: + ShowOptionsToolPointOfIntersection(item); + break; + case VToolShoulderPoint::Type: + ShowOptionsToolShoulderPoint(item); + break; + case VToolSpline::Type: + ShowOptionsToolSpline(item); + break; + case VToolSplinePath::Type: + ShowOptionsToolSplinePath(item); + break; + case VToolTriangle::Type: + ShowOptionsToolTriangle(item); + break; + case VGraphicsSimpleTextItem::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; + case VControlPointSpline::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; + case VSimpleCurve::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; + case VToolLineIntersectAxis::Type: + ShowOptionsToolLineIntersectAxis(item); + break; + case VToolCurveIntersectAxis::Type: + ShowOptionsToolCurveIntersectAxis(item); + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptions() +{ + if (currentItem == nullptr) + { + return; + } + + switch (currentItem->type()) + { + case VToolSinglePoint::Type: + UpdateOptionsToolSinglePoint(); + break; + case VToolEndLine::Type: + UpdateOptionsToolEndLine(); + break; + case VToolAlongLine::Type: + UpdateOptionsToolAlongLine(); + break; + case VToolArc::Type: + UpdateOptionsToolArc(); + break; + case VToolBisector::Type: + UpdateOptionsToolBisector(); + break; + case VToolCutArc::Type: + UpdateOptionsToolCutArc(); + break; + case VToolCutSpline::Type: + UpdateOptionsToolCutSpline(); + break; + case VToolCutSplinePath::Type: + UpdateOptionsToolCutSplinePath(); + break; + case VToolHeight::Type: + UpdateOptionsToolHeight(); + break; + case VToolLine::Type: + UpdateOptionsToolLine(); + break; + case VToolLineIntersect::Type: + UpdateOptionsToolLineIntersect(); + break; + case VToolNormal::Type: + UpdateOptionsToolNormal(); + break; + case VToolPointOfContact::Type: + UpdateOptionsToolPointOfContact(); + break; + case VToolPointOfIntersection::Type: + UpdateOptionsToolPointOfIntersection(); + break; + case VToolShoulderPoint::Type: + UpdateOptionsToolShoulderPoint(); + break; + case VToolSpline::Type: + UpdateOptionsToolSpline(); + break; + case VToolSplinePath::Type: + UpdateOptionsToolSplinePath(); + break; + case VToolTriangle::Type: + UpdateOptionsToolTriangle(); + break; + case VGraphicsSimpleTextItem::Type: + ShowItemOptions(currentItem->parentItem()); + break; + case VControlPointSpline::Type: + ShowItemOptions(currentItem->parentItem()); + break; + case VToolLineIntersectAxis::Type: + UpdateOptionsToolLineIntersectAxis(); + break; + case VToolCurveIntersectAxis::Type: + UpdateOptionsToolCurveIntersectAxis(); + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) +{ + VProperty *prop = property; + if (!propertyToId.contains(prop)) + { + if (!propertyToId.contains(prop->getParent()))// Maybe we know parent + { + return; + } + else + { + prop = prop->getParent(); + } + } + + if (!currentItem) + { + return; + } + + switch (currentItem->type()) + { + case VToolSinglePoint::Type: + ChangeDataToolSinglePoint(prop); + break; + case VToolEndLine::Type: + ChangeDataToolEndLine(prop); + break; + case VToolAlongLine::Type: + ChangeDataToolAlongLine(prop); + break; + case VToolArc::Type: + ChangeDataToolArc(prop); + break; + case VToolBisector::Type: + ChangeDataToolBisector(prop); + break; + case VToolCutArc::Type: + ChangeDataToolCutArc(prop); + break; + case VToolCutSpline::Type: + ChangeDataToolCutSpline(prop); + break; + case VToolCutSplinePath::Type: + ChangeDataToolCutSplinePath(prop); + break; + case VToolHeight::Type: + ChangeDataToolHeight(prop); + break; + case VToolLine::Type: + ChangeDataToolLine(prop); + break; + case VToolLineIntersect::Type: + ChangeDataToolLineIntersect(prop); + break; + case VToolNormal::Type: + ChangeDataToolNormal(prop); + break; + case VToolPointOfContact::Type: + ChangeDataToolPointOfContact(prop); + break; + case VToolPointOfIntersection::Type: + ChangeDataToolPointOfIntersection(prop); + break; + case VToolShoulderPoint::Type: + ChangeDataToolShoulderPoint(prop); + break; + case VToolSpline::Type: + ChangeDataToolSpline(prop); + break; + case VToolSplinePath::Type: + ChangeDataToolSplinePath(prop); + break; + case VToolTriangle::Type: + ChangeDataToolTriangle(prop); + break; + case VToolLineIntersectAxis::Type: + ChangeDataToolLineIntersectAxis(prop); + break; + case VToolCurveIntersectAxis::Type: + ChangeDataToolCurveIntersectAxis(prop); + break; + default: + break; + } + qApp->getSceneView()->update(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) +{ + if (item != nullptr) + { + if (item->isEnabled()==false) + { + return; + } + } + + if (currentItem == item && item != nullptr) + { + UpdateOptions(); + return; + } + + PropertyModel->clear(); + propertyToId.clear(); + idToProperty.clear(); + + + if (currentItem != nullptr) + { + VAbstractTool *previousTool = dynamic_cast(currentItem); + if (previousTool != nullptr) + { + previousTool->ShowVisualization(false); // hide for previous tool + } + } + + currentItem = item; + if (currentItem == nullptr) + { + formView->setTitle(""); + return; + } + + ShowItemOptions(currentItem); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName, const VFormula &formula, + const QString &attrName) +{ + VFormulaProperty* itemLength = new VFormulaProperty(propertyName); + itemLength->setFormula(formula); + AddProperty(itemLength, attrName); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &propertyName) +{ + VProperty* itemName = new VProperty(propertyName); + itemName->setValue(i->name()); + AddProperty(itemName, VAbstractTool::AttrName); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName) +{ + VEnumProperty *lineTypeProperty = new VEnumProperty(propertyName); + QStringList styles = VAbstractTool::Styles(); + lineTypeProperty->setLiterals(styles); + qint32 index = styles.indexOf(i->getLineType()); + if (index == -1) + { + qWarning()<<"Can't find line style" << i->getLineType()<<"in list"; + } + lineTypeProperty->setValue(index); + AddProperty(lineTypeProperty, VAbstractTool::AttrTypeLine); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::SetPointName(const QString &name) +{ + if (Tool *i = qgraphicsitem_cast(currentItem)) + { + if (name == i->name()) + { + return; + } + + QRegExp rx(nameRegExp); + if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.exactMatch(name) == false) + { + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + } + else + { + i->setName(name); + } + } + else + { + qWarning()<<"Can't cast item"; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::AddProperty(VProperty *property, const QString &id) +{ + propertyToId[property] = id; + idToProperty[id] = property; + PropertyModel->addProperty(property, id); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ChangeDataToolSinglePoint(VProperty *property) +{ + SCASSERT(property != nullptr) + + QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 1: // QLatin1String("position") + currentItem->setPos(value.toPointF()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolEndLine *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 5: // VAbstractTool::AttrAngle + i->setFormulaAngle(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolAlongLine *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolArc *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 8: // VAbstractTool::AttrRadius + i->setFormulaRadius(value.value()); + break; + case 9: // VAbstractTool::AttrAngle1 + i->setFormulaF1(value.value()); + break; + case 10: // VAbstractTool::AttrAngle2 + i->setFormulaF2(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolBisector *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutArc *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutSpline *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutSplinePath *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolHeight *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolLine *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolNormal *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 5: // VAbstractTool::AttrAngle + i->setAngle(value.toDouble()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolPointOfContact *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 8: // VAbstractTool::AttrRadius + i->setArcRadius(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolShoulderPoint *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolSpline *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 25: // VAbstractTool::AttrKCurve + { + VSpline spl = i->getSpline(); + spl.SetKcurve(value.toDouble()); + i->setSpline(spl); + break; + } + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolSplinePath *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 25: // VAbstractTool::AttrKCurve + { + VSplinePath splPath = i->getSplinePath(); + splPath.setKCurve(value.toDouble()); + i->setSplinePath(splPath); + break; + } + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolLineIntersectAxis *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + case 5: // VAbstractTool::AttrAngle + i->setFormulaAngle(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCurveIntersectAxis *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + case 5: // VAbstractTool::AttrAngle + i->setFormulaAngle(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<(item); + i->ShowVisualization(true); + formView->setTitle(tr("Base point")); + + AddPropertyPointName(i, tr("Point label")); + + VPointFProperty* itemPosition = new VPointFProperty(tr("Position")); + itemPosition->setValue(i->pos()); + AddProperty(itemPosition, QLatin1String("position")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) +{ + VToolEndLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point at distance and angle")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) +{ + VToolAlongLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point at distance along line")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) +{ + VToolArc *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Arc")); + + AddPropertyFormula(tr("Radius"), i->getFormulaRadius(), VAbstractTool::AttrRadius); + AddPropertyFormula(tr("First angle"), i->getFormulaF1(), VAbstractTool::AttrAngle1); + AddPropertyFormula(tr("Second angle"), i->getFormulaF2(), VAbstractTool::AttrAngle2); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) +{ + VToolBisector *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point along bisector")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) +{ + VToolCutArc *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Cut arc tool")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) +{ + VToolCutSpline *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool for segmenting a curve")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *item) +{ + VToolCutSplinePath *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool segment a pathed curve")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) +{ + VToolHeight *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Perpendicular point along line")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) +{ + VToolLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Line between points")); + + AddPropertyLineType(i, tr("Line type")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *item) +{ + VToolLineIntersect *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point at line intersection")); + + AddPropertyPointName(i, tr("Point label")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) +{ + VToolNormal *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point along perpendicular")); + + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + + VDoubleProperty* itemAngle = new VDoubleProperty(tr("Additional angle degrees")); + itemAngle->setValue(i->getAngle()); + itemAngle->setSetting("Min", -360); + itemAngle->setSetting("Max", 360); + itemAngle->setSetting("Precision", 3); + AddProperty(itemAngle, VAbstractTool::AttrAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *item) +{ + VToolPointOfContact *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point at intersection of arc and line")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Radius"), i->getArcRadius(), VAbstractTool::AttrRadius); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsItem *item) +{ + VToolPointOfIntersection *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool to make point from x & y of two other points")); + + AddPropertyPointName(i, tr("Point label")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) +{ + VToolShoulderPoint *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Special point on shoulder")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) +{ + VToolSpline *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Curve tool")); + + VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); + VSpline spl = i->getSpline(); + itemFactor->setSetting("Min", 0.1); + itemFactor->setSetting("Max", 1000); + itemFactor->setSetting("Step", 0.01); + itemFactor->setSetting("Precision", 3); + itemFactor->setValue(spl.GetKcurve()); + AddProperty(itemFactor, VAbstractTool::AttrKCurve); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) +{ + VToolSplinePath *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool for path curve")); + + VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); + VSplinePath splPath = i->getSplinePath(); + itemFactor->setSetting("Min", 0.1); + itemFactor->setSetting("Max", 1000); + itemFactor->setSetting("Step", 0.01); + itemFactor->setSetting("Precision", 3); + itemFactor->setValue(splPath.getKCurve()); + AddProperty(itemFactor, VAbstractTool::AttrKCurve); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item) +{ + VToolTriangle *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool triangle")); + + AddPropertyPointName(i, tr("Point label")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem *item) +{ + VToolLineIntersectAxis *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point intersection line and axis")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item) +{ + VToolCurveIntersectAxis *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); + formView->setTitle(tr("Point intersection line and axis")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint() +{ + VToolSinglePoint *i = qgraphicsitem_cast(currentItem); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + idToProperty[QLatin1String("position")]->setValue(i->pos()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() +{ + VToolEndLine *i = qgraphicsitem_cast(currentItem); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + QVariant valueAngle; + valueAngle.setValue(i->getFormulaAngle()); + idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() +{ + VToolAlongLine *i = qgraphicsitem_cast(currentItem); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolArc() +{ + VToolArc *i = qgraphicsitem_cast(currentItem); + + + QVariant valueRadius; + valueRadius.setValue(i->getFormulaRadius()); + idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius); + + QVariant valueFirstAngle; + valueFirstAngle.setValue(i->getFormulaF1()); + idToProperty[VAbstractTool::AttrAngle1]->setValue(valueFirstAngle); + + QVariant valueSecondAngle; + valueSecondAngle.setValue(i->getFormulaF2()); + idToProperty[VAbstractTool::AttrAngle2]->setValue(valueSecondAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() +{ + VToolBisector *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc() +{ + VToolCutArc *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline() +{ + VToolCutSpline *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath() +{ + VToolCutSplinePath *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() +{ + VToolHeight *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() +{ + VToolLine *i = qgraphicsitem_cast(currentItem); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersect() +{ + VToolLineIntersect *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() +{ + VToolNormal *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + idToProperty[VAbstractTool::AttrAngle]->setValue( i->getAngle()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfContact() +{ + VToolPointOfContact *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getArcRadius()); + idToProperty[VAbstractTool::AttrRadius]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersection() +{ + VToolPointOfIntersection *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() +{ + VToolShoulderPoint *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() +{ + VToolSpline *i = qgraphicsitem_cast(currentItem); + + VSpline spl = i->getSpline(); + idToProperty[VAbstractTool::AttrKCurve]->setValue(spl.GetKcurve()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() +{ + VToolSplinePath *i = qgraphicsitem_cast(currentItem); + + VSplinePath splPath = i->getSplinePath(); + idToProperty[VAbstractTool::AttrKCurve]->setValue(splPath.getKCurve()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolTriangle() +{ + VToolTriangle *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis() +{ + VToolLineIntersectAxis *i = qgraphicsitem_cast(currentItem); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueAngle; + valueAngle.setValue(i->getFormulaAngle()); + idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis() +{ + VToolCurveIntersectAxis *i = qgraphicsitem_cast(currentItem); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueAngle; + valueAngle.setValue(i->getFormulaAngle()); + idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList VToolOptionsPropertyBrowser::PropertiesList() const +{ + QStringList attr = QStringList() << VAbstractTool::AttrName /* 0 */ + << QLatin1String("position") /* 1 */ + << VAbstractTool::AttrBasePoint /* 2 */ + << VAbstractTool::AttrTypeLine /* 3 */ + << VAbstractTool::AttrLength /* 4 */ + << VAbstractTool::AttrAngle /* 5 */ + << VAbstractTool::AttrFirstPoint /* 6 */ + << VAbstractTool::AttrSecondPoint /* 7 */ + << VAbstractTool::AttrRadius /* 8 */ + << VAbstractTool::AttrAngle1 /* 9 */ + << VAbstractTool::AttrAngle2 /* 10 */ + << VAbstractTool::AttrCenter /* 11 */ + << VAbstractTool::AttrThirdPoint /* 12 */ + << VToolCutArc::AttrArc /* 13 */ + << VToolCutSpline::AttrSpline /* 14 */ + << VToolCutSplinePath::AttrSplinePath /* 15 */ + << VAbstractTool::AttrP1Line /* 16 */ + << VAbstractTool::AttrP2Line /* 17 */ + << VAbstractTool::AttrP1Line1 /* 18 */ + << VAbstractTool::AttrP2Line1 /* 19 */ + << VAbstractTool::AttrP1Line2 /* 20 */ + << VAbstractTool::AttrP2Line2 /* 21 */ + << VAbstractTool::AttrPShoulder /* 22 */ + << VAbstractTool::AttrAxisP1 /* 23 */ + << VAbstractTool::AttrAxisP2 /* 24 */ + << VAbstractTool::AttrKCurve; /* 25 */ + return attr; +} diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h new file mode 100644 index 000000000..1c4c65fa1 --- /dev/null +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -0,0 +1,144 @@ +/************************************************************************ + ** + ** @file vtooloptionspropertybrowser.h + ** @author Roman Telezhynskyi + ** @date 22 8, 2014 + ** + ** @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) 2014 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 VTOOLOPTIONSPROPERTYBROWSER_H +#define VTOOLOPTIONSPROPERTYBROWSER_H + +#include +#include + +#include "../../libs/vpropertyexplorer/vproperty.h" +#include "../../libs/vpropertyexplorer/vpropertymodel.h" +#include "../../libs/vpropertyexplorer/vpropertyformview.h" + +class QDockWidget; +class QGraphicsItem; +class QScrollArea; +class VFormula; + +class VToolOptionsPropertyBrowser : public QObject +{ + Q_OBJECT +public: + VToolOptionsPropertyBrowser(QDockWidget *parent); + void ClearPropertyBrowser(); +public slots: + void itemClicked(QGraphicsItem *item); + void userChangedData(VPE::VProperty* property); + void UpdateOptions(); +private: + Q_DISABLE_COPY(VToolOptionsPropertyBrowser) + + VPE::VPropertyModel* PropertyModel; + VPE::VPropertyFormView* formView; + + QGraphicsItem *currentItem; + QMap propertyToId; + QMap idToProperty; + + void AddProperty(VPE::VProperty *property, const QString &id); + void ShowItemOptions(QGraphicsItem *item); + + template + void SetPointName(const QString &name); + + template + void AddPropertyPointName(Tool *i, const QString &propertyName); + + template + void AddPropertyLineType(Tool *i, const QString &propertyName); + + void AddPropertyFormula(const QString &propertyName, const VFormula &formula, const QString &attrName); + + QStringList PropertiesList() const; + + void ChangeDataToolSinglePoint(VPE::VProperty *property); + void ChangeDataToolEndLine(VPE::VProperty *property); + void ChangeDataToolAlongLine(VPE::VProperty *property); + void ChangeDataToolArc(VPE::VProperty *property); + void ChangeDataToolBisector(VPE::VProperty *property); + void ChangeDataToolCutArc(VPE::VProperty *property); + void ChangeDataToolCutSpline(VPE::VProperty *property); + void ChangeDataToolCutSplinePath(VPE::VProperty *property); + void ChangeDataToolHeight(VPE::VProperty *property); + void ChangeDataToolLine(VPE::VProperty *property); + void ChangeDataToolLineIntersect(VPE::VProperty *property); + void ChangeDataToolNormal(VPE::VProperty *property); + void ChangeDataToolPointOfContact(VPE::VProperty *property); + void ChangeDataToolPointOfIntersection(VPE::VProperty *property); + void ChangeDataToolShoulderPoint(VPE::VProperty *property); + void ChangeDataToolSpline(VPE::VProperty *property); + void ChangeDataToolSplinePath(VPE::VProperty *property); + void ChangeDataToolTriangle(VPE::VProperty *property); + void ChangeDataToolLineIntersectAxis(VPE::VProperty *property); + void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property); + + void ShowOptionsToolSinglePoint(QGraphicsItem *item); + void ShowOptionsToolEndLine(QGraphicsItem *item); + void ShowOptionsToolAlongLine(QGraphicsItem *item); + void ShowOptionsToolArc(QGraphicsItem *item); + void ShowOptionsToolBisector(QGraphicsItem *item); + void ShowOptionsToolCutArc(QGraphicsItem *item); + void ShowOptionsToolCutSpline(QGraphicsItem *item); + void ShowOptionsToolCutSplinePath(QGraphicsItem *item); + void ShowOptionsToolHeight(QGraphicsItem *item); + void ShowOptionsToolLine(QGraphicsItem *item); + void ShowOptionsToolLineIntersect(QGraphicsItem *item); + void ShowOptionsToolNormal(QGraphicsItem *item); + void ShowOptionsToolPointOfContact(QGraphicsItem *item); + void ShowOptionsToolPointOfIntersection(QGraphicsItem *item); + void ShowOptionsToolShoulderPoint(QGraphicsItem *item); + void ShowOptionsToolSpline(QGraphicsItem *item); + void ShowOptionsToolSplinePath(QGraphicsItem *item); + void ShowOptionsToolTriangle(QGraphicsItem *item); + void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item); + void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item); + + void UpdateOptionsToolSinglePoint(); + void UpdateOptionsToolEndLine(); + void UpdateOptionsToolAlongLine(); + void UpdateOptionsToolArc(); + void UpdateOptionsToolBisector(); + void UpdateOptionsToolCutArc(); + void UpdateOptionsToolCutSpline(); + void UpdateOptionsToolCutSplinePath(); + void UpdateOptionsToolHeight(); + void UpdateOptionsToolLine(); + void UpdateOptionsToolLineIntersect(); + void UpdateOptionsToolNormal(); + void UpdateOptionsToolPointOfContact(); + void UpdateOptionsToolPointOfIntersection(); + void UpdateOptionsToolShoulderPoint(); + void UpdateOptionsToolSpline(); + void UpdateOptionsToolSplinePath(); + void UpdateOptionsToolTriangle(); + void UpdateOptionsToolLineIntersectAxis(); + void UpdateOptionsToolCurveIntersectAxis(); +}; + +#endif // VTOOLOPTIONSPROPERTYBROWSER_H diff --git a/src/app/widgets/widgets.pri b/src/app/widgets/widgets.pri new file mode 100644 index 000000000..ef5e646c1 --- /dev/null +++ b/src/app/widgets/widgets.pri @@ -0,0 +1,24 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vtablegraphicsview.h \ + $$PWD/vmaingraphicsview.h \ + $$PWD/vmaingraphicsscene.h \ + $$PWD/vitem.h \ + $$PWD/doubledelegate.h \ + $$PWD/textdelegate.h \ + $$PWD/vtooloptionspropertybrowser.h \ + $$PWD/vformulapropertyeditor.h \ + $$PWD/vformulaproperty.h + +SOURCES += \ + $$PWD/vtablegraphicsview.cpp \ + $$PWD/vmaingraphicsview.cpp \ + $$PWD/vmaingraphicsscene.cpp \ + $$PWD/vitem.cpp \ + $$PWD/doubledelegate.cpp \ + $$PWD/textdelegate.cpp \ + $$PWD/vtooloptionspropertybrowser.cpp \ + $$PWD/vformulapropertyeditor.cpp \ + $$PWD/vformulaproperty.cpp diff --git a/src/app/xml/vabstractmeasurements.cpp b/src/app/xml/vabstractmeasurements.cpp new file mode 100644 index 000000000..fbf3339b7 --- /dev/null +++ b/src/app/xml/vabstractmeasurements.cpp @@ -0,0 +1,274 @@ +/************************************************************************ + ** + ** @file vabstractmeasurements.cpp + ** @author Roman Telezhynskyi + ** @date 18 6, 2014 + ** + ** @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) 2014 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 "vabstractmeasurements.h" + +const QString VAbstractMeasurements::TagUnit = QStringLiteral("unit"); +const QString VAbstractMeasurements::AttrValue = QStringLiteral("value"); + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractMeasurements::VAbstractMeasurements(VContainer *data) + :VDomDocument(), data(data) +{ + SCASSERT(data != nullptr) +} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractMeasurements::~VAbstractMeasurements() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Measurements help read all measurements. + * + * Virtual method that keep all common measurements name. Measurements height and size create in different way in + * individual and standard measurements, see VIndividualMeasurements::Measurements(). + */ +void VAbstractMeasurements::Measurements() +{ + //Set of measurements common for both standard. + //head and neck + Measurement(headGirth_M); + Measurement(midNeckGirth_M); + Measurement(neckBaseGirth_M); + Measurement(headAndNeckLength_M); + //torso + Measurement(centerFrontWaistLength_M); + Measurement(centerBackWaistLength_M); + Measurement(shoulderLength_M); + Measurement(sideWaistLength_M); + Measurement(trunkLength_M); + Measurement(shoulderGirth_M); + Measurement(upperChestGirth_M); + Measurement(bustGirth_M); + Measurement(underBustGirth_M); + Measurement(waistGirth_M); + Measurement(highHipGirth_M); + Measurement(hipGirth_M); + Measurement(upperFrontChestWidth_M); + Measurement(frontChestWidth_M); + Measurement(acrossFrontShoulderWidth_M); + Measurement(acrossBackShoulderWidth_M); + Measurement(upperBackWidth_M); + Measurement(backWidth_M); + Measurement(bustpointToBustpoint_M); + Measurement(halterBustpointToBustpoint_M); + Measurement(neckToBustpoint_M); + Measurement(crotchLength_M); + Measurement(riseHeight_M); + Measurement(shoulderDrop_M); + Measurement(shoulderSlopeDegrees_M); + Measurement(frontShoulderSlopeLength_M); + Measurement(backShoulderSlopeLength_M); + Measurement(frontShoulderToWaistLength_M); + Measurement(backShoulderToWaistLength_M); + Measurement(frontNeckArc_M); + Measurement(backNeckArc_M); + Measurement(frontUpperChestArc_M); + Measurement(backUpperChestArc_M); + Measurement(frontWaistArc_M); + Measurement(backWaistArc_M); + Measurement(frontUpperHipArc_M); + Measurement(backUpperHipArc_M); + Measurement(frontHipArc_M); + Measurement(backHipArc_M); + Measurement(chestSlope_M); + Measurement(backSlope_M); + Measurement(frontWaistSlope_M); + Measurement(backWaistSlope_M); + Measurement(frontNeckToUpperChestHeight_M); + Measurement(frontNeckToBustHeight_M); + Measurement(frontWaistToUpperChest_M); + Measurement(frontWaistToLowerBreast_M); + Measurement(backWaistToUpperChest_M); + Measurement(strapLength_M); + //arm + Measurement(armscyeGirth_M); + Measurement(elbowGirth_M); + Measurement(upperArmGirth_M); + Measurement(wristGirth_M); + Measurement(scyeDepth_M); + Measurement(shoulderAndArmLength_M); + Measurement(underarmLength_M); + Measurement(cervicaleToWristLength_M); + Measurement(shoulderToElbowLength_M); + Measurement(armLength_M); + //hand + Measurement(handWidth_M); + Measurement(handLength_M); + Measurement(handGirth_M); + //leg + Measurement(thighGirth_M); + Measurement(midThighGirth_M); + Measurement(kneeGirth_M); + Measurement(calfGirth_M); + Measurement(ankleGirth_M); + Measurement(kneeHeight_M); + Measurement(ankleHeight_M); + //foot + Measurement(footWidth_M); + Measurement(footLength_M); + //heights + Measurement(cervicaleHeight_M); + Measurement(cervicaleToKneeHeight_M); + Measurement(waistHeight_M); + Measurement(highHipHeight_M); + Measurement(hipHeight_M); + Measurement(waistToHipHeight_M); + Measurement(waistToKneeHeight_M); + Measurement(crotchHeight_M); + //extended + Measurement(heightFrontNeckBasePoint_M); + Measurement(heightBaseNeckSidePoint_M); + Measurement(heightShoulderPoint_M); + Measurement(heightNipplePoint_M); + Measurement(heightBackAngleAxilla_M); + Measurement(heightScapularPoint_M); + Measurement(heightUnderButtockFolds_M); + Measurement(hipsExcludingProtrudingAbdomen_M); + Measurement(girthFootInstep_M); + Measurement(sideWaistToFloor_M); + Measurement(frontWaistToFloor_M); + Measurement(arcThroughGroinArea_M); + Measurement(waistToPlaneSeat_M); + Measurement(neckToRadialPoint_M); + Measurement(neckToThirdFinger_M); + Measurement(neckToFirstLineChestCircumference_M); + Measurement(frontWaistLength_M); + Measurement(arcThroughShoulderJoint_M); + Measurement(neckToBackLineChestCircumference_M); + Measurement(waistToNeckSide_M); + Measurement(arcLengthUpperBody_M); + Measurement(chestWidth_M); + Measurement(anteroposteriorDiameterHands_M); + Measurement(heightClavicularPoint_M); + Measurement(heightArmholeSlash_M); + Measurement(slashShoulderHeight_M); + Measurement(halfGirthNeck_M); + Measurement(halfGirthNeckForShirts_M); + Measurement(halfGirthChestFirst_M); + Measurement(halfGirthChestSecond_M); + Measurement(halfGirthChestThird_M); + Measurement(halfGirthWaist_M); + Measurement(halfGirthHipsConsideringProtrudingAbdomen_M); + Measurement(halfGirthHipsExcludingProtrudingAbdomen_M); + Measurement(girthKneeFlexedFeet_M); + Measurement(neckTransverseDiameter_M); + Measurement(frontSlashShoulderHeight_M); + Measurement(neckToFrontWaistLine_M); + Measurement(handVerticalDiameter_M); + Measurement(neckToKneePoint_M); + Measurement(waistToKnee_M); + Measurement(shoulderHeight_M); + Measurement(headHeight_M); + Measurement(bodyPosition_M); + Measurement(arcBehindShoulderGirdle_M); + Measurement(neckToNeckBase_M); + Measurement(depthWaistFirst_M); + Measurement(depthWaistSecond_M); +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit VAbstractMeasurements::MUnit() const +{ + const QString unit = UniqueTagText(TagUnit, UnitCM); + return VDomDocument::StrToUnits(unit); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const Unit &to) +{ + switch (from) + { + case Unit::Mm: + switch (to) + { + case Unit::Mm: + return value; + case Unit::Cm: + return value / 10.0; + case Unit::Inch: + return value / 25.4; + default: + break; + } + break; + case Unit::Cm: + switch (to) + { + case Unit::Mm: + return value * 10.0; + case Unit::Cm: + return value; + case Unit::Inch: + return value / 2.54; + default: + break; + } + break; + case Unit::Inch: + switch (to) + { + case Unit::Mm: + return value * 25.4; + case Unit::Cm: + return value * 2.54; + case Unit::Inch: + return value; + default: + break; + } + break; + default: + break; + } + return 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractMeasurements::Measurement(const QString &tag) +{ + const QDomNodeList nodeList = this->elementsByTagName(tag); + if (nodeList.isEmpty()) + { + qWarning()<<"Measurement" << tag <<"doesn't exist"; + return; + } + else + { + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + ReadMeasurement(domElement, tag); + } + } + } +} diff --git a/src/app/xml/vabstractmeasurements.h b/src/app/xml/vabstractmeasurements.h new file mode 100644 index 000000000..ac64c9828 --- /dev/null +++ b/src/app/xml/vabstractmeasurements.h @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file vabstractmeasurements.h + ** @author Roman Telezhynskyi + ** @date 18 6, 2014 + ** + ** @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) 2014 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 VABSTRACTMEASUREMENTS_H +#define VABSTRACTMEASUREMENTS_H + +#include "../libs/ifc/xml/vdomdocument.h" +#include "../container/vcontainer.h" + +class VAbstractMeasurements : public VDomDocument +{ +public: + VAbstractMeasurements(VContainer *data); + virtual ~VAbstractMeasurements(); + virtual void Measurements(); + Unit MUnit() const; + static const QString TagUnit; + static const QString AttrValue; + static qreal UnitConvertor(qreal value, const Unit &from, const Unit &to); +protected: + /** @brief data container with data. */ + VContainer *data; + + void Measurement(const QString &tag); + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) = 0; +private: + Q_DISABLE_COPY(VAbstractMeasurements) +}; + +#endif // VABSTRACTMEASUREMENTS_H diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp new file mode 100644 index 000000000..c39dc72ac --- /dev/null +++ b/src/app/xml/vindividualmeasurements.cpp @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file vindividualmeasurements.cpp + ** @author Roman Telezhynskyi + ** @date 8 3, 2014 + ** + ** @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 + ** 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 "vindividualmeasurements.h" +#include "../core/vapplication.h" +#include + +const QString VIndividualMeasurements::TagFamily_name = QStringLiteral("family-name"); +const QString VIndividualMeasurements::TagGiven_name = QStringLiteral("given-name"); +const QString VIndividualMeasurements::TagBirth_date = QStringLiteral("birth-date"); +const QString VIndividualMeasurements::TagSex = QStringLiteral("sex"); +const QString VIndividualMeasurements::TagEmail = QStringLiteral("email"); +const QString VIndividualMeasurements::SexMale = QStringLiteral("male"); +const QString VIndividualMeasurements::SexFemale = QStringLiteral("female"); + +//--------------------------------------------------------------------------------------------------------------------- +VIndividualMeasurements::VIndividualMeasurements(VContainer *data) + :VAbstractMeasurements(data) +{ + SCASSERT(data != nullptr) +} + +//--------------------------------------------------------------------------------------------------------------------- +VIndividualMeasurements::~VIndividualMeasurements() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setUnit(const Unit &unit) +{ + setTagText(TagUnit, UnitsToStr(unit)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::Measurements() +{ + VAbstractMeasurements::Measurements(); + //heights + Measurement(height_M); + //extended + Measurement(size_M); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag) +{ + qreal value = GetParametrDouble(domElement, AttrValue, "0.0"); + value = UnitConvertor(value, MUnit(), qApp->patternUnit()); + data->AddVariable(tag, new VMeasurement(tag, value, qApp->GuiText(tag), qApp->Description(tag), tag)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VIndividualMeasurements::FamilyName() const +{ + return UniqueTagText(TagFamily_name, ""); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setFamilyName(const QString &text) +{ + setTagText(TagFamily_name, text); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VIndividualMeasurements::GivenName() const +{ + return UniqueTagText(TagGiven_name, ""); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setGivenName(const QString &text) +{ + setTagText(TagGiven_name, text); +} + +//--------------------------------------------------------------------------------------------------------------------- +QDate VIndividualMeasurements::BirthDate() const +{ + const QString date = UniqueTagText(TagBirth_date, "1900-01-01"); + return QDate::fromString(date, "yyyy-MM-dd"); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setBirthDate(const QDate &date) +{ + setTagText(TagBirth_date, date.toString("yyyy-MM-dd")); +} + +//--------------------------------------------------------------------------------------------------------------------- +SexType VIndividualMeasurements::Sex() const +{ + return StrToGender(UniqueTagText(TagSex, "")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setSex(const SexType &sex) +{ + setTagText(TagSex, GenderToStr(sex)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VIndividualMeasurements::Mail() const +{ + return UniqueTagText(TagEmail, ""); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VIndividualMeasurements::setMail(const QString &text) +{ + setTagText(TagEmail, text); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VIndividualMeasurements::GenderToStr(const SexType &sex) +{ + switch (sex) + { + case SexType::Male: + return SexMale; + case SexType::Female: + return SexFemale; + default: + return SexMale; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +SexType VIndividualMeasurements::StrToGender(const QString &sex) +{ + QStringList genders = QStringList() << SexMale << SexFemale; + switch (genders.indexOf(sex)) + { + case 0: // SexMale + return SexType::Male; + case 1: // SexFemale + return SexType::Female; + default: + return SexType::Male; + } +} diff --git a/src/app/xml/vindividualmeasurements.h b/src/app/xml/vindividualmeasurements.h new file mode 100644 index 000000000..85e967216 --- /dev/null +++ b/src/app/xml/vindividualmeasurements.h @@ -0,0 +1,78 @@ +/************************************************************************ + ** + ** @file vindividualmeasurements.h + ** @author Roman Telezhynskyi + ** @date 8 3, 2014 + ** + ** @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 + ** 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 VINDIVIDUALMEASUREMENTS_H +#define VINDIVIDUALMEASUREMENTS_H + +#include "vabstractmeasurements.h" + +/* + VIT_VERSION is (major << 16) + (minor << 8) + patch. +*/ +// version without patch part +#define VIT_MIN_VERSION 0x000200 +// max support version of format +#define VIT_VERSION 0x000200 + +enum class SexType : char { Male, Female }; + +class VIndividualMeasurements:public VAbstractMeasurements +{ +public: + VIndividualMeasurements(VContainer *data); + virtual ~VIndividualMeasurements(); + void setUnit(const Unit &unit); + virtual void Measurements(); + QString FamilyName() const; + void setFamilyName(const QString &text); + QString GivenName() const; + void setGivenName(const QString &text); + QDate BirthDate() const; + void setBirthDate(const QDate &date); + SexType Sex() const; + void setSex(const SexType &sex); + QString Mail() const; + void setMail(const QString &text); + + static const QString TagFamily_name; + static const QString TagGiven_name; + static const QString TagBirth_date; + static const QString TagSex; + static const QString TagEmail; + static const QString SexMale; + static const QString SexFemale; + + static QString GenderToStr(const SexType &sex); + static SexType StrToGender(const QString &sex); +protected: + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag); +private: + Q_DISABLE_COPY(VIndividualMeasurements) +}; + +#endif // VINDIVIDUALMEASUREMENTS_H diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp new file mode 100644 index 000000000..4e567f6c3 --- /dev/null +++ b/src/app/xml/vpattern.cpp @@ -0,0 +1,2753 @@ +/************************************************************************ + ** + ** @file vpattern.cpp + ** @author Roman Telezhynskyi + ** @date 24 2, 2014 + ** + ** @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 + ** 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 "vpattern.h" +#include "../tools/vdatatool.h" +#include "../tools/vtooldetail.h" +#include "../tools/vtooluniondetails.h" +#include "../tools/drawTools/drawtools.h" +#include "../tools/nodeDetails/nodedetails.h" +#include "../libs/ifc/exception/vexceptionobjecterror.h" +#include "../libs/ifc/exception/vexceptionwrongid.h" +#include "../libs/ifc/exception/vexceptionconversionerror.h" +#include "../libs/ifc/exception/vexceptionemptyparameter.h" +#include "../libs/ifc/exception/vexceptionundo.h" +#include "../libs/ifc/xml/vpatternconverter.h" +#include "../core/undoevent.h" +#include "../core/vsettings.h" +#include "vstandardmeasurements.h" +#include "vindividualmeasurements.h" +#include "../../libs/qmuparser/qmuparsererror.h" +#include "../geometry/varc.h" + +#include +#include +#include + +const QString VPattern::TagPattern = QStringLiteral("pattern"); +const QString VPattern::TagCalculation = QStringLiteral("calculation"); +const QString VPattern::TagModeling = QStringLiteral("modeling"); +const QString VPattern::TagDetails = QStringLiteral("details"); +const QString VPattern::TagAuthor = QStringLiteral("author"); +const QString VPattern::TagDescription = QStringLiteral("description"); +const QString VPattern::TagNotes = QStringLiteral("notes"); +const QString VPattern::TagMeasurements = QStringLiteral("measurements"); +const QString VPattern::TagIncrements = QStringLiteral("increments"); +const QString VPattern::TagIncrement = QStringLiteral("increment"); +const QString VPattern::TagDraw = QStringLiteral("draw"); +const QString VPattern::TagPoint = QStringLiteral("point"); +const QString VPattern::TagLine = QStringLiteral("line"); +const QString VPattern::TagSpline = QStringLiteral("spline"); +const QString VPattern::TagArc = QStringLiteral("arc"); +const QString VPattern::TagTools = QStringLiteral("tools"); +const QString VPattern::TagGradation = QStringLiteral("gradation"); +const QString VPattern::TagHeights = QStringLiteral("heights"); +const QString VPattern::TagSizes = QStringLiteral("sizes"); + +const QString VPattern::AttrName = QStringLiteral("name"); +const QString VPattern::AttrType = QStringLiteral("type"); +const QString VPattern::AttrPath = QStringLiteral("path"); + +const QString VPattern::AttrAll = QStringLiteral("all"); + +const QString VPattern::AttrH92 = QStringLiteral("h92"); +const QString VPattern::AttrH98 = QStringLiteral("h98"); +const QString VPattern::AttrH104 = QStringLiteral("h104"); +const QString VPattern::AttrH110 = QStringLiteral("h110"); +const QString VPattern::AttrH116 = QStringLiteral("h116"); +const QString VPattern::AttrH122 = QStringLiteral("h122"); +const QString VPattern::AttrH128 = QStringLiteral("h128"); +const QString VPattern::AttrH134 = QStringLiteral("h134"); +const QString VPattern::AttrH140 = QStringLiteral("h140"); +const QString VPattern::AttrH146 = QStringLiteral("h146"); +const QString VPattern::AttrH152 = QStringLiteral("h152"); +const QString VPattern::AttrH158 = QStringLiteral("h158"); +const QString VPattern::AttrH164 = QStringLiteral("h164"); +const QString VPattern::AttrH170 = QStringLiteral("h170"); +const QString VPattern::AttrH176 = QStringLiteral("h176"); +const QString VPattern::AttrH182 = QStringLiteral("h182"); +const QString VPattern::AttrH188 = QStringLiteral("h188"); +const QString VPattern::AttrH194 = QStringLiteral("h194"); + +const QString VPattern::AttrS22 = QStringLiteral("s22"); +const QString VPattern::AttrS24 = QStringLiteral("s24"); +const QString VPattern::AttrS26 = QStringLiteral("s26"); +const QString VPattern::AttrS28 = QStringLiteral("s28"); +const QString VPattern::AttrS30 = QStringLiteral("s30"); +const QString VPattern::AttrS32 = QStringLiteral("s32"); +const QString VPattern::AttrS34 = QStringLiteral("s34"); +const QString VPattern::AttrS36 = QStringLiteral("s36"); +const QString VPattern::AttrS38 = QStringLiteral("s38"); +const QString VPattern::AttrS40 = QStringLiteral("s40"); +const QString VPattern::AttrS42 = QStringLiteral("s42"); +const QString VPattern::AttrS44 = QStringLiteral("s44"); +const QString VPattern::AttrS46 = QStringLiteral("s46"); +const QString VPattern::AttrS48 = QStringLiteral("s48"); +const QString VPattern::AttrS50 = QStringLiteral("s50"); +const QString VPattern::AttrS52 = QStringLiteral("s52"); +const QString VPattern::AttrS54 = QStringLiteral("s54"); +const QString VPattern::AttrS56 = QStringLiteral("s56"); + +const QString VPattern::IncrementName = QStringLiteral("name"); +const QString VPattern::IncrementBase = QStringLiteral("base"); +const QString VPattern::IncrementKsize = QStringLiteral("ksize"); +const QString VPattern::IncrementKgrowth = QStringLiteral("kgrowth"); +const QString VPattern::IncrementDescription = QStringLiteral("description"); + +//--------------------------------------------------------------------------------------------------------------------- +VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, + VMainGraphicsScene *sceneDetail, QObject *parent) + : QObject(parent), VDomDocument(), data(data), nameActivPP(QString()), tools(QHash()), + history(QVector()), cursor(0), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw), + sceneDetail(sceneDetail) +{ + SCASSERT(sceneDraw != nullptr); + SCASSERT(sceneDetail != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CreateEmptyFile create minimal empty file. + * @param tablePath path to measurement file (standard or individual) + */ +void VPattern::CreateEmptyFile(const QString &tablePath) +{ + if (tablePath.isEmpty()) + { + throw VException("Path to measurement table empty."); + } + this->clear(); + QDomElement patternElement = this->createElement(TagPattern); + + patternElement.appendChild(createComment("Valentina pattern format.")); + + QDomElement version = createElement(TagVersion); + QDomText newNodeText = createTextNode(VPatternConverter::PatternMaxVerStr); + version.appendChild(newNodeText); + patternElement.appendChild(version); + + patternElement.appendChild(createElement(TagAuthor)); + patternElement.appendChild(createElement(TagDescription)); + patternElement.appendChild(createElement(TagNotes)); + + QDomElement measurements = createElement(TagMeasurements); + SetAttribute(measurements, AttrUnit, UnitsToStr(qApp->patternUnit())); + SetAttribute(measurements, AttrType, qApp->patternType()); + SetAttribute(measurements, AttrPath, tablePath); + patternElement.appendChild(measurements); + + patternElement.appendChild(createElement(TagIncrements)); + + this->appendChild(patternElement); + insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangeActivPP set new active pattern piece name. + * @param name new name. + * @param parse parser file mode. + */ +void VPattern::ChangeActivPP(const QString &name, const Document &parse) +{ + Q_ASSERT_X(name.isEmpty() == false, "ChangeActivPP", "name pattern piece is empty"); + if (CheckExistNamePP(name) && this->nameActivPP != name) + { + this->nameActivPP = name; + if (parse == Document::FullParse) + { + emit ChangedActivPP(name); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetActivDrawElement return draw tag for current pattern peace. + * @param element draw tag. + * @return true if found. + */ +bool VPattern::GetActivDrawElement(QDomElement &element) const +{ + if (nameActivPP.isEmpty() == false) + { + const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); + if (elements.size() == 0) + { + return false; + } + for ( qint32 i = 0; i < elements.count(); i++ ) + { + element = elements.at( i ).toElement(); + if (element.isNull() == false) + { + const QString fieldName = element.attribute( AttrName ); + if ( fieldName == nameActivPP ) + { + return true; + } + } + } + element = QDomElement(); + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief appendPP add new pattern piece. + * + * Method check if not exist pattern piece with the same name and change name active pattern piece name, send signal + * about change pattern piece. Doen't add pattern piece to file structure. This task make SPoint tool. + * @param name pattern peace name. + * @return true if success. + */ +bool VPattern::appendPP(const QString &name) +{ + Q_ASSERT_X(name.isEmpty() == false, "appendPP", "name pattern piece is empty"); + if (name.isEmpty()) + { + return false; + } + if (CheckExistNamePP(name) == false) + { + if (nameActivPP.isEmpty()) + { + SetActivPP(name); + } + else + { + this->nameActivPP = name; + emit ChangedActivPP(name); + } + return true; + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangeNamePP change pattern piece name. + * @param oldName old pattern piece name. + * @param newName new pattern piece name. + * @return true if success. + */ +bool VPattern::ChangeNamePP(const QString& oldName, const QString &newName) +{ + Q_ASSERT_X(newName.isEmpty() == false, "SetNamePP", "new name pattern piece is empty"); + Q_ASSERT_X(oldName.isEmpty() == false, "SetNamePP", "old name pattern piece is empty"); + + if (CheckExistNamePP(oldName) == false) + { + qDebug()<<"Do not exist pattern piece with name"< 1)//don't need upadate data if we have only one pattern piece + { + qCDebug(vXML)<<"Setting current data"; + qCDebug(vXML)<<"Current PP name"< 0) + { + try + { + ToolExists(id); + } + catch (VExceptionBadId &e) + { + qCDebug(vXML)<<"List of tools doesn't containe id="<getData(); + qCDebug(vXML)<<"Data successfully updated."; + } + else + { + qCDebug(vXML)<<"List of tools is empty!"; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddTool add tool to list tools. + * @param id tool id. + * @param tool tool. + */ +void VPattern::AddTool(const quint32 &id, VDataTool *tool) +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + SCASSERT(tool != nullptr); + tools.insert(id, tool); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateToolData update tool in list tools. + * @param id tool id. + * @param data container with variables. + */ +void VPattern::UpdateToolData(const quint32 &id, VContainer *data) +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + SCASSERT(data != nullptr); + ToolExists(id); + VDataTool *tool = tools.value(id); + SCASSERT(tool != nullptr); + tool->VDataTool::setData(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief IncrementReferens increment reference parent objects. + * @param id parent object id. + */ +void VPattern::IncrementReferens(quint32 id) const +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + ToolExists(id); + VDataTool *tool = tools.value(id); + SCASSERT(tool != nullptr); + tool->incrementReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DecrementReferens decrement reference parent objects. + * @param id parent object id. + */ +void VPattern::DecrementReferens(quint32 id) const +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + ToolExists(id); + VDataTool *tool = tools.value(id); + SCASSERT(tool != nullptr); + tool->decrementReferens(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SPointActiveDraw return id base point current pattern peace. + * @return id base point. + */ +quint32 VPattern::SPointActiveDraw() +{ + QDomElement calcElement; + if (GetActivNodeElement(TagCalculation, calcElement)) + { + const QDomNode domNode = calcElement.firstChild(); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == VToolPoint::TagName && + domElement.attribute(AttrType, "") == VToolSinglePoint::ToolType) + { + return GetParametrId(domElement); + } + } + } + } + return 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CheckNameDraw check if exist pattern peace with this name. + * @param name pattern peace name. + * @return true if exist. + */ +bool VPattern::CheckExistNamePP(const QString &name) const +{ + Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty"); + const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); + if (elements.size() == 0) + { + return false; + } + for ( qint32 i = 0; i < elements.count(); i++ ) + { + const QDomElement elem = elements.at( i ).toElement(); + if (elem.isNull() == false) + { + if ( GetParametrString(elem, AttrName) == name ) + { + return true; + } + } + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetActivPP set current pattern piece. + * @param name pattern peace name. + */ +void VPattern::SetActivPP(const QString &name) +{ + Q_ASSERT_X(name.isEmpty() == false, "SetActivPP", "name pattern piece is empty"); + this->nameActivPP = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetActivNodeElement find element in current pattern piece by name. + * @param name name tag. + * @param element element. + * @return true if found. + */ +bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element) const +{ + Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty"); + QDomElement drawElement; + if (GetActivDrawElement(drawElement)) + { + const QDomNodeList listElement = drawElement.elementsByTagName(name); + if (listElement.size() != 1) + { + return false; + } + element = listElement.at( 0 ).toElement(); + if (element.isNull() == false) + { + return true; + } + else + { + return false; + } + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::MPath() const +{ + QDomNodeList list = elementsByTagName(TagMeasurements); + QDomElement element = list.at(0).toElement(); + if (element.isElement()) + { + return GetParametrString(element, AttrPath); + } + else + { + return QString(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetPath(const QString &path) +{ + if (path.isEmpty()) + { + qDebug()<<"Path to measurements is empty"<getMainWindow()); + return false; + } + + return VDomDocument::SaveDocument(fileName, error); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LiteParseTree lite parse file. + */ +void VPattern::LiteParseTree(const Document &parse) +{ + // Save name current pattern piece + QString namePP = nameActivPP; + + try + { + emit SetEnabledGUI(true); + switch (parse) + { + case Document::LitePPParse: + ParseCurrentPP(); + break; + case Document::LiteParse: + Parse(parse); + break; + case Document::FullParse: + qCWarning(vXML)<<"Lite parsing doesn't support full parsing"; + break; + default: + break; + } + } + catch (const VExceptionUndo &e) + { + Q_UNUSED(e); + /* If user want undo last operation before undo we need finish broken redo operation. For those we post event + * myself. Later in method customEvent call undo.*/ + QApplication::postEvent(this, new UndoEvent()); + return; + } + catch (const VExceptionObjectError &e) + { + e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow()); + emit SetEnabledGUI(false); + return; + } + catch (const VExceptionConversionError &e) + { + e.CriticalMessageBox(tr("Error can't convert value."), qApp->getMainWindow()); + emit SetEnabledGUI(false); + return; + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter."), qApp->getMainWindow()); + emit SetEnabledGUI(false); + return; + } + catch (const VExceptionWrongId &e) + { + e.CriticalMessageBox(tr("Error wrong id."), qApp->getMainWindow()); + emit SetEnabledGUI(false); + return; + } + catch (VException &e) + { + e.CriticalMessageBox(tr("Error parsing file."), qApp->getMainWindow()); + emit SetEnabledGUI(false); + return; + } + catch (const std::bad_alloc &) + { +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + QMessageBox::critical(qApp->getMainWindow(), tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."), + QMessageBox::Ok, QMessageBox::Ok); +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + emit SetEnabledGUI(false); + return; + } + + // Restore name current pattern piece + nameActivPP = namePP; + qCDebug(vXML)<<"Current pattern piece"<getSceneView()); + VAbstractTool::NewSceneRect(sceneDetail, qApp->getSceneView()); + qCDebug(vXML)<<"Scene size updated."; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief haveLiteChange we have unsaved change. + */ +void VPattern::haveLiteChange() +{ + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowHistoryTool hightlight tool. + * @param id tool id. + * @param color hightlight color. + * @param enable enable or diasable hightlight. + */ +void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable) +{ + emit ShowTool(id, color, enable); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::NeedFullParsing() +{ + emit UndoCommand(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ClearScene() +{ + emit ClearMainWindow(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::customEvent(QEvent *event) +{ + if (event->type() == UNDO_EVENT) + { + qApp->getUndoStack()->undo(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseDrawElement parse draw tag. + * @param node node. + * @param parse parser file mode. + */ +void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse) +{ + QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails; + QDomNode domNode = node.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + switch (tags.indexOf(domElement.tagName())) + { + case 0: // TagCalculation + data->ClearCalculationGObjects(); + ParseDrawMode(domElement, parse, Draw::Calculation); + break; + case 1: // TagModeling + ParseDrawMode(domElement, parse, Draw::Modeling); + break; + case 2: // TagDetails + ParseDetails(domElement, parse); + break; + default: + qDebug()<<"Wrong tag name"<toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"))); + detail.setMy(qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0"))); + detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); + detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); + detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); + + QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline + << VToolDetail::NodeSplinePath; + const QDomNodeList nodeList = domElement.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VToolDetail::TagNode) + { + const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, NULL_ID_STR); + const qreal mx = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); + const qreal my = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); + const bool reverse = GetParametrUInt(element, VToolDetail::AttrReverse, "0"); + const NodeDetail nodeType = NodeDetail::Contour; + + const QString t = GetParametrString(element, AttrType, "NodePoint"); + Tool tool; + + switch (types.indexOf(t)) + { + case 0: // VToolDetail::NodePoint + tool = Tool::NodePoint; + break; + case 1: // VToolDetail::NodeArc + tool = Tool::NodeArc; + break; + case 2: // VToolDetail::NodeSpline + tool = Tool::NodeSpline; + break; + case 3: // VToolDetail::NodeSplinePath + tool = Tool::NodeSplinePath; + break; + default: + qDebug()<<"Wrong node type."<toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParsePointElement parse point tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of point. + */ +void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, + const Document &parse, const QString &type) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); + + quint32 id = 0; + QString name; + qreal mx = 0; + qreal my = 0; + QString typeLine; + + QStringList points = QStringList() << VToolSinglePoint::ToolType << VToolEndLine::ToolType + << VToolAlongLine::ToolType << VToolShoulderPoint::ToolType + << VToolNormal::ToolType << VToolBisector::ToolType + << VToolLineIntersect::ToolType << VToolPointOfContact::ToolType + << VNodePoint::ToolType << VToolHeight::ToolType << VToolTriangle::ToolType + << VToolPointOfIntersection::ToolType << VToolCutSpline::ToolType + << VToolCutSplinePath::ToolType << VToolCutArc::ToolType + << VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType; + switch (points.indexOf(type)) + { + case 0: //VToolSinglePoint::ToolType + { + VToolSinglePoint *spoint = 0; + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0")); + const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0")); + + data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); + VDrawTool::AddRecord(id, Tool::SinglePoint, this); + if (parse != Document::FullParse) + { + UpdateToolData(id, data); + } + if (parse == Document::FullParse) + { + spoint = new VToolSinglePoint(this, data, id, Source::FromFile, nameActivPP, MPath()); + scene->addItem(spoint); + connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolPoint::Disable); + tools[id] = spoint; + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating single point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + scene->removeItem(spoint); + delete spoint; + throw excep; + } + break; + } + case 1: //VToolEndLine::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; + + const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); + + const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); + QString angleFix = angle; + + VToolEndLine::Create(id, name, typeLine, f, angleFix, basePointId, mx, my, scene, this, data, parse, + Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula || angleFix != angle) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 2: //VToolAlongLine::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + + VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this, + data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 3: //VToolShoulderPoint::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; + const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); + const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR); + const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, NULL_ID_STR); + + VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, + data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 4: //VToolNormal::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); + + VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, + this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 5: //VToolBisector::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, NULL_ID_STR); + + VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId, + typeLine, name, mx, my, scene, this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 6: //VToolLineIntersect::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, NULL_ID_STR); + const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, NULL_ID_STR); + const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, NULL_ID_STR); + const quint32 p2Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, NULL_ID_STR); + + VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, + mx, my, scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 7: //VToolPointOfContact::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0"); + QString f = radius;//need for saving fixed formula; + const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, NULL_ID_STR); + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + + VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this, + data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != radius) + { + SetAttribute(domElement, VAbstractTool::AttrRadius, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 8: //VNodePoint::ToolType + try + { + PointsCommonAttributes(domElement, id, mx, my); + const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR); + const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); + const QSharedPointer point = data->GeometricObject(idObject ); + data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject, + Draw::Modeling)); + VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 9: //VToolHeight::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); + const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); + const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR); + + VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, + mx, my, scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating height"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 10: //VToolTriangle::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, NULL_ID_STR); + const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, NULL_ID_STR); + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + + VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, + data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 11: //VToolPointOfIntersection::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + + VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, + parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 12: //VToolCutSpline::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; + const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); + + VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 13: //VToolCutSplinePath::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; + const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, + NULL_ID_STR); + + VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, + Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 14: //VToolCutArc::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; + const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, NULL_ID_STR); + + VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 15: //VToolLineIntersectAxis::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + + const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); + const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); + const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR); + + const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); + QString angleFix = angle; + + VToolLineIntersectAxis::Create(id, name, typeLine, angleFix, basePointId, firstPointId, secondPointId, + mx, my, scene, this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (angleFix != angle) + { + SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), + domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), + domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 16: //VToolCurveIntersectAxis::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + + const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); + const quint32 curveId = GetParametrUInt(domElement, VAbstractTool::AttrCurve, NULL_ID_STR); + const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); + QString angleFix = angle; + + VToolCurveIntersectAxis::Create(id, name, typeLine, angleFix, basePointId, curveId, mx, my, scene, this, + data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (angleFix != angle) + { + SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), + domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), + domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + default: + qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseLineElement parse line tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + */ +void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document &parse) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + quint32 id = 0; + try + { + ToolsCommonAttributes(domElement, id); + const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); + const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + + VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool) +{ + ToolsCommonAttributes(domElement, id); + idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR); + idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParseCurrentPP() +{ + QDomElement domElement; + if (GetActivDrawElement(domElement)) + { + ParseDrawElement(domElement, Document::LiteParse); + } + emit CheckLayout(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::CheckTagExists(const QString &tag) +{ + QDomNodeList list = elementsByTagName(tag); + if (list.size() == 0) + { + QStringList tags = QStringList() << TagVersion << TagAuthor << TagDescription << TagNotes << TagGradation; + QDomElement pattern = documentElement(); + switch (tags.indexOf(tag)) + { + case 0: //TagVersion + break;// Mandatory tag + case 1: //TagAuthor + pattern.insertAfter(createElement(TagAuthor), elementsByTagName(TagVersion).at(0)); + SetVersion(); + break; + case 2: //TagDescription + { + for (int i = tags.indexOf(tag)-1; i >= 0; --i) + { + QDomNodeList list = elementsByTagName(tags.at(i)); + if (list.isEmpty()) + { + continue; + } + pattern.insertAfter(createElement(TagDescription), list.at(0)); + } + SetVersion(); + break; + } + case 3: //TagNotes + { + for (int i = tags.indexOf(tag)-1; i >= 0; --i) + { + QDomNodeList list = elementsByTagName(tags.at(i)); + if (list.isEmpty()) + { + continue; + } + pattern.insertAfter(createElement(TagNotes), list.at(0)); + } + SetVersion(); + break; + } + case 4: //TagGradation + { + QDomElement gradation = createElement(TagGradation); + gradation.appendChild(createElement(TagHeights)); + gradation.appendChild(createElement(TagSizes)); + + for (int i = tags.indexOf(tag)-1; i >= 0; --i) + { + QDomNodeList list = elementsByTagName(tags.at(i)); + if (list.isEmpty()) + { + continue; + } + pattern.insertAfter(gradation, list.at(0)); + break; + } + SetVersion(); + break; + } + default: + break; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetLabelBase(unsigned int index) const +{ + QStringList list = VApplication::LabelLanguages(); + QStringList alphabet; + switch (list.indexOf(qApp->getSettings()->GetLabelLanguage())) + { + case 0: // de + { + QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 1: // en + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 2: // fr + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 3: // ru + { + QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я"); + alphabet = al.split(","); + break; + } + case 4: // uk + { + QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я"); + alphabet = al.split(","); + break; + } + case 5: // hr + { + QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž"); + alphabet = al.split(","); + break; + } + case 6: // sr + { + QString al = QStringLiteral("А,Б,В,Г,Д,Ђ,Е,Ж,З,И,Ј,К,Л,Љ,М,Н,Њ,О,П,Р,С,Т,Ћ,У,Ф,Х,Ц,Ч,Џ,Ш"); + alphabet = al.split(","); + break; + } + case 7: // bs + { + QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž"); + alphabet = al.split(","); + break; + } + default: // en + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + } + + QString base; + int count = qFloor(index/static_cast(alphabet.size())); + int number = static_cast(index) - alphabet.size() * count; + int i = 0; + do + { + base.append(alphabet.at(number)); + ++i; + } while (i < count); + return base; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseSplineElement parse spline tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ +void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document &parse, const QString &type) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + quint32 id = 0; + quint32 idObject = 0; + quint32 idTool = 0; + + QStringList splines = QStringList() << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType + << VNodeSplinePath::ToolType; + switch (splines.indexOf(type)) + { + case 0: //VToolSpline::ToolType + try + { + ToolsCommonAttributes(domElement, id); + const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, NULL_ID_STR); + const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, NULL_ID_STR); + const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0"); + const qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0"); + const qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0"); + const qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0"); + const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + + VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse, + Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 1: //VToolSplinePath::ToolType + try + { + ToolsCommonAttributes(domElement, id); + const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + VSplinePath *path = new VSplinePath(kCurve); + + const QDomNodeList nodeList = domElement.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VAbstractTool::AttrPathPoint) + { + const qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0"); + const qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0"); + const qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0"); + const quint32 pSpline = GetParametrUInt(element, VAbstractTool::AttrPSpline, NULL_ID_STR); + const VPointF p = *data->GeometricObject(pSpline); + + QLineF line(0, 0, 100, 0); + line.setAngle(angle+180); + + VSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle); + path->append(splPoint); + if (parse == Document::FullParse) + { + IncrementReferens(pSpline); + } + } + } + } + + VToolSplinePath::Create(id, path, scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 2: //VNodeSpline::ToolType + try + { + SplinesCommonAttributes(domElement, id, idObject, idTool); + VSpline *spl = new VSpline(*data->GeometricObject(idObject)); + spl->setIdObject(idObject); + spl->setMode(Draw::Modeling); + data->UpdateGObject(id, spl); + VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 3: //VNodeSplinePath::ToolType + try + { + SplinesCommonAttributes(domElement, id, idObject, idTool); + VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); + path->setIdObject(idObject); + path->setMode(Draw::Modeling); + data->UpdateGObject(id, path); + VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qDebug() << "Illegal spline type in VDomDocument::ParseSplineElement()."; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseArcElement parse arc tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ +void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, + const QString &type) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + quint32 id = 0; + QStringList arcs = QStringList() << VToolArc::ToolType << VNodeArc::ToolType; + + switch (arcs.indexOf(type)) + { + case 0: //VToolArc::ToolType + try + { + ToolsCommonAttributes(domElement, id); + const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, NULL_ID_STR); + const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10"); + QString r = radius;//need for saving fixed formula; + const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180"); + QString f1Fix = f1;//need for saving fixed formula; + const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); + QString f2Fix = f2;//need for saving fixed formula; + + VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (r != radius || f1Fix != f1 || f2Fix != f2) + { + SetAttribute(domElement, VAbstractTool::AttrRadius, r); + SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix); + SetAttribute(domElement, VAbstractTool::AttrAngle2, f2Fix); + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } + break; + case 1: //VNodeArc::ToolType + try + { + ToolsCommonAttributes(domElement, id); + const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR); + const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); + VArc *arc = new VArc(*data->GeometricObject(idObject)); + arc->setIdObject(idObject); + arc->setMode(Draw::Modeling); + data->UpdateGObject(id, arc); + VNodeArc::Create(this, data, id, idObject, parse, Source::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qDebug() << "Illegal arc type in VDomDocument::ParseArcElement()."; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseToolsElement parse tools tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ +void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document &parse, const QString &type) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + quint32 id = 0; + QStringList tools{VToolUnionDetails::ToolType}; + + switch (tools.indexOf(type)) + { + case 0: //VToolUnionDetails::ToolType + try + { + ToolsCommonAttributes(domElement, id); + const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1"); + const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1"); + + const QVector vector = VToolUnionDetails::GetDetailFromFile(this, domElement); + + VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse, + Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating union details"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qDebug() << "Illegal tools type in VDomDocument::ParseToolsElement()."; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseIncrementsElement parse increments tag. + * @param node tag in xml tree. + */ +void VPattern::ParseIncrementsElement(const QDomNode &node) +{ + QDomNode domNode = node.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == TagIncrement) + { + const quint32 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, IncrementName, ""); + const qreal base = GetParametrDouble(domElement, IncrementBase, "0"); + const qreal ksize = GetParametrDouble(domElement, IncrementKsize, "0"); + const qreal kgrowth = GetParametrDouble(domElement, IncrementKgrowth, "0"); + const QString desc = GetParametrString(domElement, IncrementDescription, "Description"); + data->UpdateId(id); + data->AddVariable(name, new VIncrement(name, id, base, ksize, kgrowth, desc)); + } + } + } + domNode = domNode.nextSibling(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QMap VPattern::GetGradationHeights() const +{ + QMap map; + map.insert(GHeights::ALL, true); + map.insert(GHeights::H92, true); + map.insert(GHeights::H98, true); + map.insert(GHeights::H104, true); + map.insert(GHeights::H110, true); + map.insert(GHeights::H116, true); + map.insert(GHeights::H122, true); + map.insert(GHeights::H128, true); + map.insert(GHeights::H134, true); + map.insert(GHeights::H140, true); + map.insert(GHeights::H146, true); + map.insert(GHeights::H152, true); + map.insert(GHeights::H158, true); + map.insert(GHeights::H164, true); + map.insert(GHeights::H170, true); + map.insert(GHeights::H176, true); + map.insert(GHeights::H182, true); + map.insert(GHeights::H188, true); + map.insert(GHeights::H194, true); + + QDomNodeList tags = elementsByTagName(TagGradation); + if (tags.size() == 0) + { + return map; + } + + QStringList gTags = QStringList() << TagHeights << TagSizes; + QDomNode domNode = tags.at(0).firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + const QString defValue = QStringLiteral("true"); + switch (gTags.indexOf(domElement.tagName())) + { + case 0: // TagHeights + if (GetParametrBool(domElement, AttrAll, defValue)) + { + return map; + } + else + { + map.insert(GHeights::ALL, false); + } + + map.insert(GHeights::H92, GetParametrBool(domElement, AttrH92, defValue)); + map.insert(GHeights::H98, GetParametrBool(domElement, AttrH98, defValue)); + map.insert(GHeights::H104, GetParametrBool(domElement, AttrH104, defValue)); + map.insert(GHeights::H110, GetParametrBool(domElement, AttrH110, defValue)); + map.insert(GHeights::H116, GetParametrBool(domElement, AttrH116, defValue)); + map.insert(GHeights::H122, GetParametrBool(domElement, AttrH122, defValue)); + map.insert(GHeights::H128, GetParametrBool(domElement, AttrH128, defValue)); + map.insert(GHeights::H134, GetParametrBool(domElement, AttrH134, defValue)); + map.insert(GHeights::H140, GetParametrBool(domElement, AttrH140, defValue)); + map.insert(GHeights::H146, GetParametrBool(domElement, AttrH146, defValue)); + map.insert(GHeights::H152, GetParametrBool(domElement, AttrH152, defValue)); + map.insert(GHeights::H158, GetParametrBool(domElement, AttrH158, defValue)); + map.insert(GHeights::H164, GetParametrBool(domElement, AttrH164, defValue)); + map.insert(GHeights::H170, GetParametrBool(domElement, AttrH170, defValue)); + map.insert(GHeights::H176, GetParametrBool(domElement, AttrH176, defValue)); + map.insert(GHeights::H182, GetParametrBool(domElement, AttrH182, defValue)); + map.insert(GHeights::H188, GetParametrBool(domElement, AttrH188, defValue)); + map.insert(GHeights::H194, GetParametrBool(domElement, AttrH194, defValue)); + return map; + break; + case 1: // TagSizes + break; + default: + break; + } + } + } + domNode = domNode.nextSibling(); + } + return map; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetGradationHeights(const QMap &options) +{ + CheckTagExists(TagGradation); + QDomNodeList tags = elementsByTagName(TagGradation); + if (tags.size() == 0) + { + qDebug()<<"Can't save tag "< VPattern::GetGradationSizes() const +{ + QMap map; + map.insert(GSizes::ALL, true); + map.insert(GSizes::S22, true); + map.insert(GSizes::S24, true); + map.insert(GSizes::S26, true); + map.insert(GSizes::S28, true); + map.insert(GSizes::S30, true); + map.insert(GSizes::S32, true); + map.insert(GSizes::S34, true); + map.insert(GSizes::S36, true); + map.insert(GSizes::S38, true); + map.insert(GSizes::S40, true); + map.insert(GSizes::S42, true); + map.insert(GSizes::S44, true); + map.insert(GSizes::S46, true); + map.insert(GSizes::S48, true); + map.insert(GSizes::S50, true); + map.insert(GSizes::S52, true); + map.insert(GSizes::S54, true); + map.insert(GSizes::S56, true); + + QDomNodeList tags = elementsByTagName(TagGradation); + if (tags.size() == 0) + { + return map; + } + + QStringList gTags = QStringList() << TagHeights << TagSizes; + QDomNode domNode = tags.at(0).firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + const QString defValue = QStringLiteral("true"); + switch (gTags.indexOf(domElement.tagName())) + { + case 0: // TagHeights + break; + case 1: // TagSizes + if (GetParametrBool(domElement, AttrAll, defValue)) + { + return map; + } + else + { + map.insert(GSizes::ALL, false); + } + + map.insert(GSizes::S22, GetParametrBool(domElement, AttrS22, defValue)); + map.insert(GSizes::S24, GetParametrBool(domElement, AttrS24, defValue)); + map.insert(GSizes::S26, GetParametrBool(domElement, AttrS26, defValue)); + map.insert(GSizes::S28, GetParametrBool(domElement, AttrS28, defValue)); + map.insert(GSizes::S30, GetParametrBool(domElement, AttrS30, defValue)); + map.insert(GSizes::S32, GetParametrBool(domElement, AttrS32, defValue)); + map.insert(GSizes::S34, GetParametrBool(domElement, AttrS34, defValue)); + map.insert(GSizes::S36, GetParametrBool(domElement, AttrS36, defValue)); + map.insert(GSizes::S38, GetParametrBool(domElement, AttrS38, defValue)); + map.insert(GSizes::S40, GetParametrBool(domElement, AttrS40, defValue)); + map.insert(GSizes::S42, GetParametrBool(domElement, AttrS42, defValue)); + map.insert(GSizes::S44, GetParametrBool(domElement, AttrS44, defValue)); + map.insert(GSizes::S46, GetParametrBool(domElement, AttrS46, defValue)); + map.insert(GSizes::S48, GetParametrBool(domElement, AttrS48, defValue)); + map.insert(GSizes::S50, GetParametrBool(domElement, AttrS50, defValue)); + map.insert(GSizes::S52, GetParametrBool(domElement, AttrS52, defValue)); + map.insert(GSizes::S54, GetParametrBool(domElement, AttrS54, defValue)); + map.insert(GSizes::S56, GetParametrBool(domElement, AttrS56, defValue)); + return map; + break; + default: + break; + } + } + } + domNode = domNode.nextSibling(); + } + return map; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetGradationSizes(const QMap &options) +{ + CheckTagExists(TagGradation); + QDomNodeList tags = elementsByTagName(TagGradation); + if (tags.size() == 0) + { + qDebug()<<"Can't save tag "<getSettings()->GetUser()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetAuthor(const QString &text) +{ + CheckTagExists(TagAuthor); + setTagText(TagAuthor, text); + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetDescription() const +{ + return UniqueTagText(TagDescription); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetDescription(const QString &text) +{ + CheckTagExists(TagDescription); + setTagText(TagDescription, text); + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetNotes() const +{ + return UniqueTagText(TagNotes); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetNotes(const QString &text) +{ + CheckTagExists(TagNotes); + setTagText(TagNotes, text); + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetVersion() const +{ + return UniqueTagText(TagVersion, VPatternConverter::PatternMaxVerStr); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SetVersion() +{ + setTagText(TagVersion, VPatternConverter::PatternMaxVerStr); + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GenerateLabel(const LabelType &type) const +{ + QDomNodeList drawList = elementsByTagName(TagDraw); + + if (type == LabelType::NewPatternPiece) + { + QString name; + int i = 0; + for (;;) + { + name = GetLabelBase(static_cast(drawList.size() + i)); + if (data->IsUnique(name)) + { + return name; + } + if (i == INT_MAX) + { + break; + } + ++i; + } + qCDebug(vXML)<<"Point label:"<(index)); + + qint32 num = 1; + QString name; + do + { + name = QString("%1%2").arg(labelBase).arg(num); + num++; + if (num == INT_MAX) + { + break; + } + } while (data->IsUnique(name) == false); + qCDebug(vXML)<<"Point label:"<(type); + return QString(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::PrepareForParse(const Document &parse) +{ + SCASSERT(sceneDraw != nullptr); + SCASSERT(sceneDetail != nullptr); + if (parse == Document::FullParse) + { + TestUniqueId(); + sceneDraw->clear(); + sceneDetail->clear(); + data->Clear(); + UpdateMeasurements(); + nameActivPP.clear(); + patternPieces.clear(); + tools.clear(); + cursor = 0; + history.clear(); + } + else if (parse == Document::LiteParse) + { + data->ClearUniqueNames(); + data->ClearVariables(VarType::ArcLength); + data->ClearVariables(VarType::LineAngle); + data->ClearVariables(VarType::LineLength); + data->ClearVariables(VarType::SplineLength); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::UpdateMeasurements() +{ + try + { + const QString path = MPath(); + if (MType() == MeasurementsType::Standard) + { + VStandardMeasurements m(data); + ValidateXML("://schema/standard_measurements.xsd", path); + m.setXMLContent(path); + m.Measurements(); + } + else + { + VIndividualMeasurements m(data); + ValidateXML("://schema/individual_measurements.xsd", path); + m.setXMLContent(path); + m.Measurements(); + } + } + catch (VException &e) + { + e.CriticalMessageBox(tr("File error."), qApp->getMainWindow()); + emit ClearMainWindow(); + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id) +{ + id = GetParametrId(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +QDomElement VPattern::GetPPElement(const QString &name) +{ + if (name.isEmpty() == false) + { + const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); + if (elements.size() == 0) + { + return QDomElement(); + } + for ( qint32 i = 0; i < elements.count(); i++ ) + { + QDomElement element = elements.at( i ).toElement(); + if (element.isNull() == false) + { + if ( element.attribute( AttrName ) == name ) + { + return element; + } + } + } + } + return QDomElement(); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPattern::CountPP() const +{ + const QDomElement rootElement = this->documentElement(); + if (rootElement.isNull()) + { + return 0; + } + + return rootElement.elementsByTagName( TagDraw ).count(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QRectF VPattern::ActiveDrawBoundingRect() const +{ + QRectF rec; + + for (qint32 i = 0; i< history.size(); ++i) + { + const VToolRecord tool = history.at(i); + if (tool.getNameDraw() == nameActivPP) + { + switch ( tool.getTypeTool() ) + { + case Tool::Arrow: + Q_UNREACHABLE(); + break; + case Tool::SinglePoint: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::EndLine: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Line: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::AlongLine: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::ShoulderPoint: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Normal: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Bisector: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::LineIntersect: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Spline: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Arc: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::SplinePath: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::PointOfContact: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Height: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::Triangle: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::PointOfIntersection: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::CutArc: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::CutSpline: + rec = ToolBoundingRect(rec, tool.getId()); + break; + case Tool::CutSplinePath: + rec = ToolBoundingRect(rec, tool.getId()); + break; + //Because "history" not only show history of pattern, but help restore current data for each pattern's + //piece, we need add record about details and nodes, but don't show them. + case Tool::Detail: + break; + case Tool::UnionDetails: + break; + case Tool::NodeArc: + break; + case Tool::NodePoint: + break; + case Tool::NodeSpline: + break; + case Tool::NodeSplinePath: + break; + default: + qDebug()<<"Got wrong tool type. Ignore."; + break; + } + } + } + return rec; +} + +//--------------------------------------------------------------------------------------------------------------------- +template +QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const +{ + QRectF recTool = rec; + if (tools.contains(id)) + { + T *vTool = qobject_cast(tools.value(id)); + SCASSERT(vTool != nullptr); + + QRectF childrenRect = vTool->childrenBoundingRect(); + //map to scene coordinate. + childrenRect.translate(vTool->scenePos()); + + recTool = recTool.united(vTool->boundingRect()); + recTool = recTool.united(childrenRect); + } + else + { + qDebug()<<"Can't find tool with id="< VPattern::getLocalHistory() const +{ + QVector historyPP; + for (qint32 i = 0; i< history.size(); ++i) + { + const VToolRecord tool = history.at(i); + if (tool.getNameDraw() != GetNameActivPP()) + { + continue; + } + historyPP.append(tool); + } + return historyPP; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VPattern::SiblingNodeId(const quint32 &nodeId) const +{ + quint32 siblingId = NULL_ID; + + const QVector history = getLocalHistory(); + for (qint32 i = 0; i < history.size(); ++i) + { + const VToolRecord tool = history.at(i); + if (nodeId == tool.getId()) + { + if (i == 0) + { + siblingId = NULL_ID; + } + else + { + for (qint32 j = i; j > 0; --j) + { + const VToolRecord tool = history.at(j-1); + switch ( tool.getTypeTool() ) + { + case Tool::Detail: + case Tool::UnionDetails: + case Tool::NodeArc: + case Tool::NodePoint: + case Tool::NodeSpline: + case Tool::NodeSplinePath: + continue; + break; + default: + siblingId = tool.getId(); + j = 0;// break loop + break; + } + } + } + } + } + return siblingId; +} diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h new file mode 100644 index 000000000..439d5c0be --- /dev/null +++ b/src/app/xml/vpattern.h @@ -0,0 +1,330 @@ +/************************************************************************ + ** + ** @file vpattern.h + ** @author Roman Telezhynskyi + ** @date 24 2, 2014 + ** + ** @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 + ** 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 VPATTERN_H +#define VPATTERN_H + +#include "../libs/ifc/xml/vdomdocument.h" +#include "vtoolrecord.h" +#include "../container/vcontainer.h" + +class VDataTool; +class VMainGraphicsScene; + +enum class Document : char { LiteParse, LitePPParse, FullParse }; +enum class LabelType : char {NewPatternPiece, NewLabel}; + +/** + * @brief The VPattern class working with pattern file. + */ +class VPattern : public QObject, public VDomDocument +{ + Q_OBJECT +public: + VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, + QObject *parent = nullptr); + + void CreateEmptyFile(const QString &tablePath); + void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse); + QString GetNameActivPP() const; + bool GetActivDrawElement(QDomElement &element) const; + bool appendPP(const QString& name); + bool ChangeNamePP(const QString& oldName, const QString &newName); + QDomElement GetPPElement(const QString &name); + bool CheckExistNamePP(const QString& name) const; + int CountPP() const; + + void Parse(const Document &parse); + QHash* getTools(); + VDataTool* getTool(const quint32 &id); + QVector *getHistory(); + QVector getLocalHistory() const; + quint32 getCursor() const; + void setCursor(const quint32 &value); + void setCurrentData(); + void AddTool(const quint32 &id, VDataTool *tool); + void UpdateToolData(const quint32 &id, VContainer *data); + void IncrementReferens(quint32 id) const; + void DecrementReferens(quint32 id) const; + quint32 SPointActiveDraw(); + bool isPatternModified() const; + void setPatternModified(bool value); + bool GetActivNodeElement(const QString& name, QDomElement& element) const; + QString MPath() const; + void SetPath(const QString &path); + Unit MUnit() const; + MeasurementsType MType() const; + static const QString TagPattern; + static const QString TagCalculation; + static const QString TagModeling; + static const QString TagDetails; + static const QString TagAuthor; + static const QString TagDescription; + static const QString TagNotes; + static const QString TagMeasurements; + static const QString TagIncrements; + static const QString TagIncrement; + static const QString TagDraw; + static const QString TagPoint; + static const QString TagLine; + static const QString TagSpline; + static const QString TagArc; + static const QString TagTools; + static const QString TagGradation; + static const QString TagHeights; + static const QString TagSizes; + + static const QString AttrName; + static const QString AttrType; + static const QString AttrPath; + + static const QString AttrAll; + + static const QString AttrH92; + static const QString AttrH98; + static const QString AttrH104; + static const QString AttrH110; + static const QString AttrH116; + static const QString AttrH122; + static const QString AttrH128; + static const QString AttrH134; + static const QString AttrH140; + static const QString AttrH146; + static const QString AttrH152; + static const QString AttrH158; + static const QString AttrH164; + static const QString AttrH170; + static const QString AttrH176; + static const QString AttrH182; + static const QString AttrH188; + static const QString AttrH194; + + static const QString AttrS22; + static const QString AttrS24; + static const QString AttrS26; + static const QString AttrS28; + static const QString AttrS30; + static const QString AttrS32; + static const QString AttrS34; + static const QString AttrS36; + static const QString AttrS38; + static const QString AttrS40; + static const QString AttrS42; + static const QString AttrS44; + static const QString AttrS46; + static const QString AttrS48; + static const QString AttrS50; + static const QString AttrS52; + static const QString AttrS54; + static const QString AttrS56; + + static const QString IncrementName; + static const QString IncrementBase; + static const QString IncrementKsize; + static const QString IncrementKgrowth; + static const QString IncrementDescription; + + virtual bool SaveDocument(const QString &fileName, QString &error) const; + QStringList getPatternPieces() const; + QRectF ActiveDrawBoundingRect() const; + + QMap GetGradationHeights() const; + void SetGradationHeights(const QMap &options); + + QMap GetGradationSizes() const; + void SetGradationSizes(const QMap &options); + + QString GetAuthor() const; + void SetAuthor(const QString &text); + + QString GetDescription() const; + void SetDescription(const QString &text); + + QString GetNotes() const; + void SetNotes(const QString &text); + + QString GetVersion() const; + void SetVersion(); + + QString GenerateLabel(const LabelType &type)const; + + quint32 SiblingNodeId(const quint32 &nodeId) const; +signals: + /** + * @brief ChangedActivDraw change active pattern peace. + * @param newName new pattern peace name. + */ + void ChangedActivPP(const QString &newName); + /** + * @brief ChangedNameDraw save new name pattern peace. + * @param oldName old name. + * @param newName new name. + */ + void ChangedNameDraw(const QString &oldName, const QString &newName); + /** + * @brief FullUpdateFromFile update tool data form file. + */ + void FullUpdateFromFile(); + /** + * @brief patternChanged emit if we have unsaved change. + */ + void patternChanged(bool saved); + /** + * @brief ShowTool highlight tool. + * @param id tool id. + * @param color highlight color. + * @param enable enable or disable highlight. + */ + void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + /** + * @brief ChangedCursor change cursor position. + * @param id tool id. + */ + void ChangedCursor(quint32 id); + void ClearMainWindow(); + void UndoCommand(); + void SetEnabledGUI(bool enabled); + void CheckLayout(); + void SetCurrentPP(const QString &patterPiece); +public slots: + void LiteParseTree(const Document &parse); + void haveLiteChange(); + void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void NeedFullParsing(); + void ClearScene(); +protected: + virtual void customEvent(QEvent * event); +private: + Q_DISABLE_COPY(VPattern) + + /** @brief data container with data. */ + VContainer *data; + + /** @brief nameActivDraw name current pattern peace. */ + QString nameActivPP; + + /** @brief tools list with pointer on tools. */ + QHash tools; + + /** @brief history history records. */ + QVector history; + + /** @brief cursor cursor keep id tool after which we will add new tool in file. */ + quint32 cursor; + + /** @brief patternPieces list of patern pieces names for combobox*/ + QStringList patternPieces; + + /** @brief mode current draw mode. */ + Draw *mode; + + VMainGraphicsScene *sceneDraw; + VMainGraphicsScene *sceneDetail; + + void SetActivPP(const QString& name); + void ParseDrawElement(const QDomNode& node, const Document &parse); + void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode); + void ParseDetailElement(const QDomElement &domElement, + const Document &parse); + void ParseDetails(const QDomElement &domElement, const Document &parse); + void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, + const Document &parse, const QString &type); + void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document &parse); + void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document &parse, const QString& type); + void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, + const Document &parse, const QString& type); + void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document &parse, const QString& type); + void ParseIncrementsElement(const QDomNode& node); + void PrepareForParse(const Document &parse); + void UpdateMeasurements(); + void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, + qreal &my, QString &typeLine); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, + qreal &my); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my); + void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, + quint32 &idTool); + template + QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const; + void ParseCurrentPP(); + void CheckTagExists(const QString &tag); + QString GetLabelBase(unsigned int index)const; + void ToolExists(const quint32 &id) const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetNameActivPP return current pattern piece name. + * @return pattern piece name. + */ +inline QString VPattern::GetNameActivPP() const +{ + return nameActivPP; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTools return list of tools pointers. + * @return list. + */ +inline QHash *VPattern::getTools() +{ + return &tools; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getHistory return list with list of history records. + * @return list of history records. + */ +inline QVector *VPattern::getHistory() +{ + return &history; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getCursor return cursor. + * @return cursor. + */ +inline quint32 VPattern::getCursor() const +{ + return cursor; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QStringList VPattern::getPatternPieces() const +{ + return patternPieces; +} + +#endif // VPATTERN_H diff --git a/src/app/xml/vstandardmeasurements.cpp b/src/app/xml/vstandardmeasurements.cpp new file mode 100644 index 000000000..43124da00 --- /dev/null +++ b/src/app/xml/vstandardmeasurements.cpp @@ -0,0 +1,136 @@ +/************************************************************************ + ** + ** @file vstandardmeasurements.cpp + ** @author Roman Telezhynskyi + ** @date 8 3, 2014 + ** + ** @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 + ** 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 "vstandardmeasurements.h" +#include +#include "../core/vapplication.h" + +const QString VStandardMeasurements::TagDescription = QStringLiteral("description"); +const QString VStandardMeasurements::TagId = QStringLiteral("id"); +const QString VStandardMeasurements::TagSize = QStringLiteral("size"); +const QString VStandardMeasurements::TagHeight = QStringLiteral("height"); +const QString VStandardMeasurements::AttrSize_increase = QStringLiteral("size_increase"); +const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase"); + +//--------------------------------------------------------------------------------------------------------------------- +VStandardMeasurements::VStandardMeasurements(VContainer *data) + :VAbstractMeasurements(data) +{ + SCASSERT(data != nullptr) +} + +//--------------------------------------------------------------------------------------------------------------------- +VStandardMeasurements::~VStandardMeasurements() +{} + +//--------------------------------------------------------------------------------------------------------------------- +QString VStandardMeasurements::Description() +{ + const QString desc = UniqueTagText(TagDescription, ""); + if (desc.isEmpty()) + { + qWarning()<<"Empty description in standard table."<patternUnit()); + + qreal size_increase = GetParametrDouble(domElement, AttrSize_increase, "0.0"); + size_increase = UnitConvertor(size_increase, MUnit(), qApp->patternUnit()); + + qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); + height_increase = UnitConvertor(height_increase, MUnit(), qApp->patternUnit()); + + if (MUnit() == Unit::Inch) + { + qWarning()<<"Standard table can't use inch unit."; + } + + data->AddVariable(tag, new VMeasurement(tag, value, size_increase, height_increase, qApp->GuiText(tag), + qApp->Description(tag), tag)); +} + + +//--------------------------------------------------------------------------------------------------------------------- +qreal VStandardMeasurements::TakeParametr(const QString &tag, qreal defValue) const +{ + const qreal defVal = UnitConvertor(defValue, Unit::Cm, qApp->patternUnit()); + + const QDomNodeList nodeList = this->elementsByTagName(tag); + if (nodeList.isEmpty()) + { + return defVal; + } + else + { + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + qreal value = GetParametrDouble(domElement, AttrValue, QString("%1").arg(defVal)); + value = UnitConvertor(value, MUnit(), qApp->patternUnit()); + return value; + } + } + } + return defVal; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VStandardMeasurements::SetSize() +{ + const qreal value = TakeParametr(TagSize, 50); + data->SetSize(value); + data->SetSizeName(size_M); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VStandardMeasurements::SetHeight() +{ + const qreal value = TakeParametr(TagHeight, 176); + data->SetHeight(value); + data->SetHeightName(height_M); +} diff --git a/src/app/xml/vstandardmeasurements.h b/src/app/xml/vstandardmeasurements.h new file mode 100644 index 000000000..93082b7bc --- /dev/null +++ b/src/app/xml/vstandardmeasurements.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file vstandardmeasurements.h + ** @author Roman Telezhynskyi + ** @date 8 3, 2014 + ** + ** @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 + ** 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 VSTANDARDMEASUREMENTS_H +#define VSTANDARDMEASUREMENTS_H + +#include "vabstractmeasurements.h" + +/* + VST_VERSION is (major << 16) + (minor << 8) + patch. +*/ +// version without patch part +#define VST_MIN_VERSION 0x000300 +// max support version of format +#define VST_VERSION 0x000300 + +class VStandardMeasurements:public VAbstractMeasurements +{ +public: + VStandardMeasurements(VContainer *data); + virtual ~VStandardMeasurements(); + QString Description(); + QString Id(); + void SetSize(); + void SetHeight(); + static const QString TagMeasurement; + static const QString TagDescription; + static const QString TagId; + static const QString TagSize; + static const QString TagHeight; + static const QString AttrSize_increase; + static const QString AttrHeight_increase; +protected: + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag); +private: + Q_DISABLE_COPY(VStandardMeasurements) + qreal TakeParametr(const QString &tag, qreal defValue) const; +}; + +#endif // VSTANDARDMEASUREMENTS_H diff --git a/src/app/xml/vtoolrecord.cpp b/src/app/xml/vtoolrecord.cpp new file mode 100644 index 000000000..036d88583 --- /dev/null +++ b/src/app/xml/vtoolrecord.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file vtoolrecord.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vtoolrecord.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolRecord default constructor. + */ +VToolRecord::VToolRecord() + :id(NULL_ID), typeTool(Tool::Arrow), nameDraw(QString()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolRecord constructor. + * @param id tool id. + * @param typeTool tool type. + * @param nameDraw pattern peace name. + */ +VToolRecord::VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw) + :id(id), typeTool(typeTool), nameDraw(nameDraw) +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VToolRecord::operator==(const VToolRecord &record) const +{ + bool isEqual = false; + if (id == record.getId() && typeTool == record.getTypeTool() && nameDraw == record.getNameDraw()) + { + isEqual = true; + } + return isEqual; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolRecord &VToolRecord::operator=(const VToolRecord &record) +{ + this->id = record.getId(); + this->typeTool = record.getTypeTool(); + this->nameDraw = record.getNameDraw(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolRecord::VToolRecord(const VToolRecord &record) + :id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VToolRecord::~VToolRecord() +{} diff --git a/src/app/xml/vtoolrecord.h b/src/app/xml/vtoolrecord.h new file mode 100644 index 000000000..5cf185f5a --- /dev/null +++ b/src/app/xml/vtoolrecord.h @@ -0,0 +1,125 @@ +/************************************************************************ + ** + ** @file vtoolrecord.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VTOOLRECORD_H +#define VTOOLRECORD_H + +#include "../options.h" + +#include + +/** + * @brief The VToolRecord class record about tool in history. + */ +class VToolRecord +{ +public: + VToolRecord(); + VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw); + bool operator==(const VToolRecord &record) const; + VToolRecord &operator=(const VToolRecord &record); + VToolRecord(const VToolRecord &record); + quint32 getId() const; + void setId(const quint32 &value); + Tool getTypeTool() const; + void setTypeTool(const Tool &value); + QString getNameDraw() const; + void setNameDraw(const QString &value); + ~VToolRecord(); +private: + /** @brief id tool id. */ + quint32 id; + + /** @brief typeTool tool type. */ + Tool typeTool; + + /** @brief nameDraw pattern peace name. */ + QString nameDraw; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getId return tool id. + * @return id. + */ +inline quint32 VToolRecord::getId() const +{ + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId set tool id. + * @param value id. + */ +inline void VToolRecord::setId(const quint32 &value) +{ + id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeTool return tool type. + * @return tool type. + */ +inline Tool VToolRecord::getTypeTool() const +{ + return typeTool; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeTool set tool type. + * @param value tool type. + */ +inline void VToolRecord::setTypeTool(const Tool &value) +{ + typeTool = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getNameDraw return pattern peace name. + * @return pattern peace name. + */ +inline QString VToolRecord::getNameDraw() const +{ + return nameDraw; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setNameDraw set pattern peace name. + * @param value pattern peace name. + */ +inline void VToolRecord::setNameDraw(const QString &value) +{ + nameDraw = value; +} + +#endif // VTOOLRECORD_H diff --git a/src/app/xml/xml.pri b/src/app/xml/xml.pri new file mode 100644 index 000000000..a26d7d4aa --- /dev/null +++ b/src/app/xml/xml.pri @@ -0,0 +1,16 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vtoolrecord.h \ + $$PWD/vpattern.h \ + $$PWD/vstandardmeasurements.h \ + $$PWD/vindividualmeasurements.h \ + $$PWD/vabstractmeasurements.h + +SOURCES += \ + $$PWD/vtoolrecord.cpp \ + $$PWD/vpattern.cpp \ + $$PWD/vstandardmeasurements.cpp \ + $$PWD/vindividualmeasurements.cpp \ + $$PWD/vabstractmeasurements.cpp diff --git a/src/container/calculator.cpp b/src/container/calculator.cpp deleted file mode 100644 index ca6c71dea..000000000 --- a/src/container/calculator.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/************************************************************************ - ** - ** @file calculator.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "calculator.h" -#include - -#define DELIMITER 1 -#define VARIABLE 2 -#define NUMBER 3 -#define COMMAND 4 -#define STRING 5 -#define QUOTE 6 -#define FINISHED 10 -#define EOL 9 - -qreal Calculator::eval(QString prog, QString *errorMsg) -{ - this->errorMsg = errorMsg; - this->errorMsg->clear(); - debugFormula.clear(); - this->prog = prog; - //qDebug()<<"Formula: "<FindVar(s, &ok); - if (ok == false) - { - qDebug()<clear(); - *errorMsg = e[error]; - qDebug()</*%^=()", c) || c=='\n' || c=='\r' || c=='\0') - { - return true; - } - return false; -} - -bool Calculator::iswhite(QChar c) -{ - if (c==' ' || c=='\t') - { - return true; - } - else - { - return false; - } -} - -void Calculator::get_token() -{ - QString *temp; - - token_type=0; tok=0; - token.clear(); - temp=&token; - - if (prog[index]=='\0') - { /* end of file */ - token="\0"; - tok=FINISHED; - token_type=DELIMITER; - return; - } - - while (iswhite(prog[index])) - { - ++index; /* skip spaces */ - } - - if (prog[index]=='\r') - { /* crtl */ - ++index; ++index; - tok= EOL; token='\r'; - token.append('\n');token.append("\0"); - token_type = DELIMITER; - return; - } - - if (StrChr("+-*^/%=;(),><", prog[index])) - { /* delimiter */ - *temp=prog[index]; - index++; /* jump to the next position */ - temp->append("\0"); - token_type=DELIMITER; - debugFormula.append(token); - return; - } - if (prog[index]=='"') - { /* quoted string */ - index++; - while (prog[index] != '"' && prog[index] != '\r') - { - temp->append(prog[index]); - index++; - } - if (prog[index]=='\r') - { - serror(1); - } - index++;temp->append("\0"); - token_type=QUOTE; - return; - } - if (prog[index].isDigit()) - { /* number */ - while (isdelim(prog[index]) == false) - { - temp->append(prog[index]); - index++; - } - temp->append('\0'); - token_type = NUMBER; - return; - } - - if (prog[index].isPrint()) - { /* variable or command */ - while (isdelim(prog[index]) == false) - { - temp->append(prog[index]); - index++; - } - token_type=STRING; - } - temp->append("\0"); - - /* Seen if there is a command line or a variable */ - if (token_type==STRING) - { - tok=look_up(token); - if (tok == false) - { - token_type = VARIABLE; - } - else - { - token_type = COMMAND; /* It is command */ - } - } - return; -} - -bool Calculator::StrChr(QString string, QChar c) -{ - return string.contains(c, Qt::CaseInsensitive); -} - -void Calculator::putback() -{ - QString t; - t = token; - index = index - t.size(); -} diff --git a/src/container/calculator.h b/src/container/calculator.h deleted file mode 100644 index 34513faf0..000000000 --- a/src/container/calculator.h +++ /dev/null @@ -1,187 +0,0 @@ -/************************************************************************ - ** - ** @file calculator.h - ** @author Roman Telezhinsky - ** @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 - ** 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 CALCULATOR_H -#define CALCULATOR_H - -#include "vcontainer.h" - -/** - * @brief The Calculator class calculate formulas of pattern. Support operation +,-,/,* and braces. - * Can replace name of variables her value. - */ -class Calculator -{ -public: - /** - * @brief Calculator class constructor. - * @param data pointer to a variable container. - */ - explicit Calculator(const VContainer *data):errorMsg(0), token(QString()), tok(0), token_type(0), prog(QString()), - index(0), data(data), debugFormula(QString()){} - /** - * @brief eval calculate formula. - * @param prog string of formula. - * @param errorMsg keep error message. - * @return value of formula. - */ - qreal eval(QString prog, QString *errorMsg); -private: - Q_DISABLE_COPY(Calculator) - /** - * @brief errorMsg keeps error message of calculation. - */ - QString *errorMsg; - /** - * @brief token теперішня лексема. - */ - QString token; - /** - * @brief tok internal representation of token. - */ - qint32 tok; - /** - * @brief token_type type of token. - */ - qint32 token_type; - /** - * @brief prog string where keeps formula. - */ - QString prog; - /** - * @brief index number character in string of formula. - */ - qint32 index; - /** - * @brief data container with data container of all variables. - */ - const VContainer *data; - /** - * @brief debugFormula decoded string of formula. - */ - QString debugFormula; - /** - * @brief get_exp calculate formula. - * @return value of formula. - */ - qreal get_exp(); - /** - * @brief get_token return next token. - */ - void get_token(); - /** - * @brief StrChr checks whether the character belongs to the line. - * @param string string with formula - * @param c character. - * @return true - belongs to the line, false - don't belongs to the line. - */ - static bool StrChr(QString string, QChar c); - /** - * @brief putback returns the readout token back into the flow. - */ - void putback(); - /** - * @brief level2 method of addition and subtraction of two terms. - * @param result result of operation. - */ - void level2(qreal *result); - /** - * @brief level3 method of multiplication, division, finding percent. - * @param result result of operation. - */ - void level3(qreal *result); - /** - * @brief level4 method of degree two numbers. - * @param result result of operation. - */ - void level4(qreal *result); - /** - * @brief level5 method for finding unary plus or minus. - * @param result result of operation. - */ - void level5(qreal *result); - /** - * @brief level6 processing method of the expression in brackets. - * @param result result of operation. - */ - void level6(qreal *result); - /** - * @brief primitive method of determining the value of a variable by its name. - * @param result result of operation. - */ - void primitive(qreal *result); - /** - * @brief arith perform the specified arithmetic. The result is written to the first element. - * @param o sign of operation. - * @param r first element. - * @param h second element. - */ - static void arith(QChar o, qreal *r, qreal *h); - /** - * @brief unary method changes the sign. - * @param o sign of symbol. - * @param r element. - */ - static void unary(QChar o, qreal *r); - /** - * @brief find_var method is finding variable by name. - * @param s name of variable. - * @return value of variable. - */ - qreal find_var(QString s); - /** - * @brief serror report an error - * @param error error code - */ - void serror(qint32 error); - /** - * @brief look_up finding the internal format for the current token in the token table. - * @param s name of token. - * @return internal number of token. - */ - static char look_up(QString s); - /** - * @brief isdelim return true if c delimiter. - * @param c character. - * @return true - delimiter, false - do not delimiter. - */ - static bool isdelim(QChar c); - /** - * @brief isdelim return true if c delimiter. - * @param c character. - * @return true - delimiter, false - do not delimiter. - */ - static bool iswhite(QChar c); - /** - * @brief iswhite checks whether c space or tab. - * @param c character. - * @return true - space or tab, false - don't space and don't tab. - */ -}; - -#endif // CALCULATOR_H diff --git a/src/container/container.pri b/src/container/container.pri deleted file mode 100644 index be62d71f1..000000000 --- a/src/container/container.pri +++ /dev/null @@ -1,13 +0,0 @@ -SOURCES += \ - src/container/vpointf.cpp \ - src/container/vincrementtablerow.cpp \ - src/container/vcontainer.cpp \ - src/container/calculator.cpp \ - src/container/vstandarttablerow.cpp - -HEADERS += \ - src/container/vpointf.h \ - src/container/vincrementtablerow.h \ - src/container/vcontainer.h \ - src/container/calculator.h \ - src/container/vstandarttablerow.h diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp deleted file mode 100644 index 108909dc7..000000000 --- a/src/container/vcontainer.cpp +++ /dev/null @@ -1,895 +0,0 @@ -/************************************************************************ - ** - ** @file vcontainer.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vcontainer.h" -#include "../exception/vexceptionbadid.h" - -#include - -qint64 VContainer::_id = 0; - -VContainer::VContainer() - :base(QHash()), points(QHash()), - pointsModeling(QHash()), - standartTable(QHash()), incrementTable(QHash()), - lengthLines(QHash()), lineAngles(QHash()), splines(QHash()), - splinesModeling(QHash()), - lengthSplines(QHash()), arcs(QHash()), arcsModeling(QHash()), - lengthArcs(QHash()), - splinePaths(QHash()), splinePathsModeling(QHash()), - details(QHash()) -{ - SetSize(500); - SetGrowth(1760); - CreateManTableIGroup (); -} - -VContainer &VContainer::operator =(const VContainer &data) -{ - setData(data); - return *this; -} - -VContainer::VContainer(const VContainer &data) - :base(QHash()), points(QHash()), - pointsModeling(QHash()), - standartTable(QHash()), incrementTable(QHash()), - lengthLines(QHash()), lineAngles(QHash()), splines(QHash()), - splinesModeling(QHash()), - lengthSplines(QHash()), arcs(QHash()), arcsModeling(QHash()), - lengthArcs(QHash()), - splinePaths(QHash()), splinePathsModeling(QHash()), - details(QHash()) -{ - setData(data); -} - -void VContainer::setData(const VContainer &data) -{ - base = *data.DataBase(); - points = *data.DataPoints(); - pointsModeling = *data.DataPointsModeling(); - standartTable = *data.DataStandartTable(); - incrementTable = *data.DataIncrementTable(); - lengthLines = *data.DataLengthLines(); - lineAngles = *data.DataLineAngles(); - splines = *data.DataSplines(); - splinesModeling = *data.DataSplinesModeling(); - lengthSplines = *data.DataLengthSplines(); - arcs = *data.DataArcs(); - arcsModeling = *data.DataArcsModeling(); - lengthArcs = *data.DataLengthArcs(); - splinePaths = *data.DataSplinePaths(); - splinePathsModeling = *data.DataSplinePathsModeling(); - details = *data.DataDetails(); -} - -VPointF VContainer::GetPoint(qint64 id) const -{ - return GetObject(points, id); -} - -VPointF VContainer::GetPointModeling(qint64 id) const -{ - return GetObject(pointsModeling, id); -} - -template -val VContainer::GetObject(const QHash &obj, key id) -{ - if (obj.contains(id)) - { - return obj.value(id); - } - else - { - throw VExceptionBadId(tr("Can't find object"), id); - } -} - -VStandartTableRow VContainer::GetStandartTableCell(const QString &name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(standartTable, name); -} - -VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(incrementTable, name); -} - -qreal VContainer::GetLine(const QString &name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(lengthLines, name); -} - -qreal VContainer::GetLengthArc(const QString &name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(lengthArcs, name); -} - -qreal VContainer::GetLengthSpline(const QString &name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(lengthSplines, name); -} - -qreal VContainer::GetLineAngle(const QString &name) const -{ - Q_ASSERT(name.isEmpty()==false); - return GetObject(lineAngles, name); -} - -VSpline VContainer::GetSpline(qint64 id) const -{ - return GetObject(splines, id); -} - -VSpline VContainer::GetSplineModeling(qint64 id) const -{ - return GetObject(splinesModeling, id); -} - -VArc VContainer::GetArc(qint64 id) const -{ - return GetObject(arcs, id); -} - -VArc VContainer::GetArcModeling(qint64 id) const -{ - return GetObject(arcsModeling, id); -} - -VSplinePath VContainer::GetSplinePath(qint64 id) const -{ - return GetObject(splinePaths, id); -} - -VSplinePath VContainer::GetSplinePathModeling(qint64 id) const -{ - return GetObject(splinePathsModeling, id); -} - -VDetail VContainer::GetDetail(qint64 id) const -{ - return GetObject(details, id); -} - -qint64 VContainer::AddPoint(const VPointF &point) -{ - return AddObject(points, point); -} - -qint64 VContainer::AddPointModeling(const VPointF &point) -{ - return AddObject(pointsModeling, point); -} - -qint64 VContainer::AddDetail(const VDetail &detail) -{ - return AddObject(details, detail); -} - -qint64 VContainer::getNextId() -{ - _id++; - return _id; -} - -void VContainer::UpdateId(qint64 newId) -{ - if (newId > _id) - { - _id = newId; - } -} - -QPainterPath VContainer::ContourPath(qint64 idDetail) const -{ - VDetail detail = GetDetail(idDetail); - QVector points; - QVector pointsEkv; - for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) - { - switch (detail[i].getTypeTool()) - { - case (Tool::NodePoint): - { - VPointF point = GetPointModeling(detail[i].getId()); - points.append(point.toQPointF()); - if (detail.getSupplement() == true) - { - QPointF pEkv = point.toQPointF(); - pEkv.setX(pEkv.x()+detail[i].getMx()); - pEkv.setY(pEkv.y()+detail[i].getMy()); - pointsEkv.append(pEkv); - } - } - break; - case (Tool::NodeArc): - { - VArc arc = GetArcModeling(detail[i].getId()); - qreal len1 = GetLengthContour(points, arc.GetPoints()); - qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints())); - if (len1 <= lenReverse) - { - points << arc.GetPoints(); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy()); - } - } - else - { - points << GetReversePoint(arc.GetPoints()); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), detail[i].getMy()); - } - } - } - break; - case (Tool::NodeSpline): - { - VSpline spline = GetSplineModeling(detail[i].getId()); - qreal len1 = GetLengthContour(points, spline.GetPoints()); - qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints())); - if (len1 <= lenReverse) - { - points << spline.GetPoints(); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy()); - } - } - else - { - points << GetReversePoint(spline.GetPoints()); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(), - detail[i].getMy()); - } - } - } - break; - case (Tool::NodeSplinePath): - { - VSplinePath splinePath = GetSplinePathModeling(detail[i].getId()); - qreal len1 = GetLengthContour(points, splinePath.GetPathPoints()); - qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints())); - if (len1 <= lenReverse) - { - points << splinePath.GetPathPoints(); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy()); - } - } - else - { - points << GetReversePoint(splinePath.GetPathPoints()); - if (detail.getSupplement() == true) - { - pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(), - detail[i].getMy()); - } - } - } - break; - case (Tool::SplineTool): - break;//Nothing to do, just ignore. - default: - qWarning()<<"Get wrong tool type. Ignore."< VContainer::biasPoints(const QVector &points, const qreal &mx, const qreal &my) const -{ - QVector p; - for (qint32 i = 0; i < points.size(); ++i) - { - QPointF point = points.at(i); - point.setX(point.x() + mx); - point.setY(point.y() + my); - p.append(point); - } - return p; -} - -QPainterPath VContainer::Equidistant(QVector points, const Detail::Equidistant &eqv, const qreal &width) const -{ - QPainterPath ekv; - QVector ekvPoints; - if ( points.size() < 3 ) - { - qDebug()<<"Not enough points for build equidistant.\n"; - return ekv; - } - for (qint32 i = 0; i < points.size(); ++i ) - { - if (i != points.size()-1) - { - if (points[i] == points[i+1]) - { - points.remove(i+1); - } - } - else - { - if (points[i] == points[0]) - { - points.remove(i); - } - } - } - if (eqv == Detail::CloseEquidistant) - { - points.append(points.at(0)); - } - for (qint32 i = 0; i < points.size(); ++i ) - { - if ( i == 0 && eqv == Detail::CloseEquidistant) - {//перша точка, ламана замкнена - ekvPoints< 0); - QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()), - -90, width)); - return paralel; -} - -QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width) -{ - Q_ASSERT(width > 0); - QLineF pLine = line; - pLine.setAngle( pLine.angle() + angle ); - pLine.setLength( width ); - return pLine.p2(); -} - -QVector VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const -{ - Q_ASSERT(width > 0); - QVector points; - if (line1.p2() != line2.p2()) - { - qWarning()<<"Last point of two lines must be equal."; - } - QPointF CrosPoint; - QLineF bigLine1 = ParallelLine(line1, width ); - QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width ); - QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint ); - switch (type) - { - case (QLineF::BoundedIntersection): - points.append(CrosPoint); - return points; - break; - case (QLineF::UnboundedIntersection): - { - QLineF line( line1.p2(), CrosPoint ); - if (line.length() > width + toPixel(8)) - { - QLineF lineL; - lineL = QLineF(bigLine1.p2(), CrosPoint); - lineL.setLength(width); - points.append(lineL.p2()); - - lineL = QLineF(bigLine2.p1(), CrosPoint); - lineL.setLength(width); - points.append(lineL.p2()); - } - else - { - points.append(CrosPoint); - return points; - } - break; - } - case (QLineF::NoIntersection): - /*If we have correct lines this means lines lie on a line.*/ - points.append(bigLine1.p2()); - return points; - break; - default: - break; - } - return points; -} - -QVector VContainer::CheckLoops(const QVector &points) const -{ - QVector ekvPoints; - /*If we got less than 4 points no need seek loops.*/ - if (points.size() < 4) - { - return ekvPoints; - } - bool closed = false; - if (points.at(0) == points.at(points.size()-1)) - { - closed = true; - } - qint32 i, j; - for (i = 0; i < points.size(); ++i) - { - /*Last three points no need check.*/ - if (i >= points.size()-3) - { - ekvPoints.append(points.at(i)); - continue; - } - QPointF crosPoint; - QLineF::IntersectType intersect = QLineF::NoIntersection; - QLineF line1(points.at(i), points.at(i+1)); - for (j = i+2; j < points.size()-1; ++j) - { - QLineF line2(points.at(j), points.at(j+1)); - intersect = line1.intersect(line2, &crosPoint); - if (intersect == QLineF::BoundedIntersection) - { - break; - } - } - if (intersect == QLineF::BoundedIntersection) - { - if (i == 0 && j+1 == points.size()-1 && closed) - { - /*We got closed contour.*/ - ekvPoints.append(points.at(i)); - } - else - { - /*We found loop.*/ - ekvPoints.append(points.at(i)); - ekvPoints.append(crosPoint); - ekvPoints.append(points.at(j+1)); - i = j + 2; - } - } - else - { - /*We did not found loop.*/ - ekvPoints.append(points.at(i)); - } - } - return ekvPoints; -} - -void VContainer::PrepareDetails(QVector &list) const -{ - QHashIterator iDetail(details); - while (iDetail.hasNext()) - { - iDetail.next(); - list.append(new VItem(ContourPath(iDetail.key()), list.size())); - } -} - -template -void VContainer::UpdateObject(QHash &obj, const qint64 &id, const val& point) -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - obj[id] = point; - UpdateId(id); -} - -void VContainer::AddLengthSpline(const QString &name, const qreal &value) -{ - Q_ASSERT(name.isEmpty() == false); - lengthSplines[name] = value; -} - -void VContainer::AddLengthArc(const qint64 &id) -{ - AddLengthArc(GetArc(id).name(), toMM(GetArc(id).GetLength())); -} - -void VContainer::AddLengthArc(const QString &name, const qreal &value) -{ - Q_ASSERT(name.isEmpty() == false); - lengthArcs[name] = value; -} - -void VContainer::AddLineAngle(const QString &name, const qreal &value) -{ - Q_ASSERT(name.isEmpty() == false); - lineAngles[name] = value; -} - -qreal VContainer::GetValueStandartTableCell(const QString& name) const -{ - VStandartTableRow cell = GetStandartTableCell(name); - qreal k_size = ( static_cast (size()/10.0) - 50.0 ) / 2.0; - qreal k_growth = ( static_cast (growth()/10.0) - 176.0 ) / 6.0; - qreal value = cell.GetBase() + k_size*cell.GetKsize() + k_growth*cell.GetKgrowth(); - return value; -} - -qreal VContainer::GetValueIncrementTableRow(const QString& name) const -{ - VIncrementTableRow cell = GetIncrementTableRow(name); - qreal k_size = ( static_cast (size()/10.0) - 50.0 ) / 2.0; - qreal k_growth = ( static_cast (growth()/10.0) - 176.0 ) / 6.0; - qreal value = cell.getBase() + k_size*cell.getKsize() + k_growth*cell.getKgrowth(); - return value; -} - -void VContainer::Clear() -{ - _id = 0; - standartTable.clear(); - incrementTable.clear(); - lengthLines.clear(); - lengthArcs.clear(); - lineAngles.clear(); - details.clear(); - arcsModeling.clear(); - pointsModeling.clear(); - splinePathsModeling.clear(); - splinesModeling.clear(); - ClearObject(); - CreateManTableIGroup (); -} - -void VContainer::ClearObject() -{ - points.clear(); - splines.clear(); - arcs.clear(); - splinePaths.clear(); -} - -qreal VContainer::FindVar(const QString &name, bool *ok)const -{ - if (base.contains(name)) - { - *ok = true; - return base.value(name); - } - - if (standartTable.contains(name)) - { - *ok = true; - return GetValueStandartTableCell(name); - } - if (incrementTable.contains(name)) - { - *ok = true; - return GetValueIncrementTableRow(name); - } - if (lengthLines.contains(name)) - { - *ok = true; - return lengthLines.value(name); - } - if (lengthArcs.contains(name)) - { - *ok = true; - return lengthArcs.value(name); - } - if (lineAngles.contains(name)) - { - *ok = true; - return lineAngles.value(name); - } - if (lengthSplines.contains(name)) - { - *ok = true; - return lengthSplines.value(name); - } - *ok = false; - return 0; -} - -void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, const Draw::Draws &mode) -{ - QString nameLine = GetNameLine(firstPointId, secondPointId, mode); - VPointF first; - VPointF second; - if (mode == Draw::Calculation) - { - first = GetPoint(firstPointId); - second = GetPoint(secondPointId); - } - else - { - first = GetPointModeling(firstPointId); - second = GetPointModeling(secondPointId); - } - AddLengthLine(nameLine, toMM(QLineF(first.toQPointF(), second.toQPointF()).length())); - nameLine = GetNameLineAngle(firstPointId, secondPointId, mode); - AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle()); -} - -qint64 VContainer::AddSpline(const VSpline &spl) -{ - return AddObject(splines, spl); -} - -qint64 VContainer::AddSplineModeling(const VSpline &spl) -{ - return AddObject(splinesModeling, spl); -} - -qint64 VContainer::AddSplinePath(const VSplinePath &splPath) -{ - return AddObject(splinePaths, splPath); -} - -qint64 VContainer::AddSplinePathModeling(const VSplinePath &splPath) -{ - return AddObject(splinePathsModeling, splPath); -} - -qint64 VContainer::AddArc(const VArc &arc) -{ - return AddObject(arcs, arc); -} - -qint64 VContainer::AddArcModeling(const VArc &arc) -{ - return AddObject(arcsModeling, arc); -} - -template -qint64 VContainer::AddObject(QHash &obj, const val& value) -{ - qint64 id = getNextId(); - obj[id] = value; - return id; -} - -QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const -{ - VPointF first; - VPointF second; - if (mode == Draw::Calculation) - { - first = GetPoint(firstPoint); - second = GetPoint(secondPoint); - } - else - { - first = GetPointModeling(firstPoint); - second = GetPointModeling(secondPoint); - } - return QString("Line_%1_%2").arg(first.name(), second.name()); -} - -QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const -{ - VPointF first; - VPointF second; - if (mode == Draw::Calculation) - { - first = GetPoint(firstPoint); - second = GetPoint(secondPoint); - } - else - { - first = GetPointModeling(firstPoint); - second = GetPointModeling(secondPoint); - } - return QString("AngleLine_%1_%2").arg(first.name(), second.name()); -} - -void VContainer::UpdatePoint(qint64 id, const VPointF &point) -{ - UpdateObject(points, id, point); -} - -void VContainer::UpdatePointModeling(qint64 id, const VPointF &point) -{ - UpdateObject(pointsModeling, id, point); -} - -void VContainer::UpdateDetail(qint64 id, const VDetail &detail) -{ - UpdateObject(details, id, detail); -} - -void VContainer::UpdateSpline(qint64 id, const VSpline &spl) -{ - UpdateObject(splines, id, spl); -} - -void VContainer::UpdateSplineModeling(qint64 id, const VSpline &spl) -{ - UpdateObject(splinesModeling, id, spl); -} - -void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath) -{ - UpdateObject(splinePaths, id, splPath); -} - -void VContainer::UpdateSplinePathModeling(qint64 id, const VSplinePath &splPath) -{ - UpdateObject(splinePathsModeling, id, splPath); -} - -void VContainer::UpdateArc(qint64 id, const VArc &arc) -{ - UpdateObject(arcs, id, arc); -} - -void VContainer::UpdateArcModeling(qint64 id, const VArc &arc) -{ - UpdateObject(arcsModeling, id, arc); -} - -void VContainer::AddLengthLine(const QString &name, const qreal &value) -{ - Q_ASSERT(name.isEmpty() == false); - lengthLines[name] = value; -} - -void VContainer::CreateManTableIGroup () -{ - AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3)); - AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3)); - AddStandartTableCell("Vtos", VStandartTableRow(1450, 2, 51)); - AddStandartTableCell("Vtosh", VStandartTableRow(1506, 2, 54)); - AddStandartTableCell("Vpt", VStandartTableRow(1438, 3, 52)); - AddStandartTableCell("Vst", VStandartTableRow(1257, -1, 49)); - AddStandartTableCell("Vlt", VStandartTableRow(1102, 0, 43)); - AddStandartTableCell("Vk", VStandartTableRow(503, 0, 22)); - AddStandartTableCell("Vsht", VStandartTableRow(1522, 2, 54)); - AddStandartTableCell("Vzy", VStandartTableRow(1328, 0, 49)); - AddStandartTableCell("Vlop", VStandartTableRow(1320, 0, 49)); - AddStandartTableCell("Vps", VStandartTableRow(811, -1, 36)); - AddStandartTableCell("Ssh", VStandartTableRow(202, 4, 1)); - AddStandartTableCell("SgI", VStandartTableRow(517, 18, 2)); - AddStandartTableCell("SgII", VStandartTableRow(522, 19, 1)); - AddStandartTableCell("SgIII", VStandartTableRow(500, 20, 0)); - AddStandartTableCell("St", VStandartTableRow(390, 20, 0)); - AddStandartTableCell("Sb", VStandartTableRow(492, 15, 5)); - AddStandartTableCell("SbI", VStandartTableRow(482, 12, 6)); - AddStandartTableCell("Obed", VStandartTableRow(566, 18, 6)); - AddStandartTableCell("Ok", VStandartTableRow(386, 8, 8)); - AddStandartTableCell("Oi", VStandartTableRow(380, 8, 6)); - AddStandartTableCell("Osch", VStandartTableRow(234, 4, 4)); - AddStandartTableCell("Dsb", VStandartTableRow(1120, 0, 44)); - AddStandartTableCell("Dsp", VStandartTableRow(1110, 0, 43)); - AddStandartTableCell("Dn", VStandartTableRow(826, -3, 37)); - AddStandartTableCell("Dps", VStandartTableRow(316, 4, 7)); - AddStandartTableCell("Dpob", VStandartTableRow(783, 14, 15)); - AddStandartTableCell("Ds", VStandartTableRow(260, 1, 6)); - AddStandartTableCell("Op", VStandartTableRow(316, 12, 0)); - AddStandartTableCell("Ozap", VStandartTableRow(180, 4, 0)); - AddStandartTableCell("Pkis", VStandartTableRow(250, 4, 0)); - AddStandartTableCell("SHp", VStandartTableRow(160, 1, 4)); - AddStandartTableCell("Dlych", VStandartTableRow(500, 2, 15)); - AddStandartTableCell("Dzap", VStandartTableRow(768, 2, 24)); - AddStandartTableCell("DIIIp", VStandartTableRow(970, 2, 29)); - AddStandartTableCell("Vprp", VStandartTableRow(214, 3, 3)); - AddStandartTableCell("Vg", VStandartTableRow(262, 8, 3)); - AddStandartTableCell("Dtp", VStandartTableRow(460, 7, 9)); - AddStandartTableCell("Dp", VStandartTableRow(355, 5, 5)); - AddStandartTableCell("Vprz", VStandartTableRow(208, 3, 5)); - AddStandartTableCell("Dts", VStandartTableRow(438, 2, 10)); - AddStandartTableCell("DtsI", VStandartTableRow(469, 2, 10)); - AddStandartTableCell("Dvcht", VStandartTableRow(929, 9, 19)); - AddStandartTableCell("SHg", VStandartTableRow(370, 14, 4)); - AddStandartTableCell("Cg", VStandartTableRow(224, 6, 0)); - AddStandartTableCell("SHs", VStandartTableRow(416, 10, 2)); - AddStandartTableCell("dpzr", VStandartTableRow(121, 6, 0)); - AddStandartTableCell("Ogol", VStandartTableRow(576, 4, 4)); - AddStandartTableCell("Ssh1", VStandartTableRow(205, 5, 0)); - AddStandartTableCell("St", VStandartTableRow(410, 20, 0)); - AddStandartTableCell("Drzap", VStandartTableRow(594, 3, 19)); - AddStandartTableCell("DbII", VStandartTableRow(1020, 0, 44)); - AddStandartTableCell("Sb", VStandartTableRow(504, 15, 4)); -} - -QVector VContainer::GetReversePoint(const QVector &points) const -{ - Q_ASSERT(points.size() > 0); - QVector reversePoints; - for (qint32 i = points.size() - 1; i >= 0; --i) - { - reversePoints.append(points.at(i)); - } - return reversePoints; -} - -qreal VContainer::GetLengthContour(const QVector &contour, const QVector &newPoints) const -{ - qreal length = 0; - QVector points; - points << contour << newPoints; - for (qint32 i = 0; i < points.size()-1; ++i) - { - QLineF line(points.at(i), points.at(i+1)); - length += line.length(); - } - return length; -} diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h deleted file mode 100644 index 91044d5cf..000000000 --- a/src/container/vcontainer.h +++ /dev/null @@ -1,688 +0,0 @@ -/************************************************************************ - ** - ** @file vcontainer.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VCONTAINER_H -#define VCONTAINER_H - -#include "vstandarttablerow.h" -#include "vincrementtablerow.h" -#include "../geometry/varc.h" -#include "../geometry/vsplinepath.h" -#include "../geometry/vdetail.h" -#include "../widgets/vitem.h" - -/** - * @brief The VContainer class container of all variables. - */ -class VContainer -{ - Q_DECLARE_TR_FUNCTIONS(VContainer) -public: - /** - * @brief VContainer create empty container - */ - VContainer(); - /** - * @brief operator = copy constructor - * @param data container - * @return copy container - */ - VContainer &operator=(const VContainer &data); - /** - * @brief VContainer create container from another container - * @param data container - */ - VContainer(const VContainer &data); - /** - * @brief setData copy data from container - * @param data container - */ - void setData(const VContainer &data); - /** - * @brief GetPoint returns a point by id - * @param id id of point - * @return point - */ - VPointF GetPoint(qint64 id) const; - /** - * @brief GetPointModeling return a point modeling by id - * @param id id of point modeling - * @return point modeling - */ - VPointF GetPointModeling(qint64 id) const; - /** - * @brief GetStandartTableCell return standart table row by name - * @param name name of standart table row - * @return row of standart table - */ - VStandartTableRow GetStandartTableCell(const QString& name) const; - /** - * @brief GetIncrementTableRow return increment table row by name - * @param name name of increment table row - * @return row of increment table - */ - VIncrementTableRow GetIncrementTableRow(const QString& name) const; - /** - * @brief GetLine return length of line by name - * @param name name of line - * @return length of line in mm - */ - qreal GetLine(const QString &name) const; - /** - * @brief GetLengthArc return length of arc by name - * @param name name of arc - * @return length of arc in mm - */ - qreal GetLengthArc(const QString &name) const; - /** - * @brief GetLengthSpline return length of spline by name - * @param name name of spline - * @return length of spline in mm - */ - qreal GetLengthSpline(const QString &name) const; - /** - * @brief GetLineAngle return angle of line - * @param name name of line angle - * @return angle in degree - */ - qreal GetLineAngle(const QString &name) const; - /** - * @brief GetSpline return spline by id - * @param id id of spline - * @return spline - */ - VSpline GetSpline(qint64 id) const; - /** - * @brief GetSplineModeling return spline modeling by id - * @param id id of spline modeling - * @return spline modeling - */ - VSpline GetSplineModeling(qint64 id) const; - /** - * @brief GetArc return arc by id - * @param id id of arc - * @return arc - */ - VArc GetArc(qint64 id) const; - /** - * @brief GetArcModeling return arc modeling by id - * @param id id of arc modeling - * @return arc modeling - */ - VArc GetArcModeling(qint64 id) const; - /** - * @brief GetSplinePath return spline path by id - * @param id id of spline path - * @return spline path - */ - VSplinePath GetSplinePath(qint64 id) const; - /** - * @brief GetSplinePathModeling return spline path modeling by id - * @param id id of spline modeling path - * @return spline modeling path - */ - VSplinePath GetSplinePathModeling(qint64 id) const; - /** - * @brief GetDetail return detail by id - * @param id id of detail - * @return detail - */ - VDetail GetDetail(qint64 id) const; - /** - * @brief getId return current id - * @return current id - */ - static qint64 getId() {return _id;} - /** - * @brief AddPoint add new point to container - * @param point new point - * @return return id of new point in container - */ - qint64 AddPoint(const VPointF& point); - /** - * @brief AddPointModeling add new point modeling to container - * @param point new point modeling - * @return return id of new point modeling in container - */ - qint64 AddPointModeling(const VPointF& point); - /** - * @brief AddDetail add new detail to container - * @param detail new detail - * @return return id of new detail in container - */ - qint64 AddDetail(const VDetail& detail); - /** - * @brief AddStandartTableCell add new row of standart table - * @param name name of row of standart table - * @param cell row of standart table - */ - inline void AddStandartTableCell(const QString& name, const VStandartTableRow& cell) - {standartTable[name] = cell;} - /** - * @brief AddIncrementTableRow add new row of increment table - * @param name name of new row of increment table - * @param row new row of increment table - */ - inline void AddIncrementTableRow(const QString& name, const VIncrementTableRow &row) - {incrementTable[name] = row;} - /** - * @brief AddLengthLine add length of line to container - * @param name name of line - * @param value length of line - */ - void AddLengthLine(const QString &name, const qreal &value); - /** - * @brief AddLengthSpline add length of spline to container - * @param name name of spline - * @param value length of spline - */ - void AddLengthSpline(const QString &name, const qreal &value); - /** - * @brief AddLengthArc add length of arc to container - * @param id id of arc - */ - void AddLengthArc(const qint64 &id); - /** - * @brief AddLengthArc add length of arc - * @param name name of arc - * @param value length of arc - */ - void AddLengthArc(const QString &name, const qreal &value); - /** - * @brief AddLineAngle add angle of line to container - * @param name name of line angle - * @param value angle in degree - */ - void AddLineAngle(const QString &name, const qreal &value); - /** - * @brief AddLine add line to container - * @param firstPointId id of first point of line - * @param secondPointId id of second point of line - * @param mode mode of line - */ - void AddLine(const qint64 &firstPointId, const qint64 &secondPointId, - const Draw::Draws &mode = Draw::Calculation); - /** - * @brief AddSpline add spline to container - * @param spl new spline - * @return id of spline in container - */ - qint64 AddSpline(const VSpline& spl); - /** - * @brief AddSplineModeling add spline modeling to container - * @param spl new spline modeling - * @return id of spline modeling in container - */ - qint64 AddSplineModeling(const VSpline& spl); - /** - * @brief AddSplinePath add spline path to container - * @param splPath new spline path - * @return id of spline path in container - */ - qint64 AddSplinePath(const VSplinePath& splPath); - /** - * @brief AddSplinePathModeling add spline path modeling to container - * @param splPath new spline path - * @return id of spline path in container - */ - qint64 AddSplinePathModeling(const VSplinePath& splPath); - /** - * @brief AddArc add arc to container - * @param arc new arc - * @return id of arc in container in container - */ - qint64 AddArc(const VArc& arc); - /** - * @brief AddArcModeling add arc modeling to container - * @param arc new arc modeling - * @return id of new arc modeling in container - */ - qint64 AddArcModeling(const VArc& arc); - /** - * @brief GetNameLine return name of line - * @param firstPoint id of first point of line - * @param secondPoint id of second point of line - * @param mode mode of line - * @return name of line - */ - QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, - const Draw::Draws &mode = Draw::Calculation) const; - /** - * @brief GetNameLineAngle return name of line angle - * @param firstPoint id of first point of line - * @param secondPoint id of second point of line - * @param mode mode of line - * @return name of angle of line - */ - QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, - const Draw::Draws &mode = Draw::Calculation) const; - /** - * @brief UpdatePoint update point by id - * @param id id of existing point - * @param point point - */ - void UpdatePoint(qint64 id, const VPointF& point); - /** - * @brief UpdatePointModeling update point modeling by id - * @param id id of existing point modeling - * @param point point modeling - */ - void UpdatePointModeling(qint64 id, const VPointF& point); - /** - * @brief UpdateDetail update detail by id - * @param id id of existing detail - * @param detail detail - */ - void UpdateDetail(qint64 id, const VDetail& detail); - /** - * @brief UpdateSpline update spline by id - * @param id if of existing spline - * @param spl spline - */ - void UpdateSpline(qint64 id, const VSpline& spl); - /** - * @brief UpdateSplineModeling update spline modeling by id - * @param id id of existing spline modeling - * @param spl spline modeling - */ - void UpdateSplineModeling(qint64 id, const VSpline& spl); - /** - * @brief UpdateSplinePath update spline path by id - * @param id id of existing spline path - * @param splPath spline path - */ - void UpdateSplinePath(qint64 id, const VSplinePath& splPath); - /** - * @brief UpdateSplinePathModeling update spline path modeling by id - * @param id id of existing spline path modeling - * @param splPath spline path modeling - */ - void UpdateSplinePathModeling(qint64 id, const VSplinePath& splPath); - /** - * @brief UpdateArc update arc by id - * @param id id of existing arc - * @param arc arc - */ - void UpdateArc(qint64 id, const VArc& arc); - /** - * @brief UpdateArcModeling update arc modeling by id - * @param id id of existing arc modeling - * @param arc arc modeling - */ - void UpdateArcModeling(qint64 id, const VArc& arc); - /** - * @brief UpdateStandartTableCell update standart table row by name - * @param name name of row - * @param cell row of standart table - */ - inline void UpdateStandartTableCell(const QString& name, const VStandartTableRow& cell) - {standartTable[name] = cell;} - /** - * @brief UpdateIncrementTableRow update increment table row by name - * @param name name of row - * @param row row - */ - inline void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& row) - {incrementTable[name] = row;} - /** - * @brief GetValueStandartTableCell return value of standart table row by name - * @param name name of row - * @return value in mm - */ - qreal GetValueStandartTableCell(const QString& name) const; - /** - * @brief GetValueIncrementTableRow return value of increment table row by name - * @param name name of row - * @return value of row in mm - */ - qreal GetValueIncrementTableRow(const QString& name) const; - /** - * @brief Clear clear data in container. Id will be 0. - */ - void Clear(); - /** - * @brief ClearObject points, splines, arcs, spline paths will be cleared. - */ - void ClearObject(); - /** - * @brief ClearIncrementTable clear increment table - */ - inline void ClearIncrementTable() {incrementTable.clear();} - /** - * @brief ClearLengthLines clear length lines - */ - inline void ClearLengthLines() {lengthLines.clear();} - /** - * @brief ClearLengthSplines clear length splines - */ - inline void ClearLengthSplines() {lengthSplines.clear();} - /** - * @brief ClearLengthArcs clear length arcs - */ - inline void ClearLengthArcs() {lengthArcs.clear();} - /** - * @brief ClearLineAngles clear angles of lines - */ - inline void ClearLineAngles() {lineAngles.clear();} - /** - * @brief SetSize set value of size - * @param size value of size in mm - */ - inline void SetSize(qint32 size) {base["Сг"] = size;} - /** - * @brief SetGrowth set value of growth - * @param growth value of growth in mm - */ - inline void SetGrowth(qint32 growth) {base["Р"] = growth;} - /** - * @brief size return size - * @return size in mm - */ - inline qint32 size() const {return base.value("Сг");} - /** - * @brief growth return growth - * @return growth in mm - */ - inline qint32 growth() const {return base.value("Р");} - /** - * @brief FindVar return value of variable by name - * @param name name of variable - * @param ok false if can't find variable - * @return value of variable - */ - qreal FindVar(const QString& name, bool *ok)const; - /** - * @brief IncrementTableContains check if increment table contains name - * @param name name of row - * @return true if contains - */ - inline bool IncrementTableContains(const QString& name) {return incrementTable.contains(name);} - /** - * @brief getNextId generate next unique id - * @return next unique id - */ - static qint64 getNextId(); - /** - * @brief RemoveIncrementTableRow remove row by name from increment table - * @param name name of existing row - */ - inline void RemoveIncrementTableRow(const QString& name) {incrementTable.remove(name);} - /** - * @brief data container with dataPoints return container of points - * @return pointer on container of points - */ - inline const QHash *DataPoints() const {return &points;} - /** - * @brief data container with dataPointsModeling return container of points modeling - * @return pointer on container of points modeling - */ - inline const QHash *DataPointsModeling() const {return &pointsModeling;} - /** - * @brief data container with dataSplines return container of splines - * @return pointer on container of splines - */ - inline const QHash *DataSplines() const {return &splines;} - /** - * @brief data container with dataSplinesModeling return container of splines modeling - * @return pointer on container of splines modeling - */ - inline const QHash *DataSplinesModeling() const {return &splinesModeling;} - /** - * @brief data container with dataArcs return container of arcs - * @return pointer on container of arcs - */ - inline const QHash *DataArcs() const {return &arcs;} - /** - * @brief data container with dataArcsModeling return container of arcs modeling - * @return pointer on container of arcs modeling - */ - inline const QHash *DataArcsModeling() const {return &arcsModeling;} - /** - * @brief data container with dataBase return container of data - * @return pointer on container of base data - */ - inline const QHash *DataBase() const {return &base;} - /** - * @brief data container with dataStandartTable return container of standart table - * @return pointer on container of standart table - */ - inline const QHash *DataStandartTable() const {return &standartTable;} - /** - * @brief data container with dataIncrementTable return container of increment table - * @return pointer on container of increment table - */ - inline const QHash *DataIncrementTable() const {return &incrementTable;} - /** - * @brief data container with dataLengthLines return container of lines lengths - * @return pointer on container of lines lengths - */ - inline const QHash *DataLengthLines() const {return &lengthLines;} - /** - * @brief data container with dataLengthSplines return container of splines lengths - * @return pointer on container of splines lengths - */ - inline const QHash *DataLengthSplines() const {return &lengthSplines;} - /** - * @brief data container with dataLengthArcs return container of arcs length - * @return pointer on container of arcs length - */ - inline const QHash *DataLengthArcs() const {return &lengthArcs;} - /** - * @brief data container with dataLineAngles return container of angles of line - * @return pointer on container of angles of line - */ - inline const QHash *DataLineAngles() const {return &lineAngles;} - /** - * @brief data container with dataSplinePaths return container of spline paths - * @return pointer on container of spline paths - */ - inline const QHash *DataSplinePaths() const {return &splinePaths;} - /** - * @brief data container with dataSplinePathsModeling return container of spline paths modeling - * @return pointer on container of spline paths modeling - */ - inline const QHash *DataSplinePathsModeling() const {return &splinePathsModeling;} - /** - * @brief data container with dataDetails return container of details - * @return pointer on container of details - */ - inline const QHash *DataDetails() const {return &details;} - /** - * @brief UpdateId update id. If new id bigger when current save new like current. - * @param newId id - */ - static void UpdateId(qint64 newId); - /** - * @brief ContourPath create painter path for detail - * @param idDetail id of detail - * @return return painter path of contour detail - */ - QPainterPath ContourPath(qint64 idDetail) const; - /** - * @brief biasPoints bias point - * @param points vector of points - * @param mx offset respect to x - * @param my offset respect to y - * @return new vector biased points - */ - QVector biasPoints(const QVector &points, const qreal &mx, const qreal &my) const; - /** - * @brief Equidistant create equidistant painter path for detail - * @param points vector of points - * @param eqv type of equidistant - * @param width width of equidistant - * @return return painter path of equidistant - */ - QPainterPath Equidistant(QVector points, const Detail::Equidistant &eqv, const qreal &width)const; - /** - * @brief ParallelLine create parallel line - * @param line starting line - * @param width width to parallel line - * @return parallel line - */ - static QLineF ParallelLine(const QLineF &line, qreal width ); - /** - * @brief SingleParallelPoint return point of parallel line - * @param line starting line - * @param angle angle in degree - * @param width width to parallel line - * @return point of parallel line - */ - static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width); - /** - * @brief EkvPoint return vector of points of equidistant two lines. Last point of two lines must be equal. - * @param line1 first line - * @param line2 second line - * @param width width of equidistant - * @return vector of points - */ - QVector EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const; - /** - * @brief CheckLoops seek and delete loops in equidistant - * @param points vector of points of equidistant - * @return vector of points of equidistant - */ - QVector CheckLoops(const QVector &points) const; - /** - * @brief PrepareDetails prepare detail for creation layout - * @param list list of details - */ - void PrepareDetails(QVector & list) const; -private: - /** - * @brief _id current id. New object will have value +1. For full class equal 0. - */ - static qint64 _id; - /** - * @brief base container of base data (size and growth) - */ - QHash base; - /** - * @brief points container of points - */ - QHash points; - /** - * @brief pointsModeling container of points modeling - */ - QHash pointsModeling; - /** - * @brief standartTable container of standart table rows - */ - QHash standartTable; - /** - * @brief incrementTable - */ - QHash incrementTable; - /** - * @brief lengthLines container of lines lengths - */ - QHash lengthLines; - /** - * @brief lineAngles container of angles of lines - */ - QHash lineAngles; - /** - * @brief splines container of splines - */ - QHash splines; - /** - * @brief splinesModeling container of splines modeling - */ - QHash splinesModeling; - /** - * @brief lengthSplines container of splines length - */ - QHash lengthSplines; - /** - * @brief arcs container of arcs - */ - QHash arcs; - /** - * @brief arcsModeling container of arcs modeling - */ - QHash arcsModeling; - /** - * @brief lengthArcs container of arcs length - */ - QHash lengthArcs; - /** - * @brief splinePaths container of spline paths - */ - QHash splinePaths; - /** - * @brief splinePathsModeling container of spline paths modeling - */ - QHash splinePathsModeling; - /** - * @brief details container of details - */ - QHash details; - /** - * @brief CreateManTableIGroup generate man standart table of measurements - */ - void CreateManTableIGroup (); - /** - * @brief GetReversePoint return revers container of points - * @param points container with points - * @return reverced points - */ - QVector GetReversePoint(const QVector &points)const; - /** - * @brief GetLengthContour return length of contour - * @param contour container with points of contour - * @param newPoints point whos we try to add to contour - * @return length length of contour - */ - qreal GetLengthContour(const QVector &contour, const QVector &newPoints)const; - template - /** - * @brief GetObject return object from container - * @param obj container - * @param id id of object - * @return Object - */ - static val GetObject(const QHash &obj, key id); - template - /** - * @brief UpdateObject update object in container - * @param obj container - * @param id id of existing object - * @param point object - */ - static void UpdateObject(QHash &obj, const qint64 &id, const val& point); - template - /** - * @brief AddObject add object to container - * @param obj container - * @param value object - * @return id of object in container - */ - static qint64 AddObject(QHash &obj, const val& value); -}; - -#endif // VCONTAINER_H diff --git a/src/container/vincrementtablerow.h b/src/container/vincrementtablerow.h deleted file mode 100644 index 493967569..000000000 --- a/src/container/vincrementtablerow.h +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************************ - ** - ** @file vincrementtablerow.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VINCREMENTTABLEROW_H -#define VINCREMENTTABLEROW_H - -#include - -/** - * @brief The VIncrementTableRow class keep data row of increment table - */ -class VIncrementTableRow -{ -public: - /** - * @brief VIncrementTableRow create enpty row - */ - VIncrementTableRow(); - /** - * @brief VIncrementTableRow create row - * @param id id - * @param base value in base size and growth - * @param ksize increment in sizes - * @param kgrowth increment in growths - * @param description description of increment - */ - VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, - QString description = QString()); - /** - * @brief getId return id of row - * @return id - */ - inline qint64 getId() const {return id;} - /** - * @brief setId set id of row - * @param value id - */ - inline void setId(const qint64 &value) {id = value;} - /** - * @brief getBase return value in base size and growth - * @return value - */ - inline qreal getBase() const {return base;} - /** - * @brief setBase set value in base size and growth - * @param value base value - */ - inline void setBase(const qreal &value) {base = value;} - /** - * @brief getKsize return increment in sizes - * @return increment - */ - inline qreal getKsize() const {return ksize;} - /** - * @brief setKsize set increment in sizes - * @param value value of increment - */ - inline void setKsize(const qreal &value) {ksize = value;} - /** - * @brief getKgrowth return increment in growths - * @return increment - */ - inline qreal getKgrowth() const {return kgrowth;} - /** - * @brief setKgrowth set increment in growths - * @param value value of increment - */ - inline void setKgrowth(const qreal &value) {kgrowth = value;} - /** - * @brief getDescription return description - * @return description - */ - inline QString getDescription() const {return description;} - /** - * @brief setDescription set description for row - * @param value description - */ - inline void setDescription(const QString &value) {description = value;} -private: - /** - * @brief id identificator - */ - qint64 id; - /** - * @brief base value in base size and growth - */ - qreal base; - /** - * @brief ksize increment in sizes - */ - qreal ksize; - /** - * @brief kgrowth increment in growths - */ - qreal kgrowth; - /** - * @brief description description of increment - */ - QString description; -}; - -#endif // VINCREMENTTABLEROW_H diff --git a/src/container/vpointf.h b/src/container/vpointf.h deleted file mode 100644 index 17260a385..000000000 --- a/src/container/vpointf.h +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************ - ** - ** @file vpointf.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VPOINTF_H -#define VPOINTF_H - -#include -#include -#include "../options.h" - -/** - * @brief The VPointF class keep data of point. - */ -class VPointF -{ -public: - /** - * @brief VPointF creat empty point - */ - inline VPointF () - :_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){} - /** - * @brief VPointF copy constructor - * @param point - */ - inline VPointF (const VPointF &point ) - :_name(point.name()), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()), - mode(point.getMode()), idObject(point.getIdObject()){} - /** - * @brief VPointF create new point - * @param x x coordinate - * @param y y coordinate - * @param name name of point - * @param mx offset name respect to x - * @param my offset name respect to y - * @param mode mode of draw - * @param idObject point modeling keep here id of parent point - */ - inline VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, - Draw::Draws mode = Draw::Calculation, qint64 idObject = 0) - :_name(name), _mx(mx), _my(my), _x(x), _y(y), mode(mode), idObject(idObject){} - /** - * @brief operator = assignment operator - * @param point point - * @return point - */ - VPointF &operator=(const VPointF &point); - ~VPointF(){} - /** - * @brief name return name of point - * @return name - */ - inline QString name() const { return _name;} - /** - * @brief mx return offset name respect to x - * @return offset - */ - inline qreal mx() const {return _mx;} - /** - * @brief my return offset name respect to y - * @return offset - */ - inline qreal my() const {return _my;} - /** - * @brief setName set name of point - * @param name name - */ - inline void setName(const QString &name) {_name = name;} - /** - * @brief setMx set offset name respect to x - * @param mx offset - */ - inline void setMx(qreal mx) {_mx = mx;} - /** - * @brief setMy set offset name respect to y - * @param my offset - */ - inline void setMy(qreal my) {_my = my;} - /** - * @brief toQPointF convert to QPointF - * @return QPointF point - */ - inline QPointF toQPointF()const {return QPointF(_x, _y);} - /** - * @brief x return x coordinate - * @return value - */ - inline qreal x() const {return _x;} - /** - * @brief setX set x coordinate - * @param value x coordinate - */ - inline void setX(const qreal &value){_x = value;} - /** - * @brief y return y coordinate - * @return value - */ - inline qreal y() const {return _y;} - /** - * @brief setY set y coordinate - * @param value y coordinate - */ - inline void setY(const qreal &value){_y = value;} - /** - * @brief getMode return mode of point - * @return mode - */ - inline Draw::Draws getMode() const{return mode;} - /** - * @brief setMode set mode for point - * @param value mode - */ - inline void setMode(const Draw::Draws &value) {mode = value;} - /** - * @brief getIdObject return id of parrent. - * @return id - */ - inline qint64 getIdObject() const {return idObject;} - /** - * @brief setIdObject set id of parent - * @param value id - */ - inline void setIdObject(const qint64 &value) {idObject = value;} -private: - /** - * @brief _name name of point - */ - QString _name; - /** - * @brief _mx offset name respect to x - */ - qreal _mx; - /** - * @brief _my offset name respect to y - */ - qreal _my; - /** - * @brief _x x coordinate - */ - qreal _x; - /** - * @brief _y y coordinate - */ - qreal _y; - /** - * @brief mode mode of point - */ - Draw::Draws mode; - /** - * @brief idObject id of parent. Only for point modeling. All another return 0. - */ - qint64 idObject; -}; - -#endif // VPOINTF_H diff --git a/src/container/vstandarttablerow.h b/src/container/vstandarttablerow.h deleted file mode 100644 index 4a56dad47..000000000 --- a/src/container/vstandarttablerow.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************ - ** - ** @file vstandarttablecell.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VSTANDARTTABLEROW_H -#define VSTANDARTTABLEROW_H - -#include - -/** - * @brief The VStandartTableRow class keep data row of standart table - */ -class VStandartTableRow -{ -public: - /** - * @brief VStandartTableRow create empty row - */ - VStandartTableRow(); - /** - * @brief VStandartTableRow create row - * @param base value in base size and growth - * @param ksize increment in sizes - * @param kgrowth increment in growths - * @param description description of increment - */ - VStandartTableRow(qint32 base, qreal ksize, qreal kgrowth, QString description = QString()); - /** - * @brief GetBase return value in base size and growth - * @return value - */ - inline qint32 GetBase() const {return base;} - /** - * @brief GetKsize return increment in sizes - * @return increment - */ - inline qreal GetKsize() const {return ksize;} - /** - * @brief GetKgrowth return increment in growths - * @return increment - */ - inline qreal GetKgrowth() const {return kgrowth;} - /** - * @brief GetDescription return description - * @return description - */ - inline QString GetDescription() const {return description;} -private: - /** - * @brief base value in base size and growth - */ - qint32 base; - /** - * @brief ksize increment in sizes - */ - qreal ksize; - /** - * @brief kgrowth increment in growths - */ - qreal kgrowth; - /** - * @brief description description measurement - */ - QString description; -}; - -#endif // VSTANDARTTABLEROW_H diff --git a/src/dialogs/dialogalongline.cpp b/src/dialogs/dialogalongline.cpp deleted file mode 100644 index 3cbe693c0..000000000 --- a/src/dialogs/dialogalongline.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/************************************************************************ - ** - ** @file dialogalongline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogalongline.h" -#include "ui_dialogalongline.h" - -#include - -DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0) -{ - ui->setupUi(this); - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; - labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = false; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogAlongLine::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected); - FillComboBoxTypeLine(ui->comboBoxLineType); - ui->comboBoxLineType->setCurrentIndex(1); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); - - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); - connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogAlongLine::PutVal); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogAlongLine::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogAlongLine::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogAlongLine::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogAlongLine::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogAlongLine::LengthLines); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogAlongLine::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogAlongLine::LengthCurves); - connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogAlongLine::EvalFormula); - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged); -} - -DialogAlongLine::~DialogAlongLine() -{ - delete ui; -} - -void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(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 second point of line")); - 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 DialogAlongLine::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->lineEditFormula->text(); - firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); - secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); - emit DialogClosed(QDialog::Accepted); -} - -void DialogAlongLine::setSecondPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); -} - -void DialogAlongLine::setFirstPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); -} - -void DialogAlongLine::setFormula(const QString &value) -{ - formula = value; - ui->lineEditFormula->setText(formula); -} - -void DialogAlongLine::setTypeLine(const QString &value) -{ - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); -} - -void DialogAlongLine::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} diff --git a/src/dialogs/dialogalongline.h b/src/dialogs/dialogalongline.h deleted file mode 100644 index 67aa5f0a2..000000000 --- a/src/dialogs/dialogalongline.h +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************ - ** - ** @file dialogalongline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGALONGLINE_H -#define DIALOGALONGLINE_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogAlongLine; -} - -/** - * @brief The DialogAlongLine class dialog for ToolAlongLine. Help create point and edit option. - */ -class DialogAlongLine : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogAlongLine create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogAlongLine(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getFormula return string of formula - * @return formula - */ - inline QString getFormula() const {return formula;} - /** - * @brief setFormula set string of formula - * @param value formula - */ - void setFormula(const QString &value); - /** - * @brief getFirstPointId return id first point of line - * @return id - */ - inline qint64 getFirstPointId() const {return firstPointId;} - /** - * @brief setFirstPointId set id first point of line - * @param value id - * @param id id of current point - */ - void setFirstPointId(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPointId return id second point of line - * @return id - */ - inline qint64 getSecondPointId() const {return secondPointId;} - /** - * @brief setSecondPointId set id second point of line - * @param value id - * @param id id of current point - */ - void setSecondPointId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogAlongLine) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogAlongLine *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief formula formula - */ - QString formula; - /** - * @brief firstPointId id first point of line - */ - qint64 firstPointId; - /** - * @brief secondPointId id second point of line - */ - qint64 secondPointId; -}; - -#endif // DIALOGALONGLINE_H diff --git a/src/dialogs/dialogalongline.ui b/src/dialogs/dialogalongline.ui deleted file mode 100644 index 3030f22ba..000000000 --- a/src/dialogs/dialogalongline.ui +++ /dev/null @@ -1,408 +0,0 @@ - - - DialogAlongLine - - - - 0 - 0 - 470 - 454 - - - - Point along line - - - - :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - - - - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Length - - - - - - - Formula calculation of length of line - - - - - - - Calculate formula - - - ... - - - - :/icon/24x24/equal.png:/icon/24x24/equal.png - - - - 24 - 24 - - - - - - - - - 0 - 0 - - - - - 87 - 0 - - - - - 0 - 0 - - - - Value of length - - - _ - - - - - - - - - - - - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Name new point - - - - - - - - - - Put variable into formula - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - - - First point - - - - - - - First point of line - - - - - - - - - - - Second point - - - - - - - Second point of line - - - - - - - - - - - Type line - - - - - - - Show line from first point to our point - - - - - - - - - - - Input data - - - - - - - Size and growth - - - true - - - - - - - Standart table - - - - - - - Increments - - - - - - - Length of lines - - - - - - - true - - - Length of arcs - - - - - - - true - - - Length of curves - - - - - - - - - - - Variables. Click twice to select. - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - lineEditFormula - toolButtonEqual - lineEditNamePoint - comboBoxFirstPoint - comboBoxSecondPoint - comboBoxLineType - radioButtonSizeGrowth - radioButtonStandartTable - radioButtonIncrements - radioButtonLengthLine - radioButtonLengthArc - radioButtonLengthSpline - listWidget - toolButtonPutHere - buttonBox - - - - - - - buttonBox - accepted() - DialogAlongLine - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DialogAlongLine - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/dialogs/dialogarc.cpp b/src/dialogs/dialogarc.cpp deleted file mode 100644 index d9429dd36..000000000 --- a/src/dialogs/dialogarc.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/************************************************************************ - ** - ** @file dialogarc.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogarc.h" -#include "ui_dialogarc.h" - -#include -#include - -DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), - timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()) -{ - ui->setupUi(this); - - timerRadius = new QTimer(this); - connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); - - timerF1 = new QTimer(this); - connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF1); - - timerF2 = new QTimer(this); - connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2); - - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogArc::DialogAccepted); - - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogArc::DialogRejected); - FillComboBoxPoints(ui->comboBoxBasePoint); - - CheckState(); - - listWidget = ui->listWidget; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - - connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); - connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); - connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogArc::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines); - connect(ui->radioButtonLineAngles, &QRadioButton::clicked, this, &DialogArc::LineAngles); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogArc::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogArc::LengthCurves); - - connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius); - connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); - connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2); - - connect(ui->lineEditRadius, &QLineEdit::textChanged, this, &DialogArc::RadiusChanged); - connect(ui->lineEditF1, &QLineEdit::textChanged, this, &DialogArc::F1Changed); - connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed); -} - -DialogArc::~DialogArc() -{ - delete ui; -} - -void DialogArc::SetCenter(const qint64 &value) -{ - center = value; - ChangeCurrentData(ui->comboBoxBasePoint, center); -} - -void DialogArc::SetF2(const QString &value) -{ - f2 = value; - ui->lineEditF2->setText(f2); -} - -void DialogArc::SetF1(const QString &value) -{ - f1 = value; - ui->lineEditF1->setText(f1); -} - -void DialogArc::SetRadius(const QString &value) -{ - radius = value; - ui->lineEditRadius->setText(radius); -} - -void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id)==false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - ChangeCurrentText(ui->comboBoxBasePoint, point.name()); - emit ToolTip(""); - this->show(); - } -} - -void DialogArc::DialogAccepted() -{ - radius = ui->lineEditRadius->text(); - f1 = ui->lineEditF1->text(); - f2 = ui->lineEditF2->text(); - center = getCurrentPointId(ui->comboBoxBasePoint); - emit DialogClosed(QDialog::Accepted); -} - -void DialogArc::ValChenged(int row) -{ - if (ui->listWidget->count() == 0) - { - return; - } - QListWidgetItem *item = ui->listWidget->item( row ); - if (ui->radioButtonLineAngles->isChecked()) - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineAngle(item->text())) - .arg(tr("Value angle of line.")); - ui->labelDescription->setText(desc); - return; - } - DialogTool::ValChenged(row); -} - -void DialogArc::PutRadius() -{ - PutValHere(ui->lineEditRadius, ui->listWidget); -} - -void DialogArc::PutF1() -{ - PutValHere(ui->lineEditF1, ui->listWidget); -} - -void DialogArc::PutF2() -{ - PutValHere(ui->lineEditF2, ui->listWidget); -} - -void DialogArc::LineAngles() -{ - ShowLineAngles(); -} - -void DialogArc::RadiusChanged() -{ - labelEditFormula = ui->labelEditRadius; - ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius); -} - -void DialogArc::F1Changed() -{ - labelEditFormula = ui->labelEditF1; - ValFormulaChanged(flagF1, ui->lineEditF1, timerF1); -} - -void DialogArc::F2Changed() -{ - labelEditFormula = ui->labelEditF2; - ValFormulaChanged(flagF2, ui->lineEditF2, timerF2); -} - -void DialogArc::CheckState() -{ - Q_ASSERT(bOk != 0); - bOk->setEnabled(flagRadius && flagF1 && flagF2); -} - -void DialogArc::EvalRadius() -{ - labelEditFormula = ui->labelEditRadius; - Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius); -} - -void DialogArc::EvalF1() -{ - labelEditFormula = ui->labelEditF1; - Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1); -} - -void DialogArc::EvalF2() -{ - labelEditFormula = ui->labelEditF2; - Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2); -} - -void DialogArc::ShowLineAngles() -{ - disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); - ui->listWidget->clear(); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); - const QHash *lineAnglesTable = data->DataLineAngles(); - Q_ASSERT(lineAnglesTable != 0); - QHashIterator i(*lineAnglesTable); - while (i.hasNext()) - { - i.next(); - QListWidgetItem *item = new QListWidgetItem(i.key()); - - item->setFont(QFont("Times", 12, QFont::Bold)); - ui->listWidget->addItem(item); - } - ui->listWidget->setCurrentRow (0); -} diff --git a/src/dialogs/dialogarc.h b/src/dialogs/dialogarc.h deleted file mode 100644 index 27bf820bb..000000000 --- a/src/dialogs/dialogarc.h +++ /dev/null @@ -1,207 +0,0 @@ -/************************************************************************ - ** - ** @file dialogarc.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGARC_H -#define DIALOGARC_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogArc; -} - -/** - * @brief The DialogArc class dialog for ToolArc. Help create arc and edit option. - */ -class DialogArc : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogArc create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogArc(); - /** - * @brief GetCenter return id of center point - * @return id id - */ - inline qint64 GetCenter() const {return center;} - /** - * @brief SetCenter set id of center point - * @param value id - */ - void SetCenter(const qint64 &value); - /** - * @brief GetRadius return formula of radius - * @return formula - */ - inline QString GetRadius() const {return radius;} - /** - * @brief SetRadius set formula of radius - * @param value formula - */ - void SetRadius(const QString &value); - /** - * @brief GetF1 return formula first angle of arc - * @return formula - */ - inline QString GetF1() const {return f1;} - /** - * @brief SetF1 set formula first angle of arc - * @param value formula - */ - void SetF1(const QString &value); - /** - * @brief GetF2 return formula second angle of arc - * @return formula - */ - inline QString GetF2() const {return f2;} - /** - * @brief SetF2 set formula second angle of arc - * @param value formula - */ - void SetF2(const QString &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); - /** - * @brief ValChenged show description angles of lines - * @param row number of row - */ - virtual void ValChenged(int row); - /** - * @brief PutRadius put variable into formula of radius - */ - void PutRadius(); - /** - * @brief PutF1 put variable into formula of first angle - */ - void PutF1(); - /** - * @brief PutF2 put variable into formula of second angle - */ - void PutF2(); - /** - * @brief LineAngles show variable angles of lines - */ - void LineAngles(); - /** - * @brief RadiusChanged after change formula of radius calculate value and show result - */ - void RadiusChanged(); - /** - * @brief F1Changed after change formula of first angle calculate value and show result - */ - void F1Changed(); - /** - * @brief F2Changed after change formula of second angle calculate value and show result - */ - void F2Changed(); -protected: - /** - * @brief CheckState if all is right enable button ok - */ - virtual void CheckState(); -private: - Q_DISABLE_COPY(DialogArc) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogArc *ui; - /** - * @brief flagRadius true if value of radius is correct - */ - bool flagRadius; - /** - * @brief flagF1 true if value of first angle is correct - */ - bool flagF1; - /** - * @brief flagF2 true if value of second angle is correct - */ - bool flagF2; - /** - * @brief timerRadius timer of check formula of radius - */ - QTimer *timerRadius; - /** - * @brief timerF1 timer of check formula of first angle - */ - QTimer *timerF1; - /** - * @brief timerF2 timer of check formula of second angle - */ - QTimer *timerF2; - /** - * @brief center id of center point - */ - qint64 center; - /** - * @brief radius formula of radius - */ - QString radius; - /** - * @brief f1 formula of first angle - */ - QString f1; - /** - * @brief f2 formula of second angle - */ - QString f2; - /** - * @brief EvalRadius calculate value of radius - */ - void EvalRadius(); - /** - * @brief EvalF1 calculate value of first angle - */ - void EvalF1(); - /** - * @brief EvalF2 calculate value of second angle - */ - void EvalF2(); - /** - * @brief ShowLineAngles show varibles angles of lines - */ - void ShowLineAngles(); -}; - -#endif // DIALOGARC_H diff --git a/src/dialogs/dialogbisector.cpp b/src/dialogs/dialogbisector.cpp deleted file mode 100644 index 1809dec13..000000000 --- a/src/dialogs/dialogbisector.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/************************************************************************ - ** - ** @file dialogbisector.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogbisector.h" -#include "ui_dialogbisector.h" - -#include - -DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0) -{ - ui->setupUi(this); - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; - labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = false; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogBisector::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); - FillComboBoxPoints(ui->comboBoxThirdPoint); - FillComboBoxTypeLine(ui->comboBoxLineType); - - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); - connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogBisector::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogBisector::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogBisector::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogBisector::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogBisector::LengthLines); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogBisector::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogBisector::LengthCurves); - connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogBisector::EvalFormula); - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged); -} - -DialogBisector::~DialogBisector() -{ - delete ui; -} - -void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(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 second point of angle")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxSecondPoint->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxSecondPoint->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select third point of angle")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxThirdPoint->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxThirdPoint->setCurrentIndex(index); - number = 0; - emit ToolTip(""); - } - if (isInitialized == false) - { - this->show(); - } - } - } -} - -void DialogBisector::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} - -void DialogBisector::setTypeLine(const QString &value) -{ - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); -} - -void DialogBisector::setFormula(const QString &value) -{ - formula = value; - ui->lineEditFormula->setText(formula); -} - -void DialogBisector::setFirstPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); -} - -void DialogBisector::setSecondPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); -} - -void DialogBisector::setThirdPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxThirdPoint, thirdPointId, value, id); -} - -void DialogBisector::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->lineEditFormula->text(); - firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); - secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); - thirdPointId = getCurrentPointId(ui->comboBoxThirdPoint); - emit DialogClosed(QDialog::Accepted); -} diff --git a/src/dialogs/dialogbisector.h b/src/dialogs/dialogbisector.h deleted file mode 100644 index dbdb03280..000000000 --- a/src/dialogs/dialogbisector.h +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************ - ** - ** @file dialogbisector.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGBISECTOR_H -#define DIALOGBISECTOR_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogBisector; -} - -/** - * @brief The DialogBisector class dialog for ToolBisector. Help create point and edit option. - */ -class DialogBisector : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogBisector create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogBisector(); - /** - * @brief getPointName return name of point - * @return name - */ - QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getFormula return string of formula - * @return formula - */ - inline QString getFormula() const {return formula;} - /** - * @brief setFormula set string of formula - * @param value formula - */ - void setFormula(const QString &value); - /** - * @brief getFirstPointId return id of first point - * @return id - */ - inline qint64 getFirstPointId() const {return firstPointId;} - /** - * @brief setFirstPointId set id of first point - * @param value id - * @param id don't show this id in list - */ - void setFirstPointId(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPointId return id of second point - * @return id - */ - inline qint64 getSecondPointId() const {return secondPointId;} - /** - * @brief setSecondPointId set id of second point - * @param value id - * @param id don't show this id in list - */ - void setSecondPointId(const qint64 &value, const qint64 &id); - /** - * @brief getThirdPointId return id of third point - * @return id - */ - inline qint64 getThirdPointId() const {return thirdPointId;} - /** - * @brief setThirdPointId set id of third point - * @param value id - * @param id don't show this id in list - */ - void setThirdPointId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogBisector) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogBisector *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief formula formula - */ - QString formula; - /** - * @brief firstPointId id of first point - */ - qint64 firstPointId; - /** - * @brief secondPointId id of second point - */ - qint64 secondPointId; - /** - * @brief thirdPointId id of third point - */ - qint64 thirdPointId; -}; - -#endif // DIALOGBISECTOR_H diff --git a/src/dialogs/dialogdetail.cpp b/src/dialogs/dialogdetail.cpp deleted file mode 100644 index 6b1b7ab9b..000000000 --- a/src/dialogs/dialogdetail.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/************************************************************************ - ** - ** @file dialogdetail.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogdetail.h" - -#include -#include - -DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true) -{ - ui.setupUi(this); - labelEditNamePoint = ui.labelEditNameDetail; - bOk = ui.buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected); - - connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged); - connect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogDetail::BiasXChanged); - connect(ui.doubleSpinBoxBiasY, static_cast(&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, 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::Line && type != Scene::Detail) - { - switch (type) - { - case (Scene::Arc): - NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour); - break; - case (Scene::Point): - NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour); - break; - case (Scene::Spline): - NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour); - break; - case (Scene::SplinePath): - NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour); - break; - default: - qWarning()<show(); - } -} - -void DialogDetail::DialogAccepted() -{ - details.Clear(); - for (qint32 i = 0; i < ui.listWidget->count(); ++i) - { - QListWidgetItem *item = ui.listWidget->item(i); - details.append( qvariant_cast(item->data(Qt::UserRole))); - } - details.setWidth(ui.doubleSpinBoxSeams->value()); - details.setName(ui.lineEditNameDetail->text()); - details.setSupplement(supplement); - details.setClosed(closed); - emit ToolTip(""); - emit DialogClosed(QDialog::Accepted); -} - -void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::Draws &mode, - const NodeDetail::NodeDetails &typeNode, qreal mx, qreal my) -{ - QString name; - switch (typeTool) - { - case (Tool::NodePoint): - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - name = point.name(); - break; - } - case (Tool::NodeArc): - { - VArc arc; - if (mode == Draw::Calculation) - { - arc = data->GetArc(id); - } - else - { - arc = data->GetArcModeling(id); - } - name = arc.name(); - break; - } - case (Tool::NodeSpline): - { - VSpline spl; - if (mode == Draw::Calculation) - { - spl = data->GetSpline(id); - } - else - { - spl = data->GetSplineModeling(id); - } - name = spl.GetName(); - break; - } - case (Tool::NodeSplinePath): - { - VSplinePath splPath; - if (mode == Draw::Calculation) - { - splPath = data->GetSplinePath(id); - } - else - { - splPath = data->GetSplinePathModeling(id); - } - name = splPath.name(); - break; - } - default: - qWarning()<setFont(QFont("Times", 12, QFont::Bold)); - VNodeDetail node(id, typeTool, mode, typeNode, mx, my); - item->setData(Qt::UserRole, QVariant::fromValue(node)); - ui.listWidget->addItem(item); - disconnect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogDetail::BiasXChanged); - disconnect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogDetail::BiasYChanged); - ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx())); - ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy())); - connect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogDetail::BiasXChanged); - connect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogDetail::BiasYChanged); -} - -void DialogDetail::setDetails(const VDetail &value) -{ - details = value; - ui.listWidget->clear(); - for (ptrdiff_t i = 0; i < details.CountNode(); ++i) - { - NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getMode(), details[i].getTypeNode(), - details[i].getMx(), details[i].getMy()); - } - ui.lineEditNameDetail->setText(details.getName()); - ui.checkBoxSeams->setChecked(details.getSupplement()); - ui.checkBoxClosed->setChecked(details.getClosed()); - ui.doubleSpinBoxSeams->setValue(details.getWidth()); - ui.listWidget->setCurrentRow(0); - ui.listWidget->setFocus(Qt::OtherFocusReason); -} - -void DialogDetail::BiasXChanged(qreal d) -{ - qint32 row = ui.listWidget->currentRow(); - QListWidgetItem *item = ui.listWidget->item( row ); - VNodeDetail node = qvariant_cast(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(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(item->data(Qt::UserRole)); - ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx())); - ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy())); -} diff --git a/src/dialogs/dialogdetail.h b/src/dialogs/dialogdetail.h deleted file mode 100644 index 3253422cd..000000000 --- a/src/dialogs/dialogdetail.h +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************ - ** - ** @file dialogdetail.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGDETAIL_H -#define DIALOGDETAIL_H - -#include "ui_dialogdetail.h" -#include "dialogtool.h" - -/** - * @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option. - */ -class DialogDetail : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogDetail create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0); - /** - * @brief getDetails return detail - * @return detail - */ - inline VDetail getDetails() const {return details;} - /** - * @brief setDetails set detail - * @param value detail - */ - void setDetails(const VDetail &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of objects (points, arcs, splines, spline paths) - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); - /** - * @brief BiasXChanged changed value of offset for object respect to x - * @param d value in mm - */ - void BiasXChanged(qreal d); - /** - * @brief BiasYChanged changed value of offset for object respect to y - * @param d value in mm - */ - void BiasYChanged(qreal d); - /** - * @brief ClickedSeams save supplement of seams for detail - * @param checked 1 - need supplement, 0 - don't need supplement - */ - void ClickedSeams(bool checked); - /** - * @brief ClickedClosed save closed equdistant or not - * @param checked 1 - closed, 0 - don't closed - */ - void ClickedClosed(bool checked); - /** - * @brief ObjectChanged changed new object (point, arc, spline or spline path) form list - * @param row number of row - */ - void ObjectChanged(int row); -private: - /** - * @brief ui keeps information about user interface - */ - Ui::DialogDetail ui; - /** - * @brief details detail - */ - VDetail details; - /** - * @brief supplement keep option supplement of seams - */ - bool supplement; - /** - * @brief closed keep option about equdistant (closed or not) - */ - bool closed; - /** - * @brief NewItem add new object (point, arc, spline or spline path) to list - * @param id id of object - * @param typeTool type of tool - * @param mode mode - * @param typeNode type of node in detail - * @param mx offset respect to x - * @param my offset respect to y - */ - 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 diff --git a/src/dialogs/dialogendline.cpp b/src/dialogs/dialogendline.cpp deleted file mode 100644 index b00834019..000000000 --- a/src/dialogs/dialogendline.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************ - ** - ** @file dialogendline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogendline.h" -#include "ui_dialogendline.h" - -#include - -DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), - formula(QString()), angle(0), basePointId(0) -{ - ui->setupUi(this); - spinBoxAngle = ui->doubleSpinBoxAngle; - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; - labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = false; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogEndLine::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogEndLine::DialogRejected); - FillComboBoxPoints(ui->comboBoxBasePoint); - FillComboBoxTypeLine(ui->comboBoxLineType); - - connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, - &DialogEndLine::ArrowDown); - connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, - &DialogEndLine::ArrowUp); - connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, - &DialogEndLine::ArrowLeft); - connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, - &DialogEndLine::ArrowRight); - connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, - &DialogEndLine::ArrowLeftUp); - connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, - &DialogEndLine::ArrowLeftDown); - connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, - &DialogEndLine::ArrowRightUp); - connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, - &DialogEndLine::ArrowRightDown); - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEndLine::PutHere); - connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEndLine::PutVal); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogEndLine::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogEndLine::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogEndLine::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEndLine::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEndLine::LengthLines); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogEndLine::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEndLine::LengthCurves); - connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEndLine::EvalFormula); - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged); -} - -void DialogEndLine::ChoosedObject(qint64 id, 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->GetPointModeling(id); - } - ChangeCurrentText(ui->comboBoxBasePoint, point.name()); - emit ToolTip(""); - this->show(); - } -} - -void DialogEndLine::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} - -void DialogEndLine::setTypeLine(const QString &value) -{ - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); -} - -void DialogEndLine::setFormula(const QString &value) -{ - formula = value; - ui->lineEditFormula->setText(formula); -} - -void DialogEndLine::setAngle(const qreal &value) -{ - angle = value; - ui->doubleSpinBoxAngle->setValue(angle); -} - -void DialogEndLine::setBasePointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id); -} - -void DialogEndLine::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->lineEditFormula->text(); - angle = ui->doubleSpinBoxAngle->value(); - basePointId = getCurrentPointId(ui->comboBoxBasePoint); - emit DialogClosed(QDialog::Accepted); -} - -DialogEndLine::~DialogEndLine() -{ - delete ui; -} diff --git a/src/dialogs/dialogendline.h b/src/dialogs/dialogendline.h deleted file mode 100644 index 394ad7876..000000000 --- a/src/dialogs/dialogendline.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************ - ** - ** @file dialogendline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGENDLINE_H -#define DIALOGENDLINE_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogEndLine; -} - -/** - * @brief The DialogEndLine class dialog for ToolEndLine. Help create point and edit option. - */ -class DialogEndLine : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogEndLine create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogEndLine(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getFormula return string of formula - * @return formula - */ - inline QString getFormula() const {return formula;} - /** - * @brief setFormula set string of formula - * @param value formula - */ - void setFormula(const QString &value); - /** - * @brief getAngle return angle of line - * @return angle in degree - */ - inline qreal getAngle() const {return angle;} - /** - * @brief setAngle set angle of line - * @param value angle in degree - */ - void setAngle(const qreal &value); - /** - * @brief getBasePointId return id base point of line - * @return id - */ - inline qint64 getBasePointId() const {return basePointId;} - /** - * @brief setBasePointId set id base point of line - * @param value id - * @param id don't show this id in list - */ - void setBasePointId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogEndLine) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogEndLine *ui; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief formula formula - */ - QString formula; - /** - * @brief angle angle of line - */ - qreal angle; - /** - * @brief basePointId id base point of line - */ - qint64 basePointId; -}; - -#endif // DIALOGENDLINE_H diff --git a/src/dialogs/dialogendline.ui b/src/dialogs/dialogendline.ui deleted file mode 100644 index ad99685ca..000000000 --- a/src/dialogs/dialogendline.ui +++ /dev/null @@ -1,614 +0,0 @@ - - - DialogEndLine - - - - 0 - 0 - 539 - 559 - - - - Point in the end of line - - - - :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - - - - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Length - - - - - - - - 0 - 0 - - - - Formula calculation of length of line - - - - - - - Calculate formula - - - ... - - - - :/icon/24x24/equal.png:/icon/24x24/equal.png - - - - 24 - 24 - - - - - - - - - 0 - 0 - - - - - 87 - 0 - - - - Value of length - - - _ - - - - - - - - - - - - - - - - 0 - 0 - - - - Base point - - - - - - - First point of line - - - - - - - ... - - - - :/icon/24x24/putHere.png:/icon/24x24/putHere.png - - - - 24 - 24 - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Name new point - - - - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Angle degree - - - - - - - QLayout::SetMinimumSize - - - 29 - - - 6 - - - - - ... - - - - :/icon/24x24/arrowRightUp.png:/icon/24x24/arrowRightUp.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowLeftUp.png:/icon/24x24/arrowLeftUp.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowLeft.png:/icon/24x24/arrowLeft.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowRight.png:/icon/24x24/arrowRight.png - - - - 32 - 32 - - - - - - - - - 0 - 0 - - - - ... - - - - :/icon/24x24/arrowUp.png:/icon/24x24/arrowUp.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowDown.png:/icon/24x24/arrowDown.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowLeftDown.png:/icon/24x24/arrowLeftDown.png - - - - 32 - 32 - - - - - - - - ... - - - - :/icon/24x24/arrowRightDown.png:/icon/24x24/arrowRightDown.png - - - - 32 - 32 - - - - - - - - - 0 - 0 - - - - - 57 - 0 - - - - Angle of line - - - 360.000000000000000 - - - - - - - - - - - - - - - Type line - - - - - - - Show line from first point to our point - - - - - - - - - - - Input data - - - - - - - Size and growth - - - true - - - - - - - Standart table - - - - - - - Increments - - - - - - - true - - - Length of lines - - - - - - - true - - - Length of arcs - - - - - - - true - - - Length of curves - - - - - - - - - - - Variables. Click twice to select. - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - lineEditFormula - comboBoxBasePoint - lineEditNamePoint - doubleSpinBoxAngle - toolButtonArrowRight - toolButtonArrowRightUp - toolButtonArrowUp - toolButtonArrowLeftUp - toolButtonArrowLeft - toolButtonArrowLeftDown - toolButtonArrowDown - toolButtonArrowRightDown - comboBoxLineType - radioButtonSizeGrowth - radioButtonStandartTable - radioButtonIncrements - radioButtonLengthLine - radioButtonLengthArc - radioButtonLengthSpline - listWidget - toolButtonPutHere - toolButtonEqual - buttonBox - - - - - - - buttonBox - accepted() - DialogEndLine - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DialogEndLine - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/dialogs/dialogheight.cpp b/src/dialogs/dialogheight.cpp deleted file mode 100644 index 1592c40bd..000000000 --- a/src/dialogs/dialogheight.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************ - ** - ** @file dialogheight.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogheight.h" -#include "ui_dialogheight.h" - -#include - -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->GetPointModeling(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); -} diff --git a/src/dialogs/dialogheight.h b/src/dialogs/dialogheight.h deleted file mode 100644 index dfa360a9b..000000000 --- a/src/dialogs/dialogheight.h +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************ - ** - ** @file dialogheight.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGHEIGHT_H -#define DIALOGHEIGHT_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogHeight; -} - -/** - * @brief The DialogHeight class dialog for ToolHeight. Help create point and edit option. - */ -class DialogHeight : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogHeight create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogHeight(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getBasePointId return id base point of height - * @return id - */ - inline qint64 getBasePointId() const {return basePointId;} - /** - * @brief setBasePointId set id base point of height - * @param value id - * @param id don't show this id in list - */ - void setBasePointId(const qint64 &value, const qint64 &id); - /** - * @brief getP1LineId return id first point of line - * @return id id - */ - inline qint64 getP1LineId() const {return p1LineId;} - /** - * @brief setP1LineId set id first point of line - * @param value id - * @param id don't show this id in list - */ - void setP1LineId(const qint64 &value, const qint64 &id); - /** - * @brief getP2LineId return id second point of line - * @return id - */ - inline qint64 getP2LineId() const{return p2LineId;} - /** - * @brief setP2LineId set id second point of line - * @param value id - * @param id don't show this id in list - */ - void setP2LineId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogHeight) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogHeight *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief basePointId id base point of height - */ - qint64 basePointId; - /** - * @brief p1LineId id first point of line - */ - qint64 p1LineId; - /** - * @brief p2LineId id second point of line - */ - qint64 p2LineId; -}; - -#endif // DIALOGHEIGHT_H diff --git a/src/dialogs/dialoghistory.cpp b/src/dialogs/dialoghistory.cpp deleted file mode 100644 index 95c29a52e..000000000 --- a/src/dialogs/dialoghistory.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/************************************************************************ - ** - ** @file dialoghistory.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialoghistory.h" -#include "ui_dialoghistory.h" -#include "../geometry/varc.h" -#include "../geometry/vspline.h" -#include "../geometry/vsplinepath.h" -#include -#include - -DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) - :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), - cursorToolRecordRow(0) -{ - ui->setupUi(this); - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); - FillTable(); - InitialTable(); - connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); - connect(this, &DialogHistory::ShowHistoryTool, doc, &VDomDocument::ShowHistoryTool); - connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); - connect(doc, &VDomDocument::haveChange, this, &DialogHistory::UpdateHistory); - connect(doc, &VDomDocument::ChangedActivDraw, this, &DialogHistory::UpdateHistory); - ShowPoint(); -} - -DialogHistory::~DialogHistory() -{ - delete ui; -} - -void DialogHistory::DialogAccepted() -{ - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); - emit DialogClosed(QDialog::Accepted); -} - -void DialogHistory::cellClicked(int row, int column) -{ - if (column == 0) - { - QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); - item->setIcon(QIcon()); - - item = ui->tableWidget->item(row, 0); - cursorRow = row; - item->setIcon(QIcon("://icon/32x32/put_after.png")); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); - doc->setCursor(id); - connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); - } - else - { - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); - - cursorToolRecordRow = row; - item = ui->tableWidget->item(cursorToolRecordRow, 0); - id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); - } -} - -void DialogHistory::ChangedCursor(qint64 id) -{ - for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i) - { - QTableWidgetItem *item = ui->tableWidget->item(i, 0); - qint64 rId = qvariant_cast(item->data(Qt::UserRole)); - if (rId == id) - { - QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); - oldCursorItem->setIcon(QIcon()); - cursorRow = i; - item->setIcon(QIcon("://icon/32x32/put_after.png")); - } - } -} - -void DialogHistory::UpdateHistory() -{ - FillTable(); - InitialTable(); -} - -void DialogHistory::FillTable() -{ - ui->tableWidget->clear(); - QVector *history = doc->getHistory(); - qint32 currentRow = -1; - qint32 count = 0; - ui->tableWidget->setRowCount(history->size()); - for (qint32 i = 0; i< history->size(); ++i) - { - VToolRecord tool = history->at(i); - if (tool.getNameDraw() != doc->GetNameActivDraw()) - { - continue; - } - currentRow++; - - QTableWidgetItem *item = new QTableWidgetItem(QString()); - item->setTextAlignment(Qt::AlignHCenter); - item->setData(Qt::UserRole, tool.getId()); - ui->tableWidget->setItem(currentRow, 0, item); - - QString historyRecord = Record(tool); - item = new QTableWidgetItem(historyRecord); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setFlags(item->flags() ^ Qt::ItemIsEditable); - ui->tableWidget->setItem(currentRow, 1, item); - ++count; - } - ui->tableWidget->setRowCount(count); - if (history->size()>0) - { - cursorRow = currentRow; - QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); - item->setIcon(QIcon("://icon/32x32/put_after.png")); - } - ui->tableWidget->resizeColumnsToContents(); - ui->tableWidget->resizeRowsToContents(); - ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); -} - -QString DialogHistory::Record(const VToolRecord &tool) -{ - QString record = QString(); - qint64 basePointId = 0; - qint64 secondPointId = 0; - qint64 firstPointId = 0; - qint64 thirdPointId = 0; - qint64 p1Line1 = 0; - qint64 p2Line1 = 0; - qint64 p1Line2 = 0; - qint64 p2Line2 = 0; - qint64 center = 0; - QDomElement domElement; - switch ( tool.getTypeTool() ) - { - case Tool::ArrowTool: - break; - case Tool::SinglePointTool: - record = QString(tr("%1 - Base point")).arg(data->GetPoint(tool.getId()).name()); - break; - case Tool::EndLineTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = domElement.attribute("basePoint", "").toLongLong(); - } - record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(), - data->GetPoint(tool.getId()).name()); - break; - case Tool::LineTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - firstPointId = domElement.attribute("firstPoint", "").toLongLong(); - secondPointId = domElement.attribute("secondPoint", "").toLongLong(); - } - record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(), - data->GetPoint(secondPointId).name()); - break; - case Tool::AlongLineTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = domElement.attribute("firstPoint", "").toLongLong(); - secondPointId = domElement.attribute("secondPoint", "").toLongLong(); - } - record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(), - data->GetPoint(secondPointId).name(), - data->GetPoint(tool.getId()).name()); - break; - case Tool::ShoulderPointTool: - record = QString(tr("%1 - Point of soulder")).arg(data->GetPoint(tool.getId()).name()); - break; - case Tool::NormalTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = domElement.attribute("firstPoint", "").toLongLong(); - secondPointId = domElement.attribute("secondPoint", "").toLongLong(); - } - record = QString(tr("%3 - Normal to line %1_%2")).arg(data->GetPoint(basePointId).name(), - data->GetPoint(secondPointId).name(), - data->GetPoint(tool.getId()).name()); - break; - case Tool::BisectorTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - firstPointId = domElement.attribute("firstPoint", "").toLongLong(); - basePointId = domElement.attribute("secondPoint", "").toLongLong(); - thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); - } - record = QString(tr("%4 - Bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(), - data->GetPoint(basePointId).name(), - data->GetPoint(thirdPointId).name(), - data->GetPoint(tool.getId()).name()); - break; - case Tool::LineIntersectTool: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); - p2Line1 = domElement.attribute("p2Line1", "").toLongLong(); - p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); - p2Line2 = domElement.attribute("p2Line2", "").toLongLong(); - } - record = QString(tr("%5 - Point of intersection lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(), - data->GetPoint(p2Line1).name(), - data->GetPoint(p1Line2).name(), - data->GetPoint(p2Line2).name(), - data->GetPoint(tool.getId()).name()); - break; - case Tool::SplineTool: - { - VSpline spl = data->GetSpline(tool.getId()); - record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(), - data->GetPoint(spl.GetP4()).name()); - } - break; - case Tool::ArcTool: - { - VArc arc = data->GetArc(tool.getId()); - record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name()); - } - break; - case Tool::SplinePathTool: - { - VSplinePath splPath = data->GetSplinePath(tool.getId()); - QVector points = splPath.GetSplinePath(); - if (points.size() != 0 ) - { - record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name()); - for (qint32 i = 1; i< points.size(); ++i) - { - QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name()); - record.append(name); - } - } - } - break; - case Tool::PointOfContact: - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - center = domElement.attribute("center", "").toLongLong(); - firstPointId = domElement.attribute("firstPoint", "").toLongLong(); - secondPointId = domElement.attribute("secondPoint", "").toLongLong(); - } - record = QString(tr("%4 - Point of contact arc with center in point %1 and line %2_%3")).arg( - data->GetPoint(center).name(), data->GetPoint(firstPointId).name(), - data->GetPoint(secondPointId).name(), data->GetPoint(tool.getId()).name()); - break; - case Tool::Height: - { - qint64 p1LineId = 0; - qint64 p2LineId = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = domElement.attribute("basePoint", "").toLongLong(); - p1LineId = domElement.attribute("p1Line", "").toLongLong(); - p2LineId = domElement.attribute("p2Line", "").toLongLong(); - } - record = QString(tr("Point of perpendical from point %1 to line %2_%3")).arg( - data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(), - data->GetPoint(p2LineId).name()); - break; - } - case Tool::Triangle: - { - qint64 axisP1Id = 0; - qint64 axisP2Id = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - axisP1Id = domElement.attribute("axisP1", "").toLongLong(); - axisP2Id = domElement.attribute("axisP2", "").toLongLong(); - firstPointId = domElement.attribute("firstPoint", "").toLongLong(); - secondPointId = domElement.attribute("secondPoint", "").toLongLong(); - } - record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( - data->GetPoint(axisP1Id).name(), data->GetPoint(axisP2Id).name(), - data->GetPoint(firstPointId).name(), data->GetPoint(secondPointId).name()); - break; - } - default: - qWarning()<tableWidget->setSortingEnabled(false); - ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); - ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool"))); -} - -void DialogHistory::ShowPoint() -{ - QVector *history = doc->getHistory(); - if (history->size()>0) - { - QTableWidgetItem *item = ui->tableWidget->item(0, 1); - item->setSelected(true); - cursorToolRecordRow = 0; - item = ui->tableWidget->item(0, 0); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); - } -} - -void DialogHistory::closeEvent(QCloseEvent *event) -{ - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); - DialogTool::closeEvent(event); -} diff --git a/src/dialogs/dialogincrements.cpp b/src/dialogs/dialogincrements.cpp deleted file mode 100644 index 5a26b7848..000000000 --- a/src/dialogs/dialogincrements.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/************************************************************************ - ** - ** @file dialogincrements.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogincrements.h" -#include "ui_dialogincrements.h" -#include "../widgets/doubledelegate.h" -#include "../exception/vexception.h" - -#include - -DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) - :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0) -{ - ui->setupUi(this); - InitialStandartTable(); - InitialIncrementTable(); - InitialLinesTable(); - InitialSplinesTable(); - InitialArcsTable(); - DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement); - ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate); - ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate); - ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate); - FillStandartTable(); - FillIncrementTable(); - FillLengthLines(); - FillLengthSplines(); - FillLengthArcs(); - - connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::cellChanged); - connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd); - connect(ui->toolButtonRemove, &QPushButton::clicked, this, - &DialogIncrements::clickedToolButtonRemove); - - connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree); - connect(this, &DialogIncrements::haveLiteChange, this->doc, &VDomDocument::haveLiteChange); - connect(this->doc, &VDomDocument::FullUpdateFromFile, this, - &DialogIncrements::FullUpdateFromFile); - - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogIncrements::DialogAccepted); - ui->tabWidget->setCurrentIndex(0); -} - -void DialogIncrements::FillStandartTable() -{ - const QHash *standartTable = data->DataStandartTable(); - qint32 currentRow = -1; - QHashIterator i(*standartTable); - ui->tableWidgetStandart->setRowCount ( standartTable->size() ); - while (i.hasNext()) - { - i.next(); - VStandartTableRow cell = i.value(); - currentRow++; - - QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); - item->setTextAlignment(Qt::AlignHCenter); - item->setFont(QFont("Times", 12, QFont::Bold)); - ui->tableWidgetStandart->setItem(currentRow, 0, item); - - item = new QTableWidgetItem(QString().setNum(data->GetValueStandartTableCell(i.key()))); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetStandart->setItem(currentRow, 1, item); - - item = new QTableWidgetItem(QString().setNum(cell.GetBase())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetStandart->setItem(currentRow, 2, item); - - item = new QTableWidgetItem(QString().setNum(cell.GetKsize())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetStandart->setItem(currentRow, 3, item); - - item = new QTableWidgetItem(QString().setNum(cell.GetKgrowth())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetStandart->setItem(currentRow, 4, item); - - item = new QTableWidgetItem(cell.GetDescription()); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetStandart->setItem(currentRow, 5, item); - } - ui->tableWidgetStandart->resizeColumnsToContents(); - ui->tableWidgetStandart->resizeRowsToContents(); - ui->tableWidgetStandart->verticalHeader()->setDefaultSectionSize(20); -} - -void DialogIncrements::FillIncrementTable() -{ - const QHash *incrementTable = data->DataIncrementTable(); - QHashIterator i(*incrementTable); - QMap map; - //Sorting QHash by id - while (i.hasNext()) - { - i.next(); - VIncrementTableRow cell = i.value(); - map.insert(cell.getId(), i.key()); - } - - qint32 currentRow = -1; - QMapIterator iMap(map); - while (iMap.hasNext()) - { - iMap.next(); - VIncrementTableRow cell = incrementTable->value(iMap.value()); - currentRow++; - ui->tableWidgetIncrement->setRowCount ( incrementTable->size() ); - - QTableWidgetItem *item = new QTableWidgetItem(iMap.value()); - item->setTextAlignment(Qt::AlignHCenter); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setData(Qt::UserRole, cell.getId()); - ui->tableWidgetIncrement->setItem(currentRow, 0, item); - - item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value()))); - item->setTextAlignment(Qt::AlignHCenter); - // set the item non-editable (view only), and non-selectable - Qt::ItemFlags flags = item->flags(); - flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag - item->setFlags(flags); - ui->tableWidgetIncrement->setItem(currentRow, 1, item); - - item = new QTableWidgetItem(QString().setNum(cell.getBase())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 2, item); - - item = new QTableWidgetItem(QString().setNum(cell.getKsize())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 3, item); - - item = new QTableWidgetItem(QString().setNum(cell.getKgrowth())); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 4, item); - - item = new QTableWidgetItem(cell.getDescription()); - item->setTextAlignment(Qt::AlignLeft); - ui->tableWidgetIncrement->setItem(currentRow, 5, item); - } - if (ui->tableWidgetIncrement->rowCount()>0) - { - ui->toolButtonRemove->setEnabled(true); - } - ui->tableWidgetIncrement->resizeColumnsToContents(); - ui->tableWidgetIncrement->resizeRowsToContents(); - ui->tableWidgetIncrement->setCurrentCell( row, column ); -} - -void DialogIncrements::FillLengthLines() -{ - const QHash *linesTable = data->DataLengthLines(); - QHashIterator iHash(*linesTable); - QMap map; - //Sorting QHash by name - while (iHash.hasNext()) - { - iHash.next(); - map.insert(iHash.key(), iHash.value()); - } - - qint32 currentRow = -1; - QMapIterator i(map); - while (i.hasNext()) - { - i.next(); - qreal length = i.value(); - currentRow++; - ui->tableWidgetLines->setRowCount ( linesTable->size() ); - - QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); - item->setTextAlignment(Qt::AlignHCenter); - item->setFont(QFont("Times", 12, QFont::Bold)); - ui->tableWidgetLines->setItem(currentRow, 0, item); - - item = new QTableWidgetItem(QString().setNum(length)); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetLines->setItem(currentRow, 1, item); - } - ui->tableWidgetLines->resizeColumnsToContents(); - ui->tableWidgetLines->resizeRowsToContents(); - ui->tableWidgetLines->verticalHeader()->setDefaultSectionSize(20); -} - -void DialogIncrements::FillLengthSplines() -{ - const QHash *splinesTable = data->DataLengthSplines(); - QHashIterator iHash(*splinesTable); - QMap map; - //Sorting QHash by name - while (iHash.hasNext()) - { - iHash.next(); - map.insert(iHash.key(), iHash.value()); - } - - qint32 currentRow = -1; - QMapIterator i(map); - while (i.hasNext()) - { - i.next(); - qreal length = i.value(); - currentRow++; - ui->tableWidgetSplines->setRowCount ( splinesTable->size() ); - - QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); - item->setTextAlignment(Qt::AlignLeft); - item->setFont(QFont("Times", 12, QFont::Bold)); - ui->tableWidgetSplines->setItem(currentRow, 0, item); - - item = new QTableWidgetItem(QString().setNum(length)); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetSplines->setItem(currentRow, 1, item); - } - ui->tableWidgetSplines->resizeColumnsToContents(); - ui->tableWidgetSplines->resizeRowsToContents(); - ui->tableWidgetSplines->verticalHeader()->setDefaultSectionSize(20); -} - -void DialogIncrements::FillLengthArcs() -{ - const QHash *arcsTable = data->DataLengthArcs(); - QHashIterator iHash(*arcsTable); - QMap map; - //Sorting QHash by name - while (iHash.hasNext()) - { - iHash.next(); - map.insert(iHash.key(), iHash.value()); - } - - qint32 currentRow = -1; - QMapIterator i(map); - while (i.hasNext()) - { - i.next(); - qreal length = i.value(); - currentRow++; - ui->tableWidgetArcs->setRowCount ( arcsTable->size() ); - - QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); - item->setTextAlignment(Qt::AlignHCenter); - item->setFont(QFont("Times", 12, QFont::Bold)); - ui->tableWidgetArcs->setItem(currentRow, 0, item); - - item = new QTableWidgetItem(QString().setNum(length)); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetArcs->setItem(currentRow, 1, item); - } - ui->tableWidgetArcs->resizeColumnsToContents(); - ui->tableWidgetArcs->resizeRowsToContents(); - ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20); -} - -void DialogIncrements::FullUpdateFromFile() -{ - disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); - - ui->tableWidgetStandart->clear(); - InitialStandartTable(); - FillStandartTable(); - - ui->tableWidgetIncrement->clear(); - InitialIncrementTable(); - FillIncrementTable(); - - ui->tableWidgetLines->clear(); - InitialLinesTable(); - FillLengthLines(); - - ui->tableWidgetSplines->clear(); - InitialSplinesTable(); - FillLengthSplines(); - - ui->tableWidgetArcs->clear(); - InitialArcsTable(); - FillLengthArcs(); - - connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); -} - -void DialogIncrements::clickedToolButtonAdd() -{ - disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); - ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason); - qint32 currentRow = ui->tableWidgetIncrement->rowCount(); - ui->tableWidgetIncrement->insertRow( currentRow ); - - qint32 num = 1; - QString name; - do - { - name = QString(tr("Denotation %1")).arg(num); - num++; - } while (data->IncrementTableContains(name)); - - qint64 id = data->getNextId(); - qreal base = 0; - qreal ksize = 0; - qreal kgrowth = 0; - QString description = QString(tr("Description")); - VIncrementTableRow incrementRow = VIncrementTableRow(id, base, ksize, kgrowth, description); - data->AddIncrementTableRow(name, incrementRow); - - AddIncrementToFile(id, name, base, ksize, kgrowth, description); - - QTableWidgetItem *item = new QTableWidgetItem(name); - item->setTextAlignment(Qt::AlignHCenter); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setData(Qt::UserRole, id); - ui->tableWidgetIncrement->setItem(currentRow, 0, item); - ui->tableWidgetIncrement->setCurrentCell(currentRow, 0, QItemSelectionModel::ClearAndSelect); - - item = new QTableWidgetItem("0"); - item->setTextAlignment(Qt::AlignHCenter); - // set the item non-editable (view only), and non-selectable - Qt::ItemFlags flags = item->flags(); - flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag - item->setFlags(flags); - ui->tableWidgetIncrement->setItem(currentRow, 1, item); - - item = new QTableWidgetItem("0"); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 2, item); - - item = new QTableWidgetItem("0"); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 3, item); - - item = new QTableWidgetItem("0"); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 4, item); - - item = new QTableWidgetItem(tr("Description")); - item->setTextAlignment(Qt::AlignHCenter); - ui->tableWidgetIncrement->setItem(currentRow, 5, item); - - ui->toolButtonRemove->setEnabled(true); - connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); - emit haveLiteChange(); -} - -void DialogIncrements::clickedToolButtonRemove() -{ - disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); - QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem(); - qint32 row = item->row(); - QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0); - data->RemoveIncrementTableRow(itemName->text()); - qint64 id = qvariant_cast(item->data(Qt::UserRole)); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNodeList list = doc->elementsByTagName("increments"); - list.at(0).removeChild(domElement); - } - ui->tableWidgetIncrement->removeRow(row); - if (ui->tableWidgetIncrement->rowCount() == 0) - { - ui->toolButtonRemove->setEnabled(false); - } - connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, - &DialogIncrements::cellChanged); - emit haveLiteChange(); -} - -void DialogIncrements::AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth, - QString description) -{ - QDomNodeList list = doc->elementsByTagName("increments"); - QDomElement element = doc->createElement("increment"); - - QDomAttr drawAttr = doc->createAttribute("id"); - drawAttr.setValue(QString().setNum(id)); - element.setAttributeNode(drawAttr); - - drawAttr = doc->createAttribute("name"); - drawAttr.setValue(name); - element.setAttributeNode(drawAttr); - - drawAttr = doc->createAttribute("base"); - drawAttr.setValue(QString().setNum(base)); - element.setAttributeNode(drawAttr); - - drawAttr = doc->createAttribute("ksize"); - drawAttr.setValue(QString().setNum(ksize)); - element.setAttributeNode(drawAttr); - - drawAttr = doc->createAttribute("kgrowth"); - drawAttr.setValue(QString().setNum(kgrowth)); - element.setAttributeNode(drawAttr); - - drawAttr = doc->createAttribute("description"); - drawAttr.setValue(description); - element.setAttributeNode(drawAttr); - - list.at(0).appendChild(element); -} - -void DialogIncrements::cellChanged ( qint32 row, qint32 column ) -{ - QTableWidgetItem *item = 0; - QTableWidgetItem *itemName = 0; - qint64 id; - QDomElement domElement; - this->row = row; - switch (column) - { - case 0: - item = ui->tableWidgetIncrement->item(row, 0); - id = qvariant_cast(item->data(Qt::UserRole)); - domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute("name", item->text()); - data->ClearIncrementTable(); - this->column = 2; - emit FullUpdateTree(); - } - break; - case 2: - itemName = ui->tableWidgetIncrement->item(row, 0); - item = ui->tableWidgetIncrement->item(row, column); - id = qvariant_cast(itemName->data(Qt::UserRole)); - domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - bool ok = false; - qreal value = item->text().toDouble(&ok); - if (ok) - { - domElement.setAttribute("base", value); - this->column = 3; - emit FullUpdateTree(); - } - else - { - throw VException(tr("Can't convert toDouble value.")); - } - } - break; - case 3: - itemName = ui->tableWidgetIncrement->item(row, 0); - item = ui->tableWidgetIncrement->item(row, column); - id = qvariant_cast(itemName->data(Qt::UserRole)); - domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute("ksize", item->text().toDouble()); - this->column = 4; - emit FullUpdateTree(); - } - break; - case 4: - itemName = ui->tableWidgetIncrement->item(row, 0); - item = ui->tableWidgetIncrement->item(row, column); - id = qvariant_cast(itemName->data(Qt::UserRole)); - domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute("kgrowth", item->text().toDouble()); - this->column = 5; - emit FullUpdateTree(); - } - break; - case 5: - itemName = ui->tableWidgetIncrement->item(row, 0); - item = ui->tableWidgetIncrement->item(row, column); - id = qvariant_cast(itemName->data(Qt::UserRole)); - domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute("description", item->text()); - VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text()); - incr.setDescription(item->text()); - data->UpdateIncrementTableRow(itemName->text(), incr); - ui->tableWidgetIncrement->resizeColumnsToContents(); - ui->tableWidgetIncrement->resizeRowsToContents(); - ui->tableWidgetIncrement->setCurrentCell( row, 0 ); - emit haveLiteChange(); - } - break; - default: - break; - } -} - -void DialogIncrements::InitialStandartTable() -{ - ui->tableWidgetStandart->setSortingEnabled(false); - ui->tableWidgetStandart->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Base value"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth"))); - ui->tableWidgetStandart->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); -} - -void DialogIncrements::InitialIncrementTable() -{ - ui->tableWidgetIncrement->setSortingEnabled(false); - ui->tableWidgetIncrement->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Denotation"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Calculated value"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Base value"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("In size"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("In growth"))); - ui->tableWidgetIncrement->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Description"))); - ui->tableWidgetIncrement->verticalHeader()->setDefaultSectionSize(20); -} - -void DialogIncrements::InitialLinesTable() -{ - ui->tableWidgetLines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Line"))); - ui->tableWidgetLines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); -} - -void DialogIncrements::InitialSplinesTable() -{ - ui->tableWidgetSplines->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Curve"))); - ui->tableWidgetSplines->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); -} - -void DialogIncrements::InitialArcsTable() -{ - ui->tableWidgetArcs->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Arc"))); - ui->tableWidgetArcs->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Length"))); -} - -void DialogIncrements::DialogAccepted() -{ - emit DialogClosed(QDialog::Accepted); -} - -DialogIncrements::~DialogIncrements() -{ - delete ui; -} diff --git a/src/dialogs/dialogincrements.h b/src/dialogs/dialogincrements.h deleted file mode 100644 index d5c1e895e..000000000 --- a/src/dialogs/dialogincrements.h +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************ - ** - ** @file dialogincrements.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGINCREMENTS_H -#define DIALOGINCREMENTS_H - -#include "dialogtool.h" -#include "../xml/vdomdocument.h" - -namespace Ui -{ - class DialogIncrements; -} - -/** - * @brief The DialogIncrements class show dialog increments. Tables of all variables in program will be here. - */ -class DialogIncrements : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogIncrements create dialog - * @param data container with data - * @param doc dom document container - * @param parent parent widget - */ - DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0); - ~DialogIncrements(); -public slots: - /** - * @brief clickedToolButtonAdd create new row in table - */ - void clickedToolButtonAdd(); - /** - * @brief clickedToolButtonRemove remove one row from table - */ - void clickedToolButtonRemove(); - /** - * @brief cellChanged cell in table was changed - * @param row number of row - * @param column number of column - */ - void cellChanged ( qint32 row, qint32 column ); - /** - * @brief FullUpdateFromFile update information in tables form file - */ - void FullUpdateFromFile(); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -signals: - /** - * @brief FullUpdateTree signal update data for dom document - */ - void FullUpdateTree(); - /** - * @brief haveLiteChange signal show sign of change - */ - void haveLiteChange(); -private: - Q_DISABLE_COPY(DialogIncrements) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogIncrements *ui; - /** - * @brief data container with data - */ - VContainer *data; // need because we must change data - /** - * @brief doc dom document container - */ - VDomDocument *doc; - /** - * @brief row save number of row current selected cell - */ - qint32 row; - /** - * @brief column save number of column current selected cell - */ - qint32 column; - /** - * @brief InitialStandartTable initial option standart table - */ - void InitialStandartTable(); - /** - * @brief InitialIncrementTable initial option increment table - */ - void InitialIncrementTable(); - /** - * @brief InitialLinesTable initial option lines table - */ - void InitialLinesTable(); - /** - * @brief InitialSplinesTable initial option splines table - */ - void InitialSplinesTable(); - /** - * @brief InitialArcsTable initial option arcs table - */ - void InitialArcsTable(); - /** - * @brief FillStandartTable fill data for standart table - */ - void FillStandartTable(); - /** - * @brief FillIncrementTable fill data for increment table - */ - void FillIncrementTable(); - /** - * @brief FillLengthLines fill data for table of lines lengths - */ - void FillLengthLines(); - /** - * @brief FillLengthSplines fill data for table of splines lengths - */ - void FillLengthSplines(); - /** - * @brief FillLengthArcs fill data for table of arcs lengths - */ - void FillLengthArcs(); - /** - * @brief AddIncrementToFile save created increment to file - * @param id id of increment - * @param name name - * @param base base value - * @param ksize increment in sizes - * @param kgrowth increment in growths - * @param description description of increment - */ - void AddIncrementToFile(qint64 id, QString name, qreal base, qreal ksize, qreal kgrowth, - QString description); -}; - -#endif // DIALOGINCREMENTS_H diff --git a/src/dialogs/dialogincrements.ui b/src/dialogs/dialogincrements.ui deleted file mode 100644 index 74203d5cc..000000000 --- a/src/dialogs/dialogincrements.ui +++ /dev/null @@ -1,395 +0,0 @@ - - - DialogIncrements - - - - 0 - 0 - 681 - 422 - - - - Increments - - - - :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - - - - - - - QTabWidget::North - - - 1 - - - - Table sizes - - - - - - true - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - 95 - - - 25 - - - false - - - true - - - false - - - 45 - - - 8 - - - - Denotation - - - - - The calculated value - - - - - Base value - - - - - In sizes - - - - - In growths - - - - - Description - - - - - - - - - Increments - - - - - - true - - - QAbstractItemView::SingleSelection - - - false - - - true - - - false - - - 95 - - - 17 - - - false - - - true - - - false - - - false - - - 45 - - - false - - - - Denotation - - - - - The calculated value - - - - - Base value - - - - - In size - - - - - In growth - - - - - Description - - - - - - - - ... - - - - - - - - - - - - false - - - ... - - - - - - - - - - - - - Lines - - - - - - QAbstractItemView::NoEditTriggers - - - false - - - 137 - - - false - - - false - - - - Line - - - - - Length of the line - - - - - - - - - Curves - - - - - - QAbstractItemView::NoEditTriggers - - - false - - - 137 - - - false - - - false - - - - Curve - - - - - Length of the curve - - - - - - - - - Arcs - - - - - - QAbstractItemView::NoEditTriggers - - - false - - - 137 - - - false - - - false - - - - Arc - - - - - Length of arc - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - false - - - - - - - tabWidget - tableWidgetStandart - tableWidgetIncrement - toolButtonAdd - toolButtonRemove - tableWidgetLines - tableWidgetSplines - tableWidgetArcs - buttonBox - - - - - - - buttonBox - accepted() - DialogIncrements - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DialogIncrements - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/dialogs/dialogline.cpp b/src/dialogs/dialogline.cpp deleted file mode 100644 index bfb438486..000000000 --- a/src/dialogs/dialogline.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************ - ** - ** @file dialogline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogline.h" -#include "ui_dialogline.h" - -#include - -DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0) -{ - ui->setupUi(this); - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); - number = 0; -} - -DialogLine::~DialogLine() -{ - delete ui; -} - -void DialogLine::setSecondPoint(const qint64 &value) -{ - secondPoint = value; - VPointF point = data->GetPoint(value); - qint32 index = ui->comboBoxSecondPoint->findText(point.name()); - if (index != -1) - { - ui->comboBoxSecondPoint->setCurrentIndex(index); - } -} - -void DialogLine::setFirstPoint(const qint64 &value) -{ - firstPoint = value; - VPointF point = data->GetPoint(value); - qint32 index = ui->comboBoxFirstPoint->findText(point.name()); - if (index != -1) - { - ui->comboBoxFirstPoint->setCurrentIndex(index); - } -} - - -void DialogLine::DialogAccepted() -{ - qint32 index = ui->comboBoxFirstPoint->currentIndex(); - firstPoint = qvariant_cast(ui->comboBoxFirstPoint->itemData(index)); - index = ui->comboBoxSecondPoint->currentIndex(); - secondPoint = qvariant_cast(ui->comboBoxSecondPoint->itemData(index)); - DialogClosed(QDialog::Accepted); -} - -void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(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 second point")); - 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(); - } - } - } -} diff --git a/src/dialogs/dialogline.h b/src/dialogs/dialogline.h deleted file mode 100644 index 74194b6fd..000000000 --- a/src/dialogs/dialogline.h +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************ - ** - ** @file dialogline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGLINE_H -#define DIALOGLINE_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogLine; -} - -/** - * @brief The DialogLine class dialog for ToolLine. Help create line and edit option. - */ -class DialogLine : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogLine create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogLine(); - /** - * @brief getFirstPoint return id first point - * @return id - */ - inline qint64 getFirstPoint() const {return firstPoint;} - /** - * @brief setFirstPoint set id first point - * @param value id - */ - void setFirstPoint(const qint64 &value); - /** - * @brief getSecondPoint return id second point - * @return id - */ - inline qint64 getSecondPoint() const {return secondPoint;} - /** - * @brief setSecondPoint set id second point - * @param value id - */ - void setSecondPoint(const qint64 &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogLine) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogLine *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief firstPoint id first point - */ - qint64 firstPoint; - /** - * @brief secondPoint id second point - */ - qint64 secondPoint; -}; - -#endif // DIALOGLINE_H diff --git a/src/dialogs/dialoglineintersect.cpp b/src/dialogs/dialoglineintersect.cpp deleted file mode 100644 index 1a96777c5..000000000 --- a/src/dialogs/dialoglineintersect.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/************************************************************************ - ** - ** @file dialoglineintersect.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialoglineintersect.h" -#include "ui_dialoglineintersect.h" - -#include - -DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), - p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true) -{ - ui->setupUi(this); - number = 0; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogLineIntersect::DialogAccepted); - labelEditNamePoint = ui->labelEditNamePoint; - flagName = false; - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogLineIntersect::DialogRejected); - FillComboBoxPoints(ui->comboBoxP1Line1); - FillComboBoxPoints(ui->comboBoxP2Line1); - FillComboBoxPoints(ui->comboBoxP1Line2); - FillComboBoxPoints(ui->comboBoxP2Line2); - - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); -} - -DialogLineIntersect::~DialogLineIntersect() -{ - delete ui; -} - -void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - if (number == 0) - { - qint32 index = ui->comboBoxP1Line1->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line1->setCurrentIndex(index); - p1Line1 = id; - number++; - emit ToolTip(tr("Select second point of first line")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP2Line1->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line1->setCurrentIndex(index); - p2Line1 = id; - number++; - emit ToolTip(tr("Select first point of second line")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxP1Line2->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line2->setCurrentIndex(index); - p1Line2 = id; - number++; - emit ToolTip(tr("Select second point of second line")); - return; - } - } - if (number == 3) - { - qint32 index = ui->comboBoxP2Line2->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line2->setCurrentIndex(index); - p2Line2 = id; - number = 0; - emit ToolTip(""); - } - if (isInitialized == false) - { - flagPoint = CheckIntersecion(); - CheckState(); - this->show(); - connect(ui->comboBoxP1Line1, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line1Changed); - connect(ui->comboBoxP2Line1, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line1Changed); - connect(ui->comboBoxP1Line2, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line2Changed); - connect(ui->comboBoxP2Line2, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line2Changed); - } - } - } -} - -void DialogLineIntersect::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - p1Line1 = getCurrentPointId(ui->comboBoxP1Line1); - p2Line1 = getCurrentPointId(ui->comboBoxP2Line1); - p1Line2 = getCurrentPointId(ui->comboBoxP1Line2); - p2Line2 = getCurrentPointId(ui->comboBoxP2Line2); - emit DialogClosed(QDialog::Accepted); -} - -void DialogLineIntersect::P1Line1Changed( int index) -{ - p1Line1 = qvariant_cast(ui->comboBoxP1Line1->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); -} - -void DialogLineIntersect::P2Line1Changed(int index) -{ - p2Line1 = qvariant_cast(ui->comboBoxP2Line1->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); -} - -void DialogLineIntersect::P1Line2Changed(int index) -{ - p1Line2 = qvariant_cast(ui->comboBoxP1Line2->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); -} - -void DialogLineIntersect::P2Line2Changed(int index) -{ - p2Line2 = qvariant_cast(ui->comboBoxP2Line2->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); -} - -void DialogLineIntersect::CheckState() -{ - Q_ASSERT(bOk != 0); - bOk->setEnabled(flagName && flagPoint); -} - -bool DialogLineIntersect::CheckIntersecion() -{ - VPointF p1L1 = data->GetPoint(p1Line1); - VPointF p2L1 = data->GetPoint(p2Line1); - VPointF p1L2 = data->GetPoint(p1Line2); - VPointF p2L2 = data->GetPoint(p2Line2); - - QLineF line1(p1L1.toQPointF(), p2L1.toQPointF()); - QLineF line2(p1L2.toQPointF(), p2L2.toQPointF()); - QPointF fPoint; - QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); - if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) - { - return true; - } - else - { - return false; - } -} - -void DialogLineIntersect::setP2Line2(const qint64 &value) -{ - p2Line2 = value; - ChangeCurrentData(ui->comboBoxP2Line2, value); -} - -void DialogLineIntersect::setP1Line2(const qint64 &value) -{ - p1Line2 = value; - ChangeCurrentData(ui->comboBoxP1Line2, value); -} - -void DialogLineIntersect::setP2Line1(const qint64 &value) -{ - p2Line1 = value; - ChangeCurrentData(ui->comboBoxP2Line1, value); -} - -void DialogLineIntersect::setP1Line1(const qint64 &value) -{ - p1Line1 = value; - ChangeCurrentData(ui->comboBoxP1Line1, value); -} - -void DialogLineIntersect::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} diff --git a/src/dialogs/dialoglineintersect.h b/src/dialogs/dialoglineintersect.h deleted file mode 100644 index 8fbbb410b..000000000 --- a/src/dialogs/dialoglineintersect.h +++ /dev/null @@ -1,181 +0,0 @@ -/************************************************************************ - ** - ** @file dialoglineintersect.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGLINEINTERSECT_H -#define DIALOGLINEINTERSECT_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogLineIntersect; -} - -/** - * @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option. - */ -class DialogLineIntersect : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogLineIntersect create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogLineIntersect(); - /** - * @brief getP1Line1 return id first point of first line - * @return id - */ - inline qint64 getP1Line1() const {return p1Line1;} - /** - * @brief setP1Line1 set id first point of first line - * @param value id - */ - void setP1Line1(const qint64 &value); - /** - * @brief getP2Line1 return id second point of first line - * @return id - */ - inline qint64 getP2Line1() const {return p2Line1;} - /** - * @brief setP2Line1 set id second point of first line - * @param value id - */ - void setP2Line1(const qint64 &value); - /** - * @brief getP1Line2 return id first point of second line - * @return id - */ - inline qint64 getP1Line2() const {return p1Line2;} - /** - * @brief setP1Line2 set id first point of second line - * @param value id - */ - void setP1Line2(const qint64 &value); - /** - * @brief getP2Line2 return id second point of second line - * @return id - */ - inline qint64 getP2Line2() const {return p2Line2;} - /** - * @brief setP2Line2 set id second point of second line - * @param value id - */ - void setP2Line2(const qint64 &value); - /** - * @brief getPointName return name of point - * @return - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value - */ - void setPointName(const QString &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); - /** - * @brief P1Line1Changed changed first point of first line - * @param index index in list - */ - void P1Line1Changed( int index); - /** - * @brief P2Line1Changed changed second point of first line - * @param index index in list - */ - void P2Line1Changed( int index); - /** - * @brief P1Line2Changed changed first point of second line - * @param index index in list - */ - void P1Line2Changed( int index); - /** - * @brief P2Line2Changed changed second point of second line - * @param index index in list - */ - void P2Line2Changed( int index); -private: - Q_DISABLE_COPY(DialogLineIntersect) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogLineIntersect *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief p1Line1 id first point of first line - */ - qint64 p1Line1; - /** - * @brief p2Line1 id second point of first line - */ - qint64 p2Line1; - /** - * @brief p1Line2 id first point of second line - */ - qint64 p1Line2; - /** - * @brief p2Line2 id second point of second line - */ - qint64 p2Line2; - /** - * @brief flagPoint keep state of point - */ - bool flagPoint; - /** - * @brief CheckState check state of dialog. Enable or disable button ok. - */ - virtual void CheckState(); - /** - * @brief CheckIntersecion check intersection of points - * @return true - line have intersection, false = don't have - */ - bool CheckIntersecion(); -}; - -#endif // DIALOGLINEINTERSECT_H diff --git a/src/dialogs/dialognormal.cpp b/src/dialogs/dialognormal.cpp deleted file mode 100644 index 84e10f4eb..000000000 --- a/src/dialogs/dialognormal.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************************ - ** - ** @file dialognormal.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialognormal.h" -#include "ui_dialognormal.h" - -#include - -DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0) -{ - ui->setupUi(this); - spinBoxAngle = ui->doubleSpinBoxAngle; - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; - labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = false; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogNormal::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); - FillComboBoxTypeLine(ui->comboBoxLineType); - - connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, - &DialogNormal::ArrowDown); - connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, - &DialogNormal::ArrowUp); - connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, - &DialogNormal::ArrowLeft); - connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, - &DialogNormal::ArrowRight); - connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, - &DialogNormal::ArrowLeftUp); - connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, - &DialogNormal::ArrowLeftDown); - connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, - &DialogNormal::ArrowRightUp); - connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, - &DialogNormal::ArrowRightDown); - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogNormal::PutHere); - connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogNormal::PutVal); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogNormal::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogNormal::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogNormal::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogNormal::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogNormal::LengthLines); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogNormal::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogNormal::LengthCurves); - connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula); - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged); -} - -DialogNormal::~DialogNormal() -{ - delete ui; -} - -void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(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 second point of line")); - 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 DialogNormal::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->lineEditFormula->text(); - angle = ui->doubleSpinBoxAngle->value(); - firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); - secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); - emit DialogClosed(QDialog::Accepted); -} - -void DialogNormal::setSecondPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); -} - -void DialogNormal::setFirstPointId(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); -} - -void DialogNormal::setAngle(const qreal &value) -{ - angle = value; - ui->doubleSpinBoxAngle->setValue(angle); -} - -void DialogNormal::setFormula(const QString &value) -{ - formula = value; - ui->lineEditFormula->setText(formula); -} - -void DialogNormal::setTypeLine(const QString &value) -{ - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); -} - -void DialogNormal::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} diff --git a/src/dialogs/dialognormal.h b/src/dialogs/dialognormal.h deleted file mode 100644 index 4d8e97d56..000000000 --- a/src/dialogs/dialognormal.h +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************************ - ** - ** @file dialognormal.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGNORMAL_H -#define DIALOGNORMAL_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogNormal; -} - -/** - * @brief The DialogNormal class dialog for ToolNormal. Help create point and edit option. - */ -class DialogNormal : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogNormal create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogNormal(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const{return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getFormula return string of formula - * @return formula - */ - inline QString getFormula() const {return formula;} - /** - * @brief setFormula set string of formula - * @param value formula - */ - void setFormula(const QString &value); - /** - * @brief getAngle return aditional angle of normal - * @return angle in degree - */ - inline qreal getAngle() const {return angle;} - /** - * @brief setAngle set aditional angle of normal - * @param value angle in degree - */ - void setAngle(const qreal &value); - /** - * @brief getFirstPointId return id of first point - * @return id - */ - inline qint64 getFirstPointId() const {return firstPointId;} - /** - * @brief setFirstPointId set id of first point - * @param value id - * @param id don't show this id in list - */ - void setFirstPointId(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPointId return id of second point - * @return id - */ - inline qint64 getSecondPointId() const {return secondPointId;} - /** - * @brief setSecondPointId set id of second point - * @param value id - * @param id don't show this id in list - */ - void setSecondPointId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogNormal) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogNormal *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief formula formula - */ - QString formula; - /** - * @brief angle aditional angle of normal - */ - qreal angle; - /** - * @brief firstPointId id first point of line - */ - qint64 firstPointId; - /** - * @brief secondPointId id second point of line - */ - qint64 secondPointId; -}; - -#endif // DIALOGNORMAL_H diff --git a/src/dialogs/dialogpointofcontact.cpp b/src/dialogs/dialogpointofcontact.cpp deleted file mode 100644 index 864f727e7..000000000 --- a/src/dialogs/dialogpointofcontact.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpointofcontact.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogpointofcontact.h" - -#include - -DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0), - firstPoint(0), secondPoint(0) -{ - ui.setupUi(this); - listWidget = ui.listWidget; - labelResultCalculation = ui.labelResultCalculation; - labelDescription = ui.labelDescription; - radioButtonSizeGrowth = ui.radioButtonSizeGrowth; - radioButtonStandartTable = ui.radioButtonStandartTable; - radioButtonIncrements = ui.radioButtonIncrements; - radioButtonLengthLine = ui.radioButtonLengthLine; - radioButtonLengthArc = ui.radioButtonLengthArc; - radioButtonLengthCurve = ui.radioButtonLengthSpline; - lineEditFormula = ui.lineEditFormula; - labelEditFormula = ui.labelEditFormula; - labelEditNamePoint = ui.labelEditNamePoint; - flagFormula = false; - bOk = ui.buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogPointOfContact::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected); - FillComboBoxPoints(ui.comboBoxCenter); - FillComboBoxPoints(ui.comboBoxFirstPoint); - FillComboBoxPoints(ui.comboBoxSecondPoint); - - connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); - connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); - connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeGrowth); - connect(ui.radioButtonStandartTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandartTable); - connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); - connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); - connect(ui.radioButtonLengthArc, &QRadioButton::clicked, this, &DialogPointOfContact::LengthArcs); - connect(ui.radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogPointOfContact::LengthCurves); - connect(ui.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula); - connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); - connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); -} - -void DialogPointOfContact::ChoosedObject(qint64 id, 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->GetPointModeling(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 second point of line")); - return; - } - } - if (number == 1) - { - qint32 index = ui.comboBoxSecondPoint->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui.comboBoxSecondPoint->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select point of center of arc")); - return; - } - } - if (number == 2) - { - qint32 index = ui.comboBoxCenter->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui.comboBoxCenter->setCurrentIndex(index); - number = 0; - emit ToolTip(""); - } - if (isInitialized == false) - { - this->show(); - } - } - } -} - -void DialogPointOfContact::DialogAccepted() -{ - pointName = ui.lineEditNamePoint->text(); - radius = ui.lineEditFormula->text(); - center = getCurrentPointId(ui.comboBoxCenter); - firstPoint = getCurrentPointId(ui.comboBoxFirstPoint); - secondPoint = getCurrentPointId(ui.comboBoxSecondPoint); - emit DialogClosed(QDialog::Accepted); -} - -void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id); -} - -void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id); -} - -void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui.comboBoxCenter, center, value, id); - center = value; -} - -void DialogPointOfContact::setRadius(const QString &value) -{ - radius = value; - ui.lineEditFormula->setText(radius); -} - -void DialogPointOfContact::setPointName(const QString &value) -{ - pointName = value; - ui.lineEditNamePoint->setText(pointName); -} diff --git a/src/dialogs/dialogpointofcontact.h b/src/dialogs/dialogpointofcontact.h deleted file mode 100644 index c8076c74a..000000000 --- a/src/dialogs/dialogpointofcontact.h +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpointofcontact.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGPOINTOFCONTACT_H -#define DIALOGPOINTOFCONTACT_H - -#include "ui_dialogpointofcontact.h" -#include "dialogtool.h" - -/** - * @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option. - */ -class DialogPointOfContact : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogPointOfContact create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getRadius return formula radius of arc - * @return formula - */ - inline QString getRadius() const {return radius;} - /** - * @brief setRadius set formula radius of arc - * @param value formula - */ - void setRadius(const QString &value); - /** - * @brief GetCenter return id of center point - * @return id - */ - inline qint64 getCenter() const {return center;} - /** - * @brief SetCenter set id of center point - * @param value id - * @param id don't show this id in list. - */ - void setCenter(const qint64 &value, const qint64 &id); - /** - * @brief getFirstPoint return id first point - * @return id - */ - inline qint64 getFirstPoint() const {return firstPoint;} - /** - * @brief setFirstPoint set id first point - * @param value id - * @param id don't show this id in list. - */ - void setFirstPoint(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPoint return id second point - * @return id - */ - inline qint64 getSecondPoint() const {return secondPoint;} - /** - * @brief setSecondPoint set id second point - * @param value id - * @param id don't show this id in list. - */ - void setSecondPoint(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogPointOfContact) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogPointOfContact ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief radius radius of arc - */ - QString radius; - /** - * @brief center id center point of arc - */ - qint64 center; - /** - * @brief firstPoint id first point of line - */ - qint64 firstPoint; - /** - * @brief secondPoint id second point of line - */ - qint64 secondPoint; -}; - -#endif // DIALOGPOINTOFCONTACT_H diff --git a/src/dialogs/dialogpointofintersection.cpp b/src/dialogs/dialogpointofintersection.cpp deleted file mode 100644 index 3d14e2f3a..000000000 --- a/src/dialogs/dialogpointofintersection.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpointofintersection.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogpointofintersection.h" -#include "ui_dialogpointofintersection.h" - -#include - -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->GetPointModeling(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); -} diff --git a/src/dialogs/dialogpointofintersection.h b/src/dialogs/dialogpointofintersection.h deleted file mode 100644 index 3c4041153..000000000 --- a/src/dialogs/dialogpointofintersection.h +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpointofintersection.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGPOINTOFINTERSECTION_H -#define DIALOGPOINTOFINTERSECTION_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogPointOfIntersection; -} - -/** - * @brief The DialogPointOfIntersection class dialog for ToolPointOfIntersection. Help create point and edit option. - */ -class DialogPointOfIntersection : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogPointOfIntersection create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogPointOfIntersection(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getFirstPointId return id of first point - * @return id - */ - inline qint64 getFirstPointId() const {return firstPointId;} - /** - * @brief setFirstPointId set id of first point - * @param value id - * @param id don't show this id in list. - */ - void setFirstPointId(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPointId return id of second point - * @return id - */ - inline qint64 getSecondPointId() const {return secondPointId;} - /** - * @brief setSecondPointId set id of second point - * @param value id - * @param id don't show this id in list. - */ - void setSecondPointId(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogPointOfIntersection) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogPointOfIntersection *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief firstPointId id first point of line - */ - qint64 firstPointId; - /** - * @brief secondPointId id second point of line - */ - qint64 secondPointId; -}; - -#endif // DIALOGPOINTOFINTERSECTION_H diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri deleted file mode 100644 index e6898dd39..000000000 --- a/src/dialogs/dialogs.pri +++ /dev/null @@ -1,62 +0,0 @@ -HEADERS += \ - src/dialogs/dialogtriangle.h \ - src/dialogs/dialogtool.h \ - src/dialogs/dialogsplinepath.h \ - src/dialogs/dialogspline.h \ - src/dialogs/dialogsinglepoint.h \ - src/dialogs/dialogshoulderpoint.h \ - src/dialogs/dialogs.h \ - src/dialogs/dialogpointofintersection.h \ - src/dialogs/dialogpointofcontact.h \ - src/dialogs/dialognormal.h \ - src/dialogs/dialoglineintersect.h \ - src/dialogs/dialogline.h \ - src/dialogs/dialogincrements.h \ - src/dialogs/dialoghistory.h \ - src/dialogs/dialogheight.h \ - src/dialogs/dialogendline.h \ - src/dialogs/dialogdetail.h \ - src/dialogs/dialogbisector.h \ - src/dialogs/dialogarc.h \ - src/dialogs/dialogalongline.h - -SOURCES += \ - src/dialogs/dialogtriangle.cpp \ - src/dialogs/dialogtool.cpp \ - src/dialogs/dialogsplinepath.cpp \ - src/dialogs/dialogspline.cpp \ - src/dialogs/dialogsinglepoint.cpp \ - src/dialogs/dialogshoulderpoint.cpp \ - src/dialogs/dialogpointofintersection.cpp \ - src/dialogs/dialogpointofcontact.cpp \ - src/dialogs/dialognormal.cpp \ - src/dialogs/dialoglineintersect.cpp \ - src/dialogs/dialogline.cpp \ - src/dialogs/dialogincrements.cpp \ - src/dialogs/dialoghistory.cpp \ - src/dialogs/dialogheight.cpp \ - src/dialogs/dialogendline.cpp \ - src/dialogs/dialogdetail.cpp \ - src/dialogs/dialogbisector.cpp \ - src/dialogs/dialogarc.cpp \ - src/dialogs/dialogalongline.cpp - -FORMS += \ - src/dialogs/dialogtriangle.ui \ - src/dialogs/dialogsplinepath.ui \ - src/dialogs/dialogspline.ui \ - src/dialogs/dialogsinglepoint.ui \ - src/dialogs/dialogshoulderpoint.ui \ - src/dialogs/dialogpointofintersection.ui \ - src/dialogs/dialogpointofcontact.ui \ - src/dialogs/dialognormal.ui \ - src/dialogs/dialoglineintersect.ui \ - src/dialogs/dialogline.ui \ - src/dialogs/dialogincrements.ui \ - src/dialogs/dialoghistory.ui \ - src/dialogs/dialogheight.ui \ - src/dialogs/dialogendline.ui \ - src/dialogs/dialogdetail.ui \ - src/dialogs/dialogbisector.ui \ - src/dialogs/dialogarc.ui \ - src/dialogs/dialogalongline.ui diff --git a/src/dialogs/dialogshoulderpoint.cpp b/src/dialogs/dialogshoulderpoint.cpp deleted file mode 100644 index 8b7bea2a1..000000000 --- a/src/dialogs/dialogshoulderpoint.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/************************************************************************ - ** - ** @file dialogshoulderpoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogshoulderpoint.h" -#include "ui_dialogshoulderpoint.h" - -#include - -DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0) -{ - ui->setupUi(this); - number = 0; - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandartTable = ui->radioButtonStandartTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; - labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = false; - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogShoulderPoint::DialogAccepted); - flagName = false; - CheckState(); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected); - FillComboBoxTypeLine(ui->comboBoxLineType); - FillComboBoxPoints(ui->comboBoxP1Line); - FillComboBoxPoints(ui->comboBoxP2Line); - FillComboBoxPoints(ui->comboBoxPShoulder); - - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); - connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogShoulderPoint::ValChenged); - - ShowVariable(data->DataBase()); - connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogShoulderPoint::SizeGrowth); - connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogShoulderPoint::StandartTable); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogShoulderPoint::Increments); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthLines); - connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthArcs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthCurves); - connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogShoulderPoint::EvalFormula); - connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged); -} - -DialogShoulderPoint::~DialogShoulderPoint() -{ - delete ui; -} - -void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - if (number == 0) - { - qint32 index = ui->comboBoxP1Line->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select second point of line")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP2Line->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select point of shoulder")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxPShoulder->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxPShoulder->setCurrentIndex(index); - number = 0; - emit ToolTip(""); - } - if (isInitialized == false) - { - this->show(); - } - } - } -} - -void DialogShoulderPoint::DialogAccepted() -{ - pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - formula = ui->lineEditFormula->text(); - p1Line = getCurrentPointId(ui->comboBoxP1Line); - p2Line = getCurrentPointId(ui->comboBoxP2Line); - pShoulder = getCurrentPointId(ui->comboBoxPShoulder); - emit DialogClosed(QDialog::Accepted); -} - -void DialogShoulderPoint::setPShoulder(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxPShoulder, pShoulder, value, id); -} - -void DialogShoulderPoint::setP2Line(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxP2Line, p2Line, value, id); -} - -void DialogShoulderPoint::setP1Line(const qint64 &value, const qint64 &id) -{ - setCurrentPointId(ui->comboBoxP1Line, p1Line, value, id); -} - -void DialogShoulderPoint::setFormula(const QString &value) -{ - formula = value; - ui->lineEditFormula->setText(formula); -} - -void DialogShoulderPoint::setTypeLine(const QString &value) -{ - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); -} - -void DialogShoulderPoint::setPointName(const QString &value) -{ - pointName = value; - ui->lineEditNamePoint->setText(pointName); -} diff --git a/src/dialogs/dialogshoulderpoint.h b/src/dialogs/dialogshoulderpoint.h deleted file mode 100644 index ce01f3235..000000000 --- a/src/dialogs/dialogshoulderpoint.h +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************ - ** - ** @file dialogshoulderpoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGSHOULDERPOINT_H -#define DIALOGSHOULDERPOINT_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogShoulderPoint; -} - -/** - * @brief The DialogShoulderPoint class dialog for ToolShoulderPoint. Help create point and edit option. - */ -class DialogShoulderPoint : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogShoulderPoint create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogShoulderPoint(); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); - /** - * @brief getTypeLine return type of line - * @return type - */ - inline QString getTypeLine() const {return typeLine;} - /** - * @brief setTypeLine set type of line - * @param value type - */ - void setTypeLine(const QString &value); - /** - * @brief getFormula return string of formula - * @return formula - */ - inline QString getFormula() const {return formula;} - /** - * @brief setFormula set string of formula - * @param value formula - */ - void setFormula(const QString &value); - /** - * @brief getP1Line return id first point of line - * @return id - */ - inline qint64 getP1Line() const {return p1Line;} - /** - * @brief setP1Line set id first point of line - * @param value id - * @param id don't show this id in list - */ - void setP1Line(const qint64 &value, const qint64 &id); - /** - * @brief getP2Line return id second point of line - * @return id - */ - inline qint64 getP2Line() const {return p2Line;} - /** - * @brief setP2Line set id second point of line - * @param value id - * @param id don't show this id in list - */ - void setP2Line(const qint64 &value, const qint64 &id); - /** - * @brief getPShoulder return id shoulder point - * @return id - */ - inline qint64 getPShoulder() const {return pShoulder;} - /** - * @brief setPShoulder set id shoulder point - * @param value id - * @param id don't show this id in list - */ - void setPShoulder(const qint64 &value, const qint64 &id); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogShoulderPoint) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogShoulderPoint *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief typeLine type of line - */ - QString typeLine; - /** - * @brief formula formula - */ - QString formula; - /** - * @brief p1Line id first point of line - */ - qint64 p1Line; - /** - * @brief p2Line id second point of line - */ - qint64 p2Line; - /** - * @brief pShoulder id shoulder point - */ - qint64 pShoulder; -}; - -#endif // DIALOGSHOULDERPOINT_H diff --git a/src/dialogs/dialogsinglepoint.cpp b/src/dialogs/dialogsinglepoint.cpp deleted file mode 100644 index 01858fa6d..000000000 --- a/src/dialogs/dialogsinglepoint.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************ - ** - ** @file dialogsinglepoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogsinglepoint.h" -#include "ui_dialogsinglepoint.h" - -#include - -DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) - :DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()), - point(QPointF()) -{ - ui->setupUi(this); - ui->doubleSpinBoxX->setRange(0, toMM(PaperSize)); - ui->doubleSpinBoxY->setRange(0, toMM(PaperSize)); - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - labelEditNamePoint = ui->labelEditName; - flagName = false; - CheckState(); - connect(bOk, &QPushButton::clicked, this, &DialogSinglePoint::DialogAccepted); - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogSinglePoint::DialogRejected); - connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NamePointChanged); -} - -void DialogSinglePoint::mousePress(const QPointF &scenePos) -{ - if (isInitialized == false) - { - ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); - ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); - this->show(); - } - else - { - ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); - ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); - } -} - -void DialogSinglePoint::DialogAccepted() -{ - point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value())); - name = ui->lineEditName->text(); - emit DialogClosed(QDialog::Accepted); -} - -void DialogSinglePoint::setData(const QString &name, const QPointF &point) -{ - this->name = name; - this->point = point; - isInitialized = true; - ui->lineEditName->setText(name); - ui->doubleSpinBoxX->setValue(toMM(point.x())); - ui->doubleSpinBoxY->setValue(toMM(point.y())); -} - -DialogSinglePoint::~DialogSinglePoint() -{ - delete ui; -} diff --git a/src/dialogs/dialogspline.cpp b/src/dialogs/dialogspline.cpp deleted file mode 100644 index 208e9f2d3..000000000 --- a/src/dialogs/dialogspline.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/************************************************************************ - ** - ** @file dialogspline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogspline.h" -#include "ui_dialogspline.h" - -#include - -DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), - kAsm1(1), kAsm2(1), kCurve(1) -{ - ui->setupUi(this); - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogSpline::DialogAccepted); - - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected); - if (mode == Draw::Calculation) - { - FillComboBoxPoints(ui->comboBoxP1); - FillComboBoxPoints(ui->comboBoxP4); - } -} - -DialogSpline::~DialogSpline() -{ - delete ui; -} - -void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - FillComboBoxPoints(ui->comboBoxP1); - FillComboBoxPoints(ui->comboBoxP4); - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - if (number == 0) - { - qint32 index = ui->comboBoxP1->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select last point of curve")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP4->findText(point.name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP4->setCurrentIndex(index); - number = 0; - emit ToolTip(""); - index = ui->comboBoxP1->currentIndex(); - qint64 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); - QPointF p1; - QPointF p4; - if (mode == Draw::Calculation) - { - p1 = data->GetPoint(p1Id).toQPointF(); - p4 = data->GetPoint(id).toQPointF(); - } - else - { - p1 = data->GetPointModeling(p1Id).toQPointF(); - p4 = data->GetPointModeling(id).toQPointF(); - } - ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle())); - ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle())); - } - if (isInitialized == false) - { - this->show(); - } - } - } -} - -void DialogSpline::DialogAccepted() -{ - p1 = getCurrentPointId(ui->comboBoxP1); - p4 = getCurrentPointId(ui->comboBoxP4); - angle1 = ui->spinBoxAngle1->value(); - angle2 = ui->spinBoxAngle2->value(); - kAsm1 = ui->doubleSpinBoxKasm1->value(); - kAsm2 = ui->doubleSpinBoxKasm2->value(); - kCurve = ui->doubleSpinBoxKcurve->value(); - emit DialogClosed(QDialog::Accepted); -} - -void DialogSpline::setKCurve(const qreal &value) -{ - kCurve = value; - ui->doubleSpinBoxKcurve->setValue(value); -} - -void DialogSpline::setKAsm2(const qreal &value) -{ - kAsm2 = value; - ui->doubleSpinBoxKasm2->setValue(value); -} - -void DialogSpline::setKAsm1(const qreal &value) -{ - kAsm1 = value; - ui->doubleSpinBoxKasm1->setValue(value); -} - -void DialogSpline::setAngle2(const qreal &value) -{ - angle2 = value; - ui->spinBoxAngle2->setValue(static_cast(value)); -} - -void DialogSpline::setAngle1(const qreal &value) -{ - angle1 = value; - ui->spinBoxAngle1->setValue(static_cast(value)); -} - -void DialogSpline::setP4(const qint64 &value) -{ - p4 = value; - ChangeCurrentData(ui->comboBoxP4, value); -} - -void DialogSpline::setP1(const qint64 &value) -{ - p1 = value; - ChangeCurrentData(ui->comboBoxP1, value); -} diff --git a/src/dialogs/dialogspline.h b/src/dialogs/dialogspline.h deleted file mode 100644 index 1df76c69e..000000000 --- a/src/dialogs/dialogspline.h +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************ - ** - ** @file dialogspline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGSPLINE_H -#define DIALOGSPLINE_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogSpline; -} - -/** - * @brief The DialogSpline class dialog for ToolSpline. Help create spline and edit option. - */ -class DialogSpline : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogSpline create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogSpline(); - /** - * @brief getP1 return id first point of spline - * @return id - */ - inline qint64 getP1() const {return p1;} - /** - * @brief setP1 set id first point of spline - * @param value id - */ - void setP1(const qint64 &value); - /** - * @brief getP4 return id fourth point of spline - * @return id - */ - inline qint64 getP4() const {return p4;} - /** - * @brief setP4 set id fourth point of spline - * @param value id - */ - void setP4(const qint64 &value); - /** - * @brief getAngle1 return first angle of spline - * @return angle in degree - */ - inline qreal getAngle1() const {return angle1;} - /** - * @brief setAngle1 set first angle of spline - * @param value angle in degree - */ - void setAngle1(const qreal &value); - /** - * @brief getAngle2 return second angle of spline - * @return angle in degree - */ - inline qreal getAngle2() const {return angle2;} - /** - * @brief setAngle2 set second angle of spline - * @param value angle in degree - */ - void setAngle2(const qreal &value); - /** - * @brief getKAsm1 return first coefficient asymmetry - * @return value. Can be >= 0. - */ - inline qreal getKAsm1() const {return kAsm1;} - /** - * @brief setKAsm1 set first coefficient asymmetry - * @param value value. Can be >= 0. - */ - void setKAsm1(const qreal &value); - /** - * @brief getKAsm2 return second coefficient asymmetry - * @return value. Can be >= 0. - */ - inline qreal getKAsm2() const {return kAsm2;} - /** - * @brief setKAsm2 set second coefficient asymmetry - * @param value value. Can be >= 0. - */ - void setKAsm2(const qreal &value); - /** - * @brief getKCurve return coefficient curve - * @return value. Can be >= 0. - */ - inline qreal getKCurve() const {return kCurve;} - /** - * @brief setKCurve set coefficient curve - * @param value value. Can be >= 0. - */ - void setKCurve(const qreal &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogSpline) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogSpline *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief p1 id first point of spline - */ - qint64 p1; - /** - * @brief p4 id fourth point of spline - */ - qint64 p4; - /** - * @brief angle1 first angle of spline in degree - */ - qreal angle1; - /** - * @brief angle2 second angle of spline in degree - */ - qreal angle2; - /** - * @brief kAsm1 first coefficient asymmetry - */ - qreal kAsm1; - /** - * @brief kAsm2 second coefficient asymmetry - */ - qreal kAsm2; - /** - * @brief kCurve coefficient curve - */ - qreal kCurve; -}; - -#endif // DIALOGSPLINE_H diff --git a/src/dialogs/dialogsplinepath.cpp b/src/dialogs/dialogsplinepath.cpp deleted file mode 100644 index 17117e9ee..000000000 --- a/src/dialogs/dialogsplinepath.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/************************************************************************ - ** - ** @file dialogsplinepath.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogsplinepath.h" -#include "ui_dialogsplinepath.h" -#include "../geometry/vsplinepoint.h" - -#include - -DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent) - :DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()) -{ - ui->setupUi(this); - bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted); - - QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - connect(bCansel, &QPushButton::clicked, this, &DialogSplinePath::DialogRejected); - FillComboBoxPoints(ui->comboBoxPoint); - - path = VSplinePath(data->DataPoints()); - - connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChenged); - connect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged), - this, &DialogSplinePath::currentPointChanged); - connect(ui->spinBoxAngle1, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle1Changed); - connect(ui->spinBoxAngle2, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle2Changed); - connect(ui->doubleSpinBoxKasm1, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm1Changed); - connect(ui->doubleSpinBoxKasm2, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm2Changed); -} - -DialogSplinePath::~DialogSplinePath() -{ - delete ui; -} - -void DialogSplinePath::SetPath(const VSplinePath &value) -{ - this->path = value; - ui->listWidget->clear(); - for (qint32 i = 0; i < path.CountPoint(); ++i) - { - NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2()); - } - ui->listWidget->setFocus(Qt::OtherFocusReason); - ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); -} - - -void DialogSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - if (idDetail == 0 && mode == Draw::Modeling) - { - if (type == Scene::Detail) - { - idDetail = id; - return; - } - } - if (mode == Draw::Modeling) - { - if (CheckObject(id) == false) - { - return; - } - } - if (type == Scene::Point) - { - NewItem(id, 1, 0, 1); - emit ToolTip(tr("Select point of curve path")); - this->show(); - } -} - -void DialogSplinePath::DialogAccepted() -{ - path.Clear(); - for (qint32 i = 0; i < ui->listWidget->count(); ++i) - { - QListWidgetItem *item = ui->listWidget->item(i); - path.append( qvariant_cast(item->data(Qt::UserRole))); - } - path.setKCurve(ui->doubleSpinBoxKcurve->value()); - emit ToolTip(""); - emit DialogClosed(QDialog::Accepted); -} - -void DialogSplinePath::PointChenged(int row) -{ - if (ui->listWidget->count() == 0) - { - return; - } - QListWidgetItem *item = ui->listWidget->item( row ); - VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); - EnableFields(); -} - -void DialogSplinePath::currentPointChanged(int index) -{ - qint64 id = qvariant_cast(ui->comboBoxPoint->itemData(index)); - qint32 row = ui->listWidget->currentRow(); - QListWidgetItem *item = ui->listWidget->item( row ); - VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - p.SetP(id); - DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); - EnableFields(); - item->setData(Qt::UserRole, QVariant::fromValue(p)); -} - -void DialogSplinePath::Angle1Changed(int index) -{ - SetAngle(index+180); -} - -void DialogSplinePath::Angle2Changed(int index) -{ - SetAngle(index); -} - -void DialogSplinePath::KAsm1Changed(qreal d) -{ - qint32 row = ui->listWidget->currentRow(); - QListWidgetItem *item = ui->listWidget->item( row ); - VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - p.SetKAsm1(d); - item->setData(Qt::UserRole, QVariant::fromValue(p)); -} - -void DialogSplinePath::KAsm2Changed(qreal d) -{ - qint32 row = ui->listWidget->currentRow(); - QListWidgetItem *item = ui->listWidget->item( row ); - VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - p.SetKAsm2(d); - item->setData(Qt::UserRole, QVariant::fromValue(p)); -} - -void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2) -{ - VPointF point; - if (mode == Draw::Calculation) - { - point = data->GetPoint(id); - } - else - { - point = data->GetPointModeling(id); - } - QListWidgetItem *item = new QListWidgetItem(point.name()); - item->setFont(QFont("Times", 12, QFont::Bold)); - VSplinePoint p(id, kAsm1, angle, kAsm2); - DataPoint(id, kAsm1, angle+180, kAsm2, angle); - item->setData(Qt::UserRole, QVariant::fromValue(p)); - ui->listWidget->addItem(item); - EnableFields(); -} - -void DialogSplinePath::DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) -{ - disconnect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged), - this, &DialogSplinePath::currentPointChanged); - disconnect(ui->spinBoxAngle1, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle1Changed); - disconnect(ui->spinBoxAngle2, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle2Changed); - disconnect(ui->doubleSpinBoxKasm1, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm1Changed); - disconnect(ui->doubleSpinBoxKasm2, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm2Changed); - - ChangeCurrentData(ui->comboBoxPoint, id); - ui->doubleSpinBoxKasm1->setValue(kAsm1); - ui->doubleSpinBoxKasm2->setValue(kAsm2); - ui->spinBoxAngle2->setValue(static_cast(angle2)); - ui->spinBoxAngle1->setValue(static_cast(angle1)); - - connect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged), - this, &DialogSplinePath::currentPointChanged); - connect(ui->spinBoxAngle1, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle1Changed); - connect(ui->spinBoxAngle2, static_cast(&QSpinBox::valueChanged), - this, &DialogSplinePath::Angle2Changed); - connect(ui->doubleSpinBoxKasm1, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm1Changed); - connect(ui->doubleSpinBoxKasm2, static_cast(&QDoubleSpinBox::valueChanged), - this, &DialogSplinePath::KAsm2Changed); -} - -void DialogSplinePath::EnableFields() -{ - ui->doubleSpinBoxKasm1->setEnabled(true); - ui->spinBoxAngle1->setEnabled(true); - ui->doubleSpinBoxKasm2->setEnabled(true); - ui->spinBoxAngle2->setEnabled(true); - qint32 row = ui->listWidget->currentRow(); - if (row == 0) - { - ui->doubleSpinBoxKasm1->setEnabled(false); - ui->spinBoxAngle1->setEnabled(false); - return; - } - if (row == ui->listWidget->count()-1) - { - ui->doubleSpinBoxKasm2->setEnabled(false); - ui->spinBoxAngle2->setEnabled(false); - return; - } -} - -void DialogSplinePath::SetAngle(qint32 angle) -{ - qint32 row = ui->listWidget->currentRow(); - QListWidgetItem *item = ui->listWidget->item( row ); - VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - p.SetAngle(angle); - DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); - item->setData(Qt::UserRole, QVariant::fromValue(p)); -} diff --git a/src/dialogs/dialogsplinepath.h b/src/dialogs/dialogsplinepath.h deleted file mode 100644 index 9cf20e16c..000000000 --- a/src/dialogs/dialogsplinepath.h +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************************ - ** - ** @file dialogsplinepath.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGSPLINEPATH_H -#define DIALOGSPLINEPATH_H - -#include "dialogtool.h" -#include "../geometry/vsplinepath.h" - -namespace Ui -{ - class DialogSplinePath; -} - -/** - * @brief The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option. - */ -class DialogSplinePath : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogSplinePath create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation, - QWidget *parent = 0); - ~DialogSplinePath(); - /** - * @brief GetPath return spline path - * @return path - */ - inline VSplinePath GetPath() const {return path;} - /** - * @brief SetPath set spline path - * @param value path - */ - void SetPath(const VSplinePath &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type don't show this id in list - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); - /** - * @brief PointChenged selected another point in list - * @param row number of row - */ - void PointChenged(int row); - /** - * @brief currentPointChanged changed point in combo box - * @param index index in list - */ - void currentPointChanged( int index ); - /** - * @brief Angle1Changed changed first angle - * @param index index in list - */ - void Angle1Changed( int index ); - /** - * @brief Angle2Changed changed second angle - * @param index index in list - */ - void Angle2Changed( int index ); - /** - * @brief KAsm1Changed changed first coefficient asymmetry - * @param d value - */ - void KAsm1Changed(qreal d); - /** - * @brief KAsm2Changed changed second coefficient asymmetry - * @param d value - */ - void KAsm2Changed(qreal d); -private: - Q_DISABLE_COPY(DialogSplinePath) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogSplinePath *ui; - /** - * @brief path spline path - */ - VSplinePath path; - /** - * @brief NewItem add point to list - * @param id id - * @param kAsm1 first coefficient asymmetry - * @param angle angle in degree - * @param kAsm2 second coefficient asymmetry - */ - void NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2); - /** - * @brief dataPoint show data of point in fields - * @param id id - * @param kAsm1 first coefficient asymmetry - * @param angle1 first angle of spline - * @param kAsm2 second coefficient asymmetry - * @param angle2 second angle of spline - */ - void DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); - /** - * @brief EnableFields enable or disable fields - */ - void EnableFields(); - /** - * @brief SetAngle set angle of point - * @param angle angle in degree - */ - void SetAngle(qint32 angle); -}; - -#endif // DIALOGSPLINEPATH_H diff --git a/src/dialogs/dialogtool.cpp b/src/dialogs/dialogtool.cpp deleted file mode 100644 index 5ec5f3343..000000000 --- a/src/dialogs/dialogtool.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/************************************************************************ - ** - ** @file dialogtool.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogtool.h" -#include "../container/calculator.h" - -#include - -DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent) - :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), - spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0), - labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0), - radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0), - idDetail(0), mode(mode) -{ - Q_ASSERT(data != 0); - timerFormula = new QTimer(this); - connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula); -} - -void DialogTool::closeEvent(QCloseEvent *event) -{ - DialogClosed(QDialog::Rejected); - event->accept(); -} - -void DialogTool::showEvent(QShowEvent *event) -{ - QDialog::showEvent( event ); - if ( event->spontaneous() ) - { - return; - } - if (isInitialized) - { - return; - } - isInitialized = true;//first show windows are held -} - -void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const -{ - box->clear(); - if (mode == Draw::Calculation) - { - const QHash *points = data->DataPoints(); - QHashIterator i(*points); - while (i.hasNext()) - { - i.next(); - if (i.key() != id) - { - VPointF point = i.value(); - box->addItem(point.name(), i.key()); - } - } - } - else - { - if (idDetail <= 0) - { - qWarning()<GetDetail(idDetail); - for (ptrdiff_t i = 0; i< det.CountNode(); ++i) - { - if (det[i].getTypeTool() == Tool::NodePoint || - det[i].getTypeTool() == Tool::AlongLineTool || - det[i].getTypeTool() == Tool::BisectorTool || - det[i].getTypeTool() == Tool::EndLineTool || - det[i].getTypeTool() == Tool::LineIntersectTool || - det[i].getTypeTool() == Tool::NormalTool || - det[i].getTypeTool() == Tool::PointOfContact || - det[i].getTypeTool() == Tool::ShoulderPointTool) - { - if (det[i].getId() != id) - { - VPointF point = data->GetPointModeling(det[i].getId()); - box->addItem(point.name(), det[i].getId()); - } - } - } - } -} - -void DialogTool::FillComboBoxTypeLine(QComboBox *box) const -{ - Q_ASSERT(box != 0); - QStringList list; - list<addItems(list); -} - -QString DialogTool::GetTypeLine(const QComboBox *box) const -{ - if (box->currentText()==tr("Line")) - { - return QString("hair"); - } - else - { - return QString("none"); - } -} - -void DialogTool::SetupTypeLine(QComboBox *box, const QString &value) -{ - if (value == "hair") - { - qint32 index = box->findText(tr("Line")); - if (index != -1) - { - box->setCurrentIndex(index); - } - } - if (value == "none") - { - qint32 index = box->findText(tr("No line")); - if (index != -1) - { - box->setCurrentIndex(index); - } - } -} - -void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value) -{ - qint32 index = box->findText(value); - if (index != -1) - { - box->setCurrentIndex(index); - } - else - { - qWarning()<findData(value); - if (index != -1) - { - box->setCurrentIndex(index); - } -} - -void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget) -{ - Q_ASSERT(lineEdit != 0); - Q_ASSERT(listWidget != 0); - QListWidgetItem *item = listWidget->currentItem(); - int pos = lineEdit->cursorPosition(); - lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); - lineEdit->setFocus(); - lineEdit->setCursorPosition(pos + item->text().size()); -} - -void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) -{ - Q_ASSERT(edit != 0); - Q_ASSERT(timer != 0); - Q_ASSERT(labelEditFormula != 0); - if (edit->text().isEmpty()) - { - flag = false; - CheckState(); - QPalette palette = labelEditFormula->palette(); - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - labelEditFormula->setPalette(palette); - return; - } - timer->start(1000); -} - -void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) -{ - Q_ASSERT(edit != 0); - Q_ASSERT(timer != 0); - Q_ASSERT(label != 0); - Q_ASSERT(labelEditFormula != 0); - QPalette palette = labelEditFormula->palette(); - if (edit->text().isEmpty()) - { - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(edit->text(), &errorMsg); - if (errorMsg.isEmpty() == false) - { - label->setText(tr("Error")); - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - label->setText(QString().setNum(result)); - flag = true; - palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); - } - } - CheckState(); - timer->stop(); - labelEditFormula->setPalette(palette); -} - -void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const -{ - Q_ASSERT(box != 0); - FillComboBoxPoints(box, id); - pointId = value; - ChangeCurrentData(box, value); -} - -qint64 DialogTool::getCurrentPointId(QComboBox *box) const -{ - Q_ASSERT(box != 0); - qint32 index = box->currentIndex(); - Q_ASSERT(index != -1); - if (index != -1) - { - return qvariant_cast(box->itemData(index)); - } - else - { - return -1; - } -} - -void DialogTool::CheckState() -{ - Q_ASSERT(bOk != 0); - bOk->setEnabled(flagFormula && flagName); -} - -void DialogTool::ChoosedObject(qint64 id, const Scene::Scenes &type) -{ - Q_UNUSED(id); - Q_UNUSED(type); -} - -void DialogTool::NamePointChanged() -{ - Q_ASSERT(labelEditNamePoint != 0); - QLineEdit* edit = qobject_cast(sender()); - if (edit) - { - QString name = edit->text(); - if (name.isEmpty() || name.contains(" ")) - { - flagName = false; - QPalette palette = labelEditNamePoint->palette(); - palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red); - labelEditNamePoint->setPalette(palette); - } - else - { - flagName = true; - QPalette palette = labelEditNamePoint->palette(); - palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76)); - labelEditNamePoint->setPalette(palette); - } - } - CheckState(); -} - -void DialogTool::DialogAccepted() -{ - emit DialogClosed(QDialog::Accepted); -} - -void DialogTool::DialogRejected() -{ - emit DialogClosed(QDialog::Rejected); -} - -void DialogTool::FormulaChanged() -{ - QLineEdit* edit = qobject_cast(sender()); - if (edit) - { - ValFormulaChanged(flagFormula, edit, timerFormula); - } -} - -void DialogTool::ArrowUp() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(90); -} - -void DialogTool::ArrowDown() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(270); -} - -void DialogTool::ArrowLeft() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(180); -} - -void DialogTool::ArrowRight() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(0); -} - -void DialogTool::ArrowLeftUp() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(135); -} - -void DialogTool::ArrowLeftDown() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(225); -} - -void DialogTool::ArrowRightUp() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(45); -} - -void DialogTool::ArrowRightDown() -{ - Q_ASSERT(spinBoxAngle != 0); - spinBoxAngle->setValue(315); -} - -void DialogTool::EvalFormula() -{ - Q_ASSERT(lineEditFormula != 0); - Q_ASSERT(labelResultCalculation != 0); - Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); -} - -void DialogTool::SizeGrowth() -{ - ShowVariable(data->DataBase()); -} - -void DialogTool::StandartTable() -{ - ShowVariable(data->DataStandartTable()); -} - -void DialogTool::LengthLines() -{ - ShowVariable(data->DataLengthLines()); -} - -void DialogTool::LengthArcs() -{ - ShowVariable(data->DataLengthArcs()); -} - -void DialogTool::LengthCurves() -{ - ShowVariable(data->DataLengthSplines()); -} - -void DialogTool::Increments() -{ - ShowVariable(data->DataIncrementTable()); -} - -void DialogTool::PutHere() -{ - PutValHere(lineEditFormula, listWidget); -} - -void DialogTool::PutVal(QListWidgetItem *item) -{ - Q_ASSERT(lineEditFormula != 0); - Q_ASSERT(item != 0); - int pos = lineEditFormula->cursorPosition(); - lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(), - item->text())); - lineEditFormula->setFocus(); - lineEditFormula->setCursorPosition(pos + item->text().size()); -} - -void DialogTool::ValChenged(int row) -{ - Q_ASSERT(listWidget != 0); - Q_ASSERT(labelDescription != 0); - Q_ASSERT(radioButtonSizeGrowth != 0); - Q_ASSERT(radioButtonStandartTable != 0); - Q_ASSERT(radioButtonIncrements != 0); - Q_ASSERT(radioButtonLengthLine != 0); - Q_ASSERT(radioButtonLengthArc != 0); - Q_ASSERT(radioButtonLengthCurve != 0); - if (listWidget->count() == 0) - { - return; - } - QListWidgetItem *item = listWidget->item( row ); - if (radioButtonSizeGrowth->isChecked()) - { - if (item->text()=="Р") - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Growth")); - labelDescription->setText(desc); - } - if (item->text()=="Сг") - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size")); - labelDescription->setText(desc); - } - return; - } - if (radioButtonStandartTable->isChecked()) - { - VStandartTableRow stable = data->GetStandartTableCell(item->text()); - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text())) - .arg(stable.GetDescription()); - labelDescription->setText(desc); - return; - } - if (radioButtonIncrements->isChecked()) - { - VIncrementTableRow itable = data->GetIncrementTableRow(item->text()); - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text())) - .arg(itable.getDescription()); - labelDescription->setText(desc); - return; - } - if (radioButtonLengthLine->isChecked()) - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text())) - .arg(tr("Line length")); - labelDescription->setText(desc); - return; - } - if (radioButtonLengthArc->isChecked()) - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(item->text())) - .arg(tr("Arc length")); - labelDescription->setText(desc); - return; - } - if (radioButtonLengthCurve->isChecked()) - { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text())) - .arg(tr("Curve length")); - labelDescription->setText(desc); - return; - } -} - -void DialogTool::UpdateList() -{ - Q_ASSERT(radioButtonSizeGrowth != 0); - Q_ASSERT(radioButtonStandartTable != 0); - Q_ASSERT(radioButtonIncrements != 0); - Q_ASSERT(radioButtonLengthLine != 0); - Q_ASSERT(radioButtonLengthArc != 0); - Q_ASSERT(radioButtonLengthCurve != 0); - - if (radioButtonSizeGrowth->isChecked()) - { - ShowVariable(data->DataBase()); - } - if (radioButtonStandartTable->isChecked()) - { - ShowVariable(data->DataStandartTable()); - } - if (radioButtonIncrements->isChecked()) - { - ShowVariable(data->DataIncrementTable()); - } - if (radioButtonLengthLine->isChecked()) - { - ShowVariable(data->DataLengthLines()); - } - if (radioButtonLengthArc->isChecked()) - { - ShowVariable(data->DataLengthArcs()); - } - if (radioButtonLengthCurve->isChecked()) - { - ShowVariable(data->DataLengthSplines()); - } -} - -bool DialogTool::CheckObject(const qint64 &id) -{ - if (mode == Draw::Calculation || idDetail == 0) - { - return false; - } - VDetail det = data->GetDetail(idDetail); - return det.Containes(id); -} - -template -void DialogTool::ShowVariable(const QHash *var) -{ - Q_ASSERT(listWidget != 0); - disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); - listWidget->clear(); - - QHashIterator i(*var); - QMap map; - while (i.hasNext()) - { - i.next(); - map.insert(i.key(), i.value()); - } - - QMapIterator iMap(map); - while (iMap.hasNext()) - { - iMap.next(); - QListWidgetItem *item = new QListWidgetItem(iMap.key()); - item->setFont(QFont("Times", 12, QFont::Bold)); - listWidget->addItem(item); - } - connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); - listWidget->setCurrentRow (0); -} diff --git a/src/dialogs/dialogtool.h b/src/dialogs/dialogtool.h deleted file mode 100644 index ca3bff440..000000000 --- a/src/dialogs/dialogtool.h +++ /dev/null @@ -1,361 +0,0 @@ -/************************************************************************ - ** - ** @file dialogtool.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGTOOL_H -#define DIALOGTOOL_H - -#include -#include -#include -#include -#include -#include -#include "../container/vcontainer.h" - -/** - * @brief The DialogTool class parent for all dialog of tools. - */ -class DialogTool : public QDialog -{ - Q_OBJECT -public: - /** - * @brief DialogTool create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - virtual ~DialogTool() {} - /** - * @brief getIdDetail return id detail - * @return id - */ - inline qint64 getIdDetail() const {return idDetail;} - /** - * @brief setIdDetail set id detail - * @param value id - */ - inline void setIdDetail(const qint64 &value) {idDetail = value;} -signals: - /** - * @brief DialogClosed signal dialog closed - * @param result keep result - */ - void DialogClosed(int result); - /** - * @brief ToolTip emit tooltipe for tool - * @param toolTip text tooltipe - */ - void ToolTip(const QString &toolTip); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief NamePointChanged check name of point - */ - void NamePointChanged(); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); - /** - * @brief DialogRejected emit signal dialog rejected - */ - virtual void DialogRejected(); - /** - * @brief formula check formula - */ - void FormulaChanged(); - /** - * @brief ArrowUp set angle value 90 degree - */ - void ArrowUp(); - /** - * @brief ArrowDown set angle value 270 degree - */ - void ArrowDown(); - /** - * @brief ArrowLeft set angle value 180 degree - */ - void ArrowLeft(); - /** - * @brief ArrowRight set angle value 0 degree - */ - void ArrowRight(); - /** - * @brief ArrowLeftUp set angle value 135 degree - */ - void ArrowLeftUp(); - /** - * @brief ArrowLeftDown set angle value 225 degree - */ - void ArrowLeftDown(); - /** - * @brief ArrowRightUp set angle value 45 degree - */ - void ArrowRightUp(); - /** - * @brief ArrowRightDown set angle value 315 degree - */ - void ArrowRightDown(); - /** - * @brief EvalFormula evaluate formula - */ - void EvalFormula(); - /** - * @brief SizeGrowth show in list base variables - */ - void SizeGrowth(); - /** - * @brief StandartTable show in list standart table variables - */ - void StandartTable(); - /** - * @brief LengthLines show in list lengths of lines variables - */ - void LengthLines(); - /** - * @brief LengthArcs show in list lengths of arcs variables - */ - void LengthArcs(); - /** - * @brief LengthCurves show in list lengths of curves variables - */ - void LengthCurves(); - /** - * @brief Increments show in list increment variables - */ - void Increments(); - /** - * @brief PutHere put variable into edit - */ - void PutHere(); - /** - * @brief PutVal put variable into edit - * @param item chosen item of list widget - */ - void PutVal(QListWidgetItem * item); - /** - * @brief ValChenged show description when current variable changed - * @param row number of row - */ - virtual void ValChenged(int row); - /** - * @brief UpdateList update lists of variables - */ - void UpdateList(); -protected: - Q_DISABLE_COPY(DialogTool) - /** - * @brief data container with data - */ - const VContainer *data; - /** - * @brief isInitialized true if window is initialized - */ - bool isInitialized; - /** - * @brief flagName true if name is correct - */ - bool flagName; - /** - * @brief flagFormula true if formula correct - */ - bool flagFormula; - /** - * @brief timerFormula timer for check formula - */ - QTimer *timerFormula; - /** - * @brief bOk button ok - */ - QPushButton *bOk; - /** - * @brief spinBoxAngle spinbox for angle - */ - QDoubleSpinBox *spinBoxAngle; - /** - * @brief lineEditFormula linEdit for formula - */ - QLineEdit *lineEditFormula; - /** - * @brief listWidget listWidget with variables - */ - QListWidget *listWidget; - /** - * @brief labelResultCalculation label with result of calculation - */ - QLabel *labelResultCalculation; - /** - * @brief labelDescription description of variable - */ - QLabel *labelDescription; - /** - * @brief labelEditNamePoint label used when need show wrong name of point - */ - QLabel *labelEditNamePoint; - /** - * @brief labelEditFormula label used when need show wrong formula - */ - QLabel *labelEditFormula; - /** - * @brief radioButtonSizeGrowth radio button for base variables - */ - QRadioButton *radioButtonSizeGrowth; - /** - * @brief radioButtonStandartTable radio button for standart table variables - */ - QRadioButton *radioButtonStandartTable; - /** - * @brief radioButtonIncrements radio button for increments variables - */ - QRadioButton *radioButtonIncrements; - /** - * @brief radioButtonLengthLine radio button for lengths od lines variables - */ - QRadioButton *radioButtonLengthLine; - /** - * @brief radioButtonLengthArc radio button for lengths of arcs variables - */ - QRadioButton *radioButtonLengthArc; - /** - * @brief radioButtonLengthCurve radio button for lengths of curves variables - */ - QRadioButton *radioButtonLengthCurve; - /** - * @brief idDetail id detail - */ - qint64 idDetail; - /** - * @brief mode mode - */ - Draw::Draws mode; - /** - * @brief CheckObject check if object belongs to detail - * @param id id of object (point, arc, spline, spline path) - * @return true - belons, false - don't - */ - bool CheckObject(const qint64 &id); - /** - * @brief closeEvent handle when dialog cloded - * @param event event - */ - virtual void closeEvent ( QCloseEvent * event ); - /** - * @brief showEvent handle when window show - * @param event event - */ - virtual void showEvent( QShowEvent *event ); - /** - * @brief FillComboBoxPoints fill comboBox list of points - * @param box comboBox - * @param id don't show this id in list - */ - void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const; - /** - * @brief FillComboBoxTypeLine fill comboBox list of type lines - * @param box comboBox - */ - void FillComboBoxTypeLine(QComboBox *box) const; - /** - * @brief CheckState enable, when all is correct, or disable, when something wrong, button ok - */ - virtual void CheckState(); - /** - * @brief getTypeLine return type of line - * @param box combobox - * @return type - */ - QString GetTypeLine(const QComboBox *box)const; - template - /** - * @brief ShowVariable show variables in list - * @param var container with variables - */ - void ShowVariable(const QHash *var); - /** - * @brief SetupTypeLine setupe type of line - * @param box combobox - * @param value string from pattern file - */ - void SetupTypeLine(QComboBox *box, const QString &value); - /** - * @brief ChangeCurrentText select item in combobox by name - * @param box combobox - * @param value name of item - */ - void ChangeCurrentText(QComboBox *box, const QString &value); - /** - * @brief ChangeCurrentData select item in combobox by id - * @param box combobox - * @param value id of item - */ - void ChangeCurrentData(QComboBox *box, const qint64 &value) const; - /** - * @brief PutValHere put variable into line edit from list - * @param lineEdit lineEdit - * @param listWidget listWidget - */ - void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); - /** - * @brief ValFormulaChanged handle change formula - * @param flag flag state of formula - * @param edit LineEdit - * @param timer timer of formula - */ - void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); - /** - * @brief Eval evaluate formula and show result - * @param edit lineEdit of formula - * @param flag flag state of formula - * @param timer timer of formula - * @param label label for signal error - */ - void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label); - /** - * @brief setCurrentPointId set current point id in combobox - * @param box combobox - * @param pointId save current point id - * @param value point id - * @param id don't show this id in list - */ - void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const; - /** - * @brief getCurrentPointId return current point id in combobox - * @param box combobox - * @return id or -1 if combobox is empty - */ - qint64 getCurrentPointId(QComboBox *box) const; -}; - -#endif // DIALOGTOOL_H diff --git a/src/dialogs/dialogtriangle.cpp b/src/dialogs/dialogtriangle.cpp deleted file mode 100644 index 5c0625b4d..000000000 --- a/src/dialogs/dialogtriangle.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************ - ** - ** @file dialogtriangle.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "dialogtriangle.h" -#include "ui_dialogtriangle.h" - -#include - -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->GetPointModeling(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); -} diff --git a/src/dialogs/dialogtriangle.h b/src/dialogs/dialogtriangle.h deleted file mode 100644 index 68f9cbbcb..000000000 --- a/src/dialogs/dialogtriangle.h +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************ - ** - ** @file dialogtriangle.h - ** @author Roman Telezhinsky - ** @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 - ** 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 DIALOGTRIANGLE_H -#define DIALOGTRIANGLE_H - -#include "dialogtool.h" - -namespace Ui -{ - class DialogTriangle; -} - -/** - * @brief The DialogTriangle class dialog for ToolTriangle. Help create point and edit option. - */ -class DialogTriangle : public DialogTool -{ - Q_OBJECT -public: - /** - * @brief DialogTriangle create dialog - * @param data container with data - * @param mode mode of creation tool - * @param parent parent widget - */ - DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0); - ~DialogTriangle(); - /** - * @brief getAxisP1Id return id first point of axis - * @return id - */ - inline qint64 getAxisP1Id() const {return axisP1Id;} - /** - * @brief setAxisP1Id set id first point of axis - * @param value id - * @param id don't show this point in list - */ - void setAxisP1Id(const qint64 &value, const qint64 &id); - /** - * @brief getAxisP2Id return id second point of axis - * @return id - */ - inline qint64 getAxisP2Id() const {return axisP2Id;} - /** - * @brief setAxisP2Id set id second point of axis - * @param value id - * @param id don't show this point in list - */ - void setAxisP2Id(const qint64 &value, const qint64 &id); - /** - * @brief getFirstPointId return id of first point - * @return id - */ - inline qint64 getFirstPointId() const {return firstPointId;} - /** - * @brief setFirstPointId set id of first point - * @param value id - * @param id don't show this point in list - */ - void setFirstPointId(const qint64 &value, const qint64 &id); - /** - * @brief getSecondPointId return id of second point - * @return id - */ - inline qint64 getSecondPointId() const {return secondPointId;} - /** - * @brief setSecondPointId set id of second point - * @param value id - * @param id don't show this point in list - */ - void setSecondPointId(const qint64 &value, const qint64 &id); - /** - * @brief getPointName return name of point - * @return name - */ - inline QString getPointName() const {return pointName;} - /** - * @brief setPointName set name of point - * @param value name - */ - void setPointName(const QString &value); -public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ - virtual void ChoosedObject(qint64 id, const Scene::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ - virtual void DialogAccepted(); -private: - Q_DISABLE_COPY(DialogTriangle) - /** - * @brief ui keeps information about user interface - */ - Ui::DialogTriangle *ui; - /** - * @brief number number of handled objects - */ - qint32 number; - /** - * @brief pointName name of point - */ - QString pointName; - /** - * @brief axisP1Id id first point of axis - */ - qint64 axisP1Id; - /** - * @brief axisP2Id id second point of axis - */ - qint64 axisP2Id; - /** - * @brief firstPointId id first point of line - */ - qint64 firstPointId; - /** - * @brief secondPointId id second point of line - */ - qint64 secondPointId; -}; - -#endif // DIALOGTRIANGLE_H diff --git a/src/exception/exception.pri b/src/exception/exception.pri deleted file mode 100644 index 3e0166be0..000000000 --- a/src/exception/exception.pri +++ /dev/null @@ -1,17 +0,0 @@ -HEADERS += \ - src/exception/vexceptionwrongparameterid.h \ - src/exception/vexceptionuniqueid.h \ - src/exception/vexceptionobjecterror.h \ - src/exception/vexceptionemptyparameter.h \ - src/exception/vexceptionconversionerror.h \ - src/exception/vexceptionbadid.h \ - src/exception/vexception.h - -SOURCES += \ - src/exception/vexceptionwrongparameterid.cpp \ - src/exception/vexceptionuniqueid.cpp \ - src/exception/vexceptionobjecterror.cpp \ - src/exception/vexceptionemptyparameter.cpp \ - src/exception/vexceptionconversionerror.cpp \ - src/exception/vexceptionbadid.cpp \ - src/exception/vexception.cpp diff --git a/src/exception/vexception.h b/src/exception/vexception.h deleted file mode 100644 index ce58a7e27..000000000 --- a/src/exception/vexception.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************ - ** - ** @file vexception.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTION_H -#define VEXCEPTION_H - -#include -#include - -/** - * @brief The VException class parent for all exception. Could be use for abstract exception - */ -class VException : public QException -{ -public: - /** - * @brief VException constructor exception - * @param what string with error - */ - VException(const QString &what); - /** - * @brief VException copy constructor - * @param e exception - */ - VException(const VException &e):what(e.What()){} - virtual ~VException() noexcept (true){} - /** - * @brief raise method raise for exception - */ - inline void raise() const { throw *this; } - /** - * @brief clone clone exception - * @return new exception - */ - inline VException *clone() const { return new VException(*this); } - /** - * @brief ErrorMessage return main error message - * @return error message - */ - virtual QString ErrorMessage() const; - /** - * @brief DetailedInformation return detailed information about error - * @return detailed information - */ - virtual QString DetailedInformation() const { return QString(); } - /** - * @brief What return string with error - * @return string with error - */ - inline QString What() const {return what;} -protected: - /** - * @brief what string with error - */ - QString what; -}; - -#endif // VEXCEPTION_H diff --git a/src/exception/vexceptionbadid.h b/src/exception/vexceptionbadid.h deleted file mode 100644 index 91a407c0c..000000000 --- a/src/exception/vexceptionbadid.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionbadid.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTIONBADID_H -#define VEXCEPTIONBADID_H - -#include "vexception.h" - -/** - * @brief The VExceptionBadId class for exception bad id - */ -class VExceptionBadId : public VException -{ -public: - /** - * @brief VExceptionBadId exception bad id - * @param what string with error - * @param id id - */ - VExceptionBadId(const QString &what, const qint64 &id) - :VException(what), id(id), key(QString()){} - /** - * @brief VExceptionBadId exception bad id - * @param what string with error - * @param key string key - */ - VExceptionBadId(const QString &what, const QString &key) - :VException(what), id(0), key(key){} - /** - * @brief VExceptionBadId copy constructor - * @param e exception - */ - VExceptionBadId(const VExceptionBadId &e) - :VException(e), id(e.BadId()), key(e.BadKey()){} - virtual ~VExceptionBadId() noexcept (true){} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ - virtual QString ErrorMessage() const; - /** - * @brief BadId return bad id - * @return id - */ - inline qint64 BadId() const {return id; } - /** - * @brief BadKey return bad key - * @return key - */ - inline QString BadKey() const {return key; } -protected: - /** - * @brief id id - */ - qint64 id; - /** - * @brief key key - */ - QString key; -}; - -#endif // VEXCEPTIONBADID_H diff --git a/src/exception/vexceptionemptyparameter.h b/src/exception/vexceptionemptyparameter.h deleted file mode 100644 index b514683a9..000000000 --- a/src/exception/vexceptionemptyparameter.h +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionemptyparameter.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTIONEMPTYPARAMETER_H -#define VEXCEPTIONEMPTYPARAMETER_H - -#include "vexception.h" - -#include - -/** - * @brief The VExceptionEmptyParameter class for exception empty parameter - */ -class VExceptionEmptyParameter : public VException -{ -public: - /** - * @brief VExceptionEmptyParameter exception empty parameter - * @param what string with error - * @param name name of attribute where error - * @param domElement dom element - */ - VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement); - /** - * @brief VExceptionEmptyParameter copy constructor - * @param e exception - */ - VExceptionEmptyParameter(const VExceptionEmptyParameter &e) - :VException(e), name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), - lineNumber(e.LineNumber()){} - virtual ~VExceptionEmptyParameter() noexcept (true) {} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ - virtual QString ErrorMessage() const; - /** - * @brief DetailedInformation return detailed information about error - * @return detailed information - */ - virtual QString DetailedInformation() const; - /** - * @brief Name return name of attribute where error - * @return name - */ - inline QString Name() const {return name;} - /** - * @brief TagText return tag text - * @return tag text - */ - inline QString TagText() const {return tagText;} - /** - * @brief TagName return tag name - * @return tag name - */ - inline QString TagName() const {return tagName;} - /** - * @brief LineNumber return line number of tag - * @return line number - */ - inline qint32 LineNumber() const {return lineNumber;} -protected: - /** - * @brief name name attribute - */ - QString name; - /** - * @brief tagText tag text - */ - QString tagText; - /** - * @brief tagName tag name - */ - QString tagName; - /** - * @brief lineNumber line number - */ - qint32 lineNumber; -}; - -#endif // VEXCEPTIONEMPTYPARAMETER_H diff --git a/src/exception/vexceptionobjecterror.h b/src/exception/vexceptionobjecterror.h deleted file mode 100644 index 71e90329b..000000000 --- a/src/exception/vexceptionobjecterror.h +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionobjecterror.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTIONOBJECTERROR_H -#define VEXCEPTIONOBJECTERROR_H - -#include "vexception.h" - -#include - -/** - * @brief The VExceptionObjectError class for exception object error - */ -class VExceptionObjectError : public VException -{ -public: - /** - * @brief VExceptionObjectError exception object error - * @param what string with error - * @param domElement dom element - */ - VExceptionObjectError(const QString &what, const QDomElement &domElement); - /** - * @brief VExceptionObjectError copy constructor - * @param e exception - */ - VExceptionObjectError(const VExceptionObjectError &e) - :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()), - moreInfo(e.MoreInformation()){} - virtual ~VExceptionObjectError() noexcept (true) {} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ - virtual QString ErrorMessage() const; - /** - * @brief DetailedInformation return detailed information about error - * @return detailed information - */ - virtual QString DetailedInformation() const; - /** - * @brief TagText return tag text - * @return tag text - */ - inline QString TagText() const {return tagText;} - /** - * @brief TagName return tag name - * @return tag name - */ - inline QString TagName() const {return tagName;} - /** - * @brief LineNumber return line number in file - * @return line number - */ - inline qint32 LineNumber() const {return lineNumber;} - /** - * @brief AddMoreInformation add more information for error - * @param info information - */ - void AddMoreInformation(const QString &info); - /** - * @brief MoreInformation return more information for error - * @return information - */ - inline QString MoreInformation() const {return moreInfo;} -protected: - /** - * @brief tagText tag text - */ - QString tagText; - /** - * @brief tagName tag name - */ - QString tagName; - /** - * @brief lineNumber line number - */ - qint32 lineNumber; - /** - * @brief moreInfo more information about error - */ - QString moreInfo; -}; - -#endif // VEXCEPTIONOBJECTERROR_H diff --git a/src/exception/vexceptionuniqueid.h b/src/exception/vexceptionuniqueid.h deleted file mode 100644 index 7e8abd569..000000000 --- a/src/exception/vexceptionuniqueid.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionuniqueid.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTIONUNIQUEID_H -#define VEXCEPTIONUNIQUEID_H - -#include "vexception.h" - -#include - -/** - * @brief The VExceptionUniqueId class for exception unique id - */ -class VExceptionUniqueId : public VException -{ -public: - /** - * @brief VExceptionUniqueId exception unique id - * @param what string with error - * @param domElement dom element - */ - VExceptionUniqueId(const QString &what, const QDomElement &domElement); - /** - * @brief VExceptionUniqueId copy constructor - * @param e exception - */ - VExceptionUniqueId(const VExceptionUniqueId &e) - :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){} - virtual ~VExceptionUniqueId() noexcept (true){} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ - virtual QString ErrorMessage() const; - /** - * @brief DetailedInformation return detailed information about error - * @return detailed information - */ - virtual QString DetailedInformation() const; - /** - * @brief TagText return tag text - * @return tag text - */ - inline QString TagText() const {return tagText;} - /** - * @brief TagName return tag name - * @return tag name - */ - inline QString TagName() const {return tagName;} - /** - * @brief LineNumber return line number in file - * @return line number - */ - inline qint32 LineNumber() const {return lineNumber;} -protected: - /** - * @brief tagText tag text - */ - QString tagText; - /** - * @brief tagName tag name - */ - QString tagName; - /** - * @brief lineNumber line number - */ - qint32 lineNumber; -}; - -#endif // VEXCEPTIONUNIQUEID_H diff --git a/src/exception/vexceptionwrongparameterid.h b/src/exception/vexceptionwrongparameterid.h deleted file mode 100644 index bc10495c8..000000000 --- a/src/exception/vexceptionwrongparameterid.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************ - ** - ** @file vexceptionwrongparameterid.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VEXCEPTIONWRONGPARAMETERID_H -#define VEXCEPTIONWRONGPARAMETERID_H - -#include "vexception.h" - -#include - -/** - * @brief The VExceptionWrongParameterId class for exception wrong parameter id - */ -class VExceptionWrongParameterId : public VException -{ -public: - /** - * @brief VExceptionWrongParameterId exception wrong parameter id - * @param what string with error - * @param domElement som element - */ - VExceptionWrongParameterId(const QString &what, const QDomElement &domElement); - /** - * @brief VExceptionWrongParameterId copy constructor - * @param e exception - */ - VExceptionWrongParameterId(const VExceptionWrongParameterId &e) - :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){} - virtual ~VExceptionWrongParameterId() noexcept (true){} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ - virtual QString ErrorMessage() const; - /** - * @brief DetailedInformation return detailed information about error - * @return detailed information - */ - virtual QString DetailedInformation() const; - /** - * @brief TagText return tag text - * @return tag text - */ - inline QString TagText() const {return tagText;} - /** - * @brief TagName return tag name - * @return tag name - */ - inline QString TagName() const {return tagName;} - /** - * @brief LineNumber return line number in file - * @return line number - */ - inline qint32 LineNumber() const {return lineNumber;} -protected: - /** - * @brief tagText tag text - */ - QString tagText; - /** - * @brief tagName tag name - */ - QString tagName; - /** - * @brief lineNumber line number - */ - qint32 lineNumber; -}; - -#endif // VEXCEPTIONWRONGPARAMETERID_H diff --git a/src/geometry/geometry.pri b/src/geometry/geometry.pri deleted file mode 100644 index e04865bed..000000000 --- a/src/geometry/geometry.pri +++ /dev/null @@ -1,15 +0,0 @@ -HEADERS += \ - src/geometry/vsplinepoint.h \ - src/geometry/vsplinepath.h \ - src/geometry/vspline.h \ - src/geometry/vnodedetail.h \ - src/geometry/vdetail.h \ - src/geometry/varc.h - -SOURCES += \ - src/geometry/vsplinepoint.cpp \ - src/geometry/vsplinepath.cpp \ - src/geometry/vspline.cpp \ - src/geometry/vnodedetail.cpp \ - src/geometry/vdetail.cpp \ - src/geometry/varc.cpp diff --git a/src/geometry/varc.cpp b/src/geometry/varc.cpp deleted file mode 100644 index 2dfd52a70..000000000 --- a/src/geometry/varc.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************ - ** - ** @file varc.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "varc.h" -#include "../exception/vexception.h" - -class QRectF; - -VArc::VArc () - : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), - center(0), points(QHash()), mode(Draw::Calculation), idObject(0), _name(QString()){} - -VArc::VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius, - qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) - : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), - center(center), points(*points), mode(mode), idObject(idObject), _name(QString()) -{ - /** - * @todo Change name of arc in formula. Name now not unique. - */ - _name = QString ("Arc_%1").arg(this->GetCenterVPoint().name()); -} - -VArc::VArc(const VArc &arc) - : f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()), - formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()), - center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()), - idObject(arc.getIdObject()), _name(arc.name()){} - -VArc &VArc::operator =(const VArc &arc) -{ - this->points = arc.GetDataPoints(); - this->f1 = arc.GetF1(); - this->formulaF1 = arc.GetFormulaF1(); - this->f2 = arc.GetF2(); - this->formulaF2 = arc.GetFormulaF2(); - this->radius = arc.GetRadius(); - this->formulaRadius = arc.GetFormulaRadius(); - this->center = arc.GetCenter(); - this->mode = arc.getMode(); - this->idObject = arc.getIdObject(); - this->_name = arc.name(); - return *this; -} - -QPointF VArc::GetCenterPoint() const -{ - return GetCenterVPoint().toQPointF(); -} - -VPointF VArc::GetCenterVPoint() const -{ - 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(); -} - -QPointF VArc::GetP1() const -{ - QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); - QLineF centerP1(GetCenterPoint(), p1); - centerP1.setAngle(f1); - return centerP1.p2(); -} - -QPointF VArc::GetP2 () const -{ - QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () ); - QLineF centerP2(GetCenterPoint(), p2); - centerP2.setAngle(f2); - return centerP2.p2(); -} - -const QHash VArc::GetDataPoints() const -{ - return points; -} - -QPainterPath VArc::GetPath() const -{ - QPainterPath Path; - QPointF center = GetCenterPoint(); - QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2); - Path.moveTo(GetP1()); - qreal angle = QLineF(center, GetP1()).angleTo(QLineF(center, GetP2())); - Path.arcTo(rect, GetF1(), angle); - return Path; -} - -qreal VArc::AngleArc() const -{ - QLineF l1(0, 0, 100, 100); - l1.setAngle(f1); - QLineF l2(0, 0, 100, 100); - l2.setAngle(f2); - return l1.angleTo(l2); -} - -qint32 VArc::NumberSplOfArc() const -{ - qint32 angArc = static_cast (AngleArc ()); - switch ( angArc ) - { - case 0: - { - QString error = QString(tr("Angle of arc can't be 0 degree.")); - throw VException(error); - } - case 90: - return 1; - case 180: - return 2; - case 270: - return 3; - case 360: - return 4; - default: - return static_cast (AngleArc ( ) / 90 + 1); - } -} - -QVector VArc::GetPoints() const -{ - QVector points; - qint32 numberSpl = NumberSplOfArc(); - for (qint32 i = 1; i <= numberSpl; ++i) - { - points< VArc::SplOfArc(qint32 number) const -{ - qint32 n = NumberSplOfArc (); - if ( number > n ) - { - QString error = QString(tr("Arc have not this number of part.")); - throw VException(error); - } - qreal f1 = GetF1 (); - qreal f2 = GetF2 (); - qint32 i; - for ( i = 0; i < n; ++i ) - { - if ( i == n - 1 ) - { - f2 = GetF2 (); - } - else - { - if ( f1 + 90 > 360 ) - { - f2 = f1 + 90 - 360; - } - else - { - f2 = f1 + 90; - } - } - qreal anglF1, anglF2; - if ( f1 + 90 > 360 ) - { - anglF1 = f1 + 90 - 360; - } - else - { - anglF1 = f1 + 90; - } - if ( f2 - 90 < 0 ) - { - anglF2 = 360 + f2 - 90; - } - else - { - anglF2 = f2 - 90; - } - if ( i + 1 == number ) - { - f1 = f2; - return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.); - } - } - return QVector(); -} diff --git a/src/geometry/varc.h b/src/geometry/varc.h deleted file mode 100644 index 890e2db80..000000000 --- a/src/geometry/varc.h +++ /dev/null @@ -1,240 +0,0 @@ -/************************************************************************ - ** - ** @file varc.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VARC_H -#define VARC_H - -#include "vspline.h" -#include -#include "../options.h" -class QString; -class QLineF; -class QPainterPath; -class QPointF; - -/** - * @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою. - */ -class VArc -{ - Q_DECLARE_TR_FUNCTIONS(VArc) -public: - /** - * @brief VArc конструктор по замовчуванню. - */ - VArc (); - /** - * @brief VArc конструктор. - * @param center точка центру. - * @param radius радіус. - * @param f1 початковий кут в градусах. - * @param f2 кінцевий кут в градусах. - */ - VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius, - qreal f1, QString formulaF1, qreal f2, QString formulaF2, - Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); - /** - * @brief VArc - * @param arc - */ - VArc(const VArc &arc); - /** - * @brief operator = - * @param arc - * @return - */ - VArc& operator= (const VArc &arc); - /** - * @brief GetF1 повертає початковий кут дуги. - * @return повертає кут в градусах. - */ - inline QString GetFormulaF1 () const {return formulaF1;} - /** - * @brief GetF1 - * @return - */ - inline qreal GetF1 () const {return f1;} - /** - * @brief GetF2 повертає кінцевий кут дуги. - * @return повертає кут в градусах. - */ - inline QString GetFormulaF2 () const {return formulaF2;} - /** - * @brief GetF2 - * @return - */ - inline qreal GetF2 () const {return f2;} - /** - * @brief GetLength повертає довжину дуги. - * @return повертає довжину дуги. - */ - inline qreal GetLength () const {return M_PI * radius/180 * (f2-f1);} - /** - * @brief GetRadius повертає радіус дуги. - * @return повертає радіус дуги. - */ - inline QString GetFormulaRadius () const {return formulaRadius;} - /** - * @brief GetRadius - * @return - */ - inline qreal GetRadius () const {return radius;} - /** - * @brief GetCenter повертає точку центра дуги. - * @return повертає точку центра дуги. - */ - inline qint64 GetCenter () const {return center;} - /** - * @brief GetCenterPoint - * @return - */ - QPointF GetCenterPoint() const; - /** - * @brief GetCenterVPoint - * @return - */ - VPointF GetCenterVPoint() const; - /** - * @brief GetP1 повертає першу точку з якої починається дуга. - * @return точку початку дуги. - */ - QPointF GetP1 () const; - /** - * @brief GetP2 повертає другу точку в якій закінчується дуга. - * @return точку кінця дуги. - */ - QPointF GetP2 () const; - /** - * @brief GetDataPoints - * @return - */ - const QHash GetDataPoints() const; - /** - * @brief GetPath будує шлях по даній дузі. - * @return повертає шлях. - */ - QPainterPath GetPath() const; - /** - * @brief AngleArc - * @return - */ - qreal AngleArc() const; - /** - * @brief NumberSplOfArc - * @return - */ - qint32 NumberSplOfArc () const; - /** - * @brief GetPoints - * @return - */ - QVector GetPoints () const; - /** - * @brief SplOfArc - * @param number - * @return - */ - QVector SplOfArc( qint32 number ) const; - /** - * @brief getMode - * @return - */ - inline Draw::Draws getMode() const {return mode;} - /** - * @brief setMode - * @param value - */ - inline void setMode(const Draw::Draws &value) {mode = value;} - /** - * @brief getIdObject - * @return - */ - inline qint64 getIdObject() const {return idObject;} - /** - * @brief setIdObject - * @param value - */ - inline void setIdObject(const qint64 &value) {idObject = value;} - /** - * @brief name - * @return - */ - QString name() const {return _name;} - /** - * @brief setName - * @param name - */ - void setName(const QString &name) {_name = name;} -private: - /** - * @brief f1 початковий кут в градусах - */ - qreal f1; // початковий кут нахилу дуги (градуси) - /** - * @brief formulaF1 - */ - QString formulaF1; - /** - * @brief f2 кінцевий кут в градусах - */ - qreal f2; // кінцевий кут нахилу дуги (градуси) - /** - * @brief formulaF2 - */ - QString formulaF2; - /** - * @brief radius радіус дуги. - */ - qreal radius; - /** - * @brief formulaRadius - */ - QString formulaRadius; - /** - * @brief center центральна точка дуги. - */ - qint64 center; - /** - * @brief points - */ - QHash points; - /** - * @brief mode - */ - Draw::Draws mode; - /** - * @brief idObject - */ - qint64 idObject; - /** - * @brief _name - */ - QString _name; -}; - -#endif // VARC_H diff --git a/src/geometry/vdetail.cpp b/src/geometry/vdetail.cpp deleted file mode 100644 index a5453788c..000000000 --- a/src/geometry/vdetail.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************ - ** - ** @file vdetail.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vdetail.h" - -VDetail::VDetail() - :nodes(QVector()), name(QString()), mx(0), my(0), supplement(true), closed(true), width(10){} - -VDetail::VDetail(const QString &name, const QVector &nodes) - :nodes(QVector()), name(name), mx(0), my(0), supplement(true), closed(true), width(10) -{ - this->nodes = nodes; -} - -VDetail::VDetail(const VDetail &detail) - :nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()), - supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){} - -VDetail &VDetail::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() -{ - nodes.clear(); - name.clear(); - mx = 0; - my = 0; - supplement = true; - closed = true; - width = 10; -} - -bool VDetail::Containes(const qint64 &id) const -{ - for (qint32 i = 0; i < nodes.size(); ++i) - { - VNodeDetail node = nodes[i]; - if (node.getId() == id) - { - return true; - } - } - return false; -} - -VNodeDetail &VDetail::operator [](ptrdiff_t indx) -{ - return nodes[indx]; -} diff --git a/src/geometry/vdetail.h b/src/geometry/vdetail.h deleted file mode 100644 index 958c8f421..000000000 --- a/src/geometry/vdetail.h +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************************ - ** - ** @file vdetail.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VDETAIL_H -#define VDETAIL_H - -#include "vnodedetail.h" - -#include -#include - -namespace Detail -{ - /** - * @brief The Contour enum - */ - enum Contour { OpenContour, CloseContour }; - Q_DECLARE_FLAGS(Contours, Contour) - - /** - * @brief The Equidistant enum - */ - enum Equidistant { OpenEquidistant, CloseEquidistant }; - Q_DECLARE_FLAGS(Equidistants, Equidistant) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) -Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) - -/** - * @brief The VDetail class - */ -class VDetail -{ -public: - /** - * @brief VDetail - */ - VDetail(); - /** - * @brief VDetail - * @param name - * @param nodes - */ - VDetail(const QString &name, const QVector &nodes); - /** - * @brief VDetail - * @param detail - */ - VDetail(const VDetail &detail); - /** - * @brief operator = - * @param detail - * @return - */ - VDetail &operator=(const VDetail &detail); - /** - * @brief append - * @param node - */ - inline void append(const VNodeDetail &node) {nodes.append(node);} - /** - * @brief Clear - */ - void Clear(); - /** - * @brief CountNode - * @return - */ - inline qint32 CountNode() const {return nodes.size();} - /** - * @brief Containes - * @param id - * @return - */ - bool Containes(const qint64 &id)const; - /** - * @brief operator [] - * @param indx - * @return - */ - VNodeDetail & operator[](ptrdiff_t indx); - /** - * @brief getName - * @return - */ - inline QString getName() const {return name;} - /** - * @brief setName - * @param value - */ - inline void setName(const QString &value) {name = value;} - /** - * @brief getMx - * @return - */ - inline qreal getMx() const {return mx;} - /** - * @brief setMx - * @param value - */ - inline void setMx(const qreal &value) {mx = value;} - /** - * @brief getMy - * @return - */ - inline qreal getMy() const {return my;} - /** - * @brief setMy - * @param value - */ - inline void setMy(const qreal &value) {my = value;} - /** - * @brief getSupplement - * @return - */ - inline bool getSupplement() const {return supplement;} - /** - * @brief setSupplement - * @param value - */ - inline void setSupplement(bool value) {supplement = value;} - /** - * @brief getClosed - * @return - */ - inline bool getClosed() const {return closed;} - /** - * @brief setClosed - * @param value - */ - inline void setClosed(bool value) {closed = value;} - /** - * @brief getWidth - * @return - */ - inline qreal getWidth() const {return width;} - /** - * @brief setWidth - * @param value - */ - inline void setWidth(const qreal &value) {width = value;} - /** - * @brief getNodes - * @return - */ - inline QVector getNodes() const {return nodes;} - /** - * @brief setNodes - * @param value - */ - inline void setNodes(const QVector &value) {nodes = value;} -private: - /** - * @brief nodes - */ - QVector nodes; - /** - * @brief name - */ - QString name; - /** - * @brief mx - */ - qreal mx; - /** - * @brief my - */ - qreal my; - /** - * @brief supplement - */ - bool supplement; - /** - * @brief closed - */ - bool closed; - /** - * @brief width - */ - qreal width; -}; - -#endif // VDETAIL_H diff --git a/src/geometry/vnodedetail.h b/src/geometry/vnodedetail.h deleted file mode 100644 index 14e3dbc31..000000000 --- a/src/geometry/vnodedetail.h +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************************ - ** - ** @file vnodedetail.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VNODEDETAIL_H -#define VNODEDETAIL_H - -#include -#include "../options.h" - -namespace NodeDetail -{ - /** - * @brief The NodeDetail enum - */ - enum NodeDetail { Contour, Modeling }; - Q_DECLARE_FLAGS(NodeDetails, NodeDetail) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails) - -/** - * @brief The VNodeDetail class - */ -class VNodeDetail -{ -public: - /** - * @brief VNodeDetail - */ - VNodeDetail(); - /** - * @brief VNodeDetail - * @param id - * @param typeTool - * @param mode - * @param typeNode - * @param mx - * @param my - */ - VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, - qreal mx = 0, qreal my = 0); - /** - * @brief VNodeDetail - * @param node - */ - VNodeDetail(const VNodeDetail &node); - /** - * @brief operator = - * @param node - * @return - */ - VNodeDetail &operator=(const VNodeDetail &node); - /** - * @brief getId - * @return - */ - inline qint64 getId() const {return id;} - /** - * @brief setId - * @param value - */ - inline void setId(const qint64 &value) {id = value;} - /** - * @brief getTypeTool - * @return - */ - inline Tool::Tools getTypeTool() const {return typeTool;} - /** - * @brief setTypeTool - * @param value - */ - inline void setTypeTool(const Tool::Tools &value) {typeTool = value;} - /** - * @brief getMode - * @return - */ - inline Draw::Draws getMode() const {return mode;} - /** - * @brief setMode - * @param value - */ - inline void setMode(const Draw::Draws &value) {mode = value;} - /** - * @brief getTypeNode - * @return - */ - inline NodeDetail::NodeDetails getTypeNode() const {return typeNode;} - /** - * @brief setTypeNode - * @param value - */ - inline void setTypeNode(const NodeDetail::NodeDetails &value) {typeNode = value;} - /** - * @brief getMx - * @return - */ - inline qreal getMx() const {return mx;} - /** - * @brief setMx - * @param value - */ - inline void setMx(const qreal &value) {mx = value;} - /** - * @brief getMy - * @return - */ - inline qreal getMy() const {return my;} - /** - * @brief setMy - * @param value - */ - inline void setMy(const qreal &value) {my = value;} -private: - /** - * @brief id - */ - qint64 id; - /** - * @brief typeTool - */ - Tool::Tools typeTool; - /** - * @brief mode - */ - Draw::Draws mode; - /** - * @brief typeNode - */ - NodeDetail::NodeDetails typeNode; - /** - * @brief mx - */ - qreal mx; - /** - * @brief my - */ - qreal my; -}; - -Q_DECLARE_METATYPE(VNodeDetail) - -#endif // VNODEDETAIL_H diff --git a/src/geometry/vspline.cpp b/src/geometry/vspline.cpp deleted file mode 100644 index 54e5026a0..000000000 --- a/src/geometry/vspline.cpp +++ /dev/null @@ -1,796 +0,0 @@ -/************************************************************************ - ** - ** @file vspline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vspline.h" - -#include - -VSpline::VSpline() - :p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), - points(QHash()), mode(Draw::Calculation), idObject(0), _name(QString()){} - -VSpline::VSpline ( const VSpline & spline ) - :p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), - angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), - points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()), _name(spline.name()){} - -VSpline::VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, - qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject) - :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), - kCurve(kCurve), points(*points), mode(mode), idObject(idObject), _name(QString()) -{ - _name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name()); - ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); -} - -VSpline::VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, - qreal kCurve, Draw::Draws mode, qint64 idObject) - :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode), - idObject(idObject), _name(QString()) -{ - _name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name()); - ModifiSpl ( p1, p2, p3, p4, kCurve); -} - -void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, - qreal kAsm1, qreal kAsm2, qreal kCurve) -{ - this->p1 = p1; - this->p4 = p4; - this->angle1 = angle1; - this->angle2 = angle2; - this->kAsm1 = kAsm1; - this->kAsm2 = kAsm2; - this->kCurve = kCurve; - QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y()); - p1pX.setAngle( angle1 ); - qreal L = 0, radius = 0, angle = 90; - // angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4())); - // if ( angle > 180 ){ - // angle = 360 - angle; - // } - QPointF point1 = GetPointP1().toQPointF(); - QPointF point4 = GetPointP4().toQPointF(); - radius = QLineF(QPointF(point1.x(), point4.y()), point4).length(); - // radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 ); - L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); - QLineF p1p2(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + L * kAsm1, GetPointP1().y()); - p1p2.setAngle(angle1); - QLineF p4p3(GetPointP4().x(), GetPointP4().y(), GetPointP4().x() + L * kAsm2, GetPointP4().y()); - p4p3.setAngle(angle2); - this->p2 = p1p2.p2(); - this->p3 = p4p3.p2(); -} - -void VSpline::ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, const qreal &kCurve) -{ - this->p1 = p1; - this->p2 = p2; - this->p3 = p3; - this->p4 = p4; - this->angle1 = QLineF ( GetPointP1().toQPointF(), p2 ).angle(); - this->angle2 = QLineF ( GetPointP4().toQPointF(), p3 ).angle(); - - QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y()); - p1pX.setAngle( angle1 ); - qreal L = 0, radius = 0, angle = 90; - // angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4())); - // if ( angle >= 180 ){ - // angle = 360 - angle; - // } - QPointF point1 = GetPointP1().toQPointF(); - QPointF point4 = GetPointP4().toQPointF(); - radius = QLineF(QPointF(point1.x(), point4.y()), point4).length(); - // radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 ); - L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); - - this->kCurve = kCurve; - this->kAsm1 = QLineF ( GetPointP1().toQPointF(), p2 ).length()/L; - this->kAsm2 = QLineF ( GetPointP4().toQPointF(), p3 ).length()/L; -} - -//void VSpline::RotationSpl (QPointF pRotate, qreal angle ){ -// QLineF pRotateP1 (pRotate, p1); -// pRotateP1.setAngle(angle); -// p1 = pRotateP1.p2(); -// QLineF pRotateP2 (pRotate, p2); -// pRotateP2.setAngle(angle); -// p2 = pRotateP2.p2(); -// QLineF pRotateP3 (pRotate, p3); -// pRotateP3.setAngle(angle); -// p3 = pRotateP3.p2(); -// QLineF pRotateP4 (pRotate, p4); -// pRotateP4.setAngle(angle); -// p4 = pRotateP4.p2(); -// angle1 = QLineF(p1, p2).angle(); -// angle2 = QLineF(p4, p2).angle(); -//} - -//void VSpline::BiasSpl ( qreal mx, qreal my ){ -// p1 = QPointF(p1.x()+mx, p1.y()+my); -// p2 = QPointF(p2.x()+mx, p2.y()+my); -// p3 = QPointF(p3.x()+mx, p3.y()+my); -// p4 = QPointF(p4.x()+mx, p4.y()+my); -//} - -VPointF VSpline::GetPointP1() const -{ - if (points.contains(p1)) - { - return points.value(p1); - } - else - { - qCritical()<<"Не можу знайти id = "<p2, this->p3, GetPointP4().toQPointF()); -} - -QString VSpline::GetName() const -{ - VPointF first = GetPointP1(); - VPointF second = GetPointP4(); - return QString("Spl_%1_%2").arg(first.name(), second.name()); -} - -QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) const -{ - QVector px; - QVector py; - px.append ( GetPointP1 ().x () ); - py.append ( GetPointP1 ().y () ); - QVector& wpx = px; - QVector& wpy = py; - PointBezier_r ( GetPointP1 ().x (), GetPointP1 ().y (), GetP2 ().x (), GetP2 ().y (), - GetP3 ().x (), GetP3 ().y (), GetPointP4 ().x (), GetPointP4 ().y (), - 0, wpx, wpy); - px.append ( GetPointP4 ().x () ); - py.append ( GetPointP4 ().y () ); - qint32 i = 0; - QPointF crosPoint; - QLineF::IntersectType type = QLineF::NoIntersection; - for ( i = 0; i < px.count()-1; ++i ) - { - type = line.intersect(QLineF ( QPointF ( px[i], py[i] ), - QPointF ( px[i+1], py[i+1] )), &crosPoint); - if ( type == QLineF::BoundedIntersection ) - { - *intersectionPoint = crosPoint; - return type; - } - } - throw "Не можу знайти точку перетину сплайну з лінією."; -} - -//void VSpline::CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const{ -// if ( length > GetLength()){ -// throw"Не правильна довжина нового сплайну\n"; -// } -// qreal parT = length / GetLength(); -// QLineF seg1_2 ( GetPointP1 (), GetP2 () ); -// seg1_2.setLength(seg1_2.length () * parT); -// QPointF p12 = seg1_2.p2(); -// QLineF seg2_3 ( GetP2 (), GetP3 () ); -// seg2_3.setLength(seg2_3.length () * parT); -// QPointF p23 = seg2_3.p2(); -// QLineF seg12_23 ( p12, p23 ); -// seg12_23.setLength(seg12_23.length () * parT); -// QPointF p123 = seg12_23.p2(); -// QLineF seg3_4 ( GetP3 (), GetPointP4 () ); -// seg3_4.setLength(seg3_4.length () * parT); -// QPointF p34 = seg3_4.p2(); -// QLineF seg23_34 ( p23, p34 ); -// seg23_34.setLength(seg23_34.length () * parT); -// QPointF p234 = seg23_34.p2(); -// QLineF seg123_234 ( p123, p234 ); -// seg123_234.setLength(seg123_234.length () * parT); -// QPointF p1234 = seg123_234.p2(); -// curFir->ModifiSpl ( GetPointP1 (), p12, p123, p1234 ); -// curSec->ModifiSpl ( p1234, p234, p34, GetPointP4 () ); -//} - -//void VSpline::CutSpline ( QPointF point, VSpline* curFir, VSpline* curSec ) const{ -// qreal t = param_t (point); -// qreal length = t*this->GetLength(); -// CutSpline ( length, curFir, curSec ); -//} - -//void VSpline::PutAlongSpl (QPointF &moveP, qreal move ) const{ -// if ( GetLength () < move ){ -// qDebug()<<"Довжина більше довжини сплайну."; -// qDebug()< VSpline::GetPoints () const -{ - return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF()); -// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint()); -// line1.setLength(500); -// QLineF line2 = line1; -// line2.setAngle(line2.angle()+90); -// qreal xk1 = line1.p2().x(); -// qreal xk0 = line1.p1().x(); -// qreal y = line2.p2().y(); -// qreal yk0 = line1.p1().y(); -// qreal yk1 = line1.p2().y(); -// qreal x = line2.p2().x(); -// qreal check = (xk1 - xk0) * (y - yk0) - (yk1 - yk0) * (x - xk0); -// if(check > 0){ -// return points; -// } else { -// QVector reversePoints; -// for (qint32 i = points.size() - 1; i >= 0; --i) { -// reversePoints.append(points.at(i)); -// } -// return reversePoints; -// } -} - -QVector VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4) -{ - QVector pvector; - QVector x; - QVector y; - QVector& wx = x; - QVector& wy = y; - x.append ( p1.x () ); - y.append ( p1.y () ); - PointBezier_r ( p1.x (), p1.y (), p2.x (), p2.y (), - p3.x (), p3.y (), p4.x (), p4.y (), 0, wx, wy ); - x.append ( p4.x () ); - y.append ( p4.y () ); - for ( qint32 i = 0; i < x.count(); ++i ) - { - pvector.append( QPointF ( x[i], y[i] ) ); - } - return pvector; -} - -qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ) const -{ - QPainterPath splinePath; - QVector points = GetPoints (p1, p2, p3, p4); - splinePath.moveTo(points[0]); - for (qint32 i = 1; i < points.count(); ++i) - { - splinePath.lineTo(points[i]); - } - return splinePath.length(); -} - -void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, - qreal x3, qreal y3, qreal x4, qreal y4, - qint16 level, QVector &px, QVector &py) -{ - const double curve_collinearity_epsilon = 1e-30; - const double curve_angle_tolerance_epsilon = 0.01; - const double m_angle_tolerance = 0.0; - enum curve_recursion_limit_e { curve_recursion_limit = 32 }; - const double m_cusp_limit = 0.0; - double m_approximation_scale = 1.0; - double m_distance_tolerance_square; - - m_distance_tolerance_square = 0.5 / m_approximation_scale; - m_distance_tolerance_square *= m_distance_tolerance_square; - - if (level > curve_recursion_limit) - { - return; - } - - // Calculate all the mid-points of the line segments - //---------------------- - double x12 = (x1 + x2) / 2; - double y12 = (y1 + y2) / 2; - double x23 = (x2 + x3) / 2; - double y23 = (y2 + y3) / 2; - double x34 = (x3 + x4) / 2; - double y34 = (y3 + y4) / 2; - double x123 = (x12 + x23) / 2; - double y123 = (y12 + y23) / 2; - double x234 = (x23 + x34) / 2; - double y234 = (y23 + y34) / 2; - double x1234 = (x123 + x234) / 2; - double y1234 = (y123 + y234) / 2; - - - // Try to approximate the full cubic curve by a single straight line - //------------------ - double dx = x4-x1; - double dy = y4-y1; - - double d2 = fabs((x2 - x4) * dy - (y2 - y4) * dx); - double d3 = fabs((x3 - x4) * dy - (y3 - y4) * dx); - double da1, da2, k; - - switch ((static_cast(d2 > curve_collinearity_epsilon) << 1) + - static_cast(d3 > curve_collinearity_epsilon)) - { - case 0: - // All collinear OR p1==p4 - //---------------------- - k = dx*dx + dy*dy; - if (k < 0.000000001) - { - d2 = CalcSqDistance(x1, y1, x2, y2); - d3 = CalcSqDistance(x4, y4, x3, y3); - } - else - { - k = 1 / k; - da1 = x2 - x1; - da2 = y2 - y1; - d2 = k * (da1*dx + da2*dy); - da1 = x3 - x1; - da2 = y3 - y1; - d3 = k * (da1*dx + da2*dy); - if (d2 > 0 && d2 < 1 && d3 > 0 && d3 < 1) - { - // Simple collinear case, 1---2---3---4 - // We can leave just two endpoints - return; - } - if (d2 <= 0) - { - d2 = CalcSqDistance(x2, y2, x1, y1); - } - else if (d2 >= 1) - { - d2 = CalcSqDistance(x2, y2, x4, y4); - } - else - { - d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy); - } - - if (d3 <= 0) - { - d3 = CalcSqDistance(x3, y3, x1, y1); - } - else if (d3 >= 1) - { - d3 = CalcSqDistance(x3, y3, x4, y4); - } - else - { - d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy); - } - } - if (d2 > d3) - { - if (d2 < m_distance_tolerance_square) - { - - px.append(x2); - py.append(y2); - //m_points.add(point_d(x2, y2)); - return; - } - } - else - { - if (d3 < m_distance_tolerance_square) - { - - px.append(x3); - py.append(y3); - //m_points.add(point_d(x3, y3)); - return; - } - } - break; - case 1: - // p1,p2,p4 are collinear, p3 is significant - //---------------------- - if (d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy)) - { - if (m_angle_tolerance < curve_angle_tolerance_epsilon) - { - - px.append(x23); - py.append(y23); - //m_points.add(point_d(x23, y23)); - return; - } - - // Angle Condition - //---------------------- - da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2)); - if (da1 >= M_PI) - { - da1 = 2*M_PI - da1; - } - - if (da1 < m_angle_tolerance) - { - - px.append(x2); - py.append(y2); - - px.append(x3); - py.append(y3); - //m_points.add(point_d(x2, y2)); - //m_points.add(point_d(x3, y3)); - return; - } - - if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) - { - if (da1 > m_cusp_limit) - { - - px.append(x3); - py.append(y3); - //m_points.add(point_d(x3, y3)); - return; - } - } - } - break; - - case 2: - // p1,p3,p4 are collinear, p2 is significant - //---------------------- - if (d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy)) - { - if (m_angle_tolerance < curve_angle_tolerance_epsilon) - { - - px.append(x23); - py.append(y23); - //m_points.add(point_d(x23, y23)); - return; - } - - // Angle Condition - //---------------------- - da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); - if (da1 >= M_PI) - { - da1 = 2*M_PI - da1; - } - - if (da1 < m_angle_tolerance) - { - - px.append(x2); - py.append(y2); - - px.append(x3); - py.append(y3); - //m_points.add(point_d(x2, y2)); - //m_points.add(point_d(x3, y3)); - return; - } - - if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) - { - if (da1 > m_cusp_limit) - { - px.append(x2); - py.append(y2); - - //m_points.add(point_d(x2, y2)); - return; - } - } - } - break; - - case 3: - // Regular case - //----------------- - if ((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy)) - { - // If the curvature doesn't exceed the distance_tolerance value - // we tend to finish subdivisions. - //---------------------- - if (m_angle_tolerance < curve_angle_tolerance_epsilon) - { - - px.append(x23); - py.append(y23); - //m_points.add(point_d(x23, y23)); - return; - } - - // Angle & Cusp Condition - //---------------------- - k = atan2(y3 - y2, x3 - x2); - da1 = fabs(k - atan2(y2 - y1, x2 - x1)); - da2 = fabs(atan2(y4 - y3, x4 - x3) - k); - if (da1 >= M_PI) - { - da1 = 2*M_PI - da1; - } - if (da2 >= M_PI) - { - da2 = 2*M_PI - da2; - } - - if (da1 + da2 < m_angle_tolerance) - { - // Finally we can stop the recursion - //---------------------- - - px.append(x23); - py.append(y23); - //m_points.add(point_d(x23, y23)); - return; - } - - if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0) - { - if (da1 > m_cusp_limit) - { - px.append(x2); - py.append(y2); - return; - } - - if (da2 > m_cusp_limit) - { - px.append(x3); - py.append(y3); - return; - } - } - } - break; - default: - break; - } - - // Continue subdivision - //---------------------- - PointBezier_r(x1, y1, x12, y12, x123, y123, x1234, y1234, static_cast(level + 1), px, py); - PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast(level + 1), px, py); -} - -qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2) -{ - qreal dx = x2 - x1; - qreal dy = y2 - y1; - return dx * dx + dy * dy; -} - -QPainterPath VSpline::GetPath() const -{ - QPainterPath splinePath; - QVector points = GetPoints (); - if (points.count() >= 2) - { - for (qint32 i = 0; i < points.count()-1; ++i) - { - splinePath.moveTo(points[i]); - splinePath.lineTo(points[i+1]); - } - } - else - { - qWarning()<<"points.count() < 2"< then x is filled with them; - 1 real + 2 complex -> x[0] is real, x[1] is real part of - complex roots, x[2] - non-negative - imaginary part. - a, b, c - coefficients, as described - Returns: 3 - 3 real roots; - 1 - 1 real root + 2 complex; - 2 - 1 real root + complex roots imaginary part is zero - (i.e. 2 real roots). -*/ -//qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){ -// qreal q,r,r2,q3; -// -// q = (a*a - 3.*b)/9.; -// r = (a*(2.*a*a - 9.*b) + 27.*c)/54.; -// r2 = r*r; -// q3 = pow(q,3); -// if(r2(malloc(3*sizeof(qreal))); -// P1 = curve_coord1; -// P2 = curve_coord2; -// P3 = curve_coord3; -// P4 = curve_coord4; -// Bt = point_coord; -// -// a = -P1 + 3*P2 - 3*P3 + P4; -// b = 3*P1 - 6*P2 + 3*P3; -// c = -3*P1 + 3*P2; -// d = -Bt + P1; -// -// if(Cubic(t, b/a, c/a, d/a) == 3){ -// ret_t = t[2]; -// } else { -// ret_t = t[0]; -// } -// /* -// * Повертається три значення, але експереминтально знайдено що шукане -// * значення знаходиться в третьому. -// */ -// -// free(t); -// if(ret_t<0 || ret_t>1){ -// qDebug()<<"Неправильне значення параметра. фунція calc_t"; -// throw"Неправильне значення параметра. фунція calc_t"; -// } -// return ret_t; -//} -/* - * Функція знаходить підходяще значення параметна t якому відповідає точка на сплайні. - */ -//qreal VSpline::param_t (QPointF pBt)const{ -// qreal t_x, t_y; -// t_x = calc_t (GetPointP1().x(), p2.x(), p3.x(), GetPointP4().x(), pBt.x()); -// t_y = calc_t (GetPointP1().y(), p2.y(), p3.y(), GetPointP4().y(), pBt.y()); -// /* -// * Порівнюємо значення по х і по у і визначаємо найбільше. Це значення і -// * буде шуканим. -// */ -// if(t_x>t_y) -// return t_x; -// else -// return t_y; -//} -// -//void VSpline::Mirror(const QPointF Pmirror){ -// QPointF P1 = p1; -// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y()); -// P1 = QPointF(P1.x() * -1.0, P1.y() * 1.0); -// P1 = QPointF(P1.x() + Pmirror.x(), P1.y() + Pmirror.y()); -// QPointF P2 = p2; -// P2 = QPointF(P2.x() - Pmirror.x(), P2.y() - Pmirror.y()); -// P2 = QPointF(P2.x() * -1.0, P2.y() * 1.0); -// P2 = QPointF(P2.x() + Pmirror.x(), P2.y() + Pmirror.y()); -// QPointF P3 = p3; -// P3 = QPointF(P3.x() - Pmirror.x(), P3.y() - Pmirror.y()); -// P3 = QPointF(P3.x() * -1.0, P3.y() * 1.0); -// P3 = QPointF(P3.x() + Pmirror.x(), P3.y() + Pmirror.y()); -// QPointF P4 = p4; -// P4 = QPointF(P4.x() - Pmirror.x(), P4.y() - Pmirror.y()); -// P4 = QPointF(P4.x() * -1.0, P4.y() * 1.0); -// P4 = QPointF(P4.x() + Pmirror.x(), P4.y() + Pmirror.y()); -// this->ModifiSpl(P1, P2, P3, P4); -//} - -QVector VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, - qreal kAsm2, qreal kCurve) -{ - QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); - p1pX.setAngle( angle1 ); - qreal L = 0, radius = 0, angle = 90; - radius = QLineF(QPointF(p1.x(), p4.y()), p4).length(); - L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 ); - QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y()); - p1p2.setAngle(angle1); - QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y()); - p4p3.setAngle(angle2); - QPointF p2 = p1p2.p2(); - QPointF p3 = p4p3.p2(); - return GetPoints(p1, p2, p3, p4); -} - -VSpline &VSpline::operator =(const VSpline &spline) -{ - this->p1 = spline.GetP1 (); - this->p2 = spline.GetP2 (); - this->p3 = spline.GetP3 (); - this->p4 = spline.GetP4 (); - this->angle1 = spline.GetAngle1 (); - this->angle2 = spline.GetAngle2 (); - this->kAsm1 = spline.GetKasm1(); - this->kAsm2 = spline.GetKasm2(); - this->kCurve = spline.GetKcurve(); - this->points = spline.GetDataPoints(); - this->mode = spline.getMode(); - this->idObject = spline.getIdObject(); - this->_name = spline.name(); - return *this; -} diff --git a/src/geometry/vspline.h b/src/geometry/vspline.h deleted file mode 100644 index 5fc34cc7a..000000000 --- a/src/geometry/vspline.h +++ /dev/null @@ -1,395 +0,0 @@ -/************************************************************************ - ** - ** @file vspline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VSPLINE_H -#define VSPLINE_H - -#include "../container/vpointf.h" - -#include -#include -#include - -class QString; - -#define M_2PI 6.28318530717958647692528676655900576 - -/** - * @brief VSpline клас, що реалізує сплайн. - */ -class VSpline -{ -public: - VSpline(); - /** - * @brief VSpline конструктор. - * @param spline сплайн з якого копіюємо. - */ - VSpline (const VSpline &spline ); - /** - * @brief VSpline конструктор. - * @param p1 початкова точка сплайна. - * @param p4 кінцева точка сплайна. - * @param angle1 кут в градусах першої напрямної. - * @param angle2 кут в градусах другої напрямної. - * @param kCurve коефіцієнт кривизни сплайна. - * @param kAsm1 коефіцієнт довжини першої напрямної. - * @param kAsm2 коефіцієнт довжини другої напрямної. - */ - VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, - qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation, - qint64 idObject = 0); - /** - * @brief VSpline конструктор. - * @param p1 початкова точка сплайну. - * @param p2 перша контролююча точка сплайну. - * @param p3 друга контролююча точка сплайну. - * @param p4 кінцева точка сплайну. - */ - VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, - qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); - /** - * @brief ModifiSpl модифікує сплайн. - * @param p1 початкова точка сплайну. - * @param p4 кінцева точка сплайну. - * @param angle1 кут в градусах першої напрямної. - * @param angle2 кут в градусах другої напрямної. - * @param kCurve коефіцієнт кривизни сплайну. - * @param kAsm1 коефіцієнт довжини першої напрямної. - * @param kAsm2 коефіцієнт довжини другої напрямної. - */ - void ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, - qreal kCurve); - /** - * @brief ModifiSpl модифікує сплайн. - * @param p1 початкова точка сплайну. - * @param p2 перша контролююча точка сплайну. - * @param p3 друга контролююча точка сплайну. - * @param p4 кінцева точка сплайну. - */ - void ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, - const qreal &kCurve); - /** - * @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки. - * @param pRotate точка навколо якої повертаємо. - * @param angle кут в градусах. - */ -// void RotationSpl ( QPointF pRotate, qreal angle ); - /** - * @brief BiasSpl зміщує сплайн. - * @param mx зміщення по х координаті. - * @param my зміщення по у координаті. - */ -// void BiasSpl ( qreal mx, qreal my ); - /** - * @brief GetP1 повертає першу точку сплайну. - * @return перша точка сплайну. - */ - qint64 GetP1 () const {return p1;} - /** - * @brief GetPointP1 - * @return - */ - VPointF GetPointP1() const; - /** - * @brief GetP2 повертує першу контрольну точку сплайну. - * @return перша контрольна точка сплайну. - */ - inline QPointF GetP2 () const {return p2;} - /** - * @brief GetP3 повертає другу контрольну точку сплайну. - * @return друга контрольна точка сплайну. - */ - inline QPointF GetP3 () const {return p3;} - /** - * @brief GetP4 повертає останню точку сплайну. - * @return остання точка сплайну. - */ - inline qint64 GetP4 () const {return p4;} - /** - * @brief GetPointP4 - * @return - */ - VPointF GetPointP4 () const; - /** - * @brief GetAngle1 повертає кут першої напрямної. - * @return кут в градусах. - */ - inline qreal GetAngle1 () const {return angle1;} - /** - * @brief GetAngle2 повертає кут другої напрямної. - * @return кут в градусах. - */ - inline qreal GetAngle2() const {return angle2;} - /** - * @brief GetLength повертає довжину сплайну. - * @return довжина сплайну. - */ - qreal GetLength () const; - /** - * @brief GetName - * @return - */ - QString GetName () const; - /** - * @brief GetKasm1 - * @return - */ - inline qreal GetKasm1() const {return kAsm1;} - /** - * @brief GetKasm2 - * @return - */ - inline qreal GetKasm2() const {return kAsm2;} - /** - * @brief GetKcurve - * @return - */ - inline qreal GetKcurve() const {return kCurve;} - /** - * @brief GetDataPoints - * @return - */ - inline const QHash GetDataPoints() const {return points;} - /** - * @brief CrossingSplLine перевіряє перетин сплайну з лінією. - * @param line лінія з якою перевіряється перетин. - * @param intersectionPoint точка перетину. - * @return результат перевірки. - */ - QLineF::IntersectType CrossingSplLine(const QLineF &line, QPointF *intersectionPoint ) const; - /** - * @brief CutSpline розрізає сплайн. - * @param length дожина першого сплайну. - * @param curFir перший сплайн. - * @param curSec другий сплайн. - */ -// void CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const; - /** - * @brief CutSpline розрізає сплайн. - * @param point точка що ділить сплайн. - * @param curFir перший сплайн. - * @param curSec другий сплайн. - */ -// void CutSpline (QPointF point, VSpline* curFir, VSpline* curSec ) const; - /** - * @brief PutAlongSpl розміщає точку на сплайні. - * @param moveP точка яка розміщується на сплайні. - * @param move довжина від початку сплайну. - */ -// void PutAlongSpl ( QPointF &moveP, qreal move ) const; - /** - * @brief GetPoints повертає точки з яких складається сплайн. - * @return список точок. - */ - QVector GetPoints () const; - /** - * @brief GetPath повертає шлях сплайну. - * @return шлях. - */ - QPainterPath GetPath() const; - /** - * @brief Mirror вертикальне дзеркалення сплайну відносно точки. - * @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну. - */ -// void Mirror(const QPointF Pmirror); - /** - * @brief getMode - * @return - */ - inline Draw::Draws getMode() const {return mode;} - /** - * @brief setMode - * @param value - */ - inline void setMode(const Draw::Draws &value) {mode = value;} - /** - * @brief SplinePoints - * @param p1 - * @param p4 - * @param angle1 - * @param angle2 - * @param kAsm1 - * @param kAsm2 - * @param kCurve - * @return - */ - static QVector SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, - qreal kAsm2, qreal kCurve); - /** - * @brief getIdObject - * @return - */ - inline qint64 getIdObject() const {return idObject;} - /** - * @brief setIdObject - * @param value - */ - inline void setIdObject(const qint64 &value) {idObject = value;} - /** - * @brief operator = - * @param spl - * @return - */ - VSpline &operator=(const VSpline &spl); - /** - * @brief name - * @return - */ - QString name() const {return _name;} - /** - * @brief setName - * @param name - */ - void setName(const QString &name) {_name = name;} -protected: - /** - * @brief GetPoints повертає точки з яких складається сплайн. - * @param p1 початкова точка сплайну. - * @param p2 перша контролююча точка сплайну. - * @param p3 друга контролююча точка сплайну. - * @param p4 кінцева точка сплайну. - * @return список точок. - */ - static QVector GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ); -private: - /** - * @brief p1 початкова точка сплайну - */ - qint64 p1; // перша точка - /** - * @brief p2 перша контрольна точка сплайну. - */ - QPointF p2; // друга точка - /** - * @brief p3 друга контрольна точка сплайну. - */ - QPointF p3; // третя точка - /** - * @brief p4 кінцеві точка сплайну. - */ - qint64 p4; // четверта точка - /** - * @brief angle1 кут в градусах першої напрямної. - */ - qreal angle1; // кут нахилу дотичної в першій точці - /** - * @brief angle2 кут в градусах другої напрямної. - */ - qreal angle2; // кут нахилу дотичної в другій точці - /** - * @brief kAsm1 - */ - qreal kAsm1; - /** - * @brief kAsm2 - */ - qreal kAsm2; - /** - * @brief kCurve - */ - qreal kCurve; - /** - * @brief points - */ - QHash points; - /** - * @brief mode - */ - Draw::Draws mode; - /** - * @brief idObject - */ - qint64 idObject; - /** - * @brief _name - */ - QString _name; - /** - * @brief LengthBezier повертає дожину сплайну за його чотирьма точками. - * @param p1 початкова точка сплайну. - * @param p2 перша контролююча точка сплайну. - * @param p3 друга контролююча точка сплайну. - * @param p4 кінцева точка сплайну. - * @return дожина сплайну. - */ - qreal LengthBezier (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ) const; - /** - * @brief PointBezier_r знаходить точки сплайну по його чотирьом точках. - * @param x1 х координата першої точки сплайну. - * @param y1 у координата другої точки сплайну. - * @param x2 х координата першої контрольної точки сплайну. - * @param y2 у координата першої контрольної точки сплайну. - * @param x3 х координата другої контрольної точки сплайну. - * @param y3 у координата другої контрольної точки сплайну. - * @param x4 х координата кінцевої точки сплайну. - * @param y4 у координата кінцевої точки сплайну. - * @param level рівень рекурсії. Напочатку повинен дорівнювати 0. - * @param px список х координат точок сплайну. - * @param py список у коодринат сплайну. - */ - static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4, - qint16 level, QVector &px, QVector &py); - /** - * @brief CalcSqDistance розраховує довжину між точками. - * @param x1 х координата першої точки. - * @param y1 у координата другої точки. - * @param x2 х координата першої точки. - * @param y2 у координата другої точки. - * @return довжину. - */ - static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2); -// /** -// * @brief Cubic знаходить розв'язок кубічного рівняння. -// * @param x коефіцієнт. -// * @param a коефіцієнт. -// * @param b коефіцієнт. -// * @param c коефіцієнт. -// * @return повертає корені рівняння. -// */ -// static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c); - /** - * @brief calc_t знаходить параметр t якому відповідає точка на сплайні. - * @param curve_coord1 координата Х або У кривої. - * @param curve_coord2 координата Х або У кривої. - * @param curve_coord3 координата Х або У кривої. - * @param curve_coord4 координата Х або У кривої. - * @param point_coord координата Х або У точки на кривій. - * @return - */ -// static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, qreal curve_coord4, -// qreal point_coord)const; - /** - * @brief param_t знаходить підходяще значення параметра t якому відповідає точка на сплайні - * @param pBt точка для якої шукається значення параметра t. - * @return підходяще значення t. - */ -// qreal param_t (QPointF pBt)const; -}; - -#endif // VSPLINE_H diff --git a/src/geometry/vsplinepath.cpp b/src/geometry/vsplinepath.cpp deleted file mode 100644 index 79b2acf76..000000000 --- a/src/geometry/vsplinepath.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/************************************************************************ - ** - ** @file vsplinepath.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vsplinepath.h" -#include "../exception/vexception.h" - -VSplinePath::VSplinePath() - : path(QVector()), kCurve(1), mode(Draw::Calculation), points(QHash()), idObject(0), - _name(QString()){} - -VSplinePath::VSplinePath(const QHash *points, qreal kCurve, Draw::Draws mode, qint64 idObject) - : path(QVector()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject), _name(QString()) -{} - -VSplinePath::VSplinePath(const VSplinePath &splPath) - : path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()), - idObject(splPath.getIdObject()), _name(splPath.name()){} - -void VSplinePath::append(const VSplinePoint &point) -{ - path.append(point); - _name = QString("SplPath"); - for (qint32 i = 1; i <= this->Count(); ++i) - { - VSpline spl = this->GetSpline(i); - VPointF first = spl.GetPointP1(); - VPointF second = spl.GetPointP4(); - QString splName = QString("_%1_%2").arg(first.name(), second.name()); - _name.append(splName); - } -} - -qint32 VSplinePath::Count() const -{ - if (path.size() == 0) - { - return 0; - } - else - { - return path.size() - 1; - } -} - -VSpline VSplinePath::GetSpline(qint32 index) const -{ - if (Count()<1) - { - throw VException(tr("Not enough points to create the spline.")); - } - if (index < 1 || index > Count()) - { - 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(), - path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve); - return spl; -} - -QPainterPath VSplinePath::GetPath() const -{ - QPainterPath painterPath; - for (qint32 i = 1; i <= Count(); ++i) - { - VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); - painterPath.addPath(spl.GetPath()); - } - return painterPath; -} - -QVector VSplinePath::GetPathPoints() const -{ - QVector pathPoints; - for (qint32 i = 1; i <= Count(); ++i) - { - VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); - QVector splP = spl.GetPoints(); - for (qint32 j = 0; j < splP.size(); ++j) - { - pathPoints.append(splP[j]); - } - } - return pathPoints; -} - -qreal VSplinePath::GetLength() const -{ - qreal length = 0; - for (qint32 i = 1; i <= Count(); ++i) - { - VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), - path[i].KAsm1(), kCurve); - length += spl.GetLength(); - } - return length; -} - -void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point) -{ - if (indexSpline < 1 || indexSpline > Count()) - { - throw VException(tr("This spline is not exist.")); - } - if (pos == SplinePoint::FirstPoint) - { - path[indexSpline-1] = point; - } - else - { - path[indexSpline] = point; - } -} - -VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const -{ - if (indexSpline < 1 || indexSpline > Count()) - { - throw VException(tr("This spline is not exist.")); - } - if (pos == SplinePoint::FirstPoint) - { - return path.at(indexSpline-1); - } - else - { - return path.at(indexSpline); - } -} - -VSplinePath &VSplinePath::operator =(const VSplinePath &path) -{ - this->path = path.GetSplinePath(); - this->kCurve = path.getKCurve(); - this->mode = path.getMode(); - this->points = path.GetDataPoints(); - this->idObject = path.getIdObject(); - this->_name = path.name(); - return *this; -} - -VSplinePoint & VSplinePath::operator[](ptrdiff_t indx) -{ - return path[indx]; -} diff --git a/src/geometry/vsplinepath.h b/src/geometry/vsplinepath.h deleted file mode 100644 index 446c0d7e4..000000000 --- a/src/geometry/vsplinepath.h +++ /dev/null @@ -1,216 +0,0 @@ -/************************************************************************ - ** - ** @file vsplinepath.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VSPLINEPATH_H -#define VSPLINEPATH_H - -#include "vsplinepoint.h" -#include "../container/vpointf.h" -#include "vspline.h" -#include - -namespace SplinePoint -{ - /** - * @brief The Position enum - */ - enum Position { FirstPoint, LastPoint }; - Q_DECLARE_FLAGS(Positions, Position) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions ) - -/** - * @brief The VSplinePath клас, що розраховує шлях сплайнів. - */ -class VSplinePath -{ - Q_DECLARE_TR_FUNCTIONS(VSplinePath) -public: - /** - * @brief VSplinePath конструктор по замовчуванню. - */ - VSplinePath(); - /** - * @brief VSplinePath конструктор по замовчуванню. - */ - VSplinePath(const QHash *points, qreal kCurve = 1, - Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); - /** - * @brief VSplinePath - * @param splPath - */ - VSplinePath(const VSplinePath& splPath); - /** - * @brief append додає точку сплайну до шляху. - * @param point точка. - */ - void append(const VSplinePoint &point); - /** - * @brief Count - * @return - */ - qint32 Count() const; - /** - * @brief CountPoint - * @return - */ - inline qint32 CountPoint() const {return path.size();} - /** - * @brief GetSpline - * @param index - * @return - */ - VSpline GetSpline(qint32 index) const; - /** - * @brief GetPath - * @return - */ - QPainterPath GetPath() const; - /** - * @brief GetPathPoints - * @return - */ - QVector GetPathPoints() const; - /** - * @brief GetSplinePath - * @return - */ - inline QVector GetSplinePath() const {return path;} - /** - * @brief GetLength - * @return - */ - qreal GetLength() const; - /** - * @brief GetDataPoints - * @return - */ - inline QHash GetDataPoints() const {return points;} - /** - * @brief UpdatePoint - * @param indexSpline - * @param pos - * @param point - */ - void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point); - /** - * @brief GetSplinePoint - * @param indexSpline - * @param pos - * @return - */ - VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const; - /** - * @brief Clear очищає шлях сплайнів. - */ - inline void Clear() {path.clear();} - /** - * @brief getKCurve - * @return - */ - inline qreal getKCurve() const {return kCurve;} - /** - * @brief setKCurve - * @param value - */ - inline void setKCurve(const qreal &value) {kCurve = value;} - /** - * @brief GetPoint - * @return - */ - inline const QVector *GetPoint() const {return &path;} - /** - * @brief operator = - * @param path - * @return - */ - VSplinePath &operator=(const VSplinePath &path); - /** - * @brief operator [] - * @param indx - * @return - */ - VSplinePoint &operator[](ptrdiff_t indx); - /** - * @brief getMode - * @return - */ - inline Draw::Draws getMode() const {return mode;} - /** - * @brief setMode - * @param value - */ - inline void setMode(const Draw::Draws &value) {mode = value;} - /** - * @brief getIdObject - * @return - */ - inline qint64 getIdObject() const {return idObject;} - /** - * @brief setIdObject - * @param value - */ - inline void setIdObject(const qint64 &value) {idObject = value;} - /** - * @brief name - * @return - */ - QString name() const {return _name;} - /** - * @brief setName - * @param name - */ - void setName(const QString &name) {_name = name;} -protected: - /** - * @brief path вектор з точок сплайна. - */ - QVector path; - /** - * @brief kCurve - */ - qreal kCurve; - /** - * @brief mode - */ - Draw::Draws mode; - /** - * @brief points - */ - QHash points; - /** - * @brief idObject - */ - qint64 idObject; - /** - * @brief _name - */ - QString _name; -}; - -#endif // VSPLINEPATH_H diff --git a/src/geometry/vsplinepoint.h b/src/geometry/vsplinepoint.h deleted file mode 100644 index 9d3bd4667..000000000 --- a/src/geometry/vsplinepoint.h +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************ - ** - ** @file vsplinepoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VSPLINEPOINT_H -#define VSPLINEPOINT_H - -#include - -/** - * @brief The VSplinePoint клас, що містить у собі інформацію про точки сплайну. - */ -class VSplinePoint -{ -public: - /** - * @brief VSplinePoint конструктор по замповчуванню. - */ - VSplinePoint(); - /** - * @brief VSplinePoint конструктор. - * @param pSpline точка сплайну. - * @param angle кут дотичної сплайна. - * @param factor коефіцієнт довжини дотичної. - */ - VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2); - /** - * @brief VSplinePoint - * @param point - */ - VSplinePoint(const VSplinePoint &point); - ~VSplinePoint() {} - /** - * @brief P повертає точку. - * @return точка. - */ - inline qint64 P() const {return pSpline;} - /** - * @brief SetP - * @param value - */ - inline void SetP(const qint64 &value) {pSpline = value;} - /** - * @brief Angle1 повертає кут дотичної сплайна. - * @return кут в градусах. - */ - inline qreal Angle1() const {return angle+180;} - /** - * @brief SetAngle - * @param value - */ - inline void SetAngle(const qreal &value) {angle = value;} - /** - * @brief Angle2 повертає кут дотичної сплайна. - * @return кут в градусах. - */ - inline qreal Angle2() const {return angle;} - /** - * @brief KAsm1 повертає коефіцієнт довжини дотичної. - * @return коефіцієнт. - */ - inline qreal KAsm1() const {return kAsm1;} - /** - * @brief SetKAsm1 - * @param value - */ - inline void SetKAsm1(const qreal &value) {kAsm1 = value;} - /** - * @brief KAsm2 повертає коефіцієнт довжини дотичної. - * @return коефіцієнт. - */ - inline qreal KAsm2() const {return kAsm2;} - /** - * @brief SetKAsm2 - * @param value - */ - inline void SetKAsm2(const qreal &value) {kAsm2 = value;} -protected: - /** - * @brief pSpline точка сплайну. - */ - qint64 pSpline; - /** - * @brief angle кут дотичної сплайну. - */ - qreal angle; - /** - * @brief kAsm1 коефіцієнт довжини дотичної сплайну. - */ - qreal kAsm1; - /** - * @brief kAsm2 коефіцієнт довжини дотичної сплайну. - */ - qreal kAsm2; -}; - -Q_DECLARE_METATYPE(VSplinePoint) - -#endif // VSPLINEPOINT_H diff --git a/src/libs/ifc/exception/exception.pri b/src/libs/ifc/exception/exception.pri new file mode 100644 index 000000000..a0b16deb2 --- /dev/null +++ b/src/libs/ifc/exception/exception.pri @@ -0,0 +1,20 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vexceptionobjecterror.h \ + $$PWD/vexceptionemptyparameter.h \ + $$PWD/vexceptionconversionerror.h \ + $$PWD/vexceptionbadid.h \ + $$PWD/vexception.h \ + $$PWD/vexceptionwrongid.h \ + $$PWD/vexceptionundo.h + +SOURCES += \ + $$PWD/vexceptionobjecterror.cpp \ + $$PWD/vexceptionemptyparameter.cpp \ + $$PWD/vexceptionconversionerror.cpp \ + $$PWD/vexceptionbadid.cpp \ + $$PWD/vexception.cpp \ + $$PWD/vexceptionwrongid.cpp \ + $$PWD/vexceptionundo.cpp diff --git a/src/libs/ifc/exception/vexception.cpp b/src/libs/ifc/exception/vexception.cpp new file mode 100644 index 000000000..051c6d60f --- /dev/null +++ b/src/libs/ifc/exception/vexception.cpp @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file vexception.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vexception.h" +#include +#include +#include +#include +#include + +Q_LOGGING_CATEGORY(vExcep, "v.excep") + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VException constructor exception + * @param what string with error + */ +VException::VException(const QString &what):QException(), what(what), moreInfo(QString()) +{ + Q_ASSERT_X(what.isEmpty() == false, Q_FUNC_INFO, "Error message is empty"); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VException copy constructor + * @param e exception + */ +VException::VException(const VException &e):what(e.What()), moreInfo(e.MoreInformation()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VException &VException::operator=(const VException &e) +{ + if ( &e == this ) + { + return *this; + } + this->what = e.What(); + this->moreInfo = e.MoreInformation(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return error message + */ +QString VException::ErrorMessage() const +{ + QString error = QString("Exception: %1").arg(what); + return error; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CriticalMessageBox show Critical Message Box. + * @param situation main text message box. + */ +void VException::CriticalMessageBox(const QString &situation, QWidget * parent) const +{ + QMessageBox msgBox(parent); + msgBox.setWindowTitle(tr("Critical error!")); + msgBox.setText(situation); + msgBox.setInformativeText(ErrorMessage()); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + if (moreInfo.isEmpty() == false) + { + msgBox.setDetailedText(DetailedInformation()); + } + msgBox.setIcon(QMessageBox::Critical); + QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + QGridLayout* layout = static_cast(msgBox.layout()); + SCASSERT(layout != nullptr); + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + //Disable Qt::WaitCursor for error message. +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + qCDebug(vExcep)<<"Critical error!"< + ** @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 + ** 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 VEXCEPTION_H +#define VEXCEPTION_H + +#include +#include +#include +#include "ifcdef.h" + +class QWidget; + +/** + * @brief The VException class parent for all exception. Could be use for abstract exception + */ +class VException : public QException +{ + Q_DECLARE_TR_FUNCTIONS(VException) +public: + VException(const QString &what); + VException(const VException &e); + VException &operator=(const VException &e); + virtual ~VException() V_NOEXCEPT_EXPR (true){} + + Q_NORETURN virtual void raise() const; + // cppcheck-suppress unusedFunction + virtual VException *clone() const; + virtual QString ErrorMessage() const; + virtual QString DetailedInformation() const; + QString What() const; + virtual void CriticalMessageBox(const QString &situation, QWidget *parent = nullptr) const; + void AddMoreInformation(const QString &info); + QString MoreInformation() const; +protected: + /** @brief what string with error */ + QString what; + + /** @brief moreInfo more information about error */ + QString moreInfo; + + QString MoreInfo(const QString &detInfo) const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief What return string with error + * @return string with error + */ +inline QString VException::What() const +{ + return what; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MoreInformation return more information for error + * @return information + */ +inline QString VException::MoreInformation() const +{ + return moreInfo; +} + +#endif // VEXCEPTION_H diff --git a/src/libs/ifc/exception/vexceptionbadid.cpp b/src/libs/ifc/exception/vexceptionbadid.cpp new file mode 100644 index 000000000..7b2dad8f1 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionbadid.cpp @@ -0,0 +1,87 @@ +/************************************************************************ + ** + ** @file vexceptionbadid.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vexceptionbadid.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionBadId exception bad id + * @param what string with error + * @param id id + */ +VExceptionBadId::VExceptionBadId(const QString &what, const quint32 &id) + :VException(what), id(id), key(QString()){} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionBadId exception bad id + * @param what string with error + * @param key string key + */ +VExceptionBadId::VExceptionBadId(const QString &what, const QString &key) + :VException(what), id(NULL_ID), key(key){} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionBadId copy constructor + * @param e exception + */ +VExceptionBadId::VExceptionBadId(const VExceptionBadId &e) + :VException(e), id(e.BadId()), key(e.BadKey()){} + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionBadId &VExceptionBadId::operator=(const VExceptionBadId &e) +{ + if ( &e == this ) + { + return *this; + } + VException::operator=(e); + this->id = e.BadId(); + this->key = e.BadKey(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return main error message + */ +QString VExceptionBadId::ErrorMessage() const +{ + QString error; + if (key.isEmpty()) + { + error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id); + } + else + { + error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key); + } + return error; +} diff --git a/src/libs/ifc/exception/vexceptionbadid.h b/src/libs/ifc/exception/vexceptionbadid.h new file mode 100644 index 000000000..59fe25d15 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionbadid.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vexceptionbadid.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VEXCEPTIONBADID_H +#define VEXCEPTIONBADID_H + +#include "vexception.h" + +/** + * @brief The VExceptionBadId class for exception bad id + */ +class VExceptionBadId : public VException +{ +public: + VExceptionBadId(const QString &what, const quint32 &id); + VExceptionBadId(const QString &what, const QString &key); + VExceptionBadId(const VExceptionBadId &e); + VExceptionBadId &operator=(const VExceptionBadId &e); + virtual ~VExceptionBadId() V_NOEXCEPT_EXPR (true){} + virtual QString ErrorMessage() const; + quint32 BadId() const; + QString BadKey() const; +protected: + /** @brief id id */ + quint32 id; + + /** @brief key key */ + QString key; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief BadId return bad id + * @return id + */ +inline quint32 VExceptionBadId::BadId() const +{ + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief BadKey return bad key + * @return key + */ +inline QString VExceptionBadId::BadKey() const +{ + return key; +} + +#endif // VEXCEPTIONBADID_H diff --git a/src/libs/ifc/exception/vexceptionconversionerror.cpp b/src/libs/ifc/exception/vexceptionconversionerror.cpp new file mode 100644 index 000000000..f30cbc8a5 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionconversionerror.cpp @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file vexceptionconversionerror.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vexceptionconversionerror.h" + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionConversionError exception conversion error + * @param what string with error + * @param str string, where happend error + */ +VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str) + :VException(what), str(str) +{ + Q_ASSERT_X(str.isEmpty() == false, Q_FUNC_INFO, "Error converting string is empty"); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionConversionError copy constructor + * @param e exception + */ +VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e) + :VException(e), str(e.String()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionConversionError::~VExceptionConversionError() V_NOEXCEPT_EXPR (true) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return main error message + */ +QString VExceptionConversionError::ErrorMessage() const +{ + QString error = QString("ExceptionConversionError: %1 \"%2\"").arg(what, str); + return error; +} diff --git a/src/exception/vexceptionconversionerror.h b/src/libs/ifc/exception/vexceptionconversionerror.h similarity index 59% rename from src/exception/vexceptionconversionerror.h rename to src/libs/ifc/exception/vexceptionconversionerror.h index 9f725b28f..bf82b2f08 100644 --- a/src/exception/vexceptionconversionerror.h +++ b/src/libs/ifc/exception/vexceptionconversionerror.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vexceptionconversionerror.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -37,34 +37,24 @@ class VExceptionConversionError : public VException { public: - /** - * @brief VExceptionConversionError exception conversion error - * @param what string with error - * @param str string, where happend error - */ - VExceptionConversionError(const QString &what, const QString &str); - /** - * @brief VExceptionConversionError copy constructor - * @param e exception - */ - VExceptionConversionError(const VExceptionConversionError &e) - :VException(e), str(e.String()){} - virtual ~VExceptionConversionError() noexcept (true) {} - /** - * @brief ErrorMessage return main error message - * @return main error message - */ + VExceptionConversionError(const QString &what, const QString &str); + VExceptionConversionError(const VExceptionConversionError &e); + virtual ~VExceptionConversionError() V_NOEXCEPT_EXPR (true); virtual QString ErrorMessage() const; - /** - * @brief String return string, where happend error - * @return string - */ - inline QString String() const {return str;} + QString String() const; protected: - /** - * @brief str string, where happend error - */ + /** @brief str string, where happend error */ QString str; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief String return string, where happend error + * @return string + */ +inline QString VExceptionConversionError::String() const +{ + return str; +} + #endif // VEXCEPTIONCONVERSIONERROR_H diff --git a/src/exception/vexceptionemptyparameter.cpp b/src/libs/ifc/exception/vexceptionemptyparameter.cpp similarity index 56% rename from src/exception/vexceptionemptyparameter.cpp rename to src/libs/ifc/exception/vexceptionemptyparameter.cpp index c3fdf6b7a..b85b721d0 100644 --- a/src/exception/vexceptionemptyparameter.cpp +++ b/src/libs/ifc/exception/vexceptionemptyparameter.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vexceptionemptyparameter.cpp - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -27,9 +27,16 @@ *************************************************************************/ #include "vexceptionemptyparameter.h" +#include +#include -#include - +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionEmptyParameter exception empty parameter + * @param what string with error + * @param name name of attribute where error + * @param domElement dom element + */ VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement) : VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1) @@ -42,14 +49,36 @@ VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QS lineNumber = domElement.lineNumber(); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionEmptyParameter copy constructor + * @param e exception + */ +VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e) + :VException(e), name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionEmptyParameter::~VExceptionEmptyParameter() V_NOEXCEPT_EXPR (true) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return main error message + */ QString VExceptionEmptyParameter::ErrorMessage() const { QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name); return error; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DetailedInformation return detailed information about error + * @return detailed information + */ QString VExceptionEmptyParameter::DetailedInformation() const { - QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText); - return detail; + return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText)); } diff --git a/src/libs/ifc/exception/vexceptionemptyparameter.h b/src/libs/ifc/exception/vexceptionemptyparameter.h new file mode 100644 index 000000000..fc188acb3 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionemptyparameter.h @@ -0,0 +1,105 @@ +/************************************************************************ + ** + ** @file vexceptionemptyparameter.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VEXCEPTIONEMPTYPARAMETER_H +#define VEXCEPTIONEMPTYPARAMETER_H + +#include "vexception.h" + +class QDomElement; + +/** + * @brief The VExceptionEmptyParameter class for exception empty parameter + */ +class VExceptionEmptyParameter : public VException +{ +public: + VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement); + VExceptionEmptyParameter(const VExceptionEmptyParameter &e); + virtual ~VExceptionEmptyParameter() V_NOEXCEPT_EXPR (true); + virtual QString ErrorMessage() const; + virtual QString DetailedInformation() const; + QString Name() const; + QString TagText() const; + QString TagName() const; + qint32 LineNumber() const; +protected: + /** @brief name name attribute */ + QString name; + + /** @brief tagText tag text */ + QString tagText; + + /** @brief tagName tag name */ + QString tagName; + + /** @brief lineNumber line number */ + qint32 lineNumber; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Name return name of attribute where error + * @return name + */ +inline QString VExceptionEmptyParameter::Name() const +{ + return name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagText return tag text + * @return tag text + */ +inline QString VExceptionEmptyParameter::TagText() const +{ + return tagText; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagName return tag name + * @return tag name + */ +inline QString VExceptionEmptyParameter::TagName() const +{ + return tagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineNumber return line number of tag + * @return line number + */ +inline qint32 VExceptionEmptyParameter::LineNumber() const +{ + return lineNumber; +} + +#endif // VEXCEPTIONEMPTYPARAMETER_H diff --git a/src/exception/vexceptionobjecterror.cpp b/src/libs/ifc/exception/vexceptionobjecterror.cpp similarity index 59% rename from src/exception/vexceptionobjecterror.cpp rename to src/libs/ifc/exception/vexceptionobjecterror.cpp index 7b77be4a3..b97257ddd 100644 --- a/src/exception/vexceptionobjecterror.cpp +++ b/src/libs/ifc/exception/vexceptionobjecterror.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file vexceptionobjecterror.cpp - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -28,9 +28,16 @@ #include "vexceptionobjecterror.h" #include +#include +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionObjectError exception object error + * @param what string with error + * @param domElement dom element + */ 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) { Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); QTextStream stream(&tagText); @@ -39,32 +46,32 @@ VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElem lineNumber = domElement.lineNumber(); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionObjectError copy constructor + * @param e exception + */ +VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e) + :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return main error message + */ QString VExceptionObjectError::ErrorMessage() const { QString error = QString("ExceptionObjectError: %1").arg(what); return error; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DetailedInformation return detailed information about error + * @return detailed information + */ QString VExceptionObjectError::DetailedInformation() const { - QString detail; - if (moreInfo.isEmpty() == false) - { - QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); - detail = QString("%1\n%2").arg(moreInfo, i); - } - else - { - detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText); - } - return detail; -} - -void VExceptionObjectError::AddMoreInformation(const QString &info) -{ - if (info.isEmpty()) - { - qWarning()<<"Error additional information is empty."<moreInfo.append(info); + return MoreInfo(QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText)); } diff --git a/src/libs/ifc/exception/vexceptionobjecterror.h b/src/libs/ifc/exception/vexceptionobjecterror.h new file mode 100644 index 000000000..1a33432a4 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionobjecterror.h @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file vexceptionobjecterror.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VEXCEPTIONOBJECTERROR_H +#define VEXCEPTIONOBJECTERROR_H + +#include "vexception.h" + +class QDomElement; + +/** + * @brief The VExceptionObjectError class for exception object error + */ +class VExceptionObjectError : public VException +{ +public: + VExceptionObjectError(const QString &what, const QDomElement &domElement); + VExceptionObjectError(const VExceptionObjectError &e); + virtual ~VExceptionObjectError() V_NOEXCEPT_EXPR (true) {} + virtual QString ErrorMessage() const; + virtual QString DetailedInformation() const; + QString TagText() const; + QString TagName() const; + qint32 LineNumber() const; +protected: + /** @brief tagText tag text */ + QString tagText; + + /** @brief tagName tag name */ + QString tagName; + + /** @brief lineNumber line number */ + qint32 lineNumber; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagText return tag text + * @return tag text + */ +inline QString VExceptionObjectError::TagText() const +{ + return tagText; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagName return tag name + * @return tag name + */ +inline QString VExceptionObjectError::TagName() const +{ + return tagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineNumber return line number in file + * @return line number + */ +inline qint32 VExceptionObjectError::LineNumber() const +{ + return lineNumber; +} + +#endif // VEXCEPTIONOBJECTERROR_H diff --git a/src/libs/ifc/exception/vexceptionundo.cpp b/src/libs/ifc/exception/vexceptionundo.cpp new file mode 100644 index 000000000..c93cd5290 --- /dev/null +++ b/src/libs/ifc/exception/vexceptionundo.cpp @@ -0,0 +1,43 @@ +/************************************************************************ + ** + ** @file vexceptionundo.cpp + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 + ** + ** @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) 2014 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 "vexceptionundo.h" + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionUndo::VExceptionUndo(const QString &what) + :VException(what) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionUndo::VExceptionUndo(const VExceptionUndo &e) + :VException(e) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VExceptionUndo::~VExceptionUndo() V_NOEXCEPT_EXPR (true) +{} diff --git a/src/exception/vexception.cpp b/src/libs/ifc/exception/vexceptionundo.h similarity index 72% rename from src/exception/vexception.cpp rename to src/libs/ifc/exception/vexceptionundo.h index 478a7613f..58521d899 100644 --- a/src/exception/vexception.cpp +++ b/src/libs/ifc/exception/vexceptionundo.h @@ -1,14 +1,14 @@ /************************************************************************ ** - ** @file vexception.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file vexceptionundo.h + ** @author Roman Telezhynskyi + ** @date 23 6, 2014 ** ** @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 + ** Copyright (C) 2014 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify @@ -26,15 +26,17 @@ ** *************************************************************************/ +#ifndef VEXCEPTIONUNDO_H +#define VEXCEPTIONUNDO_H + #include "vexception.h" -VException::VException(const QString &what):QException(), what(what) +class VExceptionUndo : public VException { - Q_ASSERT_X(what.isEmpty() == false, Q_FUNC_INFO, "Error message is empty"); -} +public: + VExceptionUndo(const QString &what); + VExceptionUndo(const VExceptionUndo &e); + virtual ~VExceptionUndo() V_NOEXCEPT_EXPR (true); +}; -QString VException::ErrorMessage() const -{ - QString error = QString("Exception: %1").arg(what); - return error; -} +#endif // VEXCEPTIONUNDO_H diff --git a/src/libs/ifc/exception/vexceptionwrongid.cpp b/src/libs/ifc/exception/vexceptionwrongid.cpp new file mode 100644 index 000000000..edc4c989e --- /dev/null +++ b/src/libs/ifc/exception/vexceptionwrongid.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file vexceptionwrongparameterid.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vexceptionwrongid.h" +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionWrongId exception wrong parameter id + * @param what string with error + * @param domElement som element + */ +VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement) + :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) +{ + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + QTextStream stream(&tagText); + domElement.save(stream, 4); + tagName = domElement.tagName(); + lineNumber = domElement.lineNumber(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VExceptionWrongId copy constructor + * @param e exception + */ +VExceptionWrongId::VExceptionWrongId(const VExceptionWrongId &e) + :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ErrorMessage return main error message + * @return main error message + */ +QString VExceptionWrongId::ErrorMessage() const +{ + QString error = QString("ExceptionWrongId: %1").arg(what); + return error; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DetailedInformation return detailed information about error + * @return detailed information + */ +QString VExceptionWrongId::DetailedInformation() const +{ + return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText)); +} diff --git a/src/libs/ifc/exception/vexceptionwrongid.h b/src/libs/ifc/exception/vexceptionwrongid.h new file mode 100644 index 000000000..a0bf9bd1e --- /dev/null +++ b/src/libs/ifc/exception/vexceptionwrongid.h @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file vexceptionwrongparameterid.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 VEXCEPTIONWRONGID_H +#define VEXCEPTIONWRONGID_H + +#include "vexception.h" + +class QDomElement; + +/** + * @brief The VExceptionWrongId class for exception wrong id + */ +class VExceptionWrongId : public VException +{ +public: + VExceptionWrongId(const QString &what, const QDomElement &domElement); + VExceptionWrongId(const VExceptionWrongId &e); + virtual ~VExceptionWrongId() V_NOEXCEPT_EXPR (true){} + virtual QString ErrorMessage() const; + virtual QString DetailedInformation() const; + QString TagText() const; + QString TagName() const; + qint32 LineNumber() const; +protected: + /** @brief tagText tag text */ + QString tagText; + + /** @brief tagName tag name */ + QString tagName; + + /** @brief lineNumber line number */ + qint32 lineNumber; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagText return tag text + * @return tag text + */ +inline QString VExceptionWrongId::TagText() const +{ + return tagText; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TagName return tag name + * @return tag name + */ +inline QString VExceptionWrongId::TagName() const +{ + return tagName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineNumber return line number in file + * @return line number + */ +inline qint32 VExceptionWrongId::LineNumber() const +{ + return lineNumber; +} + +#endif // VEXCEPTIONWRONGID_H diff --git a/src/libs/ifc/ifc.pri b/src/libs/ifc/ifc.pri new file mode 100644 index 000000000..124d558f1 --- /dev/null +++ b/src/libs/ifc/ifc.pri @@ -0,0 +1,13 @@ +# Suport subdirectories. Just better project code tree. +include(exception/exception.pri) +include(xml/xml.pri) + +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/stable.h \ + $$PWD/ifcdef.h + +SOURCES += \ + $$PWD/stable.cpp diff --git a/src/libs/ifc/ifc.pro b/src/libs/ifc/ifc.pro new file mode 100644 index 000000000..cc52de5c4 --- /dev/null +++ b/src/libs/ifc/ifc.pro @@ -0,0 +1,97 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-12-10T17:53:37 +# +#------------------------------------------------- + +# File with common stuff for whole project +include(../../../Valentina.pri) + +# Library work with xml. +QT += xml xmlpatterns printsupport + +# We don't need gui library. +QT -= gui + +# Name of library +TARGET = ifc # Internal Format Converter + +# We want create library +TEMPLATE = lib + +CONFIG += \ + staticlib \# Making static library + c++11 # We use C++11 standard + +# Use out-of-source builds (shadow builds) +CONFIG -= debug_and_release debug_and_release_target + +# Since Qt 5.4.0 the source code location is recorded only in debug builds. +# We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT. +DEFINES += QT_MESSAGELOGCONTEXT + +include(ifc.pri) + +# This is static library so no need in "make install" + +# directory for executable file +DESTDIR = bin + +# files created moc +MOC_DIR = moc + +# objecs files +OBJECTS_DIR = obj + +# Resource files. This files will be included in binary. +RESOURCES += \ + schema.qrc # Schemas for validation xml files. + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +$$enable_ccache() + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +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}/$${MOC_DIR}" \ + $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + #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_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}/$${MOC_DIR}" \ + $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + +}else{ + # Release mode + DEFINES += V_NO_ASSERT + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + !macx:!win32-msvc*{ + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. TODO: find way how to strip binary file. + QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_LFLAGS_RELEASE = + } +} diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h new file mode 100644 index 000000000..616772c5f --- /dev/null +++ b/src/libs/ifc/ifcdef.h @@ -0,0 +1,119 @@ +/************************************************************************ + ** + ** @file ifcdef.h + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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) 2014 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 IFCDEF_H +#define IFCDEF_H + +#include +#include + +#ifdef Q_OS_WIN32 + extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; +#endif /*Q_OS_WIN32*/ + +enum class Unit : char { Mm, Cm, Inch }; +enum class MeasurementsType : char { Standard, Individual }; + +static const quint32 null_id = 0; + +#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value. +#define NULL_ID_STR "0" + +/* + * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow + * you to continue afterwards should you choose to. + * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 + * Usefull links: + * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - + * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func + * + * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx + * + * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx + * + * 4. Continue to debug after failed assertion on Linux? [C/C++] - + * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c + */ +#ifndef V_NO_ASSERT +#ifdef Q_OS_WIN32 +#ifdef Q_CC_MSVC +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __FUNCSIG__, __FILE__, __LINE__); \ + DebugBreak(); \ + } \ +} \ + +#else + +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + DebugBreak(); \ + } \ +} \ + +#endif /*Q_CC_MSVC*/ +#else +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + std::raise(SIGTRAP); \ + } \ +} \ + +#endif /* Q_OS_WIN32 */ +#else // define but disable this function if debugging is not set +#define SCASSERT(cond) qt_noop(); +#endif /* QT_NO_DEBUG */ + +// Detect whether the compiler supports C++11 noexcept exception specifications. +# if defined(__clang__) +# if __has_feature(cxx_noexcept) +# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept +# endif +# elif defined(__GNUC__) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept +# endif +# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114 +# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) +# else +# define V_NOEXCEPT_EXPR(x) +# endif + +#endif // IFCDEF_H diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc new file mode 100644 index 000000000..2037ec8b5 --- /dev/null +++ b/src/libs/ifc/schema.qrc @@ -0,0 +1,9 @@ + + + schema/individual_measurements.xsd + schema/standard_measurements.xsd + schema/pattern/v0.1.0.xsd + schema/pattern/v0.1.1.xsd + schema/pattern/v0.1.2.xsd + + diff --git a/src/libs/ifc/schema/individual_measurements.xsd b/src/libs/ifc/schema/individual_measurements.xsd new file mode 100644 index 000000000..5c97f5269 --- /dev/null +++ b/src/libs/ifc/schema/individual_measurements.xsd @@ -0,0 +1,764 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/pattern/v0.1.0.xsd b/src/libs/ifc/schema/pattern/v0.1.0.xsd new file mode 100644 index 000000000..7f0a5f96a --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.1.0.xsd @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/pattern/v0.1.1.xsd b/src/libs/ifc/schema/pattern/v0.1.1.xsd new file mode 100644 index 000000000..496c0cf6a --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.1.1.xsd @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/pattern/v0.1.2.xsd b/src/libs/ifc/schema/pattern/v0.1.2.xsd new file mode 100644 index 000000000..134c9be89 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.1.2.xsd @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/standard_measurements.xsd b/src/libs/ifc/schema/standard_measurements.xsd new file mode 100644 index 000000000..97730dd24 --- /dev/null +++ b/src/libs/ifc/schema/standard_measurements.xsd @@ -0,0 +1,1007 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/stable.cpp b/src/libs/ifc/stable.cpp new file mode 100644 index 000000000..877ab2ddf --- /dev/null +++ b/src/libs/ifc/stable.cpp @@ -0,0 +1,30 @@ +/************************************************************************ + ** + ** @file stable.cpp + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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 + ** 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 . + ** + *************************************************************************/ + +// Build the precompiled headers. +#include "stable.h" diff --git a/src/libs/ifc/stable.h b/src/libs/ifc/stable.h new file mode 100644 index 000000000..c2c2a7780 --- /dev/null +++ b/src/libs/ifc/stable.h @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file stable.h + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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 + ** 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 STABLE_H +#define STABLE_H + +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for IFC library.\n") +#endif + +/* Add C includes here */ + +#if defined __cplusplus +/* Add C++ includes here */ + +#ifdef QT_CORE_LIB +#include +#endif + +#ifdef QT_XML_LIB +# include +#endif + +//In Windows you can't use those headers in all modes. +#if !defined(Q_OS_WIN) +# ifdef QT_PRINTSUPPORT_LIB +# include +# endif + +# ifdef QT_XMLPATTERNS_LIB +# include +# endif + +# ifdef QT_NETWORK_LIB +# include +# endif +#endif/*Q_OS_WIN*/ + +#endif/*__cplusplus*/ + +#endif // STABLE_H diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp new file mode 100644 index 000000000..f148d3fac --- /dev/null +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -0,0 +1,198 @@ +/************************************************************************ + ** + ** @file vabstractconverter.cpp + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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) 2014 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 "vabstractconverter.h" +#include "exception/vexception.h" +#include "exception/vexceptionwrongid.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractConverter::VAbstractConverter(const QString &fileName) + :VDomDocument(), ver(0x0), fileName(fileName) +{ + this->setXMLContent(fileName); + const QString version = GetVersionStr(); + ver = GetVersion(version); +} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractConverter::~VAbstractConverter() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractConverter::Convert() +{ + if (ver == MaxVer()) + { + return; + } + + QString error; + const QString backupFileName = fileName +".backup"; + if (SafeCopy(fileName, backupFileName, error) == false) + { + const QString errorMsg(tr("Error creation backup file: %1.").arg(error)); + throw VException(errorMsg); + } + + ApplyPatches(); + + QFile file(backupFileName); + file.remove(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractConverter::GetVersionStr() const +{ + const QDomNodeList nodeList = this->elementsByTagName(TagVersion); + if (nodeList.isEmpty()) + { + const QString errorMsg(tr("Couldn't get version information.")); + throw VException(errorMsg); + } + + if (nodeList.count() > 1) + { + const QString errorMsg(tr("Too many tags <%1> in file.").arg(TagVersion)); + throw VException(errorMsg); + } + + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + return domElement.text(); + } + } + return QString(QStringLiteral("0.0.0")); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VAbstractConverter::GetVersion(const QString &version) const +{ + ValidateVersion(version); + + QStringList ver = version.split("."); + + bool ok = false; + int major = ver.at(0).toInt(&ok); + if (ok == false) + { + return 0x0; + } + + ok = false; + int minor = ver.at(1).toInt(&ok); + if (ok == false) + { + return 0x0; + } + + ok = false; + int patch = ver.at(2).toInt(&ok); + if (ok == false) + { + return 0x0; + } + + return (major<<16)|(minor<<8)|(patch); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractConverter::ValidateVersion(const QString &version) const +{ + QRegExp rx(QStringLiteral("^(0|([1-9][0-9]*)).(0|([1-9][0-9]*)).(0|([1-9][0-9]*))$")); + + if (rx.exactMatch(version) == false) + { + const QString errorMsg(tr("Version \"%1\" invalid.").arg(version)); + throw VException(errorMsg); + } + + if (version == QLatin1String("0.0.0")) + { + const QString errorMsg(tr("Version \"0.0.0\" invalid.")); + throw VException(errorMsg); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractConverter::CheckVersion(int ver) const +{ + if (ver < MinVer()) + { + const QString errorMsg(tr("Invalid version. Minimum supported version is %1").arg(MinVerStr())); + throw VException(errorMsg); + } + + if (ver > MaxVer()) + { + const QString errorMsg(tr("Invalid version. Maximum supported version is %1").arg(MaxVerStr())); + throw VException(errorMsg); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractConverter::SaveDocument(const QString &fileName, QString &error) const +{ + try + { + TestUniqueId(); + } + catch (const VExceptionWrongId &e) + { + error = tr("Error no unique id."); + return false; + } + + return VDomDocument::SaveDocument(fileName, error); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractConverter::Save() const +{ + QString error; + if (SaveDocument(fileName, error) == false) + { + VException e(error); + throw e; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractConverter::SetVersion(const QString &version) +{ + if (setTagText(TagVersion, version) == false) + { + VException e(tr("Could not change version.")); + throw e; + } +} diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h new file mode 100644 index 000000000..c3ce71d33 --- /dev/null +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file vabstractconverter.h + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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) 2014 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 VABSTRACTCONVERTER_H +#define VABSTRACTCONVERTER_H + +#include "vdomdocument.h" + +class VAbstractConverter :public VDomDocument +{ + Q_DECLARE_TR_FUNCTIONS(VAbstractConverter) +public: + VAbstractConverter(const QString &fileName); + virtual ~VAbstractConverter(); + + void Convert(); + virtual bool SaveDocument(const QString &fileName, QString &error) const; + +protected: + int ver; + QString fileName; + + int GetVersion(const QString &version) const; + void CheckVersion(int ver) const; + void Save() const; + void SetVersion(const QString &version); + + virtual int MinVer() const =0; + virtual int MaxVer() const =0; + + virtual QString MinVerStr() const =0; + virtual QString MaxVerStr() const =0; + + virtual QString XSDSchema(int ver) const =0; + virtual void ApplyPatches() =0; + +private: + Q_DISABLE_COPY(VAbstractConverter) + + QString GetVersionStr() const; + + void ValidateVersion(const QString &version) const; +}; + +#endif // VABSTRACTCONVERTER_H diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp new file mode 100644 index 000000000..0f29fb26f --- /dev/null +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -0,0 +1,746 @@ +/************************************************************************ + ** + ** @file vdomdocument.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 "vdomdocument.h" +#include "exception/vexceptionconversionerror.h" +#include "exception/vexceptionemptyparameter.h" +#include "exception/vexceptionbadid.h" +#include "exception/vexceptionwrongid.h" + +#include +#include +#include +#include +#include +#include + +//This class need for validation pattern file using XSD shema +class MessageHandler : public QAbstractMessageHandler +{ +public: + MessageHandler() : QAbstractMessageHandler(), m_messageType(QtMsgType()), m_description(QString()), + m_sourceLocation(QSourceLocation()){} + QString statusMessage() const; + qint64 line() const; + qint64 column() const; +protected: + // cppcheck-suppress unusedFunction + virtual void handleMessage(QtMsgType type, const QString &description, + const QUrl &identifier, const QSourceLocation &sourceLocation); +private: + QtMsgType m_messageType; + QString m_description; + QSourceLocation m_sourceLocation; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QString MessageHandler::statusMessage() const +{ + return m_description; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qint64 MessageHandler::line() const +{ + return m_sourceLocation.line(); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qint64 MessageHandler::column() const +{ + return m_sourceLocation.column(); +} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void MessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, + const QSourceLocation &sourceLocation) +{ + Q_UNUSED(type); + Q_UNUSED(identifier); + + m_messageType = type; + m_description = description; + m_sourceLocation = sourceLocation; +} + +Q_LOGGING_CATEGORY(vXML, "v.xml") + +const QString VDomDocument::AttrId = QStringLiteral("id"); +const QString VDomDocument::AttrUnit = QStringLiteral("unit"); +const QString VDomDocument::UnitMM = QStringLiteral("mm"); +const QString VDomDocument::UnitCM = QStringLiteral("cm"); +const QString VDomDocument::UnitINCH = QStringLiteral("inch"); +const QString VDomDocument::TagVersion = QStringLiteral("version"); + +//--------------------------------------------------------------------------------------------------------------------- +VDomDocument::VDomDocument() + : QDomDocument(), map(QHash()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VDomDocument::~VDomDocument() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Finds an element by id. + * @param id value id attribute. + * @return dom element. + */ +QDomElement VDomDocument::elementById(const QString& id) +{ + if (map.contains(id)) + { + QDomElement e = map[id]; + if (e.parentNode().nodeType() != QDomNode::BaseNode) + { + return e; + } + map.remove(id); + } + + if (this->find(this->documentElement(), id)) + { + return map[id]; + } + + return QDomElement(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Removes all children of a given element tag. RENAME: removeAllChildren + * @param element tag + */ +void VDomDocument::removeAllChilds(QDomElement &element) +{ + QDomNode domNode = element.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + element.removeChild(domElement); + } + } + domNode = element.firstChild(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Find element by id. + * @param node node + * @param id id value + * @return true if found + */ +bool VDomDocument::find(const QDomElement &node, const QString& id) +{ + if (node.hasAttribute(AttrId)) + { + const QString value = node.attribute(AttrId); + this->map[value] = node; + if (value == id) + { + return true; + } + } + + for (qint32 i=0; ifind(n.toElement(), id)) + { + return true; + } + } + } + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the long long value of the given attribute. RENAME: GetParameterLongLong? + * @param domElement tag in xml tree + * @param name attribute name + * @return long long value + */ +quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue) const +{ + Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + + bool ok = false; + QString parametr; + quint32 id = 0; + + QString message = tr("Can't convert toUInt parameter"); + try + { + parametr = GetParametrString(domElement, name, defValue); + id = parametr.toUInt(&ok); + if (ok == false) + { + throw VExceptionConversionError(message, name); + } + } + catch (const VExceptionEmptyParameter &e) + { + VExceptionConversionError excep(message, name); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) const +{ + Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + + QString parametr; + bool val = true; + + QString message = tr("Can't convert toBool parameter"); + try + { + parametr = GetParametrString(domElement, name, defValue); + + QStringList bools = QStringList() << QLatin1String("true") << QLatin1String("false"); + switch (bools.indexOf(parametr)) + { + case 0: // true + val = true; + break; + case 1: // false + val = false; + break; + default:// others + throw VExceptionConversionError(message, name); + break; + } + } + catch (const VExceptionEmptyParameter &e) + { + VExceptionConversionError excep(message, name); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + + return val; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the string value of the given attribute. RENAME: see above + * + * if attribute empty return default value. If default value empty too throw exception. + * @return attribute value + * @throw VExceptionEmptyParameter when attribute is empty + */ +QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name, + const QString &defValue) const +{ + Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + const QString parameter = domElement.attribute(name, defValue); + if (parameter.isEmpty()) + { + if (defValue.isEmpty()) + { + throw VExceptionEmptyParameter(tr("Got empty parameter"), name, domElement); + } + else + { + return defValue; + } + } + return parameter; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the double value of the given attribute. + * @param domElement tag in xml tree + * @param name attribute name + * @return double value + */ +qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) const +{ + Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + + bool ok = false; + qreal param = 0; + + QString message = tr("Can't convert toDouble parameter"); + try + { + QString parametr = GetParametrString(domElement, name, defValue); + param = parametr.replace(",", ".").toDouble(&ok); + if (ok == false) + { + throw VExceptionConversionError(message, name); + } + } + catch (const VExceptionEmptyParameter &e) + { + VExceptionConversionError excep(message, name); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + return param; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetParametrId return value id attribute. + * @param domElement tag in xml tree. + * @return id value. + */ +quint32 VDomDocument::GetParametrId(const QDomElement &domElement) const +{ + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + + quint32 id = 0; + + QString message = tr("Got wrong parameter id. Need only id > 0."); + try + { + id = GetParametrUInt(domElement, VDomDocument::AttrId, NULL_ID_STR); + if (id <= 0) + { + throw VExceptionWrongId(message, domElement); + } + } + catch (const VExceptionConversionError &e) + { + VExceptionWrongId excep(message, domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const +{ + const QDomNodeList nodeList = this->elementsByTagName(tagName); + if (nodeList.isEmpty()) + { + return defVal; + } + else + { + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + return domElement.text(); + } + } + } + return defVal; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TestUniqueId test exist unique id in pattern file. Each id must be unique. + */ +void VDomDocument::TestUniqueId() const +{ + QVector vector; + CollectId(documentElement(), vector); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDomDocument::CollectId(const QDomElement &node, QVector &vector) const +{ + if (node.hasAttribute(VDomDocument::AttrId)) + { + const quint32 id = GetParametrId(node); + if (vector.contains(id)) + { + throw VExceptionWrongId(tr("This id is not unique."), node); + } + vector.append(id); + } + + for (qint32 i=0; ielementsByTagName(tag); + if (nodeList.isEmpty()) + { + qDebug()<<"Can't save tag "<= 1 ) + { + domElement.removeChild( domElement.firstChild() ); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QDomNode VDomDocument::ParentNodeById(const quint32 &nodeId) +{ + QDomElement domElement = NodeById(nodeId); + return domElement.parentNode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QDomElement VDomDocument::CloneNodeById(const quint32 &nodeId) +{ + QDomElement domElement = NodeById(nodeId); + return domElement.cloneNode().toElement(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QDomElement VDomDocument::NodeById(const quint32 &nodeId) +{ + QDomElement domElement = elementById(QString().setNum(nodeId)); + if (domElement.isNull() || domElement.isElement() == false) + { + throw VExceptionBadId(tr("Couldn't get node"), nodeId); + } + return domElement; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VDomDocument::SafeCopy(const QString &source, const QString &destination, QString &error) +{ + bool result = false; + +#ifdef Q_OS_WIN32 + qt_ntfs_permission_lookup++; // turn checking on +#endif /*Q_OS_WIN32*/ + + QFile patternFile(destination); + patternFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner); + // We need here temporary file because we want restore document after error of copying temp file. + QTemporaryFile tempOfPattern; + if (tempOfPattern.open()) + { + if (patternFile.exists()) + { + patternFile.copy(tempOfPattern.fileName()); + } + } + if ( patternFile.exists() == false || patternFile.remove() ) + { + QFile sourceFile(source); + if ( sourceFile.copy(patternFile.fileName()) == false ) + { + error = tr("Could not copy temp file to document file"); + tempOfPattern.copy(destination); + result = false; + } + else + { + result = true; + } + } + else + { + error = tr("Could not remove document file"); + result = false; + } + +#ifdef Q_OS_WIN32 + qt_ntfs_permission_lookup--; // turn off check permission again +#endif /*Q_OS_WIN32*/ + + return result; +} diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h new file mode 100644 index 000000000..ac2d5029a --- /dev/null +++ b/src/libs/ifc/xml/vdomdocument.h @@ -0,0 +1,178 @@ +/************************************************************************ + ** + ** @file vdomdocument.h + ** @author Roman Telezhynskyi + ** @date November 15, 2013 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program that allows creating and modelling patterns of clothing. + ** Copyright (C) 2013 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 VDOMDOCUMENT_H +#define VDOMDOCUMENT_H + +#include +#include +#include +#include + +#include "ifcdef.h" + +Q_DECLARE_LOGGING_CATEGORY(vXML) + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +/** + * @brief The VDomDocument class represents a Valentina document (.val file). + * + * A Valentina document describes the construction of a sewing pattern. The + * information is stored in XML format. By parsing a VDomDocument, the contained + * pattern is rendered to a Valentina graphics scene (VMainGraphicsScene). + * + * A sewing pattern consists of zero or more increments and one + * or more pattern pieces. + * + * An increment is an auxiliary variable that is calculated from regular measurement + * variables (that belong to the standard measurements table). Increments are used to + * create a graduation schema for the sewing pattern. + * + * A pattern piece contains + * 1) auxiliary pattern construction elements (calculation), + * 2) pattern construction elements (modeling), and + * 3) special markers, e.g. seam allowances (details). + * Of these, 2) and 3) are visible in the final pattern (draw mode 'Modeling'), + * 1) is only displayed when editing (draw mode 'Calculation') the pattern. + */ +class VDomDocument : public QDomDocument +{ + Q_DECLARE_TR_FUNCTIONS(VDomDocument) +public: + static const QString AttrId; + static const QString AttrUnit; + static const QString UnitMM; + static const QString UnitCM; + static const QString UnitINCH; + static const QString TagVersion; + /** + * @param data container with variables + */ + VDomDocument(); + virtual ~VDomDocument(); + QDomElement elementById(const QString& id); + void removeAllChilds(QDomElement &element); + template + /** + * @brief SetAttribute set attribute in pattern file. Replace "," by ".". + * @param domElement element in xml tree. + * @param name name of attribute. + * @param value value of attribute. + */ + void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const + { + QString val = QString().setNum(value); + val = val.replace(",", "."); + domElement.setAttribute(name, val); + } + quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue) const; + bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue) const; + QString GetParametrString(const QDomElement& domElement, const QString &name, + const QString &defValue = QString()) const; + qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const; + quint32 GetParametrId(const QDomElement& domElement) const; + + static void ValidateXML(const QString &schema, const QString &fileName); + void setXMLContent(const QString &fileName); + static Unit StrToUnits(const QString &unit); + static QString UnitsToStr(const Unit &unit, const bool translate = false); + virtual bool SaveDocument(const QString &fileName, QString &error) const; + QString Major() const; + QString Minor() const; + QString Patch() const; + static void RemoveAllChild(QDomElement &domElement); + + QDomNode ParentNodeById(const quint32 &nodeId); + QDomElement CloneNodeById(const quint32 &nodeId); + QDomElement NodeById(const quint32 &nodeId); + + static bool SafeCopy(const QString &source, const QString &destination, QString &error); + +protected: + bool setTagText(const QString &tag, const QString &text); + QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const; + + void TestUniqueId() const; + void CollectId(const QDomElement &node, QVector &vector)const; + +private: + Q_DISABLE_COPY(VDomDocument) + /** @brief Map used for finding element by id. */ + QHash map; + + bool find(const QDomElement &node, const QString& id); +}; + +//--------------------------------------------------------------------------------------------------------------------- +template <> +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, + const QString &value) const +{ + domElement.setAttribute(name, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +template <> +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, const bool &value) const +{ + QString string; + if (value) + { + string = "true"; + } + else + { + string = "false"; + } + domElement.setAttribute(name, string); +} + +//--------------------------------------------------------------------------------------------------------------------- +template <> +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, + const MeasurementsType &value) const +{ + if (value == MeasurementsType::Standard) + { + domElement.setAttribute(name, "standard"); + } + else + { + domElement.setAttribute(name, "individual"); + } +} + +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif + +#endif // VDOMDOCUMENT_H diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp new file mode 100644 index 000000000..af47c64ed --- /dev/null +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -0,0 +1,161 @@ +/************************************************************************ + ** + ** @file vpatternconverter.cpp + ** @author Roman Telezhynskyi + ** @date 11 12, 2014 + ** + ** @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) 2014 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 "vpatternconverter.h" +#include "exception/vexception.h" + +#include + +/* + * Version rules: + * 1. Version have three parts "major.minor.patch"; + * 2. major part only for stable releases; + * 3. minor - 10 or more patch changes, or one big change; + * 4. patch - little change. + */ + +const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.2"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.2.xsd"); + +//--------------------------------------------------------------------------------------------------------------------- +VPatternConverter::VPatternConverter(const QString &fileName) + :VAbstractConverter(fileName) +{ + const QString schema = XSDSchema(ver); + ValidateXML(schema, fileName); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPatternConverter::~VPatternConverter() +{} + +//--------------------------------------------------------------------------------------------------------------------- +int VPatternConverter::MinVer() const +{ + return GetVersion(PatternMinVerStr); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPatternConverter::MaxVer() const +{ + return GetVersion(PatternMaxVerStr); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPatternConverter::MinVerStr() const +{ + return PatternMinVerStr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPatternConverter::MaxVerStr() const +{ + return PatternMaxVerStr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPatternConverter::XSDSchema(int ver) const +{ + CheckVersion(ver); + + switch(ver) + { + case (0x000100): + return QStringLiteral("://schema/pattern/v0.1.0.xsd"); + case (0x000101): + return QStringLiteral("://schema/pattern/v0.1.1.xsd"); + case (0x000102): + return CurrentSchema; + default: + { + const QString errorMsg(tr("Unexpected version \"%1\".").arg(ver, 0, 16)); + throw VException(errorMsg); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ApplyPatches() +{ + try + { + switch(ver) + { + case (0x000100): + { + ToV0_1_1(); + const QString schema = XSDSchema(0x000101); + ValidateXML(schema, fileName); + // continue conversion + } + case (0x000101): + { + ToV0_1_2(); + const QString schema = XSDSchema(0x000102); + ValidateXML(schema, fileName); + break; + } + case (0x000102): + break; + default: + break; + } + } + catch (VException &e) + { + QString error; + const QString backupFileName = fileName +".backup"; + if (SafeCopy(backupFileName, fileName, error) == false) + { + const QString errorMsg(tr("Error restoring backup file: %1.").arg(error)); + VException excep(errorMsg); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + + QFile file(backupFileName); + file.remove(); + + throw; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_1_1() +{ + SetVersion(QStringLiteral("0.1.1")); + Save(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_1_2() +{ + SetVersion(QStringLiteral("0.1.2")); + Save(); +} diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h new file mode 100644 index 000000000..5d8b4c651 --- /dev/null +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file vpatternconverter.h + ** @author Roman Telezhynskyi + ** @date 11 12, 2014 + ** + ** @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) 2014 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 VPATTERNCONVERTER_H +#define VPATTERNCONVERTER_H + +#include "vabstractconverter.h" + +class VPatternConverter : public VAbstractConverter +{ + Q_DECLARE_TR_FUNCTIONS(VPatternConverter) +public: + VPatternConverter(const QString &fileName); + virtual ~VPatternConverter(); + + static const QString PatternMaxVerStr; + static const QString CurrentSchema; + +protected: + virtual int MinVer() const; + virtual int MaxVer() const; + + virtual QString MinVerStr() const; + virtual QString MaxVerStr() const; + + QString XSDSchema(int ver) const; + virtual void ApplyPatches(); + +private: + Q_DISABLE_COPY(VPatternConverter) + static const QString PatternMinVerStr; + + void ToV0_1_1(); + void ToV0_1_2(); +}; + +#endif // VPATTERNCONVERTER_H diff --git a/src/libs/ifc/xml/xml.pri b/src/libs/ifc/xml/xml.pri new file mode 100644 index 000000000..c64e090e9 --- /dev/null +++ b/src/libs/ifc/xml/xml.pri @@ -0,0 +1,12 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vabstractconverter.h \ + $$PWD/vdomdocument.h \ + $$PWD/vpatternconverter.h + +SOURCES += \ + $$PWD/vabstractconverter.cpp \ + $$PWD/vdomdocument.cpp \ + $$PWD/vpatternconverter.cpp diff --git a/src/libs/libs.pro b/src/libs/libs.pro new file mode 100644 index 000000000..1828fc39e --- /dev/null +++ b/src/libs/libs.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = qmuparser \ + vpropertyexplorer \ + ifc \ + vobj diff --git a/src/libs/qmuparser/LICENSE_BSD.txt b/src/libs/qmuparser/LICENSE_BSD.txt new file mode 100644 index 000000000..c66f0cbce --- /dev/null +++ b/src/libs/qmuparser/LICENSE_BSD.txt @@ -0,0 +1,29 @@ +####################################################################### +# # +# # +# Fast math parser Library # +# # +# Copyright (C) 2011 Ingo Berg # +# # +# Web: muparser.beltoforion.de # +# e-mail: muparser@beltoforion.de # +# # +# # +####################################################################### + + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/libs/qmuparser/doc/doxygen/Doxyfile b/src/libs/qmuparser/doc/doxygen/Doxyfile new file mode 100644 index 000000000..54ed8835e --- /dev/null +++ b/src/libs/qmuparser/doc/doxygen/Doxyfile @@ -0,0 +1,1890 @@ +# Doxyfile 1.8.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed +# in front of the TAG it is preceding . +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "qmuParser API -" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 2.2.4 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Math parser" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Latvian, Lithuanian, Norwegian, Macedonian, +# Persian, Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, +# Slovak, Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = YES + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields or simple typedef fields will be shown +# inline in the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO (the default), structs, classes, and unions are shown on a separate +# page (for HTML and Man pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can +# be an expensive process and often the same symbol appear multiple times in +# the code, doxygen keeps a cache of pre-resolved symbols. If the cache is too +# small doxygen will become slower. If the cache is too large, memory is wasted. +# The cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid +# range is 0..9, the default is 0, corresponding to a cache size of 2^16 = 65536 +# symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.h *.cpp + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = */.hg/* + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be ignored. +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript +# pieces of code that will be used on startup of the MathJax code. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search +# engine library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4 will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images +# or other source files which should be copied to the LaTeX output directory. +# Note that the files will be copied as-is; there are no commands or markers +# available. + +LATEX_EXTRA_FILES = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +# If the GENERATE_DOCBOOK tag is set to YES Doxygen will generate DOCBOOK files +# that can be used to generate PDF. + +GENERATE_DOCBOOK = NO + +# The DOCBOOK_OUTPUT tag is used to specify where the DOCBOOK pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in +# front of it. If left blank docbook will be used as the default path. + +DOCBOOK_OUTPUT = docbook + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed +# in the related pages index. If set to NO, only the current project's +# pages will be listed. + +EXTERNAL_PAGES = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = YES + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# manageable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = svg + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = YES + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp new file mode 100644 index 000000000..799c6c8ca --- /dev/null +++ b/src/libs/qmuparser/qmuparser.cpp @@ -0,0 +1,385 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparser.h" + +#include +#include + +using namespace std; + +/** + * @file + * @brief Implementation of the standard floating point QmuParser. + */ + +/** + * @brief Namespace for mathematical applications. + */ +namespace qmu +{ +// Trigonometric function +qreal QmuParser::Sinh(qreal v) +{ + return sinh(v); +} + +qreal QmuParser::Cosh(qreal v) +{ + return cosh(v); +} + +qreal QmuParser::Tanh(qreal v) +{ + return tanh(v); +} + +qreal QmuParser::ASinh(qreal v) +{ + return log(v + qSqrt(v * v + 1)); +} + +qreal QmuParser::ACosh(qreal v) +{ + return log(v + qSqrt(v * v - 1)); +} + +qreal QmuParser::ATanh(qreal v) +{ + return (0.5 * log((1 + v) / (1 - v))); +} +//--------------------------------------------------------------------------------------------------------------------- +// Logarithm functions + +// Logarithm base 2 +qreal QmuParser::Log2(qreal v) +{ +#ifdef MUP_MATH_EXCEPTIONS + if (v<=0) + { + throw QmuParserError(ecDOMAIN_ERROR, "Log2"); + } +#endif + return log(v)/log(2.0); +} + +// Logarithm base 10 +qreal QmuParser::Log10(qreal v) +{ +#ifdef MUP_MATH_EXCEPTIONS + if (v<=0) + { + throw QmuParserError(ecDOMAIN_ERROR, "Log10"); + } +#endif + return log10(v); +} + +//--------------------------------------------------------------------------------------------------------------------- +// misc +qreal QmuParser::Abs(qreal v) +{ + return qAbs(v); +} + +qreal QmuParser::Rint(qreal v) +{ + return qFloor(v + 0.5); +} + +qreal QmuParser::Sign(qreal v) +{ + return ((v<0) ? -1 : (v>0) ? 1 : 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Callback for adding multiple values. + * @param [in] a_afArg Vector with the function arguments + * @param [in] a_iArgc The size of a_afArg + */ +qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc) +{ + if (a_iArgc == false) + { + throw QmuParserError("too few arguments for function sum."); + } + qreal fRes=0; + for (int i=0; i(a_iArgc); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Callback for determining the minimum value out of a vector. + * @param [in] a_afArg Vector with the function arguments + * @param [in] a_iArgc The size of a_afArg + */ +qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc) +{ + if (a_iArgc == false) + { + throw QmuParserError("too few arguments for function min."); + } + qreal fRes=a_afArg[0]; + for (int i=0; i> fVal; + stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading + + if (iEnd==static_cast(-1)) + { + return 0; + } + + *a_iPos += static_cast(iEnd); + *a_fVal = fVal; + return 1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor. + * + * Call QmuParserBase class constructor and trigger Function, Operator and Constant initialization. + */ +QmuParser::QmuParser():QmuParserBase() +{ + AddValIdent(IsVal); + + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define the character sets. + * @sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars + * + * This function is used for initializing the default character sets that define + * the characters to be useable in function and variable names and operators. + */ +void QmuParser::InitCharSets() +{ + DefineNameChars( QStringLiteral("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); + DefineOprtChars( QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") ); + DefineInfixOprtChars( QStringLiteral("/+-*^?<>=#!$%&|~'_") ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize the default functions. + */ +void QmuParser::InitFun() +{ + // trigonometric functions + DefineFun("sin", qSin); + DefineFun("cos", qCos); + DefineFun("tan", qTan); + // arcus functions + DefineFun("asin", qAsin); + DefineFun("acos", qAcos); + DefineFun("atan", qAtan); + DefineFun("atan2", qAtan2); + // hyperbolic functions + DefineFun("sinh", Sinh); + DefineFun("cosh", Cosh); + DefineFun("tanh", Tanh); + // arcus hyperbolic functions + DefineFun("asinh", ASinh); + DefineFun("acosh", ACosh); + DefineFun("atanh", ATanh); + // Logarithm functions + DefineFun("log2", Log2); + DefineFun("log10", Log10); + DefineFun("log", Log10); + DefineFun("ln", qLn); + // misc + DefineFun("exp", qExp); + DefineFun("sqrt", qSqrt); + DefineFun("sign", Sign); + DefineFun("rint", Rint); + DefineFun("abs", Abs); + // Functions with variable number of arguments + DefineFun("sum", Sum); + DefineFun("avg", Avg); + DefineFun("min", Min); + DefineFun("max", Max); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize constants. + * + * By default the QmuParser recognizes two constants. Pi ("pi") and the eulerian + * number ("_e"). + */ +void QmuParser::InitConst() +{ + DefineConst("_pi", (qreal)M_PI); + DefineConst("_e", (qreal)M_E); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize operators. + * + * By default only the unary minus operator is added. + */ +void QmuParser::InitOprt() +{ + DefineInfixOprt("-", UnaryMinus); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) +{ + Q_UNUSED(pExpr); + Q_UNUSED(nStart); + Q_UNUSED(nEnd); + // this is just sample code to illustrate modifying variable names on the fly. + // I'm not sure anyone really needs such a feature... + /* + + + string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd); + string sRepl = std::string("_") + sVar + "_"; + + int nOrigVarEnd = nEnd; + cout << "variable detected!\n"; + cout << " Expr: " << *pExpr << "\n"; + cout << " Start: " << nStart << "\n"; + cout << " End: " << nEnd << "\n"; + cout << " Var: \"" << sVar << "\"\n"; + cout << " Repl: \"" << sRepl << "\"\n"; + nEnd = nStart + sRepl.length(); + cout << " End: " << nEnd << "\n"; + pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl); + cout << " New expr: " << *pExpr << "\n"; + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Numerically differentiate with regard to a variable. + * @param [in] a_Var Pointer to the differentiation variable. + * @param [in] a_fPos Position at which the differentiation should take place. + * @param [in] a_fEpsilon Epsilon used for the numerical differentiation. + * + * Numerical differentiation uses a 5 point operator yielding a 4th order + * formula. The default value for epsilon is 0.00074 which is + * numeric_limits::epsilon() ^ (1/5) as suggested in the muQmuParser + * forum: + * + * http://sourceforge.net/forum/forum.php?thread_id=1994611&forum_id=462843 + */ +// cppcheck-suppress unusedFunction +qreal QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const +{ + qreal fRes(0), + fBuf(*a_Var), + f[4] = {0, 0, 0, 0}, + fEpsilon(a_fEpsilon); + + // Backwards compatible calculation of epsilon inc case the user doesnt provide + // his own epsilon + if (qFuzzyCompare(fEpsilon + 1, 1 + 0)) + { + fEpsilon = (qFuzzyCompare(a_fPos + 1, 1 + 0)) ? static_cast(1e-10) : static_cast(1e-7) * a_fPos; + } + + *a_Var = a_fPos+2 * fEpsilon; f[0] = Eval(); + *a_Var = a_fPos+1 * fEpsilon; f[1] = Eval(); + *a_Var = a_fPos-1 * fEpsilon; f[2] = Eval(); + *a_Var = a_fPos-2 * fEpsilon; f[3] = Eval(); + *a_Var = fBuf; // restore variable + + fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon); + return fRes; +} +} // namespace qmu diff --git a/src/libs/qmuparser/qmuparser.h b/src/libs/qmuparser/qmuparser.h new file mode 100644 index 000000000..e65bdfa40 --- /dev/null +++ b/src/libs/qmuparser/qmuparser.h @@ -0,0 +1,98 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSER_H +#define QMUPARSER_H + +#include "qmuparser_global.h" +#include "qmuparserbase.h" + +/** + * @file + * @brief Definition of the standard floating point parser. + */ + +namespace qmu +{ + /** @brief Mathematical expressions parser. + * + * Standard implementation of the mathematical expressions parser. + * Can be used as a reference implementation for subclassing the parser. + * + * + * (C) 2011 Ingo Berg
+ * muparser(at)gmx.de + *
+ */ + /* final */ class QMUPARSERSHARED_EXPORT QmuParser : public QmuParserBase + { + public: + QmuParser(); + virtual void InitCharSets(); + virtual void InitFun(); + virtual void InitConst(); + virtual void InitOprt(); + virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd); + qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const; + protected: + static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal); + // Trigonometric functions + static qreal Tan2(qreal, qreal); + // hyperbolic functions + static qreal Sinh(qreal); + static qreal Cosh(qreal); + static qreal Tanh(qreal); + // arcus hyperbolic functions + static qreal ASinh(qreal); + static qreal ACosh(qreal); + static qreal ATanh(qreal); + // Logarithm functions + static qreal Log2(qreal); // Logarithm Base 2 + static qreal Log10(qreal); // Logarithm Base 10 + // misc + static qreal Abs(qreal); + static qreal Rint(qreal); + static qreal Sign(qreal); + // Prefix operators + // !!! Unary Minus is a MUST if you want to use negative signs !!! + static qreal UnaryMinus(qreal v); + // Functions with variable number of arguments + static qreal Sum(const qreal*, int); // sum + static qreal Avg(const qreal*, int); // mean value + static qreal Min(const qreal*, int); // minimum + static qreal Max(const qreal*, int); // maximum + }; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Callback for the unary minus operator. + * @param v The value to negate + * @return -v + */ +inline qreal QmuParser::UnaryMinus(qreal v) +{ + return -v; +} + +} // namespace qmu + +#endif // QMUPARSER_H diff --git a/src/libs/qmuparser/qmuparser.pri b/src/libs/qmuparser/qmuparser.pri new file mode 100644 index 000000000..13a555b84 --- /dev/null +++ b/src/libs/qmuparser/qmuparser.pri @@ -0,0 +1,28 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +SOURCES += \ + $$PWD/qmuparser.cpp \ + $$PWD/qmuparsertokenreader.cpp \ + $$PWD/qmuparsererror.cpp \ + $$PWD/qmuparsercallback.cpp \ + $$PWD/qmuparserbytecode.cpp \ + $$PWD/qmuparserbase.cpp \ + $$PWD/qmuparsertest.cpp \ + $$PWD/stable.cpp \ + $$PWD/qmutranslation.cpp + +HEADERS += \ + $$PWD/qmuparser.h\ + $$PWD/qmuparser_global.h \ + $$PWD/qmuparsertokenreader.h \ + $$PWD/qmuparsertoken.h \ + $$PWD/qmuparserfixes.h \ + $$PWD/qmuparsererror.h \ + $$PWD/qmuparserdef.h \ + $$PWD/qmuparsercallback.h \ + $$PWD/qmuparserbytecode.h \ + $$PWD/qmuparserbase.h \ + $$PWD/qmuparsertest.h \ + $$PWD/stable.h \ + $$PWD/qmutranslation.h diff --git a/src/libs/qmuparser/qmuparser.pro b/src/libs/qmuparser/qmuparser.pro new file mode 100644 index 000000000..8fec99c3a --- /dev/null +++ b/src/libs/qmuparser/qmuparser.pro @@ -0,0 +1,114 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-04-25T12:01:49 +# +#------------------------------------------------- + +# File with common stuff for whole project +include(../../../Valentina.pri) + +# We don't need gui library. +QT -= gui + +# Name of library +TARGET = qmuparser + +# We want create a library +TEMPLATE = lib + +# Use out-of-source builds (shadow builds) +CONFIG -= debug_and_release debug_and_release_target + +# We use C++11 standard +CONFIG += c++11 + +# Since Qt 5.4.0 the source code location is recorded only in debug builds. +# We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT. +DEFINES += QT_MESSAGELOGCONTEXT + +DEFINES += QMUPARSER_LIBRARY + +# directory for executable file +DESTDIR = bin + +# files created moc +MOC_DIR = moc + +# objecs files +OBJECTS_DIR = obj + +include(qmuparser.pri) + +VERSION = 2.2.5 + +# Set "make install" command for Unix-like systems. +unix:!macx{ + isEmpty(PREFIX_LIB){ + isEmpty(PREFIX){ + PR_LIB = $$DEFAULT_PREFIX + } else { + PR_LIB = $$PREFIX + } + contains(QMAKE_HOST.arch, x86_64) { + PREFIX_LIB = $$PR_LIB/lib64 + } else { + PREFIX_LIB = $$PR_LIB/lib + } + } + target.path = $$PREFIX_LIB + INSTALLS += target +} + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +$$enable_ccache() + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +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}/$${MOC_DIR}" \ + $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + #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_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}/$${MOC_DIR}" \ + $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + +}else{ + # Release mode + + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + !macx:!win32-msvc*{ + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. TODO: find way how to strip binary file. + QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_LFLAGS_RELEASE = + + # Strip debug symbols. + QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg && + QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} && + QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET} + } +} diff --git a/src/libs/qmuparser/qmuparser_global.h b/src/libs/qmuparser/qmuparser_global.h new file mode 100644 index 000000000..95202fc48 --- /dev/null +++ b/src/libs/qmuparser/qmuparser_global.h @@ -0,0 +1,34 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSER_GLOBAL_H +#define QMUPARSER_GLOBAL_H + +#include + +#if defined(QMUPARSER_LIBRARY) +# define QMUPARSERSHARED_EXPORT Q_DECL_EXPORT +#else +# define QMUPARSERSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // QMUPARSER_GLOBAL_H diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp new file mode 100644 index 000000000..c627e1f80 --- /dev/null +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -0,0 +1,1914 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparserbase.h" + +#include +#ifdef QMUP_USE_OPENMP + #include +#endif +#include + +using namespace std; + +/** + * @file + * @brief This file contains the basic implementation of the muparser engine. + */ + +namespace qmu +{ +std::locale QmuParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep('.')); + +bool QmuParserBase::g_DbgDumpCmdCode = false; +bool QmuParserBase::g_DbgDumpStack = false; + +/** + * @brief Identifiers for built in binary operators. + * + * When defining custom binary operators with #AddOprt(...) make sure not to choose + * names conflicting with these definitions. + */ +const QStringList QmuParserBase::c_DefaultOprt = QStringList()<< "<=" << ">=" << "!=" << "==" << "<" << ">" << "+" + << "-" << "*" << "/" << "^" << "&&" << "||" << "=" + << "(" << ")" << "?" << ":"; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor. + */ +QmuParserBase::QmuParserBase() + :m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(), + m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(), + m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(), + m_nFinalResultIdx(0), m_Tokens(QMap()), m_Numbers(QMap()), allowSubexpressions(true) +{ + InitTokenReader(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy constructor. + * + * Tha parser can be safely copy constructed but the bytecode is reset during copy construction. + */ +QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser) + :m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(), + m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(), + m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(), + m_nFinalResultIdx(0), m_Tokens(QMap()), m_Numbers(QMap()), allowSubexpressions(true) +{ + m_pTokenReader.reset(new token_reader_type(this)); + Assign(a_Parser); +} + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserBase::~QmuParserBase() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Assignement operator. + * + * Implemented by calling Assign(a_Parser). Self assignement is suppressed. + * @param a_Parser Object to copy to this. + * @return *this + * @throw nothrow + */ +QmuParserBase& QmuParserBase::operator=(const QmuParserBase &a_Parser) +{ + Assign(a_Parser); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy state of a parser object to this. + * + * Clears Variables and Functions of this parser. + * Copies the states of all internal variables. + * Resets parse function to string parse mode. + * + * @param a_Parser the source object. + */ +void QmuParserBase::Assign(const QmuParserBase &a_Parser) +{ + if (&a_Parser==this) + { + return; + } + + // Don't copy bytecode instead cause the parser to create new bytecode + // by resetting the parse function. + ReInit(); + + m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants + m_VarDef = a_Parser.m_VarDef; // Copy user defined variables + m_bBuiltInOp = a_Parser.m_bBuiltInOp; + m_vStringBuf = a_Parser.m_vStringBuf; + m_vStackBuffer = a_Parser.m_vStackBuffer; + m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; + m_StrVarDef = a_Parser.m_StrVarDef; + m_vStringVarBuf = a_Parser.m_vStringVarBuf; + m_nIfElseCounter = a_Parser.m_nIfElseCounter; + m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); + + // Copy function and operator callbacks + m_FunDef = a_Parser.m_FunDef; // Copy function definitions + m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators + m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation + m_OprtDef = a_Parser.m_OprtDef; // binary operators + + m_sNameChars = a_Parser.m_sNameChars; + m_sOprtChars = a_Parser.m_sOprtChars; + m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set the decimal separator. + * @param cDecSep Decimal separator as a character value. + * @sa SetThousandsSep + * + * By default muparser uses the "C" locale. The decimal separator of this + * locale is overwritten by the one provided here. + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::SetDecSep(char_type cDecSep) +{ + char_type cThousandsSep = std::use_facet< change_dec_sep >(s_locale).thousands_sep(); + s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Sets the thousands operator. + * @param cThousandsSep The thousands separator as a character + * @sa SetDecSep + * + * By default muparser uses the "C" locale. The thousands separator of this + * locale is overwritten by the one provided here. + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::SetThousandsSep(char_type cThousandsSep) +{ + char_type cDecSep = std::use_facet< change_dec_sep >(s_locale).decimal_point(); + s_locale = std::locale(std::locale("C"), new change_dec_sep(cDecSep, cThousandsSep)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Resets the locale. + * + * The default locale used "." as decimal separator, no thousands separator and "," as function argument separator. + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::ResetLocale() +{ + s_locale = std::locale(std::locale("C"), new change_dec_sep('.')); + SetArgSep(','); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Reset parser to string parsing mode and clear internal buffers. + * + * Clear bytecode, reset the token reader. + * @throw nothrow + */ +void QmuParserBase::ReInit() const +{ + m_pParseFormula = &QmuParserBase::ParseString; + m_vStringBuf.clear(); + m_vRPN.clear(); + m_pTokenReader->ReInit(); + m_nIfElseCounter = 0; + m_Tokens.clear(); + m_Numbers.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) +{ + Q_UNUSED(pExpr); + Q_UNUSED(nStart); + Q_UNUSED(nEnd); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::setAllowSubexpressions(bool value) +{ + allowSubexpressions = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the version of muparser. + * @param eInfo A flag indicating whether the full version info should be returned or not. + * + * Format is as follows: "MAJOR.MINOR (COMPILER_FLAGS)" The COMPILER_FLAGS are returned only if eInfo==pviFULL. + */ +// cppcheck-suppress unusedFunction +QString QmuParserBase::GetVersion(EParserVersionInfo eInfo) +{ + QString versionInfo; + QTextStream ss(&versionInfo); + + ss << QMUP_VERSION; + + if (eInfo==pviFULL) + { + ss << " (" << QMUP_VERSION_DATE; + ss << "; " << sizeof(void*)*8 << "BIT"; + + #ifdef _DEBUG + ss << "; DEBUG"; + #else + ss << "; RELEASE"; + #endif + + #ifdef _UNICODE + ss << "; UNICODE"; + #else + #ifdef _MBCS + ss << "; MBCS"; + #else + ss << "; ASCII"; + #endif + #endif + + #ifdef QMUP_USE_OPENMP + ss << "; OPENMP"; + //#else + // ss << "; NO_OPENMP"; + #endif + + #if defined(MUP_MATH_EXCEPTIONS) + ss << "; MATHEXC"; + //#else + // ss << "; NO_MATHEXC"; + #endif + + ss << ")"; + } + return versionInfo; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a function or operator callback to the parser. + */ +void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback, + funmap_type &a_Storage, const QString &a_szCharSet ) +{ + if (a_Callback.GetAddr()==0) + { + Error(ecINVALID_FUN_PTR); + } + + const funmap_type *pFunMap = &a_Storage; + + // Check for conflicting operator or function names + if ( pFunMap!=&m_FunDef && m_FunDef.find(a_strName)!=m_FunDef.end() ) + { + Error(ecNAME_CONFLICT, -1, a_strName); + } + + if ( pFunMap!=&m_PostOprtDef && m_PostOprtDef.find(a_strName)!=m_PostOprtDef.end() ) + { + Error(ecNAME_CONFLICT, -1, a_strName); + } + + if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_InfixOprtDef.find(a_strName)!=m_InfixOprtDef.end() ) + { + Error(ecNAME_CONFLICT, -1, a_strName); + } + + if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_OprtDef.find(a_strName)!=m_OprtDef.end() ) + { + Error(ecNAME_CONFLICT, -1, a_strName); + } + + CheckOprt(a_strName, a_Callback, a_szCharSet); + a_Storage[a_strName] = a_Callback; + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a name contains invalid characters. + * + * @throw ParserException if the name contains invalid charakters. + */ +void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback, + const QString &a_szCharSet) const +{ + const std::wstring a_sNameStd = a_sName.toStdWString(); + const std::wstring a_szCharSetStd = a_szCharSet.toStdWString(); + + if ( a_sNameStd.length() == false || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) || + (a_sNameStd.at(0)>='0' && a_sNameStd.at(0)<='9')) + { + switch (a_Callback.GetCode()) + { + case cmOPRT_POSTFIX: + Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); + break; + case cmOPRT_INFIX: + Error(ecINVALID_INFIX_IDENT, -1, a_sName); + break; + default: + Error(ecINVALID_NAME, -1, a_sName); + break; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a name contains invalid characters. + * + * @throw ParserException if the name contains invalid charakters. + */ +void QmuParserBase::CheckName(const QString &a_sName, const QString &a_szCharSet) const +{ + std::wstring a_sNameStd = a_sName.toStdWString(); + std::wstring a_szCharSetStd = a_szCharSet.toStdWString(); + + if ( a_sNameStd.length() == false || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) || + (a_sNameStd[0]>='0' && a_sNameStd[0]<='9')) + { + Error(ecINVALID_NAME); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set the formula. + * @param a_sExpr Formula as string_type + * @throw ParserException in case of syntax errors. + * + * Triggers first time calculation thus the creation of the bytecode and scanning of used variables. + */ +void QmuParserBase::SetExpr(const QString &a_sExpr) +{ + // Check locale compatibility + std::locale loc; + if (m_pTokenReader->GetArgSep()==std::use_facet >(loc).decimal_point()) + { + Error(ecLOCALE); + } + + // 20060222: Bugfix for Borland-Kylix: + // adding a space to the expression will keep Borlands KYLIX from going wild + // when calling tellg on a stringstream created from the expression after + // reading a value at the end of an expression. (qmu::QmuParser::IsVal function) + // (tellg returns -1 otherwise causing the parser to ignore the value) + QString sBuf(a_sExpr + " " ); + m_pTokenReader->SetFormula(sBuf); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Virtual function that defines the characters allowed in name identifiers. + * @sa #ValidOprtChars, #ValidPrefixOprtChars + */ +const QString& QmuParserBase::ValidNameChars() const +{ + assert(m_sNameChars.size()); + return m_sNameChars; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Virtual function that defines the characters allowed in operator definitions. + * @sa #ValidNameChars, #ValidPrefixOprtChars + */ +const QString &QmuParserBase::ValidOprtChars() const +{ + assert(m_sOprtChars.size()); + return m_sOprtChars; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Virtual function that defines the characters allowed in infix operator definitions. + * @sa #ValidNameChars, #ValidOprtChars + */ +const QString &QmuParserBase::ValidInfixOprtChars() const +{ + assert(m_sInfixOprtChars.size()); + return m_sInfixOprtChars; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a user defined operator. + * @post Will reset the Parser to string parsing mode. + */ +void QmuParserBase::DefinePostfixOprt(const QString &a_sName, fun_type1 a_pFun, bool a_bAllowOpt) +{ + AddCallback(a_sName, QmuParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), m_PostOprtDef, + ValidOprtChars() ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize user defined functions. + * + * Calls the virtual functions InitFun(), InitConst() and InitOprt(). + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::Init() +{ + InitCharSets(); + InitFun(); + InitConst(); + InitOprt(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a user defined operator. + * @post Will reset the Parser to string parsing mode. + * @param [in] a_sName operator Identifier + * @param [in] a_pFun Operator callback function + * @param [in] a_iPrec Operator Precedence (default=prSIGN) + * @param [in] a_bAllowOpt True if operator is volatile (default=false) + * @sa EPrec + */ +void QmuParserBase::DefineInfixOprt(const QString &a_sName, fun_type1 a_pFun, int a_iPrec, bool a_bAllowOpt) +{ + AddCallback(a_sName, QmuParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), m_InfixOprtDef, + ValidInfixOprtChars() ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define a binary operator. + * @param [in] a_sName The identifier of the operator. + * @param [in] a_pFun Pointer to the callback function. + * @param [in] a_iPrec Precedence of the operator. + * @param [in] a_eAssociativity The associativity of the operator. + * @param [in] a_bAllowOpt If this is true the operator may be optimized away. + * + * Adds a new Binary operator the the parser instance. + */ +void QmuParserBase::DefineOprt( const QString &a_sName, fun_type2 a_pFun, unsigned a_iPrec, + EOprtAssociativity a_eAssociativity, bool a_bAllowOpt ) +{ + // Check for conflicts with built in operator names + for (int i=0; m_bBuiltInOp && i(a_iPrec), a_eAssociativity), m_OprtDef, + ValidOprtChars() ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define a new string constant. + * @param [in] a_strName The name of the constant. + * @param [in] a_strVal the value of the constant. + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::DefineStrConst(const QString &a_strName, const QString &a_strVal) +{ + // Test if a constant with that names already exists + if (m_StrVarDef.find(a_strName)!=m_StrVarDef.end()) + { + Error(ecNAME_CONFLICT); + } + + CheckName(a_strName, ValidNameChars()); + + m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer + m_StrVarDef[a_strName] = m_vStringBuf.size(); // bind buffer index to variable name + + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a user defined variable. + * @param [in] a_sName the variable name + * @param [in] a_pVar A pointer to the variable vaule. + * @post Will reset the Parser to string parsing mode. + * @throw ParserException in case the name contains invalid signs or a_pVar is NULL. + */ +void QmuParserBase::DefineVar(const QString &a_sName, qreal *a_pVar) +{ + if (a_pVar==0) + { + Error(ecINVALID_VAR_PTR); + } + + // Test if a constant with that names already exists + if (m_ConstDef.find(a_sName)!=m_ConstDef.end()) + { + Error(ecNAME_CONFLICT); + } + + CheckName(a_sName, ValidNameChars()); + m_VarDef[a_sName] = a_pVar; + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a user defined constant. + * @param [in] a_sName The name of the constant. + * @param [in] a_fVal the value of the constant. + * @post Will reset the Parser to string parsing mode. + * @throw ParserException in case the name contains invalid signs. + */ +void QmuParserBase::DefineConst(const QString &a_sName, qreal a_fVal) +{ + CheckName(a_sName, ValidNameChars()); + m_ConstDef[a_sName] = a_fVal; + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Get operator priority. + * @throw ParserException if a_Oprt is no operator code + */ +int QmuParserBase::GetOprtPrecedence(const token_type &a_Tok) const +{ + switch (a_Tok.GetCode()) + { + // built in operators + case cmEND: + return -5; + case cmARG_SEP: + return -4; + case cmASSIGN: + return -1; + case cmELSE: + case cmIF: + return 0; + case cmLAND: + return prLAND; + case cmLOR: + return prLOR; + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + return prCMP; + case cmADD: + case cmSUB: + return prADD_SUB; + case cmMUL: + case cmDIV: + return prMUL_DIV; + case cmPOW: + return prPOW; + // user defined binary operators + case cmOPRT_INFIX: + case cmOPRT_BIN: + return a_Tok.GetPri(); + default: + Error(ecINTERNAL_ERROR, 5); + return 999; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Get operator priority. + * @throw ParserException if a_Oprt is no operator code + */ +EOprtAssociativity QmuParserBase::GetOprtAssociativity(const token_type &a_Tok) const +{ + switch (a_Tok.GetCode()) + { + case cmASSIGN: + case cmLAND: + case cmLOR: + case cmLT: + case cmGT: + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + return oaLEFT; + case cmPOW: + return oaRIGHT; + case cmOPRT_BIN: + return a_Tok.GetAssociativity(); + default: + return oaNONE; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return a map containing the used variables only. + */ +const varmap_type& QmuParserBase::GetUsedVar() const +{ + try + { + m_pTokenReader->IgnoreUndefVar(true); + CreateRPN(); // try to create bytecode, but don't use it for any further calculations since it + // may contain references to nonexisting variables. + m_pParseFormula = &QmuParserBase::ParseString; + m_pTokenReader->IgnoreUndefVar(false); + } + catch (const QmuParserError &e) + { + Q_UNUSED(e) + // Make sure to stay in string parse mode, dont call ReInit() + // because it deletes the array with the used variables + m_pParseFormula = &QmuParserBase::ParseString; + m_pTokenReader->IgnoreUndefVar(false); + throw; + } + return m_pTokenReader->GetUsedVar(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Execute a function that takes a single string argument. + * @param a_FunTok Function token. + * @throw QmuParserError If the function token is not a string function + */ +QmuParserBase::token_type QmuParserBase::ApplyStrFunc(const token_type &a_FunTok, + const QVector &a_vArg) const +{ + if (a_vArg.back().GetCode()!=cmSTRING) + { + Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + } + + token_type valTok; + generic_fun_type pFunc = a_FunTok.GetFuncAddr(); + assert(pFunc); + + try + { + // Check function arguments; write dummy value into valtok to represent the result + switch (a_FunTok.GetArgCount()) + { + case 0: + valTok.SetVal(1); + a_vArg[0].GetAsString(); + break; + case 1: + valTok.SetVal(1); + a_vArg[1].GetAsString(); + a_vArg[0].GetVal(); + break; + case 2: + valTok.SetVal(1); + a_vArg[2].GetAsString(); + a_vArg[1].GetVal(); + a_vArg[0].GetVal(); + break; + default: + Error(ecINTERNAL_ERROR); + break; + } + } + catch (QmuParserError& ) + { + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); + } + + // string functions won't be optimized + m_vRPN.AddStrFun(pFunc, a_FunTok.GetArgCount(), a_vArg.back().GetIdx()); + + // Push dummy value representing the function result to the stack + return valTok; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Apply a function token. + * @param a_iArgCount Number of Arguments actually gathered used only for multiarg functions. + * @post The result is pushed to the value stack + * @post The function token is removed from the stack + * @throw QmuParserError if Argument count does not mach function requirements. + */ +void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack &a_stVal, int a_iArgCount) const +{ + assert(m_pTokenReader.get()); + + // Operator stack empty or does not contain tokens with callback functions + if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr()==0 ) + { + return; + } + + token_type funTok = a_stOpt.pop(); + assert(funTok.GetFuncAddr()); + + // Binary operators must rely on their internal operator number + // since counting of operators relies on commas for function arguments + // binary operators do not have commas in their expression + int iArgCount = (funTok.GetCode()==cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; + + // determine how many parameters the function needs. To remember iArgCount includes the + // string parameter whilst GetArgCount() counts only numeric parameters. + int iArgRequired = funTok.GetArgCount() + ((funTok.GetType()==tpSTR) ? 1 : 0); + + // Thats the number of numerical parameters + int iArgNumerical = iArgCount - ((funTok.GetType()==tpSTR) ? 1 : 0); + + if (funTok.GetCode()==cmFUNC_STR && iArgCount-iArgNumerical>1) + { + Error(ecINTERNAL_ERROR); + } + + if (funTok.GetArgCount()>=0 && iArgCount>iArgRequired) + { + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + } + + if (funTok.GetCode()!=cmOPRT_BIN && iArgCountGetPos()-1, funTok.GetAsString()); + } + + if (funTok.GetCode()==cmFUNC_STR && iArgCount>iArgRequired ) + { + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + } + + // Collect the numeric function arguments from the value stack and store them + // in a vector + QVector stArg; + for (int i=0; iGetPos(), funTok.GetAsString()); + } + stArg.push_back( a_stVal.pop() ); + if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + { + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + } + + switch (funTok.GetCode()) + { + case cmFUNC_STR: + stArg.push_back(a_stVal.pop()); + + if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + { + Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + + ApplyStrFunc(funTok, stArg); + break; + case cmFUNC_BULK: + m_vRPN.AddBulkFun(funTok.GetFuncAddr(), stArg.size()); + break; + case cmOPRT_BIN: + case cmOPRT_POSTFIX: + case cmOPRT_INFIX: + case cmFUNC: + if (funTok.GetArgCount()==-1 && iArgCount==0) + { + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), funTok.GetAsString()); + } + + m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount()==-1) ? -iArgNumerical : iArgNumerical); + break; + default: + break; + } + // Push dummy value representing the function result to the stack + token_type token; + token.SetVal(1); + a_stVal.push(token); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::ApplyIfElse(QStack &a_stOpt, QStack &a_stVal) const +{ + // Check if there is an if Else clause to be calculated + while (a_stOpt.size() && a_stOpt.top().GetCode()==cmELSE) + { + token_type opElse = a_stOpt.pop(); + Q_ASSERT(a_stOpt.size()>0); + + // Take the value associated with the else branch from the value stack + token_type vVal2 = a_stVal.pop(); + + Q_ASSERT(a_stOpt.size()>0); + Q_ASSERT(a_stVal.size()>=2); + + // it then else is a ternary operator Pop all three values from the value s + // tack and just return the right value + token_type vVal1 = a_stVal.pop(); + token_type vExpr = a_stVal.pop(); + + a_stVal.push( (qFuzzyCompare(vExpr.GetVal()+1, 1+0)==false) ? vVal1 : vVal2); + + token_type opIf = a_stOpt.pop(); + Q_ASSERT(opElse.GetCode()==cmELSE); + Q_ASSERT(opIf.GetCode()==cmIF); + + m_vRPN.AddIfElse(cmENDIF); + } // while pending if-else-clause found +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Performs the necessary steps to write code for the execution of binary operators into the bytecode. + */ +void QmuParserBase::ApplyBinOprt(QStack &a_stOpt, QStack &a_stVal) const +{ + // is it a user defined binary operator? + if (a_stOpt.top().GetCode()==cmOPRT_BIN) + { + ApplyFunc(a_stOpt, a_stVal, 2); + } + else + { + Q_ASSERT(a_stVal.size()>=2); + token_type valTok1 = a_stVal.pop(), + valTok2 = a_stVal.pop(), + optTok = a_stOpt.pop(), + resTok; + + if ( valTok1.GetType()!=valTok2.GetType() || (valTok1.GetType()==tpSTR && valTok2.GetType()==tpSTR) ) + { + Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); + } + + if (optTok.GetCode()==cmASSIGN) + { + if (valTok2.GetCode()!=cmVAR) + { + Error(ecUNEXPECTED_OPERATOR, -1, "="); + } + m_vRPN.AddAssignOp(valTok2.GetVar()); + } + else + { + m_vRPN.AddOp(optTok.GetCode()); + } + resTok.SetVal(1); + a_stVal.push(resTok); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Apply a binary operator. + * @param stOpt The operator stack + * @param stVal The value stack + */ +void QmuParserBase::ApplyRemainingOprt(QStack &stOpt, QStack &stVal) const +{ + while (stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmIF) + { + token_type tok = stOpt.top(); + const ECmdCode code = tok.GetCode(); + + if ((code >= cmLE && code <= cmASSIGN) || code == cmOPRT_INFIX || code == cmOPRT_BIN) + { + if (stOpt.top().GetCode()==cmOPRT_INFIX) + { + ApplyFunc(stOpt, stVal, 1); + } + else + { + ApplyBinOprt(stOpt, stVal); + } + } + else if (code == cmELSE) + { + ApplyIfElse(stOpt, stVal); + } + else + { + Error(ecINTERNAL_ERROR); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Parse the command code. + * @sa ParseString(...) + * + * Command code contains precalculated stack positions of the values and the associated operators. The Stack is + * filled beginning from index one the value at index zero is not used at all. + */ +qreal QmuParserBase::ParseCmdCode() const +{ + return ParseCmdCodeBulk(0, 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Evaluate the RPN. + * @param nOffset The offset added to variable addresses (for bulk mode) + * @param nThreadID OpenMP Thread id of the calling thread + */ +qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const +{ + assert(nThreadID<=s_MaxNumOpenMPThreads); + + // Note: The check for nOffset==0 and nThreadID here is not necessary but + // brings a minor performance gain when not in bulk mode. + qreal *Stack = ((nOffset==0) && (nThreadID==0)) ? &m_vStackBuffer[0] : &m_vStackBuffer[nThreadID * + (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; + qreal buf; + int sidx(0); + for (const SToken *pTok = m_vRPN.GetBase(); pTok->Cmd!=cmEND ; ++pTok) + { + switch (pTok->Cmd) + { + // built in binary operators + case cmLE: + --sidx; + Stack[sidx] = Stack[sidx] <= Stack[sidx+1]; + continue; + case cmGE: + --sidx; + Stack[sidx] = Stack[sidx] >= Stack[sidx+1]; + continue; + case cmNEQ: + --sidx; + Stack[sidx] = (qFuzzyCompare(Stack[sidx], Stack[sidx+1])==false); + continue; + case cmEQ: + --sidx; + Stack[sidx] = qFuzzyCompare(Stack[sidx], Stack[sidx+1]); + continue; + case cmLT: + --sidx; + Stack[sidx] = Stack[sidx] < Stack[sidx+1]; + continue; + case cmGT: + --sidx; + Stack[sidx] = Stack[sidx] > Stack[sidx+1]; + continue; + case cmADD: + --sidx; + Stack[sidx] += Stack[1+sidx]; + continue; + case cmSUB: + --sidx; + Stack[sidx] -= Stack[1+sidx]; + continue; + case cmMUL: + --sidx; + Stack[sidx] *= Stack[1+sidx]; + continue; + case cmDIV: + --sidx; + #if defined(MUP_MATH_EXCEPTIONS) + if (Stack[1+sidx]==0) + { + Error(ecDIV_BY_ZERO); + } + #endif + Stack[sidx] /= Stack[1+sidx]; + continue; + case cmPOW: + --sidx; + Stack[sidx] = qPow(Stack[sidx], Stack[1+sidx]); + continue; + case cmLAND: + --sidx; +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + Stack[sidx] = static_cast(Stack[sidx]) && static_cast(Stack[sidx+1]); +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif + continue; + case cmLOR: + --sidx; +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + Stack[sidx] = static_cast(Stack[sidx]) || static_cast(Stack[sidx+1]); +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif + continue; + case cmASSIGN: + --sidx; + Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; + continue; + case cmIF: + if (qFuzzyCompare(Stack[sidx--]+1, 1+0)) + { + pTok += pTok->Oprt.offset; + } + continue; + case cmELSE: + pTok += pTok->Oprt.offset; + continue; + case cmENDIF: + continue; + + // value and variable tokens + case cmVAR: + Stack[++sidx] = *(pTok->Val.ptr + nOffset); + continue; + case cmVAL: + Stack[++sidx] = pTok->Val.data2; + continue; + case cmVARPOW2: + buf = *(pTok->Val.ptr + nOffset); + Stack[++sidx] = buf*buf; + continue; + case cmVARPOW3: + buf = *(pTok->Val.ptr + nOffset); + Stack[++sidx] = buf*buf*buf; + continue; + case cmVARPOW4: + buf = *(pTok->Val.ptr + nOffset); + Stack[++sidx] = buf*buf*buf*buf; + continue; + case cmVARMUL: + Stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2; + continue; + // Next is treatment of numeric functions + case cmFUNC: + { + int iArgCount = pTok->Fun.argc; +#ifdef Q_CC_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundefined-reinterpret-cast" +#endif + + // switch according to argument count + switch (iArgCount) + { + case 0: + sidx += 1; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(); + continue; + case 1: + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx]); + continue; + case 2: + sidx -= 1; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1]); + continue; + case 3: + sidx -= 2; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2]); + continue; + case 4: + sidx -= 3; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3]); + continue; + case 5: + sidx -= 4; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); + continue; + case 6: + sidx -= 5; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); + continue; + case 7: + sidx -= 6; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); + continue; + case 8: + sidx -= 7; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], + Stack[sidx+7]); + continue; + case 9: + sidx -= 8; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], + Stack[sidx+7], Stack[sidx+8]); + continue; + case 10: + sidx -= 9; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], + Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], + Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); + continue; + default: + if (iArgCount>0) // function with variable arguments store the number as a negative value + { + Error(ecINTERNAL_ERROR, 1); + } + + sidx -= -iArgCount - 1; + Stack[sidx] =(*reinterpret_cast(pTok->Fun.ptr))(&Stack[sidx], -iArgCount); + continue; + } + } + // Next is treatment of string functions + case cmFUNC_STR: + { + sidx -= pTok->Fun.argc -1; + + // The index of the string argument in the string table + int iIdxStack = pTok->Fun.idx; + Q_ASSERT( iIdxStack>=0 && iIdxStackFun.argc) // switch according to argument count + { + case 0: + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack)); + continue; + case 1: + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack), + Stack[sidx]); + continue; + case 2: + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack), + Stack[sidx], Stack[sidx+1]); + continue; + default: + break; + } + + continue; + } + case cmFUNC_BULK: + { + int iArgCount = pTok->Fun.argc; + + // switch according to argument count + switch (iArgCount) + { + case 0: + sidx += 1; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID); + continue; + case 1: + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, + Stack[sidx]); + continue; + case 2: + sidx -= 1; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1]); + continue; + case 3: + sidx -= 2; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2]); + continue; + case 4: + sidx -= 3; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); + continue; + case 5: + sidx -= 4; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], + Stack[sidx+4]); + continue; + case 6: + sidx -= 5; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], + Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); + continue; + case 7: + sidx -= 6; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], + Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); + continue; + case 8: + sidx -= 7; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], + Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); + continue; + case 9: + sidx -= 8; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], + Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); + continue; + case 10: + sidx -= 9; + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, + Stack[sidx], + Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], + Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], + Stack[sidx+9]); + continue; + default: + Error(ecINTERNAL_ERROR, 2); + continue; + } + } + case cmSTRING: + case cmOPRT_BIN: + case cmOPRT_POSTFIX: + case cmOPRT_INFIX: + // Q_ASSERT(INVALID_CODE_IN_BYTECODE); + // continue; + case cmEND: + // return Stack[m_nFinalResultIdx]; + case cmPOW2: + case cmUNKNOWN: + case cmBO: // unused, listed for compiler optimization purposes + case cmBC: + // Q_ASSERT(INVALID_CODE_IN_BYTECODE); + // continue; + case cmARG_SEP: + // Q_ASSERT(INVALID_CODE_IN_BYTECODE); + // continue; + default: + Error(ecINTERNAL_ERROR, 3); + return 0; + } // switch CmdCode + +#ifdef Q_CC_CLANG + #pragma clang diagnostic pop +#endif + + } // for all bytecode tokens + + return Stack[m_nFinalResultIdx]; +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::CreateRPN() const +{ + if (m_pTokenReader->GetExpr().length() == false) + { + Error(ecUNEXPECTED_EOF, 0); + } + + QStack stOpt, stVal; + QStack stArgCount; + token_type opta, opt; // for storing operators + //token_type val, tval; // for storing value + //string_type strBuf; // buffer for string function arguments + + ReInit(); + + // The outermost counter counts the number of seperated items + // such as in "a=10,b=20,c=c+a" + stArgCount.push(1); + + for (;;) + { + opt = m_pTokenReader->ReadNextToken(); + + switch (opt.GetCode()) + { + // + // Next three are different kind of value entries + // + case cmSTRING: + opt.SetIdx(m_vStringBuf.size()); // Assign buffer index to token + stVal.push(opt); + m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer + m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + break; + case cmVAR: + stVal.push(opt); + m_vRPN.AddVar( static_cast(opt.GetVar()) ); + m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + break; + case cmVAL: + stVal.push(opt); + m_vRPN.AddVal( opt.GetVal() ); + m_Numbers.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + break; + case cmELSE: + m_nIfElseCounter--; + if (m_nIfElseCounter<0) + { + Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); + } + ApplyRemainingOprt(stOpt, stVal); + m_vRPN.AddIfElse(cmELSE); + stOpt.push(opt); + break; + case cmARG_SEP: + if (stArgCount.empty()) + { + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + } + if (stOpt.empty() && allowSubexpressions == false) + { + Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos()); + } + ++stArgCount.top(); + // fallthrough intentional (no break!) + #ifdef Q_CC_CLANG + [[clang::fallthrough]]; + #endif + case cmEND: + ApplyRemainingOprt(stOpt, stVal); + break; + case cmBC: + { + // The argument count for parameterless functions is zero + // by default an opening bracket sets parameter count to 1 + // in preparation of arguments to come. If the last token + // was an opening bracket we know better... + if (opta.GetCode()==cmBO) + { + --stArgCount.top(); + } + + ApplyRemainingOprt(stOpt, stVal); + + // Check if the bracket content has been evaluated completely + if (stOpt.size() && stOpt.top().GetCode()==cmBO) + { + // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check + // if there is either a function or a sign pending + // neither the opening nor the closing bracket will be pushed back to + // the operator stack + // Check if a function is standing in front of the opening bracket, + // if yes evaluate it afterwards check for infix operators + assert(stArgCount.size()); + int iArgCount = stArgCount.pop(); + + stOpt.pop(); // Take opening bracket from stack + + if (iArgCount>1 && ( stOpt.size()==0 || (stOpt.top().GetCode()!=cmFUNC && + stOpt.top().GetCode()!=cmFUNC_BULK && + stOpt.top().GetCode()!=cmFUNC_STR) ) ) + { + Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); + } + + // The opening bracket was popped from the stack now check if there + // was a function before this bracket + if (stOpt.size() && stOpt.top().GetCode()!=cmOPRT_INFIX && stOpt.top().GetCode()!=cmOPRT_BIN && + stOpt.top().GetFuncAddr()!=0) + { + ApplyFunc(stOpt, stVal, iArgCount); + } + } + } // if bracket content is evaluated + break; + // + // Next are the binary operator entries + // + //case cmAND: // built in binary operators + //case cmOR: + //case cmXOR: + case cmIF: + m_nIfElseCounter++; + // fallthrough intentional (no break!) + #ifdef Q_CC_CLANG + [[clang::fallthrough]]; + #endif + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmLT: + case cmGT: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmLAND: + case cmLOR: + case cmASSIGN: + case cmOPRT_BIN: + // A binary operator (user defined or built in) has been found. + while ( stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmELSE && + stOpt.top().GetCode() != cmIF) + { + int nPrec1 = GetOprtPrecedence(stOpt.top()), + nPrec2 = GetOprtPrecedence(opt); + + if (stOpt.top().GetCode()==opt.GetCode()) + { + // Deal with operator associativity + EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); + if ( (eOprtAsct==oaRIGHT && (nPrec1 <= nPrec2)) || + (eOprtAsct==oaLEFT && (nPrec1 < nPrec2)) ) + { + break; + } + } + else if (nPrec1 < nPrec2) + { + // In case the operators are not equal the precedence decides alone... + break; + } + if (stOpt.top().GetCode()==cmOPRT_INFIX) + { + ApplyFunc(stOpt, stVal, 1); + } + else + { + ApplyBinOprt(stOpt, stVal); + } + } // while ( ... ) + + if (opt.GetCode()==cmIF) + { + m_vRPN.AddIfElse(opt.GetCode()); + } + + // The operator can't be evaluated right now, push back to the operator stack + stOpt.push(opt); + break; + // + // Last section contains functions and operators implicitely mapped to functions + // + case cmBO: + stArgCount.push(1); + stOpt.push(opt); + break; + case cmOPRT_INFIX: + case cmFUNC: + case cmFUNC_BULK: + case cmFUNC_STR: + stOpt.push(opt); + m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + break; + case cmOPRT_POSTFIX: + stOpt.push(opt); + ApplyFunc(stOpt, stVal, 1); // this is the postfix operator + m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + break; + case cmENDIF: + case cmVARPOW2: + case cmVARPOW3: + case cmVARPOW4: + case cmVARMUL: + case cmPOW2: + case cmUNKNOWN: + default: + Error(ecINTERNAL_ERROR, 3); + } // end of switch operator-token + + opta = opt; + + if ( opt.GetCode() == cmEND ) + { + m_vRPN.Finalize(); + break; + } + + if (QmuParserBase::g_DbgDumpStack) + { + StackDump(stVal, stOpt); + m_vRPN.AsciiDump(); + } + } // while (true) + + if (QmuParserBase::g_DbgDumpCmdCode) + { + m_vRPN.AsciiDump(); + } + + if (m_nIfElseCounter>0) + { + Error(ecMISSING_ELSE_CLAUSE); + } + + // get the last value (= final result) from the stack + Q_ASSERT(stArgCount.size()==1); + m_nFinalResultIdx = stArgCount.top(); + if (m_nFinalResultIdx==0) + { + Error(ecINTERNAL_ERROR, 9); + } + + if (stVal.size()==0) + { + Error(ecEMPTY_EXPRESSION); + } + + if (stVal.top().GetType()!=tpDBL) + { + Error(ecSTR_RESULT); + } + + m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief One of the two main parse functions. + * @sa ParseCmdCode(...) + * + * Parse expression from input string. Perform syntax checking and create bytecode. After parsing the string and + * creating the bytecode the function pointer #m_pParseFormula will be changed to the second parse routine the + * uses bytecode instead of string parsing. + */ +qreal QmuParserBase::ParseString() const +{ + try + { + CreateRPN(); + m_pParseFormula = &QmuParserBase::ParseCmdCode; + return (this->*m_pParseFormula)(); + } + catch (qmu::QmuParserError &exc) + { + exc.SetFormula(m_pTokenReader->GetExpr()); + throw; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** +* @brief Create an error containing the parse error position. +* +* This function will create an Parser Exception object containing the error text and its position. +* +* @param a_iErrc [in] The error code of type #EErrorCodes. +* @param a_iPos [in] The position where the error was detected. +* @param a_sTok [in] The token string representation associated with the error. +* @throw ParserException always throws thats the only purpose of this function. +*/ +void Q_NORETURN QmuParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const QString &a_sTok) const +{ + throw qmu::QmuParserError (a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear all user defined variables. + * @throw nothrow + * + * Resets the parser to string parsing mode by calling #ReInit. + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::ClearVar() +{ + m_VarDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Remove a variable from internal storage. + * @throw nothrow + * + * Removes a variable if it exists. If the Variable does not exist nothing will be done. + */ +void QmuParserBase::RemoveVar(const QString &a_strVarName) +{ + varmap_type::iterator item = m_VarDef.find(a_strVarName); + if (item!=m_VarDef.end()) + { + m_VarDef.erase(item); + ReInit(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear all functions. + * @post Resets the parser to string parsing mode. + * @throw nothrow + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::ClearFun() +{ + m_FunDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear all user defined constants. + * + * Both numeric and string constants will be removed from the internal storage. + * @post Resets the parser to string parsing mode. + * @throw nothrow + */ +void QmuParserBase::ClearConst() +{ + m_ConstDef.clear(); + m_StrVarDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear all user defined postfix operators. + * @post Resets the parser to string parsing mode. + * @throw nothrow + */ +void QmuParserBase::ClearPostfixOprt() +{ + m_PostOprtDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear all user defined binary operators. + * @post Resets the parser to string parsing mode. + * @throw nothrow + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::ClearOprt() +{ + m_OprtDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear the user defined Prefix operators. + * @post Resets the parser to string parser mode. + * @throw nothrow + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::ClearInfixOprt() +{ + m_InfixOprtDef.clear(); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Enable or disable the formula optimization feature. + * @post Resets the parser to string parser mode. + * @throw nothrow + */ +void QmuParserBase::EnableOptimizer(bool a_bIsOn) +{ + m_vRPN.EnableOptimizer(a_bIsOn); + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Enable the dumping of bytecode amd stack content on the console. + * @param bDumpCmd Flag to enable dumping of the current bytecode to the console. + * @param bDumpStack Flag to enable dumping of the stack content is written to the console. + * + * This function is for debug purposes only! + */ +// cppcheck-suppress unusedFunction +void QmuParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack) +{ + QmuParserBase::g_DbgDumpCmdCode = bDumpCmd; + QmuParserBase::g_DbgDumpStack = bDumpStack; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Enable or disable the built in binary operators. + * @throw nothrow + * @sa m_bBuiltInOp, ReInit() + * + * If you disable the built in binary operators there will be no binary operators defined. Thus you must add them + * manually one by one. It is not possible to disable built in operators selectively. This function will Reinitialize + * the parser by calling ReInit(). + */ +void QmuParserBase::EnableBuiltInOprt(bool a_bIsOn) +{ + m_bBuiltInOp = a_bIsOn; + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Get the argument separator character. + */ +QChar QmuParserBase::GetArgSep() const +{ + return m_pTokenReader->GetArgSep(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set argument separator. + * @param cArgSep the argument separator character. + */ +void QmuParserBase::SetArgSep(char_type cArgSep) +{ + m_pTokenReader->SetArgSep(cArgSep); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Dump stack content. + * + * This function is used for debugging only. + */ +void QmuParserBase::StackDump(const QStack &a_stVal, const QStack &a_stOprt) const +{ + QStack stOprt(a_stOprt), + stVal(a_stVal); + + qDebug() << "\nValue stack:\n"; + while ( stVal.empty() == false ) + { + token_type val = stVal.pop(); + if (val.GetType()==tpSTR) + { + qDebug() << " \"" << val.GetAsString() << "\" "; + } + else + { + qDebug() << " " << val.GetVal() << " "; + } + } + qDebug() << "\nOperator stack:\n"; + + while ( stOprt.empty() == false ) + { + if (stOprt.top().GetCode()<=cmASSIGN) + { + qDebug() << "OPRT_INTRNL \"" << QmuParserBase::c_DefaultOprt[stOprt.top().GetCode()] << "\" \n"; + } + else + { + switch ( stOprt.top().GetCode()) + { + case cmVAR: + qDebug() << "VAR\n"; + break; + case cmVAL: + qDebug() << "VAL\n"; + break; + case cmFUNC: + qDebug() << "FUNC \"" << stOprt.top().GetAsString() << "\"\n"; + break; + case cmFUNC_BULK: + qDebug() << "FUNC_BULK \"" << stOprt.top().GetAsString() << "\"\n"; + break; + case cmOPRT_INFIX: + qDebug() << "OPRT_INFIX \"" << stOprt.top().GetAsString() << "\"\n"; + break; + case cmOPRT_BIN: + qDebug() << "OPRT_BIN \"" << stOprt.top().GetAsString() << "\"\n"; + break; + case cmFUNC_STR: + qDebug() << "FUNC_STR\n"; + break; + case cmEND: + qDebug() << "END\n"; + break; + case cmUNKNOWN: + qDebug() << "UNKNOWN\n"; + break; + case cmBO: + qDebug() << "BRACKET \"(\"\n"; + break; + case cmBC: + qDebug() << "BRACKET \")\"\n"; + break; + case cmIF: + qDebug() << "IF\n"; + break; + case cmELSE: + qDebug() << "ELSE\n"; + break; + case cmENDIF: + qDebug() << "ENDIF\n"; + break; + default: + qDebug() << stOprt.top().GetCode() << " "; + break; + } + } + stOprt.pop(); + } + qDebug() << dec; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** @brief Evaluate an expression containing comma seperated subexpressions + * @param [out] nStackSize The total number of results available + * @return Pointer to the array containing all expression results + * + * This member function can be used to retriev all results of an expression made up of multiple comma seperated + * subexpressions (i.e. "x+y,sin(x),cos(y)") + */ +qreal* QmuParserBase::Eval(int &nStackSize) const +{ + (this->*m_pParseFormula)(); + nStackSize = m_nFinalResultIdx; + + // (for historic reasons the stack starts at position 1) + return &m_vStackBuffer[1]; +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserBase::Eval(qreal *results, int nBulkSize) const +{ + CreateRPN(); + + int i = 0; + + #ifdef QMUP_USE_OPENMP + //#define DEBUG_OMP_STUFF + #ifdef DEBUG_OMP_STUFF + int *pThread = new int[nBulkSize]; + int *pIdx = new int[nBulkSize]; + #endif + + int nMaxThreads = qMin(omp_get_max_threads(), s_MaxNumOpenMPThreads); + // cppcheck-suppress variableScope + int nThreadID; + // cppcheck-suppress unreadVariable + int ct=0; + omp_set_num_threads(nMaxThreads); + + #pragma omp parallel for schedule(static, nBulkSize/nMaxThreads) private(nThreadID) + for (i=0; iSetVarCreator(a_pFactory, pUserData); +} + +} // namespace qmu diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h new file mode 100644 index 000000000..59d8b7c59 --- /dev/null +++ b/src/libs/qmuparser/qmuparserbase.h @@ -0,0 +1,429 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUQPARSERBASE_H +#define QMUQPARSERBASE_H + +#include "qmuparser_global.h" +#include +#include +#include + +#include "qmuparserdef.h" +#include "qmuparsertokenreader.h" +#include "qmuparserbytecode.h" + +namespace qmu +{ +/** + * @file + * @brief This file contains the class definition of the qmuparser engine. + */ + +/** + * @brief Mathematical expressions parser (base parser engine). + * @author (C) 2013 Ingo Berg + * + * This is the implementation of a bytecode based mathematical expressions parser. + * The formula will be parsed from string and converted into a bytecode. + * Future calculations will be done with the bytecode instead the formula string + * resulting in a significant performance increase. + * Complementary to a set of internally implemented functions the parser is able to handle + * user defined functions and variables. + */ +class QMUPARSERSHARED_EXPORT QmuParserBase +{ + friend class QmuParserTokenReader; +public: + QmuParserBase(); + QmuParserBase(const QmuParserBase &a_Parser); + QmuParserBase& operator=(const QmuParserBase &a_Parser); + virtual ~QmuParserBase(); + + static void EnableDebugDump(bool bDumpCmd, bool bDumpStack); + qreal Eval() const; + qreal* Eval(int &nStackSize) const; + void Eval(qreal *results, int nBulkSize) const; + int GetNumResults() const; + void SetExpr(const QString &a_sExpr); + void SetVarFactory(facfun_type a_pFactory, void *pUserData = nullptr); + void SetDecSep(char_type cDecSep); + void SetThousandsSep(char_type cThousandsSep = 0); + void ResetLocale(); + void EnableOptimizer(bool a_bIsOn=true); + void EnableBuiltInOprt(bool a_bIsOn=true); + bool HasBuiltInOprt() const; + void AddValIdent(identfun_type a_pCallback); + void DefineOprt(const QString &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, + EOprtAssociativity a_eAssociativity = oaLEFT, bool a_bAllowOpt = false); + void DefineConst(const QString &a_sName, qreal a_fVal); + void DefineStrConst(const QString &a_sName, const QString &a_strVal); + void DefineVar(const QString &a_sName, qreal *a_fVar); + void DefinePostfixOprt(const QString &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true); + void DefineInfixOprt(const QString &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, + bool a_bAllowOpt=true); + // Clear user defined variables, constants or functions + void ClearVar(); + void ClearFun(); + void ClearConst(); + void ClearInfixOprt(); + void ClearPostfixOprt(); + void ClearOprt(); + void RemoveVar(const QString &a_strVarName); + const varmap_type& GetUsedVar() const; + const varmap_type& GetVar() const; + const valmap_type& GetConst() const; + const QString& GetExpr() const; + const funmap_type& GetFunDef() const; + static QString GetVersion(EParserVersionInfo eInfo = pviFULL); + static const QStringList& GetOprtDef(); + QMap GetTokens() const; + QMap GetNumbers() const; + void DefineNameChars(const QString &a_szCharset); + void DefineOprtChars(const QString &a_szCharset); + void DefineInfixOprtChars(const QString &a_szCharset); + const QString& ValidNameChars() const; + const QString& ValidOprtChars() const; + const QString& ValidInfixOprtChars() const; + void SetArgSep(char_type cArgSep); + QChar GetArgSep() const; + void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_strTok = QString() ) const; + /** + * @fn void qmu::QmuParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun, + * bool a_bAllowOpt = true) + * @brief Define a parser function without arguments. + * @param a_strName Name of the function + * @param a_pFun Pointer to the callback function + * @param a_bAllowOpt A flag indicating this function may be optimized + */ + template + void DefineFun(const QString &a_strName, T a_pFun, bool a_bAllowOpt = true) + { + AddCallback( a_strName, QmuParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars() ); + } + void setAllowSubexpressions(bool value); + +protected: + static const QStringList c_DefaultOprt; + static std::locale s_locale; ///< The locale used by the parser + static bool g_DbgDumpCmdCode; + static bool g_DbgDumpStack; + void Init(); + virtual void InitCharSets() = 0; + virtual void InitFun() = 0; + virtual void InitConst() = 0; + virtual void InitOprt() = 0; + virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd); + /** + * @brief A facet class used to change decimal and thousands separator. + */ + template + class change_dec_sep : public std::numpunct + { + public: + explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3) + :std::numpunct(), m_nGroup(nGroup), m_cDecPoint(cDecSep), m_cThousandsSep(cThousandsSep) + {} + protected: + virtual char_type do_decimal_point() const + { + return m_cDecPoint; + } + + virtual char_type do_thousands_sep() const + { + return m_cThousandsSep; + } + + virtual std::string do_grouping() const + { + // fix for issue 4: https://code.google.com/p/muparser/issues/detail?id=4 + // courtesy of Jens Bartsch + // original code: + // return std::string(1, (char)m_nGroup); + // new code: + return std::string(1, static_cast(m_cThousandsSep > 0 ? m_nGroup : CHAR_MAX)); + } + private: + int m_nGroup; + char_type m_cDecPoint; + char_type m_cThousandsSep; + }; +private: + /** + * @brief Typedef for the parse functions. + * + * The parse function do the actual work. The parser exchanges + * the function pointer to the parser function depending on + * which state it is in. (i.e. bytecode parser vs. string parser) + */ + typedef qreal (QmuParserBase::*ParseFunction)() const; + + /** + * @brief Type used for storing an array of values. + */ + typedef QVector valbuf_type; + + /** + * @brief Type for a vector of strings. + */ + typedef QVector stringbuf_type; + + /** + * @brief Typedef for the token reader. + */ + typedef QmuParserTokenReader token_reader_type; + + /** + * @brief Type used for parser tokens. + */ + typedef QmuParserToken token_type; + + /** + * @brief Maximum number of threads spawned by OpenMP when using the bulk mode. + */ + static const int s_MaxNumOpenMPThreads = 4; + + /** + * @brief Pointer to the parser function. + * + * Eval() calls the function whose address is stored there. + */ + mutable ParseFunction m_pParseFormula; + mutable QmuParserByteCode m_vRPN; ///< The Bytecode class. + mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments + stringbuf_type m_vStringVarBuf; + + std::unique_ptr m_pTokenReader; ///< Managed pointer to the token reader object. + + funmap_type m_FunDef; ///< Map of function names and pointers. + funmap_type m_PostOprtDef; ///< Postfix operator callbacks + funmap_type m_InfixOprtDef; ///< unary infix operator. + funmap_type m_OprtDef; ///< Binary operator callbacks + valmap_type m_ConstDef; ///< user constants. + strmap_type m_StrVarDef; ///< user defined string constants + varmap_type m_VarDef; ///< user defind variables. + + bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off + + QString m_sNameChars; ///< Charset for names + QString m_sOprtChars; ///< Charset for postfix/ binary operator tokens + QString m_sInfixOprtChars; ///< Charset for infix operator tokens + + mutable int m_nIfElseCounter; ///< Internal counter for keeping track of nested if-then-else clauses + + // items merely used for caching state information + mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine + mutable int m_nFinalResultIdx; + mutable QMap m_Tokens;///< Keep all tokens that we can translate + mutable QMap m_Numbers;///< Keep all numbers what exist in formula + + bool allowSubexpressions; + + void Assign(const QmuParserBase &a_Parser); + void InitTokenReader(); + void ReInit() const; + void AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback, + funmap_type &a_Storage, const QString &a_szCharSet ); + void ApplyRemainingOprt(QStack &a_stOpt, QStack &a_stVal) const; + void ApplyBinOprt(QStack &a_stOpt, QStack &a_stVal) const; + void ApplyIfElse(QStack &a_stOpt, QStack &a_stVal) const; + void ApplyFunc(QStack &a_stOpt, QStack &a_stVal, int iArgCount) const; + token_type ApplyStrFunc(const token_type &a_FunTok, const QVector &a_vArg) const; + int GetOprtPrecedence(const token_type &a_Tok) const; + EOprtAssociativity GetOprtAssociativity(const token_type &a_Tok) const; + void CreateRPN() const; + qreal ParseString() const; + qreal ParseCmdCode() const; + qreal ParseCmdCodeBulk(int nOffset, int nThreadID) const; + void CheckName(const QString &a_strName, const QString &a_CharSet) const; + void CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback, + const QString &a_szCharSet) const; + void StackDump(const QStack &a_stVal, const QStack &a_stOprt) const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize the token reader. + * + * Create new token reader object and submit pointers to function, operator, constant and variable definitions. + * + * @post m_pTokenReader.get()!=0 + */ +inline void QmuParserBase::InitTokenReader() +{ + m_pTokenReader.reset(new token_reader_type(this)); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a value parsing function. + * + * When parsing an expression muParser tries to detect values in the expression string using different valident + * callbacks. Thuis it's possible to parse for hex values, binary values and floating point values. + */ +inline void QmuParserBase::AddValIdent(identfun_type a_pCallback) +{ + m_pTokenReader->AddValIdent(a_pCallback); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Get the default symbols used for the built in operators. + * @sa c_DefaultOprt + */ +inline const QStringList &QmuParserBase::GetOprtDef() +{ + return c_DefaultOprt; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QMap QmuParserBase::GetTokens() const +{ + return m_Tokens; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QMap QmuParserBase::GetNumbers() const +{ + return m_Numbers; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define the set of valid characters to be used in names of functions, variables, constants. + */ +inline void QmuParserBase::DefineNameChars(const QString &a_szCharset) +{ + m_sNameChars = a_szCharset; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define the set of valid characters to be used in names of binary operators and postfix operators. + */ +inline void QmuParserBase::DefineOprtChars(const QString &a_szCharset) +{ + m_sOprtChars = a_szCharset; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Define the set of valid characters to be used in names of infix operators. + */ +inline void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset) +{ + m_sInfixOprtChars = a_szCharset; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return a map containing the used variables only. + */ +inline const varmap_type &QmuParserBase::GetVar() const +{ + return m_VarDef; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return a map containing all parser constants. + */ +inline const valmap_type &QmuParserBase::GetConst() const +{ + return m_ConstDef; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return prototypes of all parser functions. + * @return #m_FunDef + * @sa FunProt + * @throw nothrow + * + * The return type is a map of the public type #funmap_type containing the prototype definitions for all numerical + * parser functions. String functions are not part of this map. The Prototype definition is encapsulated in objects + * of the class FunProt one per parser function each associated with function names via a map construct. + */ +inline const funmap_type &QmuParserBase::GetFunDef() const +{ + return m_FunDef; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Retrieve the formula. + */ +inline const QString& QmuParserBase::GetExpr() const +{ + return m_pTokenReader->GetExpr(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Query status of built in variables. + * @return #m_bBuiltInOp; true if built in operators are enabled. + * @throw nothrow + */ +inline bool QmuParserBase::HasBuiltInOprt() const +{ + return m_bBuiltInOp; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the number of results on the calculation stack. + * + * If the expression contains comma seperated subexpressions (i.e. "sin(y), x+y"). There mey be more than one return + * value. This function returns the number of available results. + */ +// cppcheck-suppress unusedFunction +inline int QmuParserBase::GetNumResults() const +{ + return m_nFinalResultIdx; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Calculate the result. + * + * A note on const correctness: + * I consider it important that Calc is a const function. + * Due to caching operations Calc changes only the state of internal variables with one exception + * m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making + * Calc non const GetUsedVar is non const because it explicitely calls Eval() forcing this update. + * + * @pre A formula must be set. + * @pre Variables must have been set (if needed) + * + * @sa #m_pParseFormula + * @return The evaluation result + * @throw ParseException if no Formula is set or in case of any other error related to the formula. + */ +inline qreal QmuParserBase::Eval() const +{ + return (this->*m_pParseFormula)(); +} + +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp new file mode 100644 index 000000000..680566436 --- /dev/null +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -0,0 +1,649 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparserbytecode.h" + +#include +#include +#include +#include "qmuparsertoken.h" +#include +#include + +namespace qmu +{ +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Bytecode default constructor. + */ +// cppcheck-suppress uninitMemberVar +QmuParserByteCode::QmuParserByteCode() + :m_iStackPos(0), m_iMaxStackSize(0), m_vRPN(), m_bEnableOptimizer(true) +{ + m_vRPN.reserve(50); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy constructor. + * + * Implemented in Terms of Assign(const QParserByteCode &a_ByteCode) + */ +// cppcheck-suppress uninitMemberVar +QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode) + :m_iStackPos(a_ByteCode.m_iStackPos), m_iMaxStackSize(a_ByteCode.m_iMaxStackSize), m_vRPN(a_ByteCode.m_vRPN), + m_bEnableOptimizer(true) +{ + Assign(a_ByteCode); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Assignment operator. + * + * Implemented in Terms of Assign(const QParserByteCode &a_ByteCode) + */ +// cppcheck-suppress operatorEqVarError +QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteCode) +{ + Assign(a_ByteCode); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy state of another object to this. + * + * @throw nowthrow + */ +void QmuParserByteCode::Assign(const QmuParserByteCode &a_ByteCode) +{ + if (this==&a_ByteCode) + { + return; + } + + m_iStackPos = a_ByteCode.m_iStackPos; + m_vRPN = a_ByteCode.m_vRPN; + m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; + m_bEnableOptimizer = a_ByteCode.m_bEnableOptimizer; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a Variable pointer to bytecode. + * @param a_pVar Pointer to be added. + * @throw nothrow + */ +void QmuParserByteCode::AddVar(qreal *a_pVar) +{ + ++m_iStackPos; + m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); + + // optimization does not apply + SToken tok; + tok.Cmd = cmVAR; + tok.Val.ptr = a_pVar; + tok.Val.data = 1; + tok.Val.data2 = 0; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a Variable pointer to bytecode. + * + * Value entries in byte code consist of: + *
    + *
  • value array position of the value
  • + *
  • the operator code according to ParserToken::cmVAL
  • + *
  • the value stored in #mc_iSizeVal number of bytecode entries.
  • + *
+ * + * @param a_fVal Value to be added. + * @throw nothrow + */ +void QmuParserByteCode::AddVal(qreal a_fVal) +{ + ++m_iStackPos; + m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); + + // If optimization does not apply + SToken tok; + tok.Cmd = cmVAL; + tok.Val.ptr = nullptr; + tok.Val.data = 0; + tok.Val.data2 = a_fVal; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) +{ + int sz = m_vRPN.size(); + qreal &x = m_vRPN[sz-2].Val.data2, + &y = m_vRPN[sz-1].Val.data2; + switch (a_Oprt) + { + case cmLAND: + x = static_cast(x) && static_cast(y); + m_vRPN.pop_back(); + break; + case cmLOR: + x = static_cast(x) || static_cast(y); + m_vRPN.pop_back(); + break; + case cmLT: + x = x < y; + m_vRPN.pop_back(); + break; + case cmGT: + x = x > y; + m_vRPN.pop_back(); + break; + case cmLE: + x = x <= y; + m_vRPN.pop_back(); + break; + case cmGE: + x = x >= y; + m_vRPN.pop_back(); + break; + case cmNEQ: + x = (qFuzzyCompare(x, y) == false); + m_vRPN.pop_back(); + break; + case cmEQ: + x = qFuzzyCompare(x, y); + m_vRPN.pop_back(); + break; + case cmADD: + x = x + y; + m_vRPN.pop_back(); + break; + case cmSUB: + x = x - y; + m_vRPN.pop_back(); + break; + case cmMUL: + x = x * y; + m_vRPN.pop_back(); + break; + case cmDIV: + #if defined(MUP_MATH_EXCEPTIONS) + if (y==0) + { + throw qmuParserError(ecDIV_BY_ZERO, "0"); + } + #endif + x = x / y; + m_vRPN.pop_back(); + break; + case cmPOW: + x = qPow(x, y); + m_vRPN.pop_back(); + break; + default: + break; + } // switch opcode +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add an operator identifier to bytecode. + * + * Operator entries in byte code consist of: + *
    + *
  • value array position of the result
  • + *
  • the operator code according to ParserToken::ECmdCode
  • + *
+ * + * @sa ParserToken::ECmdCode + */ +void QmuParserByteCode::AddOp(ECmdCode a_Oprt) +{ + bool bOptimized = false; + + if (m_bEnableOptimizer) + { + int sz = m_vRPN.size(); + + // Check for foldable constants like: + // cmVAL cmVAL cmADD + // where cmADD can stand fopr any binary operator applied to + // two constant values. + if (sz>=2 && m_vRPN[sz-2].Cmd == cmVAL && m_vRPN[sz-1].Cmd == cmVAL) + { + ConstantFolding(a_Oprt); + bOptimized = true; + } + else + { + switch (a_Oprt) + { + case cmPOW: + // Optimization for ploynomials of low order + if (m_vRPN[sz-2].Cmd == cmVAR && m_vRPN[sz-1].Cmd == cmVAL) + { + if (qFuzzyCompare(m_vRPN[sz-1].Val.data2, 2)) + { + m_vRPN[sz-2].Cmd = cmVARPOW2; + } + else if (qFuzzyCompare(m_vRPN[sz-1].Val.data2, 3)) + { + m_vRPN[sz-2].Cmd = cmVARPOW3; + } + else if (qFuzzyCompare(m_vRPN[sz-1].Val.data2, 4)) + { + m_vRPN[sz-2].Cmd = cmVARPOW4; + } + else + { + break; + } + m_vRPN.pop_back(); + bOptimized = true; + } + break; + + case cmSUB: + case cmADD: + // Simple optimization based on pattern recognition for a shitload of different + // bytecode combinations of addition/subtraction + if ( (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAL) || + (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) || + (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL) || + (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAL) || + (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && + m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || + (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVARMUL + && m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || + (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAR && + m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) || + (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVARMUL && + m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ) + { + assert( (m_vRPN[sz-2].Val.ptr==nullptr && m_vRPN[sz-1].Val.ptr!=nullptr) || + (m_vRPN[sz-2].Val.ptr!=nullptr && m_vRPN[sz-1].Val.ptr==nullptr) || + (m_vRPN[sz-2].Val.ptr == m_vRPN[sz-1].Val.ptr) ); + + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( + reinterpret_cast(m_vRPN[sz-2].Val.ptr) | + reinterpret_cast(m_vRPN[sz-1].Val.ptr)); // variable + m_vRPN[sz-2].Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data2; // offset + m_vRPN[sz-2].Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN[sz-1].Val.data; // multiplikatior + m_vRPN.pop_back(); + bOptimized = true; + } + break; + case cmMUL: + if ( (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAL) || + (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVAR) ) + { + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( + reinterpret_cast(m_vRPN[sz-2].Val.ptr) | + reinterpret_cast(m_vRPN[sz-1].Val.ptr)); + m_vRPN[sz-2].Val.data = m_vRPN[sz-2].Val.data2 + m_vRPN[sz-1].Val.data2; + m_vRPN[sz-2].Val.data2 = 0; + m_vRPN.pop_back(); + bOptimized = true; + } + else if ( (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL) || + (m_vRPN[sz-1].Cmd == cmVARMUL && m_vRPN[sz-2].Cmd == cmVAL) ) + { + // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( + reinterpret_cast(m_vRPN[sz-2].Val.ptr) | + reinterpret_cast(m_vRPN[sz-1].Val.ptr)); + if (m_vRPN[sz-1].Cmd == cmVAL) + { + m_vRPN[sz-2].Val.data *= m_vRPN[sz-1].Val.data2; + m_vRPN[sz-2].Val.data2 *= m_vRPN[sz-1].Val.data2; + } + else + { + m_vRPN[sz-2].Val.data = m_vRPN[sz-1].Val.data * m_vRPN[sz-2].Val.data2; + m_vRPN[sz-2].Val.data2 = m_vRPN[sz-1].Val.data2 * m_vRPN[sz-2].Val.data2; + } + m_vRPN.pop_back(); + bOptimized = true; + } + else if (m_vRPN[sz-1].Cmd == cmVAR && m_vRPN[sz-2].Cmd == cmVAR && + m_vRPN[sz-1].Val.ptr == m_vRPN[sz-2].Val.ptr) + { + // Optimization: a*a -> a^2 + m_vRPN[sz-2].Cmd = cmVARPOW2; + m_vRPN.pop_back(); + bOptimized = true; + } + break; + case cmDIV: + if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL && + (qFuzzyCompare(m_vRPN[sz-1].Val.data2+1, 1+0)==false)) + { + // Optimization: 4*a/2 -> 2*a + m_vRPN[sz-2].Val.data /= m_vRPN[sz-1].Val.data2; + m_vRPN[sz-2].Val.data2 /= m_vRPN[sz-1].Val.data2; + m_vRPN.pop_back(); + bOptimized = true; + } + break; + default: + break; + + } // switch a_Oprt + } + } + + // If optimization can't be applied just write the value + if (bOptimized == false) + { + --m_iStackPos; + SToken tok; + tok.Cmd = a_Oprt; + m_vRPN.push_back(tok); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt) +{ + SToken tok; + tok.Cmd = a_Oprt; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add an assignement operator + * + * Operator entries in byte code consist of: + *
    + *
  • cmASSIGN code
  • + *
  • the pointer of the destination variable
  • + *
+ * + * @sa ParserToken::ECmdCode + */ +void QmuParserByteCode::AddAssignOp(qreal *a_pVar) +{ + --m_iStackPos; + + SToken tok; + tok.Cmd = cmASSIGN; + tok.Val.ptr = a_pVar; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add function to bytecode. + * + * @param a_iArgc Number of arguments, negative numbers indicate multiarg functions. + * @param a_pFun Pointer to function callback. + */ +void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) +{ + if (a_iArgc>=0) + { + m_iStackPos = m_iStackPos - static_cast(a_iArgc) + 1; + } + else + { + // function with unlimited number of arguments + m_iStackPos = static_cast(static_cast(m_iStackPos) + a_iArgc + 1); + } + m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); + + SToken tok; + tok.Cmd = cmFUNC; + tok.Fun.argc = a_iArgc; + tok.Fun.ptr = a_pFun; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add a bulk function to bytecode. + * + * @param a_iArgc Number of arguments, negative numbers indicate multiarg functions. + * @param a_pFun Pointer to function callback. + */ +void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) +{ + m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); + m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); + + SToken tok; + tok.Cmd = cmFUNC_BULK; + tok.Fun.argc = a_iArgc; + tok.Fun.ptr = a_pFun; + m_vRPN.push_back(tok); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add Strung function entry to the parser bytecode. + * @throw nothrow + * + * A string function entry consists of the stack position of the return value, followed by a cmSTRFUNC code, the + * function pointer and an index into the string buffer maintained by the parser. + */ +void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx) +{ + m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); + + SToken tok; + tok.Cmd = cmFUNC_STR; + tok.Fun.argc = a_iArgc; + tok.Fun.idx = a_iIdx; + tok.Fun.ptr = a_pFun; + m_vRPN.push_back(tok); + + m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Add end marker to bytecode. + * + * @throw nothrow + */ +void QmuParserByteCode::Finalize() +{ + SToken tok; + tok.Cmd = cmEND; + m_vRPN.push_back(tok); + rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit + + // Determine the if-then-else jump offsets + QStack stIf, stElse; + int idx; + for (int i=0; i + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERBYTECODE_H +#define QMUPARSERBYTECODE_H + +#include "qmuparserdef.h" +#include "qmuparsertoken.h" + +/** + * @file + * @brief Definition of the parser bytecode class. + */ + +#ifdef Q_CC_CLANG +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnested-anon-types" +#endif +namespace qmu +{ +struct SToken +{ + ECmdCode Cmd; + int StackPos; + + union // + { + struct //SValData + { + qreal *ptr; + qreal data; + qreal data2; + } Val; + + struct //SFunData + { + // Note: generic_fun_type is merely a placeholder. The real type could be + // anything between gun_type1 and fun_type9. I can't use a void + // pointer due to constraints in the ANSI standard which allows + // data pointers and function pointers to differ in size. + generic_fun_type ptr; + int argc; + int idx; + } Fun; + + struct //SOprtData + { + qreal *ptr; + int offset; + } Oprt; + }; +}; + +#ifdef Q_CC_CLANG +#pragma clang diagnostic pop +#endif + +/** + * @brief Bytecode implementation of the Math Parser. + * + * The bytecode contains the formula converted to revers polish notation stored in a continious + * memory area. Associated with this data are operator codes, variable pointers, constant + * values and function pointers. Those are necessary in order to calculate the result. + * All those data items will be casted to the underlying datatype of the bytecode. + * + * @author (C) 2004-2013 Ingo Berg + */ +class QmuParserByteCode +{ +public: + QmuParserByteCode(); + QmuParserByteCode(const QmuParserByteCode &a_ByteCode); + QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode); + void Assign(const QmuParserByteCode &a_ByteCode); + void AddVar(qreal *a_pVar); + void AddVal(qreal a_fVal); + void AddOp(ECmdCode a_Oprt); + void AddIfElse(ECmdCode a_Oprt); + void AddAssignOp(qreal *a_pVar); + void AddFun(generic_fun_type a_pFun, int a_iArgc); + void AddBulkFun(generic_fun_type a_pFun, int a_iArgc); + void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx); + void EnableOptimizer(bool bStat); + void Finalize(); + void clear(); + int GetMaxStackSize() const; + int GetSize() const; + const SToken* GetBase() const; + void AsciiDump(); +private: + /** @brief Token type for internal use only. */ + typedef QmuParserToken token_type; + + /** @brief Token vector for storing the RPN. */ + typedef QVector rpn_type; + + /** @brief Position in the Calculation array. */ + unsigned m_iStackPos; + + /** @brief Maximum size needed for the stack. */ + unsigned m_iMaxStackSize; + + /** @brief The actual rpn storage. */ + rpn_type m_vRPN; + + bool m_bEnableOptimizer; + + void ConstantFolding(ECmdCode a_Oprt); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline void QmuParserByteCode::EnableOptimizer(bool bStat) +{ + m_bEnableOptimizer = bStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline int QmuParserByteCode::GetMaxStackSize() const +{ + return static_cast(m_iMaxStackSize+1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the number of entries in the bytecode. + */ +// cppcheck-suppress unusedFunction +inline int QmuParserByteCode::GetSize() const +{ + return m_vRPN.size(); +} + +} // namespace qmu +#endif diff --git a/src/libs/qmuparser/qmuparsercallback.cpp b/src/libs/qmuparser/qmuparsercallback.cpp new file mode 100644 index 000000000..6f1cd95da --- /dev/null +++ b/src/libs/qmuparser/qmuparsercallback.cpp @@ -0,0 +1,328 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparsercallback.h" + +/** + * @file + * @brief Implementation of the parser callback class. + */ + +namespace qmu +{ +//--------------------------------------------------------------------------------------------------------------------- +//Supressing specific warnings on gcc/g++ http://www.mr-edd.co.uk/blog/supressing_gcc_warnings +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ), + m_iCode ( a_iCode ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor for constructing funcstion callbacks taking two arguments. + * @throw nothrow + */ +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor for constructing binary operator callbacks. + * @param a_pFun Pointer to a static function taking two arguments + * @param a_bAllowOpti A flag indicating this funcation can be optimized + * @param a_iPrec The operator precedence + * @param a_eOprtAsct The operators associativity + * @throw nothrow + */ +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, + EOprtAssociativity a_eOprtAsct ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ), + m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor for constructing funcstion callbacks taking two arguments. + * @throw nothrow + */ +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +#ifdef __GNUC__ +__extension__ +#endif +QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti ) + : m_pFun ( reinterpret_cast ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), + m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Default constructor. + * @throw nothrow + */ +QmuParserCallback::QmuParserCallback() + : m_pFun ( 0 ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), + m_bAllowOpti ( 0 ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy constructor. + * @throw nothrow + */ +QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref ) + : m_pFun ( ref.m_pFun ), m_iArgc ( ref.m_iArgc ), m_iPri ( ref.m_iPri ), m_eOprtAsct ( ref.m_eOprtAsct ), + m_iCode ( ref.m_iCode ), m_iType ( ref.m_iType ), m_bAllowOpti ( ref.m_bAllowOpti ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserCallback &QmuParserCallback::operator=(const QmuParserCallback &a_Fun) +{ + m_pFun = a_Fun.m_pFun; + m_iArgc = a_Fun.m_iArgc; + m_bAllowOpti = a_Fun.m_bAllowOpti; + m_iCode = a_Fun.m_iCode; + m_iType = a_Fun.m_iType; + m_iPri = a_Fun.m_iPri; + m_eOprtAsct = a_Fun.m_eOprtAsct; + return *this; +} + +} // namespace qmu diff --git a/src/libs/qmuparser/qmuparsercallback.h b/src/libs/qmuparser/qmuparsercallback.h new file mode 100644 index 000000000..f6573a5f9 --- /dev/null +++ b/src/libs/qmuparser/qmuparsercallback.h @@ -0,0 +1,199 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERCALLBACK_H +#define QMUPARSERCALLBACK_H + +#include "qmuparserdef.h" + +/** + * @file + * @brief Definition of the parser callback class. + */ + +namespace qmu +{ + +/** + * @brief Encapsulation of prototypes for a numerical parser function. + * + * Encapsulates the prototyp for numerical parser functions. The class stores the number of arguments for parser + * functions as well as additional flags indication the function is non optimizeable. The pointer to the callback + * function pointer is stored as void* and needs to be casted according to the argument count. Negative argument counts + * indicate a parser function with a variable number of arguments. + * + * @author (C) 2004-2011 Ingo Berg + */ +class QmuParserCallback +{ +public: + QmuParserCallback(fun_type0 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC); + QmuParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity); + QmuParserCallback(fun_type2 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type3 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type4 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type5 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type6 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type7 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type8 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type9 a_pFun, bool a_bAllowOpti); + QmuParserCallback(fun_type10 a_pFun, bool a_bAllowOpti); + + QmuParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti); + QmuParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti); + + QmuParserCallback(multfun_type a_pFun, bool a_bAllowOpti); + QmuParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti); + QmuParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti); + QmuParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti); + QmuParserCallback(); + QmuParserCallback(const QmuParserCallback &a_Fun); + QmuParserCallback &operator=(const QmuParserCallback &a_Fun); + + QmuParserCallback* Clone() const; + bool IsOptimizable() const; + void* GetAddr() const; + ECmdCode GetCode() const; + ETypeCode GetType() const; + int GetPri() const; + EOprtAssociativity GetAssociativity() const; + int GetArgc() const; +private: + void *m_pFun; ///< Pointer to the callback function, casted to void + + /** + * @brief Number of numeric function arguments + * + * This number is negative for functions with variable number of arguments. in this cases + * they represent the actual number of arguments found. + */ + int m_iArgc; + int m_iPri; ///< Valid only for binary and infix operators; Operator precedence. + EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators + ECmdCode m_iCode; + ETypeCode m_iType; + bool m_bAllowOpti; ///< Flag indication optimizeability +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Container for Callback objects. + */ +typedef std::map funmap_type; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clone this instance and return a pointer to the new instance. + */ +inline QmuParserCallback* QmuParserCallback::Clone() const +{ + return new QmuParserCallback ( *this ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return true if the function is conservative. + * + * Conservative functions return always the same result for the same argument. + * @throw nothrow + */ +// cppcheck-suppress unusedFunction +inline bool QmuParserCallback::IsOptimizable() const +{ + return m_bAllowOpti; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Get the callback address for the parser function. + * + * The type of the address is void. It needs to be recasted according to the argument number to the right type. + * + * @throw nothrow + * @return #pFun + */ +inline void* QmuParserCallback::GetAddr() const +{ + return m_pFun; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the callback code. +*/ +inline ECmdCode QmuParserCallback::GetCode() const +{ + return m_iCode; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline ETypeCode QmuParserCallback::GetType() const +{ + return m_iType; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the operator precedence. + * @throw nothrown + * + * Only valid if the callback token is an operator token (binary or infix). + */ +inline int QmuParserCallback::GetPri() const +{ + return m_iPri; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the operators associativity. + * @throw nothrown + * + * Only valid if the callback token is a binary operator token. + */ +inline EOprtAssociativity QmuParserCallback::GetAssociativity() const +{ + return m_eOprtAsct; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the number of function Arguments. + */ +inline int QmuParserCallback::GetArgc() const +{ + return m_iArgc; +} + +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmuparserdef.h b/src/libs/qmuparser/qmuparserdef.h new file mode 100644 index 000000000..cf6ce2652 --- /dev/null +++ b/src/libs/qmuparser/qmuparserdef.h @@ -0,0 +1,284 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPDEF_H +#define QMUPDEF_H + +#include +#include + +#include "qmuparserfixes.h" + +/** @file + @brief This file contains standard definitions used by the parser. +*/ + +#define QMUP_VERSION "2.2.4" +#define QMUP_VERSION_DATE "20140504; GC" + +#define QMUP_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +// Detect whether the compiler supports C++11 noexcept exception specifications. +# if defined(__clang__) +# if __has_feature(cxx_noexcept) +# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept +# endif +# elif defined(__GNUC__) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept +# endif +# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114 +# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) +# else +# define QMUP_NOEXCEPT_EXPR(x) +# endif + +/** @brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ +//#define QMUP_MATH_EXCEPTIONS + +/** @brief Activate this option in order to compile with OpenMP support. + + OpenMP is used only in the bulk mode it may increase the performance a bit. +*/ +//#define QMUP_USE_OPENMP + +/** @brief Definition of the basic parser string type. */ +#define QMUP_STRING_TYPE std::wstring + +namespace qmu +{ +//------------------------------------------------------------------------------ +/** @brief Bytecode values. + + \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! +*/ +enum ECmdCode +{ + // The following are codes for built in binary operators + // apart from built in operators the user has the opportunity to + // add user defined operators. + cmLE = 0, ///< Operator item: less or equal + cmGE = 1, ///< Operator item: greater or equal + cmNEQ = 2, ///< Operator item: not equal + cmEQ = 3, ///< Operator item: equals + cmLT = 4, ///< Operator item: less than + cmGT = 5, ///< Operator item: greater than + cmADD = 6, ///< Operator item: add + cmSUB = 7, ///< Operator item: subtract + cmMUL = 8, ///< Operator item: multiply + cmDIV = 9, ///< Operator item: division + cmPOW = 10, ///< Operator item: y to the power of ... + cmLAND = 11, + cmLOR = 12, + cmASSIGN = 13, ///< Operator item: Assignment operator + cmBO = 14, ///< Operator item: opening bracket + cmBC = 15, ///< Operator item: closing bracket + cmIF = 16, ///< For use in the ternary if-then-else operator + cmELSE = 17, ///< For use in the ternary if-then-else operator + cmENDIF = 18, ///< For use in the ternary if-then-else operator + cmARG_SEP = 19, ///< function argument separator + cmVAR = 20, ///< variable item + cmVAL = 21, ///< value item + + // For optimization purposes + cmVARPOW2, + cmVARPOW3, + cmVARPOW4, + cmVARMUL, + cmPOW2, + + // operators and functions + cmFUNC, ///< Code for a generic function item + cmFUNC_STR, ///< Code for a function with a string parameter + cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index + cmSTRING, ///< Code for a string token + cmOPRT_BIN, ///< user defined binary operator + cmOPRT_POSTFIX, ///< code for postfix operators + cmOPRT_INFIX, ///< code for infix operators + cmEND, ///< end of formula + cmUNKNOWN ///< uninitialized item +}; + +//------------------------------------------------------------------------------ +/** @brief Types internally used by the parser. +*/ +enum ETypeCode +{ + tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) + tpDBL = 1, ///< Floating point variables + tpVOID = 2 ///< Undefined type. +}; + +//------------------------------------------------------------------------------ +enum EParserVersionInfo +{ + pviBRIEF, + pviFULL +}; + +//------------------------------------------------------------------------------ +/** @brief Parser operator precedence values. */ +enum EOprtAssociativity +{ + oaLEFT = 0, + oaRIGHT = 1, + oaNONE = 2 +}; + +//------------------------------------------------------------------------------ +/** @brief Parser operator precedence values. */ +enum EOprtPrecedence +{ + // binary operators + prLOR = 1, + prLAND = 2, + prLOGIC = 3, ///< logic operators + prCMP = 4, ///< comparsion operators + prADD_SUB = 5, ///< addition + prMUL_DIV = 6, ///< multiplication/division + prPOW = 7, ///< power operator priority (highest) + + // infix operators + prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator + prPOSTFIX = 6 ///< Postfix operator priority (currently unused) +}; + +//------------------------------------------------------------------------------ +// basic types + +/** @brief The stringtype used by the parser. + + Depends on wether UNICODE is used or not. +*/ +typedef QMUP_STRING_TYPE string_type; + +/** @brief The character type used by the parser. + + Depends on wether UNICODE is used or not. +*/ +typedef string_type::value_type char_type; + +/** @brief Typedef for easily using stringstream that respect the parser stringtype. */ +typedef std::basic_stringstream < char_type, std::char_traits, std::allocator > stringstream_type; + +// Data container types + +/** @brief Type used for storing variables. */ +typedef std::map varmap_type; + +/** @brief Type used for storing constants. */ +typedef std::map valmap_type; + +/** @brief Type for assigning a string name to an index in the internal string table. */ +typedef std::map strmap_type; + +// Parser callbacks + +/** @brief Callback type used for functions without arguments. */ +typedef qreal ( *generic_fun_type ) (); + +/** @brief Callback type used for functions without arguments. */ +typedef qreal ( *fun_type0 ) (); + +/** @brief Callback type used for functions with a single arguments. */ +typedef qreal ( *fun_type1 ) ( qreal ); + +/** @brief Callback type used for functions with two arguments. */ +typedef qreal ( *fun_type2 ) ( qreal, qreal ); + +/** @brief Callback type used for functions with three arguments. */ +typedef qreal ( *fun_type3 ) ( qreal, qreal, qreal ); + +/** @brief Callback type used for functions with four arguments. */ +typedef qreal ( *fun_type4 ) ( qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type5 ) ( qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type6 ) ( qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type7 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type8 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type9 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *fun_type10 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions without arguments. */ +typedef qreal ( *bulkfun_type0 ) ( int, int ); + +/** @brief Callback type used for functions with a single arguments. */ +typedef qreal ( *bulkfun_type1 ) ( int, int, qreal ); + +/** @brief Callback type used for functions with two arguments. */ +typedef qreal ( *bulkfun_type2 ) ( int, int, qreal, qreal ); + +/** @brief Callback type used for functions with three arguments. */ +typedef qreal ( *bulkfun_type3 ) ( int, int, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with four arguments. */ +typedef qreal ( *bulkfun_type4 ) ( int, int, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type5 ) ( int, int, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type6 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type7 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type8 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type9 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with five arguments. */ +typedef qreal ( *bulkfun_type10 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); + +/** @brief Callback type used for functions with a variable argument list. */ +typedef qreal ( *multfun_type ) ( const qreal*, int ); + +/** @brief Callback type used for functions taking a string as an argument. */ +typedef qreal ( *strfun_type1 ) ( const QString & ); + +/** @brief Callback type used for functions taking a string and a value as arguments. */ +typedef qreal ( *strfun_type2 ) ( const QString &, qreal ); + +/** @brief Callback type used for functions taking a string and two values as arguments. */ +typedef qreal ( *strfun_type3 ) ( const QString &, qreal, qreal ); + +/** @brief Callback used for functions that identify values in a string. */ +typedef int ( *identfun_type ) ( const QString &sExpr, int *nPos, qreal *fVal ); + +/** @brief Callback used for variable creation factory functions. */ +typedef qreal* ( *facfun_type ) ( const QString &, void* ); +} // end of namespace + +#endif diff --git a/src/libs/qmuparser/qmuparsererror.cpp b/src/libs/qmuparser/qmuparsererror.cpp new file mode 100644 index 000000000..89ffbea50 --- /dev/null +++ b/src/libs/qmuparser/qmuparsererror.cpp @@ -0,0 +1,339 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparsererror.h" + +#include +#include + +#ifdef Q_OS_WIN +#include +#endif + +namespace qmu +{ +const QmuParserErrorMsg QmuParserErrorMsg::m_Instance; + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserErrorMsg::~QmuParserErrorMsg() +{} + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserErrorMsg::QmuParserErrorMsg() + : m_vErrMsg () +{ + m_vErrMsg.clear(); + + m_vErrMsg.insert(ecUNASSIGNABLE_TOKEN, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected token \"$TOK$\" found at position $POS$.", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecINTERNAL_ERROR, + QmuTranslation::translate("QmuParserErrorMsg", + "Internal error", + "Math parser error messages.")); + m_vErrMsg.insert(ecINVALID_NAME, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid function-, variable- or constant name: \"$TOK$\".", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecINVALID_BINOP_IDENT, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid binary operator identifier: \"$TOK$\".", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecINVALID_INFIX_IDENT, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid infix operator identifier: \"$TOK$\".", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecINVALID_POSTFIX_IDENT, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid postfix operator identifier: \"$TOK$\".", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecINVALID_FUN_PTR, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid pointer to callback function.", + "Math parser error messages.")); + m_vErrMsg.insert(ecEMPTY_EXPRESSION, + QmuTranslation::translate("QmuParserErrorMsg", + "Expression is empty.", + "Math parser error messages.")); + m_vErrMsg.insert(ecINVALID_VAR_PTR, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid pointer to variable.", + "Math parser error messages.")); + m_vErrMsg.insert(ecUNEXPECTED_OPERATOR, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected operator \"$TOK$\" found at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_EOF, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected end of expression at position $POS$", + "Math parser error messages. Left untouched $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_ARG_SEP, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected argument separator at position $POS$", + "Math parser error messages. Left untouched $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_PARENS, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected parenthesis \"$TOK$\" at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_FUN, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected function \"$TOK$\" at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_VAL, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected value \"$TOK$\" found at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_VAR, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected variable \"$TOK$\" found at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_ARG, + QmuTranslation::translate("QmuParserErrorMsg", + "Function arguments used without a function (position: $POS$)", + "Math parser error messages. Left untouched $POS$")); + m_vErrMsg.insert(ecMISSING_PARENS, + QmuTranslation::translate("QmuParserErrorMsg", + "Missing parenthesis", + "Math parser error messages.")); + m_vErrMsg.insert(ecTOO_MANY_PARAMS, + QmuTranslation::translate("QmuParserErrorMsg", + "Too many parameters for function \"$TOK$\" at expression position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecTOO_FEW_PARAMS, + QmuTranslation::translate("QmuParserErrorMsg", + "Too few parameters for function \"$TOK$\" at expression position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecDIV_BY_ZERO, + QmuTranslation::translate("QmuParserErrorMsg", + "Divide by zero", + "Math parser error messages.")); + m_vErrMsg.insert(ecDOMAIN_ERROR, + QmuTranslation::translate("QmuParserErrorMsg", + "Domain error", + "Math parser error messages.")); + m_vErrMsg.insert(ecNAME_CONFLICT, + QmuTranslation::translate("QmuParserErrorMsg", + "Name conflict", + "Math parser error messages.")); + m_vErrMsg.insert(ecOPT_PRI, + QmuTranslation::translate("QmuParserErrorMsg", + "Invalid value for operator priority (must be greater or equal to zero).", + "Math parser error messages.")); + m_vErrMsg.insert(ecBUILTIN_OVERLOAD, + QmuTranslation::translate("QmuParserErrorMsg", + "user defined binary operator \"$TOK$\" conflicts with a built in operator.", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecUNEXPECTED_STR, + QmuTranslation::translate("QmuParserErrorMsg", + "Unexpected string token found at position $POS$.", + "Math parser error messages. Left untouched $POS$")); + m_vErrMsg.insert(ecUNTERMINATED_STRING, + QmuTranslation::translate("QmuParserErrorMsg", + "Unterminated string starting at position $POS$.", + "Math parser error messages. Left untouched $POS$")); + m_vErrMsg.insert(ecSTRING_EXPECTED, + QmuTranslation::translate("QmuParserErrorMsg", + "String function called with a non string type of argument.", + "Math parser error messages.")); + m_vErrMsg.insert(ecVAL_EXPECTED, + QmuTranslation::translate("QmuParserErrorMsg", + "String value used where a numerical argument is expected.", + "Math parser error messages.")); + m_vErrMsg.insert(ecOPRT_TYPE_CONFLICT, + QmuTranslation::translate("QmuParserErrorMsg", + "No suitable overload for operator \"$TOK$\" at position $POS$.", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecSTR_RESULT, + QmuTranslation::translate("QmuParserErrorMsg", + "Function result is a string.", + "Math parser error messages.")); + m_vErrMsg.insert(ecGENERIC, + QmuTranslation::translate("QmuParserErrorMsg", + "Parser error.", + "Math parser error messages.")); + m_vErrMsg.insert(ecLOCALE, + QmuTranslation::translate("QmuParserErrorMsg", + "Decimal separator is identic to function argument separator.", + "Math parser error messages.")); + m_vErrMsg.insert(ecUNEXPECTED_CONDITIONAL, + QmuTranslation::translate("QmuParserErrorMsg", + "The \"$TOK$\" operator must be preceeded by a closing bracket.", + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecMISSING_ELSE_CLAUSE, + QmuTranslation::translate("QmuParserErrorMsg", + "If-then-else operator is missing an else clause", + "Math parser error messages. Do not translate operator name.")); + m_vErrMsg.insert(ecMISPLACED_COLON, + QmuTranslation::translate("QmuParserErrorMsg", + "Misplaced colon at position $POS$", + "Math parser error messages. Left untouched $POS$")); +} + +//--------------------------------------------------------------------------------------------------------------------- +// +// QParserError class +// +//--------------------------------------------------------------------------------------------------------------------- + +/** + * @brief Default constructor. + */ +QmuParserError::QmuParserError() + : QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ), + m_ErrMsg ( QmuParserErrorMsg::Instance() ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief This Constructor is used for internal exceptions only. + * + * It does not contain any information but the error code. + */ +QmuParserError::QmuParserError ( EErrorCodes a_iErrc ) + : QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( a_iErrc ), + m_ErrMsg ( QmuParserErrorMsg::Instance() ) +{ + m_sMsg = m_ErrMsg[m_iErrc]; + m_sMsg.replace("$POS$", QString().setNum ( m_iPos )); + m_sMsg.replace("$TOK$", m_sTok ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Construct an error from a message text. + */ +QmuParserError::QmuParserError ( const QString &sMsg ) + : QException(), m_sMsg(sMsg), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ), + m_ErrMsg ( QmuParserErrorMsg::Instance() ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Construct an error object. + * @param [in] iErrc the error code. + * @param [in] sTok The token string related to this error. + * @param [in] sExpr The expression related to the error. + * @param [in] iPos the position in the expression where the error occured. + */ +QmuParserError::QmuParserError ( EErrorCodes iErrc, const QString &sTok, const QString &sExpr, int iPos ) + : QException(), m_sMsg(), m_sExpr ( sExpr ), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ), + m_ErrMsg ( QmuParserErrorMsg::Instance() ) +{ + m_sMsg = m_ErrMsg[m_iErrc]; + qDebug()< + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERERROR_H +#define QMUPARSERERROR_H + +#include "qmuparser_global.h" +#include +#include +#include + +#include "qmuparserdef.h" +#include "qmutranslation.h" + +/** @file + @brief This file defines the error class used by the parser. +*/ + +namespace qmu +{ + +/** @brief Error codes. */ +enum EErrorCodes +{ + // Formula syntax errors + ecUNEXPECTED_OPERATOR = 0, ///< Unexpected binary operator found + ecUNASSIGNABLE_TOKEN = 1, ///< Token cant be identified. + ecUNEXPECTED_EOF = 2, ///< Unexpected end of formula. (Example: "2+sin(") + ecUNEXPECTED_ARG_SEP = 3, ///< An unexpected comma has been found. (Example: "1,23") + ecUNEXPECTED_ARG = 4, ///< An unexpected argument has been found + ecUNEXPECTED_VAL = 5, ///< An unexpected value token has been found + ecUNEXPECTED_VAR = 6, ///< An unexpected variable token has been found + ecUNEXPECTED_PARENS = 7, ///< Unexpected Parenthesis, opening or closing + ecUNEXPECTED_STR = 8, ///< A string has been found at an inapropriate position + ecSTRING_EXPECTED = 9, ///< A string function has been called with a different type of argument + ecVAL_EXPECTED = 10, ///< A numerical function has been called with a non value type of argument + ecMISSING_PARENS = 11, ///< Missing parens. (Example: "3*sin(3") + ecUNEXPECTED_FUN = 12, ///< Unexpected function found. (Example: "sin(8)cos(9)") + ecUNTERMINATED_STRING = 13, ///< unterminated string constant. (Example: "3*valueof("hello)") + ecTOO_MANY_PARAMS = 14, ///< Too many function parameters + ecTOO_FEW_PARAMS = 15, ///< Too few function parameters. (Example: "ite(1<2,2)") + ecOPRT_TYPE_CONFLICT = 16, ///< binary operators may only be applied to value items of the same type + ecSTR_RESULT = 17, ///< result is a string + + // Invalid Parser input Parameters + ecINVALID_NAME = 18, ///< Invalid function, variable or constant name. + ecINVALID_BINOP_IDENT = 19, ///< Invalid binary operator identifier + ecINVALID_INFIX_IDENT = 20, ///< Invalid function, variable or constant name. + ecINVALID_POSTFIX_IDENT = 21, ///< Invalid function, variable or constant name. + + ecBUILTIN_OVERLOAD = 22, ///< Trying to overload builtin operator + ecINVALID_FUN_PTR = 23, ///< Invalid callback function pointer + ecINVALID_VAR_PTR = 24, ///< Invalid variable pointer + ecEMPTY_EXPRESSION = 25, ///< The Expression is empty + ecNAME_CONFLICT = 26, ///< Name conflict + ecOPT_PRI = 27, ///< Invalid operator priority + // + ecDOMAIN_ERROR = 28, ///< catch division by zero, sqrt(-1), log(0) (currently unused) + ecDIV_BY_ZERO = 29, ///< Division by zero (currently unused) + ecGENERIC = 30, ///< Generic error + ecLOCALE = 31, ///< Conflict with current locale + + ecUNEXPECTED_CONDITIONAL = 32, + ecMISSING_ELSE_CLAUSE = 33, + ecMISPLACED_COLON = 34, + + // internal errors + ecINTERNAL_ERROR = 35, ///< Internal error of any kind. + + // The last two are special entries + ecCOUNT, ///< This is no error code, It just stores just the total number of error codes + ecUNDEFINED = -1 ///< Undefined message, placeholder to detect unassigned error messages +}; + +//--------------------------------------------------------------------------- +/** @brief A class that handles the error messages. +*/ +class QmuParserErrorMsg +{ +public: + typedef QmuParserErrorMsg self_type; + + QmuParserErrorMsg(); + ~QmuParserErrorMsg(); + + static const QmuParserErrorMsg& Instance(); + QString operator[] ( int a_iIdx ) const; + +private: + Q_DISABLE_COPY(QmuParserErrorMsg) + QMap m_vErrMsg; ///< A map with the predefined error messages + static const self_type m_Instance; ///< The instance pointer +}; + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +inline const QmuParserErrorMsg& QmuParserErrorMsg::Instance() +{ + return m_Instance; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QString QmuParserErrorMsg::operator[] ( int a_iIdx ) const +{ + return m_vErrMsg.value(a_iIdx).translate(); +} + +//--------------------------------------------------------------------------- +/** @brief Error class of the parser. + @author Ingo Berg + + Part of the math parser package. +*/ +class QMUPARSERSHARED_EXPORT QmuParserError : public QException +{ +public: + QmuParserError(); + explicit QmuParserError ( EErrorCodes a_iErrc ); + explicit QmuParserError ( const QString &sMsg ); + QmuParserError ( EErrorCodes a_iErrc, const QString &sTok, const QString &sFormula = QString(), int a_iPos = -1 ); + QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok ); + QmuParserError ( const QString &a_szMsg, int a_iPos, const QString &sTok = QString() ); + QmuParserError ( const QmuParserError &a_Obj ); + QmuParserError& operator= ( const QmuParserError &a_Obj ); + virtual ~QmuParserError() QMUP_NOEXCEPT_EXPR (true){} + + void SetFormula ( const QString &a_strFormula ); + const QString& GetExpr() const; + const QString& GetMsg() const; + int GetPos() const; + const QString& GetToken() const; + EErrorCodes GetCode() const; + Q_NORETURN virtual void raise() const; + virtual QmuParserError *clone() const; +private: + QString m_sMsg; ///< The message string + QString m_sExpr; ///< Formula string + QString m_sTok; ///< Token related with the error + int m_iPos; ///< Formula position related to the error + EErrorCodes m_iErrc; ///< Error code + const QmuParserErrorMsg &m_ErrMsg; + void Reset(); +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set the expression related to this error. + */ +inline void QmuParserError::SetFormula ( const QString &a_strFormula ) +{ + m_sExpr = a_strFormula; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief gets the expression related tp this error. + */ +inline const QString& QmuParserError::GetExpr() const +{ + return m_sExpr; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the message string for this error. + */ +inline const QString& QmuParserError::GetMsg() const +{ + return m_sMsg; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the formula position related to the error. + * + * If the error is not related to a distinct position this will return -1 + */ +inline int QmuParserError::GetPos() const +{ + return m_iPos; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return string related with this token (if available). + */ +inline const QString& QmuParserError::GetToken() const +{ + return m_sTok; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the error code. + */ +inline EErrorCodes QmuParserError::GetCode() const +{ + return m_iErrc; +} + +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmuparserfixes.h b/src/libs/qmuparser/qmuparserfixes.h new file mode 100644 index 000000000..85b4298cd --- /dev/null +++ b/src/libs/qmuparser/qmuparserfixes.h @@ -0,0 +1,57 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERFIXES_H +#define QMUPARSERFIXES_H + +/** @file + @brief This file contains compatibility fixes for some platforms. +*/ + +// +// Compatibility fixes +// + +//--------------------------------------------------------------------------- +// +// Intel Compiler +// +//--------------------------------------------------------------------------- + +#ifdef __INTEL_COMPILER + +// remark #981: operands are evaluated in unspecified order +// disabled -> completely pointless if the functions do not have side effects +// +#pragma warning(disable:981) + +// remark #383: value copied to temporary, reference to temporary used +#pragma warning(disable:383) + +// remark #1572: floating-point equality and inequality comparisons are unreliable +// disabled -> everyone knows it, the parser passes this problem +// deliberately to the user +#pragma warning(disable:1572) + +#endif + +#endif // include guard diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp new file mode 100644 index 000000000..1d11cef83 --- /dev/null +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -0,0 +1,1420 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparsertest.h" + +#include +#include +#include "qmuparsererror.h" +#include +#include + +using namespace std; + +/** + * @file + * @brief This file contains the implementation of parser test cases. + */ + +namespace qmu +{ +namespace Test +{ +int QmuParserTester::c_iCount = 0; + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserTester::QmuParserTester() + : m_vTestFun() +{ + AddTest ( &QmuParserTester::TestNames ); + AddTest ( &QmuParserTester::TestSyntax ); + AddTest ( &QmuParserTester::TestPostFix ); + AddTest ( &QmuParserTester::TestInfixOprt ); + AddTest ( &QmuParserTester::TestVarConst ); + AddTest ( &QmuParserTester::TestMultiArg ); + AddTest ( &QmuParserTester::TestExpression ); + AddTest ( &QmuParserTester::TestIfThenElse ); + AddTest ( &QmuParserTester::TestInterface ); + AddTest ( &QmuParserTester::TestBinOprt ); + AddTest ( &QmuParserTester::TestException ); + AddTest ( &QmuParserTester::TestStrArg ); + + QmuParserTester::c_iCount = 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal ) +{ + if ( a_szExpr.data()[1] == 0 || ( a_szExpr.data()[0] != '0' || a_szExpr.data()[1] != 'x' ) ) + { + return 0; + } + + unsigned iVal ( 0 ); + + std::wstring a_szExprStd = a_szExpr.mid(2).toStdWString(); + + // New code based on streams for UNICODE compliance: + stringstream_type::pos_type nPos(0); + stringstream_type ss(a_szExprStd); + ss >> std::hex >> iVal; + nPos = ss.tellg(); + + if (nPos==static_cast(0)) + { + return 1; + } + + *a_iPos += static_cast(2 + nPos); + *a_fVal = static_cast(iVal); + return 1; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestInterface() +{ + int iStat = 0; + qWarning() << "testing member functions..."; + + // Test RemoveVar + qreal afVal[3] = {1, 2, 3}; + QmuParser p; + + try + { + p.DefineVar ( "a", &afVal[0] ); + p.DefineVar ( "b", &afVal[1] ); + p.DefineVar ( "c", &afVal[2] ); + p.SetExpr ( "a+b+c" ); + p.Eval(); + } + catch ( ... ) + { + iStat += 1; // this is not supposed to happen + } + + try + { + p.RemoveVar ( "c" ); + p.Eval(); + iStat += 1; // not supposed to reach this, nonexisting variable "c" deleted... + } + catch ( ... ) + { + // failure is expected... + } + + if ( iStat == 0 ) + { + qWarning() << "TestInterface passed"; + } + else + { + qWarning() << "\n TestInterface failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestStrArg() +{ + int iStat = 0; + qWarning() << "testing string arguments..."; + + iStat += EqnTest ( "valueof(\"\")", 123, true ); // empty string arguments caused a crash + iStat += EqnTest ( "valueof(\"aaa\")+valueof(\"bbb\") ", 246, true ); + iStat += EqnTest ( "2*(valueof(\"aaa\")-23)+valueof(\"bbb\")", 323, true ); + // use in expressions with variables + iStat += EqnTest ( "a*(atof(\"10\")-b)", 8, true ); + iStat += EqnTest ( "a-(atof(\"10\")*b)", -19, true ); + // string + numeric arguments + iStat += EqnTest ( "strfun1(\"100\")", 100, true ); + iStat += EqnTest ( "strfun2(\"100\",1)", 101, true ); + iStat += EqnTest ( "strfun3(\"99\",1,2)", 102, true ); + + if ( iStat == 0 ) + { + qWarning() << "TestStrArg passed"; + } + else + { + qWarning() << "\n TestStrArg failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestBinOprt() +{ + int iStat = 0; + qWarning() << "testing binary operators..."; + + // built in operators + // xor operator + //iStat += EqnTest("1 xor 2", 3, true); + //iStat += EqnTest("a xor b", 3, true); // with a=1 and b=2 + //iStat += EqnTest("1 xor 2 xor 3", 0, true); + //iStat += EqnTest("a xor b xor 3", 0, true); // with a=1 and b=2 + //iStat += EqnTest("a xor b xor c", 0, true); // with a=1 and b=2 + //iStat += EqnTest("(1 xor 2) xor 3", 0, true); + //iStat += EqnTest("(a xor b) xor c", 0, true); // with a=1 and b=2 + //iStat += EqnTest("(a) xor (b) xor c", 0, true); // with a=1 and b=2 + //iStat += EqnTest("1 or 2"), 3, true; + //iStat += EqnTest("a or b"), 3, true; // with a=1 and b=2 + iStat += EqnTest ( "a++b", 3, true ); + iStat += EqnTest ( "a ++ b", 3, true ); + iStat += EqnTest ( "1++2", 3, true ); + iStat += EqnTest ( "1 ++ 2", 3, true ); + iStat += EqnTest ( "a add b", 3, true ); + iStat += EqnTest ( "1 add 2", 3, true ); + iStat += EqnTest ( "aa", 1, true ); + iStat += EqnTest ( "a>a", 0, true ); + iStat += EqnTest ( "aa", 0, true ); + iStat += EqnTest ( "a<=a", 1, true ); + iStat += EqnTest ( "a<=b", 1, true ); + iStat += EqnTest ( "b<=a", 0, true ); + iStat += EqnTest ( "a>=a", 1, true ); + iStat += EqnTest ( "b>=a", 1, true ); + iStat += EqnTest ( "a>=b", 0, true ); + + // Test logical operators, expecially if user defined "&" and the internal "&&" collide + iStat += EqnTest ( "1 && 1", 1, true ); + iStat += EqnTest ( "1 && 0", 0, true ); + iStat += EqnTest ( "(aa)", 1, true ); + iStat += EqnTest ( "(ab)", 0, true ); + //iStat += EqnTest("12 and 255", 12, true); + //iStat += EqnTest("12 and 0", 0, true); + iStat += EqnTest ( "12 & 255", 12, true ); + iStat += EqnTest ( "12 & 0", 0, true ); + iStat += EqnTest ( "12&255", 12, true ); + iStat += EqnTest ( "12&0", 0, true ); + + // Assignement operator + iStat += EqnTest ( "a = b", 2, true ); + iStat += EqnTest ( "a = sin(b)", 0.909297, true ); + iStat += EqnTest ( "a = 1+sin(b)", 1.909297, true ); + iStat += EqnTest ( "(a=b)*2", 4, true ); + iStat += EqnTest ( "2*(a=b)", 4, true ); + iStat += EqnTest ( "2*(a=b+1)", 6, true ); + iStat += EqnTest ( "(a=b+1)*2", 6, true ); + + iStat += EqnTest ( "2^2^3", 256, true ); + iStat += EqnTest ( "1/2/3", 1.0 / 6.0, true ); + + // reference: http://www.wolframalpha.com/input/?i=3%2B4*2%2F%281-5%29^2^3 + iStat += EqnTest ( "3+4*2/(1-5)^2^3", 3.0001220703125, true ); + + if ( iStat == 0 ) + { + qWarning() << "TestBinOprt passed"; + } + else + { + qWarning() << "\n TestBinOprt failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** @brief Check muParser name restriction enforcement. */ +int QmuParserTester::TestNames() +{ + int iStat = 0, + iErr = 0; + + qWarning() << "testing name restriction enforcement..."; + + QmuParser p; + +#define PARSER_THROWCHECK(DOMAIN, FAIL, EXPR, ARG) \ + iErr = 0; \ + QmuParserTester::c_iCount++; \ + try \ + { \ + p.Define##DOMAIN(EXPR, ARG); \ + } \ + catch (QmuParserError &) \ + { \ + iErr = (FAIL==false) ? 0 : 1; \ + } \ + iStat += iErr; + + // constant names + PARSER_THROWCHECK ( Const, false, "0a", 1 ) + PARSER_THROWCHECK ( Const, false, "9a", 1 ) + PARSER_THROWCHECK ( Const, false, "+a", 1 ) + PARSER_THROWCHECK ( Const, false, "-a", 1 ) + PARSER_THROWCHECK ( Const, false, "a-", 1 ) + PARSER_THROWCHECK ( Const, false, "a*", 1 ) + PARSER_THROWCHECK ( Const, false, "a?", 1 ) + PARSER_THROWCHECK ( Const, true, "a", 1 ) + PARSER_THROWCHECK ( Const, true, "a_min", 1 ) + PARSER_THROWCHECK ( Const, true, "a_min0", 1 ) + PARSER_THROWCHECK ( Const, true, "a_min9", 1 ) + // variable names + qreal a; + p.ClearConst(); + PARSER_THROWCHECK ( Var, false, "123abc", &a ) + PARSER_THROWCHECK ( Var, false, "9a", &a ) + PARSER_THROWCHECK ( Var, false, "0a", &a ) + PARSER_THROWCHECK ( Var, false, "+a", &a ) + PARSER_THROWCHECK ( Var, false, "-a", &a ) + PARSER_THROWCHECK ( Var, false, "?a", &a ) + PARSER_THROWCHECK ( Var, false, "!a", &a ) + PARSER_THROWCHECK ( Var, false, "a+", &a ) + PARSER_THROWCHECK ( Var, false, "a-", &a ) + PARSER_THROWCHECK ( Var, false, "a*", &a ) + PARSER_THROWCHECK ( Var, false, "a?", &a ) + PARSER_THROWCHECK ( Var, true, "a", &a ) + PARSER_THROWCHECK ( Var, true, "a_min", &a ) + PARSER_THROWCHECK ( Var, true, "a_min0", &a ) + PARSER_THROWCHECK ( Var, true, "a_min9", &a ) + PARSER_THROWCHECK ( Var, false, "a_min9", 0 ) + // Postfix operators + // fail + PARSER_THROWCHECK ( PostfixOprt, false, "(k", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, false, "9+", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, false, "+", 0 ) + // pass + PARSER_THROWCHECK ( PostfixOprt, true, "-a", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "?a", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "_", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "#", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "&&", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "||", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "&", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "|", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "++", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "--", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "?>", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "?<", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "**", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "xor", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "and", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "or", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "not", f1of1 ) + PARSER_THROWCHECK ( PostfixOprt, true, "!", f1of1 ) + // Binary operator + // The following must fail with builtin operators activated + // p.EnableBuiltInOp(true); -> this is the default + p.ClearPostfixOprt(); + PARSER_THROWCHECK ( Oprt, false, "+", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "-", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "*", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "/", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "^", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "&&", f1of2 ) + PARSER_THROWCHECK ( Oprt, false, "||", f1of2 ) + // without activated built in operators it should work + p.EnableBuiltInOprt ( false ); + PARSER_THROWCHECK ( Oprt, true, "+", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "-", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "*", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "/", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "^", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "&&", f1of2 ) + PARSER_THROWCHECK ( Oprt, true, "||", f1of2 ) +#undef PARSER_THROWCHECK + + if ( iStat == 0 ) + { + qWarning() << "TestNames passed"; + } + else + { + qWarning() << "\n TestNames failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestSyntax() +{ + int iStat = 0; + qWarning() << "testing syntax engine..."; + + iStat += ThrowTest ( "1,", ecUNEXPECTED_EOF ); // incomplete hex definition + iStat += ThrowTest ( "a,", ecUNEXPECTED_EOF ); // incomplete hex definition + iStat += ThrowTest ( "sin(8),", ecUNEXPECTED_EOF ); // incomplete hex definition + iStat += ThrowTest ( "(sin(8)),", ecUNEXPECTED_EOF ); // incomplete hex definition + iStat += ThrowTest ( "a{m},", ecUNEXPECTED_EOF ); // incomplete hex definition + + iStat += EqnTest ( "(1+ 2*a)", 3, true ); // Spaces within formula + iStat += EqnTest ( "sqrt((4))", 2, true ); // Multiple brackets + iStat += EqnTest ( "sqrt((2)+2)", 2, true ); // Multiple brackets + iStat += EqnTest ( "sqrt(2+(2))", 2, true ); // Multiple brackets + iStat += EqnTest ( "sqrt(a+(3))", 2, true ); // Multiple brackets + iStat += EqnTest ( "sqrt((3)+a)", 2, true ); // Multiple brackets + iStat += EqnTest ( "order(1,2)", 1, true ); // May not cause name collision with operator "or" + iStat += EqnTest ( "(2+", 0, false ); // missing closing bracket + iStat += EqnTest ( "2++4", 0, false ); // unexpected operator + iStat += EqnTest ( "2+-4", 0, false ); // unexpected operator + iStat += EqnTest ( "(2+)", 0, false ); // unexpected closing bracket + iStat += EqnTest ( "--2", 0, false ); // double sign + iStat += EqnTest ( "ksdfj", 0, false ); // unknown token + iStat += EqnTest ( "()", 0, false ); // empty bracket without a function + iStat += EqnTest ( "5+()", 0, false ); // empty bracket without a function + iStat += EqnTest ( "sin(cos)", 0, false ); // unexpected function + iStat += EqnTest ( "5t6", 0, false ); // unknown token + iStat += EqnTest ( "5 t 6", 0, false ); // unknown token + iStat += EqnTest ( "8*", 0, false ); // unexpected end of formula + iStat += EqnTest ( ",3", 0, false ); // unexpected comma + iStat += EqnTest ( "3,5", 0, false ); // unexpected comma + iStat += EqnTest ( "sin(8,8)", 0, false ); // too many function args + iStat += EqnTest ( "(7,8)", 0, false ); // too many function args + iStat += EqnTest ( "sin)", 0, false ); // unexpected closing bracket + iStat += EqnTest ( "a)", 0, false ); // unexpected closing bracket + iStat += EqnTest ( "pi)", 0, false ); // unexpected closing bracket + iStat += EqnTest ( "sin(())", 0, false ); // unexpected closing bracket + iStat += EqnTest ( "sin()", 0, false ); // unexpected closing bracket + + if ( iStat == 0 ) + { + qWarning() << "TestSyntax passed"; + } + else + { + qWarning() << "\n TestSyntax failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestVarConst() +{ + int iStat = 0; + qWarning() << "testing variable/constant detection..."; + + // Test if the result changes when a variable changes + iStat += EqnTestWithVarChange ( "a", 1, 1, 2, 2 ); + iStat += EqnTestWithVarChange ( "2*a", 2, 4, 3, 6 ); + + // distinguish constants with same basename + iStat += EqnTest ( "const", 1, true ); + iStat += EqnTest ( "const1", 2, true ); + iStat += EqnTest ( "const2", 3, true ); + iStat += EqnTest ( "2*const", 2, true ); + iStat += EqnTest ( "2*const1", 4, true ); + iStat += EqnTest ( "2*const2", 6, true ); + iStat += EqnTest ( "2*const+1", 3, true ); + iStat += EqnTest ( "2*const1+1", 5, true ); + iStat += EqnTest ( "2*const2+1", 7, true ); + iStat += EqnTest ( "const", 0, false ); + iStat += EqnTest ( "const1", 0, false ); + iStat += EqnTest ( "const2", 0, false ); + + // distinguish variables with same basename + iStat += EqnTest ( "a", 1, true ); + iStat += EqnTest ( "aa", 2, true ); + iStat += EqnTest ( "2*a", 2, true ); + iStat += EqnTest ( "2*aa", 4, true ); + iStat += EqnTest ( "2*a-1", 1, true ); + iStat += EqnTest ( "2*aa-1", 3, true ); + + // custom value recognition + iStat += EqnTest ( "0xff", 255, true ); + iStat += EqnTest ( "0x97 + 0xff", 406, true ); + + // Finally test querying of used variables + try + { + int idx; + qmu::QmuParser p; + qreal vVarVal[] = { 1, 2, 3, 4, 5}; + p.DefineVar ( "a", &vVarVal[0] ); + p.DefineVar ( "b", &vVarVal[1] ); + p.DefineVar ( "c", &vVarVal[2] ); + p.DefineVar ( "d", &vVarVal[3] ); + p.DefineVar ( "e", &vVarVal[4] ); + + // Test lookup of defined variables + // 4 used variables + p.SetExpr ( "a+b+c+d" ); + qmu::varmap_type UsedVar = p.GetUsedVar(); + int iCount = static_cast(UsedVar.size()); + if ( iCount != 4 ) + { + throw false; + } + + // the next check will fail if the parser + // erroneousely creates new variables internally + if ( p.GetVar().size() != 5 ) + { + throw false; + } + + qmu::varmap_type::const_iterator item = UsedVar.begin(); + for ( idx = 0; item != UsedVar.end(); ++item ) + { + if ( &vVarVal[idx++] != item->second ) + { + throw false; + } + } + + // Test lookup of undefined variables + p.SetExpr ( "undef1+undef2+undef3" ); + UsedVar = p.GetUsedVar(); + iCount = static_cast(UsedVar.size()); + if ( iCount != 3 ) + { + throw false; + } + + // the next check will fail if the parser + // erroneousely creates new variables internally + if ( p.GetVar().size() != 5 ) + { + throw false; + } + + for ( item = UsedVar.begin(); item != UsedVar.end(); ++item ) + { + if ( item->second != 0 ) + { + throw false; // all pointers to undefined variables must be null + } + } + + // 1 used variables + p.SetExpr ( "a+b" ); + UsedVar = p.GetUsedVar(); + iCount = static_cast(UsedVar.size()); + if ( iCount != 2 ) + { + throw false; + } + item = UsedVar.begin(); + for ( idx = 0; item != UsedVar.end(); ++item ) + { + if ( &vVarVal[idx++] != item->second ) + { + throw false; + } + } + + } + catch ( ... ) + { + iStat += 1; + } + + if ( iStat == 0 ) + { + qWarning() << "TestVarConst passed"; + } + else + { + qWarning() << "\n TestVarConst failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestMultiArg() +{ + int iStat = 0; + qWarning() << "testing multiarg functions..."; + + // Compound expressions + iStat += EqnTest ( "1,2,3", 3, true ); + iStat += EqnTest ( "a,b,c", 3, true ); + iStat += EqnTest ( "a=10,b=20,c=a*b", 200, true ); + iStat += EqnTest ( "1,\n2,\n3", 3, true ); + iStat += EqnTest ( "a,\nb,\nc", 3, true ); + iStat += EqnTest ( "a=10,\nb=20,\nc=a*b", 200, true ); + iStat += EqnTest ( "1,\r\n2,\r\n3", 3, true ); + iStat += EqnTest ( "a,\r\nb,\r\nc", 3, true ); + iStat += EqnTest ( "a=10,\r\nb=20,\r\nc=a*b", 200, true ); + + // picking the right argument + iStat += EqnTest ( "f1of1(1)", 1, true ); + iStat += EqnTest ( "f1of2(1, 2)", 1, true ); + iStat += EqnTest ( "f2of2(1, 2)", 2, true ); + iStat += EqnTest ( "f1of3(1, 2, 3)", 1, true ); + iStat += EqnTest ( "f2of3(1, 2, 3)", 2, true ); + iStat += EqnTest ( "f3of3(1, 2, 3)", 3, true ); + iStat += EqnTest ( "f1of4(1, 2, 3, 4)", 1, true ); + iStat += EqnTest ( "f2of4(1, 2, 3, 4)", 2, true ); + iStat += EqnTest ( "f3of4(1, 2, 3, 4)", 3, true ); + iStat += EqnTest ( "f4of4(1, 2, 3, 4)", 4, true ); + iStat += EqnTest ( "f1of5(1, 2, 3, 4, 5)", 1, true ); + iStat += EqnTest ( "f2of5(1, 2, 3, 4, 5)", 2, true ); + iStat += EqnTest ( "f3of5(1, 2, 3, 4, 5)", 3, true ); + iStat += EqnTest ( "f4of5(1, 2, 3, 4, 5)", 4, true ); + iStat += EqnTest ( "f5of5(1, 2, 3, 4, 5)", 5, true ); + // Too few arguments / Too many arguments + iStat += EqnTest ( "1+ping()", 11, true ); + iStat += EqnTest ( "ping()+1", 11, true ); + iStat += EqnTest ( "2*ping()", 20, true ); + iStat += EqnTest ( "ping()*2", 20, true ); + iStat += EqnTest ( "ping(1,2)", 0, false ); + iStat += EqnTest ( "1+ping(1,2)", 0, false ); + iStat += EqnTest ( "f1of1(1,2)", 0, false ); + iStat += EqnTest ( "f1of1()", 0, false ); + iStat += EqnTest ( "f1of2(1, 2, 3)", 0, false ); + iStat += EqnTest ( "f1of2(1)", 0, false ); + iStat += EqnTest ( "f1of3(1, 2, 3, 4)", 0, false ); + iStat += EqnTest ( "f1of3(1)", 0, false ); + iStat += EqnTest ( "f1of4(1, 2, 3, 4, 5)", 0, false ); + iStat += EqnTest ( "f1of4(1)", 0, false ); + iStat += EqnTest ( "(1,2,3)", 0, false ); + iStat += EqnTest ( "1,2,3", 0, false ); + iStat += EqnTest ( "(1*a,2,3)", 0, false ); + iStat += EqnTest ( "1,2*a,3", 0, false ); + + // correct calculation of arguments + iStat += EqnTest ( "min(a, 1)", 1, true ); + iStat += EqnTest ( "min(3*2, 1)", 1, true ); + iStat += EqnTest ( "min(3*2, 1)", 6, false ); + iStat += EqnTest ( "firstArg(2,3,4)", 2, true ); + iStat += EqnTest ( "lastArg(2,3,4)", 4, true ); + iStat += EqnTest ( "min(3*a+1, 1)", 1, true ); + iStat += EqnTest ( "max(3*a+1, 1)", 4, true ); + iStat += EqnTest ( "max(3*a+1, 1)*2", 8, true ); + iStat += EqnTest ( "2*max(3*a+1, 1)+2", 10, true ); + + // functions with Variable argument count + iStat += EqnTest ( "sum(a)", 1, true ); + iStat += EqnTest ( "sum(1,2,3)", 6, true ); + iStat += EqnTest ( "sum(a,b,c)", 6, true ); + iStat += EqnTest ( "sum(1,-max(1,2),3)*2", 4, true ); + iStat += EqnTest ( "2*sum(1,2,3)", 12, true ); + iStat += EqnTest ( "2*sum(1,2,3)+2", 14, true ); + iStat += EqnTest ( "2*sum(-1,2,3)+2", 10, true ); + iStat += EqnTest ( "2*sum(-1,2,-(-a))+2", 6, true ); + iStat += EqnTest ( "2*sum(-1,10,-a)+2", 18, true ); + iStat += EqnTest ( "2*sum(1,2,3)*2", 24, true ); + iStat += EqnTest ( "sum(1,-max(1,2),3)*2", 4, true ); + iStat += EqnTest ( "sum(1*3, 4, a+2)", 10, true ); + iStat += EqnTest ( "sum(1*3, 2*sum(1,2,2), a+2)", 16, true ); + iStat += EqnTest ( "sum(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2)", 24, true ); + + // some failures + iStat += EqnTest ( "sum()", 0, false ); + iStat += EqnTest ( "sum(,)", 0, false ); + iStat += EqnTest ( "sum(1,2,)", 0, false ); + iStat += EqnTest ( "sum(,1,2)", 0, false ); + + if ( iStat == 0 ) + { + qWarning() << "TestMultiArg passed"; + } + else + { + qWarning() << "\n TestMultiArg failed with " << iStat << " errors"; + } + + return iStat; +} + + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestInfixOprt() +{ + int iStat ( 0 ); + qWarning() << "testing infix operators..."; + + iStat += EqnTest ( "-1", -1, true ); + iStat += EqnTest ( "-(-1)", 1, true ); + iStat += EqnTest ( "-(-1)*2", 2, true ); + iStat += EqnTest ( "-(-2)*sqrt(4)", 4, true ); + iStat += EqnTest ( "-_pi", -M_PI, true ); + iStat += EqnTest ( "-a", -1, true ); + iStat += EqnTest ( "-(a)", -1, true ); + iStat += EqnTest ( "-(-a)", 1, true ); + iStat += EqnTest ( "-(-a)*2", 2, true ); + iStat += EqnTest ( "-(8)", -8, true ); + iStat += EqnTest ( "-8", -8, true ); + iStat += EqnTest ( "-(2+1)", -3, true ); + iStat += EqnTest ( "-(f1of1(1+2*3)+1*2)", -9, true ); + iStat += EqnTest ( "-(-f1of1(1+2*3)+1*2)", 5, true ); + iStat += EqnTest ( "-sin(8)", -0.989358, true ); + iStat += EqnTest ( "3-(-a)", 4, true ); + iStat += EqnTest ( "3--a", 4, true ); + iStat += EqnTest ( "-1*3", -3, true ); + + // Postfix / infix priorities + iStat += EqnTest ( "~2#", 8, true ); + iStat += EqnTest ( "~f1of1(2)#", 8, true ); + iStat += EqnTest ( "~(b)#", 8, true ); + iStat += EqnTest ( "(~b)#", 12, true ); + iStat += EqnTest ( "~(2#)", 8, true ); + iStat += EqnTest ( "~(f1of1(2)#)", 8, true ); + // + iStat += EqnTest ( "-2^2", -4, true ); + iStat += EqnTest ( "-(a+b)^2", -9, true ); + iStat += EqnTest ( "(-3)^2", 9, true ); + iStat += EqnTest ( "-(-2^2)", 4, true ); + iStat += EqnTest ( "3+-3^2", -6, true ); + // The following assumes use of sqr as postfix operator ("") together + // with a sign operator of low priority: + iStat += EqnTest ( "-2'", -4, true ); + iStat += EqnTest ( "-(1+1)'", -4, true ); + iStat += EqnTest ( "2+-(1+1)'", -2, true ); + iStat += EqnTest ( "2+-2'", -2, true ); + // This is the classic behaviour of the infix sign operator (here: "$") which is + // now deprecated: + iStat += EqnTest ( "$2^2", 4, true ); + iStat += EqnTest ( "$(a+b)^2", 9, true ); + iStat += EqnTest ( "($3)^2", 9, true ); + iStat += EqnTest ( "$($2^2)", -4, true ); + iStat += EqnTest ( "3+$3^2", 12, true ); + + // infix operators sharing the first few characters + iStat += EqnTest ( "~ 123", 123 + 2, true ); + iStat += EqnTest ( "~~ 123", 123 + 2, true ); + + if ( iStat == 0 ) + { + qWarning() << "TestInfixOprt passed"; + } + else + { + qWarning() << "\n TestInfixOprt failed with " << iStat << " errors"; + } + + return iStat; +} + + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestPostFix() +{ + int iStat = 0; + qWarning() << "testing postfix operators..."; + + // application + iStat += EqnTest ( "3{m}+5", 5.003, true ); + iStat += EqnTest ( "1000{m}", 1, true ); + iStat += EqnTest ( "1000 {m}", 1, true ); + iStat += EqnTest ( "(a){m}", 1e-3, true ); + iStat += EqnTest ( "a{m}", 1e-3, true ); + iStat += EqnTest ( "a {m}", 1e-3, true ); + iStat += EqnTest ( "-(a){m}", -1e-3, true ); + iStat += EqnTest ( "-2{m}", -2e-3, true ); + iStat += EqnTest ( "-2 {m}", -2e-3, true ); + iStat += EqnTest ( "f1of1(1000){m}", 1, true ); + iStat += EqnTest ( "-f1of1(1000){m}", -1, true ); + iStat += EqnTest ( "-f1of1(-1000){m}", 1, true ); + iStat += EqnTest ( "f4of4(0,0,0,1000){m}", 1, true ); + iStat += EqnTest ( "2+(a*1000){m}", 3, true ); + + // can postfix operators "m" und "meg" be told apart properly? + iStat += EqnTest ( "2*3000meg+2", 2 * 3e9 + 2, true ); + + // some incorrect results + iStat += EqnTest ( "1000{m}", 0.1, false ); + iStat += EqnTest ( "(a){m}", 2, false ); + // failure due to syntax checking + iStat += ThrowTest ( "0x", ecUNASSIGNABLE_TOKEN ); // incomplete hex definition + iStat += ThrowTest ( "3+", ecUNEXPECTED_EOF ); + iStat += ThrowTest ( "4 + {m}", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "{m}4", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "sin({m})", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "{m} {m}", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "{m}(8)", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "4,{m}", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "-{m}", ecUNASSIGNABLE_TOKEN ); + iStat += ThrowTest ( "2(-{m})", ecUNEXPECTED_PARENS ); + iStat += ThrowTest ( "2({m})", ecUNEXPECTED_PARENS ); + + iStat += ThrowTest ( "multi*1.0", ecUNASSIGNABLE_TOKEN ); + + if ( iStat == 0 ) + { + qWarning() << "TestPostFix passed"; + } + else + { + qWarning() << "\n TestPostFix failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestExpression() +{ + int iStat = 0; + qWarning() << "testing expression samples..."; + + qreal b = 2; + + // Optimization + iStat += EqnTest ( "2*b*5", 20, true ); + iStat += EqnTest ( "2*b*5 + 4*b", 28, true ); + iStat += EqnTest ( "2*a/3", 2.0 / 3.0, true ); + + // Addition auf cmVARMUL + iStat += EqnTest ( "3+b", b + 3, true ); + iStat += EqnTest ( "b+3", b + 3, true ); + iStat += EqnTest ( "b*3+2", b * 3 + 2, true ); + iStat += EqnTest ( "3*b+2", b * 3 + 2, true ); + iStat += EqnTest ( "2+b*3", b * 3 + 2, true ); + iStat += EqnTest ( "2+3*b", b * 3 + 2, true ); + iStat += EqnTest ( "b+3*b", b + 3 * b, true ); + iStat += EqnTest ( "3*b+b", b + 3 * b, true ); + + iStat += EqnTest ( "2+b*3+b", 2 + b * 3 + b, true ); + iStat += EqnTest ( "b+2+b*3", b + 2 + b * 3, true ); + + iStat += EqnTest ( "(2*b+1)*4", ( 2 * b + 1 ) * 4, true ); + iStat += EqnTest ( "4*(2*b+1)", ( 2 * b + 1 ) * 4, true ); + // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 + iStat += EqnTest ( "1+2+3", 6, true ); + + // operator precedencs + iStat += EqnTest ( "1+2-3*4/5^6", 2.99923, true ); + iStat += EqnTest ( "1^2/3*4-5+6", 2.33333333, true ); + iStat += EqnTest ( "1+2*3", 7, true ); + iStat += EqnTest ( "1+2*3", 7, true ); + iStat += EqnTest ( "(1+2)*3", 9, true ); + iStat += EqnTest ( "(1+2)*(-3)", -9, true ); + iStat += EqnTest ( "2/4", 0.5, true ); + + iStat += EqnTest ( "exp(ln(7))", 7, true ); + iStat += EqnTest ( "e^ln(7)", 7, true ); + iStat += EqnTest ( "e^(ln(7))", 7, true ); + iStat += EqnTest ( "(e^(ln(7)))", 7, true ); + iStat += EqnTest ( "1-(e^(ln(7)))", -6, true ); + iStat += EqnTest ( "2*(e^(ln(7)))", 14, true ); + iStat += EqnTest ( "10^log(5)", 5, true ); + iStat += EqnTest ( "10^log10(5)", 5, true ); + iStat += EqnTest ( "2^log2(4)", 4, true ); + iStat += EqnTest ( "-(sin(0)+1)", -1, true ); + iStat += EqnTest ( "-(2^1.1)", -2.14354692, true ); + + iStat += EqnTest ( "(cos(2.41)/b)", -0.372056, true ); + iStat += EqnTest ( "(1*(2*(3*(4*(5*(6*(a+b)))))))", 2160, true ); + iStat += EqnTest ( "(1*(2*(3*(4*(5*(6*(7*(a+b))))))))", 15120, true ); + iStat += EqnTest ( "(a/((((b+(((e*(((((pi*((((3.45*((pi+a)+pi))+b)+b)*a))+0.68)+e)+a)/a))+a)+b))+b)*a)-pi))", + 0.00377999, true ); + + // long formula (Reference: Matlab) + iStat += EqnTest ( + "(((-9))-e/(((((((pi-(((-7)+(-3)/4/e))))/(((-5))-2)-((pi+(-0))*(sqrt((e+e))*(-8))*(((-pi)+(-pi)-(-9)*(6*5))" + "/(-e)-e))/2)/((((sqrt(2/(-e)+6)-(4-2))+((5/(-2))/(1*(-pi)+3))/8)*pi*((pi/((-2)/(-6)*1*(-1))*(-6)+(-e)))))/" + "((e+(-2)+(-e)*((((-3)*9+(-e)))+(-9)))))))-((((e-7+(((5/pi-(3/1+pi)))))/e)/(-5))/(sqrt((((((1+(-7))))+((((-" + "e)*(-e)))-8))*(-5)/((-e)))*(-6)-((((((-2)-(-9)-(-e)-1)/3))))/(sqrt((8+(e-((-6))+(9*(-9))))*(((3+2-8))*(7+6" + "+(-5))+((0/(-e)*(-pi))+7)))+(((((-e)/e/e)+((-6)*5)*e+(3+(-5)/pi))))+pi))/sqrt((((9))+((((pi))-8+2))+pi))/e" + "*4)*((-5)/(((-pi))*(sqrt(e)))))-(((((((-e)*(e)-pi))/4+(pi)*(-9)))))))+(-pi)", -12.23016549, true ); + + // long formula (Reference: Matlab) + iStat += EqnTest ( + "(atan(sin((((((((((((((((pi/cos((a/((((0.53-b)-pi)*e)/b))))+2.51)+a)-0.54)/0.98)+b)*b)+e)/a)+b)+a)+b)+pi)/e" + ")+a)))*2.77)", -2.16995656, true ); + + // long formula (Reference: Matlab) + iStat += EqnTest ( "1+2-3*4/5^6*(2*(1-5+(3*7^9)*(4+6*7-3)))+12", -7995810.09926, true ); + + if ( iStat == 0 ) + { + qWarning() << "TestExpression passed"; + } + else + { + qWarning() << "\n TestExpression failed with " << iStat << " errors"; + } + + return iStat; +} + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::TestIfThenElse() +{ + int iStat = 0; + qWarning() << "testing if-then-else operator..."; + + // Test error detection + iStat += ThrowTest ( ":3", ecUNEXPECTED_CONDITIONAL ); + iStat += ThrowTest ( "? 1 : 2", ecUNEXPECTED_CONDITIONAL ); + iStat += ThrowTest ( "(ab) ? 10 : 11", 11, true ); + iStat += EqnTest ( "(ab) ? c : d", -2, true ); + + iStat += EqnTest ( "(a>b) ? 1 : 0", 0, true ); + iStat += EqnTest ( "((a>b) ? 1 : 0) ? 1 : 2", 2, true ); + iStat += EqnTest ( "((a>b) ? 1 : 0) ? 1 : sum((a>b) ? 1 : 2)", 2, true ); + iStat += EqnTest ( "((a>b) ? 0 : 1) ? 1 : sum((a>b) ? 1 : 2)", 1, true ); + + iStat += EqnTest ( "sum((a>b) ? 1 : 2)", 2, true ); + iStat += EqnTest ( "sum((1) ? 1 : 2)", 1, true ); + iStat += EqnTest ( "sum((a>b) ? 1 : 2, 100)", 102, true ); + iStat += EqnTest ( "sum((1) ? 1 : 2, 100)", 101, true ); + iStat += EqnTest ( "sum(3, (a>b) ? 3 : 10)", 13, true ); + iStat += EqnTest ( "sum(3, (ab) ? 3 : 10)", 130, true ); + iStat += EqnTest ( "10*sum(3, (ab) ? 3 : 10)*10", 130, true ); + iStat += EqnTest ( "sum(3, (ab) ? sum(3, (ab) ? sum(3, (ab) ? sum(3, (ab)&&(a2)&&(1<2) ? 128 : 255", 255, true ); + iStat += EqnTest ( "((1<2)&&(1<2)) ? 128 : 255", 128, true ); + iStat += EqnTest ( "((1>2)&&(1<2)) ? 128 : 255", 255, true ); + iStat += EqnTest ( "((ab)&&(a0 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 64", 255, true ); + iStat += EqnTest ( "1>0 ? 1>2 ? 128 : 255 :(1>0 ? 32 : 64)", 255, true ); + iStat += EqnTest ( "1>0 ? 1>0 ? 128 : 255 : 1>2 ? 32 : 64", 128, true ); + iStat += EqnTest ( "1>0 ? 1>0 ? 128 : 255 :(1>2 ? 32 : 64)", 128, true ); + iStat += EqnTest ( "1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 64", 32, true ); + iStat += EqnTest ( "1>2 ? 1>0 ? 128 : 255 : 1>2 ? 32 : 64", 64, true ); + iStat += EqnTest ( "1>0 ? 50 : 1>0 ? 128 : 255", 50, true ); + iStat += EqnTest ( "1>0 ? 50 : (1>0 ? 128 : 255)", 50, true ); + iStat += EqnTest ( "1>0 ? 1>0 ? 128 : 255 : 50", 128, true ); + iStat += EqnTest ( "1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 : 1>2 ? 64 : 16", 32, true ); + iStat += EqnTest ( "1>2 ? 1>2 ? 128 : 255 : 1>0 ? 32 :(1>2 ? 64 : 16)", 32, true ); + iStat += EqnTest ( "1>0 ? 1>2 ? 128 : 255 : 1>0 ? 32 :1>2 ? 64 : 16", 255, true ); + iStat += EqnTest ( "1>0 ? 1>2 ? 128 : 255 : (1>0 ? 32 :1>2 ? 64 : 16)", 255, true ); + iStat += EqnTest ( "1 ? 0 ? 128 : 255 : 1 ? 32 : 64", 255, true ); + + // assignment operators + iStat += EqnTest ( "a= 0 ? 128 : 255, a", 255, true ); + iStat += EqnTest ( "a=((a>b)&&(a + // this is now legal, for reference see: + // https://sourceforge.net/forum/message.php?msg_id=7411373 + // iStat += ThrowTest( "sin=9"), ecUNEXPECTED_OPERATOR); + //
+ + iStat += ThrowTest ( "(8)=5", ecUNEXPECTED_OPERATOR ); + iStat += ThrowTest ( "(a)=5", ecUNEXPECTED_OPERATOR ); + iStat += ThrowTest ( "a=\"tttt\"", ecOPRT_TYPE_CONFLICT ); + + if ( iStat == 0 ) + { + qWarning() << "TestException passed"; + } + else + { + qWarning() << "\n TestException failed with " << iStat << " errors"; + } + + return iStat; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserTester::AddTest ( testfun_type a_pFun ) +{ + m_vTestFun.push_back ( a_pFun ); +} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void QmuParserTester::Run() +{ + int iStat = 0; + try + { + for ( int i = 0; i < m_vTestFun.size(); ++i ) + { + iStat += ( this->*m_vTestFun[i] ) (); + } + } + catch ( QmuParserError &e ) + { + qWarning() << "\n" << e.GetMsg(); + qWarning() << e.GetToken(); + Abort(); + } + catch ( std::exception &e ) + { + qWarning() << e.what(); + Abort(); + } + catch ( ... ) + { + qWarning() << "Internal error"; + Abort(); + } + + if ( iStat == 0 ) + { + qWarning() << "Test passed (" << QmuParserTester::c_iCount << " expressions)"; + } + else + { + qWarning() << "Test failed with " << iStat + << " errors (" << QmuParserTester::c_iCount + << " expressions)"; + } + QmuParserTester::c_iCount = 0; +} + + +//--------------------------------------------------------------------------------------------------------------------- +int QmuParserTester::ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail ) +{ + QmuParserTester::c_iCount++; + + try + { + qreal fVal[] = {1, 1, 1}; + QmuParser p; + + p.DefineVar ( "a", &fVal[0] ); + p.DefineVar ( "b", &fVal[1] ); + p.DefineVar ( "c", &fVal[2] ); + p.DefinePostfixOprt ( "{m}", Milli ); + p.DefinePostfixOprt ( "m", Milli ); + p.DefineFun ( "ping", Ping ); + p.DefineFun ( "valueof", ValueOf ); + p.DefineFun ( "strfun1", StrFun1 ); + p.DefineFun ( "strfun2", StrFun2 ); + p.DefineFun ( "strfun3", StrFun3 ); + p.SetExpr ( a_str ); + p.Eval(); + } + catch ( const qmu::QmuParserError &e ) + { + // output the formula in case of an failed test + if ( a_bFail == false || ( a_bFail == true && a_iErrc != e.GetCode() ) ) + { + qWarning() << "\n " << "Expression: " << a_str << " Code:" << e.GetCode() << "(" << e.GetMsg() << ")" + << " Expected:" << a_iErrc; + } + + return ( a_iErrc == e.GetCode() ) ? 0 : 1; + } + + // if a_bFail==false no exception is expected + bool bRet ( ( a_bFail == false ) ? 0 : 1 ); + if ( bRet == 1 ) + { + qWarning() << "\n " + << "Expression: " << a_str + << " did evaluate; Expected error:" << a_iErrc; + } + + return bRet; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Evaluate a tet expression. + * + * @return 1 in case of a failure, 0 otherwise. + */ +int QmuParserTester::EqnTestWithVarChange ( const QString &a_str, double a_fVar1, double a_fRes1, double a_fVar2, + double a_fRes2 ) +{ + QmuParserTester::c_iCount++; + qreal fVal[2] = { -999, -999 }; // should be equalinitially + + try + { + QmuParser p; + + // variable + qreal var = 0; + p.DefineVar ( "a", &var ); + p.SetExpr ( a_str ); + + var = a_fVar1; + fVal[0] = p.Eval(); + + // cppcheck-suppress redundantAssignment + var = a_fVar2; + fVal[1] = p.Eval(); + + if ( fabs ( a_fRes1 - fVal[0] ) > 0.0000000001 ) + { + throw std::runtime_error ( "incorrect result (first pass)" ); + } + + if ( fabs ( a_fRes2 - fVal[1] ) > 0.0000000001 ) + { + throw std::runtime_error ( "incorrect result (second pass)" ); + } + } + catch ( QmuParserError &e ) + { + qWarning() << "\n fail: " << a_str << " (" << e.GetMsg() << ")"; + return 1; + } + catch ( std::exception &e ) + { + qWarning() << "\n fail: " << a_str << " (" << e.what() << ")"; + return 1; // always return a failure since this exception is not expected + } + catch ( ... ) + { + qWarning() << "\n fail: " << a_str << " (unexpected exception)"; + return 1; // exceptions other than ParserException are not allowed + } + + return 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Evaluate a tet expression. + * + * @return 1 in case of a failure, 0 otherwise. + */ +int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass ) +{ + QmuParserTester::c_iCount++; + int iRet ( 0 ); + qreal fVal[5] = { -999, -998, -997, -996, -995}; // initially should be different + + try + { + std::unique_ptr p1; + QmuParser p2, p3; // three parser objects + // they will be used for testing copy and assihnment operators + // p1 is a pointer since i'm going to delete it in order to test if + // parsers after copy construction still refer to members of it. + // !! If this is the case this function will crash !! + + p1.reset ( new qmu::QmuParser() ); + // Add constants + p1->DefineConst ( "pi", ( qreal ) M_PI ); + p1->DefineConst ( "e", ( qreal ) M_E ); + p1->DefineConst ( "const", 1 ); + p1->DefineConst ( "const1", 2 ); + p1->DefineConst ( "const2", 3 ); + // variables + qreal vVarVal[] = { 1, 2, 3, -2}; + p1->DefineVar ( "a", &vVarVal[0] ); + p1->DefineVar ( "aa", &vVarVal[1] ); + p1->DefineVar ( "b", &vVarVal[1] ); + p1->DefineVar ( "c", &vVarVal[2] ); + p1->DefineVar ( "d", &vVarVal[3] ); + + // custom value ident functions + p1->AddValIdent ( &QmuParserTester::IsHexVal ); + + // functions + p1->DefineFun ( "ping", Ping ); + p1->DefineFun ( "f1of1", f1of1 ); // one parameter + p1->DefineFun ( "f1of2", f1of2 ); // two parameter + p1->DefineFun ( "f2of2", f2of2 ); + p1->DefineFun ( "f1of3", f1of3 ); // three parameter + p1->DefineFun ( "f2of3", f2of3 ); + p1->DefineFun ( "f3of3", f3of3 ); + p1->DefineFun ( "f1of4", f1of4 ); // four parameter + p1->DefineFun ( "f2of4", f2of4 ); + p1->DefineFun ( "f3of4", f3of4 ); + p1->DefineFun ( "f4of4", f4of4 ); + p1->DefineFun ( "f1of5", f1of5 ); // five parameter + p1->DefineFun ( "f2of5", f2of5 ); + p1->DefineFun ( "f3of5", f3of5 ); + p1->DefineFun ( "f4of5", f4of5 ); + p1->DefineFun ( "f5of5", f5of5 ); + + // binary operators + p1->DefineOprt ( "add", add, 0 ); + p1->DefineOprt ( "++", add, 0 ); + p1->DefineOprt ( "&", land, prLAND ); + + // sample functions + p1->DefineFun ( "min", Min ); + p1->DefineFun ( "max", Max ); + p1->DefineFun ( "sum", Sum ); + p1->DefineFun ( "valueof", ValueOf ); + p1->DefineFun ( "atof", StrToFloat ); + p1->DefineFun ( "strfun1", StrFun1 ); + p1->DefineFun ( "strfun2", StrFun2 ); + p1->DefineFun ( "strfun3", StrFun3 ); + p1->DefineFun ( "lastArg", LastArg ); + p1->DefineFun ( "firstArg", FirstArg ); + p1->DefineFun ( "order", FirstArg ); + + // infix / postfix operator + // Note: Identifiers used here do not have any meaning + // they are mere placeholders to test certain features. + p1->DefineInfixOprt ( "$", sign, prPOW + 1 ); // sign with high priority + p1->DefineInfixOprt ( "~", plus2 ); // high priority + p1->DefineInfixOprt ( "~~", plus2 ); + p1->DefinePostfixOprt ( "{m}", Milli ); + p1->DefinePostfixOprt ( "{M}", Mega ); + p1->DefinePostfixOprt ( "m", Milli ); + p1->DefinePostfixOprt ( "meg", Mega ); + p1->DefinePostfixOprt ( "#", times3 ); + p1->DefinePostfixOprt ( "'", sqr ); + p1->SetExpr ( a_str ); + + // Test bytecode integrity + // String parsing and bytecode parsing must yield the same result + fVal[0] = p1->Eval(); // result from stringparsing + fVal[1] = p1->Eval(); // result from bytecode + if ( qFuzzyCompare( fVal[0], fVal[1] ) == false ) + { + throw QmuParserError ( "Bytecode / string parsing mismatch." ); + } + + // Test copy and assignement operators + try + { + // Test copy constructor + QVector vParser; + vParser.push_back ( * ( p1.get() ) ); + qmu::QmuParser p2 = vParser[0]; // take parser from vector + + // destroy the originals from p2 + vParser.clear(); // delete the vector + p1.reset ( 0 ); + + fVal[2] = p2.Eval(); + + // Test assignement operator + // additionally disable Optimizer this time + qmu::QmuParser p3; + p3 = p2; + p3.EnableOptimizer ( false ); + fVal[3] = p3.Eval(); + + // Test Eval function for multiple return values + // use p2 since it has the optimizer enabled! + int nNum; + qreal *v = p2.Eval ( nNum ); + fVal[4] = v[nNum - 1]; + } + catch ( std::exception &e ) + { + qWarning() << "\n " << e.what() << "\n"; + } + + // limited floating point accuracy requires the following test + bool bCloseEnough ( true ); + for ( unsigned i = 0; i < sizeof ( fVal ) / sizeof ( qreal ); ++i ) + { + bCloseEnough &= ( fabs ( a_fRes - fVal[i] ) <= fabs ( fVal[i] * 0.00001 ) ); + + // The tests equations never result in infinity, if they do thats a bug. + // reference: + // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/5037825 +#if defined(Q_CC_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if (std::numeric_limits::has_infinity) +#if defined(Q_CC_MSVC) +#pragma warning(pop) +#endif + { + bCloseEnough &= (qFuzzyCompare( fabs ( fVal[i] ), std::numeric_limits::infinity())==false ); + } + } + + iRet = ( ( bCloseEnough && a_fPass ) || ( bCloseEnough == false && a_fPass == false) ) ? 0 : 1; + + + if ( iRet == 1 ) + { + qWarning() << "\n fail: " << a_str + << " (incorrect result; expected: " << a_fRes + << " ;calculated: " << fVal[0] << "," + << fVal[1] << "," + << fVal[2] << "," + << fVal[3] << "," + << fVal[4] << ")."; + } + } + catch ( QmuParserError &e ) + { + if ( a_fPass ) + { + if ( (qFuzzyCompare(fVal[0], fVal[2])==false) && (qFuzzyCompare(fVal[0], -999)==false) && + (qFuzzyCompare(fVal[1], -998 )==false)) + { + qWarning() << "\n fail: " << a_str << " (copy construction)"; + } + else + { + qWarning() << "\n fail: " << a_str << " (" << e.GetMsg() << ")"; + } + return 1; + } + } + catch ( std::exception &e ) + { + qWarning() << "\n fail: " << a_str << " (" << e.what() << ")"; + return 1; // always return a failure since this exception is not expected + } + catch ( ... ) + { + qWarning() << "\n fail: " << a_str << " (unexpected exception)"; + return 1; // exceptions other than ParserException are not allowed + } + + return iRet; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Internal error in test class Test is going to be aborted. + */ +void Q_NORETURN QmuParserTester::Abort() +{ + qWarning() << "Test failed (internal error in test class)"; + while ( getchar() == false); + exit ( -1 ); +} +} // namespace test +} // namespace qmu diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h new file mode 100644 index 000000000..d2ae906ef --- /dev/null +++ b/src/libs/qmuparser/qmuparsertest.h @@ -0,0 +1,311 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERTEST_H +#define QMUPARSERTEST_H + +#include "qmuparser_global.h" +#include "qmuparser.h" +#include + +/** + * @file + * @brief This file contains the parser test class. + */ + +namespace qmu +{ +/** + * @brief Namespace for test cases. + */ +namespace Test +{ +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Test cases for unit testing. + * + * (C) 2004-2011 Ingo Berg + */ +class QMUPARSERSHARED_EXPORT QmuParserTester // final +{ +public: + typedef int ( QmuParserTester::*testfun_type ) (); + + QmuParserTester(); + void Run(); +private: + QVector m_vTestFun; + static int c_iCount; + + void AddTest ( testfun_type a_pFun ); + + // Test Double Parser + static int EqnTest ( const QString &a_str, double a_fRes, bool a_fPass ); + static int EqnTestWithVarChange ( const QString &a_str, double a_fRes1, double a_fVar1, double a_fRes2, + double a_fVar2 ); + static int ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail = true ); + + // Multiarg callbacks + static qreal f1of1 ( qreal v ) + { + return v; + } + + static qreal f1of2 ( qreal v, qreal ) + { + return v; + } + + static qreal f2of2 ( qreal, qreal v ) + { + return v; + } + + static qreal f1of3 ( qreal v, qreal, qreal ) + { + return v; + } + + static qreal f2of3 ( qreal, qreal v, qreal ) + { + return v; + } + + static qreal f3of3 ( qreal, qreal, qreal v ) + { + return v; + } + + static qreal f1of4 ( qreal v, qreal, qreal, qreal ) + { + return v; + } + + static qreal f2of4 ( qreal, qreal v, qreal, qreal ) + { + return v; + } + + static qreal f3of4 ( qreal, qreal, qreal v, qreal ) + { + return v; + } + + static qreal f4of4 ( qreal, qreal, qreal, qreal v ) + { + return v; + } + + static qreal f1of5 ( qreal v, qreal, qreal, qreal, qreal ) + { + return v; + } + + static qreal f2of5 ( qreal, qreal v, qreal, qreal, qreal ) + { + return v; + } + + static qreal f3of5 ( qreal, qreal, qreal v, qreal, qreal ) + { + return v; + } + + static qreal f4of5 ( qreal, qreal, qreal, qreal v, qreal ) + { + return v; + } + + static qreal f5of5 ( qreal, qreal, qreal, qreal, qreal v ) + { + return v; + } + + static qreal Min ( qreal a_fVal1, qreal a_fVal2 ) + { + return ( a_fVal1 < a_fVal2 ) ? a_fVal1 : a_fVal2; + } + + static qreal Max ( qreal a_fVal1, qreal a_fVal2 ) + { + return ( a_fVal1 > a_fVal2 ) ? a_fVal1 : a_fVal2; + } + + static qreal plus2 ( qreal v1 ) + { + return v1 + 2; + } + + static qreal times3 ( qreal v1 ) + { + return v1 * 3; + } + + static qreal sqr ( qreal v1 ) + { + return v1 * v1; + } + + static qreal sign ( qreal v ) + { + return -v; + } + + static qreal add ( qreal v1, qreal v2 ) + { + return v1 + v2; + } + + static qreal land ( qreal v1, qreal v2 ) + { + return static_cast( v1 ) & static_cast( v2 ); + } + + static qreal FirstArg ( const qreal* a_afArg, int a_iArgc ) + { + if ( a_iArgc == false) + { + throw QmuParserError ( "too few arguments for function FirstArg." ); + } + + return a_afArg[0]; + } + + static qreal LastArg ( const qreal* a_afArg, int a_iArgc ) + { + if ( a_iArgc == false) + { + throw QmuParserError ( "too few arguments for function LastArg." ); + } + + return a_afArg[a_iArgc - 1]; + } + + static qreal Sum ( const qreal* a_afArg, int a_iArgc ) + { + if ( a_iArgc == false) + { + throw QmuParserError ( "too few arguments for function sum." ); + } + + qreal fRes = 0; + for ( int i = 0; i < a_iArgc; ++i ) + { + fRes += a_afArg[i]; + } + return fRes; + } + + static qreal Rnd ( qreal v ) + { + return static_cast( ( 1 + ( v * qrand() / ( RAND_MAX + 1.0 ) ) ) ); + } + + static qreal RndWithString ( const char_type* ) + { + return static_cast( ( 1 + ( 1000.0f * static_cast(qrand()) / ( RAND_MAX + 1.0 ) ) ) ); + } + + static qreal Ping() + { + return 10; + } + + static qreal ValueOf ( const QString & ) + { + return 123; + } + + static qreal StrFun1 ( const QString & v1 ) + { + int val = v1.toInt(); + return static_cast(val); + } + + static qreal StrFun2 ( const QString & v1, qreal v2 ) + { + int val = v1.toInt(); + return static_cast( val + v2 ); + } + + static qreal StrFun3 ( const QString & v1, qreal v2, qreal v3 ) + { + int val = v1.toInt(); + return val + v2 + v3; + } + + static qreal StrToFloat ( const QString & a_szMsg ) + { + qreal val = a_szMsg.toDouble(); + return val; + } + + // postfix operator callback + static qreal Mega ( qreal a_fVal ) + { + return a_fVal * static_cast( 1e6 ); + } + + static qreal Micro ( qreal a_fVal ) + { + return a_fVal * static_cast( 1e-6 ); + } + + static qreal Milli ( qreal a_fVal ) + { + return a_fVal / static_cast( 1e3 ); + } + + // Custom value recognition + static int IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal ); + + // cppcheck-suppress functionStatic + int TestNames(); + // cppcheck-suppress functionStatic + int TestSyntax(); + // cppcheck-suppress functionStatic + int TestMultiArg(); + // cppcheck-suppress functionStatic + int TestPostFix(); + // cppcheck-suppress functionStatic + int TestExpression(); + // cppcheck-suppress functionStatic + int TestInfixOprt(); + // cppcheck-suppress functionStatic + int TestBinOprt(); + // cppcheck-suppress functionStatic + int TestVarConst(); + // cppcheck-suppress functionStatic + int TestInterface(); + // cppcheck-suppress functionStatic + int TestException(); + // cppcheck-suppress functionStatic + int TestStrArg(); + // cppcheck-suppress functionStatic + int TestIfThenElse(); + + static void Q_NORETURN Abort(); +}; +} // namespace Test +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmuparsertoken.h b/src/libs/qmuparser/qmuparsertoken.h new file mode 100644 index 000000000..8db39d292 --- /dev/null +++ b/src/libs/qmuparser/qmuparsertoken.h @@ -0,0 +1,482 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERTOKEN_H +#define QMUPARSERTOKEN_H + +#include +#include +#include +#include +#include + +#include "qmuparsererror.h" +#include "qmuparsercallback.h" + +/** @file + @brief This file contains the parser token definition. +*/ + +namespace qmu +{ +/** + * @brief Encapsulation of the data for a single formula token. + * + * Formula token implementation. Part of the Math Parser Package. + * Formula tokens can be either one of the following: + *
    + *
  • value
  • + *
  • variable
  • + *
  • function with numerical arguments
  • + *
  • functions with a string as argument
  • + *
  • prefix operators
  • + *
  • infix operators
  • + *
  • binary operator
  • + *
+ * + * @author (C) 2004-2013 Ingo Berg + */ +template +class QmuParserToken +{ +public: + //--------------------------------------------------------------------------- + /** + * @brief Constructor (default). + * + * Sets token to an neutral state of type cmUNKNOWN. + * @throw nothrow + * @sa ECmdCode + */ + QmuParserToken() + : m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( 0 ), m_iIdx ( -1 ), m_strTok(), m_strVal(), m_fVal(), + m_pCallback() + {} + + //------------------------------------------------------------------------------ + /** + * @brief Create token from another one. + * + * Implemented by calling Assign(...) + * @throw nothrow + * @post m_iType==cmUNKNOWN + * @sa #Assign + */ + QmuParserToken ( const QmuParserToken &a_Tok ) + : m_iCode ( a_Tok.m_iCode ), m_iType ( a_Tok.m_iType ), m_pTok ( a_Tok.m_pTok ), m_iIdx ( a_Tok.m_iIdx ), + m_strTok( a_Tok.m_strTok ), m_strVal(a_Tok.m_strVal), m_fVal(a_Tok.m_fVal), m_pCallback() + { + Assign ( a_Tok ); + } + + //------------------------------------------------------------------------------ + /** + * @brief Assignement operator. + * + * Copy token state from another token and return this. + * Implemented by calling Assign(...). + * @throw nothrow + */ + QmuParserToken& operator= ( const QmuParserToken &a_Tok ) + { + if ( &a_Tok == this ) + { + return *this; + } + Assign ( a_Tok ); + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief Copy token information from argument. + * + * @throw nothrow + */ + void Assign ( const QmuParserToken &a_Tok ) + { + m_iCode = a_Tok.m_iCode; + m_pTok = a_Tok.m_pTok; + m_strTok = a_Tok.m_strTok; + m_iIdx = a_Tok.m_iIdx; + m_strVal = a_Tok.m_strVal; + m_iType = a_Tok.m_iType; + m_fVal = a_Tok.m_fVal; + // create new callback object if a_Tok has one + m_pCallback.reset ( a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0 ); + } + + //------------------------------------------------------------------------------ + /** + * @brief Assign a token type. + * + * Token may not be of type value, variable or function. Those have seperate set functions. + * + * @pre [assert] a_iType!=cmVAR + * @pre [assert] a_iType!=cmVAL + * @pre [assert] a_iType!=cmFUNC + * @post m_fVal = 0 + * @post m_pTok = 0 + */ + QmuParserToken& Set ( ECmdCode a_iType, const TString &a_strTok = TString() ) + { + // The following types cant be set this way, they have special Set functions + assert ( a_iType != cmVAR ); + assert ( a_iType != cmVAL ); + assert ( a_iType != cmFUNC ); + + m_iCode = a_iType; + m_iType = tpVOID; + m_pTok = 0; + m_strTok = a_strTok; + m_iIdx = -1; + + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief Set Callback type. + */ + QmuParserToken& Set ( const QmuParserCallback &a_pCallback, const TString &a_sTok ) + { + assert ( a_pCallback.GetAddr() ); + + m_iCode = a_pCallback.GetCode(); + m_iType = tpVOID; + m_strTok = a_sTok; + m_pCallback.reset ( new QmuParserCallback ( a_pCallback ) ); + + m_pTok = 0; + m_iIdx = -1; + + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief Make this token a value token. + * + * Member variables not necessary for value tokens will be invalidated. + * @throw nothrow + */ + QmuParserToken& SetVal ( TBase a_fVal, const TString &a_strTok = TString() ) + { + m_iCode = cmVAL; + m_iType = tpDBL; + m_fVal = a_fVal; + m_strTok = a_strTok; + m_iIdx = -1; + + m_pTok = 0; + m_pCallback.reset ( 0 ); + + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief make this token a variable token. + * + * Member variables not necessary for variable tokens will be invalidated. + * @throw nothrow + */ + QmuParserToken& SetVar ( TBase *a_pVar, const TString &a_strTok ) + { + m_iCode = cmVAR; + m_iType = tpDBL; + m_strTok = a_strTok; + m_iIdx = -1; + m_pTok = reinterpret_cast ( a_pVar ); + m_pCallback.reset ( 0 ); + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief Make this token a variable token. + * + * Member variables not necessary for variable tokens will be invalidated. + * @throw nothrow + */ + QmuParserToken& SetString ( const TString &a_strTok, int a_iSize ) + { + m_iCode = cmSTRING; + m_iType = tpSTR; + m_strTok = a_strTok; + m_iIdx = a_iSize; + + m_pTok = 0; + m_pCallback.reset ( 0 ); + return *this; + } + + //------------------------------------------------------------------------------ + /** + * @brief Set an index associated with the token related data. + * + * In cmSTRFUNC - This is the index to a string table in the main parser. + * @param a_iIdx The index the string function result will take in the bytecode parser. + * @throw QmuParserError if #a_iIdx<0 or #m_iType!=cmSTRING + */ + void SetIdx ( int a_iIdx ) + { + if ( m_iCode != cmSTRING || a_iIdx < 0 ) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + m_iIdx = a_iIdx; + } + + //------------------------------------------------------------------------------ + /** + * @brief Return Index associated with the token related data. + * + * In cmSTRFUNC - This is the index to a string table in the main parser. + * + * @throw QmuParserError if #m_iIdx<0 or #m_iType!=cmSTRING + * @return The index the result will take in the Bytecode calculatin array (#m_iIdx). + */ + int GetIdx() const + { + if ( m_iIdx < 0 || m_iCode != cmSTRING ) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + return m_iIdx; + } + + //------------------------------------------------------------------------------ + /** + * @brief Return the token type. + * + * @return #m_iType + * @throw nothrow + */ + ECmdCode GetCode() const + { + if ( m_pCallback.get() ) + { + return m_pCallback->GetCode(); + } + else + { + return m_iCode; + } + } + + //------------------------------------------------------------------------------ + ETypeCode GetType() const + { + if ( m_pCallback.get() ) + { + return m_pCallback->GetType(); + } + else + { + return m_iType; + } + } + + //------------------------------------------------------------------------------ + int GetPri() const + { + if ( m_pCallback.get() == nullptr) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + if ( m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX ) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + return m_pCallback->GetPri(); + } + + //------------------------------------------------------------------------------ + EOprtAssociativity GetAssociativity() const + { + if ( m_pCallback.get() == nullptr || m_pCallback->GetCode() != cmOPRT_BIN ) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + return m_pCallback->GetAssociativity(); + } + + //------------------------------------------------------------------------------ + template < class FunctionPtr > + static FunctionPtr union_cast( void* objectPtr ) + { + union + { + void* obj; + FunctionPtr func; + } var; + + Q_STATIC_ASSERT_X(sizeof(void *) == sizeof(void (*)(void)), + "object pointer and function pointer sizes must equal"); + + var.obj = objectPtr; + return var.func; + } + + //------------------------------------------------------------------------------ + /** + * @brief Return the address of the callback function assoziated with function and operator tokens. + * + * @return The pointer stored in #m_pTok. + * @throw QmuParserError if token type is non of: + *
    + *
  • cmFUNC
  • + *
  • cmSTRFUNC
  • + *
  • cmPOSTOP
  • + *
  • cmINFIXOP
  • + *
  • cmOPRT_BIN
  • + *
+ * @sa ECmdCode + */ + generic_fun_type GetFuncAddr() const + { + return ( union_cast( m_pCallback.get() ) ) ? + union_cast( m_pCallback->GetAddr() ) : union_cast(0); + } + + //------------------------------------------------------------------------------ + /** + * @brief Get value of the token. + * + * Only applicable to variable and value tokens. + * @throw QmuParserError if token is no value/variable token. + */ + TBase GetVal() const + { + switch ( m_iCode ) + { + case cmVAL: + return m_fVal; + case cmVAR: + return * ( reinterpret_cast(m_pTok) ); + case cmLE: + case cmGE: + case cmNEQ: + case cmEQ: + case cmLT: + case cmGT: + case cmADD: + case cmSUB: + case cmMUL: + case cmDIV: + case cmPOW: + case cmLAND: + case cmLOR: + case cmASSIGN: + case cmBO: + case cmBC: + case cmIF: + case cmELSE: + case cmENDIF: + case cmARG_SEP: + case cmVARPOW2: + case cmVARPOW3: + case cmVARPOW4: + case cmVARMUL: + case cmPOW2: + case cmFUNC: + case cmFUNC_STR: + case cmFUNC_BULK: + case cmOPRT_BIN: + case cmOPRT_POSTFIX: + case cmOPRT_INFIX: + case cmEND: + case cmUNKNOWN: + case cmSTRING: + default: + throw QmuParserError ( ecVAL_EXPECTED ); + } + } + + //------------------------------------------------------------------------------ + /** + * @brief Get address of a variable token. + * + * Valid only if m_iType==CmdVar. + * @throw QmuParserError if token is no variable token. + */ + TBase* GetVar() const + { + if ( m_iCode != cmVAR ) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + return reinterpret_cast( m_pTok ); + } + + //------------------------------------------------------------------------------ + /** + * @brief Return the number of function arguments. + * + * Valid only if m_iType==CmdFUNC. + */ + int GetArgCount() const + { + assert ( m_pCallback.get() ); + + if ( m_pCallback->GetAddr() == nullptr) + { + throw QmuParserError ( ecINTERNAL_ERROR ); + } + + return m_pCallback->GetArgc(); + } + + //------------------------------------------------------------------------------ + /** + * @brief Return the token identifier. + * + * If #m_iType is cmSTRING the token identifier is the value of the string argument + * for a string function. + * @return #m_strTok + * @throw nothrow + * @sa m_strTok + */ + const TString& GetAsString() const + { + return m_strTok; + } +private: + ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. + ETypeCode m_iType; + void *m_pTok; ///< Stores Token pointer; not applicable for all tokens + int m_iIdx; ///< An otional index to an external buffer storing the token data + TString m_strTok; ///< Token string + TString m_strVal; ///< Value for string variables + qreal m_fVal; ///< the value + std::unique_ptr m_pCallback; +}; +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp new file mode 100644 index 000000000..9475308cc --- /dev/null +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -0,0 +1,1025 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmuparsertokenreader.h" +#include "qmuparserbase.h" +#include +#include + +/** + * @file + * @brief This file contains the parser token reader implementation. + */ + +namespace qmu +{ + +// Forward declaration +class QmuParserBase; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Copy constructor. + * + * @sa Assign + * @throw nothrow + */ +QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reader ) + :m_pParser( a_Reader.m_pParser ), m_strFormula( a_Reader.m_strFormula ), m_iPos( a_Reader.m_iPos ), + m_iSynFlags( a_Reader.m_iSynFlags ), m_bIgnoreUndefVar( a_Reader.m_bIgnoreUndefVar ), + m_pFunDef( a_Reader.m_pFunDef ), m_pPostOprtDef( a_Reader.m_pPostOprtDef ), + m_pInfixOprtDef( a_Reader.m_pInfixOprtDef ), m_pOprtDef( a_Reader.m_pOprtDef), + m_pConstDef( a_Reader.m_pConstDef ), m_pStrVarDef( a_Reader.m_pStrVarDef ), m_pVarDef( a_Reader.m_pVarDef ), + m_pFactory( a_Reader.m_pFactory ), m_pFactoryData( a_Reader.m_pFactoryData ), m_vIdentFun( a_Reader.m_vIdentFun ), + m_UsedVar( a_Reader.m_UsedVar ), m_fZero(0), m_iBrackets( a_Reader.m_iBrackets ), m_lastTok(), + m_cArgSep( a_Reader.m_cArgSep ) +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Assignement operator. + * + * Self assignement will be suppressed otherwise #Assign is called. + * + * @param a_Reader Object to copy to this token reader. + * @throw nothrow + */ +QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) +{ + if ( &a_Reader != this ) + { + Assign ( a_Reader ); + } + + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Assign state of a token reader to this token reader. + * + * @param a_Reader Object from which the state should be copied. + * @throw nothrow + */ +void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader ) +{ + m_pParser = a_Reader.m_pParser; + m_strFormula = a_Reader.m_strFormula; + m_iPos = a_Reader.m_iPos; + m_iSynFlags = a_Reader.m_iSynFlags; + + m_UsedVar = a_Reader.m_UsedVar; + m_pFunDef = a_Reader.m_pFunDef; + m_pConstDef = a_Reader.m_pConstDef; + m_pVarDef = a_Reader.m_pVarDef; + m_pStrVarDef = a_Reader.m_pStrVarDef; + m_pPostOprtDef = a_Reader.m_pPostOprtDef; + m_pInfixOprtDef = a_Reader.m_pInfixOprtDef; + m_pOprtDef = a_Reader.m_pOprtDef; + m_bIgnoreUndefVar = a_Reader.m_bIgnoreUndefVar; + m_vIdentFun = a_Reader.m_vIdentFun; + m_pFactory = a_Reader.m_pFactory; + m_pFactoryData = a_Reader.m_pFactoryData; + m_iBrackets = a_Reader.m_iBrackets; + m_cArgSep = a_Reader.m_cArgSep; + + m_fZero = 0; + m_lastTok = token_type(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Constructor. + * + * Create a Token reader and bind it to a parser object. + * + * @pre [assert] a_pParser may not be NULL + * @post #m_pParser==a_pParser + * @param a_pParent Parent parser object of the token reader. + */ +QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent ) + : m_pParser ( a_pParent ), m_strFormula(), m_iPos ( 0 ), m_iSynFlags ( 0 ), m_bIgnoreUndefVar ( false ), + m_pFunDef ( nullptr ), m_pPostOprtDef ( nullptr ), m_pInfixOprtDef ( nullptr ), m_pOprtDef ( nullptr ), + m_pConstDef ( nullptr ), m_pStrVarDef ( nullptr ), m_pVarDef ( nullptr ), m_pFactory ( nullptr ), + m_pFactoryData ( nullptr ), m_vIdentFun(), m_UsedVar(), m_fZero ( 0 ), m_iBrackets ( 0 ), m_lastTok(), + m_cArgSep ( ',' ) +{ + assert ( m_pParser ); + SetParent ( m_pParser ); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create instance of a QParserTokenReader identical with this and return its pointer. + * + * This is a factory method the calling function must take care of the object destruction. + * + * @return A new QParserTokenReader object. + * @throw nothrow + */ +QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const +{ + std::unique_ptr ptr ( new QmuParserTokenReader ( *this ) ); + ptr->SetParent ( a_pParent ); + return ptr.release(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) +{ + m_lastTok = tok; + return m_lastTok; +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback ) +{ + // Use push_front is used to give user defined callbacks a higher priority than + // the built in ones. Otherwise reading hex numbers would not work + // since the "0" in "0xff" would always be read first making parsing of + // the rest impossible. + // reference: + // http://sourceforge.net/projects/muparser/forums/forum/462843/topic/4824956 + m_vIdentFun.push_front ( a_pCallback ); +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData ) +{ + m_pFactory = a_pFactory; + m_pFactoryData = pUserData; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Initialize the token Reader. + * + * Sets the formula position index to zero and set Syntax flags to default for initial formula parsing. + * @pre [assert] triggered if a_szFormula==0 + */ +void QmuParserTokenReader::SetFormula ( const QString &a_strFormula ) +{ + m_strFormula = a_strFormula; + ReInit(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Reset the token reader to the start of the formula. + * + * The syntax flags will be reset to a value appropriate for the start of a formula. + * @post #m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR + * @throw nothrow + * @sa ESynCodes + */ +void QmuParserTokenReader::ReInit() +{ + m_iPos = 0; + m_iSynFlags = sfSTART_OF_LINE; + m_iBrackets = 0; + m_UsedVar.clear(); + m_lastTok = token_type(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Read the next token from the string. + */ +QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken() +{ + assert ( m_pParser ); + + token_type tok; + + // Ignore all non printable characters when reading the expression + while ( m_strFormula.data()[m_iPos] > 0 && m_strFormula.data()[m_iPos] <= 0x20 ) + { + ++m_iPos; + } + + if ( IsEOF ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for end of formula + } + if ( IsOprt ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for user defined binary operator + } + if ( IsFunTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for function token + } + if ( IsBuiltIn ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check built in operators / tokens + } + if ( IsArgSep ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for function argument separators + } + if ( IsValTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for values / constant tokens + } + if ( IsVarTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for variable tokens + } + if ( IsStrVarTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for string variables + } + if ( IsString ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for String tokens + } + if ( IsInfixOpTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for unary operators + } + if ( IsPostOpTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); // Check for unary operators + } + + // Check String for undefined variable token. Done only if a + // flag is set indicating to ignore undefined variables. + // This is a way to conditionally avoid an error if + // undefined variables occur. + // (The GetUsedVar function must suppress the error for + // undefined variables in order to collect all variable + // names including the undefined ones.) + if ( ( m_bIgnoreUndefVar || m_pFactory ) && IsUndefVarTok ( tok ) ) + { + return SaveBeforeReturn ( tok ); + } + + // Check for unknown token + // + // !!! From this point on there is no exit without an exception possible... + // + QString strTok; + int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + if ( iEnd != m_iPos ) + { + Error ( ecUNASSIGNABLE_TOKEN, m_iPos, strTok ); + } + + Error ( ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.mid ( m_iPos ) ); + return token_type(); // never reached +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) +{ + m_pParser = a_pParent; + m_pFunDef = &a_pParent->m_FunDef; + m_pOprtDef = &a_pParent->m_OprtDef; + m_pInfixOprtDef = &a_pParent->m_InfixOprtDef; + m_pPostOprtDef = &a_pParent->m_PostOprtDef; + m_pVarDef = &a_pParent->m_VarDef; + m_pStrVarDef = &a_pParent->m_StrVarDef; + m_pConstDef = &a_pParent->m_ConstDef; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Extract all characters that belong to a certain charset. + * + * @param a_szCharSet [in] Const char array of the characters allowed in the token. + * @param a_sTok [out] The string that consists entirely of characters listed in a_szCharSet. + * @param a_iPos [in] Position in the string from where to start reading. + * @return The Position of the first character not listed in a_szCharSet. + * @throw nothrow + */ +int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const +{ + const std::wstring m_strFormulaStd = m_strFormula.toStdWString(); + const std::wstring a_szCharSetStd = a_szCharSet.toStdWString(); + + int iEnd = static_cast(m_strFormulaStd.find_first_not_of ( a_szCharSetStd, static_cast(a_iPos) )); + + if ( iEnd == static_cast(string_type::npos) ) + { + iEnd = static_cast(m_strFormulaStd.length()); + } + + // Assign token string if there was something found + if ( a_iPos != iEnd ) + { + a_sTok = QString().fromStdWString ( std::wstring ( m_strFormulaStd.begin() + a_iPos, + m_strFormulaStd.begin() + iEnd ) ); + } + + return iEnd; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check Expression for the presence of a binary operator token. + * + * Userdefined binary operator "++" gives inconsistent parsing result for the equations "a++b" and "a ++ b" if + * alphabetic characters are allowed in operator tokens. To avoid this this function checks specifically + * for operator tokens. + */ +int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) const +{ + const std::wstring m_strFormulaStd = m_strFormula.toStdWString(); + const std::wstring oprtCharsStd = m_pParser->ValidInfixOprtChars().toStdWString(); + + int iEnd = static_cast( m_strFormulaStd.find_first_not_of ( oprtCharsStd, static_cast(a_iPos) ) ); + if ( iEnd == static_cast( string_type::npos ) ) + { + iEnd = static_cast( m_strFormulaStd.length() ); + } + + // Assign token string if there was something found + if ( a_iPos != iEnd ) + { + a_sTok = QString().fromStdWString ( string_type ( m_strFormulaStd.begin() + a_iPos, + m_strFormulaStd.begin() + iEnd ) ); + return iEnd; + } + else + { + // There is still the chance of having to deal with an operator consisting exclusively + // of alphabetic characters. + return ExtractToken ( QMUP_CHARS, a_sTok, a_iPos ); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a built in operator or other token can be found + * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. + * @return true if an operator token has been found. + */ +bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) +{ + const QStringList pOprtDef = m_pParser->GetOprtDef(); + + // Compare token with function and operator strings + // check string for operator/function + for ( int i = 0; i < pOprtDef.size(); ++i ) + { + int len = pOprtDef.at ( i ).length(); + if ( pOprtDef.at ( i ) == m_strFormula.mid ( m_iPos, len ) ) + { + if (i >= cmLE && i <= cmASSIGN) + { + //if (len!=sTok.length()) + // continue; + + // The assignement operator need special treatment + if ( i == cmASSIGN && m_iSynFlags & noASSIGN ) + { + Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); + } + + if ( m_pParser->HasBuiltInOprt() == false) + { + continue; + } + if ( m_iSynFlags & noOPT ) + { + // Maybe its an infix operator not an operator + // Both operator types can share characters in + // their identifiers + if ( IsInfixOpTok ( a_Tok ) ) + { + return true; + } + + Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); + } + + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + m_iSynFlags |= noEND ; + } + else if (i == cmBO) + { + if ( m_iSynFlags & noBO ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } + + if ( m_lastTok.GetCode() == cmFUNC ) + { + m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + } + else + { + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + } + + ++m_iBrackets; + } + else if (i == cmBC) + { + if ( m_iSynFlags & noBC ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } + + m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; + + if ( --m_iBrackets < 0 ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } + } + else if (i == cmELSE) + { + if ( m_iSynFlags & noELSE ) + { + Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); + } + + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; + } + else if (i == cmIF) + { + if ( m_iSynFlags & noIF ) + { + Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); + } + + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; + } + else // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... + { + Error ( ecINTERNAL_ERROR ); + } + + m_iPos += len; + a_Tok.Set ( static_cast(i), pOprtDef.at ( i ) ); + return true; + } // if operator string found + } // end of for all operator strings + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) +{ + if ( m_strFormula.at ( m_iPos ) == m_cArgSep ) + { + // copy the separator into null terminated string + QString szSep; + szSep[0] = m_cArgSep; + szSep[1] = 0; + + if ( m_iSynFlags & noARG_SEP ) + { + Error ( ecUNEXPECTED_ARG_SEP, m_iPos, szSep ); + } + + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN; + m_iPos++; + a_Tok.Set ( cmARG_SEP, szSep ); + return true; + } + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check for End of Formula. + * + * @return true if an end of formula is found false otherwise. + * @param a_Tok [out] If an eof is found the corresponding token will be stored there. + * @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok + */ +bool QmuParserTokenReader::IsEOF ( token_type &a_Tok ) +{ + // check for EOF + if ( m_strFormula.data()[m_iPos] == false /*|| szFormula[m_iPos] == '\n'*/ ) + { + if ( m_iSynFlags & noEND ) + { + try + { + Error ( ecUNEXPECTED_EOF, m_iPos ); + } + catch (qmu::QmuParserError &e) + { + qDebug() << " Code:" << e.GetCode() << "(" << e.GetMsg() << ")"; + throw; + } + } + + if ( m_iBrackets > 0 ) + { + Error ( ecMISSING_PARENS, m_iPos, ")" ); + } + + m_iSynFlags = 0; + a_Tok.Set ( cmEND ); + return true; + } + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a string position contains a unary infix operator. + * @return true if a function token has been found false otherwise. + */ +bool QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) +{ + QString sTok; + int iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + // iteraterate over all postfix operator strings + auto it = m_pInfixOprtDef->rbegin(); + for ( ; it != m_pInfixOprtDef->rend(); ++it ) + { + if ( sTok.indexOf ( it->first ) != 0 ) + { + continue; + } + + a_Tok.Set ( it->second, it->first ); + m_iPos += static_cast(it->first.length()); + + if ( m_iSynFlags & noINFIXOP ) + { + Error ( ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString() ); + } + + m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; + return true; + } + + return false; + + /* + a_Tok.Set(item->second, sTok); + m_iPos = (int)iEnd; + + if (m_iSynFlags & noINFIXOP) + Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + + m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; + return true; + */ +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check whether the token at a given position is a function token. + * @param a_Tok [out] If a value token is found it will be placed here. + * @throw ParserException if Syntaxflags do not allow a function at a_iPos + * @return true if a function token has been found false otherwise. + * @pre [assert] m_pParser!=0 + */ +bool QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) +{ + QString strTok; + int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + funmap_type::const_iterator item = m_pFunDef->find ( strTok ); + if ( item == m_pFunDef->end() ) + { + return false; + } + + // Check if the next sign is an opening bracket + if ( m_strFormula.at ( iEnd ) != '(' ) + { + return false; + } + + a_Tok.Set ( item->second, strTok ); + + m_iPos = iEnd; + if ( m_iSynFlags & noFUN ) + { + Error ( ecUNEXPECTED_FUN, m_iPos - static_cast(a_Tok.GetAsString().length()), a_Tok.GetAsString() ); + } + + m_iSynFlags = noANY ^ noBO; + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a string position contains a binary operator. + * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. + * @return true if an operator token has been found. + */ +bool QmuParserTokenReader::IsOprt ( token_type &a_Tok ) +{ + QString strTok; + + int iEnd = ExtractOperatorToken ( strTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + // Check if the operator is a built in operator, if so ignore it here + const QStringList pOprtDef = m_pParser->GetOprtDef(); + QStringList::const_iterator constIterator; + for ( constIterator = pOprtDef.constBegin(); m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd(); + ++constIterator ) + { + if ( ( *constIterator ) == strTok ) + { + return false; + } + } + + // Note: + // All tokens in oprt_bin_maptype are have been sorted by their length + // Long operators must come first! Otherwise short names (like: "add") that + // are part of long token names (like: "add123") will be found instead + // of the long ones. + // Length sorting is done with ascending length so we use a reverse iterator here. + auto it = m_pOprtDef->rbegin(); + for ( ; it != m_pOprtDef->rend(); ++it ) + { + const QString &sID = it->first; + if ( sID == m_strFormula.mid ( m_iPos, sID.length() ) ) + { + a_Tok.Set ( it->second, strTok ); + + // operator was found + if ( m_iSynFlags & noOPT ) + { + // An operator was found but is not expected to occur at + // this position of the formula, maybe it is an infix + // operator, not a binary operator. Both operator types + // can share characters in their identifiers. + if ( IsInfixOpTok ( a_Tok ) ) + { + return true; + } + else + { + // nope, no infix operator + return false; + //Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString()); + } + + } + + m_iPos += sID.length(); + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noASSIGN; + return true; + } + } + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check if a string position contains a unary post value operator. + */ +bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) +{ + // Do not check for postfix operators if they are not allowed at + // the current expression index. + // + // This will fix the bug reported here: + // + // http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979 + // + if ( m_iSynFlags & noPOSTOP ) + { + return false; + } + // + + // Tricky problem with equations like "3m+5": + // m is a postfix operator, + is a valid sign for postfix operators and + // for binary operators parser detects "m+" as operator string and + // finds no matching postfix operator. + // + // This is a special case so this routine slightly differs from the other + // token readers. + + // Test if there could be a postfix operator + QString sTok; + int iEnd = ExtractToken ( m_pParser->ValidOprtChars(), sTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + // iteraterate over all postfix operator strings + auto it = m_pPostOprtDef->rbegin(); + for ( ; it != m_pPostOprtDef->rend(); ++it ) + { + if ( sTok.indexOf ( it->first ) != 0 ) + { + continue; + } + + a_Tok.Set ( it->second, sTok ); + m_iPos += it->first.length(); + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noSTR | noASSIGN; + return true; + } + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check whether the token at a given position is a value token. + * + * Value tokens are either values or constants. + * + * @param a_Tok [out] If a value token is found it will be placed here. + * @return true if a value token has been found. + */ +bool QmuParserTokenReader::IsValTok ( token_type &a_Tok ) +{ + assert ( m_pConstDef ); + assert ( m_pParser ); + + QString strTok; + qreal fVal ( 0 ); + int iEnd ( 0 ); + + // 2.) Check for user defined constant + // Read everything that could be a constant name + iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + if ( iEnd != m_iPos ) + { + valmap_type::const_iterator item = m_pConstDef->find ( strTok ); + if ( item != m_pConstDef->end() ) + { + m_iPos = iEnd; + a_Tok.SetVal ( item->second, strTok ); + + if ( m_iSynFlags & noVAL ) + { + Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok ); + } + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + // 3.call the value recognition functions provided by the user + // Call user defined value recognition functions + std::list::const_iterator item = m_vIdentFun.begin(); + for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item ) + { + int iStart = m_iPos; + if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal ) == 1 ) + { + // 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2 + strTok = m_strFormula.mid ( iStart, m_iPos-iStart ); + if ( m_iSynFlags & noVAL ) + { + Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok ); + } + + a_Tok.SetVal ( fVal, strTok ); + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; + } + } + + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check wheter a token at a given position is a variable token. + * @param a_Tok [out] If a variable token has been found it will be placed here. + * @return true if a variable token has been found. + */ +bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) +{ + if ( m_pVarDef->empty()) + { + return false; + } + + QString strTok; + int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + varmap_type::const_iterator item = m_pVarDef->find ( strTok ); + if ( item == m_pVarDef->end() ) + { + return false; + } + + if ( m_iSynFlags & noVAR ) + { + Error ( ecUNEXPECTED_VAR, m_iPos, strTok ); + } + + m_pParser->OnDetectVar ( m_strFormula, m_iPos, iEnd ); + + m_iPos = iEnd; + a_Tok.SetVar ( item->second, strTok ); + m_UsedVar[item->first] = item->second; // Add variable to used-var-list + + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR; + +// Zur Info hier die SynFlags von IsVal(): +// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) +{ + if ( m_pStrVarDef == nullptr || m_pStrVarDef->empty() ) + { + return false; + } + + QString strTok; + int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); + if ( iEnd == m_iPos ) + { + return false; + } + + strmap_type::const_iterator item = m_pStrVarDef->find ( strTok ); + if ( item == m_pStrVarDef->end() ) + { + return false; + } + + if ( m_iSynFlags & noSTR ) + { + Error ( ecUNEXPECTED_VAR, m_iPos, strTok ); + } + + m_iPos = iEnd; + if ( m_pParser->m_vStringVarBuf.size() == false) + { + Error ( ecINTERNAL_ERROR ); + } + + a_Tok.SetString ( m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() ); + + m_iSynFlags = noANY ^ ( noBC | noOPT | noEND | noARG_SEP ); + return true; +} + + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check wheter a token at a given position is an undefined variable. + * + * @param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here. + * @return true if a variable token has been found. + * @throw nothrow + */ +bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) +{ + QString strTok; + int iEnd ( ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ) ); + if ( iEnd == m_iPos ) + { + return false; + } + + if ( m_iSynFlags & noVAR ) + { + // 20061021 added token string strTok instead of a_Tok.GetAsString() as the + // token identifier. + // related bug report: + // http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979 + Error ( ecUNEXPECTED_VAR, m_iPos - a_Tok.GetAsString().length(), strTok ); + } + + // If a factory is available implicitely create new variables + if ( m_pFactory ) + { + qreal *fVar = m_pFactory ( strTok, m_pFactoryData ); + a_Tok.SetVar ( fVar, strTok ); + + // Do not use m_pParser->DefineVar( strTok, fVar ); + // in order to define the new variable, it will clear the + // m_UsedVar array which will kill previousely defined variables + // from the list + // This is safe because the new variable can never override an existing one + // because they are checked first! + ( *m_pVarDef ) [strTok] = fVar; + m_UsedVar[strTok] = fVar; // Add variable to used-var-list + } + else + { + a_Tok.SetVar ( &m_fZero, strTok ); + m_UsedVar[strTok] = 0; // Add variable to used-var-list + } + + m_iPos = iEnd; + + // Call the variable factory in order to let it define a new parser variable + m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR; + return true; +} + + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Check wheter a token at a given position is a string. + * @param a_Tok [out] If a variable token has been found it will be placed here. + * @return true if a string token has been found. + * @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok + */ +bool QmuParserTokenReader::IsString ( token_type &a_Tok ) +{ + if ( m_strFormula[m_iPos] != '"' ) + { + return false; + } + + QString strBuf (m_strFormula.mid(m_iPos + 1)); + int iEnd ( 0 ), iSkip ( 0 ); + + // parser over escaped '\"' end replace them with '"' + for ( iEnd = strBuf.indexOf ( "\"" ); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf ( "\"", iEnd ) ) + { + if ( strBuf[iEnd - 1] != '\\' ) + { + break; + } + strBuf.replace ( iEnd - 1, 2, "\"" ); + iSkip++; + } + + if ( iEnd == -1 ) + { + Error ( ecUNTERMINATED_STRING, m_iPos, "\"" ); + } + + QString strTok = strBuf.mid ( 0, iEnd ); + + if ( m_iSynFlags & noSTR ) + { + Error ( ecUNEXPECTED_STR, m_iPos, strTok ); + } + + m_pParser->m_vStringBuf.push_back ( strTok ); // Store string in internal buffer + a_Tok.SetString ( strTok, m_pParser->m_vStringBuf.size() ); + + m_iPos += strTok.length() + 2 + iSkip; // +2 wg Anfhrungszeichen; +iSkip fr entfernte escape zeichen + m_iSynFlags = noANY ^ ( noARG_SEP | noBC | noOPT | noEND ); + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create an error containing the parse error position. + * + * This function will create an Parser Exception object containing the error text and its position. + * + * @param a_iErrc [in] The error code of type #EErrorCodes. + * @param a_iPos [in] The position where the error was detected. + * @param a_sTok [in] The token string representation associated with the error. + * @throw ParserException always throws thats the only purpose of this function. + */ +void Q_NORETURN QmuParserTokenReader::Error ( EErrorCodes a_iErrc, int a_iPos, const QString &a_sTok ) const +{ + m_pParser->Error ( a_iErrc, a_iPos, a_sTok ); +} +} // namespace qmu diff --git a/src/libs/qmuparser/qmuparsertokenreader.h b/src/libs/qmuparser/qmuparsertokenreader.h new file mode 100644 index 000000000..43d08106e --- /dev/null +++ b/src/libs/qmuparser/qmuparsertokenreader.h @@ -0,0 +1,198 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2013 Ingo Berg + ** Modified work Copyright 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUPARSERTOKENREADER_H +#define QMUPARSERTOKENREADER_H + +#include "qmuparserdef.h" +#include "qmuparsertoken.h" + +/** + * @file + * @brief This file contains the parser token reader definition. + */ + +namespace qmu +{ +// Forward declaration +class QmuParserBase; + +/** + * @brief Token reader for the ParserBase class. + * + */ +class QmuParserTokenReader +{ +private: + typedef QmuParserToken token_type; +public: + QmuParserTokenReader(QmuParserBase *a_pParent); + QmuParserTokenReader* Clone(QmuParserBase *a_pParent) const; + + void AddValIdent(identfun_type a_pCallback); + void SetVarCreator(facfun_type a_pFactory, void *pUserData); + void SetFormula(const QString &a_strFormula); + void SetArgSep(char_type cArgSep); + int GetPos() const; + const QString& GetExpr() const; + varmap_type& GetUsedVar(); + QChar GetArgSep() const; + void IgnoreUndefVar(bool bIgnore); + void ReInit(); + token_type ReadNextToken(); +private: + + /** + * @brief Syntax codes. + * + * The syntax codes control the syntax check done during the first time parsing of + * the expression string. They are flags that indicate which tokens are allowed next + * if certain tokens are identified. + */ + enum ESynCodes + { + noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" + noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" + noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" + noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" + noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... + noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" + noOPT = 1 << 6, ///< to avoid i.e. "(+)" + noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" + noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" + noEND = 1 << 9, ///< to avoid unexpected end of formula + noSTR = 1 << 10, ///< to block numeric arguments on string functions + noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7" + noIF = 1 << 12, + noELSE = 1 << 13, + sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, + noANY = ~0 ///< All of he above flags set + }; + + QmuParserTokenReader(const QmuParserTokenReader &a_Reader); + QmuParserTokenReader& operator=(const QmuParserTokenReader &a_Reader); + void Assign(const QmuParserTokenReader &a_Reader); + + void SetParent(QmuParserBase *a_pParent); + int ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const; + int ExtractOperatorToken(QString &a_sTok, int a_iPos) const; + + bool IsBuiltIn(token_type &a_Tok); + bool IsArgSep(token_type &a_Tok); + bool IsEOF(token_type &a_Tok); + bool IsInfixOpTok(token_type &a_Tok); + bool IsFunTok(token_type &a_Tok); + bool IsPostOpTok(token_type &a_Tok); + bool IsOprt(token_type &a_Tok); + bool IsValTok(token_type &a_Tok); + bool IsVarTok(token_type &a_Tok); + bool IsStrVarTok(token_type &a_Tok); + bool IsUndefVarTok(token_type &a_Tok); + bool IsString(token_type &a_Tok); + void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_sTok = QString() ) const; + + token_type& SaveBeforeReturn(const token_type &tok); + + QmuParserBase *m_pParser; + QString m_strFormula; + int m_iPos; + int m_iSynFlags; + bool m_bIgnoreUndefVar; + + const funmap_type *m_pFunDef; + const funmap_type *m_pPostOprtDef; + const funmap_type *m_pInfixOprtDef; + const funmap_type *m_pOprtDef; + const valmap_type *m_pConstDef; + const strmap_type *m_pStrVarDef; + varmap_type *m_pVarDef; ///< The only non const pointer to parser internals + facfun_type m_pFactory; + void *m_pFactoryData; + std::list m_vIdentFun; ///< Value token identification function + varmap_type m_UsedVar; + qreal m_fZero; ///< Dummy value of zero, referenced by undefined variables + int m_iBrackets; ///< Keep count open brackets + token_type m_lastTok; + QChar m_cArgSep; ///< The character used for separating function arguments +}; + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return the current position of the token reader in the formula string. + * + * @return #m_iPos + * @throw nothrow + */ +inline int QmuParserTokenReader::GetPos() const +{ + return m_iPos; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return a reference to the formula. + * + * @return #m_strFormula + * @throw nothrow + */ +inline const QString& QmuParserTokenReader::GetExpr() const +{ + return m_strFormula; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Return a map containing the used variables only. + */ +inline varmap_type& QmuParserTokenReader::GetUsedVar() +{ + return m_UsedVar; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set Flag that contronls behaviour in case of undefined variables beeing found. + * + * If true, the parser does not throw an exception if an undefined variable is found. Otherwise it does. This variable + * is used internally only! It supresses a "undefined variable" exception in GetUsedVar(). + * Those function should return a complete list of variables including + * those the are not defined by the time of it's call. + */ +inline void QmuParserTokenReader::IgnoreUndefVar ( bool bIgnore ) +{ + m_bIgnoreUndefVar = bIgnore; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void QmuParserTokenReader::SetArgSep ( char_type cArgSep ) +{ + m_cArgSep = cArgSep; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QChar QmuParserTokenReader::GetArgSep() const +{ + return m_cArgSep; +} +} // namespace qmu + +#endif diff --git a/src/libs/qmuparser/qmutranslation.cpp b/src/libs/qmuparser/qmutranslation.cpp new file mode 100644 index 000000000..a01b5cdf5 --- /dev/null +++ b/src/libs/qmuparser/qmutranslation.cpp @@ -0,0 +1,77 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#include "qmutranslation.h" +#include + +namespace qmu +{ + +//--------------------------------------------------------------------------------------------------------------------- +QmuTranslation QmuTranslation::translate(const QString &context, const QString &sourceText, + const QString &disambiguation, int n) +{ + if (n < 0) + { + n = -1; + } + QmuTranslation t(context, sourceText, disambiguation, n); + return t; +} + +//--------------------------------------------------------------------------------------------------------------------- +QmuTranslation::QmuTranslation() + :mcontext(QString()), msourceText(QString()), mdisambiguation(QString()), mn(-1) +{} + +//--------------------------------------------------------------------------------------------------------------------- +QmuTranslation::QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation, int n) + :mcontext(context), msourceText(sourceText), mdisambiguation(disambiguation), mn(n) +{} + +//--------------------------------------------------------------------------------------------------------------------- +QmuTranslation &QmuTranslation::operator=(const QmuTranslation &tr) +{ + if ( &tr == this ) + { + return *this; + } + this->mcontext = tr.getMcontext(); + this->msourceText = tr.getMsourceText(); + this->mdisambiguation = tr.getMdisambiguation(); + this->mn = tr.getN(); + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +QmuTranslation::QmuTranslation(const QmuTranslation &tr) + :mcontext(tr.getMcontext()), msourceText(tr.getMsourceText()), mdisambiguation(tr.getMdisambiguation()), + mn(tr.getN()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +QString QmuTranslation::translate() const +{ + return QCoreApplication::translate(mcontext.toUtf8().constData(), msourceText.toUtf8().constData(), + mdisambiguation.toUtf8().constData(), mn); +} + +} // namespace qmu diff --git a/src/libs/qmuparser/qmutranslation.h b/src/libs/qmuparser/qmutranslation.h new file mode 100644 index 000000000..688e8ecb5 --- /dev/null +++ b/src/libs/qmuparser/qmutranslation.h @@ -0,0 +1,95 @@ +/*************************************************************************************************** + ** + ** Original work Copyright (C) 2014 Roman Telezhynskyi + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy of this + ** software and associated documentation files (the "Software"), to deal in the Software + ** without restriction, including without limitation the rights to use, copy, modify, + ** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + ** permit persons to whom the Software is furnished to do so, subject to the following conditions: + ** + ** The above copyright notice and this permission notice shall be included in all copies or + ** substantial portions of the Software. + ** + ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + ** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ** + ******************************************************************************************************/ + +#ifndef QMUTRANSLATION_H +#define QMUTRANSLATION_H + +#include "qmuparser_global.h" +#include + +namespace qmu +{ + +/** + * @file + * @brief The VTranslation class help store string for translation. + * + * I took idea from this article http://ololoepepe.blogspot.com/2013/08/qt.html. + * As you know, if wrap string to a function translate, it will be marked for translation. No matter what namespace + * contains this function. In class Translation used this circumstance. + * This mean never change name of method translate!!!!!. + * Instead of using QT_TRANSLATE_NOOP3 macros we can store strings in QMap. + * Example: + * create map and fill up its + * QMap map; + * map.insert("head_girth", VTranslation::translate("Measurements", "head_girth", "Around fullest part of Head.")); + * get translated string + * map.value(measurement).translate(); + */ +class QMUPARSERSHARED_EXPORT QmuTranslation +{ +public: + QmuTranslation(); + ~QmuTranslation(){} + QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation = 0, int n = -1); + QmuTranslation &operator=(const QmuTranslation &tr); + QmuTranslation(const QmuTranslation &tr); + QString translate() const; + static QmuTranslation translate(const QString &context, const QString &sourceText, + const QString &disambiguation = 0, int n = -1); + QString getMcontext() const; + QString getMsourceText() const; + QString getMdisambiguation() const; + int getN() const; +private: + QString mcontext; + QString msourceText; + QString mdisambiguation; + int mn; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QString QmuTranslation::getMcontext() const +{ + return mcontext; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QString QmuTranslation::getMsourceText() const +{ + return msourceText; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QString QmuTranslation::getMdisambiguation() const +{ + return mdisambiguation; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline int QmuTranslation::getN() const +{ + return mn; +} + +} // namespace qmu + +#endif // QMUTRANSLATION_H diff --git a/src/tools/vdatatool.cpp b/src/libs/qmuparser/stable.cpp similarity index 77% rename from src/tools/vdatatool.cpp rename to src/libs/qmuparser/stable.cpp index 58a6eb39f..243b23938 100644 --- a/src/tools/vdatatool.cpp +++ b/src/libs/qmuparser/stable.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** - ** @file vdatatool.cpp - ** @author Roman Telezhinsky + ** @file stable.cpp + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -26,19 +26,5 @@ ** *************************************************************************/ -#include "vdatatool.h" - -VDataTool &VDataTool::operator =(const VDataTool &tool) -{ - data = tool.getData(); - _referens = tool.referens(); - return *this; -} - -void VDataTool::decrementReferens() -{ - if (_referens > 0) - { - --_referens; - } -} +// Build the precompiled headers. +#include "stable.h" diff --git a/src/stable.h b/src/libs/qmuparser/stable.h similarity index 77% rename from src/stable.h rename to src/libs/qmuparser/stable.h index 09cd50c93..2c8c41189 100644 --- a/src/stable.h +++ b/src/libs/qmuparser/stable.h @@ -1,7 +1,7 @@ /************************************************************************ ** ** @file stable.h - ** @author Roman Telezhinsky + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -29,25 +29,20 @@ #ifndef STABLE_H #define STABLE_H -/* I like to include this pragma too, -so the build log indicates if pre-compiled headers -were in use. */ -#pragma message("Compiling precompiled headers.\n") +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for QmuParser library.\n") +#endif /* Add C includes here */ #if defined __cplusplus /* Add C++ includes here */ -#ifdef Q_CC_MSVC -#define _USE_MATH_DEFINES -#endif + +#ifdef QT_CORE_LIB #include -#include -#include -#include -#include -#include -#include "options.h" +#endif + #endif #endif // STABLE_H diff --git a/src/libs/vobj/delaunay.c b/src/libs/vobj/delaunay.c new file mode 100644 index 000000000..37cd77cc4 --- /dev/null +++ b/src/libs/vobj/delaunay.c @@ -0,0 +1,1076 @@ +/* +** delaunay.c : compute 2D delaunay triangulation in the plane. +** Copyright (C) 2005 Wael El Oraiby +** +** +** This program 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. +** +** This program 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 this program. If not, see . +*/ + +#include +#include +#include +#include +#include + +#include "delaunay.h" + +#if PREDICATE == EXACT_PREDICATE +extern void exactinit(); +extern real incircle(real* pa, real* pb, real* pc, real* pd); +#endif + +#define ON_RIGHT 1 +#define ON_SEG 0 +#define ON_LEFT -1 + +#define OUTSIDE -1 +#define ON_CIRCLE 0 +#define INSIDE 1 + +struct point2d_s; +struct face_s; +struct halfedge_s; +struct delaunay_s; + + +#ifdef USE_DOUBLE +# define REAL_ZERO 0.0 +# define REAL_ONE 1.0 +# define REAL_TWO 2.0 +# define REAL_FOUR 4.0 +# define TOLERANCE (1024.0 * 1024.0) +#else +# define REAL_ZERO 0.0f +# define REAL_ONE 1.0f +# define REAL_TWO 2.0f +# define REAL_FOUR 4.0f +# define TOLERANCE (16.0f ) +#endif + +#define EPSILON (REAL_ONE / TOLERANCE) + +typedef struct point2d_s point2d_t; +typedef struct face_s face_t; +typedef struct halfedge_s halfedge_t; +typedef struct delaunay_s delaunay_t; +typedef real mat3_t[3][3]; + +struct point2d_s +{ + real x, y; /* point coordinates */ + halfedge_t* he; /* point halfedge */ + unsigned int idx; /* point index in input buffer */ +}; + +struct face_s +{ +/* real radius; + real cx, cy; + point2d_t* p[3]; +*/ + halfedge_t* he; /* a pointing half edge */ + unsigned int num_verts; /* number of vertices on this face */ +}; + +struct halfedge_s +{ + point2d_t* vertex; /* vertex */ + halfedge_t* pair; /* pair */ + halfedge_t* next; /* next */ + halfedge_t* prev; /* next^-1 */ + face_t* face; /* halfedge face */ +}; + +struct delaunay_s +{ + halfedge_t* rightmost_he; /* right most halfedge */ + halfedge_t* leftmost_he; /* left most halfedge */ + point2d_t** points; /* pointer to points */ + face_t* faces; /* faces of delaunay */ + unsigned int num_faces; /* face count */ + unsigned int start_point; /* start point index */ + unsigned int end_point; /* end point index */ +}; + + +/* +* 3x3 matrix determinant +*/ +//static real det3( mat3_t *m ) +//{ +// real res; + +// res = ((*m)[0][0]) * (((*m)[1][1]) * ((*m)[2][2]) - ((*m)[1][2]) * ((*m)[2][1])) +// - ((*m)[0][1]) * (((*m)[1][0]) * ((*m)[2][2]) - ((*m)[1][2]) * ((*m)[2][0])) +// + ((*m)[0][2]) * (((*m)[1][0]) * ((*m)[2][1]) - ((*m)[1][1]) * ((*m)[2][0])); + +// return res; +//} + +/* +* allocate a point +*/ +static point2d_t* point_alloc() +{ + point2d_t* p; + + p = (point2d_t*)malloc(sizeof(point2d_t)); + assert( p != NULL ); + memset(p, 0, sizeof(point2d_t)); + + return p; +} + +/* +* free a point +*/ +static void point_free( point2d_t* p ) +{ + assert( p != NULL ); + free(p); +} + +/* +* allocate a halfedge +*/ +static halfedge_t* halfedge_alloc() +{ + halfedge_t* d; + + d = (halfedge_t*)malloc(sizeof(halfedge_t)); + assert( d != NULL ); + memset(d, 0, sizeof(halfedge_t)); + + return d; +} + +/* +* free a halfedge +*/ +static void halfedge_free( halfedge_t* d ) +{ + assert( d != NULL ); + memset(d, 0, sizeof(halfedge_t)); + free(d); +} + +/* +* free all delaunay halfedges +*/ +void del_free_halfedges( delaunay_t *del ) +{ + unsigned int i; + halfedge_t *d, *sig; + + /* if there is nothing to do */ + if( del->points == NULL ) + return; + + for( i = 0; i <= (del->end_point - del->start_point); i++ ) + { + /* free all the halfedges around the point */ + d = del->points[i]->he; + if( d != NULL ) + { + do { + sig = d->next; + halfedge_free( d ); + d = sig; + } while( d != del->points[i]->he ); + del->points[i]->he = NULL; + } + } +} + +/* + * allocate memory for a face + */ +//static face_t* face_alloc() +//{ +// face_t *f = (face_t*)malloc(sizeof(face_t)); +// assert( f != NULL ); +// memset(f, 0, sizeof(face_t)); +// return f; +//} + +/* + * free a face + */ +//static void face_free(face_t *f) +//{ +// assert( f != NULL ); +// free(f); +//} + +/* +* compare 2 points when sorting +*/ +static int cmp_points( const void *_pt0, const void *_pt1 ) +{ + point2d_t *pt0, *pt1; + + pt0 = (point2d_t*)(*((point2d_t**)_pt0)); + pt1 = (point2d_t*)(*((point2d_t**)_pt1)); + + if( pt0->x < pt1->x ) + return -1; + else if( pt0->x > pt1->x ) + return 1; + else if( pt0->y < pt1->y ) + return -1; + else if( pt0->y > pt1->y ) + return 1; + assert(0 && "2 or more points share the same exact coordinate"); + return 0; /* Should not be given! */ +} + +/* +* classify a point relative to a segment +*/ +static int classify_point_seg( point2d_t *s, point2d_t *e, point2d_t *pt ) +{ + point2d_t se, spt; + real res; + + se.x = e->x - s->x; + se.y = e->y - s->y; + + spt.x = pt->x - s->x; + spt.y = pt->y - s->y; + + res = (( se.x * spt.y ) - ( se.y * spt.x )); + if( res < REAL_ZERO ) + return ON_RIGHT; + else if( res > REAL_ZERO ) + return ON_LEFT; + + return ON_SEG; +} + +/* +* classify a point relative to a halfedge, -1 is left, 0 is on, 1 is right +*/ +static int del_classify_point( halfedge_t *d, point2d_t *pt ) +{ + point2d_t *s, *e; + + s = d->vertex; + e = d->pair->vertex; + + return classify_point_seg(s, e, pt); +} + +/* +* return the absolute value +*/ +//static real dabs( real a ) +//{ +// if( a < REAL_ZERO ) +// return (-a); +// return a; +//} + +/* +* compute the circle given 3 points +*/ +#if PREDICATE == LOOSE_PREDICATE +static void compute_circle( point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, real *cx, real *cy, real *radius ) +{ + mat3_t ma, mbx, mby, mc; + real x0y0, x1y1, x2y2; + real a, bx, by, c; + + /* calculate x0y0, .... */ + x0y0 = pt0->x * pt0->x + pt0->y * pt0->y; + x1y1 = pt1->x * pt1->x + pt1->y * pt1->y; + x2y2 = pt2->x * pt2->x + pt2->y * pt2->y; + + /* setup A matrix */ + ma[0][0] = pt0->x; + ma[0][1] = pt0->y; + ma[1][0] = pt1->x; + ma[1][1] = pt1->y; + ma[2][0] = pt2->x; + ma[2][1] = pt2->y; + ma[0][2] = ma[1][2] = ma[2][2] = REAL_ONE; + + /* setup Bx matrix */ + mbx[0][0] = x0y0; + mbx[1][0] = x1y1; + mbx[2][0] = x2y2; + mbx[0][1] = pt0->y; + mbx[1][1] = pt1->y; + mbx[2][1] = pt2->y; + mbx[0][2] = mbx[1][2] = mbx[2][2] = REAL_ONE; + + /* setup By matrix */ + mby[0][0] = x0y0; + mby[1][0] = x1y1; + mby[2][0] = x2y2; + mby[0][1] = pt0->x; + mby[1][1] = pt1->x; + mby[2][1] = pt2->x; + mby[0][2] = mby[1][2] = mby[2][2] = REAL_ONE; + + /* setup C matrix */ + mc[0][0] = x0y0; + mc[1][0] = x1y1; + mc[2][0] = x2y2; + mc[0][1] = pt0->x; + mc[1][1] = pt1->x; + mc[2][1] = pt2->x; + mc[0][2] = pt0->y; + mc[1][2] = pt1->y; + mc[2][2] = pt2->y; + + /* compute a, bx, by and c */ + a = det3(&ma); + bx = det3(&mbx); + by = -det3(&mby); + c = -det3(&mc); + + *cx = bx / (REAL_TWO * a); + *cy = by / (REAL_TWO * a); + *radius = sqrt(bx * bx + by * by - REAL_FOUR * a * c) / (REAL_TWO * dabs(a)); +} +#endif + +/* +* test if a point is inside a circle given by 3 points, 1 if inside, 0 if outside +*/ +static int in_circle( point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t *p ) +{ +#if PREDICATE == EXACT_PREDICATE + real res = incircle(&(pt0->x), &(pt1->x), &(pt2->x), &(p->x)); + if( res > REAL_ZERO ) + return INSIDE; + else if( res < REAL_ZERO ) + return OUTSIDE; + + return ON_CIRCLE; +#endif +#if PREDICATE == LOOSE_PREDICATE + real cx, cy, radius; + compute_circle(pt0, pt1, pt2, &cx, &cy, &radius); + + real distance = sqrt((p->x - cx) * (p->x - cx) + (p->y - cy) * (p->y - cy)); + if( distance < radius - EPSILON ) + return INSIDE; + else if(distance > radius + EPSILON ) + return OUTSIDE; + return ON_CIRCLE; +#endif +#if PREDICATE == FAST_PREDICATE + mat3_t ma, mbx, mby, mc; + real x0y0, x1y1, x2y2; + real a, bx, by, c, res; + + /* calculate x0y0, .... */ + x0y0 = pt0->x * pt0->x + pt0->y * pt0->y; + x1y1 = pt1->x * pt1->x + pt1->y * pt1->y; + x2y2 = pt2->x * pt2->x + pt2->y * pt2->y; + + /* setup A matrix */ + ma[0][0] = pt0->x; + ma[0][1] = pt0->y; + ma[1][0] = pt1->x; + ma[1][1] = pt1->y; + ma[2][0] = pt2->x; + ma[2][1] = pt2->y; + ma[0][2] = ma[1][2] = ma[2][2] = REAL_ONE; + + /* setup Bx matrix */ + mbx[0][0] = x0y0; + mbx[1][0] = x1y1; + mbx[2][0] = x2y2; + mbx[0][1] = pt0->y; + mbx[1][1] = pt1->y; + mbx[2][1] = pt2->y; + mbx[0][2] = mbx[1][2] = mbx[2][2] = REAL_ONE; + + /* setup By matrix */ + mby[0][0] = x0y0; + mby[1][0] = x1y1; + mby[2][0] = x2y2; + mby[0][1] = pt0->x; + mby[1][1] = pt1->x; + mby[2][1] = pt2->x; + mby[0][2] = mby[1][2] = mby[2][2] = REAL_ONE; + + /* setup C matrix */ + mc[0][0] = x0y0; + mc[1][0] = x1y1; + mc[2][0] = x2y2; + mc[0][1] = pt0->x; + mc[1][1] = pt1->x; + mc[2][1] = pt2->x; + mc[0][2] = pt0->y; + mc[1][2] = pt1->y; + mc[2][2] = pt2->y; + + /* compute a, bx, by and c */ + a = det3(&ma); + bx = det3(&mbx); + by = -det3(&mby); + c = -det3(&mc); + + res = a * (p->x * p->x + p->y * p->y ) - bx * p->x - by * p->y + c; + + + if( res < REAL_ZERO ) + return INSIDE; + else if( res > REAL_ZERO ) + return OUTSIDE; + + return ON_CIRCLE; +#endif +} + +/* +* initialize delaunay segment +*/ +static int del_init_seg( delaunay_t *del, int start ) +{ + halfedge_t *d0, *d1; + point2d_t *pt0, *pt1; + + /* init delaunay */ + del->start_point = start; + del->end_point = start + 1; + + /* setup pt0 and pt1 */ + pt0 = del->points[start]; + pt1 = del->points[start + 1]; + + /* allocate the halfedges and setup them */ + d0 = halfedge_alloc(); + d1 = halfedge_alloc(); + + d0->vertex = pt0; + d1->vertex = pt1; + + d0->next = d0->prev = d0; + d1->next = d1->prev = d1; + + d0->pair = d1; + d1->pair = d0; + + pt0->he = d0; + pt1->he = d1; + + del->rightmost_he = d1; + del->leftmost_he = d0; + + + return 0; +} + +/* +* initialize delaunay triangle +*/ +static int del_init_tri( delaunay_t *del, int start ) +{ + halfedge_t *d0, *d1, *d2, *d3, *d4, *d5; + point2d_t *pt0, *pt1, *pt2; + + /* initiate delaunay */ + del->start_point = start; + del->end_point = start + 2; + + /* setup the points */ + pt0 = del->points[start]; + pt1 = del->points[start + 1]; + pt2 = del->points[start + 2]; + + /* allocate the 6 halfedges */ + d0 = halfedge_alloc(); + d1 = halfedge_alloc(); + d2 = halfedge_alloc(); + d3 = halfedge_alloc(); + d4 = halfedge_alloc(); + d5 = halfedge_alloc(); + + if( classify_point_seg(pt0, pt2, pt1) == ON_LEFT ) /* first case */ + { + /* set halfedges points */ + d0->vertex = pt0; + d1->vertex = pt2; + d2->vertex = pt1; + + d3->vertex = pt2; + d4->vertex = pt1; + d5->vertex = pt0; + + /* set points halfedges */ + pt0->he = d0; + pt1->he = d2; + pt2->he = d1; + + /* next and next -1 setup */ + d0->next = d5; + d0->prev = d5; + + d1->next = d3; + d1->prev = d3; + + d2->next = d4; + d2->prev = d4; + + d3->next = d1; + d3->prev = d1; + + d4->next = d2; + d4->prev = d2; + + d5->next = d0; + d5->prev = d0; + + /* set halfedges pair */ + d0->pair = d3; + d3->pair = d0; + + d1->pair = d4; + d4->pair = d1; + + d2->pair = d5; + d5->pair = d2; + + del->rightmost_he = d1; + del->leftmost_he = d0; + + } else /* 2nd case */ + { + /* set halfedges points */ + d0->vertex = pt0; + d1->vertex = pt1; + d2->vertex = pt2; + + d3->vertex = pt1; + d4->vertex = pt2; + d5->vertex = pt0; + + /* set points halfedges */ + pt0->he = d0; + pt1->he = d1; + pt2->he = d2; + + /* next and next -1 setup */ + d0->next = d5; + d0->prev = d5; + + d1->next = d3; + d1->prev = d3; + + d2->next = d4; + d2->prev = d4; + + d3->next = d1; + d3->prev = d1; + + d4->next = d2; + d4->prev = d2; + + d5->next = d0; + d5->prev = d0; + + /* set halfedges pair */ + d0->pair = d3; + d3->pair = d0; + + d1->pair = d4; + d4->pair = d1; + + d2->pair = d5; + d5->pair = d2; + + del->rightmost_he = d2; + del->leftmost_he = d0; + } + + return 0; +} + +/* +* remove an edge given a halfedge +*/ +static void del_remove_edge( halfedge_t *d ) +{ + halfedge_t *next, *prev, *pair, *orig_pair; + + orig_pair = d->pair; + + next = d->next; + prev = d->prev; + pair = d->pair; + + assert(next != NULL); + assert(prev != NULL); + + next->prev = prev; + prev->next = next; + + + /* check to see if we have already removed pair */ + if( pair ) + pair->pair = NULL; + + /* check to see if the vertex points to this halfedge */ + if( d->vertex->he == d ) + d->vertex->he = next; + + d->vertex = NULL; + d->next = NULL; + d->prev = NULL; + d->pair = NULL; + + next = orig_pair->next; + prev = orig_pair->prev; + pair = orig_pair->pair; + + assert(next != NULL); + assert(prev != NULL); + + next->prev = prev; + prev->next = next; + + + /* check to see if we have already removed pair */ + if( pair ) + pair->pair = NULL; + + /* check to see if the vertex points to this halfedge */ + if( orig_pair->vertex->he == orig_pair ) + orig_pair->vertex->he = next; + + orig_pair->vertex = NULL; + orig_pair->next = NULL; + orig_pair->prev = NULL; + orig_pair->pair = NULL; + + + /* finally free the halfedges */ + halfedge_free(d); + halfedge_free(orig_pair); +} + +/* +* pass through all the halfedges on the left side and validate them +*/ +static halfedge_t* del_valid_left( halfedge_t* b ) +{ + point2d_t *g, *d, *u, *v; + halfedge_t *c, *du, *dg; + + g = b->vertex; /* base halfedge point */ + dg = b; + + d = b->pair->vertex; /* pair(halfedge) point */ + b = b->next; + + u = b->pair->vertex; /* next(pair(halfedge)) point */ + du = b->pair; + + v = b->next->pair->vertex; /* pair(next(next(halfedge)) point */ + + if( classify_point_seg(g, d, u) == ON_LEFT ) + { + /* 3 points aren't colinear */ + /* as long as the 4 points belong to the same circle, do the cleaning */ + assert( v != u && "1: floating point precision error"); + while( v != d && v != g && in_circle(g, d, u, v) == INSIDE ) + { + c = b->next; + du = b->next->pair; + del_remove_edge(b); + b = c; + u = du->vertex; + v = b->next->pair->vertex; + } + + assert( v != u && "2: floating point precision error"); + if( v != d && v != g && in_circle(g, d, u, v) == ON_CIRCLE ) + { + du = du->prev; + del_remove_edge(b); + } + } else /* treat the case where the 3 points are colinear */ + du = dg; + + assert(du->pair); + return du; +} + +/* +* pass through all the halfedges on the right side and validate them +*/ +static halfedge_t* del_valid_right( halfedge_t *b ) +{ + point2d_t *rv, *lv, *u, *v; + halfedge_t *c, *dd, *du; + + b = b->pair; + rv = b->vertex; + dd = b; + lv = b->pair->vertex; + b = b->prev; + u = b->pair->vertex; + du = b->pair; + + v = b->prev->pair->vertex; + + if( classify_point_seg(lv, rv, u) == ON_LEFT ) + { + assert( v != u && "1: floating point precision error"); + while( v != lv && v != rv && in_circle(lv, rv, u, v) == INSIDE ) + { + c = b->prev; + du = c->pair; + del_remove_edge(b); + b = c; + u = du->vertex; + v = b->prev->pair->vertex; + } + + assert( v != u && "1: floating point precision error"); + if( v != lv && v != rv && in_circle(lv, rv, u, v) == ON_CIRCLE ) + { + du = du->next; + del_remove_edge(b); + } + } else + du = dd; + + assert(du->pair); + return du; +} + + +/* +* validate a link +*/ +static halfedge_t* del_valid_link( halfedge_t *b ) +{ + point2d_t *g, *g_p, *d, *d_p; + halfedge_t *gd, *dd, *new_gd, *new_dd; + + g = b->vertex; + gd = del_valid_left(b); + g_p = gd->vertex; + + assert(b->pair); + d = b->pair->vertex; + dd = del_valid_right(b); + d_p = dd->vertex; + assert(b->pair); + + if( g != g_p && d != d_p ) + { + int a = in_circle(g, d, g_p, d_p); + + if( a != ON_CIRCLE ) + { + if( a == INSIDE ) + { + g_p = g; + gd = b; + } + else + { + d_p = d; + dd = b->pair; + } + } + } + + /* create the 2 halfedges */ + new_gd = halfedge_alloc(); + new_dd = halfedge_alloc(); + + /* setup new_gd and new_dd */ + + new_gd->vertex = gd->vertex; + new_gd->pair = new_dd; + new_gd->prev = gd; + new_gd->next = gd->next; + gd->next->prev = new_gd; + gd->next = new_gd; + + new_dd->vertex = dd->vertex; + new_dd->pair = new_gd; + new_dd->prev = dd->prev; + dd->prev->next = new_dd; + new_dd->next = dd; + dd->prev = new_dd; + + return new_gd; +} + +/* +* find the lower tangent between the two delaunay, going from left to right (returns the left half edge) +*/ +static halfedge_t* del_get_lower_tangent( delaunay_t *left, delaunay_t *right ) +{ + halfedge_t *right_d, *left_d, *new_ld, *new_rd; + int sl, sr; + + left_d = left->rightmost_he; + right_d = right->leftmost_he; + + do { + point2d_t *pl = left_d->prev->pair->vertex; + point2d_t *pr = right_d->pair->vertex; + + if( (sl = classify_point_seg(left_d->vertex, right_d->vertex, pl)) == ON_RIGHT ) { + left_d = left_d->prev->pair; + } + + if( (sr = classify_point_seg(left_d->vertex, right_d->vertex, pr)) == ON_RIGHT ) { + right_d = right_d->pair->next; + } + + } while( sl == ON_RIGHT || sr == ON_RIGHT ); + + /* create the 2 halfedges */ + new_ld = halfedge_alloc(); + new_rd = halfedge_alloc(); + + /* setup new_gd and new_dd */ + new_ld->vertex = left_d->vertex; + new_ld->pair = new_rd; + new_ld->prev = left_d->prev; + left_d->prev->next = new_ld; + new_ld->next = left_d; + left_d->prev = new_ld; + + new_rd->vertex = right_d->vertex; + new_rd->pair = new_ld; + new_rd->prev = right_d->prev; + right_d->prev->next = new_rd; + new_rd->next = right_d; + right_d->prev = new_rd; + + return new_ld; +} + +/* +* link the 2 delaunay together +*/ +static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right ) +{ + point2d_t *u, *v, *ml, *mr; + halfedge_t *base; + + assert( left->points == right->points ); + + /* save the most right point and the most left point */ + ml = left->leftmost_he->vertex; + mr = right->rightmost_he->vertex; + + base = del_get_lower_tangent(left, right); + + u = base->next->pair->vertex; + v = base->pair->prev->pair->vertex; + + while( del_classify_point(base, u) == ON_LEFT || + del_classify_point(base, v) == ON_LEFT ) + { + base = del_valid_link(base); + u = base->next->pair->vertex; + v = base->pair->prev->pair->vertex; + } + + right->rightmost_he = mr->he; + left->leftmost_he = ml->he; + + /* TODO: this part is not needed, and can be optimized */ + while( del_classify_point( right->rightmost_he, right->rightmost_he->prev->pair->vertex ) == ON_RIGHT ) + right->rightmost_he = right->rightmost_he->prev; + + while( del_classify_point( left->leftmost_he, left->leftmost_he->prev->pair->vertex ) == ON_RIGHT ) + left->leftmost_he = left->leftmost_he->prev; + + result->leftmost_he = left->leftmost_he; + result->rightmost_he = right->rightmost_he; + result->points = left->points; + result->start_point = left->start_point; + result->end_point = right->end_point; +} + +/* +* divide and conquer delaunay +*/ +void del_divide_and_conquer( delaunay_t *del, int start, int end ) +{ + delaunay_t left, right; + + int n = (end - start + 1); + + if( n > 3 ) + { + int i = (n / 2) + (n & 1); + left.points = del->points; + right.points = del->points; + del_divide_and_conquer( &left, start, start + i - 1 ); + del_divide_and_conquer( &right, start + i, end ); + del_link( del, &left, &right ); + } else + if( n == 3 ) + del_init_tri( del, start ); + else + if( n == 2 ) + del_init_seg( del, start ); +} + +static void build_halfedge_face( delaunay_t *del, halfedge_t *d ) +{ + halfedge_t *curr; + + /* test if the halfedge has already a pointing face */ + if( d->face != NULL ) + return; + + del->faces = (face_t*)realloc(del->faces, (del->num_faces + 1) * sizeof(face_t)); + + face_t *f = &(del->faces[del->num_faces]); + curr = d; + f->he = d; + f->num_verts = 0; + do { + curr->face = f; + (f->num_verts)++; + curr = curr->pair->prev; + } while( curr != d ); + + (del->num_faces)++; + +/* if( d->face.radius < 0.0 ) + { + d->face.p[0] = d->vertex; + d->face.p[1] = d->pair->vertex; + d->face.p[2] = d->pair->prev->pair->vertex; + + if( classify_point_seg( d->face.p[0], d->face.p[1], d->face.p[2] ) == ON_LEFT ) + { + compute_circle(d->face.p[0], d->face.p[1], d->face.p[2], &(d->face.cx), &(d->face.cy), &(d->face.radius)); + } + } +*/ +} + +/* +* build the faces for all the halfedge +*/ +void del_build_faces( delaunay_t *del ) +{ + unsigned int i; + halfedge_t *curr; + + del->num_faces = 0; + del->faces = NULL; + + /* build external face first */ + build_halfedge_face(del, del->rightmost_he->pair); + + for( i = del->start_point; i <= del->end_point; i++ ) + { + curr = del->points[i]->he; + + do { + build_halfedge_face( del, curr ); + curr = curr->next; + } while( curr != del->points[i]->he ); + } +} + +/* +*/ +delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points) { + delaunay2d_t* res = NULL; + delaunay_t del; + unsigned int i; + unsigned int* faces = NULL; + + del.num_faces = 0; //Warning using uninitialized value + +#if PREDICATE == EXACT_PREDICATE + exactinit(); +#endif + + /* allocate the points */ + del.points = (point2d_t**)malloc(num_points * sizeof(point2d_t*)); + assert( del.points != NULL ); + memset(del.points, 0, num_points * sizeof(point2d_t*)); + + /* copy the points */ + for( i = 0; i < num_points; i++ ) + { + del.points[i] = point_alloc(); + del.points[i]->idx = i; + del.points[i]->x = points[i].x; + del.points[i]->y = points[i].y; + } + + qsort(del.points, num_points, sizeof(point2d_t*), cmp_points); + + if( num_points >= 3 ) { + del_divide_and_conquer( &del, 0, num_points - 1 ); + + del_build_faces( &del ); + + unsigned int fbuff_size = 0; + for( i = 0; i < del.num_faces; i++ ) + fbuff_size += del.faces[i].num_verts + 1; + + faces = (unsigned int*)malloc(sizeof(unsigned int) * fbuff_size); + + unsigned int j = 0; + for( i = 0; i < del.num_faces; i++ ) + { + halfedge_t *curr; + + faces[j] = del.faces[i].num_verts; + j++; + + curr = del.faces[i].he; + do { + faces[j] = curr->vertex->idx; + j++; + curr = curr->pair->prev; + } while( curr != del.faces[i].he ); + } + + del_free_halfedges( &del ); + + free(del.faces); + for( i = 0; i < num_points; i++ ) + point_free(del.points[i]); + + free(del.points); + } + + res = (delaunay2d_t*)malloc(sizeof(delaunay2d_t)); + res->num_points = num_points; + res->points = malloc(sizeof(del_point2d_t) * num_points); + memcpy(res->points, points, sizeof(del_point2d_t) * num_points); + res->num_faces = del.num_faces; + res->faces = faces; + + return res; +} + +void delaunay2d_release(delaunay2d_t *del) { + free(del->faces); + free(del->points); + free(del); +} diff --git a/src/libs/vobj/delaunay.h b/src/libs/vobj/delaunay.h new file mode 100644 index 000000000..f7e10184d --- /dev/null +++ b/src/libs/vobj/delaunay.h @@ -0,0 +1,92 @@ +#ifndef DELAUNAY_H +#define DELAUNAY_H + +/* +** delaunay.c : compute 2D delaunay triangulation in the plane. +** Copyright (C) 2005 Wael El Oraiby +** +** +** This program 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. +** +** This program 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 this program. If not, see . +*/ + +#define DEL_CIRCLE + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* define the floating point type, comment to use float - Be careful "float" type will assert more often */ +#define USE_DOUBLE + +#define FAST_PREDICATE 1 /* fast but floating point errors are more likely to occur */ +#define LOOSE_PREDICATE 2 /* loose with epsilon defined in the delaunay file - errors will happen but less frequently */ +#define EXACT_PREDICATE 3 /* use exact arithmetic - slower, but shouldn't produce any floating point error */ + +#define PREDICATE EXACT_PREDICATE + +#if PREDICATE == EXACT_PREDICATE && !defined(USE_DOUBLE) +# define USE_DOUBLE +#endif + +#ifdef USE_DOUBLE +typedef double real; +#else +typedef float real; +#endif + +typedef struct { + real x, y; +} del_point2d_t; + +typedef struct { + /** input points count */ + unsigned int num_points; + + /** the input points */ + del_point2d_t* points; + + /** number of returned faces */ + unsigned int num_faces; + + /** the triangles given as a sequence: num verts, verts indices, num verts, verts indices first face is the external face */ + unsigned int* faces; +} delaunay2d_t; + +typedef int (*incircle_predicate_t)(del_point2d_t* p0, del_point2d_t* p1, del_point2d_t* p2, del_point2d_t* p3); + +/* + * build the 2D Delaunay triangulation given a set of points of at least 3 points + * + * @points: point set given as a sequence of tuple x0, y0, x1, y1, .... + * @num_points: number of given point + * @preds: the incircle predicate + * @faces: the triangles given as a sequence: num verts, verts indices, num verts, verts indices + * first face is the external face + * @pred: incircle predicate + * @return: the number of created faces + */ +delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points); + +/* + * release a delaunay2d object + */ +void delaunay2d_release(delaunay2d_t* del); + +#ifdef __cplusplus +} +#endif + +#endif // DELAUNAY_H diff --git a/src/libs/vobj/predicates.c b/src/libs/vobj/predicates.c new file mode 100644 index 000000000..7da2238e7 --- /dev/null +++ b/src/libs/vobj/predicates.c @@ -0,0 +1,1063 @@ +/*****************************************************************************/ +/* */ +/* Routines for Arbitrary Precision Floating-point Arithmetic */ +/* and Fast Robust Geometric Predicates */ +/* (predicates.c) */ +/* */ +/* May 18, 1996 */ +/* */ +/* Placed in the public domain by */ +/* Jonathan Richard Shewchuk */ +/* School of Computer Science */ +/* Carnegie Mellon University */ +/* 5000 Forbes Avenue */ +/* Pittsburgh, Pennsylvania 15213-3891 */ +/* jrs@cs.cmu.edu */ +/* */ +/* This file contains C implementation of algorithms for exact addition */ +/* and multiplication of floating-point numbers, and predicates for */ +/* robustly performing the orientation and incircle tests used in */ +/* computational geometry. The algorithms and underlying theory are */ +/* described in Jonathan Richard Shewchuk. "Adaptive Precision Floating- */ +/* Point Arithmetic and Fast Robust Geometric Predicates." Technical */ +/* Report CMU-CS-96-140, School of Computer Science, Carnegie Mellon */ +/* University, Pittsburgh, Pennsylvania, May 1996. (Submitted to */ +/* Discrete & Computational Geometry.) */ +/* */ +/* This file, the paper listed above, and other information are available */ +/* from the Web page http://www.cs.cmu.edu/~quake/robust.html . */ +/* */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* */ +/* Using this code: */ +/* */ +/* First, read the short or long version of the paper (from the Web page */ +/* above). */ +/* */ +/* Be sure to call exactinit() once, before calling any of the arithmetic */ +/* functions or geometric predicates. Also be sure to turn on the */ +/* optimizer when compiling this file. */ +/* */ +/* */ +/* Several geometric predicates are defined. Their parameters are all */ +/* points. Each point is an array of two or three floating-point */ +/* numbers. The geometric predicates, described in the papers, are */ +/* */ +/* incircle(pa, pb, pc, pd) */ +/* incirclefast(pa, pb, pc, pd) */ +/* */ +/* Those with suffix "fast" are approximate, non-robust versions. Those */ +/* without the suffix are adaptive precision, robust versions. There */ +/* are also versions with the suffices "exact" and "slow", which are */ +/* non-adaptive, exact arithmetic versions, which I use only for timings */ +/* in my arithmetic papers. */ +/* */ +/* */ +/* An expansion is represented by an array of floating-point numbers, */ +/* sorted from smallest to largest magnitude (possibly with interspersed */ +/* zeros). The length of each expansion is stored as a separate integer, */ +/* and each arithmetic function returns an integer which is the length */ +/* of the expansion it created. */ +/* */ +/* Several arithmetic functions are defined. Their parameters are */ +/* */ +/* e, f Input expansions */ +/* elen, flen Lengths of input expansions (must be >= 1) */ +/* h Output expansion */ +/* b Input scalar */ +/* */ +/* The arithmetic functions are */ +/* */ +/* expansion_sum(elen, e, flen, f, h) */ +/* expansion_sum_zeroelim1(elen, e, flen, f, h) */ +/* expansion_sum_zeroelim2(elen, e, flen, f, h) */ +/* fast_expansion_sum(elen, e, flen, f, h) */ +/* fast_expansion_sum_zeroelim(elen, e, flen, f, h) */ +/* linear_expansion_sum(elen, e, flen, f, h) */ +/* linear_expansion_sum_zeroelim(elen, e, flen, f, h) */ +/* scale_expansion(elen, e, b, h) */ +/* scale_expansion_zeroelim(elen, e, b, h) */ +/* compress(elen, e, h) */ +/* */ +/* All of these are described in the long version of the paper; some are */ +/* described in the short version. All return an integer that is the */ +/* length of h. Those with suffix _zeroelim perform zero elimination, */ +/* and are recommended over their counterparts. The procedure */ +/* fast_expansion_sum_zeroelim() (or linear_expansion_sum_zeroelim() on */ +/* processors that do not use the round-to-even tiebreaking rule) is */ +/* recommended over expansion_sum_zeroelim(). Each procedure has a */ +/* little note next to it (in the code below) that tells you whether or */ +/* not the output expansion may be the same array as one of the input */ +/* expansions. */ +/* */ +/* */ +/* If you look around below, you'll also find macros for a bunch of */ +/* simple unrolled arithmetic operations, and procedures for printing */ +/* expansions (commented out because they don't work with all C */ +/* compilers) and for generating random floating-point numbers whose */ +/* significand bits are all random. Most of the macros have undocumented */ +/* requirements that certain of their parameters should not be the same */ +/* variable; for safety, better to make sure all the parameters are */ +/* distinct variables. Feel free to send email to jrs@cs.cmu.edu if you */ +/* have questions. */ +/* */ +/*****************************************************************************/ + +#include +#include +#include +#include + +/* On some machines, the exact arithmetic routines might be defeated by the */ +/* use of internal extended precision floating-point registers. Sometimes */ +/* this problem can be fixed by defining certain values to be volatile, */ +/* thus forcing them to be stored to memory and rounded off. This isn't */ +/* a great solution, though, as it slows the arithmetic down. */ +/* */ +/* To try this out, write "#define INEXACT volatile" below. Normally, */ +/* however, INEXACT should be defined to be nothing. ("#define INEXACT".) */ + +#define INEXACT /* Nothing */ +/* #define INEXACT volatile */ + +#define REALPRINT doubleprint +#define REALRAND doublerand +#define NARROWRAND narrowdoublerand +#define UNIFORMRAND uniformdoublerand + +/* Which of the following two methods of finding the absolute values is */ +/* fastest is compiler-dependent. A few compilers can inline and optimize */ +/* the fabs() call; but most will incur the overhead of a function call, */ +/* which is disastrously slow. A faster way on IEEE machines might be to */ +/* mask the appropriate bit, but that's difficult to do in C. */ + +#define Absolute(a) ((a) >= 0.0 ? (a) : -(a)) +/* #define Absolute(a) fabs(a) */ + + +/* Many of the operations are broken up into two pieces, a main part that */ +/* performs an approximate operation, and a "tail" that computes the */ +/* roundoff error of that operation. */ +/* */ +/* The operations Fast_Two_Sum(), Fast_Two_Diff(), Two_Sum(), Two_Diff(), */ +/* Split(), and Two_Product() are all implemented as described in the */ +/* reference. Each of these macros requires certain variables to be */ +/* defined in the calling routine. The variables `bvirt', `c', `abig', */ +/* `_i', `_j', `_k', `_l', `_m', and `_n' are declared `INEXACT' because */ +/* they store the result of an operation that may incur roundoff error. */ +/* The input parameter `x' (or the highest numbered `x_' parameter) must */ +/* also be declared `INEXACT'. */ + +#define Fast_Two_Sum_Tail(a, b, x, y) \ + bvirt = x - a; \ + y = b - bvirt + +#define Fast_Two_Sum(a, b, x, y) \ + x = (qreal) (a + b); \ + Fast_Two_Sum_Tail(a, b, x, y) + +#define Two_Sum_Tail(a, b, x, y) \ + bvirt = (qreal) (x - a); \ + avirt = x - bvirt; \ + bround = b - bvirt; \ + around = a - avirt; \ + y = around + bround + +#define Two_Sum(a, b, x, y) \ + x = (qreal) (a + b); \ + Two_Sum_Tail(a, b, x, y) + +#define Two_Diff_Tail(a, b, x, y) \ + bvirt = (qreal) (a - x); \ + avirt = x + bvirt; \ + bround = bvirt - b; \ + around = a - avirt; \ + y = around + bround + +#define Two_Diff(a, b, x, y) \ + x = (qreal) (a - b); \ + Two_Diff_Tail(a, b, x, y) + +#define Split(a, ahi, alo) \ + c = (qreal) (splitter * a); \ + abig = (qreal) (c - a); \ + ahi = c - abig; \ + alo = a - ahi + +#define Two_Product_Tail(a, b, x, y) \ + Split(a, ahi, alo); \ + Split(b, bhi, blo); \ + err1 = x - (ahi * bhi); \ + err2 = err1 - (alo * bhi); \ + err3 = err2 - (ahi * blo); \ + y = (alo * blo) - err3 + +#define Two_Product(a, b, x, y) \ + x = (qreal) (a * b); \ + Two_Product_Tail(a, b, x, y) + +/* Two_Product_Presplit() is Two_Product() where one of the inputs has */ +/* already been split. Avoids redundant splitting. */ + +#define Two_Product_Presplit(a, b, bhi, blo, x, y) \ + x = (qreal) (a * b); \ + Split(a, ahi, alo); \ + err1 = x - (ahi * bhi); \ + err2 = err1 - (alo * bhi); \ + err3 = err2 - (ahi * blo); \ + y = (alo * blo) - err3 + +/* Square() can be done more quickly than Two_Product(). */ + +#define Square_Tail(a, x, y) \ + Split(a, ahi, alo); \ + err1 = x - (ahi * ahi); \ + err3 = err1 - ((ahi + ahi) * alo); \ + y = (alo * alo) - err3 + +#define Square(a, x, y) \ + x = (qreal) (a * a); \ + Square_Tail(a, x, y) + +/* Macros for summing expansions of various fixed lengths. These are all */ +/* unrolled versions of Expansion_Sum(). */ + +#define Two_One_Sum(a1, a0, b, x2, x1, x0) \ + Two_Sum(a0, b , _i, x0); \ + Two_Sum(a1, _i, x2, x1) + +#define Two_One_Diff(a1, a0, b, x2, x1, x0) \ + Two_Diff(a0, b , _i, x0); \ + Two_Sum( a1, _i, x2, x1) + +#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \ + Two_One_Sum(a1, a0, b0, _j, _0, x0); \ + Two_One_Sum(_j, _0, b1, x3, x2, x1) + +#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \ + Two_One_Diff(a1, a0, b0, _j, _0, x0); \ + Two_One_Diff(_j, _0, b1, x3, x2, x1) + +qreal splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */ +qreal epsilon; /* = 2^(-p). Used to estimate roundoff errors. */ +/* A set of coefficients used to calculate maximum roundoff errors. */ +qreal resulterrbound; +qreal ccwerrboundA, ccwerrboundB, ccwerrboundC; +qreal o3derrboundA, o3derrboundB, o3derrboundC; +qreal iccerrboundA, iccerrboundB, iccerrboundC; +qreal isperrboundA, isperrboundB, isperrboundC; + +/*****************************************************************************/ +/* */ +/* exactinit() Initialize the variables used for exact arithmetic. */ +/* */ +/* `epsilon' is the largest power of two such that 1.0 + epsilon = 1.0 in */ +/* floating-point arithmetic. `epsilon' bounds the relative roundoff */ +/* error. It is used for floating-point error analysis. */ +/* */ +/* `splitter' is used to split floating-point numbers into two half- */ +/* length significands for exact multiplication. */ +/* */ +/* I imagine that a highly optimizing compiler might be too smart for its */ +/* own good, and somehow cause this routine to fail, if it pretends that */ +/* floating-point arithmetic is too much like real arithmetic. */ +/* */ +/* Don't change this routine unless you fully understand it. */ +/* */ +/*****************************************************************************/ + +void exactinit() +{ + qreal half; + qreal check, lastcheck; + int every_other; + + every_other = 1; + half = 0.5; + epsilon = 1.0; + splitter = 1.0; + check = 1.0; + /* Repeatedly divide `epsilon' by two until it is too small to add to */ + /* one without causing roundoff. (Also check if the sum is equal to */ + /* the previous sum, for machines that round up instead of using exact */ + /* rounding. Not that this library will work on such machines anyway. */ + do + { + lastcheck = check; + epsilon *= half; + if (every_other) + { + splitter *= 2.0; + } + every_other = !every_other; + check = 1.0 + epsilon; + } while ((check != 1.0) && (check != lastcheck)); + splitter += 1.0; + + /* Error bounds for orientation and incircle tests. */ + resulterrbound = (3.0 + 8.0 * epsilon) * epsilon; + ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon; + ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon; + ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon; + o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon; + o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon; + o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon; + iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon; + iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon; + iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon; + isperrboundA = (16.0 + 224.0 * epsilon) * epsilon; + isperrboundB = (5.0 + 72.0 * epsilon) * epsilon; + isperrboundC = (71.0 + 1408.0 * epsilon) * epsilon * epsilon; +} + +/*****************************************************************************/ +/* */ +/* fast_expansion_sum_zeroelim() Sum two expansions, eliminating zero */ +/* components from the output expansion. */ +/* */ +/* Sets h = e + f. See the long version of my paper for details. */ +/* */ +/* If round-to-even is used (as with IEEE 754), maintains the strongly */ +/* nonoverlapping property. (That is, if e is strongly nonoverlapping, h */ +/* will be also.) Does NOT maintain the nonoverlapping or nonadjacent */ +/* properties. */ +/* */ +/*****************************************************************************/ + +int fast_expansion_sum_zeroelim(int elen, qreal *e, int flen, qreal *f, qreal *h) /* h cannot be e or f. */ +{ + qreal Q; + INEXACT qreal Qnew; + INEXACT qreal hh; + INEXACT qreal bvirt; + qreal avirt, bround, around; + int eindex, findex, hindex; + qreal enow, fnow; + + enow = e[0]; + fnow = f[0]; + eindex = findex = 0; + if ((fnow > enow) == (fnow > -enow)) + { + Q = enow; + enow = e[++eindex]; + } + else + { + Q = fnow; + fnow = f[++findex]; + } + hindex = 0; + if ((eindex < elen) && (findex < flen)) + { + if ((fnow > enow) == (fnow > -enow)) + { + Fast_Two_Sum(enow, Q, Qnew, hh); + enow = e[++eindex]; + } + else + { + Fast_Two_Sum(fnow, Q, Qnew, hh); + fnow = f[++findex]; + } + Q = Qnew; + if (hh != 0.0) + { + h[hindex++] = hh; + } + while ((eindex < elen) && (findex < flen)) + { + if ((fnow > enow) == (fnow > -enow)) + { + Two_Sum(Q, enow, Qnew, hh); + enow = e[++eindex]; + } + else + { + Two_Sum(Q, fnow, Qnew, hh); + fnow = f[++findex]; + } + Q = Qnew; + if (hh != 0.0) + { + h[hindex++] = hh; + } + } + } + while (eindex < elen) + { + Two_Sum(Q, enow, Qnew, hh); + enow = e[++eindex]; + Q = Qnew; + if (hh != 0.0) + { + h[hindex++] = hh; + } + } + while (findex < flen) + { + Two_Sum(Q, fnow, Qnew, hh); + fnow = f[++findex]; + Q = Qnew; + if (hh != 0.0) + { + h[hindex++] = hh; + } + } + if ((Q != 0.0) || (hindex == 0)) + { + h[hindex++] = Q; + } + return hindex; +} + +/*****************************************************************************/ +/* */ +/* scale_expansion_zeroelim() Multiply an expansion by a scalar, */ +/* eliminating zero components from the */ +/* output expansion. */ +/* */ +/* Sets h = be. See either version of my paper for details. */ +/* */ +/* Maintains the nonoverlapping property. If round-to-even is used (as */ +/* with IEEE 754), maintains the strongly nonoverlapping and nonadjacent */ +/* properties as well. (That is, if e has one of these properties, so */ +/* will h.) */ +/* */ +/*****************************************************************************/ + +int scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) /* e and h cannot be the same. */ +{ + INEXACT qreal Q, sum; + qreal hh; + INEXACT qreal product1; + qreal product0; + int eindex, hindex; + qreal enow; + INEXACT qreal bvirt; + qreal avirt, bround, around; + INEXACT qreal c; + INEXACT qreal abig; + qreal ahi, alo, bhi, blo; + qreal err1, err2, err3; + + Split(b, bhi, blo); + Two_Product_Presplit(e[0], b, bhi, blo, Q, hh); + hindex = 0; + if (hh != 0) { + h[hindex++] = hh; + } + for (eindex = 1; eindex < elen; eindex++) + { + enow = e[eindex]; + Two_Product_Presplit(enow, b, bhi, blo, product1, product0); + Two_Sum(Q, product0, sum, hh); + if (hh != 0) + { + h[hindex++] = hh; + } + Fast_Two_Sum(product1, sum, Q, hh); + if (hh != 0) + { + h[hindex++] = hh; + } + } + if ((Q != 0.0) || (hindex == 0)) + { + h[hindex++] = Q; + } + return hindex; +} + +/*****************************************************************************/ +/* */ +/* estimate() Produce a one-word estimate of an expansion's value. */ +/* */ +/* See either version of my paper for details. */ +/* */ +/*****************************************************************************/ + +qreal estimate(int elen, qreal *e) +{ + qreal Q; + int eindex; + + Q = e[0]; + for (eindex = 1; eindex < elen; eindex++) + { + Q += e[eindex]; + } + return Q; +} + +qreal incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent) +{ + INEXACT qreal adx, bdx, cdx, ady, bdy, cdy; + qreal det, errbound; + + INEXACT qreal bdxcdy1, cdxbdy1, cdxady1, adxcdy1, adxbdy1, bdxady1; + qreal bdxcdy0, cdxbdy0, cdxady0, adxcdy0, adxbdy0, bdxady0; + qreal bc[4], ca[4], ab[4]; + INEXACT qreal bc3, ca3, ab3; + qreal axbc[8], axxbc[16], aybc[8], ayybc[16], adet[32]; + int axbclen, axxbclen, aybclen, ayybclen, alen; + qreal bxca[8], bxxca[16], byca[8], byyca[16], bdet[32]; + int bxcalen, bxxcalen, bycalen, byycalen, blen; + qreal cxab[8], cxxab[16], cyab[8], cyyab[16], cdet[32]; + int cxablen, cxxablen, cyablen, cyyablen, clen; + qreal abdet[64]; + int ablen; + qreal fin1[1152], fin2[1152]; + qreal *finnow, *finother, *finswap; + int finlength; + + qreal adxtail, bdxtail, cdxtail, adytail, bdytail, cdytail; + INEXACT qreal adxadx1, adyady1, bdxbdx1, bdybdy1, cdxcdx1, cdycdy1; + qreal adxadx0, adyady0, bdxbdx0, bdybdy0, cdxcdx0, cdycdy0; + qreal aa[4], bb[4], cc[4]; + INEXACT qreal aa3, bb3, cc3; + INEXACT qreal ti1, tj1; + qreal ti0, tj0; + qreal u[4], v[4]; + INEXACT qreal u3, v3; + qreal temp8[8], temp16a[16], temp16b[16], temp16c[16]; + qreal temp32a[32], temp32b[32], temp48[48], temp64[64]; + int temp8len, temp16alen, temp16blen, temp16clen; + int temp32alen, temp32blen, temp48len, temp64len; + qreal axtbb[8], axtcc[8], aytbb[8], aytcc[8]; + int axtbblen, axtcclen, aytbblen, aytcclen; + qreal bxtaa[8], bxtcc[8], bytaa[8], bytcc[8]; + int bxtaalen, bxtcclen, bytaalen, bytcclen; + qreal cxtaa[8], cxtbb[8], cytaa[8], cytbb[8]; + int cxtaalen, cxtbblen, cytaalen, cytbblen; + qreal axtbc[8], aytbc[8], bxtca[8], bytca[8], cxtab[8], cytab[8]; + int axtbclen, aytbclen, bxtcalen, bytcalen, cxtablen, cytablen; + qreal axtbct[16], aytbct[16], bxtcat[16], bytcat[16], cxtabt[16], cytabt[16]; + int axtbctlen, aytbctlen, bxtcatlen, bytcatlen, cxtabtlen, cytabtlen; + qreal axtbctt[8], aytbctt[8], bxtcatt[8]; + qreal bytcatt[8], cxtabtt[8], cytabtt[8]; + int axtbcttlen, aytbcttlen, bxtcattlen, bytcattlen, cxtabttlen, cytabttlen; + qreal abt[8], bct[8], cat[8]; + int abtlen, bctlen, catlen; + qreal abtt[4], bctt[4], catt[4]; + int abttlen, bcttlen, cattlen; + INEXACT qreal abtt3, bctt3, catt3; + qreal negate; + + INEXACT qreal bvirt; + qreal avirt, bround, around; + INEXACT qreal c; + INEXACT qreal abig; + qreal ahi, alo, bhi, blo; + qreal err1, err2, err3; + INEXACT qreal _i, _j; + qreal _0; + + adx = (qreal) (pa[0] - pd[0]); + bdx = (qreal) (pb[0] - pd[0]); + cdx = (qreal) (pc[0] - pd[0]); + ady = (qreal) (pa[1] - pd[1]); + bdy = (qreal) (pb[1] - pd[1]); + cdy = (qreal) (pc[1] - pd[1]); + + Two_Product(bdx, cdy, bdxcdy1, bdxcdy0); + Two_Product(cdx, bdy, cdxbdy1, cdxbdy0); + Two_Two_Diff(bdxcdy1, bdxcdy0, cdxbdy1, cdxbdy0, bc3, bc[2], bc[1], bc[0]); + bc[3] = bc3; + axbclen = scale_expansion_zeroelim(4, bc, adx, axbc); + axxbclen = scale_expansion_zeroelim(axbclen, axbc, adx, axxbc); + aybclen = scale_expansion_zeroelim(4, bc, ady, aybc); + ayybclen = scale_expansion_zeroelim(aybclen, aybc, ady, ayybc); + alen = fast_expansion_sum_zeroelim(axxbclen, axxbc, ayybclen, ayybc, adet); + + Two_Product(cdx, ady, cdxady1, cdxady0); + Two_Product(adx, cdy, adxcdy1, adxcdy0); + Two_Two_Diff(cdxady1, cdxady0, adxcdy1, adxcdy0, ca3, ca[2], ca[1], ca[0]); + ca[3] = ca3; + bxcalen = scale_expansion_zeroelim(4, ca, bdx, bxca); + bxxcalen = scale_expansion_zeroelim(bxcalen, bxca, bdx, bxxca); + bycalen = scale_expansion_zeroelim(4, ca, bdy, byca); + byycalen = scale_expansion_zeroelim(bycalen, byca, bdy, byyca); + blen = fast_expansion_sum_zeroelim(bxxcalen, bxxca, byycalen, byyca, bdet); + + Two_Product(adx, bdy, adxbdy1, adxbdy0); + Two_Product(bdx, ady, bdxady1, bdxady0); + Two_Two_Diff(adxbdy1, adxbdy0, bdxady1, bdxady0, ab3, ab[2], ab[1], ab[0]); + ab[3] = ab3; + cxablen = scale_expansion_zeroelim(4, ab, cdx, cxab); + cxxablen = scale_expansion_zeroelim(cxablen, cxab, cdx, cxxab); + cyablen = scale_expansion_zeroelim(4, ab, cdy, cyab); + cyyablen = scale_expansion_zeroelim(cyablen, cyab, cdy, cyyab); + clen = fast_expansion_sum_zeroelim(cxxablen, cxxab, cyyablen, cyyab, cdet); + + ablen = fast_expansion_sum_zeroelim(alen, adet, blen, bdet, abdet); + finlength = fast_expansion_sum_zeroelim(ablen, abdet, clen, cdet, fin1); + + det = estimate(finlength, fin1); + errbound = iccerrboundB * permanent; + if ((det >= errbound) || (-det >= errbound)) + { + return det; + } + + Two_Diff_Tail(pa[0], pd[0], adx, adxtail); + Two_Diff_Tail(pa[1], pd[1], ady, adytail); + Two_Diff_Tail(pb[0], pd[0], bdx, bdxtail); + Two_Diff_Tail(pb[1], pd[1], bdy, bdytail); + Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail); + Two_Diff_Tail(pc[1], pd[1], cdy, cdytail); + if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) + && (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0)) + { + return det; + } + + errbound = iccerrboundC * permanent + resulterrbound * Absolute(det); + det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail)) + + 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx)) + + ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail)) + + 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx)) + + ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail)) + + 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx)); + if ((det >= errbound) || (-det >= errbound)) + { + return det; + } + + finnow = fin1; + finother = fin2; + + if ((bdxtail != 0.0) || (bdytail != 0.0) || (cdxtail != 0.0) || (cdytail != 0.0)) + { + Square(adx, adxadx1, adxadx0); + Square(ady, adyady1, adyady0); + Two_Two_Sum(adxadx1, adxadx0, adyady1, adyady0, aa3, aa[2], aa[1], aa[0]); + aa[3] = aa3; + } + if ((cdxtail != 0.0) || (cdytail != 0.0) || (adxtail != 0.0) || (adytail != 0.0)) + { + Square(bdx, bdxbdx1, bdxbdx0); + Square(bdy, bdybdy1, bdybdy0); + Two_Two_Sum(bdxbdx1, bdxbdx0, bdybdy1, bdybdy0, bb3, bb[2], bb[1], bb[0]); + bb[3] = bb3; + } + if ((adxtail != 0.0) || (adytail != 0.0) || (bdxtail != 0.0) || (bdytail != 0.0)) + { + Square(cdx, cdxcdx1, cdxcdx0); + Square(cdy, cdycdy1, cdycdy0); + Two_Two_Sum(cdxcdx1, cdxcdx0, cdycdy1, cdycdy0, cc3, cc[2], cc[1], cc[0]); + cc[3] = cc3; + } + + if (adxtail != 0.0) + { + axtbclen = scale_expansion_zeroelim(4, bc, adxtail, axtbc); + temp16alen = scale_expansion_zeroelim(axtbclen, axtbc, 2.0 * adx, temp16a); + + axtcclen = scale_expansion_zeroelim(4, cc, adxtail, axtcc); + temp16blen = scale_expansion_zeroelim(axtcclen, axtcc, bdy, temp16b); + + axtbblen = scale_expansion_zeroelim(4, bb, adxtail, axtbb); + temp16clen = scale_expansion_zeroelim(axtbblen, axtbb, -cdy, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (adytail != 0.0) + { + aytbclen = scale_expansion_zeroelim(4, bc, adytail, aytbc); + temp16alen = scale_expansion_zeroelim(aytbclen, aytbc, 2.0 * ady, temp16a); + + aytbblen = scale_expansion_zeroelim(4, bb, adytail, aytbb); + temp16blen = scale_expansion_zeroelim(aytbblen, aytbb, cdx, temp16b); + + aytcclen = scale_expansion_zeroelim(4, cc, adytail, aytcc); + temp16clen = scale_expansion_zeroelim(aytcclen, aytcc, -bdx, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (bdxtail != 0.0) + { + bxtcalen = scale_expansion_zeroelim(4, ca, bdxtail, bxtca); + temp16alen = scale_expansion_zeroelim(bxtcalen, bxtca, 2.0 * bdx, temp16a); + + bxtaalen = scale_expansion_zeroelim(4, aa, bdxtail, bxtaa); + temp16blen = scale_expansion_zeroelim(bxtaalen, bxtaa, cdy, temp16b); + + bxtcclen = scale_expansion_zeroelim(4, cc, bdxtail, bxtcc); + temp16clen = scale_expansion_zeroelim(bxtcclen, bxtcc, -ady, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (bdytail != 0.0) + { + bytcalen = scale_expansion_zeroelim(4, ca, bdytail, bytca); + temp16alen = scale_expansion_zeroelim(bytcalen, bytca, 2.0 * bdy, temp16a); + + bytcclen = scale_expansion_zeroelim(4, cc, bdytail, bytcc); + temp16blen = scale_expansion_zeroelim(bytcclen, bytcc, adx, temp16b); + + bytaalen = scale_expansion_zeroelim(4, aa, bdytail, bytaa); + temp16clen = scale_expansion_zeroelim(bytaalen, bytaa, -cdx, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (cdxtail != 0.0) + { + cxtablen = scale_expansion_zeroelim(4, ab, cdxtail, cxtab); + temp16alen = scale_expansion_zeroelim(cxtablen, cxtab, 2.0 * cdx, temp16a); + + cxtbblen = scale_expansion_zeroelim(4, bb, cdxtail, cxtbb); + temp16blen = scale_expansion_zeroelim(cxtbblen, cxtbb, ady, temp16b); + + cxtaalen = scale_expansion_zeroelim(4, aa, cdxtail, cxtaa); + temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, + temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, + temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, + temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (cdytail != 0.0) + { + cytablen = scale_expansion_zeroelim(4, ab, cdytail, cytab); + temp16alen = scale_expansion_zeroelim(cytablen, cytab, 2.0 * cdy, temp16a); + + cytaalen = scale_expansion_zeroelim(4, aa, cdytail, cytaa); + temp16blen = scale_expansion_zeroelim(cytaalen, cytaa, bdx, temp16b); + + cytbblen = scale_expansion_zeroelim(4, bb, cdytail, cytbb); + temp16clen = scale_expansion_zeroelim(cytbblen, cytbb, -adx, temp16c); + + temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + + if ((adxtail != 0.0) || (adytail != 0.0)) + { + if ((bdxtail != 0.0) || (bdytail != 0.0) || (cdxtail != 0.0) || (cdytail != 0.0)) + { + Two_Product(bdxtail, cdy, ti1, ti0); + Two_Product(bdx, cdytail, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); + u[3] = u3; + negate = -bdy; + Two_Product(cdxtail, negate, ti1, ti0); + negate = -bdytail; + Two_Product(cdx, negate, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); + v[3] = v3; + bctlen = fast_expansion_sum_zeroelim(4, u, 4, v, bct); + + Two_Product(bdxtail, cdytail, ti1, ti0); + Two_Product(cdxtail, bdytail, tj1, tj0); + Two_Two_Diff(ti1, ti0, tj1, tj0, bctt3, bctt[2], bctt[1], bctt[0]); + bctt[3] = bctt3; + bcttlen = 4; + } + else + { + bct[0] = 0.0; + bctlen = 1; + bctt[0] = 0.0; + bcttlen = 1; + } + + if (adxtail != 0.0) + { + temp16alen = scale_expansion_zeroelim(axtbclen, axtbc, adxtail, temp16a); + axtbctlen = scale_expansion_zeroelim(bctlen, bct, adxtail, axtbct); + temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, 2.0 * adx, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + if (bdytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (cdytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + + temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, adxtail, temp32a); + axtbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adxtail, axtbctt); + temp16alen = scale_expansion_zeroelim(axtbcttlen, axtbctt, 2.0 * adx, temp16a); + temp16blen = scale_expansion_zeroelim(axtbcttlen, axtbctt, adxtail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (adytail != 0.0) + { + temp16alen = scale_expansion_zeroelim(aytbclen, aytbc, adytail, temp16a); + aytbctlen = scale_expansion_zeroelim(bctlen, bct, adytail, aytbct); + temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, 2.0 * ady, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; finnow = finother; finother = finswap; + + + temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, adytail, temp32a); + aytbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adytail, aytbctt); + temp16alen = scale_expansion_zeroelim(aytbcttlen, aytbctt, 2.0 * ady, temp16a); + temp16blen = scale_expansion_zeroelim(aytbcttlen, aytbctt, adytail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + } + if ((bdxtail != 0.0) || (bdytail != 0.0)) + { + if ((cdxtail != 0.0) || (cdytail != 0.0) || (adxtail != 0.0) || (adytail != 0.0)) + { + Two_Product(cdxtail, ady, ti1, ti0); + Two_Product(cdx, adytail, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); + u[3] = u3; + negate = -cdy; + Two_Product(adxtail, negate, ti1, ti0); + negate = -cdytail; + Two_Product(adx, negate, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); + v[3] = v3; + catlen = fast_expansion_sum_zeroelim(4, u, 4, v, cat); + + Two_Product(cdxtail, adytail, ti1, ti0); + Two_Product(adxtail, cdytail, tj1, tj0); + Two_Two_Diff(ti1, ti0, tj1, tj0, catt3, catt[2], catt[1], catt[0]); + catt[3] = catt3; + cattlen = 4; + } + else + { + cat[0] = 0.0; + catlen = 1; + catt[0] = 0.0; + cattlen = 1; + } + + if (bdxtail != 0.0) + { + temp16alen = scale_expansion_zeroelim(bxtcalen, bxtca, bdxtail, temp16a); + bxtcatlen = scale_expansion_zeroelim(catlen, cat, bdxtail, bxtcat); + temp32alen = scale_expansion_zeroelim(bxtcatlen, bxtcat, 2.0 * bdx, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + if (cdytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, aa, bdxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + } + if (adytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, cc, -bdxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, adytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + } + + temp32alen = scale_expansion_zeroelim(bxtcatlen, bxtcat, bdxtail, temp32a); + bxtcattlen = scale_expansion_zeroelim(cattlen, catt, bdxtail, bxtcatt); + temp16alen = scale_expansion_zeroelim(bxtcattlen, bxtcatt, 2.0 * bdx, temp16a); + temp16blen = scale_expansion_zeroelim(bxtcattlen, bxtcatt, bdxtail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + if (bdytail != 0.0) + { + temp16alen = scale_expansion_zeroelim(bytcalen, bytca, bdytail, temp16a); + bytcatlen = scale_expansion_zeroelim(catlen, cat, bdytail, bytcat); + temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, 2.0 * bdy, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + + + temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, temp32a); + bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt); + temp16alen = scale_expansion_zeroelim(bytcattlen, bytcatt, 2.0 * bdy, temp16a); + temp16blen = scale_expansion_zeroelim(bytcattlen, bytcatt, bdytail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + } + } + if ((cdxtail != 0.0) || (cdytail != 0.0)) + { + if ((adxtail != 0.0) || (adytail != 0.0) || (bdxtail != 0.0) || (bdytail != 0.0)) + { + Two_Product(adxtail, bdy, ti1, ti0); + Two_Product(adx, bdytail, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); + u[3] = u3; + negate = -ady; + Two_Product(bdxtail, negate, ti1, ti0); + negate = -adytail; + Two_Product(bdx, negate, tj1, tj0); + Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); + v[3] = v3; + abtlen = fast_expansion_sum_zeroelim(4, u, 4, v, abt); + + Two_Product(adxtail, bdytail, ti1, ti0); + Two_Product(bdxtail, adytail, tj1, tj0); + Two_Two_Diff(ti1, ti0, tj1, tj0, abtt3, abtt[2], abtt[1], abtt[0]); + abtt[3] = abtt3; + abttlen = 4; + } + else + { + abt[0] = 0.0; + abtlen = 1; + abtt[0] = 0.0; + abttlen = 1; + } + + if (cdxtail != 0.0) + { + temp16alen = scale_expansion_zeroelim(cxtablen, cxtab, cdxtail, temp16a); + cxtabtlen = scale_expansion_zeroelim(abtlen, abt, cdxtail, cxtabt); + temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, 2.0 * cdx, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + if (adytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, bb, cdxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, adytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + } + if (bdytail != 0.0) + { + temp8len = scale_expansion_zeroelim(4, aa, -cdxtail, temp8); + temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + + temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, cdxtail, temp32a); + cxtabttlen = scale_expansion_zeroelim(abttlen, abtt, cdxtail, cxtabtt); + temp16alen = scale_expansion_zeroelim(cxtabttlen, cxtabtt, 2.0 * cdx, temp16a); + temp16blen = scale_expansion_zeroelim(cxtabttlen, cxtabtt, cdxtail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + } + if (cdytail != 0.0) + { + temp16alen = scale_expansion_zeroelim(cytablen, cytab, cdytail, temp16a); + cytabtlen = scale_expansion_zeroelim(abtlen, abt, cdytail, cytabt); + temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, 2.0 * cdy, temp32a); + temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother); + finswap = finnow; + finnow = finother; + finother = finswap; + + + temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, temp32a); + cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt); + temp16alen = scale_expansion_zeroelim(cytabttlen, cytabtt, 2.0 * cdy, temp16a); + temp16blen = scale_expansion_zeroelim(cytabttlen, cytabtt, cdytail, temp16b); + temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b); + temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64); + finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother); + finswap = finnow; finnow = finother; finother = finswap; + } + } + + return finnow[finlength - 1]; +} + +qreal incircle(qreal *pa, qreal *pb, qreal *pc, qreal *pd) +{ + qreal adx, bdx, cdx, ady, bdy, cdy; + qreal bdxcdy, cdxbdy, cdxady, adxcdy, adxbdy, bdxady; + qreal alift, blift, clift; + qreal det; + qreal permanent, errbound; + + adx = pa[0] - pd[0]; + bdx = pb[0] - pd[0]; + cdx = pc[0] - pd[0]; + ady = pa[1] - pd[1]; + bdy = pb[1] - pd[1]; + cdy = pc[1] - pd[1]; + + bdxcdy = bdx * cdy; + cdxbdy = cdx * bdy; + alift = adx * adx + ady * ady; + + cdxady = cdx * ady; + adxcdy = adx * cdy; + blift = bdx * bdx + bdy * bdy; + + adxbdy = adx * bdy; + bdxady = bdx * ady; + clift = cdx * cdx + cdy * cdy; + + det = alift * (bdxcdy - cdxbdy) + + blift * (cdxady - adxcdy) + + clift * (adxbdy - bdxady); + + permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift + + (Absolute(cdxady) + Absolute(adxcdy)) * blift + + (Absolute(adxbdy) + Absolute(bdxady)) * clift; + errbound = iccerrboundA * permanent; + if ((det > errbound) || (-det > errbound)) + { + return det; + } + + return incircleadapt(pa, pb, pc, pd, permanent); +} diff --git a/src/libs/vobj/stable.cpp b/src/libs/vobj/stable.cpp new file mode 100644 index 000000000..877ab2ddf --- /dev/null +++ b/src/libs/vobj/stable.cpp @@ -0,0 +1,30 @@ +/************************************************************************ + ** + ** @file stable.cpp + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @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 + ** 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 . + ** + *************************************************************************/ + +// Build the precompiled headers. +#include "stable.h" diff --git a/src/geometry/vsplinepoint.cpp b/src/libs/vobj/stable.h similarity index 66% rename from src/geometry/vsplinepoint.cpp rename to src/libs/vobj/stable.h index e57a7363a..adb5eed9f 100644 --- a/src/geometry/vsplinepoint.cpp +++ b/src/libs/vobj/stable.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file vsplinepoint.cpp - ** @author Roman Telezhinsky - ** @date November 15, 2013 + ** @file stable.h + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 ** ** @brief ** @copyright @@ -26,13 +26,27 @@ ** *************************************************************************/ -#include "vsplinepoint.h" +#ifndef STABLE_H +#define STABLE_H -VSplinePoint::VSplinePoint() - :pSpline(0), angle(0), kAsm1(1), kAsm2(1){} +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for VObj library.\n") +#endif -VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2) - :pSpline(pSpline), angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){} +/* Add C includes here */ -VSplinePoint::VSplinePoint(const VSplinePoint &point) - :pSpline(point.P()), angle(point.Angle2()), kAsm1(point.KAsm1()), kAsm2(point.KAsm2()){} +#if defined __cplusplus +/* Add C++ includes here */ + +#ifdef QT_CORE_LIB +#include +#endif + +#ifdef QT_GUI_LIB +# include +#endif + +#endif/*__cplusplus*/ + +#endif // STABLE_H diff --git a/src/libs/vobj/vobj.pri b/src/libs/vobj/vobj.pri new file mode 100644 index 000000000..15faf94a1 --- /dev/null +++ b/src/libs/vobj/vobj.pri @@ -0,0 +1,15 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +SOURCES += \ + $$PWD/vobjengine.cpp \ + $$PWD/delaunay.c \ + $$PWD/predicates.c \ + $$PWD/vobjpaintdevice.cpp \ + $$PWD/stable.cpp + +HEADERS += \ + $$PWD/vobjengine.h \ + $$PWD/delaunay.h \ + $$PWD/vobjpaintdevice.h \ + $$PWD/stable.h diff --git a/src/libs/vobj/vobj.pro b/src/libs/vobj/vobj.pro new file mode 100644 index 000000000..db7ed3ff9 --- /dev/null +++ b/src/libs/vobj/vobj.pro @@ -0,0 +1,87 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-12-12T14:55:06 +# +#------------------------------------------------- + +# File with common stuff for whole project +include(../../../Valentina.pri) + +# Name of library +TARGET = vobj + +# We want create a library +TEMPLATE = lib + +CONFIG += \ + staticlib \# Making static library + c++11 # We use C++11 standard + +# Use out-of-source builds (shadow builds) +CONFIG -= debug_and_release debug_and_release_target + +# Since Qt 5.4.0 the source code location is recorded only in debug builds. +# We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT. +DEFINES += QT_MESSAGELOGCONTEXT + +include(vobj.pri) + +# This is static library so no need in "make install" + +# directory for executable file +DESTDIR = bin + +# files created moc +MOC_DIR = moc + +# objecs files +OBJECTS_DIR = obj + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +$$enable_ccache() + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +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}/$${MOC_DIR}" \ + $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + #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_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}/$${MOC_DIR}" \ + $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + +}else{ + # Release mode + + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + !macx:!win32-msvc*{ + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. TODO: find way how to strip binary file. + QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_LFLAGS_RELEASE = + } +} diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp new file mode 100644 index 000000000..ee1536355 --- /dev/null +++ b/src/libs/vobj/vobjengine.cpp @@ -0,0 +1,343 @@ +/************************************************************************ + ** + ** @file vobjengine.cpp + ** @author Roman Telezhynskyi + ** @date 12 12, 2014 + ** + ** @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) 2014 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 "vobjengine.h" + +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() +{ + return QPaintEngine::PaintEngineFeatures( + QPaintEngine::AllFeatures + & ~QPaintEngine::PatternBrush + & ~QPaintEngine::PerspectiveTransform + & ~QPaintEngine::ConicalGradientFill + & ~QPaintEngine::PorterDuff); +} + +//--------------------------------------------------------------------------------------------------------------------- +VObjEngine::VObjEngine() + :QPaintEngine(svgEngineFeatures()), stream(nullptr), globalPointsCount(0), outputDevice(nullptr), planeCount(0), + size(), resolution(96), matrix() +{ + for(int i=0; i < MAX_POINTS; i++) + { + points[i].x = 0; + points[i].y = 0; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VObjEngine::~VObjEngine() +{ + outputDevice = nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VObjEngine::begin(QPaintDevice *pdev) +{ + Q_UNUSED(pdev) + if (outputDevice == nullptr) + { + qWarning("VObjEngine::begin(), no output device"); + return false; + } + if (outputDevice->isOpen() == false) + { + if (outputDevice->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate) == false) + { + qWarning("VObjEngine::begin(), could not open output device: '%s'", + qPrintable(outputDevice->errorString())); + return false; + } + } + else if (outputDevice->isWritable() == false) + { + qWarning("VObjEngine::begin(), could not write to read-only output device: '%s'", + qPrintable(outputDevice->errorString())); + return false; + } + + if (size.isValid() == false) + { + qWarning()<<"VObjEngine::begin(), size is not valid"; + return false; + } + + stream = new QTextStream(outputDevice); + *stream << "# Valentina OBJ File" << endl; + *stream << "# www.valentina-project.org/" << endl; + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VObjEngine::end() +{ + delete stream; + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::updateState(const QPaintEngineState &state) +{ + QPaintEngine::DirtyFlags flags = state.state(); + + // always stream full gstate, which is not required, but... + flags |= QPaintEngine::AllDirty; + + + if (flags & QPaintEngine::DirtyTransform) + { + matrix = state.matrix(); // Save new matrix for moving paths + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::drawPath(const QPainterPath &path) +{ + QPolygonF polygon = path.toFillPolygon(matrix); + polygon = MakePointsUnique(polygon);// Points must be unique + if (polygon.size() < 3) + { + return; + } + + qint64 sq = Square(polygon); + + ++planeCount; + *stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << endl; + + unsigned int num_points = 0; + + for(int i=0; i < polygon.count(); i++) + { + if( num_points < MAX_POINTS ) + { + points[num_points].x = polygon.at(i).x(); + points[num_points].y = polygon.at(i).y(); + num_points++; + } + } + + int offset = 0; + delaunay2d_t *res = delaunay2d_from(points, num_points);//Calculate faces + + QPointF pf[MAX_POINTS]; + bool skipFace=false;//Need skip first face + + for(unsigned int i = 0; i < res->num_faces; i++ ) + { + if (offset == 0) + { + skipFace=true; + } + else + { + skipFace=false; + } + int num_verts = res->faces[offset]; + offset++; + for( int j = 0; j < num_verts; j++ ) + { + int p0 = res->faces[offset + j]; + pf[j] = QPointF(points[p0].x, points[p0].y); + } + if (skipFace == false ) + { + QPolygonF face; + for( int i = 0; i < num_verts; i++ ) + { + face << QPointF(pf[i]); + } + QPolygonF united = polygon.united(face); + qint64 sqUnited = Square(united); + if(sqUnited <= sq) + {// This face incide our base polygon. + drawPolygon(pf, num_verts, QPaintEngine::OddEvenMode); + } + } + offset += num_verts; + } + + delaunay2d_release(res);//Don't forget release data + *stream << "s off" << endl; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) +{ + Q_UNUSED(mode) + + drawPoints(points, pointCount); + *stream << "f"; + + for (int i = 0; i < pointCount; ++i) + { + *stream << QString(" %1").arg(globalPointsCount - pointCount + i + 1); + } + *stream << endl; +} + +void VObjEngine::drawPolygon(const QPoint *points, int pointCount, QPaintEngine::PolygonDrawMode mode) +{ + QPaintEngine::drawPolygon(points, pointCount, mode); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPaintEngine::Type VObjEngine::type() const +{ + return QPaintEngine::User; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::drawPoints(const QPointF *points, int pointCount) +{ + for (int i = 0; i < pointCount; ++i) + { + qreal x = ((points[i].x() - 0)/qFloor(size.width()/2.0)) - 1.0; + qreal y = (((points[i].y() - 0)/qFloor(size.width()/2.0)) - 1.0)*-1; + + *stream << "v" << " " << QString::number(x, 'f', 6 ) << " " << QString::number(y, 'f', 6 ) << " " + << "0.000000" << endl; + ++globalPointsCount; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::drawPoints(const QPoint *points, int pointCount) +{ + QPaintEngine::drawPoints(points, pointCount); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) +{ + Q_UNUSED(r) + Q_UNUSED(pm) + Q_UNUSED(sr) +} + +//--------------------------------------------------------------------------------------------------------------------- +QSize VObjEngine::getSize() const +{ + return size; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::setSize(const QSize &value) +{ + Q_ASSERT(!isActive()); + size = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QIODevice *VObjEngine::getOutputDevice() const +{ + return outputDevice; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::setOutputDevice(QIODevice *value) +{ + Q_ASSERT(!isActive()); + outputDevice = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VObjEngine::getResolution() const +{ + return resolution; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjEngine::setResolution(int value) +{ + Q_ASSERT(!isActive()); + resolution = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPolygonF VObjEngine::MakePointsUnique(const QPolygonF &polygon) const +{ + QVector set; + QPolygonF uniquePolygon; + for(int i=0; i < polygon.count(); i++) + { + if (set.contains(polygon.at(i)) == false) + { + set.append(polygon.at(i)); + uniquePolygon.append(polygon.at(i)); + } + } + return uniquePolygon; +} + +//--------------------------------------------------------------------------------------------------------------------- +qint64 VObjEngine::Square(const QPolygonF &poly) const +{ + QVector x; + QVector y; + + int n = poly.count(); + qreal s, res = 0; + qint64 sq = 0; + + for(int i=0; i < n; i++) + { + x.append(poly.at(i).x()); + y.append(poly.at(i).y()); + } + + // Calculation a polygon area through the sum of the areas of trapezoids + for (int i = 0; i < n; i++) + { + if (i == 0) + { + s = x.at(i)*(y.at(n-1) - y.at(i+1)); //if i == 0, then y[i-1] replace on y[n-1] + res += s; + } + else + { + if (i == n-1) + { + s = x.at(i)*(y.at(i-1) - y.at(0)); // if i == n-1, then y[i+1] replace on y[0] + res += s; + } + else + { + s = x.at(i)*(y.at(i-1) - y.at(i+1)); + res += s; + } + } + } + sq = qFloor(qAbs(res/2.0)); + return sq; +} diff --git a/src/libs/vobj/vobjengine.h b/src/libs/vobj/vobjengine.h new file mode 100644 index 000000000..52e71055a --- /dev/null +++ b/src/libs/vobj/vobjengine.h @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file vobjengine.h + ** @author Roman Telezhynskyi + ** @date 12 12, 2014 + ** + ** @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) 2014 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 VOBJENGINE_H +#define VOBJENGINE_H + +#include +#include "delaunay.h" + +class QTextStream; + +#define MAX_POINTS 512 + +class VObjEngine : public QPaintEngine +{ +public: + VObjEngine(); + virtual ~VObjEngine(); + + virtual bool begin(QPaintDevice *pdev); + virtual bool end(); + virtual void updateState(const QPaintEngineState &state); + virtual void drawPath(const QPainterPath &path); + virtual Type type() const; + virtual void drawPoints(const QPointF *points, int pointCount); + virtual void drawPoints(const QPoint *points, int pointCount); + virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); + virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); + virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); + + QSize getSize() const; + void setSize(const QSize &value); + + QIODevice *getOutputDevice() const; + void setOutputDevice(QIODevice *value); + + int getResolution() const; + void setResolution(int value); + +private: + Q_DISABLE_COPY(VObjEngine) + QTextStream *stream; + unsigned int globalPointsCount; + QIODevice *outputDevice; + del_point2d_t points[MAX_POINTS]; + unsigned int planeCount; + QSize size; + int resolution; + QMatrix matrix; + + QPolygonF MakePointsUnique(const QPolygonF &polygon)const; + qint64 Square(const QPolygonF &poly)const; +}; + +#endif // VOBJENGINE_H diff --git a/src/libs/vobj/vobjpaintdevice.cpp b/src/libs/vobj/vobjpaintdevice.cpp new file mode 100644 index 000000000..0b248b48d --- /dev/null +++ b/src/libs/vobj/vobjpaintdevice.cpp @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file vobjpaintdevice.cpp + ** @author Roman Telezhynskyi + ** @date 6 12, 2014 + ** + ** @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) 2014 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 "vobjpaintdevice.h" +#include "vobjengine.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VObjPaintDevice::VObjPaintDevice() + :QPaintDevice(), engine(new VObjEngine()), fileName(), owns_iodevice(1) +{ + owns_iodevice = false; +} + +//--------------------------------------------------------------------------------------------------------------------- +VObjPaintDevice::~VObjPaintDevice() +{ + if (owns_iodevice) + { + delete engine->getOutputDevice(); + } + delete engine; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPaintEngine *VObjPaintDevice::paintEngine() const +{ + return engine; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VObjPaintDevice::getFileName() const +{ + return fileName; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjPaintDevice::setFileName(const QString &value) +{ + if (engine->isActive()) + { + qWarning("VObjPaintDevice::setFileName(), cannot set file name while OBJ is being generated"); + return; + } + + if (owns_iodevice) + { + delete engine->getOutputDevice(); + } + + owns_iodevice = true; + + fileName = value; + QFile *file = new QFile(fileName); + engine->setOutputDevice(file); +} + +//--------------------------------------------------------------------------------------------------------------------- +QSize VObjPaintDevice::getSize() +{ + return engine->getSize(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjPaintDevice::setSize(const QSize &size) +{ + if (engine->isActive()) + { + qWarning("VObjPaintDevice::setSize(), cannot set size while OBJ is being generated"); + return; + } + engine->setSize(size); +} + +//--------------------------------------------------------------------------------------------------------------------- +QIODevice *VObjPaintDevice::getOutputDevice() +{ + return engine->getOutputDevice(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjPaintDevice::setOutputDevice(QIODevice *outputDevice) +{ + if (engine->isActive()) + { + qWarning("VObjPaintDevice::setOutputDevice(), cannot set output device while OBJ is being generated"); + return; + } + owns_iodevice = false; + engine->setOutputDevice(outputDevice); + fileName = QString(); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VObjPaintDevice::getResolution() const +{ + return engine->getResolution(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VObjPaintDevice::setResolution(int dpi) +{ + engine->setResolution(dpi); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const +{ + switch (metric) + { + case QPaintDevice::PdmDepth: + return 32; + case QPaintDevice::PdmWidth: + return engine->getSize().width(); + case QPaintDevice::PdmHeight: + return engine->getSize().height(); + case QPaintDevice::PdmDpiX: + return engine->getResolution(); + case QPaintDevice::PdmDpiY: + return engine->getResolution(); + case QPaintDevice::PdmHeightMM: + return qRound(engine->getSize().height() * 25.4 / engine->getResolution()); + case QPaintDevice::PdmWidthMM: + return qRound(engine->getSize().width() * 25.4 / engine->getResolution()); + case QPaintDevice::PdmNumColors: + return 0xffffffff; + case QPaintDevice::PdmPhysicalDpiX: + return engine->getResolution(); + case QPaintDevice::PdmPhysicalDpiY: + return engine->getResolution(); + default: + qWarning("VObjPaintDevice::metric(), unhandled metric %d\n", metric); + break; + } + return 0; +} + + diff --git a/src/libs/vobj/vobjpaintdevice.h b/src/libs/vobj/vobjpaintdevice.h new file mode 100644 index 000000000..365a6da7a --- /dev/null +++ b/src/libs/vobj/vobjpaintdevice.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vobjpaintdevice.h + ** @author Roman Telezhynskyi + ** @date 6 12, 2014 + ** + ** @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) 2014 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 VOBJPAINTDEVICE_H +#define VOBJPAINTDEVICE_H + +#include +#include + +class VObjEngine; +class QIODevice; + +class VObjPaintDevice : public QPaintDevice +{ +public: + VObjPaintDevice(); + virtual ~VObjPaintDevice(); + virtual QPaintEngine *paintEngine() const; + + QString getFileName() const; + void setFileName(const QString &value); + + QSize getSize(); + void setSize(const QSize &size); + + QIODevice *getOutputDevice(); + void setOutputDevice(QIODevice *outputDevice); + + int getResolution() const; + void setResolution(int dpi); + +protected: + virtual int metric(PaintDeviceMetric metric) const; +private: + Q_DISABLE_COPY(VObjPaintDevice) + VObjEngine *engine; + QString fileName; + uint owns_iodevice; +}; + +#endif // VOBJPAINTDEVICE_H diff --git a/src/libs/vpropertyexplorer/LICENSE.txt b/src/libs/vpropertyexplorer/LICENSE.txt new file mode 100644 index 000000000..65c5ca88a --- /dev/null +++ b/src/libs/vpropertyexplorer/LICENSE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp new file mode 100644 index 000000000..f462a1685 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp @@ -0,0 +1,143 @@ +/************************************************************************ + ** + ** @file vvector3dproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vvector3dproperty.h" + +using namespace VPE; + +#include "../../vproperty_p.h" +#include "../vnumberproperty.h" +#include + +QVector3DProperty::QVector3DProperty(const QString& name) + : VProperty(name, QVariant::String) // todo: QVariant::Vector3D?? +{ + QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double); + VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false); + VDoubleProperty* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false); + VDoubleProperty* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false); + setVector(Vector3D()); +} + + +//! Get the data how it should be displayed +QVariant QVector3DProperty::data (int column, int role) const +{ + if (column == DPC_Data && Qt::DisplayRole == role) + { + Vector3D tmpVect = getVector(); + return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X), + QString::number(tmpVect.Y), + QString::number(tmpVect.Z)); + } + else + return VProperty::data(column, role); +} + +//! Returns item flags +Qt::ItemFlags QVector3DProperty::flags(int column) const +{ + if (column == DPC_Name || column == DPC_Data) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + else + return Qt::NoItemFlags; +} + + +//! Returns the Vector3d +Vector3D QVector3DProperty::getVector() const +{ + Vector3D tmpVect; + + if (d_ptr->Children.count() < 3) + { + return tmpVect; + } + + tmpVect.X = d_ptr->Children.at(0)->getValue().toFloat(); + tmpVect.Y = d_ptr->Children.at(1)->getValue().toFloat(); + tmpVect.Z = d_ptr->Children.at(2)->getValue().toFloat(); + + return tmpVect; +} + +//! Sets the Vector3d +void QVector3DProperty::setVector(const Vector3D &vect) +{ + setVector(vect.X, vect.Y, vect.Z); +} + +void QVector3DProperty::setVector(float x, float y, float z) +{ + if (d_ptr->Children.count() < 3) + { + return; + } + + QVariant tmpX(x); tmpX.convert(QVariant::Double); + QVariant tmpY(y); tmpY.convert(QVariant::Double); + QVariant tmpZ(z); tmpZ.convert(QVariant::Double); + d_ptr->Children.at(0)->setValue(tmpX); + d_ptr->Children.at(1)->setValue(tmpY); + d_ptr->Children.at(2)->setValue(tmpZ); +} + +QString QVector3DProperty::type() const +{ + return "vector3d"; +} + +VProperty* QVector3DProperty::clone(bool include_children, VProperty* container) const +{ + if (!container) + { + container = new QVector3DProperty(getName()); + + if (!include_children) + { + QList tmpChildren = container->getChildren(); + foreach (VProperty* tmpChild, tmpChildren) + { + container->removeChild(tmpChild); + delete tmpChild; + } + } + } + + return VProperty::clone(false, container); // Child +} + +void QVector3DProperty::setValue(const QVariant &value) +{ + QStringList tmpStrings = value.toString().split(","); + if (tmpStrings.count() == 3) + { + setVector(tmpStrings[0].toFloat(), tmpStrings[1].toFloat(), tmpStrings[2].toFloat()); + } + +} + +QVariant QVector3DProperty::getValue() const +{ + Vector3D tmpVect = getVector(); + return QString("%1,%2,%3").arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), QString::number(tmpVect.Z)); +} diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h new file mode 100644 index 000000000..0f6435d0d --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h @@ -0,0 +1,97 @@ +/************************************************************************ + ** + ** @file vvector3dproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VVECTOR3DPROPERTY_H +#define VVECTOR3DPROPERTY_H + +#include "../../vpropertyexplorer_global.h" +#include "../../vproperty.h" + +namespace VPE +{ + +struct VPROPERTYEXPLORERSHARED_EXPORT Vector3D +{ +public: + Vector3D() + :X(0), Y(0), Z(0) + {} + + Vector3D(const Vector3D& other) + :X(other.X), Y(other.Y), Z(other.Z) + {} + + ~Vector3D() {} + + float X, Y, Z; +}; +/* +} + +Q_DECLARE_METATYPE(QPE::Vector3D) // todo + +*/ + +class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty +{ + Q_OBJECT +public: + QVector3DProperty(const QString& name); + + virtual ~QVector3DProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns item flags + Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Returns the Vector3d + virtual Vector3D getVector() const; + + //! Sets the Vector3d + virtual void setVector(const Vector3D& vect); + + //! Sets the Vector3d + virtual void setVector(float x, float y, float z); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns the value of the property as a QVariant + virtual QVariant getValue() const; + +private: + Q_DISABLE_COPY(QVector3DProperty) +}; + +} + +#endif // VVECTOR3DPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vboolproperty.cpp b/src/libs/vpropertyexplorer/plugins/vboolproperty.cpp new file mode 100644 index 000000000..f635c4293 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vboolproperty.cpp @@ -0,0 +1,100 @@ +/************************************************************************ + ** + ** @file vboolproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vboolproperty.h" + +#include +#include +#include +#include +#include +#include + +#include "../vproperty_p.h" + +using namespace VPE; + +QVariant VBoolProperty::TrueText; +QVariant VBoolProperty::FalseText; + +VBoolProperty::VBoolProperty(const QString& name) : + VProperty(name, QVariant::Bool) +{ + d_ptr->VariantValue.setValue(false); + d_ptr->VariantValue.convert(QVariant::Bool); + + // I'm not sure, how Qt handles the translations... + if (TrueText.isNull()) + { + TrueText = tr("True"); + } + if (FalseText.isNull()) + { + FalseText = tr("False"); + } +} + + +//! Get the data how it should be displayed +QVariant VBoolProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + return d_ptr->VariantValue.toBool() ? TrueText : FalseText; + } + if (column == DPC_Data && Qt::CheckStateRole == role) + { + return d_ptr->VariantValue.toBool() ? Qt::Checked : Qt::Unchecked; + } + else + return VProperty::data(column, role); +} + +bool VBoolProperty::setData(const QVariant &data, int role) +{ + if (Qt::CheckStateRole == role) + { + d_ptr->VariantValue = (Qt::Checked == static_cast(data.toInt())); + return true; + } + + return false; +} + +//! Returns item flags +Qt::ItemFlags VBoolProperty::flags(int column) const +{ + if (column == DPC_Data) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; + } + else + return VProperty::flags(column); +} + +QString VBoolProperty::type() const +{ + return "bool"; +} + +VProperty *VBoolProperty::clone(bool include_children, VProperty *container) const +{ + return VProperty::clone(include_children, container ? container : new VBoolProperty(getName())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vboolproperty.h b/src/libs/vpropertyexplorer/plugins/vboolproperty.h new file mode 100644 index 000000000..603cd2ef0 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vboolproperty.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file vboolproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VBOOLPROPERTY_H +#define VBOOLPROPERTY_H + +#include "../vproperty.h" + +namespace VPE +{ + +//! The VBoolProperty can take two states: True or False. +class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty +{ + Q_OBJECT +public: + //! Default constructor + VBoolProperty(const QString& name); + + //! Destructor + ~VBoolProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! This is used by the model to set the data + //! \param data The data to set + //! \param role The role. Default is Qt::EditRole + //! \return Returns true, if the data was changed, false if not. + virtual bool setData (const QVariant& data, int role = Qt::EditRole); + + //! Returns item flags + virtual Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + +protected: + //! The (translatable) text displayed when the property is set to true (default: "True") + static QVariant TrueText; + + //! The (translatable) text displayed when the property is set to false (default: "False") + static QVariant FalseText; + +private: + Q_DISABLE_COPY(VBoolProperty) +}; + +} + +#endif // VBOOLPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp new file mode 100644 index 000000000..f47b41856 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp @@ -0,0 +1,99 @@ +/************************************************************************ + ** + ** @file vcolorproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vcolorproperty.h" +#include "vcolorpropertyeditor.h" + +#include "../vproperty_p.h" + +using namespace VPE; + +VColorProperty::VColorProperty(const QString &name) : + VProperty(name, QVariant::Color) +{ +} + + +//! Get the data how it should be displayed +QVariant VColorProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role)) + { + return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value()); + } + else if (Qt::EditRole == role) + { + return QVariant(); + } + else if (column == DPC_Data && (Qt::DecorationRole == role)) + { + return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value()); + } + else + return VProperty::data(column, role); +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + + VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent); + tmpWidget->setColor(d_ptr->VariantValue.value()); + return tmpWidget; +} + +//! Sets the property's data to the editor (returns false, if the standard delegate should do that) +bool VColorProperty::setEditorData(QWidget* editor) +{ + VColorPropertyEditor* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + tmpWidget->setColor(d_ptr->VariantValue.value()); + } + else + return false; + + return true; +} + +//! Gets the data from the widget +QVariant VColorProperty::getEditorData(const QWidget *editor) const +{ + const VColorPropertyEditor* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + return tmpWidget->getColor(); + } + + return QVariant(); +} + +QString VColorProperty::type() const +{ + return "color"; +} + +VProperty *VColorProperty::clone(bool include_children, VProperty *container) const +{ + return VProperty::clone(include_children, container ? container : new VColorProperty(getName())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.h b/src/libs/vpropertyexplorer/plugins/vcolorproperty.h new file mode 100644 index 000000000..ef84b47fc --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file vcolorproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VCOLORPROPERTY_H +#define VCOLORPROPERTY_H + +#include "../vpropertyexplorer_global.h" + +#include "../vproperty.h" + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty +{ + Q_OBJECT +public: + VColorProperty(const QString &name); + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + +private: + Q_DISABLE_COPY(VColorProperty) +}; + +} + +#endif // VCOLORPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp new file mode 100644 index 000000000..ab55c2378 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp @@ -0,0 +1,129 @@ +/************************************************************************ + ** + ** @file vcolorpropertyeditor.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vcolorpropertyeditor.h" + +#include +#include +#include +#include +#include + +#include "../vproperty.h" + +using namespace VPE; + +VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) + : QWidget(parent), Color(), ToolButton(nullptr), TextLabel(nullptr), ColorLabel(nullptr), Spacer(nullptr) +{ + setAutoFillBackground(true); + + // Create the tool button + ToolButton = new QToolButton(this); + ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); + ToolButton->setText("..."); + ToolButton->setFixedWidth(20); + ToolButton->installEventFilter(this); + setFocusProxy(ToolButton); // Make the ToolButton the focus proxy + setFocusPolicy(ToolButton->focusPolicy()); + connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked())); + + // Create the text label + TextLabel = new QLabel(this); + TextLabel->setText(getColorString(Color)); + + // Create the label for the pixmap + ColorLabel = new QLabel(this); + ColorLabel->setPixmap(getColorPixmap(Color)); + + // Spacer (this is needed for proper display of the label and button) + Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored); + + // The layout (a horizontal layout) + QHBoxLayout* layout = new QHBoxLayout(this); + layout->setSpacing(3); + layout->setMargin(0); + layout->addWidget(ColorLabel); + layout->addWidget(TextLabel); + layout->addItem(Spacer); + layout->addWidget(ToolButton); + //TextLabel->hide(); + //ColorLabel->hide(); // for now, we just use the standard display and only add the button +} + +void VColorPropertyEditor::setColor(const QColor& color_) +{ + if (Color != color_) + { + Color = color_; + ColorLabel->setPixmap(getColorPixmap(Color)); + TextLabel->setText(getColorString(Color)); + } +} + +QPixmap VColorPropertyEditor::getColorPixmap(const QColor& color, unsigned int size) +{ + QImage tmpImgage(static_cast(size), static_cast(size), QImage::Format_ARGB32_Premultiplied); + tmpImgage.fill(static_cast(color.rgb())); + return QPixmap::fromImage(tmpImgage); + // todo: support alpha channel +} + +QString VColorPropertyEditor::getColorString(const QColor& color) +{ + return QString("[%1, %2, %3] (%4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); +} + +void VColorPropertyEditor::onToolButtonClicked() +{ + bool ok = false; + QRgb oldRgba = Color.rgba(); + QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this); + if (ok && newRgba != oldRgba) + { + setColor(QColor::fromRgba(newRgba)); + emit dataChangedByUser(Color, this); + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( this, event ); + } +} + +bool VColorPropertyEditor::eventFilter(QObject *obj, QEvent *ev) +{ + if (obj == ToolButton && ev->type() == QEvent::KeyPress) + { + // Ignore the event, so that eventually the delegate gets the event. + ev->ignore(); + return true; + } + + return QWidget::eventFilter(obj, ev); +} + + +VColorPropertyEditor::~VColorPropertyEditor() +{ + // +} + +QColor VColorPropertyEditor::getColor() const +{ + return Color; +} diff --git a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h new file mode 100644 index 000000000..ac6dba31a --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h @@ -0,0 +1,88 @@ +/************************************************************************ + ** + ** @file vcolorpropertyeditor.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VCOLORPROPERTYEDITOR_H +#define VCOLORPROPERTYEDITOR_H + +#include "../vpropertyexplorer_global.h" + +#include +#include +#include +#include +#include + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget +{ + Q_OBJECT + +public: + //! Constructor taking a widget as parent + VColorPropertyEditor(QWidget *parent); + + //! Destructor + virtual ~VColorPropertyEditor(); + + + //! Returns the color currently set + QColor getColor() const; + + //! A little helper function generating an image to represent a color + //! \param color The color to fill the image with + //! \size The size of the generated pixmap + //! \return Returns a QPixmap + static QPixmap getColorPixmap(const QColor& color, unsigned int size = 16); + + //! A helper function to convert a color into a string. + //! \param color The color to fill the image with + //! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA) + static QString getColorString(const QColor& color); + + //! Needed for proper event handling + bool eventFilter(QObject *obj, QEvent *ev); + +signals: + //! This is emitted, when the user changes the color + void dataChangedByUser(const QColor &getColor, VColorPropertyEditor* editor); + + void dataChanged(); + +public slots: + //! Sets the color of the widget + void setColor(const QColor &color_); + +private slots: + void onToolButtonClicked(); + +private: + Q_DISABLE_COPY(VColorPropertyEditor) + QColor Color; + QToolButton* ToolButton; + QLabel* TextLabel; + QLabel* ColorLabel; + QSpacerItem* Spacer; +}; + +} + +#endif // QFILEPROPERTYEDITOR_H diff --git a/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp b/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp new file mode 100644 index 000000000..db1f9959e --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp @@ -0,0 +1,97 @@ +/************************************************************************ + ** + ** @file vemptyproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vemptyproperty.h" + +using namespace VPE; + +VEmptyProperty::VEmptyProperty(const QString& name) + : VProperty(name, QVariant::Invalid) +{ +} + + +VEmptyProperty::VEmptyProperty(VPropertyPrivate *d) + : VProperty(d) +{ +} + + +VEmptyProperty::~VEmptyProperty() +{ + // +} + +//! Get the data how it should be displayed +QVariant VEmptyProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + return QVariant(); + } + else if (role == Qt::BackgroundRole) + { + return QBrush(QColor(217, 217, 217)); + } + else if (role == Qt::FontRole) + { + QFont tmpFont; tmpFont.setBold(true); return tmpFont; + } + else + return VProperty::data(column, role); +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(parent); + Q_UNUSED(delegate); + + return NULL; +} + + +//! Gets the data from the widget +QVariant VEmptyProperty::getEditorData(const QWidget *editor) const +{ + Q_UNUSED(editor); + + return QVariant(); +} + +//! Returns item flags +Qt::ItemFlags VEmptyProperty::flags(int column) const +{ + Q_UNUSED(column); + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QString VEmptyProperty::type() const +{ + return "empty"; +} + +VProperty* VEmptyProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VEmptyProperty(getName())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vemptyproperty.h b/src/libs/vpropertyexplorer/plugins/vemptyproperty.h new file mode 100644 index 000000000..f19c9bc1d --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vemptyproperty.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vemptyproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VEMPTYPROPERTY_H +#define VEMPTYPROPERTY_H + +#include "../vproperty.h" + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty +{ + Q_OBJECT +public: + //! Standard constructor, takes a name and a parent property as argument + explicit VEmptyProperty(const QString& name); + + //! Destructor + virtual ~VEmptyProperty(); + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Returns item flags + virtual Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + +protected: + //! Protected constructor + VEmptyProperty(VPropertyPrivate* d); + +private: + Q_DISABLE_COPY(VEmptyProperty) +}; + +} + +#endif // VEMPTYPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.cpp b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp new file mode 100644 index 000000000..30330044d --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp @@ -0,0 +1,163 @@ +/************************************************************************ + ** + ** @file venumproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "venumproperty.h" +#include "../vproperty_p.h" + +#include +#include + +using namespace VPE; + +VEnumProperty::VEnumProperty(const QString& name) + : VProperty(name, QVariant::Int), EnumerationLiterals() +{ + VProperty::d_ptr->VariantValue = 0; + VProperty::d_ptr->VariantValue.convert(QVariant::Int); +} + + +//! Get the data how it should be displayed +QVariant VEnumProperty::data (int column, int role) const +{ + if (EnumerationLiterals.empty()) + { + return QVariant(); + } + + int tmpIndex = VProperty::d_ptr->VariantValue.toInt(); + + if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count()) + { + tmpIndex = 0; + } + + if (column == DPC_Data && Qt::DisplayRole == role) + { + return EnumerationLiterals.at(tmpIndex); + } + else if (column == DPC_Data && Qt::EditRole == role) + { + return tmpIndex; + } + else + return VProperty::data(column, role); +} + + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + QComboBox* tmpEditor = new QComboBox(parent); + tmpEditor->clear(); + tmpEditor->addItems(EnumerationLiterals); + tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); + connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, + &VEnumProperty::currentIndexChanged); + + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +//! Gets the data from the widget +QVariant VEnumProperty::getEditorData(const QWidget *editor) const +{ + const QComboBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->currentIndex(); + } + + return QVariant(0); +} + +//! Sets the enumeration literals +void VEnumProperty::setLiterals(const QStringList& literals) +{ + EnumerationLiterals = literals; +} + +//! Get the settings. This function has to be implemented in a subclass in order to have an effect +QStringList VEnumProperty::getLiterals() const +{ + return EnumerationLiterals; +} + +//! Sets the value of the property +void VEnumProperty::setValue(const QVariant& value) +{ + int tmpIndex = value.toInt(); + + if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count()) + { + tmpIndex = 0; + } + + VProperty::d_ptr->VariantValue = tmpIndex; + VProperty::d_ptr->VariantValue.convert(QVariant::Int); + + if (VProperty::d_ptr->editor != nullptr) + { + setEditorData(VProperty::d_ptr->editor); + } +} + +QString VEnumProperty::type() const +{ + return "enum"; +} + +VProperty* VEnumProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VEnumProperty(getName())); +} + +void VEnumProperty::setSetting(const QString& key, const QVariant& value) +{ + if (key == "literals") + { + setLiterals(value.toString().split(";;")); + } +} + +QVariant VEnumProperty::getSetting(const QString& key) const +{ + if (key == "literals") + { + return getLiterals().join(";;"); + } + else + return VProperty::getSetting(key); +} + +QStringList VEnumProperty::getSettingKeys() const +{ + return QStringList("literals"); +} + +void VEnumProperty::currentIndexChanged(int index) +{ + Q_UNUSED(index) + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( VProperty::d_ptr->editor, event ); +} diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.h b/src/libs/vpropertyexplorer/plugins/venumproperty.h new file mode 100644 index 000000000..b15a04cd5 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/venumproperty.h @@ -0,0 +1,99 @@ +/************************************************************************ + ** + ** @file venumproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VENUMPROPERTY_H +#define VENUMPROPERTY_H + +#include "../vproperty.h" + +#include + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty +{ + Q_OBJECT +public: + //! Constructor + VEnumProperty(const QString& name); + + //! Destructor + ~VEnumProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the enumeration literals + virtual void setLiterals(const QStringList &literals); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QStringList getLiterals() const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + + //! Sets the settings. Available settings: + //! + //! key: "literals" - value: "item1;;item2;;item3" + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + +public slots: + void currentIndexChanged(int index); + +protected: + //! The list of possible options to choose frome + QStringList EnumerationLiterals; + // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other + //members by reimplementing the VPropertyPrivate class without touching this header file. +private: + Q_DISABLE_COPY(VEnumProperty) +}; + +} + +#endif // VENUMPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp new file mode 100644 index 000000000..4434675d0 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp @@ -0,0 +1,172 @@ +/************************************************************************ + ** + ** @file vfileproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vfileproperty.h" +#include +#include + +#include "vfilepropertyeditor.h" + +#include "../vfileproperty_p.h" + +using namespace VPE; + +VFileProperty::VFileProperty(const QString& name) + : VProperty(new VFilePropertyPrivate(name, QVariant::String)) +{ + +} + +VFileProperty::~VFileProperty() +{ + // +} + + +void VFileProperty::setFileFilters(const QString& filefilters) +{ + static_cast(d_ptr)->FileFilters = filefilters; +} + + +QString VFileProperty::getFileFilters() const +{ + return static_cast(d_ptr)->FileFilters; +} + + +void VFileProperty::setFile(const QString& file) +{ + d_ptr->VariantValue.setValue(file); +} + + +QString VFileProperty::getFile() const +{ + return d_ptr->VariantValue.toString(); +} + + +QVariant VFileProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + QFileInfo tmpFile(d_ptr->VariantValue.toString()); + return tmpFile.fileName(); + } + else + return VProperty::data(column, role); +} + + +QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + + VFileEditWidget* tmpWidget = new VFileEditWidget(parent); + if (delegate) + { + VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); + + } + tmpWidget->setFilter(static_cast(d_ptr)->FileFilters); // todo: parse this string + tmpWidget->setFile(d_ptr->VariantValue.toString()); + tmpWidget->setDirectory(static_cast(d_ptr)->Directory); + return tmpWidget; +} + + +bool VFileProperty::setEditorData(QWidget* editor) +{ + VFileEditWidget* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + tmpWidget->setFile(d_ptr->VariantValue.toString()); + } + else + return false; + + return true; +} + + +QVariant VFileProperty::getEditorData(const QWidget *editor) const +{ + const VFileEditWidget* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + return tmpWidget->getFile(); + } + + return QVariant(); +} + +void VFileProperty::setSetting(const QString& key, const QVariant& value) +{ + if (key == "FileFilters") + { + setFileFilters(value.toString()); + } + else if (key == "Directory") + { + setDirectory(value.toBool()); + } +} + +QVariant VFileProperty::getSetting(const QString& key) const +{ + if (key == "FileFilters") + { + return getFileFilters(); + } + else if (key == "Directory") + { + return isDirectory(); + } + else + return VProperty::getSetting(key); +} + +QStringList VFileProperty::getSettingKeys() const +{ + return QStringList("FileFilters") << "Directory"; +} + +QString VFileProperty::type() const +{ + return "file"; +} + +VProperty* VFileProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VFileProperty(getName())); +} + +bool VFileProperty::isDirectory() const +{ + return static_cast(d_ptr)->Directory; +} + + +void VFileProperty::setDirectory(bool is_directory) +{ + static_cast(d_ptr)->Directory = is_directory; +} diff --git a/src/libs/vpropertyexplorer/plugins/vfileproperty.h b/src/libs/vpropertyexplorer/plugins/vfileproperty.h new file mode 100644 index 000000000..64611cf23 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vfileproperty.h @@ -0,0 +1,104 @@ +/************************************************************************ + ** + ** @file vfileproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VFILEPROPERTY_H +#define VFILEPROPERTY_H + +#include "../vpropertyexplorer_global.h" + +#include "../vproperty.h" + +#include + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty +{ + Q_OBJECT +public: + VFileProperty(const QString &name); + + //! The destructor + ~VFileProperty(); + + //! Sets the file filters. The file filters have to be like the ones passed a QFileOpenDialog. + virtual void setFileFilters(const QString& filefilters); + + //! Returns the current file filters as a string + virtual QString getFileFilters() const; + + //! Set file + virtual void setFile(const QString& file); + + //! Get file + virtual QString getFile() const; + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the settings. Available settings: + //! + //! key: "FileFilters" - value: File filters in the same format the QFileDialog expects it + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + + //! Returns whether this is a file (false) or a directory (true) + virtual bool isDirectory() const; + + //! Sets whether this is a file (false) or a directory (true) + virtual void setDirectory(bool is_directory); + +private: + Q_DISABLE_COPY(VFileProperty) +}; + +} + +#endif // VFILEPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp new file mode 100644 index 000000000..a9d70d535 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -0,0 +1,242 @@ +/************************************************************************ + ** + ** @file vfilepropertyeditor.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vfilepropertyeditor.h" + +#include "vfileproperty.h" + +#include +#include +#include +#include + +using namespace VPE; + +VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory) + : QWidget(parent), CurrentFilePath(), ToolButton(nullptr), FileLineEdit(nullptr), FileDialogFilter(), FilterList(), + Directory(is_directory) +{ + // Create the tool button,ToolButton = new QToolButton(this); + ToolButton = new QToolButton(this); + ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); + ToolButton->setText("..."); + ToolButton->setFixedWidth(20); + ToolButton->installEventFilter(this); + setFocusProxy(ToolButton); // Make the ToolButton the focus proxy + setFocusPolicy(ToolButton->focusPolicy()); + connect(ToolButton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked())); + + // Create the line edit widget + FileLineEdit = new QLineEdit(this); + FileLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + FileLineEdit->setText(CurrentFilePath); + FileLineEdit->installEventFilter(this); + + // The layout (a horizontal layout) + QHBoxLayout* layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setMargin(0); + layout->addWidget(FileLineEdit); + layout->addWidget(ToolButton); + + // Accept drops + setAcceptDrops(true); +} + + +VFileEditWidget::~VFileEditWidget() +{ + // nothing needs to be done here +} + + +void VFileEditWidget::setFile(const QString &value, bool emit_signal) +{ + if (CurrentFilePath != value) + { + CurrentFilePath = value; + FileLineEdit->setText(CurrentFilePath); + + if (emit_signal) + { + emit dataChangedByUser(CurrentFilePath, this); + emit commitData(this); + } + } +} + + +void VFileEditWidget::setFilter(const QString &dialog_filter, const QStringList& filter_list) +{ + FileDialogFilter = dialog_filter; + FilterList = filter_list; +} + +void VFileEditWidget::setDirectory(bool dir) +{ + Directory = dir; +} + +QString VFileEditWidget::getFile() const +{ + return CurrentFilePath; +} + + +void VFileEditWidget::onToolButtonClicked() +{ + QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath) + : QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath, + FileDialogFilter)); + if (filepath.isNull() == false) + { + setFile(filepath, true); + } +} + + +bool VFileEditWidget::eventFilter(QObject *obj, QEvent *ev) +{ + if (ev->type() == QEvent::DragEnter || ev->type() == QEvent::Drop) + { + ev->ignore(); + if (ev->type() == QEvent::DragEnter) + { + dragEnterEvent(static_cast(ev)); + } + else if (ev->type() == QEvent::Drop) + { + dropEvent(static_cast(ev)); + } + + if (ev->isAccepted()) + { + return true; + } + else + return QWidget::eventFilter(obj, ev); + } + else if (obj == ToolButton && ev->type() == QEvent::KeyPress) + { + // Ignore the event, so that eventually the delegate gets the event. + ev->ignore(); + return true; + } + else if (obj == FileLineEdit) + { + if (ev->type() == QEvent::FocusOut) + { + setFile(FileLineEdit->text(), true); + // We don't return true here because we still want the line edit to catch the event as well + } + } + + // forward the signal to the parent class + return QWidget::eventFilter(obj, ev); +} + +bool VFileEditWidget::isDirectory() +{ + return Directory; +} + + +void VFileEditWidget::dragEnterEvent(QDragEnterEvent* event) +{ + QString tmpFileName; + if (checkMimeData(event->mimeData(), tmpFileName)) + { + event->accept(); + event->acceptProposedAction(); + } +} + +void VFileEditWidget::dragMoveEvent(QDragMoveEvent* event) +{ + event->acceptProposedAction(); +} + +void VFileEditWidget::dragLeaveEvent(QDragLeaveEvent* event) +{ + event->accept(); +} + +void VFileEditWidget::dropEvent(QDropEvent* event) +{ + QString tmpFileName; + if (checkMimeData(event->mimeData(), tmpFileName)) + { + setFile(tmpFileName); + emit dataChangedByUser(getFile(), this); + emit commitData(this); + event->accept(); + event->acceptProposedAction(); + } +} + + +bool VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const +{ + if (data->hasUrls()) + { + QList tmpUrlList = data->urls(); + QFileInfo tmpFileInfo; + + foreach(QUrl tmpUrl, tmpUrlList) + if (QFile::exists(tmpUrl.toLocalFile())) + { + tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); break; + } + + if (checkFileFilter(tmpFileInfo.fileName())) + { + file = tmpFileInfo.absoluteFilePath(); + return true; + } + } + + return false; +} + +bool VFileEditWidget::checkFileFilter(const QString& file) const +{ + if (FilterList.isEmpty()) + { + return true; + } + + QFileInfo tmpFileInfo(file); + + if ((Directory && !tmpFileInfo.isDir()) || (!Directory && !tmpFileInfo.isFile())) + { + return false; + } + + foreach(QString tmpFilter, FilterList) + { + QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + if (tmpRegExpFilter.exactMatch(file)) + { + return true; + } + } + + return false; +} diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h new file mode 100644 index 000000000..c4b69151c --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h @@ -0,0 +1,112 @@ +/************************************************************************ + ** + ** @file vfilepropertyeditor.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VFILEPROPERTYEDITOR_H +#define VFILEPROPERTYEDITOR_H + +#include "../vpropertyexplorer_global.h" + +#include +#include +#include +#include + +namespace VPE +{ + + +class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget +{ + Q_OBJECT + +public: + VFileEditWidget(QWidget* parent, bool is_directory = false); + virtual ~VFileEditWidget(); + + + //! This function returns the file currently set to this editor + QString getFile() const; + + //! Needed for proper event handling + bool eventFilter(QObject* obj, QEvent* ev); + + //! Returns the directory/file setting + //! \return True, if a directory dialog is being shown, false if a file dialog + bool isDirectory(); + +signals: + //! This signal is emitted when the user changed the curret file. + //! Actions triggering this signal are either using the file dialog + //! to select a new file or changing the file path in the line edit. + void dataChangedByUser(const QString &getFile, VFileEditWidget* editor); + + //! This signal is emitted whenever dataChangedByUser() gets emmitted + //! and is connected to the delegate's commitData() signal + void commitData(QWidget* editor); + + +public slots: + //! Sets the current file, does not check if it is valid + //! \param getFile The new filepath the widget should show + //! \param emit_signal If true, this will emit the dataChangedByUser()-signal (if file differs from the current + //! file) + void setFile(const QString &getFile, bool emit_signal = false); + + //! Sets a filter for the file field + //! \param dialog_filter The filter used for the File Dialog + //! \param filter_list The list of file endings. The filters are being checked using regular expressions + void setFilter(const QString& dialog_filter = QString(), const QStringList& filter_list = QStringList()); + + //! Sets whether the property stores a directory or a file + void setDirectory(bool dir); + +private slots: + //! This slot gets activated, when the "..." button gets clicked + void onToolButtonClicked(); + +protected: + void dragEnterEvent(QDragEnterEvent* event); + void dragMoveEvent(QDragMoveEvent* event); + void dragLeaveEvent(QDragLeaveEvent* event); + void dropEvent(QDropEvent* event); + + //! This function checks the mime data, if it is compatible with the filters + virtual bool checkMimeData(const QMimeData* data, QString& getFile) const; + + //! This checks, if a file is compatible with the filters + virtual bool checkFileFilter(const QString& getFile) const; + + + QString CurrentFilePath; + QToolButton* ToolButton; + QLineEdit* FileLineEdit; + QString FileDialogFilter; + QStringList FilterList; + + //! Specifies whether it is being looked for a directory (true) or a file (false, default) + bool Directory; + +private: + Q_DISABLE_COPY(VFileEditWidget) +}; + +} + +#endif // VFILEPROPERTYEDITOR_H diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp new file mode 100644 index 000000000..b86def022 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -0,0 +1,245 @@ +/************************************************************************ + ** + ** @file vnumberproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vnumberproperty.h" + +#include +#include +#include +#include + +#include "../vproperty_p.h" + +using namespace VPE; + + +const int VIntegerProperty::StandardMin = -1000000; +const int VIntegerProperty::StandardMax = 1000000; + +VIntegerProperty::VIntegerProperty(const QString& name, const QMap& settings) + : VProperty(name, QVariant::Int), minValue(StandardMin), maxValue(StandardMax), singleStep(1.0) +{ + VProperty::setSettings(settings); + VProperty::d_ptr->VariantValue.setValue(0); + VProperty::d_ptr->VariantValue.convert(QVariant::Int); +} + +VIntegerProperty::VIntegerProperty(const QString &name) + : VProperty(name), minValue(StandardMin), maxValue(StandardMax), singleStep(1.0) +{ + VProperty::d_ptr->VariantValue.setValue(0); + VProperty::d_ptr->VariantValue.convert(QVariant::Int); +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + + QSpinBox* tmpEditor = new QSpinBox(parent); + tmpEditor->setMinimum(static_cast(minValue)); + tmpEditor->setMaximum(static_cast(maxValue)); + tmpEditor->setSingleStep(static_cast(singleStep)); + tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt()); + connect(tmpEditor, static_cast(&QSpinBox::valueChanged), this, + &VIntegerProperty::valueChanged); + + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +//! Gets the data from the widget +QVariant VIntegerProperty::getEditorData(const QWidget *editor) const +{ + const QSpinBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->value(); + } + + return QVariant(0); +} + +void VIntegerProperty::setSetting(const QString& key, const QVariant& value) +{ + if (key == QLatin1String("Min")) + { + maxValue = value.toInt(); + } + else if (key == QLatin1String("Max")) + { + minValue = value.toInt(); + } + else if (key == QLatin1String("Step")) + { + singleStep = value.toInt(); + } +} + +QVariant VIntegerProperty::getSetting(const QString& key) const +{ + if (key == QLatin1String("Min")) + { + return minValue; + } + if (key == QLatin1String("Max")) + { + return maxValue; + } + if (key == QLatin1String("Step")) + { + return singleStep; + } + else + return VProperty::getSetting(key); +} + +QStringList VIntegerProperty::getSettingKeys() const +{ + return (QStringList("Min") << "Max" << "Step"); +} + +QString VIntegerProperty::type() const +{ + return "integer"; +} + +VProperty* VIntegerProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VIntegerProperty(getName())); +} + +void VIntegerProperty::valueChanged(int i) +{ + Q_UNUSED(i) + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( VProperty::d_ptr->editor, event ); +} + +const double VDoubleProperty::StandardPrecision = 5; + +VDoubleProperty::VDoubleProperty(const QString& name, const QMap& settings) + : VIntegerProperty(name), Precision(static_cast(StandardPrecision)) +{ + VProperty::setSettings(settings); + VProperty::d_ptr->VariantValue.setValue(0); + VProperty::d_ptr->VariantValue.convert(QVariant::Double); + VProperty::d_ptr->PropertyVariantType = QVariant::Double; +} + +VDoubleProperty::VDoubleProperty(const QString &name) + : VIntegerProperty(name), Precision(static_cast(StandardPrecision)) +{ + VProperty::d_ptr->VariantValue.setValue(0); + VProperty::d_ptr->VariantValue.convert(QVariant::Double); + VProperty::d_ptr->PropertyVariantType = QVariant::Double; +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent); + tmpEditor->setMinimum(minValue); + tmpEditor->setMaximum(maxValue); + tmpEditor->setDecimals(Precision); + tmpEditor->setSingleStep(singleStep); + tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble()); + connect(tmpEditor, static_cast(&QDoubleSpinBox::valueChanged), this, + &VIntegerProperty::valueChanged); + + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +//! Gets the data from the widget +QVariant VDoubleProperty::getEditorData(const QWidget *editor) const +{ + const QDoubleSpinBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->value(); + } + + return QVariant(0); +} + +void VDoubleProperty::setSetting(const QString& key, const QVariant& value) +{ + if (key == QLatin1String("Min")) + { + minValue = value.toDouble(); + } + else if (key == QLatin1String("Max")) + { + maxValue = value.toDouble(); + } + else if (key == QLatin1String("Step")) + { + singleStep = value.toDouble(); + } + else if (key == QLatin1String("Precision")) + { + Precision = value.toInt(); + } +} + +QVariant VDoubleProperty::getSetting(const QString& key) const +{ + if (key == QLatin1String("Min")) + { + return minValue; + } + if (key == QLatin1String("Max")) + { + return maxValue; + } + if (key == QLatin1String("Step")) + { + return singleStep; + } + if (key == QLatin1String("Precision")) + { + return Precision; + } + else + return VProperty::getSetting(key); +} + +QStringList VDoubleProperty::getSettingKeys() const +{ + return (QStringList("Min") << "Max" << "Step" << "Precision"); +} + +QString VDoubleProperty::type() const +{ + return "double"; +} + +VProperty* VDoubleProperty::clone(bool include_children, VProperty* container) const +{ + return VIntegerProperty::clone(include_children, container ? container : new VDoubleProperty(getName())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h new file mode 100644 index 000000000..c76a4382d --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h @@ -0,0 +1,140 @@ +/************************************************************************ + ** + ** @file vnumberproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VNUMBERPROPERTY_H +#define VNUMBERPROPERTY_H + +#include "../vpropertyexplorer_global.h" +#include "../vproperty.h" + +namespace VPE +{ + + +//! Class for holding an integer property +class VPROPERTYEXPLORERSHARED_EXPORT VIntegerProperty : public VProperty +{ + Q_OBJECT +public: + VIntegerProperty(const QString& name, const QMap& settings); + + VIntegerProperty(const QString& name); + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the settings. Available settings: + //! + //! key: "Min" - value: Minimum number as integer + //! key: "Max" - value: Maximum number as integer + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; +public slots: + void valueChanged(int i); +protected: + double minValue, maxValue, singleStep; + + static const int StandardMin;// = -1000000; + static const int StandardMax;// = 1000000; + +private: + Q_DISABLE_COPY(VIntegerProperty) +}; + + +//! Class for holding a double property +class VPROPERTYEXPLORERSHARED_EXPORT VDoubleProperty : public VIntegerProperty +{ + Q_OBJECT +public: + VDoubleProperty(const QString& name, const QMap& settings); + + VDoubleProperty(const QString& name); + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the settings. Available settings: + //! + //! key: "Min" - value: Minimum number as integer + //! key: "Max" - value: Maximum number as integer + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + +protected: + //! Number of decimals after the decimal point + int Precision; + + const static double StandardPrecision;// = 5; + +private: + Q_DISABLE_COPY(VDoubleProperty) +}; + + +} + +#endif // VNUMBERPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp new file mode 100644 index 000000000..513d8d812 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp @@ -0,0 +1,164 @@ +/************************************************************************ + ** + ** @file vobjectproperty.cpp + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vobjectproperty.h" +#include "../vproperty_p.h" + +#include +#include +#include + +using namespace VPE; + +VObjectProperty::VObjectProperty(const QString& name) + : VProperty(name, QVariant::Int), objects() +{ + VProperty::d_ptr->VariantValue = 0; + VProperty::d_ptr->VariantValue.convert(QVariant::UInt); +} + +//! Get the data how it should be displayed +QVariant VObjectProperty::data (int column, int role) const +{ + if (objects.empty()) + { + return QVariant(); + } + + QComboBox* tmpEditor = qobject_cast(VProperty::d_ptr->editor); + + if (column == DPC_Data && Qt::DisplayRole == role) + { + return VProperty::d_ptr->VariantValue; + } + else if (column == DPC_Data && Qt::EditRole == role) + { + return tmpEditor->currentIndex(); + } + else + return VProperty::data(column, role); +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + QComboBox* tmpEditor = new QComboBox(parent); + tmpEditor->clear(); + FillList(tmpEditor, objects); + tmpEditor->setCurrentIndex(tmpEditor->findData(VProperty::d_ptr->VariantValue.toUInt())); + connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, + &VObjectProperty::currentIndexChanged); + + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +bool VObjectProperty::setEditorData(QWidget *editor) +{ + if (!editor) + { + return false; + } + + QComboBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + quint32 objId = VProperty::d_ptr->VariantValue.toUInt(); + qint32 tmpIndex = tmpEditor->findData(objId); + + if (tmpIndex == -1) + { + tmpIndex = 0; + } + tmpEditor->blockSignals(true); + tmpEditor->setCurrentIndex(tmpIndex); + tmpEditor->blockSignals(false); + return true; + } + + return false; +} + +//! Gets the data from the widget +QVariant VObjectProperty::getEditorData(const QWidget *editor) const +{ + const QComboBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->itemData(tmpEditor->currentIndex()); + } + + return QVariant(0); +} + +//! Sets the objects list +void VObjectProperty::setObjectsList(const QMap &objects) +{ + this->objects = objects; +} + +//! Get the settings. This function has to be implemented in a subclass in order to have an effect +QMap VObjectProperty::getObjects() const +{ + return objects; +} + +//! Sets the value of the property +void VObjectProperty::setValue(const QVariant& value) +{ + VProperty::d_ptr->VariantValue = value; + VProperty::d_ptr->VariantValue.convert(QVariant::UInt); + + if (VProperty::d_ptr->editor != nullptr) + { + setEditorData(VProperty::d_ptr->editor); + } +} + +QString VObjectProperty::type() const +{ + return "objectList"; +} + +VProperty* VObjectProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VObjectProperty(getName())); +} + +void VObjectProperty::currentIndexChanged(int index) +{ + Q_UNUSED(index) + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( VProperty::d_ptr->editor, event ); +} + +void VObjectProperty::FillList(QComboBox *box, const QMap &list) const +{ + box->clear(); + + QMap::const_iterator i; + for (i = list.constBegin(); i != list.constEnd(); ++i) + { + box->addItem(i.key(), i.value()); + } +} diff --git a/src/libs/vpropertyexplorer/plugins/vobjectproperty.h b/src/libs/vpropertyexplorer/plugins/vobjectproperty.h new file mode 100644 index 000000000..9c5b66f2c --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vobjectproperty.h @@ -0,0 +1,96 @@ +/************************************************************************ + ** + ** @file vobjectproperty.h + ** @author Roman Telezhynskyi + ** @date 28 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VOBJECTPROPERTY_H +#define VOBJECTPROPERTY_H + +#include "../vproperty.h" + +#include + +class QComboBox; + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty +{ + Q_OBJECT +public: + //! Constructor + VObjectProperty(const QString& name); + + //! Destructor + ~VObjectProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the objects list + void setObjectsList(const QMap &objects); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QMap getObjects() const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + +public slots: + void currentIndexChanged(int index); + +protected: + //! The list of possible objects + QMap objects; + + void FillList(QComboBox *box, const QMap &list)const; + // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other + //members by reimplementing the VPropertyPrivate class without touching this header file. + +private: + Q_DISABLE_COPY(VObjectProperty) +}; + +} + +#endif // VOBJECTPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp new file mode 100644 index 000000000..f5ed1b951 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vpointfproperty.cpp @@ -0,0 +1,138 @@ +/************************************************************************ + ** + ** @file vpointfproperty.cpp + ** @author Roman Telezhynskyi + ** @date 27 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpointfproperty.h" + +using namespace VPE; + +#include "../vproperty_p.h" +#include "vnumberproperty.h" +#include + +VPE::VPointFProperty::VPointFProperty(const QString &name) + : VProperty(name, QVariant::PointF) +{ + d_ptr->VariantValue.setValue(0); + d_ptr->VariantValue.convert(QVariant::PointF); + + VDoubleProperty* tmpX = new VDoubleProperty("X"); + addChild(tmpX); + tmpX->setUpdateBehaviour(true, false); + + VDoubleProperty* tmpY = new VDoubleProperty("Y"); + addChild(tmpY); + tmpY->setUpdateBehaviour(true, false); + + setValue(QPointF()); +} + +QVariant VPointFProperty::data(int column, int role) const +{ + if (column == DPC_Data && Qt::DisplayRole == role) + { + return getPointF(); + } + else + return VProperty::data(column, role); +} + +Qt::ItemFlags VPointFProperty::flags(int column) const +{ + if (column == DPC_Name || column == DPC_Data) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + else + return Qt::NoItemFlags; +} + +QPointF VPointFProperty::getPointF() const +{ + QPointF tmpValue; + + if (d_ptr->Children.count() < 2) + { + return tmpValue; + } + + tmpValue.setX(d_ptr->Children.at(0)->getValue().toDouble()); + tmpValue.setY(d_ptr->Children.at(1)->getValue().toDouble()); + + return tmpValue; +} + +void VPointFProperty::setPointF(const QPointF &point) +{ + setPointF(point.x(), point.y()); +} + +void VPointFProperty::setPointF(qreal x, qreal y) +{ + if (d_ptr->Children.count() < 2) + { + return; + } + + QVariant tmpX(x); + tmpX.convert(QVariant::Double); + + QVariant tmpY(y); + tmpY.convert(QVariant::Double); + + d_ptr->Children.at(0)->setValue(tmpX); + d_ptr->Children.at(1)->setValue(tmpY); +} + +QString VPointFProperty::type() const +{ + return "pointF"; +} + +VProperty *VPointFProperty::clone(bool include_children, VProperty *container) const +{ + if (!container) + { + container = new VPointFProperty(getName()); + + if (!include_children) + { + QList tmpChildren = container->getChildren(); + foreach(VProperty* tmpChild, tmpChildren) + { + container->removeChild(tmpChild); + delete tmpChild; + } + } + } + + return VProperty::clone(false, container); // Child +} + +void VPointFProperty::setValue(const QVariant &value) +{ + QPointF tmpPoint = value.toPointF(); + setPointF(tmpPoint); +} + +QVariant VPointFProperty::getValue() const +{ + QPointF tmpValue = getPointF(); + return QString("%1,%2").arg(QString::number(tmpValue.x()), QString::number(tmpValue.y())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vpointfproperty.h b/src/libs/vpropertyexplorer/plugins/vpointfproperty.h new file mode 100644 index 000000000..7c74cd0a2 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vpointfproperty.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vpointfproperty.h + ** @author Roman Telezhynskyi + ** @date 27 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPOINTFPROPERTY_H +#define VPOINTFPROPERTY_H + +#include "../vpropertyexplorer_global.h" + +#include "../vproperty.h" + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty +{ + Q_OBJECT +public: + VPointFProperty(const QString& name); + + virtual ~VPointFProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns item flags + Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Returns the QPointF + virtual QPointF getPointF() const; + + //! Sets the QPointF + virtual void setPointF(const QPointF& point); + + //! Sets the QPointF + virtual void setPointF(qreal x, qreal y); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns the value of the property as a QVariant + virtual QVariant getValue() const; + +private: + Q_DISABLE_COPY(VPointFProperty) +}; + +} + +#endif // VPOINTFPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp new file mode 100644 index 000000000..f51346d54 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp @@ -0,0 +1,108 @@ +/************************************************************************ + ** + ** @file vshortcutproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vshortcutproperty.h" +#include +#include + +#include "vshortcutpropertyeditor.h" + +#include "../vproperty_p.h" + + +using namespace VPE; + +VShortcutProperty::VShortcutProperty(const QString& name) + : VProperty(name, QVariant::String) +{ + +} + +VShortcutProperty::~VShortcutProperty() +{ + // +} + +QVariant VShortcutProperty::data (int column, int role) const +{ + if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + return d_ptr->VariantValue; + } + else + return VProperty::data(column, role); +} + + +QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + + VShortcutEditWidget* tmpWidget = new VShortcutEditWidget(parent); + if (delegate) + { + VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); + } + + return tmpWidget; +} + + +bool VShortcutProperty::setEditorData(QWidget* editor) +{ + VShortcutEditWidget* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + tmpWidget->setShortcut(d_ptr->VariantValue.toString(), false); + } + else + return false; + + return true; +} + + +QVariant VShortcutProperty::getEditorData(const QWidget *editor) const +{ + const VShortcutEditWidget* tmpWidget = qobject_cast(editor); + if (tmpWidget) + { + return tmpWidget->getShortcutAsString(); + } + + return QVariant(); +} + + +QString VShortcutProperty::type() const +{ + return "shortcut"; +} + +VProperty* VShortcutProperty::clone(bool include_children, VProperty* container) const +{ + return VProperty::clone(include_children, container ? container : new VShortcutProperty(getName())); +} + +void VShortcutProperty::setValue(const QVariant &value) +{ + VProperty::setValue(QKeySequence::fromString(value.toString()).toString()); +} diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h new file mode 100644 index 000000000..db8e03cb5 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vshortcutproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VSHORTCUTROPERTY_H +#define VSHORTCUTROPERTY_H + +#include "../vpropertyexplorer_global.h" +#include "../vproperty.h" + +namespace VPE +{ + +//! This property can be used to handle key shortcuts +class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty +{ + Q_OBJECT +public: + VShortcutProperty(const QString &name); + + //! The destructor + ~VShortcutProperty(); + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + +private: + Q_DISABLE_COPY(VShortcutProperty) +}; + +} + +#endif // VFILEPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp new file mode 100644 index 000000000..412c2f456 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.cpp @@ -0,0 +1,109 @@ +/************************************************************************ + ** + ** @file vshortcutpropertyeditor.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vshortcutpropertyeditor.h" + +#include +#include + +using namespace VPE; + +VShortcutEditWidget::VShortcutEditWidget(QWidget *parent) + : QWidget(parent), CurrentKeySequence(), LineEdit(nullptr) +{ + // Create the line edit widget + LineEdit = new QLineEdit(this); + LineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + LineEdit->clear(); + LineEdit->installEventFilter(this); + setFocusProxy(LineEdit); + connect(LineEdit, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited(QString))); + + // The layout (a horizontal layout) + QHBoxLayout* layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setMargin(0); + layout->addWidget(LineEdit); +} + + +VShortcutEditWidget::~VShortcutEditWidget() +{ + // nothing needs to be done here +} + +bool VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == LineEdit) + { + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + + int keys = keyEvent->key(); + + if (keys != Qt::Key_Shift && + keys != Qt::Key_Control && + keys != Qt::Key_Meta && + keys != Qt::Key_AltGr && + keys != Qt::Key_Alt) + { + keys += keyEvent->modifiers(); + setShortcut(QKeySequence(keys), true); + return true; + } + } + } + + return QWidget::eventFilter(obj, event); +} + +QString VShortcutEditWidget::getShortcutAsString() const +{ + return CurrentKeySequence.toString(); +} + +QKeySequence VShortcutEditWidget::getShortcut() +{ + return CurrentKeySequence; +} + +void VShortcutEditWidget::setShortcut(const QString &shortcut, bool emit_signal) +{ + setShortcut(QKeySequence::fromString(shortcut), emit_signal); +} + +void VShortcutEditWidget::setShortcut(const QKeySequence &shortcut, bool emit_signal) +{ + if (shortcut != CurrentKeySequence) + { + CurrentKeySequence = shortcut; + LineEdit->setText(CurrentKeySequence.toString()); + if (emit_signal) + { + emit dataChangedByUser(CurrentKeySequence, this); + } + } +} + +void VShortcutEditWidget::onTextEdited(const QString &text) +{ + setShortcut(text, true); +} diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h new file mode 100644 index 000000000..6e9c91144 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h @@ -0,0 +1,88 @@ +/************************************************************************ + ** + ** @file vshortcutpropertyeditor.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VSHORTCUTPROPERTYEDITOR_H +#define VSHORTCUTPROPERTYEDITOR_H + +#include "../vpropertyexplorer_global.h" + +#include +#include +#include +#include + +namespace VPE +{ + + +class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget +{ + Q_OBJECT + +public: + VShortcutEditWidget(QWidget* parent); + virtual ~VShortcutEditWidget(); + + //! Needed for proper event handling + bool eventFilter(QObject* obj, QEvent* evenvt); + + //! Returns the currently set shortcut + QString getShortcutAsString() const; + + //! Returns the currently set shortcut + QKeySequence getShortcut(); + +signals: + //! This signal is emitted when the user changed the current shortcut + void dataChangedByUser(const QKeySequence& sequence, VShortcutEditWidget* editor); + + //! This signal is emitted whenever dataChangedByUser() gets emmitted + //! and is connected to the delegate's commitData() signal + void commitData(QWidget* editor); + +public slots: + //! Sets the shortcut + //! \param shortcut The new shortcut + //! \emit_signal If true, this will emit the dataChangedByUser()-signal + void setShortcut(const QString &shortcut, bool emit_signal); + + //! Sets the shortcut + //! \param shortcut The new shortcut + //! \emit_signal If true, this will emit the dataChangedByUser()-signal + void setShortcut(const QKeySequence &shortcut, bool emit_signal); + +private slots: + //! This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mouse) + void onTextEdited(const QString& text); + +protected: + //! The current key sequence + QKeySequence CurrentKeySequence; + + //! The line to display and edit the key sequence + QLineEdit* LineEdit; + +private: + Q_DISABLE_COPY(VShortcutEditWidget) +}; + +} + +#endif // VFILEPROPERTYEDITOR_H diff --git a/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp new file mode 100644 index 000000000..d4bac678c --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp @@ -0,0 +1,133 @@ +/************************************************************************ + ** + ** @file vstringproperty.cpp + ** @author Roman Telezhynskyi + ** @date 27 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vstringproperty.h" + +#include +#include + +#include "../vproperty_p.h" + +using namespace VPE; + + +VPE::VStringProperty::VStringProperty(const QString &name, const QMap &settings) + : VProperty(name, QVariant::String), readOnly(false), typeForParent(0) +{ + VProperty::setSettings(settings); + d_ptr->VariantValue.setValue(QString()); + d_ptr->VariantValue.convert(QVariant::String); +} + +VPE::VStringProperty::VStringProperty(const QString &name) + : VProperty(name), readOnly(false), typeForParent(0) +{ + d_ptr->VariantValue.setValue(QString()); + d_ptr->VariantValue.convert(QVariant::String); +} + +QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionViewItem &options, + const QAbstractItemDelegate *delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + + QLineEdit* tmpEditor = new QLineEdit(parent); + tmpEditor->setReadOnly(readOnly); + tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + tmpEditor->setText(d_ptr->VariantValue.toString()); + + d_ptr->editor = tmpEditor; + return d_ptr->editor; +} + +QVariant VPE::VStringProperty::getEditorData(const QWidget *editor) const +{ + const QLineEdit* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->text(); + } + + return QVariant(QString()); +} + +void VPE::VStringProperty::setReadOnly(bool readOnly) +{ + this->readOnly = readOnly; +} + +void VPE::VStringProperty::setSetting(const QString &key, const QVariant &value) +{ + if (key == QLatin1String("ReadOnly")) + { + setReadOnly(value.toBool()); + } + if (key == QLatin1String("TypeForParent")) + { + setTypeForParent(value.toInt()); + } +} + +QVariant VPE::VStringProperty::getSetting(const QString &key) const +{ + if (key == QLatin1String("ReadOnly")) + { + return readOnly; + } + else if (key == QLatin1String("TypeForParent")) + { + return typeForParent; + } + else + return VProperty::getSetting(key); +} + +QStringList VPE::VStringProperty::getSettingKeys() const +{ + QStringList settings; + settings << QStringLiteral("ReadOnly") << QStringLiteral("TypeForParent"); + return settings; +} + +QString VPE::VStringProperty::type() const +{ + return QStringLiteral("string"); +} + +VPE::VProperty *VPE::VStringProperty::clone(bool include_children, VPE::VProperty *container) const +{ + return VProperty::clone(include_children, container ? container : new VStringProperty(getName(), getSettings())); +} + +void VStringProperty::UpdateParent(const QVariant &value) +{ + emit childChanged(value, typeForParent); +} + +int VStringProperty::getTypeForParent() const +{ + return typeForParent; +} + +void VStringProperty::setTypeForParent(int value) +{ + typeForParent = value; +} diff --git a/src/libs/vpropertyexplorer/plugins/vstringproperty.h b/src/libs/vpropertyexplorer/plugins/vstringproperty.h new file mode 100644 index 000000000..247801ce3 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vstringproperty.h @@ -0,0 +1,86 @@ +/************************************************************************ + ** + ** @file vstringproperty.h + ** @author Roman Telezhynskyi + ** @date 27 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VSTRINGPROPERTY_H +#define VSTRINGPROPERTY_H + +#include "../vpropertyexplorer_global.h" +#include "../vproperty.h" + +namespace VPE +{ + + +//! Class for holding a string property +class VPROPERTYEXPLORERSHARED_EXPORT VStringProperty : public VProperty +{ + Q_OBJECT +public: + VStringProperty(const QString& name, const QMap& settings); + + VStringProperty(const QString& name); + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + void setReadOnly(bool readOnly); + + //! Sets the settings. + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + + virtual void UpdateParent(const QVariant &value); + + int getTypeForParent() const; + void setTypeForParent(int value); + +protected: + bool readOnly; + int typeForParent; + +private: + Q_DISABLE_COPY(VStringProperty) +}; + +} +#endif // VSTRINGPROPERTY_H diff --git a/src/libs/vpropertyexplorer/plugins/vwidgetproperty.cpp b/src/libs/vpropertyexplorer/plugins/vwidgetproperty.cpp new file mode 100644 index 000000000..61159e9b5 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vwidgetproperty.cpp @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file vwidgetproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vwidgetproperty.h" + + +#include "../vwidgetproperty_p.h" + +using namespace VPE; + +VWidgetProperty::VWidgetProperty(const QString& name, QWidget* widget) + : VEmptyProperty(new VWidgetPropertyPrivate(name, QVariant::Invalid, widget)) +{ +} + +VWidgetProperty::~VWidgetProperty() +{ + // +} + +QWidget *VWidgetProperty::getWidget() const +{ + return static_cast(d_ptr)->Widget.data(); +} + +void VWidgetProperty::setWidget(QWidget* widget) +{ + VWidgetPropertyPrivate* tmpDPtr = static_cast(d_ptr); + QWidget* tmpOldWidget = tmpDPtr->Widget.data(); + if (tmpOldWidget) + { + tmpOldWidget->deleteLater(); + } + + tmpDPtr->Widget = widget; +} + + +QString VWidgetProperty::type() const +{ + return "widget"; +} + +VProperty* VWidgetProperty::clone(bool include_children, VProperty* container) const +{ + /* todo: This is a tricky one to clone... don't know what would be the best way to do so... Maybe serialize the + * widget somehow? + */ + return VProperty::clone(include_children, container ? container : new VWidgetProperty(getName())); +} diff --git a/src/libs/vpropertyexplorer/plugins/vwidgetproperty.h b/src/libs/vpropertyexplorer/plugins/vwidgetproperty.h new file mode 100644 index 000000000..610d91cab --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vwidgetproperty.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vwidgetproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VWIDGETROPERTY_H +#define VWIDGETROPERTY_H + +#include "../vpropertyexplorer_global.h" + +#include "vemptyproperty.h" + +#include + +namespace VPE +{ + +// todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the +// actual widget! + +//! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty +//! property +class VPROPERTYEXPLORERSHARED_EXPORT VWidgetProperty : public VEmptyProperty +{ +public: + //! Constructor + VWidgetProperty(const QString &name, QWidget* widget = nullptr); + + //! The destructor + ~VWidgetProperty(); + + //! Returns the widget held by this property + QWidget* getWidget() const; + + //! Sets the widget for this property. If there is already an old one, it will be deleted. + void setWidget(QWidget* widget); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; +}; + +} + +#endif // VWIDGETROPERTY_H diff --git a/src/libs/vpropertyexplorer/stable.cpp b/src/libs/vpropertyexplorer/stable.cpp new file mode 100644 index 000000000..dc0e7d1cb --- /dev/null +++ b/src/libs/vpropertyexplorer/stable.cpp @@ -0,0 +1,22 @@ +/************************************************************************ + ** + ** @file stable.cpp + ** @author Roman Telezhynskyi + ** @date 20 9, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +// Build the precompiled headers. +#include "stable.h" diff --git a/src/libs/vpropertyexplorer/stable.h b/src/libs/vpropertyexplorer/stable.h new file mode 100644 index 000000000..119249ac7 --- /dev/null +++ b/src/libs/vpropertyexplorer/stable.h @@ -0,0 +1,41 @@ +/************************************************************************ + ** + ** @file stable.h + ** @author Roman Telezhynskyi + ** @date 20 9, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef STABLE_H +#define STABLE_H + +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for VPropertyExplorer library.\n") +#endif + +/* Add C includes here */ + +#if defined __cplusplus +/* Add C++ includes here */ + +/*In all cases we need include core header for getting defined values*/ +#ifdef QT_CORE_LIB +# include +#endif + +#endif /*__cplusplus*/ + +#endif // STABLE_H diff --git a/src/libs/vpropertyexplorer/vabstractpropertyfactory.h b/src/libs/vpropertyexplorer/vabstractpropertyfactory.h new file mode 100644 index 000000000..2d71d137e --- /dev/null +++ b/src/libs/vpropertyexplorer/vabstractpropertyfactory.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file vabstractpropertyfactory.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VABSTRACTPROPERTYFACTORY_H +#define VABSTRACTPROPERTYFACTORY_H + +#include "vpropertyexplorer_global.h" +#include + +namespace VPE +{ + +class VProperty; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +class VPROPERTYEXPLORERSHARED_EXPORT VAbstractPropertyFactory +{ +public: + //! Empty virtual destructor + virtual ~VAbstractPropertyFactory() + {} + + //! Creates a new property of a certain type and assigns a name and description (otionally) + //! \param type The type of the property as string + //! \param name The property's name + //! \return Returns the created property or NULL if it couldn't be be created + virtual VProperty* createProperty(const QString& type, const QString &name) = 0; +}; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic pop +#endif + +} + +#endif // VABSTRACTPROPERTYFACTORY_H diff --git a/src/libs/vpropertyexplorer/vfileproperty_p.h b/src/libs/vpropertyexplorer/vfileproperty_p.h new file mode 100644 index 000000000..c24c299ea --- /dev/null +++ b/src/libs/vpropertyexplorer/vfileproperty_p.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file vfileproperty_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VFILEPROPERTY_P_H +#define VFILEPROPERTY_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include "vproperty_p.h" + +namespace VPE +{ + +class VFilePropertyPrivate : public VPropertyPrivate +{ +public: + //! File filters + QString FileFilters; + + //! Determines whether the file property is a file or a directory. Default: false + bool Directory; + + + //! Constructor passing name and type + VFilePropertyPrivate(const QString& name, QVariant::Type type, bool directory = false) + : VPropertyPrivate(name, type), FileFilters(), Directory(directory) {} + + //! Constructor + VFilePropertyPrivate() + : VPropertyPrivate(), FileFilters(), Directory(false) {} + + virtual ~VFilePropertyPrivate(); +}; + +VFilePropertyPrivate::~VFilePropertyPrivate() +{} + +} + +#endif // VFILEPROPERTY_P_H diff --git a/src/libs/vpropertyexplorer/vproperties.h b/src/libs/vpropertyexplorer/vproperties.h new file mode 100644 index 000000000..f1c531f27 --- /dev/null +++ b/src/libs/vpropertyexplorer/vproperties.h @@ -0,0 +1,38 @@ +/************************************************************************ + ** + ** @file vproperties.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTIES_H +#define VPROPERTIES_H + +#include "vproperty.h" +#include "plugins/vboolproperty.h" +#include "plugins/vcolorproperty.h" +#include "plugins/Vector3d/vvector3dproperty.h" +#include "plugins/vemptyproperty.h" +#include "plugins/venumproperty.h" +#include "plugins/vfileproperty.h" +#include "plugins/vnumberproperty.h" +#include "plugins/vobjectproperty.h" +#include "plugins/vpointfproperty.h" +#include "plugins/vshortcutproperty.h" +#include "plugins/vstringproperty.h" +#include "plugins/vwidgetproperty.h" + +#endif // VPROPERTIES_H diff --git a/src/libs/vpropertyexplorer/vproperty.cpp b/src/libs/vpropertyexplorer/vproperty.cpp new file mode 100644 index 000000000..a89cb160b --- /dev/null +++ b/src/libs/vpropertyexplorer/vproperty.cpp @@ -0,0 +1,422 @@ +/************************************************************************ + ** + ** @file vproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vproperty.h" +#include +#include +#include +#include + +#include "vproperty_p.h" + +using namespace VPE; + +//! Standard constructor, takes a name and a parent property as argument +VProperty::VProperty(const QString& name, QVariant::Type type) + : QObject(), d_ptr(new VPropertyPrivate(name, type)) +{ + +} + +VProperty::VProperty(VPropertyPrivate *d) + : d_ptr(d) +{ +} + + +VProperty::~VProperty() +{ + setParent(nullptr); + + while (!d_ptr->Children.isEmpty()) + { + VProperty* tmpChild = d_ptr->Children.takeLast(); + delete tmpChild; + } + + delete d_ptr; +} + +QString VProperty::type() const +{ + return "string"; +} + +//! Get the data how it should be displayed +QVariant VProperty::data (int column, int role) const +{ + if (column == DPC_Name && Qt::DisplayRole == role) + { + return QVariant(d_ptr->Name); + } + else if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + return d_ptr->VariantValue; + } + else if (Qt::ToolTipRole == role) + { + return QVariant(d_ptr->Description); + } + else + return QVariant(); +} + +bool VProperty::setData(const QVariant &data, int role) +{ + bool tmpResult = false; + if (Qt::EditRole == role) + { + tmpResult = (d_ptr->VariantValue != data); + setValue(data); + } + + return tmpResult; +} + +bool VProperty::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, + const QAbstractItemDelegate *delegate) const +{ + Q_UNUSED(painter); + Q_UNUSED(option); + Q_UNUSED(index); + Q_UNUSED(delegate); + + return false; +} + +//! Returns an editor widget, or NULL if it doesn't supply one +QWidget* VProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + + QItemEditorFactory *factory = new QItemEditorFactory; + QItemEditorCreatorBase *lineCreator = new QStandardItemEditorCreator(); + factory->registerEditor(QVariant::String, lineCreator); + QItemEditorFactory::setDefaultFactory(factory); + + d_ptr->editor = factory->createEditor(static_cast(d_ptr->PropertyVariantType), parent); + return d_ptr->editor; +} + +bool VProperty::setEditorData(QWidget* editor) +{ + if (!editor) + { + return false; + } + + QByteArray n = editor->metaObject()->userProperty().name(); + + if (!n.isEmpty()) + { + editor->blockSignals(true); + editor->setProperty(n, d_ptr->VariantValue); + editor->blockSignals(false); + return true; + } + + return false; +} + +//! Gets the data from the widget +QVariant VProperty::getEditorData(const QWidget* editor) const +{ + if (!editor) + { + return QVariant(); + } + + QByteArray n = editor->metaObject()->userProperty().name(); + + if (!n.isEmpty()) + { + return editor->property(n); + } + else + return QVariant(); +} + +//! Returns item flags +Qt::ItemFlags VProperty::flags(int column) const +{ + if (column == DPC_Name) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + else if (column == DPC_Data) + { + return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable; + } + else + return Qt::NoItemFlags; +} + + +void VProperty::setValue(const QVariant &value) +{ + d_ptr->VariantValue = value; + d_ptr->VariantValue.convert(static_cast(d_ptr->PropertyVariantType)); + if (d_ptr->editor != nullptr) + { + setEditorData(d_ptr->editor); + } +} + +QVariant VProperty::getValue() const +{ + return d_ptr->VariantValue; +} + +QString VProperty::serialize() const +{ + return getValue().toString(); +} + +void VProperty::deserialize(const QString& value) +{ + setValue(QVariant(value)); +} + + +void VProperty::setName(const QString& name) +{ + d_ptr->Name = name; +} + + +QString VProperty::getName() const +{ + return d_ptr->Name; +} + + +void VProperty::setDescription(const QString& desc) +{ + d_ptr->Description = desc; +} + + +QString VProperty::getDescription() const +{ + return d_ptr->Description; +} + +//! Returns a reference to the list of children +QList& VProperty::getChildren() +{ + return d_ptr->Children; +} + +//! Returns a reference to the list of children +const QList& VProperty::getChildren() const +{ + return d_ptr->Children; +} + +//! Returns the child at a certain row +VProperty* VProperty::getChild(int row) const +{ + if (row >= 0 && row < getRowCount()) + { + return d_ptr->Children.at(row); + } + else + return nullptr; +} + +//! Gets the number of children +int VProperty::getRowCount() const +{ + return d_ptr->Children.count(); +} + +//! Gets the parent of this property +VProperty* VProperty::getParent() const +{ + return d_ptr->Parent; +} + +//! Sets the parent of this property +void VProperty::setParent(VProperty* parent) +{ + if (d_ptr->Parent == parent) + { + return; + } + + VProperty* oldParent = d_ptr->Parent; + d_ptr->Parent = parent; + + if (oldParent) + { + oldParent->removeChild(this); + } + + if (d_ptr->Parent && d_ptr->Parent->getChildRow(this) == -1) + { + d_ptr->Parent->addChild(this); + } +} + +int VProperty::addChild(VProperty *child) +{ + if (child && child->getParent() != this) + { + child->setParent(this); + } + + if (!d_ptr->Children.contains(child) && child != nullptr) + { + d_ptr->Children.push_back(child); + return d_ptr->Children.count()-1; + } + else + { + return d_ptr->Children.indexOf(child); + } +} + +//! Removes a child from the children list +void VProperty::removeChild(VProperty* child) +{ + d_ptr->Children.removeAll(child); + + if (child && child->getParent() == this) + { + child->setParent(nullptr); + } +} + +//! Returns the row the child has +int VProperty::getChildRow(VProperty* child) const +{ + return d_ptr->Children.indexOf(child); +} + +//! Returns whether the views have to update the parent of this property if it changes +bool VProperty::getUpdateParent() const +{ + return d_ptr->UpdateParent; +} + +//! Returns whether the views have to update the children of this property if it changes +bool VProperty::getUpdateChildren() const +{ + return d_ptr->UpdateChildren; +} + +//! Sets whether the views should update Parents or children after this property changes +void VProperty::setUpdateBehaviour(bool update_parent, bool update_children) +{ + d_ptr->UpdateParent = update_parent; + d_ptr->UpdateChildren = update_children; +} + + +void VProperty::setSettings(const QMap& settings) +{ + QMap::const_iterator tmpIterator = settings.constBegin(); + for (; tmpIterator != settings.constEnd(); ++tmpIterator) + { + setSetting(tmpIterator.key(), tmpIterator.value()); + } +} + +QMap VProperty::getSettings() const +{ + QMap tmpResult; + + QStringList tmpKeyList = getSettingKeys(); + foreach(const QString& tmpKey, tmpKeyList) + tmpResult.insert(tmpKey, getSetting(tmpKey)); + + return tmpResult; +} + +void VProperty::setSetting(const QString& key, const QVariant& value) +{ + Q_UNUSED(key) + Q_UNUSED(value) + // Not needed in the Standard property +} + +QVariant VProperty::getSetting(const QString& key) const +{ + // Not needed in the Standard property + Q_UNUSED(key) + return QVariant(); +} + +QStringList VProperty::getSettingKeys() const +{ + return QStringList(); +} + +VProperty* VProperty::clone(bool include_children, VProperty* container) const +{ + if (!container) + { + container = new VProperty(getName(), d_ptr->PropertyVariantType); + } + + container->setName(getName()); + container->setDescription(getDescription()); + container->setValue(getValue()); + container->setSettings(getSettings()); + container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren()); + container->setPropertyType(propertyType()); + + if (include_children) + { + foreach(VProperty* tmpChild, d_ptr->Children) + container->addChild(tmpChild->clone(true)); + } + + return container; +} + +Property VProperty::propertyType() const +{ + return d_ptr->type; +} + +void VProperty::setPropertyType(const Property &type) +{ + d_ptr->type = type; +} + +void VProperty::UpdateParent(const QVariant &value) +{ + Q_UNUSED(value); +} + +void VProperty::ValueChildChanged(const QVariant &value, int typeForParent) +{ + Q_UNUSED(value) + Q_UNUSED(typeForParent) +} + +UserChangeEvent::~UserChangeEvent() +{} + +VPE::VPropertyPrivate::~VPropertyPrivate() +{} diff --git a/src/libs/vpropertyexplorer/vproperty.h b/src/libs/vpropertyexplorer/vproperty.h new file mode 100644 index 000000000..d0371b20e --- /dev/null +++ b/src/libs/vpropertyexplorer/vproperty.h @@ -0,0 +1,219 @@ +/************************************************************************ + ** + ** @file vproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTY_H +#define VPROPERTY_H + +#include "vpropertyexplorer_global.h" + +#include +#include +#include +#include +#include +#include + +namespace VPE +{ + +enum class Property : char{Simple, Complex}; + +static const int MyCustomEventType = 1099; + +class VPROPERTYEXPLORERSHARED_EXPORT UserChangeEvent : public QEvent +{ +public: + UserChangeEvent() : QEvent(static_cast(MyCustomEventType)) {} + virtual ~UserChangeEvent(); +}; + +class VPropertyPrivate; + +class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject +{ + Q_OBJECT +public: + enum DPC_DisplayColumn + { + DPC_Name = 0, + DPC_Data + }; + + //! Standard constructor, takes a name and a parent property as argument + explicit VProperty(const QString& name, QVariant::Type type = QVariant::String); + + //! Destructor + virtual ~VProperty(); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! This is used by the model to set the data + //! \param data The data to set + //! \param role The role. Default is Qt::EditRole + //! \return Returns true, if the data was changed, false if not. + virtual bool setData (const QVariant& data, int role = Qt::EditRole); + + //! This is called by the delegate when the property value is being drawn. + //! The standard implementation doesn't do anything. + //! If you reimplement this in a sub property, make sure to return true or the delegate will draw the item. + virtual bool paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, + const QAbstractItemDelegate* delegate) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Sets the property's data to the editor (returns false, if the standard delegate should do that) + virtual bool setEditorData(QWidget* editor); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Returns item flags + virtual Qt::ItemFlags flags(int column = DPC_Name) const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns the value of the property as a QVariant + virtual QVariant getValue() const; + + //! Serializes the value to a string + virtual QString serialize() const; + + //! Deserializes the value from a string + virtual void deserialize(const QString& value); + + // The following functions are experimental and not yet implemented. + /*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be + //! used. + //! \return Returns a void pointer to the data. Not all properties have to support this. By default, this + //! implementation returns a NULL pointer. + virtual void* getDataPointer(); + + //! Sets the data. + //! \return Returns a void pointer to the data. Not all properties have to support this. By default, this + //! implementation returns a NULL pointer. + virtual bool setDataPointer(void* pointer);*/ + + //! Sets the name of the property + virtual void setName(const QString& name); + + //! Gets the name of the property + virtual QString getName() const; + + //! Sets the name of the property + virtual void setDescription(const QString& desc); + + //! Gets the name of the property + virtual QString getDescription() const; + + //! Adds a child to this property + virtual int addChild(VProperty* child); + + //! Returns a reference to the list of children + virtual QList& getChildren(); + + //! Returns a reference to the list of children + virtual const QList& getChildren() const; + + //! Returns the child at a certain row + virtual VProperty* getChild(int row) const; + + //! Gets the number of children + virtual int getRowCount() const; + + //! Gets the parent of this property + virtual VProperty* getParent() const; + + //! Sets the parent of this property + virtual void setParent(VProperty* parent); + + //! Removes a child from the children list, doesn't delete the child! + virtual void removeChild(VProperty* child); + + //! Returns the row the child has + virtual int getChildRow(VProperty* child) const; + + //! Returns whether the views have to update the parent of this property if it changes + virtual bool getUpdateParent() const; + + //! Returns whether the views have to update the children of this property if it changes + virtual bool getUpdateChildren() const; + + //! Sets whether the views should update Parents or children after this property changes + virtual void setUpdateBehaviour(bool update_parent, bool update_children); + + //! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item + //! in the map. + virtual void setSettings(const QMap& settings); + + //! Get the settings. + virtual QMap getSettings() const; + + //! Sets the settings. This function has to be implemented in a subclass in order to have an effect + virtual void setSetting(const QString& key, const QVariant& value); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QVariant getSetting(const QString& key) const; + + //! Returns the list of keys of the property's settings + virtual QStringList getSettingKeys() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + + Property propertyType() const; + void setPropertyType(const Property &type); + + virtual void UpdateParent(const QVariant &value); +public slots: + virtual void ValueChildChanged(const QVariant &value, int typeForParent); +signals: + void childChanged(const QVariant &value, int typeForParent); + +protected: + //! Protected constructor + VProperty(VPropertyPrivate* d); + + //! The protected structure holding the member variables (to assure binary compatibility) + VPropertyPrivate* d_ptr; + +private: + // Provide access functions for the d_ptr + Q_DECLARE_PRIVATE(VProperty) + Q_DISABLE_COPY(VProperty) +}; + +} + +#endif // VPROPERTY_H diff --git a/src/libs/vpropertyexplorer/vproperty_p.h b/src/libs/vpropertyexplorer/vproperty_p.h new file mode 100644 index 000000000..db04d39e0 --- /dev/null +++ b/src/libs/vpropertyexplorer/vproperty_p.h @@ -0,0 +1,91 @@ +/************************************************************************ + ** + ** @file vproperty_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTY_P_H +#define VPROPERTY_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include +#include "vproperty.h" + +namespace VPE +{ + +class VPropertyPrivate +{ +public: + //! The property's value. + //! This does not have to be used by subclasses, but it makes sense in cases where QVariant supports + //! the data type. Also, this can be used as cache, so that when the data() function gets called by + //! the model, the data does not have to be converted in a QVariant every time. + QVariant VariantValue; + + //! Property name + QString Name; + + //! Description + QString Description; + + //! Specifies whether the property is empty or not + bool IsEmpty; + + //! Stores the property type + QVariant::Type PropertyVariantType; + + //! Stores whether the views have to update the parent of this property if it changes + bool UpdateParent; + + //! Stores whether the views have to update the children of this property if it changes + bool UpdateChildren; + + //! The parent property + VProperty* Parent; + + QWidget* editor; + + Property type; + + //! List of child properties + QList Children; + + //! Constructor passing name and type + VPropertyPrivate(const QString& name, QVariant::Type type) + : VariantValue(type), Name(name), Description(QString()), IsEmpty(false), PropertyVariantType(type), + UpdateParent(false), UpdateChildren(false), Parent(nullptr), editor(nullptr), type(Property::Simple), + Children(QList()) + {} + + //! Constructor + VPropertyPrivate() + : VariantValue(), Name(), Description(QString()), IsEmpty(false), PropertyVariantType(QVariant::Invalid), + UpdateParent(false), UpdateChildren(false), Parent(nullptr), editor(nullptr), type(Property::Simple), + Children(QList()) + {} + + virtual ~VPropertyPrivate(); +private: + Q_DISABLE_COPY(VPropertyPrivate) +}; + +} + +#endif // VPROPERTY_P_H diff --git a/src/libs/vpropertyexplorer/vpropertydelegate.cpp b/src/libs/vpropertyexplorer/vpropertydelegate.cpp new file mode 100644 index 000000000..04a15e350 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertydelegate.cpp @@ -0,0 +1,128 @@ +/************************************************************************ + ** + ** @file vpropertydelegate.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertydelegate.h" +#include "vproperty.h" + +#include +#include +#include +#include + +using namespace VPE; + +VPropertyDelegate::VPropertyDelegate(QObject *parent) : + QStyledItemDelegate(parent), RowHeight(0), AddRowHeight(false) +{ +} + +VPropertyDelegate::~VPropertyDelegate() +{ + // +} + +QWidget* VPropertyDelegate::createEditor (QWidget* parent, const QStyleOptionViewItem& option, + const QModelIndex& index) const +{ + QWidget* tmpWidget = nullptr; + if (index.isValid()) + { + VProperty* tmpProperty = reinterpret_cast(index.internalPointer()); + tmpWidget = tmpProperty->createEditor(parent, option, this); + } + + return tmpWidget ? tmpWidget : QStyledItemDelegate::createEditor(parent, option, index); +} + + +//! Sets the index data to the editor +void VPropertyDelegate::setEditorData (QWidget * editor, const QModelIndex & index) const +{ + bool done = false; + if (index.isValid() && editor) + { + VProperty* tmpProperty = reinterpret_cast(index.internalPointer()); + done = tmpProperty->setEditorData(editor); + } + + if (!done) + { + QStyledItemDelegate::setEditorData(editor, index); + } +} + +//! Updates the index data +void VPropertyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const +{ + QVariant tmpData; + if (index.isValid() && editor) + { + VProperty* tmpProperty = reinterpret_cast(index.internalPointer()); + tmpData = tmpProperty->getEditorData(editor); + } + + if (tmpData.isNull()) + { + QStyledItemDelegate::setModelData(editor, model, index); + } + else + model->setData(index, tmpData); +} + +QSize VPropertyDelegate::sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + QSize tmpStandardSizeHint = QStyledItemDelegate::sizeHint(option, index); + tmpStandardSizeHint.setHeight(tmpStandardSizeHint.height() + 1); + + if (RowHeight > 0) + { + return QSize(tmpStandardSizeHint.width(), AddRowHeight ? tmpStandardSizeHint.height() + RowHeight : RowHeight); + } + else + return tmpStandardSizeHint; +} + +void VPropertyDelegate::setRowHeight(int height, bool add_to_standard) +{ + RowHeight = height; + AddRowHeight = add_to_standard; +} + +void VPropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + bool done = false; + if (index.isValid() && index.column() == 1) + { + done = reinterpret_cast(index.internalPointer())->paint(painter, option, index, this); + } + + if (!done) + { + QStyledItemDelegate::paint(painter, option, index); + } + + QColor tmpPenColor = static_cast(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option)); + + QPen tmpOldPen = painter->pen(); + painter->setPen(QPen(tmpPenColor)); + painter->drawLine(option.rect.right(), option.rect.y(), option.rect.right(), option.rect.bottom()); + painter->drawLine(option.rect.x(), option.rect.bottom(), option.rect.right(), option.rect.bottom()); + painter->setPen(tmpOldPen); +} diff --git a/src/libs/vpropertyexplorer/vpropertydelegate.h b/src/libs/vpropertyexplorer/vpropertydelegate.h new file mode 100644 index 000000000..9b15abeba --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertydelegate.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file vpropertydelegate.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYDELEGATE_H +#define VPROPERTYDELEGATE_H + +#include "vpropertyexplorer_global.h" + +#include + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + explicit VPropertyDelegate(QObject *parent = 0); + virtual ~VPropertyDelegate(); + + //! Creates the editor widget + virtual QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; + + //! Sets the index data to the editor + virtual void setEditorData (QWidget * editor, const QModelIndex & index) const; + + //! Updates the index data + virtual void setModelData (QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const; + + //! Returns the size hint + virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const; + + //! Sets the row height. Set this to 0 and the standard will be taken + void setRowHeight(int height = 0, bool add_to_standard = false); + + //! Renders the delegate using the given painter and style option for the item specified by index. + virtual void paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; + +protected: + int RowHeight; + bool AddRowHeight; + + +}; + +} + +#endif // VPROPERTYDELEGATE_H diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pri b/src/libs/vpropertyexplorer/vpropertyexplorer.pri new file mode 100644 index 000000000..d5ab89175 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pri @@ -0,0 +1,70 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +SOURCES += \ + $$PWD/vproperty.cpp \ + $$PWD/vpropertydelegate.cpp \ + $$PWD/vpropertyfactorymanager.cpp \ + $$PWD/vpropertyformview.cpp \ + $$PWD/vpropertyformwidget.cpp \ + $$PWD/vpropertymodel.cpp \ + $$PWD/vpropertyset.cpp \ + $$PWD/vpropertytreeview.cpp \ + $$PWD/vserializedproperty.cpp \ + $$PWD/plugins/vwidgetproperty.cpp \ + $$PWD/plugins/vemptyproperty.cpp \ + $$PWD/plugins/vboolproperty.cpp \ + $$PWD/plugins/vshortcutproperty.cpp \ + $$PWD/plugins/vcolorproperty.cpp \ + $$PWD/plugins/vshortcutpropertyeditor.cpp \ + $$PWD/plugins/venumproperty.cpp \ + $$PWD/plugins/vfileproperty.cpp \ + $$PWD/plugins/vcolorpropertyeditor.cpp \ + $$PWD/plugins/vfilepropertyeditor.cpp \ + $$PWD/plugins/vnumberproperty.cpp \ + $$PWD/plugins/Vector3d/vvector3dproperty.cpp \ + $$PWD/vstandardpropertyfactory.cpp \ + $$PWD/plugins/vstringproperty.cpp \ + $$PWD/plugins/vpointfproperty.cpp \ + $$PWD/plugins/vobjectproperty.cpp \ + $$PWD/stable.cpp + +HEADERS +=\ + $$PWD/vpropertyexplorer_global.h \ + $$PWD/vpropertyfactorymanager_p.h \ + $$PWD/vpropertytreeview_p.h \ + $$PWD/vpropertyset_p.h \ + $$PWD/vabstractpropertyfactory.h \ + $$PWD/vfileproperty_p.h \ + $$PWD/vwidgetproperty_p.h \ + $$PWD/vpropertymodel_p.h \ + $$PWD/vstandardpropertyfactory.h \ + $$PWD/vpropertyformview_p.h \ + $$PWD/vpropertytreeview.h \ + $$PWD/vpropertyformwidget_p.h \ + $$PWD/vpropertydelegate.h \ + $$PWD/vproperty_p.h \ + $$PWD/vpropertyformwidget.h \ + $$PWD/vpropertyformview.h \ + $$PWD/vpropertyset.h \ + $$PWD/vpropertymodel.h \ + $$PWD/vproperty.h \ + $$PWD/plugins/vwidgetproperty.h \ + $$PWD/plugins/vcolorproperty.h \ + $$PWD/plugins/vboolproperty.h \ + $$PWD/plugins/vcolorpropertyeditor.h \ + $$PWD/plugins/vshortcutpropertyeditor.h \ + $$PWD/plugins/vemptyproperty.h \ + $$PWD/plugins/vshortcutproperty.h \ + $$PWD/plugins/venumproperty.h \ + $$PWD/plugins/vfilepropertyeditor.h \ + $$PWD/plugins/vfileproperty.h \ + $$PWD/plugins/vnumberproperty.h \ + $$PWD/plugins/Vector3d/vvector3dproperty.h \ + $$PWD/vpropertyfactorymanager.h \ + $$PWD/vserializedproperty.h \ + $$PWD/plugins/vstringproperty.h \ + $$PWD/plugins/vpointfproperty.h \ + $$PWD/plugins/vobjectproperty.h \ + $$PWD/vproperties.h \ + $$PWD/stable.h diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pro b/src/libs/vpropertyexplorer/vpropertyexplorer.pro new file mode 100644 index 000000000..7c85ea983 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pro @@ -0,0 +1,112 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-08-26T14:18:08 +# +#------------------------------------------------- + +# File with common stuff for whole project +include(../../../Valentina.pri) + +# Library use widgets +QT += widgets + +# We don't need gui library. +QT -= gui + +# Name of library +TARGET = vpropertyexplorer + +# We want create library +TEMPLATE = lib + +# We use C++11 standard +CONFIG += c++11 + +# Since Qt 5.4.0 the source code location is recorded only in debug builds. +# We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT. +DEFINES += QT_MESSAGELOGCONTEXT + +DEFINES += VPROPERTYEXPLORER_LIBRARY + +# directory for executable file +DESTDIR = bin + +# files created moc +MOC_DIR = moc + +# objecs files +OBJECTS_DIR = obj + +include(vpropertyexplorer.pri) + +# Set "make install" command for Unix-like systems. +unix:!macx{ + isEmpty(PREFIX_LIB){ + isEmpty(PREFIX){ + PR_LIB = $$DEFAULT_PREFIX + } else { + PR_LIB = $$PREFIX + } + contains(QMAKE_HOST.arch, x86_64) { + PREFIX_LIB = $$PR_LIB/lib64 + } else { + PREFIX_LIB = $$PR_LIB/lib + } + } + target.path = $$PREFIX_LIB + INSTALLS += target +} + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +$$enable_ccache() + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +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}/$${MOC_DIR}" \ + $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + #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_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}/$${MOC_DIR}" \ + $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + +}else{ + # Release mode + + !unix:*-g++{ + QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll + } + + !macx:!win32-msvc*{ + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. TODO: find way how to strip binary file. + QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_CFLAGS_RELEASE += -g -gdwarf-3 + QMAKE_LFLAGS_RELEASE = + + # Strip debug symbols. + QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg && + QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} && + QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET} + } +} diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer_global.h b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h new file mode 100644 index 000000000..783cdda43 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h @@ -0,0 +1,32 @@ +/************************************************************************ + ** + ** @file vpropertyexplorer_global.h + ** @author Roman Telezhynskyi + ** @date 26 8, 2014 + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYEXPLORER_GLOBAL_H +#define VPROPERTYEXPLORER_GLOBAL_H + +#include + +#if defined(VPROPERTYEXPLORER_LIBRARY) +# define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_EXPORT +#else +# define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // VPROPERTYEXPLORER_GLOBAL_H diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp new file mode 100644 index 000000000..95f16804a --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp @@ -0,0 +1,154 @@ +/************************************************************************ + ** + ** @file vpropertyfactorymanager.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertyfactorymanager.h" +#include "vpropertyfactorymanager_p.h" + +#include "vstandardpropertyfactory.h" +#include "vproperty.h" + +using namespace VPE; + + +VPropertyFactoryManager* VPropertyFactoryManager::DefaultManager = NULL; + +VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent) + : QObject(parent), d_ptr(new VPropertyFactoryManagerPrivate()) +{ + +} + +VPropertyFactoryManager::~VPropertyFactoryManager() +{ + // Delete all factories + QList tmpFactories = d_ptr->Factories.values(); + while (!tmpFactories.isEmpty()) + { + VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast(); + tmpFactories.removeAll(tmpFactory); + delete tmpFactory; + } + + + delete d_ptr; + if (this == DefaultManager) + { + DefaultManager = NULL; + } +} + +void VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory) +{ + if (type.isEmpty()) + { + return; + } + + // Remove old factory + unregisterFactory(getFactory(type), type, true); + // Register new one + d_ptr->Factories[type] = factory; +} + +void VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type, + bool delete_if_unused) +{ + if (!factory) + { + return; + } + + if (!type.isEmpty()) + { + // Remove all occurances + QString tmpKey; + do + { + tmpKey = d_ptr->Factories.key(factory, QString()); + if (!tmpKey.isEmpty()) + { + d_ptr->Factories.remove(tmpKey); + } + } while(!tmpKey.isEmpty()); + } + else + { + // Only remove one type + if (d_ptr->Factories.value(type, NULL) == factory) + { + d_ptr->Factories.remove(type); + } + } + + if (delete_if_unused && !isRegistered(factory)) + { + delete factory; + } +} + +bool VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factory) +{ + return (!d_ptr->Factories.key(factory, QString()).isEmpty()); +} + +VAbstractPropertyFactory* VPropertyFactoryManager::getFactory(const QString& type) +{ + return d_ptr->Factories.value(type, NULL); +} + + +VProperty* VPropertyFactoryManager::createProperty(const QString& type, const QString& name, const QString& description, + const QString &default_value) +{ + VAbstractPropertyFactory* tmpFactory = getFactory(type); + VProperty* tmpResult = NULL; + if (tmpFactory) + { + tmpResult = tmpFactory->createProperty(type, name); + + if (tmpResult) + { + tmpResult->setDescription(description); + + if (!default_value.isEmpty()) + { + tmpResult->deserialize(default_value); + } + } + } + + return tmpResult; +} + +VPropertyFactoryManager *VPropertyFactoryManager::getDefaultManager() +{ + if (!DefaultManager) + { + DefaultManager = new VPropertyFactoryManager(); + /*VStandardPropertyFactory* tmpStandardProp = */new VStandardPropertyFactory(DefaultManager); + } + + return DefaultManager; +} + +QStringList VPropertyFactoryManager::getSupportedTypes() +{ + return d_ptr->Factories.keys(); +} diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.h b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h new file mode 100644 index 000000000..4e8c2060f --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h @@ -0,0 +1,92 @@ +/************************************************************************ + ** + ** @file vpropertyfactorymanager.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFACTORYMANAGER_H +#define VPROPERTYFACTORYMANAGER_H + +#include "vpropertyexplorer_global.h" +#include + +namespace VPE +{ + +class VAbstractPropertyFactory; +class VPropertyFactoryManagerPrivate; +class VProperty; + +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFactoryManager : public QObject +{ + Q_OBJECT +public: + //! Constructor + VPropertyFactoryManager(QObject* parent = nullptr); + + //! Destructor + virtual ~VPropertyFactoryManager(); + + //! Register a factory to the factory manager + //! Note that the manager takes ownership of the factory, so don't delete it. + //! You can unregister a factory using unregisterFactory() + void registerFactory(const QString& type, VAbstractPropertyFactory* factory); + + //! Removes a factory from the manager. + //! \param factory The factory to unregister + //! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered + //! for are being removed + //! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this + //! manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on. + void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(), + bool delete_if_unused = true); + + //! Returns whether a factory is registered (and thus owned) by this factory manager + bool isRegistered(VAbstractPropertyFactory* factory); + + //! Returns a pointer to a factory registered for a certain type + //! \param type The type to return the factory for + //! \return Returns NULL, if there is none registered for this type + VAbstractPropertyFactory* getFactory(const QString& type); + + //! Creates a new property of a certain type and assigns a name and description (otionally) + //! \param type The type of the property as string + //! \param name The name of the property + //! \param description The property's description. Optional. + //! \param default_value The properties initial value as string. Optional. + //! \return Returns the created property or NULL if it couldn't be be created + VProperty* createProperty(const QString& type, const QString& name, const QString& description = QString(), + const QString& default_value = QString()); + + //! Returns the default manager. + static VPropertyFactoryManager* getDefaultManager(); + + //! Returns a list of all supported property types + QStringList getSupportedTypes(); + +protected: + VPropertyFactoryManagerPrivate* d_ptr; + + //! The default manager + static VPropertyFactoryManager* DefaultManager; +private: + Q_DISABLE_COPY(VPropertyFactoryManager) +}; + +} + +#endif // VPROPERTYFACTORYMANAGER_H diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager_p.h b/src/libs/vpropertyexplorer/vpropertyfactorymanager_p.h new file mode 100644 index 000000000..4c517d5ee --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager_p.h @@ -0,0 +1,44 @@ +/************************************************************************ + ** + ** @file vpropertyfactorymanager_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFACTORYMANAGER_P_H +#define VPROPERTYFACTORYMANAGER_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include + +namespace VPE +{ + +class VAbstractPropertyFactory; + +class VPropertyFactoryManagerPrivate +{ +public: + VPropertyFactoryManagerPrivate():Factories(QMap()){} + QMap Factories; + +}; + +} + +#endif // VPROPERTYFACTORYMANAGER_P_H diff --git a/src/libs/vpropertyexplorer/vpropertyformview.cpp b/src/libs/vpropertyexplorer/vpropertyformview.cpp new file mode 100644 index 000000000..c76ebcfe1 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformview.cpp @@ -0,0 +1,222 @@ +/************************************************************************ + ** + ** @file vpropertyformview.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertyformview.h" +#include "vpropertymodel.h" +#include "vpropertyset.h" +#include +#include +#include + +#include "vpropertyformview_p.h" + +using namespace VPE; + +VPropertyFormView::VPropertyFormView(QWidget* parent) + : VPropertyFormWidget(new VPropertyFormViewPrivate(), parent) +{ + // +} + +VPropertyFormView::VPropertyFormView(VPropertyModel* model, QWidget *parent) + : VPropertyFormWidget(new VPropertyFormViewPrivate(), parent) +{ + setModel(model); +} + +VPropertyFormView::VPropertyFormView(VPropertySet* property_set, QWidget *parent) + : VPropertyFormWidget(new VPropertyFormViewPrivate(), parent) +{ + setPropertySet(property_set); +} + +VPropertyFormView::~VPropertyFormView() +{ + // Nothing to do +} + +void VPropertyFormView::build() +{ + VPropertyFormWidget::build(); + + // Go through all sub widgets and connect + connectPropertyFormWidget(this); +} + +void VPropertyFormView::setModel(VPropertyModel *model) +{ + // Remove old model or set + removeModelAndSet(); + + // Set model + static_cast(d_ptr)->Model = model; + if (model) + { + // Set the property list + if (model->getPropertySet()) + { + d_ptr->Properties = model->getPropertySet()->getRootProperties(); + } + + // Connect signals // todo: more signals neccesary!!! + connect(model, SIGNAL(destroyed()), this, SLOT(modelDestroyed())); + connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, + SLOT(rowsInserted(QModelIndex, int, int))); + connect(model, SIGNAL(modelReset()), this, SLOT(modelReset())); + connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, + SLOT(rowsRemoved(QModelIndex, int, int))); + } + + // Build the widget + updatePropertyList(); +} + +void VPropertyFormView::setPropertySet(VPropertySet* property_set) +{ + // Remove old model or set + removeModelAndSet(); + + // Set property set + static_cast(d_ptr)->PropertySet = property_set; + if (property_set) + { + // Set the property list + d_ptr->Properties = property_set->getRootProperties(); + } + + // Build the widget + updatePropertyList(); +} + +void VPropertyFormView::rowsRemoved(const QModelIndex &parent, int start, int end) +{ + // todo: Only rebuild the neccessary parts + Q_UNUSED(parent) + Q_UNUSED(start) + Q_UNUSED(end) + updatePropertyList(); +} + +void VPropertyFormView::rowsInserted(const QModelIndex &parent, int start, int end) +{ + // todo: Only rebuild the neccessary parts + Q_UNUSED(parent) + Q_UNUSED(start) + Q_UNUSED(end) + updatePropertyList(); +} + +void VPropertyFormView::modelReset() +{ + updatePropertyList(); +} + +void VPropertyFormView::modelDestroyed() +{ + removeModelAndSet(); + updatePropertyList(); +} + +void VPropertyFormView::dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right) +{ + Q_UNUSED(top_left) + Q_UNUSED(bottom_right) + if (static_cast(d_ptr)->IgnoreDataChangedSignal) + { + return; + } + // todo: handle data changes +} + +void VPropertyFormView::dataSubmitted(VProperty *property) +{ + VPropertyModel* tmpModel = static_cast(d_ptr)->Model; + + if (tmpModel && d_ptr->UpdateEditors) + { + static_cast(d_ptr)->IgnoreDataChangedSignal = true; + tmpModel->onDataChangedByModel(property); + static_cast(d_ptr)->IgnoreDataChangedSignal = false; + } +} + +void VPropertyFormView::showEvent(QShowEvent *event) +{ + Q_UNUSED(event) + if (static_cast(d_ptr)->NeedsRebuild) + { + build(); + } + static_cast(d_ptr)->NeedsRebuild = false; +} + +void VPropertyFormView::updatePropertyList() +{ + VPropertyModel* tmpModel = static_cast(d_ptr)->Model; + VPropertySet* tmpSet = static_cast(d_ptr)->PropertySet; + + if (tmpModel && tmpModel->getPropertySet()) + { + d_ptr->Properties = tmpModel->getPropertySet()->getRootProperties(); + } + else if (tmpSet) + { + d_ptr->Properties = tmpSet->getRootProperties(); + } + else + d_ptr->Properties.clear(); + + if (isVisible()) + { + build(); + } + else + static_cast(d_ptr)->NeedsRebuild = true; +} + +void VPropertyFormView::removeModelAndSet() +{ + if (static_cast(d_ptr)->Model) + { + disconnect(static_cast(d_ptr)->Model, 0, this, 0); + static_cast(d_ptr)->Model = nullptr; + } + + static_cast(d_ptr)->NeedsRebuild = true; + d_ptr->Properties.clear(); + static_cast(d_ptr)->PropertySet = nullptr; +} + +void VPropertyFormView::connectPropertyFormWidget(VPropertyFormWidget *widget) +{ + if (!widget) + { + return; + } + + connect(widget, &VPropertyFormWidget::propertyDataSubmitted, this, &VPropertyFormView::dataSubmitted, + Qt::UniqueConnection); + QList tmpList = widget->getChildPropertyFormWidgets(); + + foreach(VPropertyFormWidget* tmpEditorWidget, tmpList) + { + connectPropertyFormWidget(tmpEditorWidget); + } +} diff --git a/src/libs/vpropertyexplorer/vpropertyformview.h b/src/libs/vpropertyexplorer/vpropertyformview.h new file mode 100644 index 000000000..3493ac539 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformview.h @@ -0,0 +1,104 @@ +/************************************************************************ + ** + ** @file vpropertyformview.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFORMVIEW_H +#define VPROPERTYFORMVIEW_H + +#include "vpropertyexplorer_global.h" +#include +#include "vpropertyformwidget.h" + +namespace VPE +{ + +class VProperty; +class VPropertyModel; +class VPropertySet; + +//! This class populates a form layout with the properties in a model +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormView : public VPropertyFormWidget +{ + Q_OBJECT +public: + //! Constructor + explicit VPropertyFormView(QWidget *parent = 0); + + //! Constructor + explicit VPropertyFormView(VPropertyModel* model, QWidget *parent = 0); + + //! Constructor + explicit VPropertyFormView(VPropertySet* property_set, QWidget *parent = 0); + + //! Destructor + virtual ~VPropertyFormView(); + + +public slots: + //! Rebuilds the whole form + virtual void build(); + + //! Set the source model. Leads to the rebuild of the form + //! \param model The model to use + void setModel(VPropertyModel* model); + + //! Set the property set to use. Note that if using a property set directly, adding and removing properties to the + //! property set leads to undifined behaviour for the property set misses notification signals. + //! \param property_set The property set to use + void setPropertySet(VPropertySet* property_set); + + //! Called when a row gets removed in the model + void rowsRemoved(const QModelIndex& parent, int start, int end); + + //! Called when a new row is being inserted into the model + void rowsInserted(const QModelIndex& parent, int start, int end); + + //! Called when the model is being reset + void modelReset(); + + +private slots: + //! Called, when the model gets destroyed + void modelDestroyed(); + + //! Called when data in the model gets changed + void dataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right); + + //! Updates the model when data was submitted by the view + void dataSubmitted(VProperty* property); + +protected: + void showEvent(QShowEvent* event); + + //! Rebuilds the widegt only if it is visible + void updatePropertyList(); + + //! Removes the model and property set if they were set + void removeModelAndSet(); + + //! Function to handle newly created VPropertyWidgets + virtual void connectPropertyFormWidget(VPropertyFormWidget* widget); + +private: + Q_DISABLE_COPY(VPropertyFormView) +}; + +} // Namespace VPE + +#endif // VPROPERTYFORMVIEW_H diff --git a/src/libs/vpropertyexplorer/vpropertyformview_p.h b/src/libs/vpropertyexplorer/vpropertyformview_p.h new file mode 100644 index 000000000..a97758f80 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformview_p.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file vpropertyformview_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFORMVIEW_P_H +#define VPROPERTYFORMVIEW_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include "vpropertyformwidget_p.h" + +namespace VPE +{ + +class VPropertyModel; +class VPropertySet; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +class VPropertyFormViewPrivate : public VPropertyFormWidgetPrivate +{ +public: + //! The current property model + VPropertyModel* Model; + + //! The currently used property set + VPropertySet* PropertySet; + + //! Determines whether the widget needs to be rebuild + bool NeedsRebuild; + + //! Helper variable + bool IgnoreDataChangedSignal; + + VPropertyFormViewPrivate() + : VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(NULL), NeedsRebuild(false), + IgnoreDataChangedSignal(false) + {} + + VPropertyFormViewPrivate(VPropertyModel* prop_model) + : VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(NULL), NeedsRebuild(false), + IgnoreDataChangedSignal(false) + {} + + VPropertyFormViewPrivate(VPropertySet* prop_set) + : VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(prop_set), NeedsRebuild(false), + IgnoreDataChangedSignal(false) + {} + + virtual ~VPropertyFormViewPrivate() + {} + +private: + Q_DISABLE_COPY(VPropertyFormViewPrivate) +}; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic pop +#endif + +} + +#endif // VPROPERTYFORMVIEW_P_H diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp new file mode 100644 index 000000000..fa0a976e7 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -0,0 +1,363 @@ +/************************************************************************ + ** + ** @file vpropertyformwidget.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertyformwidget.h" + +#include +#include "vpropertyformwidget_p.h" + +#include "plugins/vwidgetproperty.h" +#include +#include +#include "vproperty.h" +#include + +using namespace VPE; + +VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QString &description, + const QList& properties, QWidget *parent) + : QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties)) +{ + build(); + setToolTip(description); + setWhatsThis(description); +} + +VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidget *parent) + : QGroupBox(parent), d_ptr(new VPropertyFormWidgetPrivate()) +{ + if (parent_property) + { + d_ptr->Properties = parent_property->getChildren(); + build(); + setTitle(parent_property->getName()); + setToolTip(parent_property->getDescription()); + setWhatsThis(parent_property->getDescription()); + } +} + +VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title, + const QString &description) + : QGroupBox(title, parent), d_ptr(d_pointer) +{ + build(); + setToolTip(description); + setWhatsThis(description); +} + +VPropertyFormWidget::~VPropertyFormWidget() +{ + delete d_ptr; +} + + +void VPropertyFormWidget::build() +{ + // Clear the old content, delete old widgets + d_ptr->EditorWidgets.clear(); + if (layout()) + { + QLayoutItem *child; + while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0) + { + if (child->widget()) + { + delete child->widget(); + } + delete child; + } + delete layout(); + } + + // Create new content + if (d_ptr->Properties.isEmpty()) + { + return; //... only if there are properties + } + + QFormLayout* tmpFormLayout = new QFormLayout(this); + setLayout(tmpFormLayout); + + for (int i = 0; i < d_ptr->Properties.count(); ++i) + { + // Get the current property + VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr); + if (!tmpProperty) + { + continue; + } + + if (tmpProperty->getRowCount() > 0) + { + if (tmpProperty->propertyType() == Property::Complex) + { + buildEditor(tmpProperty, tmpFormLayout, Property::Complex); + QWidget *group = new QWidget(this); + tmpFormLayout->addRow(group); + + QFormLayout* subFormLayout = new QFormLayout(group); + QMargins margins = subFormLayout->contentsMargins(); + margins.setTop(0); + margins.setLeft(14); + subFormLayout->setContentsMargins(margins); + + group->setLayout(subFormLayout); + QList children = tmpProperty->getChildren(); + for (int j = 0; j < children.size(); ++j) + { + buildEditor(children[j], subFormLayout); + connect(children[j], &VProperty::childChanged, tmpProperty, &VProperty::ValueChildChanged, + Qt::UniqueConnection); + ++i; + d_ptr->Properties.insert(i, children[j]); + } + } + else + { + // Child properties, the property itself is not being added + VPropertyFormWidget* tmpNewFormWidget = new VPropertyFormWidget(tmpProperty, this); + tmpFormLayout->addRow(tmpNewFormWidget); + d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget)); + tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors); + } + } + else if (tmpProperty->type() == "widget") + { + VWidgetProperty* tmpWidgetProperty = static_cast(tmpProperty); + tmpFormLayout->addRow(tmpWidgetProperty->getWidget()); + d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget())); + } + else + { + buildEditor(tmpProperty, tmpFormLayout); + } + } +} + +void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayout, Property type) +{ + // Add property (no child properties) + // Create the editor (if it doesn't work, create empty widget) + QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr); + if (!tmpEditor) + { + tmpEditor = new QWidget(this); + } + + // set tooltip and whats this + tmpEditor->setToolTip(property->getDescription()); + tmpEditor->setWhatsThis(property->getDescription()); + + // Install event filter + tmpEditor->installEventFilter(this); + + // Set the editor data + property->setEditorData(tmpEditor); + + // add new row + if (type == Property::Complex) + { + QString name = ""+property->getName()+""; + formLayout->addRow(name, tmpEditor); + } + else + { + formLayout->addRow(property->getName(), tmpEditor); + } + + d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpEditor)); +} + +void VPropertyFormWidget::commitData() +{ + for (int i = 0; i < d_ptr->Properties.count(); ++i) + { + commitData(i); + } +} + +void VPropertyFormWidget::loadData() +{ + for (int i = 0; i < d_ptr->Properties.count(); ++i) + { + loadData(i); + } +} + +void VPropertyFormWidget::commitData(int row) +{ + if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) + { + return; + } + + VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row]; + VProperty* tmpProperty = d_ptr->Properties[row]; + if (tmpEditorWidget.FormWidget) + { + tmpEditorWidget.FormWidget->commitData(); + } + else if (tmpEditorWidget.Editor && tmpProperty) + { + QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor); + QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole); + if (oldValue != newValue) + { + VProperty *parent = tmpProperty->getParent(); + if (parent == nullptr) + { + tmpProperty->setValue(newValue); + emit propertyDataSubmitted(tmpProperty); + } + else if (parent->propertyType() == Property::Complex) + { + tmpProperty->UpdateParent(newValue); + emit propertyDataSubmitted(parent); + } + else + { + tmpProperty->setValue(newValue); + emit propertyDataSubmitted(tmpProperty); + } + } + } +} + +void VPropertyFormWidget::loadData(int row) +{ + if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count()) + { + return; + } + + VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[row]; + VProperty* tmpProperty = d_ptr->Properties[row]; + if (tmpEditorWidget.FormWidget) + { + tmpEditorWidget.FormWidget->loadData(); + } + else if (tmpEditorWidget.Editor && tmpProperty) + { + tmpProperty->setEditorData(tmpEditorWidget.Editor); + } +} + +void VPropertyFormWidget::setCommitBehaviour(bool auto_commit) +{ + d_ptr->UpdateEditors = auto_commit; + + QList tmpChildFormWidgets = getChildPropertyFormWidgets(); + foreach(VPropertyFormWidget* tmpChild, tmpChildFormWidgets) + { + if (tmpChild) + { + tmpChild->setCommitBehaviour(auto_commit); + } + } +} + +QList VPropertyFormWidget::getChildPropertyFormWidgets() const +{ + QList tmpResult; + foreach(const VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget, d_ptr->EditorWidgets) + { + if (tmpEditorWidget.FormWidget) + { + tmpResult.append(tmpEditorWidget.FormWidget); + } + } + + return tmpResult; +} + +bool VPropertyFormWidget::eventFilter(QObject *object, QEvent *event) +{ + if (!d_ptr->UpdateEditors) + { + return false; + } + + QWidget* editor = qobject_cast(object); + if (!editor) + { + return false; + } + + if (event->type() == QEvent::KeyPress) + { + switch (static_cast(event)->key()) + { + case Qt::Key_Tab: + case Qt::Key_Backtab: + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Escape: + commitData(editor); + event->accept(); + return true; + default: + return false; + } + } + else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow())) + { + commitData(editor); + return false; + } + else if (event->type() == QEvent::ShortcutOverride) + { + if (static_cast(event)->key() == Qt::Key_Escape) + { + commitData(editor); + event->accept(); + return true; + } + } + else if (event->type() == MyCustomEventType) + { + commitData(editor); + event->accept(); + return true; + } + else + { + return QGroupBox::eventFilter(object, event); + } + + // Default: + return false; +} + +void VPropertyFormWidget::commitData(const QWidget *editor) +{ + if (!editor) + { + return; + } + + for (int i = 0; i < d_ptr->EditorWidgets.count(); ++i) + { + VPropertyFormWidgetPrivate::SEditorWidget& tmpEditorWidget = d_ptr->EditorWidgets[i]; + if (tmpEditorWidget.Editor == editor) + { + commitData(i); + } + } +} diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.h b/src/libs/vpropertyexplorer/vpropertyformwidget.h new file mode 100644 index 000000000..55338084c --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.h @@ -0,0 +1,102 @@ +/************************************************************************ + ** + ** @file vpropertyformwidget.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFORMWIDGET_H +#define VPROPERTYFORMWIDGET_H + +#include +#include +#include "vproperty.h" + +class QFormLayout; + +namespace VPE +{ + +class VPropertyFormWidgetPrivate; +class VPropertySet; + +//! Class that displays the sub properties of a property using a form layout +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormWidget : public QGroupBox +{ + Q_OBJECT +public: + //! Constructor + VPropertyFormWidget(const QString& title, const QString& description, const QList& properties, + QWidget* parent); + + //! Constructor + VPropertyFormWidget(VProperty* parent_property, QWidget* parent); + + //! Destructor + ~VPropertyFormWidget(); + + + //! Returns a list of all child property form widgets (note that indirect children will not be in the list) + QList getChildPropertyFormWidgets() const; + +public slots: + //! Rebuilds the whole form + virtual void build(); + + void buildEditor(VProperty *property, QFormLayout *formLayout, Property type = Property::Simple); + + //! Reads the data from the editors and commits it to the properties + void commitData(); + + //! Refills the editors with the propertie's data + void loadData(); + + //! Reads the data from row'th editor and commits it to the property + void commitData(int row); + + //! Reads the data from row'th property + void loadData(int row); + + //! Sets the update behaviour + //! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be + //! submitted to the property. + void setCommitBehaviour(bool auto_commit = true); + +signals: + //! Emitted whenever a property data changes + void propertyDataSubmitted(VProperty* property); + +protected: + //! Protected Constructor + VPropertyFormWidget(VPropertyFormWidgetPrivate* d_pointer, QWidget* parent, const QString &title = QString(), + const QString &description = QString()); + + //! The protected data + VPropertyFormWidgetPrivate* d_ptr; + + //! Event filter for the editor widgets + bool eventFilter(QObject *object, QEvent *event); + + //! Commits data of an editor + void commitData(const QWidget* editor); + +private: + Q_DISABLE_COPY(VPropertyFormWidget) +}; + +} // Namespace VPE + +#endif // VPROPERTYFORMWIDGET_H diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget_p.h b/src/libs/vpropertyexplorer/vpropertyformwidget_p.h new file mode 100644 index 000000000..013e607fd --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyformwidget_p.h @@ -0,0 +1,81 @@ +/************************************************************************ + ** + ** @file vpropertyformwidget_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYFORMWIDGET_P_H +#define VPROPERTYFORMWIDGET_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include "vproperty.h" + +namespace VPE +{ + +#ifdef Q_CC_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +class VPropertyFormWidgetPrivate +{ +public: + //! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null) + struct SEditorWidget + { + SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {} + SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {} + SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {} + + VPropertyFormWidget* FormWidget; + QWidget* Editor; + }; + + //! The root property to use + QList Properties; + + //! Binds the properties to their editors + QList EditorWidgets; + + //! Determines the behaviour of the editors. If this is true, when a focus out event etc. happens, the data will be + //! submitted to the VProperty. If false, you will have to call commitData() yourself. + bool UpdateEditors; + + //! Default constructor + VPropertyFormWidgetPrivate() + : Properties(QList()), EditorWidgets(QList()), UpdateEditors(true) + {} + + //! Constructor + VPropertyFormWidgetPrivate(const QList& properties) + : Properties(properties), EditorWidgets(QList()), UpdateEditors(true) + {} + + virtual ~VPropertyFormWidgetPrivate() + {} +}; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic pop +#endif + +} + +#endif // VPROPERTYFORMWIDGET_P_H diff --git a/src/libs/vpropertyexplorer/vpropertymodel.cpp b/src/libs/vpropertyexplorer/vpropertymodel.cpp new file mode 100644 index 000000000..6597ed9f3 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertymodel.cpp @@ -0,0 +1,362 @@ +/************************************************************************ + ** + ** @file vpropertymodel.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertymodel.h" + +#include +#include "vpropertyset.h" + +using namespace VPE; + +#include "vpropertymodel_p.h" + +VPropertyModel::VPropertyModel(VPropertyModelPrivate *d, QObject *parent) + : QAbstractItemModel(parent), d_ptr(d) +{ +} + + +VPropertyModel::VPropertyModel(QObject * parent) : + QAbstractItemModel(parent), d_ptr(new VPropertyModelPrivate()) +{ +} + +VPropertyModel::~VPropertyModel() +{ + delete d_ptr->Properties; + delete d_ptr; +} + +//! Adds the property to the model and attaches it to the parentid +bool VPropertyModel::addProperty(VProperty* property, const QString& id, const QString &parentid, bool emitsignals) +{ + if (!property) + { + return false; + } + + if (!d_ptr->Properties) // If not existant, create property set + { + d_ptr->Properties = new VPropertySet(); + } + + if (emitsignals) + { + VProperty* tmpParent = getProperty(parentid); + int tmpRow = tmpParent != nullptr ? tmpParent->getRowCount() : d_ptr->Properties->getRootPropertyCount(); + beginInsertRows((tmpParent != nullptr ? getIndexFromProperty(tmpParent) : QModelIndex()), tmpRow, tmpRow); + } + + d_ptr->Properties->addProperty(property, id, parentid); + + if (emitsignals) + { + endInsertRows(); + } + + return true; + +} + +//! Creates a property and adds it to the model +VProperty* VPropertyModel::createProperty(const QString& id, const QString& name, const QString& parentid, + const QVariant& data) +{ + VProperty* tmpProp = new VProperty(name); + tmpProp->setValue(data); + if (addProperty(tmpProp, id, parentid)) + { + return tmpProp; + } + else + return nullptr; +} + +//! Gets a property by it's ID +VProperty* VPropertyModel::getProperty(const QString& id) +{ + return d_ptr->Properties != nullptr ? d_ptr->Properties->getProperty(id) : nullptr; +} + +//! Returns the model index at row/column +QModelIndex VPropertyModel::index(int row, int column, const QModelIndex& parent) const +{ + if (d_ptr->Properties == nullptr || (parent.isValid() && parent.column() > 1)) + { + return QModelIndex(); + } + + if (parent.isValid()) + { + // Get the parent index + VProperty* parentItem = getProperty(parent); + if (parentItem) + { + VProperty* childItem = parentItem->getChild(row); + if (childItem) + { + return createIndex(row, column, childItem); + } + } + } + else if (row >= 0 && row < d_ptr->Properties->count()) + { + return createIndex(row, column, d_ptr->Properties->getRootProperty(row)); + } + + return QModelIndex(); +} + +//! Returns the parent of one model index +QModelIndex VPropertyModel::parent ( const QModelIndex & index ) const +{ + if (!index.isValid()) + { + return QModelIndex(); + } + + VProperty* childItem = getProperty(index); + if (childItem) + { + VProperty* parentItem = childItem->getParent(); + if (parentItem) + { + VProperty* grandParentItem = parentItem->getParent(); + int parents_row = grandParentItem != nullptr ? grandParentItem->getChildRow(parentItem) + : d_ptr->Properties->getRootProperties().indexOf(parentItem); + + if (parents_row >= 0) + { + return createIndex(parents_row, 0, parentItem); + } + } + } + + return QModelIndex(); +} + +//! Returns the item flags for the given index +Qt::ItemFlags VPropertyModel::flags (const QModelIndex& index) const +{ + VProperty* tmpProperty = getProperty(index); + if (!tmpProperty) + { + return Qt::NoItemFlags; + } + else + return tmpProperty->flags(index.column()); +} + +//! Sets the role data for the item at index to value +bool VPropertyModel::setData (const QModelIndex& index, const QVariant& value, int role) +{ + VProperty* tmpProperty = getProperty(index); + if (index.column() == 1 && tmpProperty) + { + bool tmpHasChanged = tmpProperty->setData(value, role); + if (tmpProperty->getUpdateParent() && tmpHasChanged) + { // If neccessary, update the parent as well + QModelIndex tmpParentIndex = parent(index); + emit dataChanged(tmpParentIndex, tmpParentIndex); + } + + if (tmpHasChanged) + { + emit onDataChangedByEditor(tmpProperty); + } + } + + + return true; +} + + +//! Returns the data of an model index +QVariant VPropertyModel::data ( const QModelIndex & index, int role ) const +{ + VProperty* tmpProperty = getProperty(index); + if (!tmpProperty) + { + return QVariant(); + } + else + return tmpProperty->data(index.column(), role); +} + + +QVariant VPropertyModel::headerData (int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + // Header data + if (section == 0) + { + return d_ptr->HeadlineProperty; + } + else if (section == 1) + { + return d_ptr->HeadlineValue; + } + } + else if (role == Qt::DisplayRole) + { + return QVariant(section); + } + + return QVariant(); +} + + +//! Returns the number of rows +int VPropertyModel::rowCount ( const QModelIndex & parent ) const +{ + if (parent.isValid()) + { + VProperty* tmpParent = getProperty(parent); + if (tmpParent) + { + return tmpParent->getRowCount(); + } + } + + // Return the root property count + if (d_ptr->Properties) + { + return d_ptr->Properties->getRootPropertyCount(); + } + + return 0; +} + + +//! Returns the number of columns +int VPropertyModel::columnCount ( const QModelIndex & parent) const +{ + Q_UNUSED(parent); + return 2; +} + + +//! Gets a property by its ModelIndex +VProperty* VPropertyModel::getProperty(const QModelIndex &index) const +{ + if (index.isValid()) + { + VProperty* prop = static_cast(index.internalPointer()); + + if (prop) + { + return prop; + } + } + return nullptr; +} + +QString VPropertyModel::getPropertyID(const VProperty *prop) const +{ + return d_ptr->Properties != nullptr ? d_ptr->Properties->getPropertyID(prop) : QString(); +} + +QModelIndex VPropertyModel::getIndexFromProperty(VProperty* property, int column) const +{ + if (!property || column > columnCount() || column < 0) + { + return QModelIndex(); + } + + VProperty* parentItem = property->getParent(); + int row = 0; + + if (parentItem) + { + row = parentItem->getChildRow(property); + } + + return createIndex(row, column, property); +} + + +void VPropertyModel::onDataChangedByModel(VProperty* property) +{ + QModelIndex tmpIndex = getIndexFromProperty(property, 1); + if (tmpIndex.isValid()) + { + emit dataChanged(tmpIndex, tmpIndex); + emit onDataChangedByEditor(property); + } +} + +const VPropertySet *VPropertyModel::getPropertySet() const +{ + return d_ptr->Properties; +} + +void VPropertyModel::clear(bool emit_signals) +{ + setPropertySet(nullptr, emit_signals); +} + +VPropertySet *VPropertyModel::takePropertySet(VPropertySet *new_property_set, bool emit_signals) +{ + VPropertySet* tmpOldPropertySet = d_ptr->Properties; + + if (emit_signals) + { + emit beginResetModel(); + } + d_ptr->Properties = new_property_set; + if (emit_signals) + { + emit endResetModel(); + } + + return tmpOldPropertySet; +} + +void VPropertyModel::setPropertySet(VPropertySet *property_set, bool emit_signals) +{ + VPropertySet* tmpOldPropertySet = takePropertySet(property_set, emit_signals); + delete tmpOldPropertySet; +} + +VProperty *VPropertyModel::takeProperty(const QString &id) +{ + QModelIndex tmpIndex = getIndexFromProperty(getProperty(id)); + if (d_ptr->Properties && tmpIndex.isValid()) + { + beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row()); + VProperty* tmpProp = d_ptr->Properties->takeProperty(id); + endRemoveRows(); + return tmpProp; + } + + return nullptr; +} + +void VPropertyModel::removeProperty(const QString &id) +{ + QModelIndex tmpIndex = getIndexFromProperty(getProperty(id)); + if (d_ptr->Properties && tmpIndex.isValid()) + { + beginRemoveRows(tmpIndex.parent(), tmpIndex.row(), tmpIndex.row()); + d_ptr->Properties->removeProperty(id); + endRemoveRows(); + } +} diff --git a/src/libs/vpropertyexplorer/vpropertymodel.h b/src/libs/vpropertyexplorer/vpropertymodel.h new file mode 100644 index 000000000..c254f8d8e --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertymodel.h @@ -0,0 +1,167 @@ +/************************************************************************ + ** + ** @file vpropertymodel.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYMODEL_H +#define VPROPERTYMODEL_H + +#include "vpropertyexplorer_global.h" + +#include +#include +#include + +#include "vproperty.h" + +namespace VPE +{ + +class VPropertyModelPrivate; +class VPropertySet; + +//! \brief This is the base model for managing all the properties +//! and passing them to the view. +//! +//! When you create your own "proxy models", this is the place to +//! start: just subclass VPropertyModel and extend the new class. +//! Have a look at existing examples of proxies. +//! +//! Note that in this context, the term "proxy model" does not refer +//! to VProxyModel as that is another concept. +//! The idea behind "proxy models" in the QtPropertyExplorer framework +//! is to provide an convenient interface which takes data as your +//! application (or a third-party-library) provides it, and converts this +//! data to VProperty-objects, manage them and produce output for the views. +//! +//! In most cases, you will not need to rewrite the basic functions of +//! QAbstractItemModel, as VPropertyModel provides standard implementations +//! to work with. Thus, instead of subclassing VPropertyModel, it is also +//! possible to use VPropertyModel directly (as it is not an abstract class). +//! This might be more convenient in some cases. +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel : public QAbstractItemModel +{ + Q_OBJECT +public: + explicit VPropertyModel(QObject * parent = 0); + virtual ~VPropertyModel(); + + //! Adds the property to the model and attaches it to the parentid + //! \param emitsignals If this is set to false, this function will not call beginInsertRows() and endInsertRows(), + //! so it has to be called from a subclass + virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid = QString(), + bool emitsignals = true); + + //! Creates a property and adds it to the model + virtual VProperty* createProperty(const QString& id, const QString& name, const QString& parentid = QString(), + const QVariant& data = QVariant()); + + //! Gets a property by it's ID + virtual VProperty* getProperty(const QString& id); + + //! Returns the item flags for the given index + virtual Qt::ItemFlags flags (const QModelIndex& index) const; + + //! Sets the role data for the item at index to value + virtual bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); + + //! Returns the model index at row/column + virtual QModelIndex index (int row, int column, const QModelIndex & parent = QModelIndex() ) const; + + //! Returns the parent of one model index + virtual QModelIndex parent (const QModelIndex& index) const; + + //! Returns the data of an model index + virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const; + + //! Returns the data for the given role and section in the header with the specified orientation. + virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + //! Returns the number of rows + virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const; + + //! Returns the number of columns + virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + + //! Gets a property by its ModelIndex + //! \param index The modelIndex of the property. + //! \return Returns the property with the given index, or NULL if none such property exists + virtual VProperty* getProperty(const QModelIndex &index) const; + + //! Returns the ID of the property within the model + //! The concept of property IDs is, that the object that manages the properties + //! and not the properties themselves handle the IDs. + //! \return Returns the ID under which the property is stored within the model + virtual QString getPropertyID(const VProperty* prop) const; + + //! Returns a const pointer to the property set managed by this model. If you want to manipulate the property set, + //! either use the methods provided by the model or use takePropertySet() and setPropertySet(). + //! \return A constant pointer to the property set or NULL if there currently is none. + virtual const VPropertySet* getPropertySet() const; + + //! Clears the model, deletes the property set managed by this model. + //! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset + //! model signals + virtual void clear(bool emit_signals = true); + + //! Removes the current property set and returns it. If new_property_set is set, the old one will be replaced by the + //! new one + //! \param new_property_set The new property set to replace the old one with. Default: NULL + //! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset + //! model signals + //! \return A constant pointer to the property set or NULL if there currently is none. + virtual VPropertySet* takePropertySet(VPropertySet* new_property_set = nullptr, bool emit_signals = true); + + //! Sets a new property set. The model will take ownership of the property set. The old property set will be + //! deleted. + //! \param property_set The new property set. Setting this to NULL has the same effect as calling clear. + //! \param emit_signals Default: true. Set this to false if you want to prevent the model from emmiting the reset + //! model signals + virtual void setPropertySet(VPropertySet* property_set, bool emit_signals = true); + + //! Removes a property from the model and returns it + virtual VProperty* takeProperty(const QString& id); + + //! Removes a property from the model and deletes it + virtual void removeProperty(const QString& id); + +signals: + //! This signal is being emitted, when the setData method is being called + void onDataChangedByEditor(VProperty* property); + +public slots: + //! This function causes the views to update the property + void onDataChangedByModel(VProperty* property); + +protected: + //! Gets a property by its ModelIndex + virtual QModelIndex getIndexFromProperty(VProperty* property, int column = 0) const; + + //! Protected constructor passing the private object + VPropertyModel(VPropertyModelPrivate* d, QObject* parent = 0); + + //! The model data + VPropertyModelPrivate* d_ptr; + +private: + Q_DISABLE_COPY(VPropertyModel) +}; + +} + +#endif // VPROPERTYMODEL_H diff --git a/src/libs/vpropertyexplorer/vpropertymodel_p.h b/src/libs/vpropertyexplorer/vpropertymodel_p.h new file mode 100644 index 000000000..cabd95480 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertymodel_p.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file vpropertymodel_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYMODEL_P_H +#define VPROPERTYMODEL_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include +#include + +namespace VPE +{ + +class VProperty; +class VPropertySet; + +class VPropertyModelPrivate +{ +public: + //! The property set holding the properties + VPropertySet* Properties; + + //! The header data for the property name column + QString HeadlineProperty; + + //! The header data for the value column + QString HeadlineValue; + + //! Constructor + VPropertyModelPrivate() + : Properties(nullptr), HeadlineProperty(QString()), HeadlineValue(QString()) + { + //: The text that appears in the first column header + HeadlineProperty = QObject::tr("Property"); + + //: The text that appears in the second column header + HeadlineValue = QObject::tr("Value"); + } + +private: + Q_DISABLE_COPY(VPropertyModelPrivate) +}; + +} + +#endif // VPROPERTYMODEL_P_H diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp new file mode 100644 index 000000000..4cdc420e3 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -0,0 +1,267 @@ +/************************************************************************ + ** + ** @file vpropertyset.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertyset.h" +using namespace VPE; + +#include "vpropertyset_p.h" + + +VPropertySet::VPropertySet() + : d_ptr(new VPropertySetPrivate()) +{ +} + + +VPropertySet::~VPropertySet() +{ + // Delete all the properties + clear(true); + + delete d_ptr; +} + +bool VPropertySet::addProperty(VProperty *property, const QString &id, const QString &parentid) +{ + // Check if the property to add is not a null pointer + if (!property) + { + return false; + } + + VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid); + return addProperty(property, id, tmpParent); +} + +bool VPropertySet::addProperty(VProperty *property, const QString &id, VProperty *parent_property) +{ + // Check if the property to add is not a null pointer + if (!property) + { + return false; + } + + QString tmpOldID = getPropertyID(property); + if (!tmpOldID.isEmpty()) + { + d_ptr->Properties.remove(tmpOldID); + } + + if (parent_property) + { + parent_property->addChild(property); + } + else + { + d_ptr->RootProperties.append(property); + if (property->getParent()) + { + property->getParent()->removeChild(property); + } + } + + if (!id.isEmpty()) + { + d_ptr->Properties.insert(id, property); + } + + return true; +} + +bool VPropertySet::hasProperty(VProperty *property) const +{ + if (!property) + { + return false; + } + + return hasProperty(property, NULL); +} + +VProperty *VPropertySet::getProperty(const QString &id) const +{ + return d_ptr->Properties.value(id, NULL); +} + +VProperty *VPropertySet::takeProperty(const QString &id) +{ + VProperty* tmpProp = getProperty(id); + removeProperty(tmpProp, false); + + // Return the property + return tmpProp; +} + +void VPropertySet::removeProperty(const QString &id) +{ + VProperty* tmpProp = takeProperty(id); + delete tmpProp; +} + +void VPropertySet::removeProperty(VProperty* prop, bool delete_property) +{ + // Remove all the children + removePropertyFromSet(prop); + + // Remove from parent and optionally delete + if (prop) + { + prop->setParent(NULL); + + if (delete_property) + { + delete prop; + } + } +} + +int VPropertySet::count() const +{ + return d_ptr->Properties.count(); +} + +void VPropertySet::clear(bool delete_properties) +{ + d_ptr->Properties.clear(); + while (!d_ptr->RootProperties.isEmpty()) + { + VProperty* tmpProp = d_ptr->RootProperties.takeLast(); + if (tmpProp != nullptr && delete_properties) + { + delete tmpProp; + } + } +} + +QString VPropertySet::getPropertyID(const VProperty *prop, bool look_for_parent_id) const +{ + QString tmpResult; + const VProperty* tmpCurrentProp = prop; + + while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) && tmpResult.isEmpty()) + { + + // todo: The following code doesn't work, because .key() doesn't accept a const VProperty* pointer ... + //tmpResult = d_ptr->Properties.key(tmpCurrentProp, QString()); + + // ... which is why we need the code below + for (QMap::const_iterator i = d_ptr->Properties.constBegin(); + i != d_ptr->Properties.constEnd(); ++i) + { + if (tmpCurrentProp == (*i)) + { + return i.key(); + } + } + + tmpCurrentProp = tmpCurrentProp->getParent(); + } + + return tmpResult; +} + +const QMap &VPropertySet::getPropertiesMap() const +{ + return d_ptr->Properties; +} + +const QList &VPropertySet::getRootProperties() const +{ + return d_ptr->RootProperties; +} + +VProperty *VPropertySet::getRootProperty(int row) const +{ + return d_ptr->RootProperties.value(row, NULL); +} + +int VPropertySet::getRootPropertyCount() const +{ + return d_ptr->RootProperties.count(); +} + +VPropertySet* VPropertySet::clone() const +{ + VPropertySet* tmpResult = new VPropertySet(); + + foreach(VProperty* tmpProperty, d_ptr->RootProperties) + cloneProperty(tmpProperty, NULL, tmpResult); + + + return tmpResult; +} + +bool VPropertySet::hasProperty(VProperty *property, VProperty *parent) const +{ + if (!property) + { + return false; + } + + const QList& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties); + foreach(VProperty* tmpProp, tmpChildrenList) + { + if (!tmpProp) + { + continue; + } + else if (tmpProp == property || hasProperty(property, tmpProp)) + { + return true; + } + } + + return false; +} + +void VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property, + VPropertySet *output_set) const +{ + if (!output_set || !property_to_clone || !hasProperty(property_to_clone)) + { + return; + } + + QString tmpID = getPropertyID(property_to_clone, false); + + // We want to clone the children ourselves (because of the IDs) + VProperty* tmpNewProperty = property_to_clone->clone(false); + + output_set->addProperty(tmpNewProperty, tmpID, parent_property); + for (int i = 0; i < property_to_clone->getRowCount(); ++i) + { + cloneProperty(property_to_clone->getChild(i), tmpNewProperty, output_set); + } +} + +void VPropertySet::removePropertyFromSet(VProperty *prop) +{ + // Remove all the children + foreach(VProperty* tmpChild, prop->getChildren()) + removeProperty(tmpChild); + + + QList tmpKeys = d_ptr->Properties.keys(prop); + foreach(const QString& tmpID, tmpKeys) + d_ptr->Properties.remove(tmpID); + + // Remove from list + d_ptr->RootProperties.removeAll(prop); +} diff --git a/src/libs/vpropertyexplorer/vpropertyset.h b/src/libs/vpropertyexplorer/vpropertyset.h new file mode 100644 index 000000000..d3559c7d7 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyset.h @@ -0,0 +1,139 @@ +/************************************************************************ + ** + ** @file vpropertyset.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYSET_H +#define VPROPERTYSET_H + +#include "vpropertyexplorer_global.h" + +#include +#include + +#include "vproperty.h" + +namespace VPE +{ + +// Forward declaration +class VPropertySetPrivate; + +// todo: better description +//! \brief VPropertySet is a simple class for managing a set of properties. +//! If you don't need all the Model-functionality, chose this class +//! over VPropertyModel. +//! + +//! +class VPROPERTYEXPLORERSHARED_EXPORT VPropertySet +{ +public: + //! Default constructor, creating an empty property set + explicit VPropertySet(); + + //! Destructor + virtual ~VPropertySet(); + + //! Adds the property to the model and attaches it to the parentid. Note that if the property has a parent which is + //! not part of this set, it will be removed from that parent. + //! \param property The property to add + //! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. + //! If the property was filed under another ID before, that will no longer be valid. + //! \param parentid The property's ID to which to add the property as child. Pass empty string to add it to the + //! root properties. + virtual bool addProperty(VProperty* property, const QString& id, const QString& parentid); + + //! Adds the property to the model and attaches it to the parent property. + //! \param property The property to add + //! \param id The property ID. If id is empty, the property will not be accessable by it's id but still be added. + //! If the property was filed under another ID before, that will no longer be valid. + //! \param parent_property The property to which to add the property as child. Pass NULL to add it to the root + //! properties. + virtual bool addProperty(VProperty* property, const QString& id, VProperty* parent_property = nullptr); + + //! Checks whether a property belongs to this set and returns the result + //! \param property The property to check for + //! \return True, if the property is part of this set, false otherwise + virtual bool hasProperty(VProperty* property) const; + + //! Gets a property by it's ID + virtual VProperty* getProperty(const QString& id) const; + + //! Removes a property from the set and returns it + virtual VProperty* takeProperty(const QString& id); + + //! Removes a property from the set and deletes it + virtual void removeProperty(const QString& id); + + //! Removes a property from the set and deletes it optionally + virtual void removeProperty(VProperty* prop, bool delete_property = true); + + //! Returns the number of properties with in ID that are directly accessable by getProperty() + virtual int count() const; + + //! Clears the set and (optionally) deletes all properties + //! \param delete_properties Set this to false, if you don't want the properties to get deleted. + virtual void clear(bool delete_properties = true); + + //! Returns the ID of the property within the set + //! The concept of property IDs is, that the object that manages the properties + //! and not the properties themselves handle the IDs. + //! \param prop The property of which to get the ID. + //! \param look_for_parent_id If this is TRUE and the property has no ID, all the parent properties are checked. + //! \return Returns the ID under which the property is stored within the set + virtual QString getPropertyID(const VProperty* prop, bool look_for_parent_id = true) const; + + //! Returns a const reference to the map of properties + const QMap& getPropertiesMap() const; + + //! Returns a const reference to the list of root properties + const QList& getRootProperties() const; + + //! Returns the root property in a certain row + //! \param row The root row in which to look for the root property + VProperty* getRootProperty(int row) const; + + //! Returns the number of independent properties + int getRootPropertyCount() const; + + //! Clones the property set + VPropertySet* clone() const; + +protected: + //! Checks whether a property belongs to this set and returns the result + //! \param property The property to check for + //! \param parent The parent property from which to start checking all the children + //! \return True, if the property is part of this set, false otherwise + virtual bool hasProperty(VProperty* property, VProperty* parent) const; + + //! Clones a property into another property set + void cloneProperty(VProperty* property_to_clone, VProperty* parent_property, VPropertySet* output_set) const; + + //! Recursivly removes a property's child properties from the set, but not from the parent + virtual void removePropertyFromSet(VProperty* prop); + + //! The data + VPropertySetPrivate* d_ptr; +private: + Q_DISABLE_COPY(VPropertySet) +}; + +} + +#endif // VPROPERTYMODEL_H diff --git a/src/libs/vpropertyexplorer/vpropertyset_p.h b/src/libs/vpropertyexplorer/vpropertyset_p.h new file mode 100644 index 000000000..5c97ffd3d --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertyset_p.h @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file vpropertyset_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYSET_P_H +#define VPROPERTYSET_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include + +namespace VPE +{ + +class VProperty; + +class VPropertySetPrivate +{ +public: + //! Property map (ID, Property) + QMap Properties; // All the Properties managed by this model are being stored in this map for + //quick access + + //! List containing the root properties + QList RootProperties; + + //! Constructor + VPropertySetPrivate() + : Properties(QMap()), RootProperties(QList()) + {} + +private: + Q_DISABLE_COPY(VPropertySetPrivate) +}; + +} + +#endif // VPROPERTYMODEL_P_H diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.cpp b/src/libs/vpropertyexplorer/vpropertytreeview.cpp new file mode 100644 index 000000000..8456a39d6 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertytreeview.cpp @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file vpropertytreeview.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vpropertytreeview.h" + +#include "vpropertydelegate.h" +#include "vpropertymodel.h" + +#include "vpropertytreeview_p.h" + +using namespace VPE; + +VPropertyTreeView::VPropertyTreeView(QWidget *parent) + : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate()) +{ + init(); +} + +VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent) + : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate()) +{ + init(); + + if (model) + { + setModel(model); + } +} + +VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init_, QWidget *parent) + : QTreeView(parent), d_ptr(d) +{ + if (init_) + { + init(); + } +} + +VPropertyTreeView::~VPropertyTreeView() +{ + delete d_ptr; +} + + +void VPropertyTreeView::setRowHeight(int height, bool add_to_standard) +{ + d_ptr->PropertyDelegate->setRowHeight(height, add_to_standard); +} + +void VPropertyTreeView::init() +{ + setAlternatingRowColors(true); + setUniformRowHeights(true); + d_ptr->PropertyDelegate = new VPropertyDelegate(this); + setItemDelegate(d_ptr->PropertyDelegate); + + setSelectionMode(QTreeView::SingleSelection); + setSelectionBehavior(QTreeView::SelectRows); + setRootIsDecorated(true); + + setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::SelectedClicked); +} diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.h b/src/libs/vpropertyexplorer/vpropertytreeview.h new file mode 100644 index 000000000..58e17341e --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertytreeview.h @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vpropertytreeview.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYTREEVIEW_H +#define VPROPERTYTREEVIEW_H + +#include +#include "vpropertyexplorer_global.h" + +namespace VPE +{ + +class VPropertyTreeViewPrivate; + +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate; +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel; + +class VPROPERTYEXPLORERSHARED_EXPORT VPropertyTreeView : public QTreeView +{ + Q_OBJECT +public: + //! Default constructor + explicit VPropertyTreeView(QWidget *parent = 0); + + //! The destructor, taking a model and setting it to the tree view + //! \param model The model to set as model for this tree view + VPropertyTreeView(VPropertyModel* model, QWidget *parent = 0); + + //! Destructor + virtual ~VPropertyTreeView(); + + //! Sets the height for each row. Set this to 0 in order to let the standard delegate decide + void setRowHeight(int height = 0, bool add_to_standard = false); + + +protected: + //! This method is called by the constructors to initialize the view + virtual void init(); + + //! protected constructor + explicit VPropertyTreeView(VPropertyTreeViewPrivate* d, bool init_, QWidget *parent = 0); + + //! The protected data + VPropertyTreeViewPrivate* d_ptr; + +private: + Q_DISABLE_COPY(VPropertyTreeView) +}; + +} + +#endif // VPROPERTYTREEVIEWEEVIEW_H diff --git a/src/libs/vpropertyexplorer/vpropertytreeview_p.h b/src/libs/vpropertyexplorer/vpropertytreeview_p.h new file mode 100644 index 000000000..cf7e072a4 --- /dev/null +++ b/src/libs/vpropertyexplorer/vpropertytreeview_p.h @@ -0,0 +1,51 @@ +/************************************************************************ + ** + ** @file vpropertytreeview_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VPROPERTYTREEVIEW_P_H +#define VPROPERTYTREEVIEW_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include +#include + +namespace VPE +{ + +class VPropertyDelegate; + +class VPropertyTreeViewPrivate +{ +public: + //! Property Delegate + VPropertyDelegate* PropertyDelegate; + + //! Constructor + VPropertyTreeViewPrivate(VPropertyDelegate* delegate) + : PropertyDelegate(delegate) {} + + //! Constructor + VPropertyTreeViewPrivate() + : PropertyDelegate(nullptr) {} +}; + +} + +#endif // VPROPERTYTREEVIEW_P_H diff --git a/src/libs/vpropertyexplorer/vserializedproperty.cpp b/src/libs/vpropertyexplorer/vserializedproperty.cpp new file mode 100644 index 000000000..d7b626daa --- /dev/null +++ b/src/libs/vpropertyexplorer/vserializedproperty.cpp @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file vserializedproperty.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vserializedproperty.h" + +using namespace VPE; + +VSerializedProperty::VSerializedProperty() + : ID(), Type(), Value(), Children() +{} + +/*! Creates a new VSerializedProperty from an existing property + +*/ +VSerializedProperty::VSerializedProperty(const VProperty* property, const VPropertySet* set) + : ID(), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant()), + Children() +{ + if (set) + { + ID = set->getPropertyID(property); + + initChildren(property, set); + } +} + +VSerializedProperty::VSerializedProperty(const VProperty *property, const QString &id, const VPropertySet *set) + : ID(id), Type(property ? property->type() : QString()), Value(property ? property->getValue() : QVariant()), + Children() +{ + initChildren(property, set); +} + +VSerializedProperty::VSerializedProperty(const QString &id, const QString &type, const QVariant &value) + : ID(id), Type(type), Value(value), Children() +{ +} + +void VSerializedProperty::initChildren(const VProperty *property, const VPropertySet *set) +{ + if (property && set) + { + const QList& tmpChildren = property->getChildren(); + foreach(const VProperty* tmpChild, tmpChildren) + { + QString tmpChildID = set->getPropertyID(property); + Children.append(VSerializedProperty(tmpChild, tmpChildID, set)); + } + } +} diff --git a/src/libs/vpropertyexplorer/vserializedproperty.h b/src/libs/vpropertyexplorer/vserializedproperty.h new file mode 100644 index 000000000..a44bf459d --- /dev/null +++ b/src/libs/vpropertyexplorer/vserializedproperty.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file vserializedproperty.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VSERIALIZEDPROPERTY_H +#define VSERIALIZEDPROPERTY_H + +#include "vpropertyexplorer_global.h" + +#include +#include +#include + +#include "vproperty.h" +#include "vpropertyset.h" + +namespace VPE +{ + + +class VPROPERTYEXPLORERSHARED_EXPORT VSerializedProperty +{ +public: + //! Constructor + VSerializedProperty(); + + //! Constructor + VSerializedProperty(const VProperty* property, const VPropertySet* set); + + //! Constructor + VSerializedProperty(const VProperty* property, const QString& id, const VPropertySet* set); + + //! Constructor + VSerializedProperty(const QString& id, const QString& type, const QVariant& value); + + //! The property type + QString ID; + + //! The property type + QString Type; + + //! The serialized value of the property + QVariant Value; + + //! List of child properties + QList Children; + +private: + void initChildren(const VProperty* property, const VPropertySet* set); +}; + +} + +#endif // VSERIALIZEDPROPERTY_H diff --git a/src/libs/vpropertyexplorer/vstandardpropertyfactory.cpp b/src/libs/vpropertyexplorer/vstandardpropertyfactory.cpp new file mode 100644 index 000000000..243bd2eb7 --- /dev/null +++ b/src/libs/vpropertyexplorer/vstandardpropertyfactory.cpp @@ -0,0 +1,106 @@ +/************************************************************************ + ** + ** @file vstandardpropertyfactory.cpp + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#include "vstandardpropertyfactory.h" + +#include "vpropertyfactorymanager.h" + +// Supported Properties +#include "vproperty.h" +#include "plugins/vboolproperty.h" +#include "plugins/vcolorproperty.h" +#include "plugins/vemptyproperty.h" +#include "plugins/venumproperty.h" +#include "plugins/vfileproperty.h" +#include "plugins/vnumberproperty.h" +#include "plugins/vshortcutproperty.h" +#include "plugins/Vector3d/vvector3dproperty.h" + + +using namespace VPE; + +VStandardPropertyFactory::VStandardPropertyFactory() + : VAbstractPropertyFactory() +{ +} + +VStandardPropertyFactory::VStandardPropertyFactory(VPropertyFactoryManager *manager) + : VAbstractPropertyFactory() +{ + if (manager) + { + manager->registerFactory("string", this); + manager->registerFactory("bool", this); + manager->registerFactory("color", this); + manager->registerFactory("empty", this); + manager->registerFactory("enum", this); + manager->registerFactory("file", this); + manager->registerFactory("integer", this); + manager->registerFactory("double", this); + manager->registerFactory("shortcut", this); + manager->registerFactory("vector3d", this); + } +} + +VProperty *VStandardPropertyFactory::createProperty(const QString &type, const QString &name) +{ + if (type == QString("string")) + { + return new VProperty(name); + } + else if (type == QString("bool")) + { + return new VBoolProperty(name); + } + else if (type == QString("color")) + { + return new VColorProperty(name); + } + else if (type == QString("empty")) + { + return new VEmptyProperty(name); + } + else if (type == QString("enum")) + { + return new VEnumProperty(name); + } + else if (type == QString("file")) + { + return new VFileProperty(name); + } + else if (type == QString("integer")) + { + return new VIntegerProperty(name); + } + else if (type == QString("double")) + { + return new VDoubleProperty(name); + } + else if (type == QString("shortcut")) + { + return new VShortcutProperty(name); + } + else if (type == QString("vector3d")) + { + return new QVector3DProperty(name); + } + else + return nullptr; +} diff --git a/src/libs/vpropertyexplorer/vstandardpropertyfactory.h b/src/libs/vpropertyexplorer/vstandardpropertyfactory.h new file mode 100644 index 000000000..88b90b0f7 --- /dev/null +++ b/src/libs/vpropertyexplorer/vstandardpropertyfactory.h @@ -0,0 +1,54 @@ +/************************************************************************ + ** + ** @file vstandardpropertyfactory.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VASTANDARDPROPERTYFACTORY_H +#define VASTANDARDPROPERTYFACTORY_H + +#include "vpropertyexplorer_global.h" +#include "vabstractpropertyfactory.h" + +namespace VPE +{ + +class VProperty; + +class VPropertyFactoryManager; + +//! The standard property factory is able to create all the properties that are included in VPropertyExplorer +//! by default. +class VPROPERTYEXPLORERSHARED_EXPORT VStandardPropertyFactory : public VAbstractPropertyFactory +{ +public: + //! Constructor + VStandardPropertyFactory(); + + //! Constructor + //! \param manager Registers this factory at the manager for all it's types + VStandardPropertyFactory(VPropertyFactoryManager* manager); + + //! Creates a new property of a certain type and assigns a name and description (otionally) + //! \param type The type of the property as string + //! \return Returns the created property or NULL if it couldn't be be created + virtual VProperty* createProperty(const QString& type, const QString &name); +}; + +} + +#endif // VASTANDARDPROPERTYFACTORY_H diff --git a/src/libs/vpropertyexplorer/vwidgetproperty_p.h b/src/libs/vpropertyexplorer/vwidgetproperty_p.h new file mode 100644 index 000000000..0e33fb801 --- /dev/null +++ b/src/libs/vpropertyexplorer/vwidgetproperty_p.h @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vwidgetproperty_p.h + ** @author hedgeware + ** @date + ** + ** @brief + ** @copyright + ** All rights reserved. This program and the accompanying materials + ** are made available under the terms of the GNU Lesser General Public License + ** (LGPL) version 2.1 which accompanies this distribution, and is available at + ** http://www.gnu.org/licenses/lgpl-2.1.html + ** + ** This library 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 + ** Lesser General Public License for more details. + ** + *************************************************************************/ + +#ifndef VWIDGETPROPERTY_P_H +#define VWIDGETPROPERTY_P_H + +// ONLY INCLUDE THIS IN .CPP FILES + +#include "vproperty_p.h" + +#include +#include + +namespace VPE +{ + +#ifdef Q_CC_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +class VWidgetPropertyPrivate : public VPropertyPrivate +{ +public: + //! The widget to show + QPointer Widget; + + //! Constructor passing name and type + VWidgetPropertyPrivate(const QString& name, QVariant::Type type, QWidget* widget = nullptr) + : VPropertyPrivate(name, type), Widget(widget) {} + + //! Constructor + VWidgetPropertyPrivate() + : VPropertyPrivate(), Widget(nullptr) {} + + //! Destructor + virtual ~VWidgetPropertyPrivate() + { + if (Widget) + { + Widget->deleteLater(); + } + } +}; + +#ifdef Q_CC_CLANG + #pragma clang diagnostic pop +#endif + +} + +#endif // VWIDGETPROPERTY_P_H diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 6bc343bc2..000000000 --- a/src/main.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************ - ** - ** @file main.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "mainwindow.h" -#include "widgets/vapplication.h" -#include -#include -#include "tablewindow.h" - -void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) -{ - QByteArray localMsg = msg.toLocal8Bit(); - switch (type) - { - case QtDebugMsg: - fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, - context.function); - break; - case QtWarningMsg: - fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, - context.function); - break; - case QtCriticalMsg: - fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, - context.function); - break; - case QtFatalMsg: - fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, - context.function); - abort(); - default: - break; - } -} - -int main(int argc, char *argv[]) -{ - qInstallMessageHandler(myMessageOutput); - VApplication app(argc, argv); - - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&qtTranslator); - - QTranslator appTranslator; -#ifdef Q_OS_WIN32 - appTranslator.load("valentina_" + QLocale::system().name(), "."); -#else - #ifdef QT_DEBUG - appTranslator.load("valentina_" + QLocale::system().name(), "."); - #else - appTranslator.load("valentina_" + QLocale::system().name(), "/usr/share/valentina/translations"); - #endif -#endif - app.installTranslator(&appTranslator); - - MainWindow w; - w.setWindowState(w.windowState() ^ Qt::WindowMaximized); - app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); - TableWindow table; - QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen); - QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed); - - const QStringList args = app.arguments(); - QString fileName; - QRegExp rxArgOpenFile("-o");//parameter open file - - if (args.size()>1) - { - for (int i = 1; i < args.size(); ++i) - { - if (rxArgOpenFile.indexIn(args.at(i)) != -1 ) - { - if (args.at(i+1).isEmpty() == false) - { - fileName = args.at(i+1); - qDebug() << args.at(i)<< ":" << fileName; - w.OpenPattern(fileName); - } - w.show(); - break; - } - else - { - qDebug() << "Uknown arg:" << args.at(i); - w.show(); - break; - } - } - } - else - { - w.show(); - } - return app.exec(); -} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp deleted file mode 100644 index abd97ea9c..000000000 --- a/src/mainwindow.cpp +++ /dev/null @@ -1,1302 +0,0 @@ -/************************************************************************ - ** - ** @file mainwindow.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "mainwindow.h" -#include "ui_mainwindow.h" -#include "geometry/vspline.h" -#include "exception/vexceptionobjecterror.h" -#include "exception/vexceptionconversionerror.h" -#include "exception/vexceptionemptyparameter.h" -#include "exception/vexceptionwrongparameterid.h" -#include "exception/vexceptionuniqueid.h" -#include "version.h" - -#include -#include -#include -#include -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent) - :QMainWindow(parent), ui(new Ui::MainWindow), tool(Tool::ArrowTool), currentScene(0), sceneDraw(0), - sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0), - dialogEndLine(QSharedPointer()), dialogLine(QSharedPointer()), - dialogAlongLine(QSharedPointer()), - dialogShoulderPoint(QSharedPointer()), dialogNormal(QSharedPointer()), - dialogBisector(QSharedPointer()), - dialogLineIntersect(QSharedPointer()), dialogSpline(QSharedPointer()), - dialogArc(QSharedPointer()), dialogSplinePath(QSharedPointer()), - dialogPointOfContact(QSharedPointer()), - dialogDetail(QSharedPointer()), dialogHeight(QSharedPointer()), - dialogTriangle(QSharedPointer()), - dialogPointOfIntersection(QSharedPointer()), - dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false), - mode(Draw::Calculation) -{ - ui->setupUi(this); - ToolBarOption(); - ToolBarDraws(); - QRectF sceneRect = QRectF(0, 0, PaperSize, PaperSize); - sceneDraw = new VMainGraphicsScene(sceneRect); - currentScene = sceneDraw; - connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); - sceneDetails = new VMainGraphicsScene(sceneRect); - connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); - view = new VMainGraphicsView(); - ui->LayoutView->addWidget(view); - view->setScene(currentScene); - connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); - QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); - policy.setHorizontalStretch(12); - view->setSizePolicy(policy); - helpLabel = new QLabel(tr("Create new drawing for start working.")); - ui->statusBar->addWidget(helpLabel); - - connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool); - connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); - connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); - connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewDraw); - connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::OptionDraw); - connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::ActionSaveAs); - connect(ui->actionSave, &QAction::triggered, this, &MainWindow::ActionSave); - connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::ActionOpen); - connect(ui->actionNew, &QAction::triggered, this, &MainWindow::ActionNew); - connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable); - connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); - connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); - connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine); - connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint); - connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal); - connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector); - connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect); - connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); - connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); - connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); - connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); - connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); - connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); - connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); - connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection); - - data = new VContainer; - - doc = new VDomDocument(data, comboBoxDraws, &mode); - doc->CreateEmptyFile(); - connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange); - - fileName.clear(); - changeInFile = false; - - //Autosaving file each 5 minutes - QTimer *timer = new QTimer(this); - timer->setTimerType(Qt::VeryCoarseTimer); - connect(timer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); - timer->start(300000); - - connect(ui->actionAbout_Qt, &QAction::triggered, this, &MainWindow::AboutQt); - connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About); - connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); - - ui->toolBox->setCurrentIndex(0); -} - -void MainWindow::ActionNewDraw() -{ - QString nameDraw; - bool bOk; - qint32 index; - QString nDraw = QString(tr("Drawing %1")).arg(comboBoxDraws->count()+1); - QInputDialog *dlg = new QInputDialog(this); - dlg->setInputMode( QInputDialog::TextInput ); - dlg->setLabelText(tr("Drawing:")); - dlg->setTextEchoMode(QLineEdit::Normal); - dlg->setWindowTitle(tr("Enter a name for the drawing.")); - dlg->resize(300, 100); - dlg->setTextValue(nDraw); - while (1) - { - bOk = dlg->exec(); - nameDraw = dlg->textValue(); - if (bOk == false || nameDraw.isEmpty()) - { - delete dlg; - return; - } - index = comboBoxDraws->findText(nameDraw); - if (index != -1) - {//we already have this name - qCritical()<appendDraw(nameDraw); - if (bOk == false) - { - qCritical()<(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - comboBoxDraws->addItem(nameDraw); - index = comboBoxDraws->findText(nameDraw); - if ( index != -1 ) - { // -1 for not found - comboBoxDraws->setCurrentIndex(index); - currentDrawChanged( index ); - } - connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, - &MainWindow::currentDrawChanged); - data->ClearObject(); - //Create single point - qint64 id = data->AddPoint(VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10)); - VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); - sceneDraw->addItem(spoint); - connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); - connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); - QHash* tools = doc->getTools(); - tools->insert(id, spoint); - VDrawTool::AddRecord(id, Tool::SinglePointTool, doc); - SetEnableTool(true); - SetEnableWidgets(true); - changeInFile = true; -} - -void MainWindow::OptionDraw() -{ - QString nameDraw; - qint32 index; - QString nDraw = doc->GetNameActivDraw(); - QInputDialog *dlg = new QInputDialog(this); - dlg->setInputMode( QInputDialog::TextInput ); - dlg->setLabelText(tr("Drawing:")); - dlg->setTextEchoMode(QLineEdit::Normal); - dlg->setWindowTitle(tr("Enter a new name for the drawing.")); - dlg->resize(300, 100); - dlg->setTextValue(nDraw); - while (1) - { - bool bOk = dlg->exec(); - nameDraw = dlg->textValue(); - if (bOk == false || nameDraw.isEmpty()) - { - delete dlg; - return; - } - index = comboBoxDraws->findText(nameDraw); - if (index != -1) - {//we already have this name - qCritical()<findText(doc->GetNameActivDraw()); - if (doc->SetNameDraw(nameDraw)) - { - comboBoxDraws->setItemText(index, nameDraw); - } - else - { - QMessageBox::warning(this, tr("Error saving change!!!"), tr("Can't save new name of drawing")); - } - -} - -template -void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &cursor, const QString &toolTip, - QSharedPointer &dialog, Func closeDialogSlot) -{ - if (checked) - { - CanselTool(); - tool = t; - QPixmap pixmap(cursor); - QCursor cur(pixmap, 2, 3); - view->setCursor(cur); - helpLabel->setText(toolTip); - dialog = QSharedPointer(new Dialog(data, mode)); - connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject); - connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot); - connect(dialog.data(), &Dialog::ToolTip, this, &MainWindow::ShowToolTip); - connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList); - } - else - { - if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) - { - Q_ASSERT(tButton != 0); - tButton->setChecked(true); - } - } -} - -template -void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail) -{ - QHash* tools = doc->getTools(); - VToolDetail *det = qobject_cast(tools->value(idDetail)); - Q_ASSERT(det != 0); - det->AddTool(tool, id, typeTool); -} - -template -void MainWindow::ClosedDialog(QSharedPointer &dialog, int result) -{ - if (result == QDialog::Accepted) - { - if (mode == Draw::Calculation) - { - DrawTool::Create(dialog, currentScene, doc, data); - } - else - { - ModelingTool *endLine = ModelingTool::Create(dialog, doc, data); - AddToolToDetail(endLine, endLine->getId(), tool, dialog->getIdDetail()); - } - } - ArrowTool(); -} - -void MainWindow::ToolEndLine(bool checked) -{ - SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), - dialogEndLine, &MainWindow::ClosedDialogEndLine); -} - -void MainWindow::ClosedDialogEndLine(int result) -{ - ClosedDialog(dialogEndLine, result); -} - -void MainWindow::ToolLine(bool checked) -{ - SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"), - dialogLine, &MainWindow::ClosedDialogLine); -} - -void MainWindow::ClosedDialogLine(int result) -{ - ClosedDialog(dialogLine, result); -} - -void MainWindow::ToolAlongLine(bool checked) -{ - SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", tr("Select point"), - dialogAlongLine, &MainWindow::ClosedDialogAlongLine); -} - -void MainWindow::ClosedDialogAlongLine(int result) -{ - ClosedDialog(dialogAlongLine, result); -} - -void MainWindow::ToolShoulderPoint(bool checked) -{ - SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", - tr("Select first point of line"), dialogShoulderPoint, - &MainWindow::ClosedDialogShoulderPoint); -} - -void MainWindow::ClosedDialogShoulderPoint(int result) -{ - ClosedDialog(dialogShoulderPoint, result); -} - -void MainWindow::ToolNormal(bool checked) -{ - SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", - tr("Select first point of line"), dialogNormal, &MainWindow::ClosedDialogNormal); -} - -void MainWindow::ClosedDialogNormal(int result) -{ - ClosedDialog(dialogNormal, result); -} - -void MainWindow::ToolBisector(bool checked) -{ - SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", - tr("Select first point of angle"), dialogBisector, &MainWindow::ClosedDialogBisector); -} - -void MainWindow::ClosedDialogBisector(int result) -{ - ClosedDialog(dialogBisector, result); -} - -void MainWindow::ToolLineIntersect(bool checked) -{ - SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", - tr("Select first point of first line"), dialogLineIntersect, - &MainWindow::ClosedDialogLineIntersect); -} - -void MainWindow::ClosedDialogLineIntersect(int result) -{ - ClosedDialog(dialogLineIntersect, result); -} - -void MainWindow::ToolSpline(bool checked) -{ - SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", - tr("Select first point curve"), dialogSpline, &MainWindow::ClosedDialogSpline); -} - -void MainWindow::ClosedDialogSpline(int result) -{ - ClosedDialog(dialogSpline, result); -} - -void MainWindow::ToolArc(bool checked) -{ - SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", - tr("Select point of center of arc"), dialogArc, &MainWindow::ClosedDialogArc); -} - -void MainWindow::ClosedDialogArc(int result) -{ - ClosedDialog(dialogArc, result); -} - -void MainWindow::ToolSplinePath(bool checked) -{ - SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", - tr("Select point of curve path"), dialogSplinePath, - &MainWindow::ClosedDialogSplinePath); -} - -void MainWindow::ClosedDialogSplinePath(int result) -{ - ClosedDialog(dialogSplinePath, result); -} - -void MainWindow::ToolPointOfContact(bool checked) -{ - SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", - tr("Select first point of line"), dialogPointOfContact, - &MainWindow::ClosedDialogPointOfContact); -} - -void MainWindow::ClosedDialogPointOfContact(int result) -{ - ClosedDialog(dialogPointOfContact, result); -} - -void MainWindow::ToolDetail(bool checked) -{ - if (checked) - { - CanselTool(); - tool = Tool::Detail; - QPixmap pixmap("://cursor/new_detail_cursor.png"); - QCursor cur(pixmap, 2, 3); - view->setCursor(cur); - helpLabel->setText(tr("Select points, arcs, curves clockwise.")); - dialogDetail = QSharedPointer(new DialogDetail(data, mode)); - connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(), - &DialogDetail::ChoosedObject); - connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail); - connect(doc, &VDomDocument::FullUpdateFromFile, dialogDetail.data(), &DialogDetail::UpdateList); - } - else - { - if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) - { - tButton->setChecked(true); - } - } -} - -void MainWindow::ClosedDialogDetail(int result) -{ - if (result == QDialog::Accepted) - { - VToolDetail::Create(dialogDetail, sceneDetails, doc, data); - } - ArrowTool(); -} - -void MainWindow::ToolHeight(bool checked) -{ - SetToolButton(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), - dialogHeight, &MainWindow::ClosedDialogHeight); -} - -void MainWindow::ClosedDialogHeight(int result) -{ - ClosedDialog(dialogHeight, result); -} - -void MainWindow::ToolTriangle(bool checked) -{ - SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), - dialogTriangle, &MainWindow::ClosedDialogTriangle); -} - -void MainWindow::ClosedDialogTriangle(int result) -{ - ClosedDialog(dialogTriangle, result); -} - -void MainWindow::ToolPointOfIntersection(bool checked) -{ - SetToolButton(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", - tr("Select point vertically"), - dialogPointOfIntersection, &MainWindow::ClosedDialogPointOfIntersection); -} - -void MainWindow::ClosedDialogPointOfIntersection(int result) -{ - ClosedDialog(dialogPointOfIntersection, result); -} - -void MainWindow::About() -{ - QString fullName = QString("Valentina %1").arg(APP_VERSION); - QString qtBase(tr("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR)); - QString buildOn(tr("Built on %3 at %4").arg(__DATE__).arg(__TIME__)); - QString about = QString(tr("

%1

%2

%3

%4")).arg(fullName).arg(qtBase).arg( - buildOn).arg(WARRANTY); - QMessageBox::about(this, tr("About Valentina"), about); -} - -void MainWindow::AboutQt() -{ - QMessageBox::aboutQt(this, tr("About Qt")); -} - -void MainWindow::ShowToolTip(const QString &toolTip) -{ - helpLabel->setText(toolTip); -} - -void MainWindow::tableClosed() -{ - show(); - MinimumScrollBar(); -} - -void MainWindow::showEvent( QShowEvent *event ) -{ - QMainWindow::showEvent( event ); - if ( event->spontaneous() ) - { - return; - } - - if (isInitialized) - { - return; - } - // do your init stuff here - MinimumScrollBar(); - - isInitialized = true;//first show windows are held -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - if (changeInFile == true) - { - QMessageBox msgBox; - msgBox.setText(tr("The pattern has been modified.")); - msgBox.setInformativeText(tr("Do you want to save your changes?")); - msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Save); - msgBox.setIcon(QMessageBox::Question); - int ret = msgBox.exec(); - switch (ret) - { - case QMessageBox::Save: - // Save was clicked - if (fileName.isEmpty()) - { - ActionSaveAs(); - } - else - { - ActionSave(); - } - if (changeInFile) - { - // We did't save file - event->ignore(); - } - else - { - // We have successfully saved the file - event->accept(); - } - break; - case QMessageBox::Discard: - // Don't Save was clicked - event->accept(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - event->ignore(); - break; - default: - // should never be reached - event->accept(); - break; - } - } -} - -void MainWindow::ToolBarOption() -{ - QLabel * labelGrowth = new QLabel; - labelGrowth->setText(tr("Growth: ")); - ui->toolBarOption->addWidget(labelGrowth); - - QStringList list; - list <<"92"<<"98"<<"104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176" - <<"182"<<"188"; - QComboBox *comboBoxGrow = new QComboBox; - comboBoxGrow->clear(); - comboBoxGrow->addItems(list); - comboBoxGrow->setCurrentIndex(14); - ui->toolBarOption->addWidget(comboBoxGrow); - connect(comboBoxGrow, - static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::ChangedGrowth); - - QLabel * labelSize = new QLabel; - labelSize->setText(tr(" Size: ")); - ui->toolBarOption->addWidget(labelSize); - - list.clear(); - list <<"22"<<"24"<<"26"<<"28"<<"30"<<"32"<<"34"<<"36"<<"38"<<"40"<<"42"<<"44"<<"46"<<"48"<<"50"<<"52"<<"54"<<"56"; - QComboBox *comboBoxSize = new QComboBox; - comboBoxSize->clear(); - comboBoxSize->addItems(list); - comboBoxSize->setCurrentIndex(14); - ui->toolBarOption->addWidget(comboBoxSize); - connect(comboBoxSize, - static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::ChangedSize); - - ui->toolBarOption->addSeparator(); - - mouseCoordinate = new QLabel; - mouseCoordinate ->setText("0, 0"); - ui->toolBarOption->addWidget(mouseCoordinate); - -} - -void MainWindow::ToolBarDraws() -{ - QLabel * labelNameDraw = new QLabel; - labelNameDraw ->setText(tr("Drawing: ")); - ui->toolBarDraws->addWidget(labelNameDraw); - - comboBoxDraws = new QComboBox; - ui->toolBarDraws->addWidget(comboBoxDraws); - comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); - connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - - ui->toolBarDraws->addAction(ui->actionOptionDraw); - ui->actionOptionDraw->setEnabled(false); - - ui->toolBarDraws->addAction(ui->actionTable); - ui->actionTable->setEnabled(false); - - ui->toolBarDraws->addAction(ui->actionHistory); - ui->actionHistory->setEnabled(false); - connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory); - - ui->toolBarDraws->addAction(ui->actionLayout); - connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout); -} - -void MainWindow::currentDrawChanged( int index ) -{ - if (index != -1) - { - doc->setCurrentData(); - doc->ChangeActivDraw(comboBoxDraws->itemText(index)); - } -} - -void MainWindow::mouseMove(const QPointF &scenePos) -{ - QString string = QString("%1, %2") - .arg(static_cast(toMM(scenePos.x()))) - .arg(static_cast(toMM(scenePos.y()))); - mouseCoordinate->setText(string); -} - -void MainWindow::CanselTool() -{ - switch ( tool ) - { - case Tool::ArrowTool: - ui->actionArrowTool->setChecked(false); - helpLabel->setText(""); - break; - case Tool::SinglePointTool: - Q_UNREACHABLE(); - //Nothing to do here because we can't create this tool from main window. - break; - case Tool::EndLineTool: - dialogEndLine.clear(); - ui->toolButtonEndLine->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::LineTool: - dialogLine.clear(); - ui->toolButtonLine->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearFocus(); - break; - case Tool::AlongLineTool: - dialogAlongLine.clear(); - ui->toolButtonAlongLine->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::ShoulderPointTool: - dialogShoulderPoint.clear(); - ui->toolButtonShoulderPoint->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::NormalTool: - dialogNormal.clear(); - ui->toolButtonNormal->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::BisectorTool: - dialogBisector.clear(); - ui->toolButtonBisector->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::LineIntersectTool: - dialogLineIntersect.clear(); - ui->toolButtonLineIntersect->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::SplineTool: - dialogSpline.clear(); - ui->toolButtonSpline->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::ArcTool: - dialogArc.clear(); - ui->toolButtonArc->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::SplinePathTool: - dialogSplinePath.clear(); - ui->toolButtonSplinePath->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::PointOfContact: - dialogPointOfContact.clear(); - ui->toolButtonPointOfContact->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::Detail: - dialogDetail.clear(); - ui->toolButtonNewDetail->setChecked(false); - break; - case Tool::Height: - dialogHeight.clear(); - ui->toolButtonHeight->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::Triangle: - dialogTriangle.clear(); - ui->toolButtonTriangle->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - case Tool::PointOfIntersection: - dialogPointOfIntersection.clear(); - ui->toolButtonPointOfIntersection->setChecked(false); - currentScene->setFocus(Qt::OtherFocusReason); - currentScene->clearSelection(); - break; - default: - qWarning()<<"Get wrong tool type. Ignore."; - break; - } -} - -void MainWindow::ArrowTool() -{ - CanselTool(); - ui->actionArrowTool->setChecked(true); - tool = Tool::ArrowTool; - QCursor cur(Qt::ArrowCursor); - view->setCursor(cur); - helpLabel->setText(""); -} - -void MainWindow::ActionAroowTool() -{ - ArrowTool(); -} - -void MainWindow::keyPressEvent ( QKeyEvent * event ) -{ - switch (event->key()) - { - case Qt::Key_Escape: - ArrowTool(); - break; - default: - break; - } - QMainWindow::keyPressEvent ( event ); -} - -void MainWindow::ActionDraw(bool checked) -{ - if (checked) - { - ui->actionDetails->setChecked(false); - /*Save scroll bars value for previous scene.*/ - QScrollBar *horScrollBar = view->horizontalScrollBar(); - currentScene->setHorScrollBar(horScrollBar->value()); - QScrollBar *verScrollBar = view->verticalScrollBar(); - currentScene->setVerScrollBar(verScrollBar->value()); - - currentScene = sceneDraw; - view->setScene(currentScene); - /*Set value for current scene scroll bar.*/ - horScrollBar = view->horizontalScrollBar(); - horScrollBar->setValue(currentScene->getHorScrollBar()); - verScrollBar = view->verticalScrollBar(); - verScrollBar->setValue(currentScene->getVerScrollBar()); - - mode = Draw::Calculation; - doc->setCurrentData(); - } - else - { - ui->actionDraw->setChecked(true); - } -} - -void MainWindow::ActionDetails(bool checked) -{ - if (checked) - { - ui->actionDraw->setChecked(false); - /*Save scroll bars value for previous scene.*/ - QScrollBar *horScrollBar = view->horizontalScrollBar(); - currentScene->setHorScrollBar(horScrollBar->value()); - QScrollBar *verScrollBar = view->verticalScrollBar(); - currentScene->setVerScrollBar(verScrollBar->value()); - - currentScene = sceneDetails; - view->setScene(sceneDetails); - /*Set value for current scene scroll bar.*/ - horScrollBar = view->horizontalScrollBar(); - horScrollBar->setValue(currentScene->getHorScrollBar()); - verScrollBar = view->verticalScrollBar(); - verScrollBar->setValue(currentScene->getVerScrollBar()); - mode = Draw::Modeling; - } - else - { - ui->actionDetails->setChecked(true); - } -} - -void MainWindow::ActionSaveAs() -{ - QString filters(tr("Lekalo files (*.xml);;All files (*.*)")); - QString defaultFilter(tr("Lekalo files (*.xml)")); - QString fName = QFileDialog::getSaveFileName(this, tr("Save as"), QDir::homePath(), - filters, &defaultFilter); - if (fName.isEmpty()) - { - return; - } - if (fName.indexOf(".xml", fName.size()-4)<0) - { - fName.append(".xml"); - } - fileName = fName; - - ActionSave(); -} - -void MainWindow::ActionSave() -{ - if (fileName.isEmpty() == false) - { - bool result = SafeSaveing(fileName); - if (result) - { - ui->actionSave->setEnabled(false); - changeInFile = false; - QFileInfo info(fileName); - QString title(info.fileName()); - title.append("-Valentina"); - setWindowTitle(title); - } - else - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error saving file. Can't save file.")); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - } - } -} - -void MainWindow::ActionOpen() -{ - QString filter(tr("Lekalo files (*.xml)")); - QString fName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter); - if (fName.isEmpty()) - { - return; - } - if (fileName.isEmpty() && changeInFile == false) - { - OpenPattern(fName); - } - else - { - /*Open new copy application*/ - QProcess *v = new QProcess(this); - QStringList arguments; - arguments << "-o" << fName; - v->startDetached(QCoreApplication::applicationFilePath (), arguments); - delete v; - } -} - -void MainWindow::Clear() -{ - setWindowTitle("Valentina"); - fileName.clear(); - data->Clear(); - doc->clear(); - sceneDraw->clear(); - sceneDetails->clear(); - CanselTool(); - comboBoxDraws->clear(); - fileName.clear(); - ui->actionOptionDraw->setEnabled(false); - ui->actionSave->setEnabled(false); - SetEnableTool(false); -} - -void MainWindow::ActionNew() -{ - QProcess *v = new QProcess(this); - v->startDetached(QCoreApplication::applicationFilePath ()); - delete v; -} - -void MainWindow::haveChange() -{ - if (fileName.isEmpty() == false) - { - ui->actionSave->setEnabled(true); - changeInFile = true; - QFileInfo info(fileName); - QString title(info.fileName()); - title.append("*-Valentina"); - setWindowTitle(title); - } -} - -void MainWindow::ChangedSize(const QString & text) -{ - qint32 size = text.toInt(); - data->SetSize(size*10); - doc->FullUpdateTree(); -} - -void MainWindow::ChangedGrowth(const QString &text) -{ - qint32 growth = text.toInt(); - data->SetGrowth(growth*10); - doc->FullUpdateTree(); -} - -void MainWindow::SetEnableWidgets(bool enable) -{ - ui->actionSaveAs->setEnabled(enable); - ui->actionDraw->setEnabled(enable); - ui->actionDetails->setEnabled(enable); - ui->actionOptionDraw->setEnabled(enable); - if (enable == true && fileName.isEmpty() == false) - { - ui->actionSave->setEnabled(enable); - } - ui->actionTable->setEnabled(enable); - ui->actionHistory->setEnabled(enable); -} - -void MainWindow::ActionTable(bool checked) -{ - if (checked) - { - dialogTable = new DialogIncrements(data, doc, this); - connect(dialogTable, &DialogIncrements::DialogClosed, this, - &MainWindow::ClosedActionTable); - dialogTable->show(); - } - else - { - ui->actionTable->setChecked(true); - dialogTable->activateWindow(); - } -} - -void MainWindow::ClosedActionTable() -{ - ui->actionTable->setChecked(false); - delete dialogTable; -} - -void MainWindow::ActionHistory(bool checked) -{ - if (checked) - { - dialogHistory = new DialogHistory(data, doc, this); - dialogHistory->setWindowFlags(Qt::Window); - connect(dialogHistory, &DialogHistory::DialogClosed, this, - &MainWindow::ClosedActionHistory); - dialogHistory->show(); - } - else - { - ui->actionHistory->setChecked(true); - dialogHistory->activateWindow(); - } -} - -void MainWindow::ActionLayout(bool checked) -{ - Q_UNUSED(checked); - hide(); - QVector listDetails; - data->PrepareDetails(listDetails); - emit ModelChosen(listDetails); -} - -void MainWindow::ClosedActionHistory() -{ - ui->actionHistory->setChecked(false); - delete dialogHistory; -} - -void MainWindow::SetEnableTool(bool enable) -{ - ui->toolButtonEndLine->setEnabled(enable); - ui->toolButtonLine->setEnabled(enable); - ui->toolButtonAlongLine->setEnabled(enable); - ui->toolButtonShoulderPoint->setEnabled(enable); - ui->toolButtonNormal->setEnabled(enable); - ui->toolButtonBisector->setEnabled(enable); - ui->toolButtonLineIntersect->setEnabled(enable); - ui->toolButtonSpline->setEnabled(enable); - ui->toolButtonArc->setEnabled(enable); - ui->toolButtonSplinePath->setEnabled(enable); - ui->toolButtonPointOfContact->setEnabled(enable); - ui->toolButtonNewDetail->setEnabled(enable); - ui->toolButtonHeight->setEnabled(enable); - ui->toolButtonTriangle->setEnabled(enable); - ui->toolButtonPointOfIntersection->setEnabled(enable); -} - -void MainWindow::MinimumScrollBar() -{ - QScrollBar *horScrollBar = view->horizontalScrollBar(); - horScrollBar->setValue(horScrollBar->minimum()); - QScrollBar *verScrollBar = view->verticalScrollBar(); - verScrollBar->setValue(verScrollBar->minimum()); -} - -bool MainWindow::SafeSaveing(const QString &fileName) const -{ - try - { - doc->TestUniqueId(); - } - catch (const VExceptionUniqueId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error don't unique id.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - return false; - } - if (fileName.isEmpty()) - { - qWarning()<save(out, Indent); - tempFile.close(); - } - //Replace temp file our - bool result = false; - QFile patternFile(fileName); - // We need here temporary file because we need restore pattern after error of copying temp file. - QTemporaryFile tempOfPattern; - if (tempOfPattern.open()) - { - patternFile.copy(tempOfPattern.fileName()); - } - if ( patternFile.exists() == false || patternFile.remove() ) - { - if ( tempFile.copy(patternFile.fileName()) == false ) - { - qCritical()<actionSave->setEnabled(false); - changeInFile = false; - QFileInfo info(fileName); - QString title(info.fileName()); - title.append("-Valentina"); - setWindowTitle(title); - } - } -} - -MainWindow::~MainWindow() -{ - CanselTool(); - delete ui; - - delete data; - if (doc->isNull() == false) - { - delete doc; - } -} - -void MainWindow::OpenPattern(const QString &fileName) -{ - if (fileName.isEmpty()) - { - qWarning()<setContent(&file, &errorMsg, &errorLine, &errorColumn)) - { - disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - try - { - doc->Parse(Document::FullParse, sceneDraw, sceneDetails); - } - catch (const VExceptionObjectError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionConversionError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error can't convert value.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionEmptyParameter &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error empty parameter.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionWrongParameterId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error wrong id.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionUniqueId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error don't unique id.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - QString nameDraw = doc->GetNameActivDraw(); - qint32 index = comboBoxDraws->findText(nameDraw); - if ( index != -1 ) - { // -1 for not found - comboBoxDraws->setCurrentIndex(index); - } - if (comboBoxDraws->count() > 0) - { - SetEnableTool(true); - } - else - { - SetEnableTool(false); - } - SetEnableWidgets(true); - } - else - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing pattern file.")); - msgBox.setInformativeText(errorMsg); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - QString error = QString(tr("Error in line %1 column %2")).arg(errorLine, errorColumn); - msgBox.setDetailedText(error); - msgBox.exec(); - file.close(); - Clear(); - return; - } - file.close(); - } - this->fileName = fileName; - QFileInfo info(fileName); - QString title(info.fileName()); - title.append("-Valentina"); - setWindowTitle(title); - helpLabel->setText(""); -} diff --git a/src/mainwindow.h b/src/mainwindow.h deleted file mode 100644 index bdd4fb190..000000000 --- a/src/mainwindow.h +++ /dev/null @@ -1,549 +0,0 @@ -/************************************************************************ - ** - ** @file mainwindow.h - ** @author Roman Telezhinsky - ** @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 - ** 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 MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include "widgets/vmaingraphicsscene.h" -#include "widgets/vmaingraphicsview.h" -#include "widgets/vitem.h" -#include "dialogs/dialogs.h" -#include "tools/vtooldetail.h" -#include "tools/drawTools/drawtools.h" -#include "tools/modelingTools/modelingtools.h" -#include "xml/vdomdocument.h" - -namespace Ui -{ - class MainWindow; -} - -/** - * @brief The MainWindow class - */ -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - /** - * @brief MainWindow - * @param parent - */ - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - /** - * @brief OpenPattern - * @param fileName - */ - void OpenPattern(const QString &fileName); -public slots: - /** - * @brief mouseMove - * @param scenePos - */ - void mouseMove(const QPointF &scenePos); - /** - * @brief ActionAroowTool - */ - void ActionAroowTool(); - /** - * @brief ActionDraw - * @param checked - */ - void ActionDraw(bool checked); - /** - * @brief ActionDetails - * @param checked - */ - void ActionDetails(bool checked); - /** - * @brief ActionNewDraw - */ - void ActionNewDraw(); - /** - * @brief ActionSaveAs - */ - void ActionSaveAs(); - /** - * @brief ActionSave - */ - void ActionSave(); - /** - * @brief ActionOpen - */ - void ActionOpen(); - /** - * @brief ActionNew - */ - void ActionNew(); - /** - * @brief ActionTable - * @param checked - */ - void ActionTable(bool checked); - /** - * @brief ActionHistory - * @param checked - */ - void ActionHistory(bool checked); - /** - * @brief ActionLayout - * @param checked - */ - void ActionLayout(bool checked); - /** - * @brief currentDrawChanged - * @param index - */ - void currentDrawChanged( int index ); - /** - * @brief OptionDraw - */ - void OptionDraw(); - /** - * @brief haveChange - */ - void haveChange(); - /** - * @brief ChangedSize - * @param text - */ - void ChangedSize(const QString &text); - /** - * @brief ChangedGrowth - * @param text - */ - void ChangedGrowth(const QString & text); - /** - * @brief ClosedActionTable - */ - void ClosedActionTable(); - /** - * @brief ClosedActionHistory - */ - void ClosedActionHistory(); - /** - * @brief ToolEndLine - * @param checked - */ - void ToolEndLine(bool checked); - /** - * @brief ToolLine - * @param checked - */ - void ToolLine(bool checked); - /** - * @brief ToolAlongLine - * @param checked - */ - void ToolAlongLine(bool checked); - /** - * @brief ToolShoulderPoint - * @param checked - */ - void ToolShoulderPoint(bool checked); - /** - * @brief ToolNormal - * @param checked - */ - void ToolNormal(bool checked); - /** - * @brief ToolBisector - * @param checked - */ - void ToolBisector(bool checked); - /** - * @brief ToolLineIntersect - * @param checked - */ - void ToolLineIntersect(bool checked); - /** - * @brief ToolSpline - * @param checked - */ - void ToolSpline(bool checked); - /** - * @brief ToolArc - * @param checked - */ - void ToolArc(bool checked); - /** - * @brief ToolSplinePath - * @param checked - */ - void ToolSplinePath(bool checked); - /** - * @brief ToolPointOfContact - * @param checked - */ - void ToolPointOfContact(bool checked); - /** - * @brief ToolDetail - * @param checked - */ - void ToolDetail(bool checked); - /** - * @brief ToolHeight - * @param checked - */ - void ToolHeight(bool checked); - /** - * @brief ToolTriangle - * @param checked - */ - void ToolTriangle(bool checked); - /** - * @brief ToolPointOfIntersection - * @param checked - */ - void ToolPointOfIntersection(bool checked); - /** - * @brief ClosedDialogEndLine - * @param result - */ - void ClosedDialogEndLine(int result); - /** - * @brief ClosedDialogLine - * @param result - */ - void ClosedDialogLine(int result); - /** - * @brief ClosedDialogAlongLine - * @param result - */ - void ClosedDialogAlongLine(int result); - /** - * @brief ClosedDialogShoulderPoint - * @param result - */ - void ClosedDialogShoulderPoint(int result); - /** - * @brief ClosedDialogNormal - * @param result - */ - void ClosedDialogNormal(int result); - /** - * @brief ClosedDialogBisector - * @param result - */ - void ClosedDialogBisector(int result); - /** - * @brief ClosedDialogLineIntersect - * @param result - */ - void ClosedDialogLineIntersect(int result); - /** - * @brief ClosedDialogSpline - * @param result - */ - void ClosedDialogSpline(int result); - /** - * @brief ClosedDialogArc - * @param result - */ - void ClosedDialogArc(int result); - /** - * @brief ClosedDialogSplinePath - * @param result - */ - void ClosedDialogSplinePath(int result); - /** - * @brief ClosedDialogPointOfContact - * @param result - */ - void ClosedDialogPointOfContact(int result); - /** - * @brief ClosedDialogDetail - * @param result - */ - void ClosedDialogDetail(int result); - /** - * @brief ClosedDialogHeight - * @param result - */ - void ClosedDialogHeight(int result); - /** - * @brief ClosedDialogTriangle - * @param result - */ - void ClosedDialogTriangle(int result); - /** - * @brief ClosedDialogPointOfIntersection - * @param result - */ - void ClosedDialogPointOfIntersection(int result); - /** - * @brief About - */ - void About(); - /** - * @brief AboutQt - */ - void AboutQt(); - /** - * @brief ShowToolTip - * @param toolTip - */ - void ShowToolTip(const QString &toolTip); - /** - * @brief tableClosed Слот, що виконується при отриманні сигналу закриття вікна укладання - *деталей моделі. - */ - void tableClosed(); -signals: - /** - * @brief ModelChosen Сигнал, що висилається після розрахунку всіх деталей моделі. - * @param listDetails Список детайле моделі. - */ - void ModelChosen(QVector listDetails); -protected: - /** - * @brief keyPressEvent - * @param event - */ - virtual void keyPressEvent ( QKeyEvent * event ); - /** - * @brief showEvent - * @param event - */ - virtual void showEvent( QShowEvent *event ); - /** - * @brief closeEvent - * @param event - */ - virtual void closeEvent( QCloseEvent * event ); - /** - * @brief Clear - */ - void Clear(); -private: - Q_DISABLE_COPY(MainWindow) - /** - * @brief ui keeps information about user interface - */ - Ui::MainWindow *ui; - /** - * @brief tool - */ - Tool::Tools tool; - /** - * @brief currentScene - */ - VMainGraphicsScene *currentScene; - /** - * @brief sceneDraw - */ - VMainGraphicsScene *sceneDraw; - /** - * @brief sceneDetails - */ - VMainGraphicsScene *sceneDetails; - /** - * @brief mouseCoordinate - */ - QLabel *mouseCoordinate; - /** - * @brief helpLabel - */ - QLabel *helpLabel; - /** - * @brief view - */ - VMainGraphicsView *view; - /** - * @brief isInitialized - */ - bool isInitialized; - /** - * @brief dialogTable - */ - DialogIncrements *dialogTable; - /** - * @brief dialogEndLine - */ - QSharedPointer dialogEndLine; - /** - * @brief dialogLine - */ - QSharedPointer dialogLine; - /** - * @brief dialogAlongLine - */ - QSharedPointer dialogAlongLine; - /** - * @brief dialogShoulderPoint - */ - QSharedPointer dialogShoulderPoint; - /** - * @brief dialogNormal - */ - QSharedPointer dialogNormal; - /** - * @brief dialogBisector - */ - QSharedPointer dialogBisector; - /** - * @brief dialogLineIntersect - */ - QSharedPointer dialogLineIntersect; - /** - * @brief dialogSpline - */ - QSharedPointer dialogSpline; - /** - * @brief dialogArc - */ - QSharedPointer dialogArc; - /** - * @brief dialogSplinePath - */ - QSharedPointer dialogSplinePath; - /** - * @brief dialogPointOfContact - */ - QSharedPointer dialogPointOfContact; - /** - * @brief dialogDetail - */ - QSharedPointer dialogDetail; - /** - * @brief dialogHeight - */ - QSharedPointer dialogHeight; - /** - * @brief dialogTriangle - */ - QSharedPointer dialogTriangle; - /** - * @brief dialogPointOfIntersection - */ - QSharedPointer dialogPointOfIntersection; - /** - * @brief dialogHistory - */ - DialogHistory *dialogHistory; - /** - * @brief doc dom document container - */ - VDomDocument *doc; - /** - * @brief data container with data - */ - VContainer *data; - /** - * @brief comboBoxDraws - */ - QComboBox *comboBoxDraws; - /** - * @brief fileName - */ - QString fileName; - /** - * @brief changeInFile - */ - bool changeInFile; - /** - * @brief mode - */ - Draw::Draws mode; - /** - * @brief ToolBarOption - */ - void ToolBarOption(); - /** - * @brief ToolBarDraws - */ - void ToolBarDraws(); - /** - * @brief CanselTool - */ - void CanselTool(); - /** - * @brief ArrowTool - */ - void ArrowTool(); - /** - * @brief SetEnableWidgets - * @param enable - */ - void SetEnableWidgets(bool enable); - /** - * @brief SetEnableTool - * @param enable - */ - void SetEnableTool(bool enable); - /** - * - */ - template - /** - * @brief SetToolButton - * @param checked - * @param t - * @param cursor - * @param toolTip - * @param dialog - * @param closeDialogSlot - */ - void SetToolButton(bool checked, Tool::Tools t, const QString &cursor, const QString &toolTip, - QSharedPointer &dialog, Func closeDialogSlot); - /** - * @brief MinimumScrollBar - */ - void MinimumScrollBar(); - template - /** - * @brief AddToolToDetail - * @param tool - * @param id - * @param typeTool - * @param idDetail - */ - void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, - const qint64 &idDetail); - template - /** - * @brief ClosedDialog - * @param dialog - * @param result - */ - void ClosedDialog(QSharedPointer &dialog, int result); - /** - * @brief SafeSaveing - * @param fileName - * @return - */ - bool SafeSaveing(const QString &fileName)const; - /** - * @brief AutoSavePattern - */ - void AutoSavePattern(); -}; - -#endif // MAINWINDOW_H diff --git a/src/options.h b/src/options.h deleted file mode 100644 index 6f86d23d2..000000000 --- a/src/options.h +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************ - ** - ** @file options.h - ** @author Roman Telezhinsky - ** @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 - ** 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 OPTIONS_H -#define OPTIONS_H - -#include - -#define PrintDPI 96 -#define PaperSize 50000 -#define toPixel(mm) ((mm / 25.4) * PrintDPI) -#define toMM(pix) ((pix / PrintDPI) * 25.4) -#define widthMainLine 1.2 -#define widthHairLine widthMainLine/3 - -namespace Scene -{ - /** - * @brief The Scene enum - */ - enum Scene { Point, Line, Spline, Arc, SplinePath, Detail }; - Q_DECLARE_FLAGS(Scenes, Scene) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( Scene::Scenes ) - -namespace Tool -{ - /** - * @brief The Tool enum - */ - enum Tool - { - ArrowTool, - SinglePointTool, - EndLineTool, - LineTool, - AlongLineTool, - ShoulderPointTool, - NormalTool, - BisectorTool, - LineIntersectTool, - SplineTool, - ArcTool, - SplinePathTool, - PointOfContact, - Detail, - NodePoint, - NodeArc, - NodeSpline, - NodeSplinePath, - Height, - Triangle, - PointOfIntersection - }; - Q_DECLARE_FLAGS(Tools, Tool) - - /** - * @brief The Source enum - */ - enum Source { FromGui, FromFile }; - Q_DECLARE_FLAGS(Sources, Source) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools ) -Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Sources ) - -namespace Draw -{ - /** - * @brief The Draw enum - */ - enum Draw { Calculation, Modeling }; - Q_DECLARE_FLAGS(Draws, Draw) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Draw::Draws) - -#endif // OPTIONS_H diff --git a/src/src.pri b/src/src.pri deleted file mode 100644 index 68200a263..000000000 --- a/src/src.pri +++ /dev/null @@ -1,13 +0,0 @@ -SOURCES += src/main.cpp \ - src/mainwindow.cpp \ - src/tablewindow.cpp \ - src/stable.cpp - -HEADERS += src/mainwindow.h \ - src/options.h \ - src/tablewindow.h \ - src/stable.h \ - src/version.h - -FORMS += src/mainwindow.ui \ - src/tablewindow.ui diff --git a/src/src.pro b/src/src.pro new file mode 100644 index 000000000..4ae343d2a --- /dev/null +++ b/src/src.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +CONFIG += ordered + +# Order is important +SUBDIRS = \ + libs \ + app \ + test diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp deleted file mode 100644 index 132c3a5e8..000000000 --- a/src/tablewindow.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/************************************************************************ - ** - ** @file tablewindow.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "tablewindow.h" -#include "ui_tablewindow.h" -#include "widgets/vtablegraphicsview.h" -#include "options.h" -#include - -TableWindow::TableWindow(QWidget *parent) - :QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow), - listDetails(QVector()), outItems(false), collidingItems(false), currentScene(0), - paper(0), shadowPaper(0), listOutItems(0), listCollidingItems(QList()), - indexDetail(0), sceneRect(QRectF()) -{ - ui->setupUi(this); - numberDetal = new QLabel("Залишилось 0 деталей.", this); - colission = new QLabel("Колізій не знайдено.", this); - ui->statusBar->addWidget(numberDetal); - ui->statusBar->addWidget(colission); - outItems = collidingItems = false; - //sceneRect = QRectF(0, 0, toPixel(203), toPixel(287)); - sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171)); - currentScene = new QGraphicsScene(sceneRect); - QBrush *brush = new QBrush(); - brush->setStyle( Qt::SolidPattern ); - brush->setColor( QColor( Qt::gray ) ); - currentScene->setBackgroundBrush( *brush ); - VTableGraphicsView* view = new VTableGraphicsView(currentScene); - view->fitInView(view->scene()->sceneRect(), Qt::KeepAspectRatio); - ui->horizontalLayout->addWidget(view); - connect(ui->actionTurn, &QAction::triggered, view, &VTableGraphicsView::rotateItems); - connect(ui->actionMirror, &QAction::triggered, view, &VTableGraphicsView::MirrorItem); - connect(ui->actionZoomIn, &QAction::triggered, view, &VTableGraphicsView::ZoomIn); - connect(ui->actionZoomOut, &QAction::triggered, view, &VTableGraphicsView::ZoomOut); - connect(ui->actionStop, &QAction::triggered, this, &TableWindow::StopTable); - connect(ui->actionSave, &QAction::triggered, this, &TableWindow::saveScene); - connect(ui->actionNext, &QAction::triggered, this, &TableWindow::GetNextDetail); - connect(ui->actionAdd, &QAction::triggered, this, &TableWindow::AddLength); - connect(ui->actionRemove, &QAction::triggered, this, &TableWindow::RemoveLength); - connect(view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); -} - -TableWindow::~TableWindow() -{ - delete ui; -} - -void TableWindow::AddPaper() -{ - qreal x1, y1, x2, y2; - sceneRect.getCoords(&x1, &y1, &x2, &y2); - shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); - shadowPaper->setBrush(QBrush(Qt::black)); - currentScene->addItem(shadowPaper); - paper = new QGraphicsRectItem(QRectF(x1, y1, x2, y2)); - paper->setPen(QPen(Qt::black, widthMainLine)); - paper->setBrush(QBrush(Qt::white)); - currentScene->addItem(paper); - qDebug()<rect().size().toSize(); -} - -void TableWindow::AddDetail() -{ - if (indexDetailclearSelection(); - VItem* Detail = listDetails[indexDetail]; - QObject::connect(Detail, SIGNAL(itemOut(int, bool)), this, SLOT(itemOut(int, bool))); - QObject::connect(Detail, SIGNAL(itemColliding(QList, int)), this, - SLOT(itemColliding(QList, int))); - QObject::connect(this, SIGNAL(LengthChanged()), Detail, SLOT(LengthChanged())); - Detail->setPen(QPen(Qt::black, 1)); - Detail->setBrush(QBrush(Qt::white)); - Detail->setPos(paper->boundingRect().center()); - Detail->setFlag(QGraphicsItem::ItemIsMovable, true); - Detail->setFlag(QGraphicsItem::ItemIsSelectable, true); - Detail->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - Detail->setPaper(paper); - currentScene->addItem(Detail); - Detail->setSelected(true); - indexDetail++; - if (indexDetail==listDetails.count()) - { - ui->actionSave->setEnabled(true); - } - } - numberDetal->setText(QString("Залишилось %1 деталей.").arg(listDetails.count()-indexDetail)); -} - -/* - * Отримуємо деталі розрахованої моделі для подальшого укладання. - */ -void TableWindow::ModelChosen(QVector listDetails) -{ - this->listDetails = listDetails; - listOutItems = new QBitArray(this->listDetails.count()); - AddPaper(); - indexDetail = 0; - AddDetail(); - show(); -} - -void TableWindow::closeEvent(QCloseEvent *event) -{ - event->ignore(); - StopTable(); -} - -void TableWindow::moveToCenter() -{ - QRect rect = frameGeometry(); - rect.moveCenter(QDesktopWidget().availableGeometry().center()); - move(rect.topLeft()); -} - -void TableWindow::showEvent ( QShowEvent * event ) -{ - QMainWindow::showEvent(event); - moveToCenter(); -} - -void TableWindow::StopTable() -{ - hide(); - currentScene->clear(); - delete listOutItems; - listDetails.clear(); - //sceneRect = QRectF(0, 0, 230*resol/25.9, 327*resol/25.9); - sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171)); - emit closed(); -} - -void TableWindow::saveScene() -{ - QString name = QFileDialog::getSaveFileName(0, tr("Save layout"), "", "Images (*.png);;Svg files (*.svg)"); - if (name.isNull()) - { - return; - } - - QBrush *brush = new QBrush(); - brush->setColor( QColor( Qt::white ) ); - currentScene->setBackgroundBrush( *brush ); - currentScene->clearSelection(); // Selections would also render to the file - shadowPaper->setVisible(false); - QFileInfo fi(name); - if (fi.suffix() == "svg") - { - paper->setVisible(false); - SvgFile(name); - paper->setVisible(true); - } - else if (fi.suffix() == "png") - { - paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); - PngFile(name); - paper->setPen(QPen(Qt::black, widthMainLine)); - } - - brush->setColor( QColor( Qt::gray ) ); - brush->setStyle( Qt::SolidPattern ); - currentScene->setBackgroundBrush( *brush ); - shadowPaper->setVisible(true); - delete brush; -} - -void TableWindow::itemChect(bool flag) -{ - ui->actionTurn->setDisabled(flag); - ui->actionMirror->setDisabled(flag); -} - -void TableWindow::checkNext() -{ - if (outItems == true && collidingItems == true) - { - colission->setText("Колізій не знайдено."); - if (indexDetail==listDetails.count()) - { - ui->actionSave->setEnabled(true); - ui->actionNext->setDisabled(true); - } - else - { - ui->actionNext->setDisabled(false); - ui->actionSave->setEnabled(false); - } - } - else - { - colission->setText("Знайдено колізії."); - ui->actionNext->setDisabled(true); - ui->actionSave->setEnabled(false); - } -} - -void TableWindow::itemOut(int number, bool flag) -{ - listOutItems->setBit(number, flag); - for ( int i = 0; i < listOutItems->count(); ++i ) - { - if (listOutItems->at(i)==true) - { - outItems=false; - qDebug()<<"itemOut::outItems="< list, int number) -{ - //qDebug()<<"number="<1) - { - for ( int i = 0; i < listCollidingItems.count(); ++i ) - { - QList lis = listCollidingItems.at(i)->collidingItems(); - if (lis.size()-2 <= 0) - { - VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(i) ); - if (bitem == 0) - { - qDebug()<<"Не можу привести тип об'єкту"; - } - else - { - bitem->setPen(QPen(Qt::black, widthMainLine)); - } - listCollidingItems.removeAt(i); - } - } - } - else if (listCollidingItems.size()==1) - { - VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(0) ); - if (bitem == 0) - { - qDebug()<<"Не можу привести тип об'єкту"; - } - else - { - bitem->setPen(QPen(Qt::black, widthMainLine)); - } - listCollidingItems.clear(); - collidingItems = true; - } - } - else - { - collidingItems = true; - } - } - else - { - collidingItems = true; - } - } - else if (number==1) - { - if (list.contains(paper)==true) - { - list.removeAt(list.indexOf(paper)); - } - if (list.contains(shadowPaper)==true) - { - list.removeAt(list.indexOf(shadowPaper)); - } - for ( int i = 0; i < list.count(); ++i ) - { - if (listCollidingItems.contains(list.at(i))==false) - { - listCollidingItems.append(list.at(i)); - } - } - collidingItems = false; - } - qDebug()<<"itemColliding::outItems="<sceneRect(); - rect.setHeight(rect.height()+toPixel(279)); - currentScene->setSceneRect(rect); - rect = shadowPaper->rect(); - rect.setHeight(rect.height()+toPixel(279)); - shadowPaper->setRect(rect); - rect = paper->rect(); - rect.setHeight(rect.height()+toPixel(279)); - paper->setRect(rect); - ui->actionRemove->setEnabled(true); - emit LengthChanged(); -} - -void TableWindow::RemoveLength() -{ - if (sceneRect.height() <= currentScene->sceneRect().height() - 100) - { - QRectF rect = currentScene->sceneRect(); - rect.setHeight(rect.height()-toPixel(279)); - currentScene->setSceneRect(rect); - rect = shadowPaper->rect(); - rect.setHeight(rect.height()-toPixel(279)); - shadowPaper->setRect(rect); - rect = paper->rect(); - rect.setHeight(rect.height()-toPixel(279)); - paper->setRect(rect); - if (fabs(sceneRect.height() - currentScene->sceneRect().height()) < 0.01) - { - ui->actionRemove->setDisabled(true); - } - emit LengthChanged(); - } - else - { - ui->actionRemove->setDisabled(true); - } -} - -void TableWindow::keyPressEvent ( QKeyEvent * event ) -{ - if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ) - { - if (ui->actionNext->isEnabled() == true ) - { - AddDetail(); - qDebug()<<"Додали деталь."; - } - } - QMainWindow::keyPressEvent ( event ); -} - - -void TableWindow::SvgFile(const QString &name) const -{ - QSvgGenerator generator; - generator.setFileName(name); - generator.setSize(paper->rect().size().toSize()); - generator.setTitle(tr("SVG Generator Example Drawing")); - generator.setDescription(tr("An SVG drawing created by the SVG Generator " - "Example provided with Qt.")); - generator.setResolution(PrintDPI); - qDebug()<<"resolution is" << generator.resolution(); - QPainter painter; - painter.begin(&generator); - painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, 1.2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); - currentScene->render(&painter); - painter.end(); -} - -void TableWindow::PngFile(const QString &name) const -{ - QRectF r = paper->rect(); - qreal x=0, y=0, w=0, h=0; - r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents - // Create the image with the exact size of the shrunk scene - QImage image(QSize(static_cast(w), static_cast(h)), QImage::Format_ARGB32); - image.fill(Qt::transparent); // Start all pixels transparent - QPainter painter(&image); - painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); - currentScene->render(&painter); - image.save(name); -} diff --git a/src/tablewindow.h b/src/tablewindow.h deleted file mode 100644 index 82ed71a95..000000000 --- a/src/tablewindow.h +++ /dev/null @@ -1,215 +0,0 @@ -/************************************************************************ - ** - ** @file tablewindow.h - ** @author Roman Telezhinsky - ** @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 - ** 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 TABLEWINDOW_H -#define TABLEWINDOW_H - -#include -#include -#include "widgets/vitem.h" - -namespace Ui -{ - class TableWindow; -} - -/** - * @brief TableWindow клас вікна створення розкладки. - */ -class TableWindow : public QMainWindow -{ - Q_OBJECT -public: - /** - * @brief numberDetal Виводиться кількість деталей що ще залишилися. - */ - QLabel* numberDetal; - /** - * @brief colission Виводиться чи є колізії. - */ - QLabel* colission; - /** - * @brief TableWindow Конструктор класу вікна створення розкладки. - * @param parent parent widget Батько об'єкту. За замовчуванням = 0. - */ - explicit TableWindow(QWidget *parent = 0); - /** - * @brief ~TableWindow Деструктор класу вікна. - */ - ~TableWindow(); -public slots: - /** - * @brief ModelChosen Слот, що виконується при отриманні сигналу про розрахунок всіх деталей - *моделі. - * @param listDetails Список моделей деталі. - */ - void ModelChosen(QVector listDetails); - /** - * @brief StopTable Слот, що виконується при хованні вікна. Виконує неохідні очищення і ховає - *вікно. - */ - void StopTable(); - /** - * @brief saveScene Слот виконується при натисненні кнопки зберегти. - */ - void saveScene(); - /** - * @brief GetNextDetail Слот виконується при натисненні кнопки наступна деталь. - */ - void GetNextDetail(); - /** - * @brief itemChect Відключає можливість виклику перевороту, якщо не вибрано жодної деталі. - * @param flag Булеве значення що регулює стан кнопки. - */ - void itemChect(bool flag); - /** - * @brief itemOut Слот, що виконується при отриманні сигналу виходу за межі листа. - * @param number Номер деталі в списку що вийшла за межі. - * @param flag Зберігає стан деталі. - */ - void itemOut(int number, bool flag); - /** - * @brief itemColliding Сигнал, що виконується при отриманні сигналу колізії об'єктів. - * @param list Список об'єктів що перетинаються. - * @param number 0 - включити до списку деталей що перетинаються, 1 - виключити зі списку. - */ - void itemColliding(QList list, int number); - /** - * @brief AddLength Збільшує довжину листа на певне значення за один раз. - */ - void AddLength(); - /** - * @brief RemoveLength Зменшує довжину листа на певне знечення за один раз. - *Зменшення відбувається до мінімально заданого значення. - */ - void RemoveLength(); -signals: - /** - * @brief closed Сигнал посилається при хованні вікна. - */ - void closed(); - /** - * @brief LengthChanged Сигнал посилається при зміні розміру листа. - */ - void LengthChanged(); -protected: - /** - * @brief closeEvent Перехоплення події закриття. - * @param event Подія що отримується. - */ - void closeEvent(QCloseEvent *event); - /** - * @brief moveToCenter Переміщує вікно у центер екрану. - */ - void moveToCenter(); - /** - * @brief showEvent Перехоплення події показу вікна для розміщення його поцентру. - * @param event Подія що отримується. - */ - void showEvent ( QShowEvent * event ); - /** - * @brief keyPressEvent - * @param event - */ - void keyPressEvent ( QKeyEvent * event ); -private: - Q_DISABLE_COPY(TableWindow) - /** - * @brief ui keeps information about user interface Змінна для доступу до об'єктів вікна. - */ - Ui::TableWindow* ui; - /** - * @brief listDetails Список деталей на укладання. - */ - QVector listDetails; - /** - * @brief outItems Змінна зберігає показує чи маємо деталі що виходять за межі листа. - */ - bool outItems; - /** - * @brief collidingItems Змінна показує чи маємо деталі що перетинаються. - */ - bool collidingItems; - /** - * @brief currentScene Зберігається покажчик на сцену. - */ - QGraphicsScene* currentScene; - /** - * @brief paper Зберігається покажчик на прямокутник що імітує листа паперу. - */ - QGraphicsRectItem* paper; - /** - * @brief shadowPaper Зберігається покажчик на прямокутник що імітує тінь листа паперу. - */ - QGraphicsRectItem* shadowPaper; - /** - * @brief checkNext Метод регулює стан кнопки Next. - */ - void checkNext(); - /** - * @brief listOutItems Список стану виходу за лист кожної деталі. - */ - QBitArray* listOutItems; - /** - * @brief listCollidingItems Список що зберігає деталі що перетинаються між собою. - */ - QList listCollidingItems; - /** - * @brief AddPaper Додає на сцену лист паперу з тінню. - */ - void AddPaper(); - /** - * @brief AddDetail Додає наступну деталь. - */ - void AddDetail(); - /** - * @brief indexDetail Індекс деталі в списку, що буде викладатися наступного разу. - */ - qint32 indexDetail; - /** - * @brief sceneRect Мінімальний розмір листа паперу що буде показуватися на сцені. - */ - QRectF sceneRect; - /** - * @brief SvgFile - * @param name - */ - void SvgFile(const QString &name)const; - /** - * @brief PngFile - * @param name - */ - void PngFile(const QString &name)const; - /** - * @brief PsFile - * @param name - */ - void PsFile(const QString &name)const; -}; - -#endif // TABLEWINDOW_H diff --git a/src/test/ParserTest/ParserTest.pro b/src/test/ParserTest/ParserTest.pro new file mode 100644 index 000000000..7a6b30b4e --- /dev/null +++ b/src/test/ParserTest/ParserTest.pro @@ -0,0 +1,96 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-05-21T20:43:38 +# +#------------------------------------------------- + +# Build QMuParser tests. + +# File with common stuff for whole project +include(../../../Valentina.pri) + +# We use many core functions. +QT += core + +# Consol application doesn't need gui. +QT -= gui + +# Name of binary file. +TARGET = ParserTest + +# Console application, we use C++11 standard. +CONFIG += console c++11 + +# Use out-of-source builds (shadow builds) +CONFIG -= app_bundle debug_and_release debug_and_release_target + +# We want create executable file +TEMPLATE = app + +# directory for executable file +DESTDIR = bin + +# objecs files +OBJECTS_DIR = obj + +HEADERS += \ + stable.h + +SOURCES += \ + main.cpp \ + stable.cpp + +# Set using ccache. Function enable_ccache() defined in Valentina.pri. +$$enable_ccache() + +# Set precompiled headers. Function set_PCH() defined in Valentina.pri. +$$set_PCH() + +CONFIG(debug, debug|release){ + # Debug mode + unix { + #Turn on compilers warnings. + *-g++{ + QMAKE_CXXFLAGS += \ + $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + #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_CFLAGS+=-fsanitize=address -fno-omit-frame-pointer + QMAKE_LFLAGS+=-fsanitize=address + } + clang*{ + QMAKE_CXXFLAGS += \ + $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } else { + *-g++{ + QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details. + } + } + +}else{ + # Release mode + DEFINES += QT_NO_DEBUG_OUTPUT + + # Turn on debug symbols in release mode on Unix systems. + # On Mac OS X temporarily disabled. Need find way how to strip binary file. + unix:!macx:QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3 +} + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:unix: LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser + +INCLUDEPATH += $$PWD/../../libs/qmuparser +DEPENDPATH += $$PWD/../../libs/qmuparser + +# Strip after you link all libaries. +CONFIG(release, debug|release){ + unix:!macx{ + # Strip debug symbols. + QMAKE_POST_LINK += objcopy --only-keep-debug $(TARGET) $(TARGET).debug && + QMAKE_POST_LINK += strip --strip-debug --strip-unneeded $(TARGET) && + QMAKE_POST_LINK += objcopy --add-gnu-debuglink $(TARGET).debug $(TARGET) + } +} diff --git a/src/test/ParserTest/main.cpp b/src/test/ParserTest/main.cpp new file mode 100644 index 000000000..6239835c8 --- /dev/null +++ b/src/test/ParserTest/main.cpp @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file main.cpp + ** @author Roman Telezhynskyi + ** @date 21 5, 2014 + ** + ** @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) 2014 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 +#include +#include +#include "../../libs/qmuparser/qmuparsertest.h" + +using namespace qmu; + +//--------------------------------------------------------------------------------------------------------------------- +void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) + { + case QtDebugMsg: + fprintf(stderr, "%s\n", localMsg.constData()); + break; + case QtWarningMsg: + fprintf(stderr, "%s\n", localMsg.constData()); + break; + case QtCriticalMsg: + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); + break; + case QtFatalMsg: + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); + abort(); + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + qInstallMessageHandler(testMessageOutput); + + qWarning() << "-----------------------------------------------------------"; + qWarning() << "Running test suite:\n"; + + + qmu::Test::QmuParserTester pt; + pt.Run(); + + qWarning() << "Done."; + qWarning() << "-----------------------------------------------------------"; + + return a.exec(); +} diff --git a/src/container/vpointf.cpp b/src/test/ParserTest/stable.cpp similarity index 76% rename from src/container/vpointf.cpp rename to src/test/ParserTest/stable.cpp index 9bae8f96f..243b23938 100644 --- a/src/container/vpointf.cpp +++ b/src/test/ParserTest/stable.cpp @@ -1,7 +1,7 @@ /************************************************************************ ** - ** @file vpointf.cpp - ** @author Roman Telezhinsky + ** @file stable.cpp + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -26,16 +26,5 @@ ** *************************************************************************/ -#include "vpointf.h" - -VPointF &VPointF::operator =(const VPointF &point) -{ - _name = point.name(); - _mx = point.mx(); - _my = point.my(); - _x = point.x(); - _y = point.y(); - mode = point.getMode(); - idObject = point.getIdObject(); - return *this; -} +// Build the precompiled headers. +#include "stable.h" diff --git a/src/container/vincrementtablerow.cpp b/src/test/ParserTest/stable.h similarity index 70% rename from src/container/vincrementtablerow.cpp rename to src/test/ParserTest/stable.h index 7b7b00655..4d9dd80f4 100644 --- a/src/container/vincrementtablerow.cpp +++ b/src/test/ParserTest/stable.h @@ -1,7 +1,7 @@ /************************************************************************ ** - ** @file vincrementtablerow.cpp - ** @author Roman Telezhinsky + ** @file stable.h + ** @author Roman Telezhynskyi ** @date November 15, 2013 ** ** @brief @@ -26,10 +26,23 @@ ** *************************************************************************/ -#include "vincrementtablerow.h" +#ifndef STABLE_H +#define STABLE_H -VIncrementTableRow::VIncrementTableRow() - :id(0), base(0), ksize(0), kgrowth(0), description(QString()){} +/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ +#ifndef __clang__ +#pragma message("Compiling precompiled headers for QmuParser tests.\n") +#endif -VIncrementTableRow::VIncrementTableRow(qint64 id, qreal base, qreal ksize, qreal kgrowth, QString description) - :id(id), base(base), ksize(ksize), kgrowth(kgrowth), description(description){} +/* Add C includes here */ + +#if defined __cplusplus +/* Add C++ includes here */ + +#ifdef QT_CORE_LIB +#include +#endif + +#endif + +#endif // STABLE_H diff --git a/src/test/test.pro b/src/test/test.pro new file mode 100644 index 000000000..db8b1c7c4 --- /dev/null +++ b/src/test/test.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = ParserTest diff --git a/src/tools/drawTools/vdrawtool.cpp b/src/tools/drawTools/vdrawtool.cpp deleted file mode 100644 index 20c93c55b..000000000 --- a/src/tools/drawTools/vdrawtool.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************ - ** - ** @file vdrawtool.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vdrawtool.h" - -qreal VDrawTool::factor = 1; - -VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) - :VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false), - nameActivDraw(doc->GetNameActivDraw()) -{ - connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); - connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); - connect(this->doc, &VDomDocument::ShowTool, this, &VDrawTool::ShowTool); -} - -void VDrawTool::AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc) -{ - qint64 cursor = doc->getCursor(); - QVector *history = doc->getHistory(); - if (cursor <= 0) - { - history->append(VToolRecord(id, toolType, doc->GetNameActivDraw())); - } - else - { - qint32 index = 0; - for (qint32 i = 0; isize(); ++i) - { - VToolRecord rec = history->at(i); - if (rec.getId() == cursor) - { - index = i; - break; - } - } - history->insert(index+1, VToolRecord(id, toolType, doc->GetNameActivDraw())); - } -} - -void VDrawTool::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - Q_UNUSED(id); - Q_UNUSED(color); - Q_UNUSED(enable); -} - -void VDrawTool::ChangedActivDraw(const QString &newName) -{ - if (nameActivDraw == newName) - { - ignoreContextMenuEvent = false; - } - else - { - ignoreContextMenuEvent = true; - } -} - -void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) -{ - if (nameActivDraw == oldName) - { - nameActivDraw = newName; - } -} - -void VDrawTool::SetFactor(qreal factor) -{ - if (factor <= 2 && factor >= 0.5) - { - this->factor = factor; - } -} - -void VDrawTool::AddToCalculation(const QDomElement &domElement) -{ - QDomElement calcElement; - bool ok = doc->GetActivCalculationElement(calcElement); - if (ok) - { - qint64 id = doc->getCursor(); - if (id <= 0) - { - calcElement.appendChild(domElement); - } - else - { - QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor())); - if (refElement.isElement()) - { - calcElement.insertAfter(domElement, refElement); - doc->setCursor(0); - } - else - { - qCritical()< - ** @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 - ** 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 VDRAWTOOL_H -#define VDRAWTOOL_H - -#include "../vabstracttool.h" - -#include -#include - -/** - * @brief The VDrawTool class - */ -class VDrawTool : public VAbstractTool -{ - Q_OBJECT -public: - /** - * @brief VDrawTool - * @param doc dom document container - * @param data - * @param id - * @param parent - */ - VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); - virtual ~VDrawTool() {} - /** - * @brief setDialog - */ - virtual void setDialog() {} - /** - * @brief AddRecord - * @param id - * @param toolType - * @param doc dom document container - */ - static void AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc); - /** - * @brief ignoreContextMenu - * @param enable - */ - void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;} -public slots: - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief ChangedActivDraw - * @param newName - */ - virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ChangedNameDraw - * @param oldName - * @param newName - */ - void ChangedNameDraw(const QString &oldName, const QString &newName); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result)=0; - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief ignoreContextMenuEvent - */ - bool ignoreContextMenuEvent; - /** - * @brief ignoreFullUpdate - */ - bool ignoreFullUpdate; - /** - * @brief nameActivDraw - */ - QString nameActivDraw; - /** - * @brief factor - */ - static qreal factor; - /** - * @brief AddToCalculation - * @param domElement - */ - void AddToCalculation(const QDomElement &domElement); - template - /** - * @brief ContextMenu - * @param dialog - * @param tool - * @param event - * @param showRemove - */ - void ContextMenu(QSharedPointer &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event, - bool showRemove = true) - { - Q_ASSERT(tool != 0); - Q_ASSERT(event != 0); - if (ignoreContextMenuEvent == false) - { - QMenu menu; - QAction *actionOption = menu.addAction(tr("Options")); - QAction *actionRemove = 0; - if (showRemove) - { - actionRemove = menu.addAction(tr("Delete")); - if (_referens > 1) - { - actionRemove->setEnabled(false); - } - else - { - actionRemove->setEnabled(true); - } - } - QAction *selectedAction = menu.exec(event->screenPos()); - if (selectedAction == actionOption) - { - dialog = QSharedPointer(new Dialog(getData())); - - connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), - &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject); - connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui); - if (ignoreFullUpdate == false) - { - connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList); - } - - tool->setDialog(); - - dialog->show(); - } - if (showRemove) - { - if (selectedAction == actionRemove) - { - //deincrement referens - RemoveReferens(); - //remove form xml file - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomElement element; - bool ok = doc->GetActivCalculationElement(element); - if (ok) - { - element.removeChild(domElement); - //update xml file - emit FullUpdateTree(); - //remove form scene - emit RemoveTool(tool); - } - } - } - } - } - } - template - /** - * @brief ShowItem - * @param item - * @param id - * @param color - * @param enable - */ - void ShowItem(Item *item, qint64 id, Qt::GlobalColor color, bool enable) - { - Q_ASSERT(item != 0); - if (id == item->id) - { - if (enable == false) - { - currentColor = baseColor; - } - else - { - currentColor = color; - } - item->setPen(QPen(currentColor, widthHairLine/factor)); - } - } -}; - -#endif // VDRAWTOOL_H diff --git a/src/tools/drawTools/vtoolalongline.cpp b/src/tools/drawTools/vtoolalongline.cpp deleted file mode 100644 index c8bb272c2..000000000 --- a/src/tools/drawTools/vtoolalongline.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolalongline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolalongline.h" -#include "../../container/calculator.h" - -const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); - -VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, - const qint64 &firstPointId, const qint64 &secondPointId, - const QString &typeLine, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId), - dialogAlongLine(QSharedPointer()) -{ - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolAlongLine::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - RefreshGeometry(); -} - -void VToolAlongLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogAlongLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogAlongLine->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogAlongLine->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogAlongLine->getSecondPointId())); - emit FullUpdateTree(); - } - } - dialogAlongLine.clear(); -} - -void VToolAlongLine::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogAlongLine, this, event); -} - -void VToolAlongLine::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -void VToolAlongLine::RemoveReferens() -{ - doc->DecrementReferens(secondPointId); - VToolLinePoint::RemoveReferens(); -} - -void VToolAlongLine::setDialog() -{ - Q_ASSERT(dialogAlongLine.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogAlongLine->setTypeLine(typeLine); - dialogAlongLine->setFormula(formula); - dialogAlongLine->setFirstPointId(basePointId, id); - dialogAlongLine->setSecondPointId(secondPointId, id); - dialogAlongLine->setPointName(p.name()); -} - -void VToolAlongLine::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - line.setLength(toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - data->AddLine(id, secondPointId); - } - else - { - data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - data->AddLine(id, secondPointId); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::AlongLineTool, doc); - if (parse == Document::FullParse) - { - VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, - secondPointId, typeLine, typeCreation); - scene->addItem(point); - connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } -} diff --git a/src/tools/drawTools/vtoolalongline.h b/src/tools/drawTools/vtoolalongline.h deleted file mode 100644 index 99dd29f6c..000000000 --- a/src/tools/drawTools/vtoolalongline.h +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolalongline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLALONGLINE_H -#define VTOOLALONGLINE_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialogalongline.h" - -/** - * @brief The VToolAlongLine class - */ -class VToolAlongLine : public VToolLinePoint -{ - Q_OBJECT -public: - /** - * @brief VToolAlongLine - * @param doc dom document container - * @param data - * @param id - * @param formula - * @param firstPointId - * @param secondPointId - * @param typeLine - * @param typeCreation - * @param parent - */ - VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, - const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param formula - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, const QString &formula, - const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogAlongLine - */ - QSharedPointer dialogAlongLine; -}; - -#endif // VTOOLALONGLINE_H diff --git a/src/tools/drawTools/vtoolarc.cpp b/src/tools/drawTools/vtoolarc.cpp deleted file mode 100644 index 9951bfcfb..000000000 --- a/src/tools/drawTools/vtoolarc.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolarc.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolarc.h" -#include "../../container/calculator.h" - -const QString VToolArc::TagName = QStringLiteral("arc"); -const QString VToolArc::ToolType = QStringLiteral("simple"); - -VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogArc(QSharedPointer()) -{ - VArc arc = data->GetArc(id); - QPainterPath path; - path.addPath(arc.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolArc::setDialog() -{ - Q_ASSERT(dialogArc.isNull() == false); - VArc arc = VAbstractTool::data.GetArc(id); - dialogArc->SetCenter(arc.GetCenter()); - dialogArc->SetF1(arc.GetFormulaF1()); - dialogArc->SetF2(arc.GetFormulaF2()); - dialogArc->SetRadius(arc.GetFormulaRadius()); -} - -void VToolArc::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - qint64 center = dialog->GetCenter(); - QString radius = dialog->GetRadius(); - QString f1 = dialog->GetF1(); - QString f2 = dialog->GetF2(); - Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Tool::FromGui); -} - -void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(radius, &errorMsg); - if (errorMsg.isEmpty()) - { - calcRadius = toPixel(result); - } - - errorMsg.clear(); - result = cal.eval(f1, &errorMsg); - if (errorMsg.isEmpty()) - { - calcF1 = result; - } - - errorMsg.clear(); - result = cal.eval(f2, &errorMsg); - if (errorMsg.isEmpty()) - { - calcF2 = result; - } - - VArc arc = VArc(data->DataPoints(), center, calcRadius, radius, calcF1, f1, calcF2, f2 ); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddArc(arc); - data->AddLengthArc(arc.name(), toMM(arc.GetLength())); - } - else - { - data->UpdateArc(id, arc); - data->AddLengthArc(arc.name(), toMM(arc.GetLength())); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::ArcTool, doc); - if (parse == Document::FullParse) - { - VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); - scene->addItem(toolArc); - connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - doc->AddTool(id, toolArc); - doc->IncrementReferens(center); - } -} - -void VToolArc::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VToolArc::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter())); - domElement.setAttribute(AttrRadius, dialogArc->GetRadius()); - domElement.setAttribute(AttrAngle1, dialogArc->GetF1()); - domElement.setAttribute(AttrAngle2, dialogArc->GetF2()); - emit FullUpdateTree(); - } - } - dialogArc.clear(); -} - -void VToolArc::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - this->setAcceptHoverEvents (selectable); - VDrawTool::ChangedActivDraw(newName); -} - -void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -void VToolArc::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogArc, this, event); -} - -void VToolArc::AddToFile() -{ - VArc arc = VAbstractTool::data.GetArc(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrCenter, arc.GetCenter()); - AddAttribute(domElement, AttrRadius, arc.GetFormulaRadius()); - AddAttribute(domElement, AttrAngle1, arc.GetFormulaF1()); - AddAttribute(domElement, AttrAngle2, arc.GetFormulaF2()); - - AddToCalculation(domElement); -} - -void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Arc); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); -} - -void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} - -void VToolArc::RemoveReferens() -{ - VArc arc = VAbstractTool::data.GetArc(id); - doc->DecrementReferens(arc.GetCenter()); -} - -void VToolArc::RefreshGeometry() -{ - this->setPen(QPen(currentColor, widthHairLine/factor)); - VArc arc = VAbstractTool::data.GetArc(id); - QPainterPath path; - path.addPath(arc.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); -} diff --git a/src/tools/drawTools/vtoolarc.h b/src/tools/drawTools/vtoolarc.h deleted file mode 100644 index 57b940c10..000000000 --- a/src/tools/drawTools/vtoolarc.h +++ /dev/null @@ -1,158 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolarc.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLARC_H -#define VTOOLARC_H - -#include "vdrawtool.h" -#include -#include "../../dialogs/dialogarc.h" -#include "../../widgets/vcontrolpointspline.h" - -/** - * @brief The VToolArc class - */ -class VToolArc :public VDrawTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VToolArc - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param center - * @param radius - * @param f1 - * @param f2 - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief ChangedActivDraw - * @param newName - */ - virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogArc - */ - QSharedPointer dialogArc; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry(); -}; - -#endif // VTOOLARC_H diff --git a/src/tools/drawTools/vtoolbisector.cpp b/src/tools/drawTools/vtoolbisector.cpp deleted file mode 100644 index e29886be5..000000000 --- a/src/tools/drawTools/vtoolbisector.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolbisector.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolbisector.h" -#include "../../container/calculator.h" - -const QString VToolBisector::ToolType = QStringLiteral("bisector"); - -VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qint64 &thirdPointId, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0), - thirdPointId(0), dialogBisector(QSharedPointer()) -{ - this->firstPointId = firstPointId; - this->thirdPointId = thirdPointId; - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, - const QPointF &thirdPoint, const qreal &length) -{ - QLineF line1(secondPoint, firstPoint); - QLineF line2(secondPoint, thirdPoint); - qreal angle = line1.angleTo(line2); - if (angle>180) - { - angle = 360 - angle; - line1.setAngle(line1.angle()-angle/2); - } - else - { - line1.setAngle(line1.angle()+angle/2); - } - line1.setLength(length); - return line1.p2(); -} - -void VToolBisector::setDialog() -{ - Q_ASSERT(dialogBisector.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogBisector->setTypeLine(typeLine); - dialogBisector->setFormula(formula); - dialogBisector->setFirstPointId(firstPointId, id); - dialogBisector->setSecondPointId(basePointId, id); - dialogBisector->setThirdPointId(thirdPointId, id); - dialogBisector->setPointName(p.name()); -} - -void VToolBisector::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - qint64 thirdPointId = dialog->getThirdPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolBisector::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - VPointF thirdPoint = data->GetPoint(thirdPointId); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - thirdPoint.toQPointF(), toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - } - else - { - data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::BisectorTool, doc); - if (parse == Document::FullParse) - { - VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, - thirdPointId, typeCreation); - scene->addItem(point); - connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - doc->IncrementReferens(thirdPointId); - } - } -} - -void VToolBisector::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - basePointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - thirdPointId = domElement.attribute(AttrThirdPoint, "").toLongLong(); - } - RefreshGeometry(); -} - -void VToolBisector::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogBisector->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine()); - domElement.setAttribute(AttrLength, dialogBisector->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogBisector->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogBisector->getSecondPointId())); - domElement.setAttribute(AttrThirdPoint, QString().setNum(dialogBisector->getThirdPointId())); - emit FullUpdateTree(); - } - } - dialogBisector.clear(); -} - -void VToolBisector::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogBisector, this, event); -} - -void VToolBisector::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, basePointId); - AddAttribute(domElement, AttrThirdPoint, thirdPointId); - - AddToCalculation(domElement); -} - -void VToolBisector::RemoveReferens() -{ - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(thirdPointId); - VToolLinePoint::RemoveReferens(); -} diff --git a/src/tools/drawTools/vtoolbisector.h b/src/tools/drawTools/vtoolbisector.h deleted file mode 100644 index 824e102aa..000000000 --- a/src/tools/drawTools/vtoolbisector.h +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolbisector.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLBISECTOR_H -#define VTOOLBISECTOR_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialogbisector.h" - -/** - * @brief The VToolBisector class - */ -class VToolBisector : public VToolLinePoint -{ -public: - /** - * @brief VToolBisector - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param firstPointId - * @param secondPointId - * @param thirdPointId - * @param typeCreation - * @param parent - */ - VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, - const qint64 &thirdPointId, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief FindPoint - * @param firstPoint - * @param secondPoint - * @param thirdPoint - * @param length - * @return - */ - static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, - const qreal& length); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param firstPointId - * @param secondPointId - * @param thirdPointId - * @param typeLine - * @param pointName - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief thirdPointId - */ - qint64 thirdPointId; - /** - * @brief dialogBisector - */ - QSharedPointer dialogBisector; -}; - -#endif // VTOOLBISECTOR_H diff --git a/src/tools/drawTools/vtoolendline.cpp b/src/tools/drawTools/vtoolendline.cpp deleted file mode 100644 index 0f08affbc..000000000 --- a/src/tools/drawTools/vtoolendline.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolendline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolendline.h" -#include "../../widgets/vmaingraphicsscene.h" -#include "../../container/calculator.h" - -const QString VToolEndLine::ToolType = QStringLiteral("endLine"); - -VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &basePointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent), - dialogEndLine(QSharedPointer()) -{ - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolEndLine::setDialog() -{ - Q_ASSERT(dialogEndLine.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogEndLine->setTypeLine(typeLine); - dialogEndLine->setFormula(formula); - dialogEndLine->setAngle(angle); - dialogEndLine->setBasePointId(basePointId, id); - dialogEndLine->setPointName(p.name()); -} - -void VToolEndLine::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - QString pointName = dialog->getPointName(); - QString typeLine = dialog->getTypeLine(); - QString formula = dialog->getFormula(); - qreal angle = dialog->getAngle(); - qint64 basePointId = dialog->getBasePointId(); - Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse, - Tool::FromGui); -} - -void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &basePointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF basePoint = data->GetPoint(basePointId); - QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y())); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - line.setLength(toPixel(result)); - line.setAngle(angle); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - data->AddLine(basePointId, id); - } - else - { - data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - data->AddLine(basePointId, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::EndLineTool, doc); - if (parse == Document::FullParse) - { - VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, - basePointId, typeCreation); - scene->addItem(point); - connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - } - } -} - -void VToolEndLine::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); - angle = domElement.attribute(AttrAngle, "").toInt(); - } - RefreshGeometry(); -} - -void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogEndLine, this, event); -} - -void VToolEndLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogEndLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogEndLine->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogEndLine->getAngle())); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogEndLine->getBasePointId())); - emit FullUpdateTree(); - } - } - dialogEndLine.clear(); -} - -void VToolEndLine::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrBasePoint, basePointId); - - AddToCalculation(domElement); -} diff --git a/src/tools/drawTools/vtoolendline.h b/src/tools/drawTools/vtoolendline.h deleted file mode 100644 index 35c802911..000000000 --- a/src/tools/drawTools/vtoolendline.h +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolendline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLENDLINE_H -#define VTOOLENDLINE_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialogendline.h" - -/** - * @brief The VToolEndLine class - */ -class VToolEndLine : public VToolLinePoint -{ - Q_OBJECT -public: - /** - * @brief VToolEndLine - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param angle - * @param basePointId - * @param typeCreation - * @param parent - */ - VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &basePointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param formula - * @param angle - * @param basePointId - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &basePointId, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - /** - * @brief dialogEndLine - */ - QSharedPointer dialogEndLine; -}; - -#endif // VTOOLENDLINE_H diff --git a/src/tools/drawTools/vtoolheight.cpp b/src/tools/drawTools/vtoolheight.cpp deleted file mode 100644 index 528f1515c..000000000 --- a/src/tools/drawTools/vtoolheight.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolheight.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolheight.h" - -const QString VToolHeight::ToolType = QStringLiteral("height"); - -VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const Tool::Sources &typeCreation, QGraphicsItem * parent) - :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), - dialogHeight(QSharedPointer()), p1LineId(p1LineId), p2LineId(p2LineId) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolHeight::setDialog() -{ - Q_ASSERT(dialogHeight.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogHeight->setTypeLine(typeLine); - dialogHeight->setBasePointId(basePointId, id); - dialogHeight->setP1LineId(p1LineId, id); - dialogHeight->setP2LineId(p2LineId, id); - dialogHeight->setPointName(p.name()); -} - -void VToolHeight::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList); - QString pointName = dialog->getPointName(); - QString typeLine = dialog->getTypeLine(); - qint64 basePointId = dialog->getBasePointId(); - qint64 p1LineId = dialog->getP1LineId(); - qint64 p2LineId = dialog->getP2LineId(); - Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF basePoint = data->GetPoint(basePointId); - VPointF p1Line = data->GetPoint(p1LineId); - VPointF p2Line = data->GetPoint(p2LineId); - - QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); - data->AddLine(basePointId, id); - data->AddLine(p1LineId, id); - data->AddLine(p2LineId, id); - } - else - { - data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); - data->AddLine(basePointId, id); - data->AddLine(p1LineId, id); - data->AddLine(p2LineId, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::Height, doc); - if (parse == Document::FullParse) - { - VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, - typeCreation); - scene->addItem(point); - connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - doc->IncrementReferens(p1LineId); - doc->IncrementReferens(p2LineId); - } -} - -QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point) -{ - qreal a = 0, b = 0, c = 0; - LineCoefficients(line, &a, &b, &c); - qreal x = point.x() + a; - qreal y = b + point.y(); - QLineF lin (point, QPointF(x, y)); - QPointF p; - QLineF::IntersectType intersect = line.intersect(lin, &p); - if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) - { - return p; - } - else - { - return QPointF(); - } -} - -void VToolHeight::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); - p1LineId = domElement.attribute(AttrP1Line, "").toLongLong(); - p2LineId = domElement.attribute(AttrP2Line, "").toLongLong(); - } - RefreshGeometry(); - -} - -void VToolHeight::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogHeight->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine()); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId())); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogHeight->getP1LineId())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogHeight->getP2LineId())); - emit FullUpdateTree(); - } - } - dialogHeight.clear(); -} - -void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogHeight, this, event); -} - -void VToolHeight::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrBasePoint, basePointId); - AddAttribute(domElement, AttrP1Line, p1LineId); - AddAttribute(domElement, AttrP2Line, p2LineId); - - AddToCalculation(domElement); - -} diff --git a/src/tools/drawTools/vtoolheight.h b/src/tools/drawTools/vtoolheight.h deleted file mode 100644 index 3aa016801..000000000 --- a/src/tools/drawTools/vtoolheight.h +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolheight.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLHEIGHT_H -#define VTOOLHEIGHT_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialogheight.h" - -/** - * @brief The VToolHeight class - */ -class VToolHeight: public VToolLinePoint -{ - Q_OBJECT -public: - /** - * @brief VToolHeight - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param basePointId - * @param p1LineId - * @param p2LineId - * @param typeCreation - * @param parent - */ - VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param basePointId - * @param p1LineId - * @param p2LineId - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief FindPoint - * @param line - * @param point - * @return - */ - static QPointF FindPoint(const QLineF &line, const QPointF &point); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - /** - * @brief dialogHeight - */ - QSharedPointer dialogHeight; - /** - * @brief p1LineId - */ - qint64 p1LineId; - /** - * @brief p2LineId - */ - qint64 p2LineId; -}; - -#endif // VTOOLHEIGHT_H diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp deleted file mode 100644 index 5b6e0f3bf..000000000 --- a/src/tools/drawTools/vtoolline.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolline.h" - -const QString VToolLine::TagName = QStringLiteral("line"); - -VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), - dialogLine(QSharedPointer()) -{ - ignoreFullUpdate = true; - //Лінія - VPointF first = data->GetPoint(firstPoint); - VPointF second = data->GetPoint(secondPoint); - this->setLine(QLineF(first.toQPointF(), second.toQPointF())); - this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - this->setPen(QPen(Qt::black, widthHairLine/factor)); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolLine::setDialog() -{ - dialogLine->setFirstPoint(firstPoint); - dialogLine->setSecondPoint(secondPoint); -} - -void VToolLine::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - qint64 firstPoint = dialog->getFirstPoint(); - qint64 secondPoint = dialog->getSecondPoint(); - Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui); -} - -void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - Q_ASSERT(scene != 0); - Q_ASSERT(doc != 0); - Q_ASSERT(data != 0); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->getNextId(); - data->AddLine(firstPoint, secondPoint); - } - else - { - data->UpdateId(id); - data->AddLine(firstPoint, secondPoint); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::LineTool, doc); - if (parse == Document::FullParse) - { - VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); - Q_ASSERT(line != 0); - scene->addItem(line); - connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); - doc->AddTool(id, line); - doc->IncrementReferens(firstPoint); - doc->IncrementReferens(secondPoint); - } -} - -void VToolLine::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VToolLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint())); - emit FullUpdateTree(); - } - } - dialogLine.clear(); -} - -void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -void VToolLine::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolLine::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, widthHairLine/factor)); - this->setAcceptHoverEvents (selectable); - VDrawTool::ChangedActivDraw(newName); -} - -void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogLine, this, event); -} - -void VToolLine::AddToFile() -{ - QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrFirstPoint, firstPoint); - AddAttribute(domElement, AttrSecondPoint, secondPoint); - - AddToCalculation(domElement); -} - -void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); -} - -void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} - -void VToolLine::RemoveReferens() -{ - doc->DecrementReferens(firstPoint); - doc->DecrementReferens(secondPoint); -} - -void VToolLine::RefreshGeometry() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VPointF first = VAbstractTool::data.GetPoint(firstPoint); - VPointF second = VAbstractTool::data.GetPoint(secondPoint); - this->setLine(QLineF(first.toQPointF(), second.toQPointF())); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} diff --git a/src/tools/drawTools/vtoolline.h b/src/tools/drawTools/vtoolline.h deleted file mode 100644 index 80df5efcf..000000000 --- a/src/tools/drawTools/vtoolline.h +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLLINE_H -#define VTOOLLINE_H - -#include "vdrawtool.h" -#include -#include "../../dialogs/dialogline.h" - -/** - * @brief The VToolLine class - */ -class VToolLine: public VDrawTool, public QGraphicsLineItem -{ - Q_OBJECT -public: - /** - * @brief VToolLine - * @param doc dom document container - * @param data - * @param id - * @param firstPoint - * @param secondPoint - * @param typeCreation - * @param parent - */ - VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, - qint64 secondPoint, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param firstPoint - * @param secondPoint - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief ChangedActivDraw - * @param newName - */ - virtual void ChangedActivDraw(const QString &newName); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief firstPoint - */ - qint64 firstPoint; - /** - * @brief secondPoint - */ - qint64 secondPoint; - /** - * @brief dialogLine - */ - QSharedPointer dialogLine; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry(); -}; - -#endif // VTOOLLINE_H diff --git a/src/tools/drawTools/vtoollineintersect.cpp b/src/tools/drawTools/vtoollineintersect.cpp deleted file mode 100644 index 1663b4c71..000000000 --- a/src/tools/drawTools/vtoollineintersect.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/************************************************************************ - ** - ** @file vtoollineintersect.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoollineintersect.h" - -const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); - -VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, - const qint64 &p2Line2, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), - p2Line2(p2Line2), dialogLineIntersect(QSharedPointer()) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolLineIntersect::setDialog() -{ - Q_ASSERT(dialogLineIntersect.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogLineIntersect->setP1Line1(p1Line1); - dialogLineIntersect->setP2Line1(p2Line1); - dialogLineIntersect->setP1Line2(p1Line2); - dialogLineIntersect->setP2Line2(p2Line2); - dialogLineIntersect->setPointName(p.name()); -} - -void VToolLineIntersect::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - qint64 p1Line1Id = dialog->getP1Line1(); - qint64 p2Line1Id = dialog->getP2Line1(); - qint64 p1Line2Id = dialog->getP1Line2(); - qint64 p2Line2Id = dialog->getP2Line2(); - QString pointName = dialog->getPointName(); - Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, - const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VPointF p1Line1 = data->GetPoint(p1Line1Id); - VPointF p2Line1 = data->GetPoint(p2Line1Id); - VPointF p1Line2 = data->GetPoint(p1Line2Id); - VPointF p2Line2 = data->GetPoint(p2Line2Id); - - QLineF line1(p1Line1.toQPointF(), p2Line1.toQPointF()); - QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF()); - QPointF fPoint; - QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); - if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) - { - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(p1Line1Id, id); - data->AddLine(id, p2Line1Id); - data->AddLine(p1Line2Id, id); - data->AddLine(id, p2Line2Id); - } - else - { - data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(p1Line1Id, id); - data->AddLine(id, p2Line1Id); - data->AddLine(p1Line2Id, id); - data->AddLine(id, p2Line2Id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::LineIntersectTool, doc); - if (parse == Document::FullParse) - { - VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, - p2Line2Id, typeCreation); - scene->addItem(point); - connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(p1Line1Id); - doc->IncrementReferens(p2Line1Id); - doc->IncrementReferens(p1Line2Id); - doc->IncrementReferens(p2Line2Id); - } - } -} - -void VToolLineIntersect::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - p1Line1 = domElement.attribute(AttrP1Line1, "").toLongLong(); - p2Line1 = domElement.attribute(AttrP2Line1, "").toLongLong(); - p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong(); - p2Line2 = domElement.attribute(AttrP2Line2, "").toLongLong(); - } - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolLineIntersect::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogLineIntersect->getPointName()); - domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1())); - domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1())); - domElement.setAttribute(AttrP1Line2, QString().setNum(dialogLineIntersect->getP1Line2())); - domElement.setAttribute(AttrP2Line2, QString().setNum(dialogLineIntersect->getP2Line2())); - emit FullUpdateTree(); - } - } - dialogLineIntersect.clear(); -} - -void VToolLineIntersect::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogLineIntersect, this, event); -} - -void VToolLineIntersect::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrP1Line1, p1Line1); - AddAttribute(domElement, AttrP2Line1, p2Line1); - AddAttribute(domElement, AttrP1Line2, p1Line2); - AddAttribute(domElement, AttrP2Line2, p2Line2); - - AddToCalculation(domElement); -} - -void VToolLineIntersect::RemoveReferens() -{ - doc->DecrementReferens(p1Line1); - doc->DecrementReferens(p2Line1); - doc->DecrementReferens(p1Line2); - doc->DecrementReferens(p2Line2); -} diff --git a/src/tools/drawTools/vtoollineintersect.h b/src/tools/drawTools/vtoollineintersect.h deleted file mode 100644 index 1812d638f..000000000 --- a/src/tools/drawTools/vtoollineintersect.h +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************************ - ** - ** @file vtoollineintersect.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLLINEINTERSECT_H -#define VTOOLLINEINTERSECT_H - -#include "vtoolpoint.h" -#include "../../dialogs/dialoglineintersect.h" - -/** - * @brief The VToolLineIntersect class - */ -class VToolLineIntersect:public VToolPoint -{ - Q_OBJECT -public: - /** - * @brief VToolLineIntersect - * @param doc dom document container - * @param data - * @param id - * @param p1Line1 - * @param p2Line1 - * @param p1Line2 - * @param p2Line2 - * @param typeCreation - * @param parent - */ - VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1, - const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p2Line2, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param p1Line1Id - * @param p2Line1Id - * @param p1Line2Id - * @param p2Line2Id - * @param pointName - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, const qint64 &p1Line2Id, - const qint64 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief p1Line1 - */ - qint64 p1Line1; - /** - * @brief p2Line1 - */ - qint64 p2Line1; - /** - * @brief p1Line2 - */ - qint64 p1Line2; - /** - * @brief p2Line2 - */ - qint64 p2Line2; - /** - * @brief dialogLineIntersect - */ - QSharedPointer dialogLineIntersect; -}; - -#endif // VTOOLLINEINTERSECT_H diff --git a/src/tools/drawTools/vtoollinepoint.cpp b/src/tools/drawTools/vtoollinepoint.cpp deleted file mode 100644 index e0042b60d..000000000 --- a/src/tools/drawTools/vtoollinepoint.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************ - ** - ** @file vtoollinepoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoollinepoint.h" - -VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &basePointId, - const qreal &angle, QGraphicsItem *parent) - :VToolPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId), - mainLine(0) -{ - Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); - //Лінія, що з'єднує дві точки - QPointF point1 = data->GetPoint(basePointId).toQPointF(); - QPointF point2 = data->GetPoint(id).toQPointF(); - mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); - mainLine->setPen(QPen(Qt::black, widthHairLine/factor)); - mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - if (typeLine == TypeLineNone) - { - mainLine->setVisible(false); - } - else - { - mainLine->setVisible(true); - } -} - -void VToolLinePoint::ChangedActivDraw(const QString &newName) -{ - if (nameActivDraw == newName) - { - currentColor = Qt::black; - } - else - { - currentColor = Qt::gray; - } - mainLine->setPen(QPen(currentColor, widthHairLine/factor)); - VToolPoint::ChangedActivDraw(newName); -} - -void VToolLinePoint::RefreshGeometry() -{ - mainLine->setPen(QPen(currentColor, widthHairLine/factor)); - VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); - QPointF point = VDrawTool::data.GetPoint(id).toQPointF(); - QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF(); - mainLine->setLine(QLineF(basePoint - point, QPointF())); - if (typeLine == TypeLineNone) - { - mainLine->setVisible(false); - } - else - { - mainLine->setVisible(true); - } -} - -void VToolLinePoint::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} diff --git a/src/tools/drawTools/vtoolnormal.cpp b/src/tools/drawTools/vtoolnormal.cpp deleted file mode 100644 index 0acb05cdf..000000000 --- a/src/tools/drawTools/vtoolnormal.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolnormal.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolnormal.h" -#include "../../container/calculator.h" - -const QString VToolNormal::ToolType = QStringLiteral("normal"); - -VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &firstPointId, - const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), - secondPointId(secondPointId), dialogNormal(QSharedPointer()) -{ - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } - -} - -void VToolNormal::setDialog() -{ - Q_ASSERT(dialogNormal.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogNormal->setTypeLine(typeLine); - dialogNormal->setFormula(formula); - dialogNormal->setAngle(angle); - dialogNormal->setFirstPointId(basePointId, id); - dialogNormal->setSecondPointId(secondPointId, id); - dialogNormal->setPointName(p.name()); -} - -void VToolNormal::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - qreal angle = dialog->getAngle(); - Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - toPixel(result), angle); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - } - else - { - data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::NormalTool, doc); - if (parse == Document::FullParse) - { - VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, - firstPointId, secondPointId, typeCreation); - scene->addItem(point); - connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } -} - -QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, - const qreal &angle) -{ - QLineF line(firstPoint, secondPoint); - QLineF normal = line.normalVector(); - normal.setAngle(normal.angle()+angle); - normal.setLength(length); - return normal.p2(); -} - -void VToolNormal::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - angle = domElement.attribute(AttrAngle, "").toDouble(); - } - RefreshGeometry(); -} - -void VToolNormal::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogNormal->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine()); - domElement.setAttribute(AttrLength, dialogNormal->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogNormal->getAngle())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogNormal->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogNormal->getSecondPointId())); - emit FullUpdateTree(); - } - } - dialogNormal.clear(); -} - -void VToolNormal::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogNormal, this, event); -} - -void VToolNormal::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -void VToolNormal::RemoveReferens() -{ - doc->DecrementReferens(secondPointId); - VToolLinePoint::RemoveReferens(); -} diff --git a/src/tools/drawTools/vtoolnormal.h b/src/tools/drawTools/vtoolnormal.h deleted file mode 100644 index 830eeff5a..000000000 --- a/src/tools/drawTools/vtoolnormal.h +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolnormal.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLNORMAL_H -#define VTOOLNORMAL_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialognormal.h" - -/** - * @brief The VToolNormal class - */ -class VToolNormal : public VToolLinePoint -{ - Q_OBJECT -public: - /** - * @brief VToolNormal - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param angle - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &firstPointId, - const qint64 &secondPointId, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param firstPointId - * @param secondPointId - * @param typeLine - * @param pointName - * @param angle - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief FindPoint - * @param firstPoint - * @param secondPoint - * @param length - * @param angle - * @return - */ - static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, - const qreal &angle = 0); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogNormal - */ - QSharedPointer dialogNormal; -}; - -#endif // VTOOLNORMAL_H diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp deleted file mode 100644 index 3deec4002..000000000 --- a/src/tools/drawTools/vtoolpoint.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolpoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolpoint.h" - -const QString VToolPoint::TagName = QStringLiteral("point"); - -VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem *parent):VDrawTool(doc, data, id), - QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0) -{ - namePoint = new VGraphicsSimpleTextItem(this); - lineName = new QGraphicsLineItem(this); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VToolPoint::NameChangePosition); - this->setBrush(QBrush(Qt::NoBrush)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolPoint::NameChangePosition(const QPointF &pos) -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QPointF p = pos - this->pos(); - point.setMx(p.x()); - point.setMy(p.y()); - RefreshLine(); - UpdateNamePosition(point.mx(), point.my()); - VAbstractTool::data.UpdatePoint(id, point); -} - -void VToolPoint::UpdateNamePosition(qreal mx, qreal my) -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrMx, QString().setNum(toMM(mx))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(my))); - emit toolhaveChange(); - } -} - -void VToolPoint::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - this->setAcceptHoverEvents (selectable); - namePoint->setFlag(QGraphicsItem::ItemIsMovable, selectable); - namePoint->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, selectable); - namePoint->setBrush(QBrush(currentColor)); - namePoint->setAcceptHoverEvents(selectable); - lineName->setPen(QPen(currentColor, widthHairLine/factor)); - VDrawTool::ChangedActivDraw(newName); -} - -void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -void VToolPoint::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Point); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); -} - -void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} - -void VToolPoint::RefreshPointGeometry(const VPointF &point) -{ - this->setPen(QPen(currentColor, widthHairLine/factor)); - QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor); - rec.translate(-rec.center().x(), -rec.center().y()); - this->setRect(rec); - this->setPos(point.toQPointF()); - disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VToolPoint::NameChangePosition); - QFont font = namePoint->font(); - font.setPointSize(static_cast(namePoint->FontSize()/factor)); - namePoint->setFont(font); - namePoint->setText(point.name()); - namePoint->setPos(QPointF(point.mx(), point.my())); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VToolPoint::NameChangePosition); - RefreshLine(); -} - -void VToolPoint::RefreshLine() -{ - QRectF nameRec = namePoint->sceneBoundingRect(); - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); - QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); - lineName->setLine(QLineF(p1, pRec - scenePos())); - lineName->setPen(QPen(currentColor, widthHairLine/factor)); - if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4)) - { - lineName->setVisible(false); - } - else - { - lineName->setVisible(true); - } -} diff --git a/src/tools/drawTools/vtoolpointofcontact.cpp b/src/tools/drawTools/vtoolpointofcontact.cpp deleted file mode 100644 index 9d94bc7e9..000000000 --- a/src/tools/drawTools/vtoolpointofcontact.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolpointofcontact.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolpointofcontact.h" -#include "../../container/calculator.h" - -const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); - -VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - : VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId), - secondPointId(secondPointId), dialogPointOfContact(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolPointOfContact::setDialog() -{ - Q_ASSERT(dialogPointOfContact.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogPointOfContact->setRadius(radius); - dialogPointOfContact->setCenter(center, id); - dialogPointOfContact->setFirstPoint(firstPointId, id); - dialogPointOfContact->setSecondPoint(secondPointId, id); - dialogPointOfContact->setPointName(p.name()); -} - -QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, - const QPointF &secondPoint) -{ - QPointF pArc; - qreal s = 0.0, s_x, s_y, step = 0.01, distans; - while ( s < 1) - { - s_x = secondPoint.x()-(qAbs(secondPoint.x()-firstPoint.x()))*s; - s_y = secondPoint.y()-(qAbs(secondPoint.y()-firstPoint.y()))*s; - distans = QLineF(center.x(), center.y(), s_x, s_y).length(); - if (fabs(distans*10 - radius*10) < 0.1) - { - pArc.rx() = s_x; - pArc.ry() = s_y; - break; - } - if (distans &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - QString radius = dialog->getRadius(); - qint64 center = dialog->getCenter(); - qint64 firstPointId = dialog->getFirstPoint(); - qint64 secondPointId = dialog->getSecondPoint(); - QString pointName = dialog->getPointName(); - Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF centerP = data->GetPoint(center); - VPointF firstP = data->GetPoint(firstPointId); - VPointF secondP = data->GetPoint(secondPointId); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(radius, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(), - firstP.toQPointF(), secondP.toQPointF()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - data->AddLine(secondPointId, id); - data->AddLine(center, id); - } - else - { - data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(firstPointId, id); - data->AddLine(secondPointId, id); - data->AddLine(center, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::PointOfContact, doc); - if (parse == Document::FullParse) - { - VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, - firstPointId, secondPointId, typeCreation); - scene->addItem(point); - connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(center); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } -} - -void VToolPointOfContact::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - radius = domElement.attribute(AttrRadius, ""); - center = domElement.attribute(AttrCenter, "").toLongLong(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolPointOfContact::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogPointOfContact->getPointName()); - domElement.setAttribute(AttrRadius, dialogPointOfContact->getRadius()); - domElement.setAttribute(AttrCenter, QString().setNum(dialogPointOfContact->getCenter())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfContact->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfContact->getSecondPoint())); - emit FullUpdateTree(); - } - } - dialogPointOfContact.clear(); -} - -void VToolPointOfContact::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogPointOfContact, this, event); -} - -void VToolPointOfContact::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrRadius, radius); - AddAttribute(domElement, AttrCenter, center); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -void VToolPointOfContact::RemoveReferens() -{ - doc->DecrementReferens(center); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} diff --git a/src/tools/drawTools/vtoolpointofcontact.h b/src/tools/drawTools/vtoolpointofcontact.h deleted file mode 100644 index d53113fa2..000000000 --- a/src/tools/drawTools/vtoolpointofcontact.h +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolpointofcontact.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLPOINTOFCONTACT_H -#define VTOOLPOINTOFCONTACT_H - -#include "vtoolpoint.h" -#include "../../dialogs/dialogpointofcontact.h" - -/** - * @brief The VToolPointOfContact class - */ -class VToolPointOfContact : public VToolPoint -{ -public: - /** - * @brief VToolPointOfContact - * @param doc dom document container - * @param data - * @param id - * @param radius - * @param center - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief FindPoint - * @param radius - * @param center - * @param firstPoint - * @param secondPoint - * @return - */ - static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, - const QPointF &secondPoint); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param radius - * @param center - * @param firstPointId - * @param secondPointId - * @param pointName - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief radius - */ - QString radius; - /** - * @brief center - */ - qint64 center; - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogPointOfContact - */ - QSharedPointer dialogPointOfContact; -}; - -#endif // VTOOLPOINTOFCONTACT_H diff --git a/src/tools/drawTools/vtoolpointofintersection.cpp b/src/tools/drawTools/vtoolpointofintersection.cpp deleted file mode 100644 index dc0d4d7e8..000000000 --- a/src/tools/drawTools/vtoolpointofintersection.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolpointofintersection.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolpointofintersection.h" - -const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); - -VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId), - dialogPointOfIntersection(QSharedPointer()) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolPointOfIntersection::setDialog() -{ - Q_ASSERT(dialogPointOfIntersection.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogPointOfIntersection->setFirstPointId(firstPointId, id); - dialogPointOfIntersection->setSecondPointId(secondPointId, id); - dialogPointOfIntersection->setPointName(p.name()); -} - -void VToolPointOfIntersection::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString pointName = dialog->getPointName(); - Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui); -} - -void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, - const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - - QPointF point(firstPoint.x(), secondPoint.y()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); - } - else - { - data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::Triangle, doc); - if (parse == Document::FullParse) - { - VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, - secondPointId, typeCreation); - scene->addItem(point); - connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolPointOfIntersection::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } -} - -void VToolPointOfIntersection::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); -} - -void VToolPointOfIntersection::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogPointOfIntersection->getPointName()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfIntersection->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfIntersection->getSecondPointId())); - emit FullUpdateTree(); - } - } - dialogPointOfIntersection.clear(); -} - -void VToolPointOfIntersection::RemoveReferens() -{ - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} - -void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogPointOfIntersection, this, event); -} - -void VToolPointOfIntersection::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} diff --git a/src/tools/drawTools/vtoolpointofintersection.h b/src/tools/drawTools/vtoolpointofintersection.h deleted file mode 100644 index 2aa964adc..000000000 --- a/src/tools/drawTools/vtoolpointofintersection.h +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolpointofintersection.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLPOINTOFINTERSECTION_H -#define VTOOLPOINTOFINTERSECTION_H - -#include "vtoolpoint.h" -#include "../../dialogs/dialogpointofintersection.h" - -/** - * @brief The VToolPointOfIntersection class - */ -class VToolPointOfIntersection : public VToolPoint -{ - Q_OBJECT -public: - /** - * @brief VToolPointOfIntersection - * @param doc dom document container - * @param data - * @param id - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, - const qint64 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - Q_DISABLE_COPY(VToolPointOfIntersection) - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogPointOfIntersection - */ - QSharedPointer dialogPointOfIntersection; -}; - -#endif // VTOOLPOINTOFINTERSECTION_H diff --git a/src/tools/drawTools/vtoolshoulderpoint.cpp b/src/tools/drawTools/vtoolshoulderpoint.cpp deleted file mode 100644 index 115cc7b47..000000000 --- a/src/tools/drawTools/vtoolshoulderpoint.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolshoulderpoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolshoulderpoint.h" -#include "../../container/calculator.h" - -const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); - -VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &p1Line, - const qint64 &p2Line, const qint64 &pShoulder, const Tool::Sources &typeCreation, - QGraphicsItem * parent) - :VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder), - dialogShoulderPoint(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolShoulderPoint::setDialog() -{ - Q_ASSERT(dialogShoulderPoint.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogShoulderPoint->setTypeLine(typeLine); - dialogShoulderPoint->setFormula(formula); - dialogShoulderPoint->setP1Line(basePointId, id); - dialogShoulderPoint->setP2Line(p2Line, id); - dialogShoulderPoint->setPShoulder(pShoulder, id); - dialogShoulderPoint->setPointName(p.name()); -} - -QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, - const qreal &length) -{ - QLineF line = QLineF(p1Line, p2Line); - qreal dist = line.length(); - if (dist>length) - { - qDebug()<<"A3П2="<=length) - { - return line.p2(); - } - } -} - -void VToolShoulderPoint::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 p1Line = dialog->getP1Line(); - qint64 p2Line = dialog->getP2Line(); - qint64 pShoulder = dialog->getPShoulder(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const qint64 &p1Line, - const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF firstPoint = data->GetPoint(p1Line); - VPointF secondPoint = data->GetPoint(p2Line); - VPointF shoulderPoint = data->GetPoint(pShoulder); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - shoulderPoint.toQPointF(), toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(p1Line, id); - data->AddLine(p2Line, id); - } - else - { - data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - data->AddLine(p1Line, id); - data->AddLine(p2Line, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::ShoulderPointTool, doc); - if (parse == Document::FullParse) - { - VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, - p1Line, p2Line, pShoulder, - typeCreation); - scene->addItem(point); - connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(p1Line); - doc->IncrementReferens(p2Line); - doc->IncrementReferens(pShoulder); - } - } -} - -void VToolShoulderPoint::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrP1Line, "").toLongLong(); - p2Line = domElement.attribute(AttrP2Line, "").toLongLong(); - pShoulder = domElement.attribute(AttrPShoulder, "").toLongLong(); - } - RefreshGeometry(); -} - -void VToolShoulderPoint::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogShoulderPoint->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogShoulderPoint->getTypeLine()); - domElement.setAttribute(AttrLength, dialogShoulderPoint->getFormula()); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogShoulderPoint->getP1Line())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogShoulderPoint->getP2Line())); - domElement.setAttribute(AttrPShoulder, QString().setNum(dialogShoulderPoint->getPShoulder())); - emit FullUpdateTree(); - } - } - dialogShoulderPoint.clear(); -} - -void VToolShoulderPoint::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogShoulderPoint, this, event); -} - -void VToolShoulderPoint::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrP1Line, basePointId); - AddAttribute(domElement, AttrP2Line, p2Line); - AddAttribute(domElement, AttrPShoulder, pShoulder); - - AddToCalculation(domElement); -} - -void VToolShoulderPoint::RemoveReferens() -{ - doc->DecrementReferens(p2Line); - doc->DecrementReferens(pShoulder); - VToolLinePoint::RemoveReferens(); -} diff --git a/src/tools/drawTools/vtoolshoulderpoint.h b/src/tools/drawTools/vtoolshoulderpoint.h deleted file mode 100644 index a6f9faf1a..000000000 --- a/src/tools/drawTools/vtoolshoulderpoint.h +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolshoulderpoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLSHOULDERPOINT_H -#define VTOOLSHOULDERPOINT_H - -#include "vtoollinepoint.h" -#include "../../dialogs/dialogshoulderpoint.h" - -/** - * @brief The VToolShoulderPoint class - */ -class VToolShoulderPoint : public VToolLinePoint -{ -public: - /** - * @brief VToolShoulderPoint - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param p1Line - * @param p2Line - * @param pShoulder - * @param typeCreation - * @param parent - */ - VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qint64 &p1Line, const qint64 &p2Line, - const qint64 &pShoulder, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief FindPoint - * @param p1Line - * @param p2Line - * @param pShoulder - * @param length - * @return - */ - static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, - const qreal &length); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param p1Line - * @param p2Line - * @param pShoulder - * @param typeLine - * @param pointName - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, - const qint64 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief p2Line - */ - qint64 p2Line; - /** - * @brief pShoulder - */ - qint64 pShoulder; - /** - * @brief dialogShoulderPoint - */ - QSharedPointer dialogShoulderPoint; -}; - -#endif // VTOOLSHOULDERPOINT_H diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp deleted file mode 100644 index 0308f2963..000000000 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolsinglepoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolsinglepoint.h" - -const QString VToolSinglePoint::ToolType = QStringLiteral("single"); - -VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent ) - :VToolPoint(doc, data, id, parent), dialogSinglePoint(QSharedPointer()) -{ - ignoreFullUpdate = true; - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolSinglePoint::setDialog() -{ - Q_ASSERT(dialogSinglePoint.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogSinglePoint->setData(p.name(), p.toQPointF()); -} - -void VToolSinglePoint::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrX, toMM(point.x())); - AddAttribute(domElement, AttrY, toMM(point.y())); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddToCalculation(domElement); -} - -QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionChange && scene()) - { - // value - это новое положение. - QPointF newPos = value.toPointF(); - QRectF rect = scene()->sceneRect(); - if (rect.contains(newPos) == false) - { - // Сохраняем элемент внутри прямоугольника сцены. - newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left()))); - newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top()))); - return newPos; - } - } - if (change == ItemPositionHasChanged && scene()) - { - // value - это новое положение. - QPointF newPos = value.toPointF(); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrX, QString().setNum(toMM(newPos.x()))); - domElement.setAttribute(AttrY, QString().setNum(toMM(newPos.y()))); - //I don't now why but signal does not work. - doc->FullUpdateTree(); - } - } - return QGraphicsItem::itemChange(change, value); -} - -void VToolSinglePoint::decrementReferens() -{ - if (_referens > 1) - { - --_referens; - } -} - -void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) -{ - ContextMenu(dialogSinglePoint, this, event, false); -} - -void VToolSinglePoint::FullUpdateFromFile() -{ - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} - -void VToolSinglePoint::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QPointF p = dialogSinglePoint->getPoint(); - QString name = dialogSinglePoint->getName(); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, name); - domElement.setAttribute(AttrX, QString().setNum(toMM(p.x()))); - domElement.setAttribute(AttrY, QString().setNum(toMM(p.y()))); - //I don't now why but signal does not work. - doc->FullUpdateTree(); - } - } - dialogSinglePoint.clear(); -} - -void VToolSinglePoint::ChangedActivDraw(const QString &newName) -{ - if (nameActivDraw == newName) - { - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - VToolPoint::ChangedActivDraw(newName); - } - else - { - this->setFlag(QGraphicsItem::ItemIsSelectable, false); - VToolPoint::ChangedActivDraw(newName); - } -} - -void VToolSinglePoint::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshPointGeometry(VAbstractTool::data.GetPoint(id)); -} diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp deleted file mode 100644 index b1ab4c6dd..000000000 --- a/src/tools/drawTools/vtoolspline.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolspline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolspline.h" -#include "../../geometry/vspline.h" - -const QString VToolSpline::TagName = QStringLiteral("spline"); -const QString VToolSpline::ToolType = QStringLiteral("simple"); - -VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogSpline(QSharedPointer()), - controlPoints(QVector()) -{ - ignoreFullUpdate = true; - - VSpline spl = data->GetSpline(id); - QPainterPath path; - path.addPath(spl.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl.GetP2(), - spl.GetPointP1().toQPointF(), this); - connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine); - connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint1); - - VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl.GetP3(), - spl.GetPointP4().toQPointF(), this); - connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine); - connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint2); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolSpline::setDialog() -{ - Q_ASSERT(dialogSpline.isNull() == false); - VSpline spl = VAbstractTool::data.GetSpline(id); - dialogSpline->setP1(spl.GetP1()); - dialogSpline->setP4(spl.GetP4()); - dialogSpline->setAngle1(spl.GetAngle1()); - dialogSpline->setAngle2(spl.GetAngle2()); - dialogSpline->setKAsm1(spl.GetKasm1()); - dialogSpline->setKAsm2(spl.GetKasm2()); - dialogSpline->setKCurve(spl.GetKcurve()); -} - -void VToolSpline::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - qint64 p1 = dialog->getP1(); - qint64 p4 = dialog->getP4(); - qreal kAsm1 = dialog->getKAsm1(); - qreal kAsm2 = dialog->getKAsm2(); - qreal angle1 = dialog->getAngle1(); - qreal angle2 = dialog->getAngle2(); - qreal kCurve = dialog->getKCurve(); - Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, - Tool::FromGui); -} - -void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, - const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddSpline(spline); - data->AddLengthSpline(spline.name(), toMM(spline.GetLength())); - } - else - { - data->UpdateSpline(id, spline); - data->AddLengthSpline(spline.name(), toMM(spline.GetLength())); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::SplineTool, doc); - if (parse == Document::FullParse) - { - VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); - scene->addItem(spl); - connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor); - doc->AddTool(id, spl); - doc->IncrementReferens(p1); - doc->IncrementReferens(p4); - } -} - -void VToolSpline::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VToolSpline::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - VSpline spl = VSpline (VAbstractTool::data.DataPoints(), dialogSpline->getP1(), - dialogSpline->getP4(), dialogSpline->getAngle1(), dialogSpline->getAngle2(), - dialogSpline->getKAsm1(), dialogSpline->getKAsm2(), dialogSpline->getKCurve()); - - disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - controlPoints[0]->setPos(spl.GetP2()); - controlPoints[1]->setPos(spl.GetP3()); - connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - - spl = VSpline (VAbstractTool::data.DataPoints(), dialogSpline->getP1(), controlPoints[0]->pos(), - controlPoints[1]->pos(), dialogSpline->getP4(), dialogSpline->getKCurve()); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1())); - domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4())); - domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1())); - domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2())); - domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2())); - domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve())); - emit FullUpdateTree(); - } - } - dialogSpline.clear(); -} - -void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos) -{ - Q_UNUSED(indexSpline); - VSpline spl = VAbstractTool::data.GetSpline(id); - if (position == SplinePoint::FirstPoint) - { - spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); - } - else - { - spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); - } - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1())); - domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2())); - domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2())); - domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve())); - emit FullUpdateTree(); - } -} - -void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogSpline, this, event); -} - -void VToolSpline::AddToFile() -{ - VSpline spl = VAbstractTool::data.GetSpline(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrPoint1, spl.GetP1()); - AddAttribute(domElement, AttrPoint4, spl.GetP4()); - AddAttribute(domElement, AttrAngle1, spl.GetAngle1()); - AddAttribute(domElement, AttrAngle2, spl.GetAngle2()); - AddAttribute(domElement, AttrKAsm1, spl.GetKasm1()); - AddAttribute(domElement, AttrKAsm2, spl.GetKasm2()); - AddAttribute(domElement, AttrKCurve, spl.GetKcurve()); - - AddToCalculation(domElement); -} - -void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Spline); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); -} - -void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} - -void VToolSpline::RemoveReferens() -{ - VSpline spl = VAbstractTool::data.GetSpline(id); - doc->DecrementReferens(spl.GetP1()); - doc->DecrementReferens(spl.GetP4()); -} - -void VToolSpline::RefreshGeometry() -{ - this->setPen(QPen(currentColor, widthHairLine/factor)); - VSpline spl = VAbstractTool::data.GetSpline(id); - QPainterPath path; - path.addPath(spl.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - QPointF splinePoint = VAbstractTool::data.GetPoint(spl.GetP1()).toQPointF(); - QPointF controlPoint = spl.GetP2(); - emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint); - splinePoint = VAbstractTool::data.GetPoint(spl.GetP4()).toQPointF(); - controlPoint = spl.GetP3(); - emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint); - - disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - controlPoints[0]->setPos(spl.GetP2()); - controlPoints[1]->setPos(spl.GetP3()); - connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); - connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSpline::ControlPointChangePosition); -} - - -void VToolSpline::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - this->setAcceptHoverEvents (selectable); - emit setEnabledPoint(selectable); - VDrawTool::ChangedActivDraw(newName); -} - -void VToolSpline::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -void VToolSpline::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} diff --git a/src/tools/drawTools/vtoolspline.h b/src/tools/drawTools/vtoolspline.h deleted file mode 100644 index cf0aeaf8e..000000000 --- a/src/tools/drawTools/vtoolspline.h +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolspline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLSPLINE_H -#define VTOOLSPLINE_H - -#include "vdrawtool.h" -#include -#include "../../dialogs/dialogspline.h" -#include "../../widgets/vcontrolpointspline.h" -#include "../../geometry/vsplinepath.h" - -/** - * @brief The VToolSpline class - */ -class VToolSpline:public VDrawTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VToolSpline - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0 ); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param p1 - * @param p4 - * @param kAsm1 - * @param kAsm2 - * @param angle1 - * @param angle2 - * @param kCurve - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, - const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -signals: - /** - * @brief RefreshLine - * @param indexSpline - * @param position - * @param controlPoint - * @param splinePoint - */ - void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, const QPointF &controlPoint, - const QPointF &splinePoint ); - /** - * @brief setEnabledPoint - * @param enable - */ - void setEnabledPoint ( bool enable ); -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile (); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui ( int result ); - /** - * @brief ControlPointChangePosition - * @param indexSpline - * @param position - * @param pos - */ - void ControlPointChangePosition (const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos); - /** - * @brief ChangedActivDraw - * @param newName - */ - virtual void ChangedActivDraw ( const QString &newName ); - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile (); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogSpline - */ - QSharedPointer dialogSpline; - /** - * @brief controlPoints - */ - QVector controlPoints; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry (); -}; - -#endif // VTOOLSPLINE_H diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp deleted file mode 100644 index bd656dc79..000000000 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolsplinepath.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtoolsplinepath.h" - -const QString VToolSplinePath::TagName = QStringLiteral("spline"); -const QString VToolSplinePath::ToolType = QStringLiteral("path"); - -VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer()), - controlPoints(QVector()) -{ - ignoreFullUpdate = true; - VSplinePath splPath = data->GetSplinePath(id); - QPainterPath path; - path.addPath(splPath.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePoint::FirstPoint, spl.GetP2(), - spl.GetPointP1().toQPointF(), this); - connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); - connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint); - - controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(), - spl.GetPointP4().toQPointF(), this); - connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); - connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint); - } - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolSplinePath::setDialog() -{ - Q_ASSERT(dialogSplinePath.isNull() == false); - VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); - dialogSplinePath->SetPath(splPath); -} - -void VToolSplinePath::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - VSplinePath path = dialog->GetPath(); - for (qint32 i = 0; i < path.CountPoint(); ++i) - { - doc->IncrementReferens(path[i].P()); - } - Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui); -} - -void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddSplinePath(path); - data->AddLengthSpline(path.name(), toMM(path.GetLength())); - } - else - { - data->UpdateSplinePath(id, path); - data->AddLengthSpline(path.name(), toMM(path.GetLength())); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::SplinePathTool, doc); - if (parse == Document::FullParse) - { - VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation); - scene->addItem(spl); - connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor); - doc->AddTool(id, spl); - } -} - -void VToolSplinePath::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VToolSplinePath::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - VSplinePath splPath = dialogSplinePath->GetPath(); - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - qint32 j = i*2; - disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - controlPoints[j-2]->setPos(spl.GetP2()); - controlPoints[j-1]->setPos(spl.GetP3()); - connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - - spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(), - controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve()); - CorectControlPoints(spl, splPath, i); - CorectControlPoints(spl, splPath, i); - - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); - emit FullUpdateTree(); - } - - } - } - dialogSplinePath.clear(); -} - -void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos) -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); - VSpline spl = splPath.GetSpline(indexSpline); - if (position == SplinePoint::FirstPoint) - { - spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); - } - else - { - spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); - } - - CorectControlPoints(spl, splPath, indexSpline); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); - emit FullUpdateTree(); - } -} - -void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) -{ - VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint); - p.SetAngle(spl.GetAngle1()); - p.SetKAsm2(spl.GetKasm1()); - splPath.UpdatePoint(indexSpline, SplinePoint::FirstPoint, p); - - p = splPath.GetSplinePoint(indexSpline, SplinePoint::LastPoint); - p.SetAngle(spl.GetAngle2()-180); - p.SetKAsm1(spl.GetKasm2()); - splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p); -} - -void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) -{ - QDomNodeList nodeList = node.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement domElement = nodeList.at(i).toElement(); - if (domElement.isNull() == false) - { - VSplinePoint p = path[i]; - domElement.setAttribute(AttrPSpline, QString().setNum(p.P())); - domElement.setAttribute(AttrKAsm1, QString().setNum(p.KAsm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(p.KAsm2())); - domElement.setAttribute(AttrAngle, QString().setNum(p.Angle2())); - } - } -} - -void VToolSplinePath::ChangedActivDraw(const QString &newName) -{ - bool selectable = false; - if (nameActivDraw == newName) - { - selectable = true; - currentColor = Qt::black; - } - else - { - selectable = false; - currentColor = Qt::gray; - } - this->setPen(QPen(currentColor, widthHairLine/factor)); - this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); - this->setAcceptHoverEvents (selectable); - emit setEnabledPoint(selectable); - VDrawTool::ChangedActivDraw(newName); -} - -void VToolSplinePath::ShowTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - ShowItem(this, id, color, enable); -} - -void VToolSplinePath::SetFactor(qreal factor) -{ - VDrawTool::SetFactor(factor); - RefreshGeometry(); -} - -void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogSplinePath, this, event); -} - -void VToolSplinePath::AddToFile() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrKCurve, splPath.getKCurve()); - - for (qint32 i = 0; i < splPath.CountPoint(); ++i) - { - AddPathPoint(domElement, splPath[i]); - } - - AddToCalculation(domElement); -} - -void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint) -{ - QDomElement pathPoint = doc->createElement(AttrPathPoint); - - AddAttribute(pathPoint, AttrPSpline, splPoint.P()); - AddAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); - AddAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); - AddAttribute(pathPoint, AttrAngle, splPoint.Angle2()); - - domElement.appendChild(pathPoint); -} - -void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::SplinePath); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VToolSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); -} - -void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); -} - -void VToolSplinePath::RemoveReferens() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); - for (qint32 i = 0; i < splPath.Count(); ++i) - { - doc->DecrementReferens(splPath[i].P()); - } -} - -void VToolSplinePath::RefreshGeometry() -{ - this->setPen(QPen(currentColor, widthHairLine/factor)); - VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); - QPainterPath path; - path.addPath(splPath.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - QPointF splinePoint = spl.GetPointP1().toQPointF(); - QPointF controlPoint = spl.GetP2(); - emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint); - splinePoint = spl.GetPointP4().toQPointF(); - controlPoint = spl.GetP3(); - emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint); - - qint32 j = i*2; - disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - controlPoints[j-2]->setPos(spl.GetP2()); - controlPoints[j-1]->setPos(spl.GetP3()); - connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - } -} diff --git a/src/tools/drawTools/vtoolsplinepath.h b/src/tools/drawTools/vtoolsplinepath.h deleted file mode 100644 index 5f20851c4..000000000 --- a/src/tools/drawTools/vtoolsplinepath.h +++ /dev/null @@ -1,201 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolsplinepath.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLSPLINEPATH_H -#define VTOOLSPLINEPATH_H - -#include "vdrawtool.h" -#include -#include "../../dialogs/dialogsplinepath.h" -#include "../../widgets/vcontrolpointspline.h" - -/** - * @brief The VToolSplinePath class - */ -class VToolSplinePath:public VDrawTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VToolSplinePath - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param path - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -signals: - /** - * @brief RefreshLine - * @param indexSpline - * @param pos - * @param controlPoint - * @param splinePoint - */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, - const QPointF &controlPoint, const QPointF &splinePoint); - /** - * @brief setEnabledPoint - * @param enable - */ - void setEnabledPoint(bool enable); -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief ControlPointChangePosition - * @param indexSpline - * @param position - * @param pos - */ - void ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos); - /** - * @brief ChangedActivDraw - * @param newName - */ - virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor - * @param factor - */ - virtual void SetFactor(qreal factor); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogSplinePath - */ - QSharedPointer dialogSplinePath; - /** - * @brief controlPoints - */ - QVector controlPoints; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry(); - /** - * @brief AddPathPoint - * @param domElement - * @param splPoint - */ - void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); - /** - * @brief UpdatePathPoint - * @param node - * @param path - */ - void UpdatePathPoint(QDomNode& node, VSplinePath &path); - /** - * @brief CorectControlPoints - * @param spl - * @param splPath - * @param indexSpline - */ - void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline); -}; - -#endif // VTOOLSPLINEPATH_H diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp deleted file mode 100644 index 7f0c65081..000000000 --- a/src/tools/drawTools/vtooltriangle.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************************************ - ** - ** @file vtooltriangle.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtooltriangle.h" - -const QString VToolTriangle::ToolType = QStringLiteral("triangle"); - -VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, - const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), - secondPointId(secondPointId), dialogTriangle(QSharedPointer()) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolTriangle::setDialog() -{ - Q_ASSERT(dialogTriangle.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogTriangle->setAxisP1Id(axisP1Id, id); - dialogTriangle->setAxisP2Id(axisP2Id, id); - dialogTriangle->setFirstPointId(firstPointId, id); - dialogTriangle->setSecondPointId(secondPointId, id); - dialogTriangle->setPointName(p.name()); -} - -void VToolTriangle::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) -{ - qint64 axisP1Id = dialog->getAxisP1Id(); - qint64 axisP2Id = dialog->getAxisP2Id(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString pointName = dialog->getPointName(); - Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, - Document::FullParse, Tool::FromGui); -} - -void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VPointF axisP1 = data->GetPoint(axisP1Id); - VPointF axisP2 = data->GetPoint(axisP2Id); - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - - QPointF point = FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(), - secondPoint.toQPointF()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); - } - else - { - data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - VDrawTool::AddRecord(id, Tool::Triangle, doc); - if (parse == Document::FullParse) - { - VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, - secondPointId, typeCreation); - scene->addItem(point); - connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(point, &VToolTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor); - doc->AddTool(id, point); - doc->IncrementReferens(axisP1Id); - doc->IncrementReferens(axisP2Id); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } -} - -QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, - const QPointF &secondPoint) -{ - qreal c = QLineF(firstPoint, secondPoint).length(); - qreal a = QLineF(axisP2, firstPoint).length(); - qreal b = QLineF(axisP2, secondPoint).length(); - if (fabs(c*c - (a*a + b*b)) < 0.0001) - { - QLineF l1(axisP2, firstPoint); - QLineF l2(axisP2, secondPoint); - if (fabs(l1.angleTo(l2) - 90) < 0.1 || fabs(l2.angleTo(l1) - 90) < 0.1) - { - return axisP2; - } - } - - QLineF line = QLineF(axisP1, axisP2); - qreal step = 0.01; - while (1) - { - line.setLength(line.length()+step); - a = QLineF(line.p2(), firstPoint).length(); - b = QLineF(line.p2(), secondPoint).length(); - if (static_cast(c*c) == static_cast(a*a + b*b)) - { - QLineF l1(axisP2, firstPoint); - QLineF l2(axisP2, secondPoint); - if (fabs(l1.angleTo(l2) - 90) < 0.1 || fabs(l2.angleTo(l1) - 90) < 0.1) - { - return line.p2(); - } - } - if (c*c < a*a + b*b) - { - qWarning()<elementById(QString().setNum(id)); - if (domElement.isElement()) - { - axisP1Id = domElement.attribute(AttrAxisP1, "").toLongLong(); - axisP2Id = domElement.attribute(AttrAxisP2, "").toLongLong(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); -} - -void VToolTriangle::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogTriangle->getPointName()); - domElement.setAttribute(AttrAxisP1, QString().setNum(dialogTriangle->getAxisP1Id())); - domElement.setAttribute(AttrAxisP2, QString().setNum(dialogTriangle->getAxisP2Id())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogTriangle->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogTriangle->getSecondPointId())); - emit FullUpdateTree(); - } - - } - dialogTriangle.clear(); -} - -void VToolTriangle::RemoveReferens() -{ - doc->DecrementReferens(axisP1Id); - doc->DecrementReferens(axisP2Id); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} - -void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogTriangle, this, event); -} - -void VToolTriangle::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrAxisP1, axisP1Id); - AddAttribute(domElement, AttrAxisP2, axisP2Id); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} diff --git a/src/tools/drawTools/vtooltriangle.h b/src/tools/drawTools/vtooltriangle.h deleted file mode 100644 index 5a9543cde..000000000 --- a/src/tools/drawTools/vtooltriangle.h +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************ - ** - ** @file vtooltriangle.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLTRIANGLE_H -#define VTOOLTRIANGLE_H - -#include "vtoolpoint.h" -#include "../../dialogs/dialogtriangle.h" - -/** - * @brief The VToolTriangle class - */ -class VToolTriangle : public VToolPoint -{ - Q_OBJECT -public: - /** - * @brief VToolTriangle - * @param doc dom document container - * @param data - * @param id - * @param axisP1Id - * @param axisP2Id - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param axisP1Id - * @param axisP2Id - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, const qint64 &axisP2Id, - const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief FindPoint - * @param axisP1 - * @param axisP2 - * @param firstPoint - * @param secondPoint - * @return - */ - static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, - const QPointF &secondPoint); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - Q_DISABLE_COPY(VToolTriangle) - /** - * @brief axisP1Id - */ - qint64 axisP1Id; - /** - * @brief axisP2Id - */ - qint64 axisP2Id; - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogTriangle - */ - QSharedPointer dialogTriangle; -}; - -#endif // VTOOLTRIANGLE_H diff --git a/src/tools/modelingTools/modelingtools.h b/src/tools/modelingTools/modelingtools.h deleted file mode 100644 index 3203357b1..000000000 --- a/src/tools/modelingTools/modelingtools.h +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************ - ** - ** @file modelingtools.h - ** @author Roman Telezhinsky - ** @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 - ** 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 MODELINGTOOLS_H -#define MODELINGTOOLS_H - -#include "vmodelingalongline.h" -#include "vmodelingarc.h" -#include "vmodelingbisector.h" -#include "vmodelingendline.h" -#include "vmodelingline.h" -#include "vmodelinglineintersect.h" -#include "vmodelingnormal.h" -#include "vmodelingpointofcontact.h" -#include "vmodelingshoulderpoint.h" -#include "vmodelingspline.h" -#include "vmodelingsplinepath.h" -#include "vmodelingheight.h" -#include "vmodelingtriangle.h" -#include "vmodelingpointofintersection.h" - -#endif // MODELINGTOOLS_H diff --git a/src/tools/modelingTools/vmodelingalongline.cpp b/src/tools/modelingTools/vmodelingalongline.cpp deleted file mode 100644 index 2f38aa88a..000000000 --- a/src/tools/modelingTools/vmodelingalongline.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingalongline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingalongline.h" -#include "../../container/calculator.h" - -const QString VModelingAlongLine::ToolType = QStringLiteral("alongLine"); - -VModelingAlongLine::VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id, - const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId), - dialogAlongLine(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingAlongLine::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - RefreshGeometry(); -} - -void VModelingAlongLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogAlongLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogAlongLine->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogAlongLine->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogAlongLine->getSecondPointId())); - emit FullUpdateTree(); - } - - } - dialogAlongLine.clear(); -} - -void VModelingAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogAlongLine, this, event); -} - -void VModelingAlongLine::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToModeling(domElement); -} - -void VModelingAlongLine::RemoveReferens() -{ - doc->DecrementReferens(secondPointId); - VModelingLinePoint::RemoveReferens(); -} - -void VModelingAlongLine::setDialog() -{ - Q_ASSERT(dialogAlongLine.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogAlongLine->setTypeLine(typeLine); - dialogAlongLine->setFormula(formula); - dialogAlongLine->setFirstPointId(basePointId, id); - dialogAlongLine->setSecondPointId(secondPointId, id); - dialogAlongLine->setPointName(p.name()); -} - -VModelingAlongLine *VModelingAlongLine::Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - return Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qreal &mx, const qreal &my, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingAlongLine *point = 0; - VPointF firstPoint = data->GetPointModeling(firstPointId); - VPointF secondPoint = data->GetPointModeling(secondPointId); - QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - line.setLength(toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(firstPointId, id); - data->AddLine(id, secondPointId); - - if (parse == Document::FullParse) - { - point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, - typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } - return point; -} diff --git a/src/tools/modelingTools/vmodelingalongline.h b/src/tools/modelingTools/vmodelingalongline.h deleted file mode 100644 index b5ddd9f8c..000000000 --- a/src/tools/modelingTools/vmodelingalongline.h +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingalongline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGALONGLINE_H -#define VMODELINGALONGLINE_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialogalongline.h" - -/** - * @brief The VModelingAlongLine class - */ -class VModelingAlongLine : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingAlongLine - * @param doc dom document container - * @param data - * @param id - * @param formula - * @param firstPointId - * @param secondPointId - * @param typeLine - * @param typeCreation - * @param parent - */ - VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id, - const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingAlongLine* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param formula - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingAlongLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogAlongLine - */ - QSharedPointer dialogAlongLine; -}; - -#endif // VMODELINGALONGLINE_H diff --git a/src/tools/modelingTools/vmodelingarc.cpp b/src/tools/modelingTools/vmodelingarc.cpp deleted file mode 100644 index 676a3c151..000000000 --- a/src/tools/modelingTools/vmodelingarc.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingarc.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingarc.h" -#include "../../container/calculator.h" - -const QString VModelingArc::TagName = QStringLiteral("arc"); -const QString VModelingArc::ToolType = QStringLiteral("simple"); - -VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogArc(QSharedPointer()) -{ - this->setPen(QPen(baseColor, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - RefreshGeometry(); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingArc::setDialog() -{ - Q_ASSERT(dialogArc.isNull() == false); - VArc arc = VAbstractTool::data.GetArcModeling(id); - dialogArc->SetCenter(arc.GetCenter()); - dialogArc->SetRadius(arc.GetFormulaRadius()); - dialogArc->SetF1(arc.GetFormulaF1()); - dialogArc->SetF2(arc.GetFormulaF2()); -} - -VModelingArc* VModelingArc::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - qint64 center = dialog->GetCenter(); - QString radius = dialog->GetRadius(); - QString f1 = dialog->GetF1(); - QString f2 = dialog->GetF2(); - return Create(0, center, radius, f1, f2, doc, data, Document::FullParse, Tool::FromGui); -} - -VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VModelingArc *toolArc = 0; - qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(radius, &errorMsg); - if (errorMsg.isEmpty()) - { - calcRadius = toPixel(result); - } - - errorMsg.clear(); - result = cal.eval(f1, &errorMsg); - if (errorMsg.isEmpty()) - { - calcF1 = result; - } - - errorMsg.clear(); - result = cal.eval(f2, &errorMsg); - if (errorMsg.isEmpty()) - { - calcF2 = result; - } - - VArc arc = VArc(data->DataPointsModeling(), center, calcRadius, radius, calcF1, f1, calcF2, f2 ); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddArcModeling(arc); - } - else - { - data->UpdateArcModeling(id, arc); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLengthArc(arc.name(), toMM(arc.GetLength())); - if (parse == Document::FullParse) - { - toolArc = new VModelingArc(doc, data, id, typeCreation); - doc->AddTool(id, toolArc); - doc->IncrementReferens(center); - } - return toolArc; -} - -void VModelingArc::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VModelingArc::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter())); - domElement.setAttribute(AttrRadius, dialogArc->GetRadius()); - domElement.setAttribute(AttrAngle1, dialogArc->GetF1()); - domElement.setAttribute(AttrAngle2, dialogArc->GetF2()); - emit FullUpdateTree(); - } - } - dialogArc.clear(); -} - -void VModelingArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogArc, this, event); -} - -void VModelingArc::AddToFile() -{ - VArc arc = VAbstractTool::data.GetArcModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrCenter, arc.GetCenter()); - AddAttribute(domElement, AttrRadius, arc.GetFormulaRadius()); - AddAttribute(domElement, AttrAngle1, arc.GetFormulaF1()); - AddAttribute(domElement, AttrAngle2, arc.GetFormulaF2()); - - AddToModeling(domElement); -} - -void VModelingArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Arc); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VModelingArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VModelingArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VModelingArc::RemoveReferens() -{ - VArc arc = VAbstractTool::data.GetArcModeling(id); - doc->DecrementReferens(arc.GetCenter()); -} - -void VModelingArc::RefreshGeometry() -{ - VArc arc = VAbstractTool::data.GetArcModeling(id); - QPainterPath path; - path.addPath(arc.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); -} diff --git a/src/tools/modelingTools/vmodelingarc.h b/src/tools/modelingTools/vmodelingarc.h deleted file mode 100644 index e32f8f6cf..000000000 --- a/src/tools/modelingTools/vmodelingarc.h +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingarc.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGARC_H -#define VMODELINGARC_H - -#include "vmodelingtool.h" -#include -#include "../../dialogs/dialogarc.h" -#include "../../widgets/vcontrolpointspline.h" - -/** - * @brief The VModelingArc class - */ -class VModelingArc :public VModelingTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VModelingArc - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingArc* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param center - * @param radius - * @param f1 - * @param f2 - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingArc* Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogArc - */ - QSharedPointer dialogArc; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry(); -}; - -#endif // VMODELINGARC_H diff --git a/src/tools/modelingTools/vmodelingbisector.cpp b/src/tools/modelingTools/vmodelingbisector.cpp deleted file mode 100644 index ccb3266af..000000000 --- a/src/tools/modelingTools/vmodelingbisector.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingbisector.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingbisector.h" -#include "../drawTools/vtoolbisector.h" -#include "../../container/calculator.h" - -const QString VModelingBisector::ToolType = QStringLiteral("bisector"); - -VModelingBisector::VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qint64 &thirdPointId, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VModelingLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0), - thirdPointId(0), dialogBisector(QSharedPointer()) -{ - this->firstPointId = firstPointId; - this->thirdPointId = thirdPointId; - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingBisector::setDialog() -{ - Q_ASSERT(dialogBisector.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogBisector->setTypeLine(typeLine); - dialogBisector->setFormula(formula); - dialogBisector->setFirstPointId(firstPointId, id); - dialogBisector->setSecondPointId(basePointId, id); - dialogBisector->setThirdPointId(thirdPointId, id); - dialogBisector->setPointName(p.name()); -} - -VModelingBisector *VModelingBisector::Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - qint64 thirdPointId = dialog->getThirdPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - return Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, doc, - data, Document::FullParse, Tool::FromGui); -} - -VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &formula, - const qint64 &firstPointId, const qint64 &secondPointId, - const qint64 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingBisector *point = 0; - VPointF firstPoint = data->GetPointModeling(firstPointId); - VPointF secondPoint = data->GetPointModeling(secondPointId); - VPointF thirdPoint = data->GetPointModeling(thirdPointId); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - thirdPoint.toQPointF(), toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(firstPointId, id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, - thirdPointId, typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - doc->IncrementReferens(thirdPointId); - } - } - return point; -} - -void VModelingBisector::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - basePointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - thirdPointId = domElement.attribute(AttrThirdPoint, "").toLongLong(); - } - RefreshGeometry(); -} - -void VModelingBisector::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogBisector->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine()); - domElement.setAttribute(AttrLength, dialogBisector->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogBisector->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogBisector->getSecondPointId())); - domElement.setAttribute(AttrThirdPoint, QString().setNum(dialogBisector->getThirdPointId())); - emit FullUpdateTree(); - } - } - dialogBisector.clear(); -} - -void VModelingBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogBisector, this, event); -} - -void VModelingBisector::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, basePointId); - AddAttribute(domElement, AttrThirdPoint, thirdPointId); - - AddToModeling(domElement); -} - -void VModelingBisector::RemoveReferens() -{ - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(thirdPointId); - VModelingLinePoint::RemoveReferens(); -} diff --git a/src/tools/modelingTools/vmodelingbisector.h b/src/tools/modelingTools/vmodelingbisector.h deleted file mode 100644 index 21b83161e..000000000 --- a/src/tools/modelingTools/vmodelingbisector.h +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingbisector.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGBISECTOR_H -#define VMODELINGBISECTOR_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialogbisector.h" - -/** - * @brief The VModelingBisector class - */ -class VModelingBisector : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingBisector - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param firstPointId - * @param secondPointId - * @param thirdPointId - * @param typeCreation - * @param parent - */ - VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, - const qint64 &firstPointId, const qint64 &secondPointId, - const qint64 &thirdPointId, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingBisector* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param firstPointId - * @param secondPointId - * @param thirdPointId - * @param typeLine - * @param pointName - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief thirdPointId - */ - qint64 thirdPointId; - /** - * @brief dialogBisector - */ - QSharedPointer dialogBisector; -}; - -#endif // VMODELINGBISECTOR_H diff --git a/src/tools/modelingTools/vmodelingendline.cpp b/src/tools/modelingTools/vmodelingendline.cpp deleted file mode 100644 index 26ae9ec22..000000000 --- a/src/tools/modelingTools/vmodelingendline.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingendline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingendline.h" -#include "../../container/calculator.h" - -const QString VModelingEndLine::ToolType = QStringLiteral("endLine"); - -VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qreal &angle, - const qint64 &basePointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent), - dialogEndLine(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingEndLine::setDialog() -{ - Q_ASSERT(dialogEndLine.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogEndLine->setTypeLine(typeLine); - dialogEndLine->setFormula(formula); - dialogEndLine->setAngle(angle); - dialogEndLine->setBasePointId(basePointId, id); - dialogEndLine->setPointName(p.name()); -} - -VModelingEndLine *VModelingEndLine::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - QString pointName = dialog->getPointName(); - QString typeLine = dialog->getTypeLine(); - QString formula = dialog->getFormula(); - qreal angle = dialog->getAngle(); - qint64 basePointId = dialog->getBasePointId(); - return Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, doc, data, Document::FullParse, - Tool::FromGui); -} - -VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &pointName, - const QString &typeLine, const QString &formula, - const qreal &angle, const qint64 &basePointId, const qreal &mx, - const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VModelingEndLine *point = 0; - VPointF basePoint = data->GetPointModeling(basePointId); - QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y())); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - line.setLength(toPixel(result)); - line.setAngle(angle); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(basePointId, id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - } - } - return point; -} - -void VModelingEndLine::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); - angle = domElement.attribute(AttrAngle, "").toDouble(); - } - RefreshGeometry(); -} - -void VModelingEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogEndLine, this, event); -} - -void VModelingEndLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogEndLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogEndLine->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogEndLine->getAngle())); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogEndLine->getBasePointId())); - emit FullUpdateTree(); - } - } - dialogEndLine.clear(); -} - -void VModelingEndLine::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrBasePoint, basePointId); - - AddToModeling(domElement); -} diff --git a/src/tools/modelingTools/vmodelingendline.h b/src/tools/modelingTools/vmodelingendline.h deleted file mode 100644 index f22ab5bf5..000000000 --- a/src/tools/modelingTools/vmodelingendline.h +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingbisector.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGENDLINE_H -#define VMODELINGENDLINE_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialogendline.h" - -/** - * @brief The VModelingEndLine class - */ -class VModelingEndLine : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingEndLine - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param angle - * @param basePointId - * @param typeCreation - * @param parent - */ - VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qreal &angle, - const qint64 &basePointId, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingEndLine* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param formula - * @param angle - * @param basePointId - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &basePointId, - const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - /** - * @brief dialogEndLine - */ - QSharedPointer dialogEndLine; -}; - -#endif // VMODELINGENDLINE_H diff --git a/src/tools/modelingTools/vmodelingheight.cpp b/src/tools/modelingTools/vmodelingheight.cpp deleted file mode 100644 index 99eeab418..000000000 --- a/src/tools/modelingTools/vmodelingheight.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingheight.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingheight.h" -#include "../drawTools/vtoolheight.h" - -const QString VModelingHeight::ToolType = QStringLiteral("height"); - -VModelingHeight::VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, - const qint64 &p2LineId, const Tool::Sources &typeCreation, - QGraphicsItem * parent) - :VModelingLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), - dialogHeight(QSharedPointer()), p1LineId(p1LineId), p2LineId(p2LineId) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingHeight::setDialog() -{ - Q_ASSERT(dialogHeight.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogHeight->setTypeLine(typeLine); - dialogHeight->setBasePointId(basePointId, id); - dialogHeight->setP1LineId(p1LineId, id); - dialogHeight->setP2LineId(p2LineId, id); - dialogHeight->setPointName(p.name()); -} - -VModelingHeight *VModelingHeight::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList); - QString pointName = dialog->getPointName(); - QString typeLine = dialog->getTypeLine(); - qint64 basePointId = dialog->getBasePointId(); - qint64 p1LineId = dialog->getP1LineId(); - qint64 p2LineId = dialog->getP2LineId(); - return Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingHeight *VModelingHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, - const qint64 &p2LineId, const qreal &mx, const qreal &my, - VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - VModelingHeight *point = 0; - VPointF basePoint = data->GetPointModeling(basePointId); - VPointF p1Line = data->GetPointModeling(p1LineId); - VPointF p2Line = data->GetPointModeling(p2LineId); - - QPointF pHeight = VToolHeight::FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), - basePoint.toQPointF()); - QLineF line = QLineF(basePoint.toQPointF(), pHeight); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(basePointId, id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - doc->IncrementReferens(p1LineId); - doc->IncrementReferens(p2LineId); - } - return point; -} - -void VModelingHeight::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toLongLong(); - p1LineId = domElement.attribute(AttrP1Line, "").toLongLong(); - p2LineId = domElement.attribute(AttrP2Line, "").toLongLong(); - } - RefreshGeometry(); -} - -void VModelingHeight::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogHeight->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine()); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId())); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogHeight->getP1LineId())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogHeight->getP2LineId())); - emit FullUpdateTree(); - } - } - dialogHeight.clear(); -} - -void VModelingHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogHeight, this, event); -} - -void VModelingHeight::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrBasePoint, basePointId); - AddAttribute(domElement, AttrP1Line, p1LineId); - AddAttribute(domElement, AttrP2Line, p2LineId); - - AddToModeling(domElement); -} diff --git a/src/tools/modelingTools/vmodelingheight.h b/src/tools/modelingTools/vmodelingheight.h deleted file mode 100644 index d89f5a4d9..000000000 --- a/src/tools/modelingTools/vmodelingheight.h +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingheight.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGHEIGHT_H -#define VMODELINGHEIGHT_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialogheight.h" - -/** - * @brief The VModelingHeight class - */ -class VModelingHeight : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingHeight - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param basePointId - * @param p1LineId - * @param p2LineId - * @param typeCreation - * @param parent - */ - VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, - const qint64 &p2LineId, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingHeight* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param typeLine - * @param basePointId - * @param p1LineId - * @param p2LineId - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingHeight* Create(const qint64 _id, const QString &pointName, const QString &typeLine, - const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - /** - * @brief dialogHeight - */ - QSharedPointer dialogHeight; - /** - * @brief p1LineId - */ - qint64 p1LineId; - /** - * @brief p2LineId - */ - qint64 p2LineId; -}; - -#endif // VMODELINGHEIGHT_H diff --git a/src/tools/modelingTools/vmodelingline.cpp b/src/tools/modelingTools/vmodelingline.cpp deleted file mode 100644 index 3ae98a59f..000000000 --- a/src/tools/modelingTools/vmodelingline.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingline.h" - -const QString VModelingLine::TagName = QStringLiteral("line"); - -VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, - qint64 secondPoint, const Tool::Sources &typeCreation, QGraphicsItem *parent): - VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), - secondPoint(secondPoint), dialogLine(QSharedPointer()) -{ - ignoreFullUpdate = true; - //Лінія - VPointF first = data->GetPointModeling(firstPoint); - VPointF second = data->GetPointModeling(secondPoint); - this->setLine(QLineF(first.toQPointF(), second.toQPointF())); - this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingLine::setDialog() -{ - dialogLine->setFirstPoint(firstPoint); - dialogLine->setSecondPoint(secondPoint); -} - -VModelingLine *VModelingLine::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - qint64 firstPoint = dialog->getFirstPoint(); - qint64 secondPoint = dialog->getSecondPoint(); - return Create(0, firstPoint, secondPoint, doc, data, Document::FullParse, Tool::FromGui); -} - -VModelingLine *VModelingLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingLine *line = 0; - Q_ASSERT(doc != 0); - Q_ASSERT(data != 0); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->getNextId(); - } - else - { - if (parse != Document::FullParse) - { - data->UpdateId(id); - doc->UpdateToolData(id, data); - } - } - data->AddLine(firstPoint, secondPoint, Draw::Modeling); - if (parse == Document::FullParse) - { - line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation); - doc->AddTool(id, line); - doc->IncrementReferens(firstPoint); - doc->IncrementReferens(secondPoint); - } - return line; -} - -void VModelingLine::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VPointF first = VAbstractTool::data.GetPointModeling(firstPoint); - VPointF second = VAbstractTool::data.GetPointModeling(secondPoint); - this->setLine(QLineF(first.toQPointF(), second.toQPointF())); -} - -void VModelingLine::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint())); - emit FullUpdateTree(); - } - } - dialogLine.clear(); -} - -void VModelingLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogLine, this, event); -} - -void VModelingLine::AddToFile() -{ - QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrFirstPoint, firstPoint); - AddAttribute(domElement, AttrSecondPoint, secondPoint); - - AddToModeling(domElement); -} - -void VModelingLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VModelingLine::RemoveReferens() -{ - doc->DecrementReferens(firstPoint); - doc->DecrementReferens(secondPoint); -} diff --git a/src/tools/modelingTools/vmodelingline.h b/src/tools/modelingTools/vmodelingline.h deleted file mode 100644 index bf9729389..000000000 --- a/src/tools/modelingTools/vmodelingline.h +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGLINE_H -#define VMODELINGLINE_H - -#include "vmodelingtool.h" -#include -#include "../../dialogs/dialogline.h" - -/** - * @brief The VModelingLine class - */ -class VModelingLine: public VModelingTool, public QGraphicsLineItem -{ - Q_OBJECT -public: - /** - * @brief VModelingLine - * @param doc dom document container - * @param data - * @param id - * @param firstPoint - * @param secondPoint - * @param typeCreation - * @param parent - */ - VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, - qint64 secondPoint, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingLine* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param firstPoint - * @param secondPoint - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingLine* Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief firstPoint - */ - qint64 firstPoint; - /** - * @brief secondPoint - */ - qint64 secondPoint; - /** - * @brief dialogLine - */ - QSharedPointer dialogLine; -}; - -#endif // VMODELINGLINE_H diff --git a/src/tools/modelingTools/vmodelinglineintersect.cpp b/src/tools/modelingTools/vmodelinglineintersect.cpp deleted file mode 100644 index dd15b7a09..000000000 --- a/src/tools/modelingTools/vmodelinglineintersect.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelinglineintersect.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelinglineintersect.h" - -const QString VModelingLineIntersect::ToolType = QStringLiteral("lineIntersect"); - -VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, - const qint64 &p2Line2, const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), - p2Line2(p2Line2), dialogLineIntersect(QSharedPointer()) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingLineIntersect::setDialog() -{ - Q_ASSERT(dialogLineIntersect.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogLineIntersect->setP1Line1(p1Line1); - dialogLineIntersect->setP2Line1(p2Line1); - dialogLineIntersect->setP1Line2(p1Line2); - dialogLineIntersect->setP2Line2(p2Line2); - dialogLineIntersect->setPointName(p.name()); -} - -VModelingLineIntersect *VModelingLineIntersect::Create(QSharedPointer &dialog, - VDomDocument *doc, VContainer *data) -{ - qint64 p1Line1Id = dialog->getP1Line1(); - qint64 p2Line1Id = dialog->getP2Line1(); - qint64 p1Line2Id = dialog->getP1Line2(); - qint64 p2Line2Id = dialog->getP2Line2(); - QString pointName = dialog->getPointName(); - return Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, - const qint64 &p2Line1Id, const qint64 &p1Line2Id, - const qint64 &p2Line2Id, const QString &pointName, - const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingLineIntersect *point = 0; - VPointF p1Line1 = data->GetPointModeling(p1Line1Id); - VPointF p2Line1 = data->GetPointModeling(p2Line1Id); - VPointF p1Line2 = data->GetPointModeling(p1Line2Id); - VPointF p2Line2 = data->GetPointModeling(p2Line2Id); - - QLineF line1(p1Line1.toQPointF(), p2Line1.toQPointF()); - QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF()); - QPointF fPoint; - QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); - if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) - { - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(p1Line1Id, id, Draw::Modeling); - data->AddLine(id, p2Line1Id, Draw::Modeling); - data->AddLine(p1Line2Id, id, Draw::Modeling); - data->AddLine(id, p2Line2Id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, - typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(p1Line1Id); - doc->IncrementReferens(p2Line1Id); - doc->IncrementReferens(p1Line2Id); - doc->IncrementReferens(p2Line2Id); - } - } - return point; -} - -void VModelingLineIntersect::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - p1Line1 = domElement.attribute(AttrP1Line1, "").toLongLong(); - p2Line1 = domElement.attribute(AttrP2Line1, "").toLongLong(); - p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong(); - p2Line2 = domElement.attribute(AttrP2Line2, "").toLongLong(); - } - RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id)); -} - -void VModelingLineIntersect::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogLineIntersect->getPointName()); - domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1())); - domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1())); - domElement.setAttribute(AttrP1Line2, QString().setNum(dialogLineIntersect->getP1Line2())); - domElement.setAttribute(AttrP2Line2, QString().setNum(dialogLineIntersect->getP2Line2())); - emit FullUpdateTree(); - } - } - dialogLineIntersect.clear(); -} - -void VModelingLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogLineIntersect, this, event); -} - -void VModelingLineIntersect::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrP1Line1, p1Line1); - AddAttribute(domElement, AttrP2Line1, p2Line1); - AddAttribute(domElement, AttrP1Line2, p1Line2); - AddAttribute(domElement, AttrP2Line2, p2Line2); - - AddToModeling(domElement); -} - -void VModelingLineIntersect::RemoveReferens() -{ - doc->DecrementReferens(p1Line1); - doc->DecrementReferens(p2Line1); - doc->DecrementReferens(p1Line2); - doc->DecrementReferens(p2Line2); -} diff --git a/src/tools/modelingTools/vmodelinglineintersect.h b/src/tools/modelingTools/vmodelinglineintersect.h deleted file mode 100644 index b0dfd515f..000000000 --- a/src/tools/modelingTools/vmodelinglineintersect.h +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelinglineintersect.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGLINEINTERSECT_H -#define VMODELINGLINEINTERSECT_H - -#include "vmodelingpoint.h" -#include "../../dialogs/dialoglineintersect.h" - -/** - * @brief The VModelingLineIntersect class - */ -class VModelingLineIntersect:public VModelingPoint -{ - Q_OBJECT -public: - /** - * @brief VModelingLineIntersect - * @param doc dom document container - * @param data - * @param id - * @param p1Line1 - * @param p2Line1 - * @param p1Line2 - * @param p2Line2 - * @param typeCreation - * @param parent - */ - VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &p1Line1, const qint64 &p2Line1, - const qint64 &p1Line2, const qint64 &p2Line2, - const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingLineIntersect* Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param p1Line1Id - * @param p2Line1Id - * @param p1Line2Id - * @param p2Line2Id - * @param pointName - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, - const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, - const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief p1Line1 - */ - qint64 p1Line1; - /** - * @brief p2Line1 - */ - qint64 p2Line1; - /** - * @brief p1Line2 - */ - qint64 p1Line2; - /** - * @brief p2Line2 - */ - qint64 p2Line2; - /** - * @brief dialogLineIntersect - */ - QSharedPointer dialogLineIntersect; -}; - -#endif // VMODELINGLINEINTERSECT_H diff --git a/src/tools/modelingTools/vmodelinglinepoint.cpp b/src/tools/modelingTools/vmodelinglinepoint.cpp deleted file mode 100644 index b68231cfe..000000000 --- a/src/tools/modelingTools/vmodelinglinepoint.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelinglinepoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelinglinepoint.h" - -VModelingLinePoint::VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &basePointId, - const qreal &angle, QGraphicsItem *parent) - :VModelingPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle), - basePointId(basePointId), mainLine(0) -{ - //Лінія, що з'єднує дві точки - QPointF point1 = data->GetPointModeling(basePointId).toQPointF(); - QPointF point2 = data->GetPointModeling(id).toQPointF(); - mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); - mainLine->setPen(QPen(Qt::black, widthHairLine)); - mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); - if (typeLine == TypeLineNone) - { - mainLine->setVisible(false); - } - else - { - mainLine->setVisible(true); - } -} - -void VModelingLinePoint::RefreshGeometry() -{ - VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id)); - QPointF point = VModelingTool::data.GetPointModeling(id).toQPointF(); - QPointF basePoint = VModelingTool::data.GetPointModeling(basePointId).toQPointF(); - mainLine->setLine(QLineF(basePoint - point, QPointF())); - if (typeLine == TypeLineNone) - { - mainLine->setVisible(false); - } - else - { - mainLine->setVisible(true); - } -} diff --git a/src/tools/modelingTools/vmodelinglinepoint.h b/src/tools/modelingTools/vmodelinglinepoint.h deleted file mode 100644 index 1ef7ee104..000000000 --- a/src/tools/modelingTools/vmodelinglinepoint.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelinglinepoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGLINEPOINT_H -#define VMODELINGLINEPOINT_H - -#include "vmodelingpoint.h" - -/** - * @brief The VModelingLinePoint class - */ -class VModelingLinePoint : public VModelingPoint -{ - Q_OBJECT -public: - /** - * @brief VModelingLinePoint - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param basePointId - * @param angle - * @param parent - */ - VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qint64 &basePointId, const qreal &angle, - QGraphicsItem * parent = 0); -protected: - /** - * @brief typeLine - */ - QString typeLine; - /** - * @brief formula - */ - QString formula; - /** - * @brief angle - */ - qreal angle; - /** - * @brief basePointId - */ - qint64 basePointId; - /** - * @brief mainLine - */ - QGraphicsLineItem *mainLine; - /** - * @brief RefreshGeometry - */ - virtual void RefreshGeometry(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens() {doc->DecrementReferens(basePointId);} -private: - Q_DISABLE_COPY(VModelingLinePoint) -}; - -#endif // VMODELINGLINEPOINT_H diff --git a/src/tools/modelingTools/vmodelingnormal.cpp b/src/tools/modelingTools/vmodelingnormal.cpp deleted file mode 100644 index 91daea902..000000000 --- a/src/tools/modelingTools/vmodelingnormal.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingnormal.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingnormal.h" -#include "../drawTools/vtoolnormal.h" -#include "../../container/calculator.h" - -const QString VModelingNormal::ToolType = QStringLiteral("normal"); - -VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const qint64 &firstPointId, - const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), - secondPointId(secondPointId), dialogNormal(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingNormal::setDialog() -{ - Q_ASSERT(dialogNormal.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogNormal->setTypeLine(typeLine); - dialogNormal->setFormula(formula); - dialogNormal->setAngle(angle); - dialogNormal->setFirstPointId(basePointId, id); - dialogNormal->setSecondPointId(secondPointId, id); - dialogNormal->setPointName(p.name()); -} - -VModelingNormal* VModelingNormal::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - qreal angle = dialog->getAngle(); - return Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingNormal *point = 0; - VPointF firstPoint = data->GetPointModeling(firstPointId); - VPointF secondPoint = data->GetPointModeling(secondPointId); - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - toPixel(result), angle); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(firstPointId, id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId, - typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } - return point; -} - -void VModelingNormal::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - angle = domElement.attribute(AttrAngle, "").toInt(); - } - RefreshGeometry(); -} - -void VModelingNormal::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogNormal->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine()); - domElement.setAttribute(AttrLength, dialogNormal->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogNormal->getAngle())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogNormal->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogNormal->getSecondPointId())); - emit FullUpdateTree(); - } - } - dialogNormal.clear(); -} - -void VModelingNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogNormal, this, event); -} - -void VModelingNormal::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToModeling(domElement); -} - -void VModelingNormal::RemoveReferens() -{ - doc->DecrementReferens(secondPointId); - VModelingLinePoint::RemoveReferens(); -} diff --git a/src/tools/modelingTools/vmodelingnormal.h b/src/tools/modelingTools/vmodelingnormal.h deleted file mode 100644 index 362b4897d..000000000 --- a/src/tools/modelingTools/vmodelingnormal.h +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingnormal.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGNORMAL_H -#define VMODELINGNORMAL_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialognormal.h" - -/** - * @brief The VModelingNormal class - */ -class VModelingNormal : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingNormal - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param angle - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qreal &angle, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingNormal* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param firstPointId - * @param secondPointId - * @param typeLine - * @param pointName - * @param angle - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, - const qint64 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogNormal - */ - QSharedPointer dialogNormal; -}; - -#endif // VMODELINGNORMAL_H diff --git a/src/tools/modelingTools/vmodelingpoint.cpp b/src/tools/modelingTools/vmodelingpoint.cpp deleted file mode 100644 index c13c3951d..000000000 --- a/src/tools/modelingTools/vmodelingpoint.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingpoint.h" -#include "../../container/vpointf.h" - -const QString VModelingPoint::TagName = QStringLiteral("point"); - -VModelingPoint::VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem *parent) - :VModelingTool(doc, data, id), QGraphicsEllipseItem(parent), radius(toPixel(1.5)), namePoint(0), lineName(0) -{ - namePoint = new VGraphicsSimpleTextItem(this); - lineName = new QGraphicsLineItem(this); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VModelingPoint::NameChangePosition); - this->setPen(QPen(Qt::black, widthHairLine)); - this->setBrush(QBrush(Qt::NoBrush)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id)); -} - -void VModelingPoint::NameChangePosition(const QPointF &pos) -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QPointF p = pos - this->pos(); - point.setMx(p.x()); - point.setMy(p.y()); - RefreshLine(); - UpdateNamePosition(point.mx(), point.my()); - VAbstractTool::data.UpdatePoint(id, point); -} - -void VModelingPoint::UpdateNamePosition(qreal mx, qreal my) -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrMx, QString().setNum(toMM(mx))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(my))); - emit toolhaveChange(); - } -} - -void VModelingPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Point); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VModelingPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VModelingPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VModelingPoint::RefreshPointGeometry(const VPointF &point) -{ - QRectF rec = QRectF(0, 0, radius*2, radius*2); - rec.translate(-rec.center().x(), -rec.center().y()); - this->setRect(rec); - this->setPos(point.toQPointF()); - disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VModelingPoint::NameChangePosition); - namePoint->setText(point.name()); - namePoint->setPos(QPointF(point.mx(), point.my())); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VModelingPoint::NameChangePosition); - RefreshLine(); -} - -void VModelingPoint::RefreshLine() -{ - QRectF nameRec = namePoint->sceneBoundingRect(); - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); - QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); - lineName->setLine(QLineF(p1, pRec - scenePos())); - if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4)) - { - lineName->setVisible(false); - } - else - { - lineName->setVisible(true); - } -} diff --git a/src/tools/modelingTools/vmodelingpoint.h b/src/tools/modelingTools/vmodelingpoint.h deleted file mode 100644 index 4a1e88432..000000000 --- a/src/tools/modelingTools/vmodelingpoint.h +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGPOINT_H -#define VMODELINGPOINT_H - -#include "vmodelingtool.h" -#include "../../widgets/vgraphicssimpletextitem.h" - -/** - * @brief The VModelingPoint class - */ -class VModelingPoint: public VModelingTool, public QGraphicsEllipseItem -{ - Q_OBJECT -public: - /** - * @brief VModelingPoint - * @param doc dom document container - * @param data - * @param id - * @param parent - */ - VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); - virtual ~VModelingPoint() {} - /** - * @brief TagName - */ - static const QString TagName; -public slots: - /** - * @brief NameChangePosition - * @param pos - */ - void NameChangePosition(const QPointF &pos); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result) = 0; -protected: - /** - * @brief radius - */ - qreal radius; - /** - * @brief namePoint - */ - VGraphicsSimpleTextItem *namePoint; - /** - * @brief lineName - */ - QGraphicsLineItem *lineName; - /** - * @brief UpdateNamePosition - * @param mx - * @param my - */ - virtual void UpdateNamePosition(qreal mx, qreal my); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RefreshPointGeometry - * @param point - */ - virtual void RefreshPointGeometry(const VPointF &point); - /** - * @brief RefreshLine - */ - void RefreshLine(); -private: - Q_DISABLE_COPY(VModelingPoint) -}; - -#endif // VMODELINGPOINT_H diff --git a/src/tools/modelingTools/vmodelingpointofcontact.cpp b/src/tools/modelingTools/vmodelingpointofcontact.cpp deleted file mode 100644 index 43dd485fd..000000000 --- a/src/tools/modelingTools/vmodelingpointofcontact.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpointofcontact.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingpointofcontact.h" -#include "../drawTools/vtoolpointofcontact.h" -#include "../../container/calculator.h" - -const QString VModelingPointOfContact::ToolType = QStringLiteral("pointOfContact"); - -VModelingPointOfContact::VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - : VModelingPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId), - secondPointId(secondPointId), dialogPointOfContact(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingPointOfContact::setDialog() -{ - Q_ASSERT(dialogPointOfContact.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogPointOfContact->setRadius(radius); - dialogPointOfContact->setCenter(center, id); - dialogPointOfContact->setFirstPoint(firstPointId, id); - dialogPointOfContact->setSecondPoint(secondPointId, id); - dialogPointOfContact->setPointName(p.name()); -} - -VModelingPointOfContact *VModelingPointOfContact::Create(QSharedPointer &dialog, - VDomDocument *doc, VContainer *data) -{ - QString radius = dialog->getRadius(); - qint64 center = dialog->getCenter(); - qint64 firstPointId = dialog->getFirstPoint(); - qint64 secondPointId = dialog->getSecondPoint(); - QString pointName = dialog->getPointName(); - return Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingPointOfContact *VModelingPointOfContact::Create(const qint64 _id, const QString &radius, - const qint64 ¢er, const qint64 &firstPointId, - const qint64 &secondPointId, - const QString &pointName, const qreal &mx, - const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingPointOfContact *point = 0; - VPointF centerP = data->GetPointModeling(center); - VPointF firstP = data->GetPointModeling(firstPointId); - VPointF secondP = data->GetPointModeling(secondPointId); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(radius, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(), - firstP.toQPointF(), secondP.toQPointF()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - if (parse == Document::FullParse) - { - point = new VModelingPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId, - typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(center); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - } - return point; -} - -void VModelingPointOfContact::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - radius = domElement.attribute(AttrRadius, ""); - center = domElement.attribute(AttrCenter, "").toLongLong(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id)); -} - -void VModelingPointOfContact::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogPointOfContact->getPointName()); - domElement.setAttribute(AttrRadius, dialogPointOfContact->getRadius()); - domElement.setAttribute(AttrCenter, QString().setNum(dialogPointOfContact->getCenter())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfContact->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfContact->getSecondPoint())); - emit FullUpdateTree(); - } - } - dialogPointOfContact.clear(); -} - -void VModelingPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogPointOfContact, this, event); -} - -void VModelingPointOfContact::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrRadius, radius); - AddAttribute(domElement, AttrCenter, center); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToModeling(domElement); -} - -void VModelingPointOfContact::RemoveReferens() -{ - doc->DecrementReferens(center); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} diff --git a/src/tools/modelingTools/vmodelingpointofcontact.h b/src/tools/modelingTools/vmodelingpointofcontact.h deleted file mode 100644 index df58ee4f2..000000000 --- a/src/tools/modelingTools/vmodelingpointofcontact.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpointofcontact.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGPOINTOFCONTACT_H -#define VMODELINGPOINTOFCONTACT_H - -#include "vmodelingpoint.h" -#include "../../dialogs/dialogpointofcontact.h" - -/** - * @brief The VModelingPointOfContact class - */ -class VModelingPointOfContact : public VModelingPoint -{ - Q_OBJECT -public: - /** - * @brief VModelingPointOfContact - * @param doc dom document container - * @param data - * @param id - * @param radius - * @param center - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingPointOfContact* Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param radius - * @param center - * @param firstPointId - * @param secondPointId - * @param pointName - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 ¢er, - const qint64 &firstPointId, const qint64 &secondPointId, - const QString &pointName, const qreal &mx, const qreal &my, - VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief radius - */ - QString radius; - /** - * @brief center - */ - qint64 center; - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogPointOfContact - */ - QSharedPointer dialogPointOfContact; -}; - -#endif // VMODELINGPOINTOFCONTACT_H diff --git a/src/tools/modelingTools/vmodelingpointofintersection.cpp b/src/tools/modelingTools/vmodelingpointofintersection.cpp deleted file mode 100644 index cfa4006d7..000000000 --- a/src/tools/modelingTools/vmodelingpointofintersection.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpointofintersection.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingpointofintersection.h" - -const QString VModelingPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); - -VModelingPointOfIntersection::VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId), - dialogPointOfIntersection(QSharedPointer()) -{ - ignoreFullUpdate = true; - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingPointOfIntersection::setDialog() -{ - Q_ASSERT(dialogPointOfIntersection.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogPointOfIntersection->setFirstPointId(firstPointId, id); - dialogPointOfIntersection->setSecondPointId(secondPointId, id); - dialogPointOfIntersection->setPointName(p.name()); -} - -VModelingPointOfIntersection *VModelingPointOfIntersection::Create(QSharedPointer &dialog, - VDomDocument *doc, VContainer *data) -{ - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString pointName = dialog->getPointName(); - return Create(0, pointName, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, Tool::FromGui); -} - -VModelingPointOfIntersection *VModelingPointOfIntersection::Create(const qint64 _id, const QString &pointName, - const qint64 &firstPointId, - const qint64 &secondPointId, const qreal &mx, - const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingPointOfIntersection *tool = 0; - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - - QPointF point(firstPoint.x(), secondPoint.y()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); - } - else - { - data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - if (parse == Document::FullParse) - { - tool = new VModelingPointOfIntersection(doc, data, id, firstPointId, secondPointId, typeCreation); - doc->AddTool(id, tool); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - return tool; -} - -void VModelingPointOfIntersection::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id)); -} - -void VModelingPointOfIntersection::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogPointOfIntersection->getPointName()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfIntersection->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfIntersection->getSecondPointId())); - emit FullUpdateTree(); - } - } - dialogPointOfIntersection.clear(); -} - -void VModelingPointOfIntersection::RemoveReferens() -{ - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} - -void VModelingPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogPointOfIntersection, this, event); -} - -void VModelingPointOfIntersection::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToModeling(domElement); -} diff --git a/src/tools/modelingTools/vmodelingpointofintersection.h b/src/tools/modelingTools/vmodelingpointofintersection.h deleted file mode 100644 index 30a5b0d8f..000000000 --- a/src/tools/modelingTools/vmodelingpointofintersection.h +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingpointofintersection.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGPOINTOFINTERSECTION_H -#define VMODELINGPOINTOFINTERSECTION_H - -#include "vmodelingpoint.h" -#include "../../dialogs/dialogpointofintersection.h" - -/** - * @brief The VModelingPointOfIntersection class - */ -class VModelingPointOfIntersection : public VModelingPoint -{ - Q_OBJECT -public: - /** - * @brief VModelingPointOfIntersection - * @param doc dom document container - * @param data - * @param id - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, - const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingPointOfIntersection* Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingPointOfIntersection* Create(const qint64 _id, const QString &pointName, - const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - Q_DISABLE_COPY(VModelingPointOfIntersection) - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogPointOfIntersection - */ - QSharedPointer dialogPointOfIntersection; -}; - -#endif // VMODELINGPOINTOFINTERSECTION_H diff --git a/src/tools/modelingTools/vmodelingshoulderpoint.cpp b/src/tools/modelingTools/vmodelingshoulderpoint.cpp deleted file mode 100644 index 68320fdd2..000000000 --- a/src/tools/modelingTools/vmodelingshoulderpoint.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingshoulderpoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingshoulderpoint.h" -#include "../drawTools/vtoolshoulderpoint.h" -#include "../../container/calculator.h" - -const QString VModelingShoulderPoint::ToolType = QStringLiteral("shoulder"); - -VModelingShoulderPoint::VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &typeLine, const QString &formula, const qint64 &p1Line, - const qint64 &p2Line, const qint64 &pShoulder, const Tool::Sources &typeCreation, - QGraphicsItem * parent) - :VModelingLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), - pShoulder(pShoulder), dialogShoulderPoint(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingShoulderPoint::setDialog() -{ - Q_ASSERT(dialogShoulderPoint.isNull() == false); - VPointF p = VAbstractTool::data.GetPointModeling(id); - dialogShoulderPoint->setTypeLine(typeLine); - dialogShoulderPoint->setFormula(formula); - dialogShoulderPoint->setP1Line(basePointId, id); - dialogShoulderPoint->setP2Line(p2Line, id); - dialogShoulderPoint->setPShoulder(pShoulder, id); - dialogShoulderPoint->setPointName(p.name()); -} - -VModelingShoulderPoint *VModelingShoulderPoint::Create(QSharedPointer &dialog, - VDomDocument *doc, VContainer *data) -{ - QString formula = dialog->getFormula(); - qint64 p1Line = dialog->getP1Line(); - qint64 p2Line = dialog->getP2Line(); - qint64 pShoulder = dialog->getPShoulder(); - QString typeLine = dialog->getTypeLine(); - QString pointName = dialog->getPointName(); - return Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, doc, data, - Document::FullParse, Tool::FromGui); -} - -VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const QString &formula, - const qint64 &p1Line, const qint64 &p2Line, - const qint64 &pShoulder, const QString &typeLine, - const QString &pointName, const qreal &mx, - const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingShoulderPoint *point = 0; - VPointF firstPoint = data->GetPointModeling(p1Line); - VPointF secondPoint = data->GetPointModeling(p2Line); - VPointF shoulderPoint = data->GetPointModeling(pShoulder); - - Calculator cal(data); - QString errorMsg; - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty()) - { - QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), - shoulderPoint.toQPointF(), toPixel(result)); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - } - else - { - data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLine(p1Line, id, Draw::Modeling); - data->AddLine(p2Line, id, Draw::Modeling); - if (parse == Document::FullParse) - { - point = new VModelingShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder, - typeCreation); - doc->AddTool(id, point); - doc->IncrementReferens(p1Line); - doc->IncrementReferens(p2Line); - doc->IncrementReferens(pShoulder); - } - } - return point; -} - -void VModelingShoulderPoint::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formula = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrP1Line, "").toLongLong(); - p2Line = domElement.attribute(AttrP2Line, "").toLongLong(); - pShoulder = domElement.attribute(AttrPShoulder, "").toLongLong(); - } - RefreshGeometry(); -} - -void VModelingShoulderPoint::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogShoulderPoint->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogShoulderPoint->getTypeLine()); - domElement.setAttribute(AttrLength, dialogShoulderPoint->getFormula()); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogShoulderPoint->getP1Line())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogShoulderPoint->getP2Line())); - domElement.setAttribute(AttrPShoulder, QString().setNum(dialogShoulderPoint->getPShoulder())); - emit FullUpdateTree(); - } - } - dialogShoulderPoint.clear(); -} - -void VModelingShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogShoulderPoint, this, event); -} - -void VModelingShoulderPoint::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrP1Line, basePointId); - AddAttribute(domElement, AttrP2Line, p2Line); - AddAttribute(domElement, AttrPShoulder, pShoulder); - - AddToModeling(domElement); -} - -void VModelingShoulderPoint::RemoveReferens() -{ - doc->DecrementReferens(p2Line); - doc->DecrementReferens(pShoulder); - VModelingLinePoint::RemoveReferens(); -} diff --git a/src/tools/modelingTools/vmodelingshoulderpoint.h b/src/tools/modelingTools/vmodelingshoulderpoint.h deleted file mode 100644 index 5fe6f796e..000000000 --- a/src/tools/modelingTools/vmodelingshoulderpoint.h +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingshoulderpoint.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGSHOULDERPOINT_H -#define VMODELINGSHOULDERPOINT_H - -#include "vmodelinglinepoint.h" -#include "../../dialogs/dialogshoulderpoint.h" - -/** - * @brief The VModelingShoulderPoint class - */ -class VModelingShoulderPoint : public VModelingLinePoint -{ - Q_OBJECT -public: - /** - * @brief VModelingShoulderPoint - * @param doc dom document container - * @param data - * @param id - * @param typeLine - * @param formula - * @param p1Line - * @param p2Line - * @param pShoulder - * @param typeCreation - * @param parent - */ - VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, - const QString &formula, const qint64 &p1Line, const qint64 &p2Line, - const qint64 &pShoulder, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingShoulderPoint* Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data); - /** - * @brief Create - * @param _id - * @param formula - * @param p1Line - * @param p2Line - * @param pShoulder - * @param typeLine - * @param pointName - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line, - const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief p2Line - */ - qint64 p2Line; - /** - * @brief pShoulder - */ - qint64 pShoulder; - /** - * @brief dialogShoulderPoint - */ - QSharedPointer dialogShoulderPoint; -}; - -#endif // VMODELINGSHOULDERPOINT_H diff --git a/src/tools/modelingTools/vmodelingspline.cpp b/src/tools/modelingTools/vmodelingspline.cpp deleted file mode 100644 index 9c9be55ba..000000000 --- a/src/tools/modelingTools/vmodelingspline.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingspline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingspline.h" -#include "../../geometry/vspline.h" - -const QString VModelingSpline::TagName = QStringLiteral("spline"); -const QString VModelingSpline::ToolType = QStringLiteral("simple"); - -VModelingSpline::VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem *parent) - :VModelingTool(doc, data, id), QGraphicsPathItem(parent), - dialogSpline(QSharedPointer()), controlPoints(QVector()) -{ - ignoreFullUpdate = true; - VSpline spl = data->GetSplineModeling(id); - QPainterPath path; - path.addPath(spl.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl.GetP2(), - spl.GetPointP1().toQPointF(), this); - connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - connect(this, &VModelingSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine); - connect(this, &VModelingSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint1); - - VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl.GetP3(), - spl.GetPointP4().toQPointF(), this); - connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - connect(this, &VModelingSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine); - connect(this, &VModelingSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint2); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingSpline::setDialog() -{ - Q_ASSERT(dialogSpline.isNull() == false); - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - dialogSpline->setP1(spl.GetP1()); - dialogSpline->setP4(spl.GetP4()); - dialogSpline->setAngle1(spl.GetAngle1()); - dialogSpline->setAngle2(spl.GetAngle2()); - dialogSpline->setKAsm1(spl.GetKasm1()); - dialogSpline->setKAsm2(spl.GetKasm2()); - dialogSpline->setKCurve(spl.GetKcurve()); -} - -VModelingSpline *VModelingSpline::Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data) -{ - qint64 p1 = dialog->getP1(); - qint64 p4 = dialog->getP4(); - qreal kAsm1 = dialog->getKAsm1(); - qreal kAsm2 = dialog->getKAsm2(); - qreal angle1 = dialog->getAngle1(); - qreal angle2 = dialog->getAngle2(); - qreal kCurve = dialog->getKCurve(); - return Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, doc, data, Document::FullParse, - Tool::FromGui); -} - -VModelingSpline *VModelingSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, - const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, - const qreal &angle2, const qreal &kCurve, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingSpline *spl = 0; - VSpline spline = VSpline(data->DataPointsModeling(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddSplineModeling(spline); - } - else - { - data->UpdateSplineModeling(id, spline); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLengthSpline(spline.name(), toMM(spline.GetLength())); - if (parse == Document::FullParse) - { - spl = new VModelingSpline(doc, data, id, typeCreation); - doc->AddTool(id, spl); - doc->IncrementReferens(p1); - doc->IncrementReferens(p4); - } - return spl; -} - -void VModelingSpline::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VModelingSpline::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - VSpline spl = VSpline (VAbstractTool::data.DataPointsModeling(), dialogSpline->getP1(), - dialogSpline->getP4(), dialogSpline->getAngle1(), dialogSpline->getAngle2(), - dialogSpline->getKAsm1(), dialogSpline->getKAsm2(), dialogSpline->getKCurve()); - - disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - controlPoints[0]->setPos(spl.GetP2()); - controlPoints[1]->setPos(spl.GetP3()); - connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - - spl = VSpline (VAbstractTool::data.DataPointsModeling(), dialogSpline->getP1(), - controlPoints[0]->pos(), controlPoints[1]->pos(), dialogSpline->getP4(), - dialogSpline->getKCurve()); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1())); - domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4())); - domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1())); - domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2())); - domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2())); - domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve())); - emit FullUpdateTree(); - } - } - dialogSpline.clear(); -} - -void VModelingSpline::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &pos) -{ - Q_UNUSED(indexSpline); - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - if (position == SplinePoint::FirstPoint) - { - spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); - } - else - { - spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); - } - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1())); - domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2())); - domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2())); - domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve())); - emit FullUpdateTree(); - } -} - -void VModelingSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogSpline, this, event); -} - -void VModelingSpline::AddToFile() -{ - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrPoint1, spl.GetP1()); - AddAttribute(domElement, AttrPoint4, spl.GetP4()); - AddAttribute(domElement, AttrAngle1, spl.GetAngle1()); - AddAttribute(domElement, AttrAngle2, spl.GetAngle2()); - AddAttribute(domElement, AttrKAsm1, spl.GetKasm1()); - AddAttribute(domElement, AttrKAsm2, spl.GetKasm2()); - AddAttribute(domElement, AttrKCurve, spl.GetKcurve()); - - AddToModeling(domElement); -} - -void VModelingSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Spline); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VModelingSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VModelingSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VModelingSpline::RemoveReferens() -{ - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - doc->DecrementReferens(spl.GetP1()); - doc->DecrementReferens(spl.GetP4()); -} - -void VModelingSpline::RefreshGeometry() -{ - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - QPainterPath path; - path.addPath(spl.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - QPointF splinePoint = VAbstractTool::data.GetPointModeling(spl.GetP1()).toQPointF(); - QPointF controlPoint = spl.GetP2(); - emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint); - splinePoint = VAbstractTool::data.GetPointModeling(spl.GetP4()).toQPointF(); - controlPoint = spl.GetP3(); - emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint); - - disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - controlPoints[0]->setPos(spl.GetP2()); - controlPoints[1]->setPos(spl.GetP3()); - connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); - connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSpline::ControlPointChangePosition); -} diff --git a/src/tools/modelingTools/vmodelingspline.h b/src/tools/modelingTools/vmodelingspline.h deleted file mode 100644 index b55dbb005..000000000 --- a/src/tools/modelingTools/vmodelingspline.h +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingspline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGSPLINE_H -#define VMODELINGSPLINE_H - -#include "vmodelingtool.h" -#include -#include "../../dialogs/dialogspline.h" -#include "../../widgets/vcontrolpointspline.h" -#include "../../geometry/vsplinepath.h" - -/** - * @brief The VModelingSpline class - */ -class VModelingSpline:public VModelingTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VModelingSpline - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VModelingSpline (VDomDocument *doc, VContainer *data, qint64 id, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0 ); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingSpline* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param p1 - * @param p4 - * @param kAsm1 - * @param kAsm2 - * @param angle1 - * @param angle2 - * @param kCurve - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingSpline* Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, - const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -signals: - /** - * @brief RefreshLine - * @param indexSpline - * @param position - * @param controlPoint - * @param splinePoint - */ - void RefreshLine (const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &controlPoint, const QPointF &splinePoint ); - /** - * @brief setEnabledPoint - * @param enable - */ - void setEnabledPoint ( bool enable ); -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile (); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui ( int result ); - /** - * @brief ControlPointChangePosition - * @param indexSpline - * @param position - * @param pos - */ - void ControlPointChangePosition (const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &pos); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile (); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogSpline - */ - QSharedPointer dialogSpline; - /** - * @brief controlPoints - */ - QVector controlPoints; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry (); -}; - -#endif // VMODELINGSPLINE_H diff --git a/src/tools/modelingTools/vmodelingsplinepath.cpp b/src/tools/modelingTools/vmodelingsplinepath.cpp deleted file mode 100644 index 012713a78..000000000 --- a/src/tools/modelingTools/vmodelingsplinepath.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingsplinepath.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingsplinepath.h" - -const QString VModelingSplinePath::TagName = QStringLiteral("spline"); -const QString VModelingSplinePath::ToolType = QStringLiteral("path"); - -VModelingSplinePath::VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer()), - controlPoints(QVector()) -{ - ignoreFullUpdate = true; - VSplinePath splPath = data->GetSplinePathModeling(id); - QPainterPath path; - path.addPath(splPath.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePoint::FirstPoint, spl.GetP2(), - spl.GetPointP1().toQPointF(), this); - connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - connect(this, &VModelingSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); - connect(this, &VModelingSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint); - - controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(), - spl.GetPointP4().toQPointF(), this); - connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - connect(this, &VModelingSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); - connect(this, &VModelingSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); - controlPoints.append(controlPoint); - } - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingSplinePath::setDialog() -{ - Q_ASSERT(dialogSplinePath.isNull() == false); - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - dialogSplinePath->SetPath(splPath); -} - -VModelingSplinePath *VModelingSplinePath::Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data) -{ - VSplinePath path = dialog->GetPath(); - for (qint32 i = 0; i < path.CountPoint(); ++i) - { - doc->IncrementReferens(path[i].P()); - } - return Create(0, path, doc, data, Document::FullParse, Tool::FromGui); -} - -VModelingSplinePath * VModelingSplinePath::Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingSplinePath *spl = 0; - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddSplinePathModeling(path); - } - else - { - data->UpdateSplinePathModeling(id, path); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - data->AddLengthSpline(path.name(), toMM(path.GetLength())); - if (parse == Document::FullParse) - { - spl = new VModelingSplinePath(doc, data, id, typeCreation); - doc->AddTool(id, spl); - } - return spl; -} - -void VModelingSplinePath::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VModelingSplinePath::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - VSplinePath splPath = dialogSplinePath->GetPath(); - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - qint32 j = i*2; - disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - controlPoints[j-2]->setPos(spl.GetP2()); - controlPoints[j-1]->setPos(spl.GetP3()); - connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - - spl = VSpline (VAbstractTool::data.DataPointsModeling(), spl.GetP1(), controlPoints[j-2]->pos(), - controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve()); - CorectControlPoints(spl, splPath, i); - CorectControlPoints(spl, splPath, i); - - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); - emit FullUpdateTree(); - } - - } - } - dialogSplinePath.clear(); -} - -void VModelingSplinePath::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &pos) -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - VSpline spl = splPath.GetSpline(indexSpline); - if (position == SplinePoint::FirstPoint) - { - spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); - } - else - { - spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); - } - - CorectControlPoints(spl, splPath, indexSpline); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); - emit FullUpdateTree(); - } -} - -void VModelingSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) -{ - VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint); - p.SetAngle(spl.GetAngle1()); - p.SetKAsm2(spl.GetKasm1()); - splPath.UpdatePoint(indexSpline, SplinePoint::FirstPoint, p); - - p = splPath.GetSplinePoint(indexSpline, SplinePoint::LastPoint); - p.SetAngle(spl.GetAngle2()-180); - p.SetKAsm1(spl.GetKasm2()); - splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p); -} - -void VModelingSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) -{ - QDomNodeList nodeList = node.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement domElement = nodeList.at(i).toElement(); - if (domElement.isNull() == false) - { - VSplinePoint p = path[i]; - domElement.setAttribute(AttrPSpline, QString().setNum(p.P())); - domElement.setAttribute(AttrKAsm1, QString().setNum(p.KAsm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(p.KAsm2())); - domElement.setAttribute(AttrAngle, QString().setNum(p.Angle2())); - } - } -} - -void VModelingSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogSplinePath, this, event); -} - -void VModelingSplinePath::AddToFile() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrKCurve, splPath.getKCurve()); - - for (qint32 i = 0; i < splPath.CountPoint(); ++i) - { - AddPathPoint(domElement, splPath[i]); - } - - AddToModeling(domElement); -} - -void VModelingSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint) -{ - QDomElement pathPoint = doc->createElement(AttrPathPoint); - - AddAttribute(pathPoint, AttrPSpline, splPoint.P()); - AddAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); - AddAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); - AddAttribute(pathPoint, AttrAngle, splPoint.Angle2()); - - domElement.appendChild(pathPoint); -} - -void VModelingSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::SplinePath); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VModelingSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VModelingSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VModelingSplinePath::RemoveReferens() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - for (qint32 i = 0; i < splPath.Count(); ++i) - { - doc->DecrementReferens(splPath[i].P()); - } -} - -void VModelingSplinePath::RefreshGeometry() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - QPainterPath path; - path.addPath(splPath.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); - for (qint32 i = 1; i<=splPath.Count(); ++i) - { - VSpline spl = splPath.GetSpline(i); - QPointF splinePoint = spl.GetPointP1().toQPointF(); - QPointF controlPoint = spl.GetP2(); - emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint); - splinePoint = spl.GetPointP4().toQPointF(); - controlPoint = spl.GetP3(); - emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint); - - qint32 j = i*2; - disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - controlPoints[j-2]->setPos(spl.GetP2()); - controlPoints[j-1]->setPos(spl.GetP3()); - connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this, - &VModelingSplinePath::ControlPointChangePosition); - } -} diff --git a/src/tools/modelingTools/vmodelingsplinepath.h b/src/tools/modelingTools/vmodelingsplinepath.h deleted file mode 100644 index 3a7ebc519..000000000 --- a/src/tools/modelingTools/vmodelingsplinepath.h +++ /dev/null @@ -1,183 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingsplinepath.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGSPLINEPATH_H -#define VMODELINGSPLINEPATH_H - -#include "vmodelingtool.h" -#include -#include "../../dialogs/dialogsplinepath.h" -#include "../../widgets/vcontrolpointspline.h" - -/** - * @brief The VModelingSplinePath class - */ -class VModelingSplinePath:public VModelingTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VModelingSplinePath - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param parent - */ - VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingSplinePath* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param path - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc, - VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief ToolType - */ - static const QString ToolType; -signals: - /** - * @brief RefreshLine - * @param indexSpline - * @param pos - * @param controlPoint - * @param splinePoint - */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, const QPointF &controlPoint, - const QPointF &splinePoint); - /** - * @brief setEnabledPoint - * @param enable - */ - void setEnabledPoint(bool enable); -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); - /** - * @brief ControlPointChangePosition - * @param indexSpline - * @param position - * @param pos - */ - void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &pos); -protected: - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - /** - * @brief dialogSplinePath - */ - QSharedPointer dialogSplinePath; - /** - * @brief controlPoints - */ - QVector controlPoints; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry(); - /** - * @brief AddPathPoint - * @param domElement - * @param splPoint - */ - void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); - /** - * @brief UpdatePathPoint - * @param node - * @param path - */ - void UpdatePathPoint(QDomNode& node, VSplinePath &path); - /** - * @brief CorectControlPoints - * @param spl - * @param splPath - * @param indexSpline - */ - void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline); -}; - -#endif // VMODELINGSPLINEPATH_H diff --git a/src/tools/modelingTools/vmodelingtool.cpp b/src/tools/modelingTools/vmodelingtool.cpp deleted file mode 100644 index d3b8f05fd..000000000 --- a/src/tools/modelingTools/vmodelingtool.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingtool.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingtool.h" -#include - -VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) - :VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false) -{ - _referens = 0; -} - -void VModelingTool::AddToModeling(const QDomElement &domElement) -{ - QDomElement modelingElement; - bool ok = doc->GetActivModelingElement(modelingElement); - if (ok) - { - modelingElement.appendChild(domElement); - } - else - { - qCritical()<<"Can't find tag Modeling"<< Q_FUNC_INFO; - } - emit toolhaveChange(); -} - -void VModelingTool::decrementReferens() -{ - if (_referens > 0) - { - --_referens; - } - if (_referens <= 0) - { - RemoveReferens(); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNode element = domElement.parentNode(); - if (element.isNull() == false) - { - element.removeChild(domElement); - } - } - } -} diff --git a/src/tools/modelingTools/vmodelingtool.h b/src/tools/modelingTools/vmodelingtool.h deleted file mode 100644 index 09c9b17b1..000000000 --- a/src/tools/modelingTools/vmodelingtool.h +++ /dev/null @@ -1,157 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingtool.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGTOOL_H -#define VMODELINGTOOL_H - -#include "../vabstracttool.h" -#include -#include - -/** - * @brief The VModelingTool class - */ -class VModelingTool: public VAbstractTool -{ - Q_OBJECT -public: - /** - * @brief VModelingTool - * @param doc dom document container - * @param data - * @param id - * @param parent - */ - VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); - virtual ~VModelingTool(){} - /** - * @brief setDialog - */ - virtual void setDialog(){} - /** - * @brief ignoreContextMenu - * @param enable - */ - inline void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;} -public slots: - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result)=0; -protected: - /** - * @brief ignoreContextMenuEvent - */ - bool ignoreContextMenuEvent; - /** - * @brief ignoreFullUpdate - */ - bool ignoreFullUpdate; - /** - * @brief AddToModeling - * @param domElement - */ - void AddToModeling(const QDomElement &domElement); - /** - * @brief decrementReferens - */ - virtual void decrementReferens(); - template - /** - * @brief ContextMenu - * @param dialog - * @param tool - * @param event - * @param showRemove - */ - void ContextMenu(QSharedPointer &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event, - bool showRemove = true) - { - if (ignoreContextMenuEvent == false) - { - QMenu menu; - QAction *actionOption = menu.addAction(tr("Option")); - QAction *actionRemove = 0; - if (showRemove) - { - actionRemove = menu.addAction(tr("Delete")); - if (_referens > 1) - { - actionRemove->setEnabled(false); - } - else - { - actionRemove->setEnabled(true); - } - } - QAction *selectedAction = menu.exec(event->screenPos()); - if (selectedAction == actionOption) - { - dialog = QSharedPointer(new Dialog(getData())); - - connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), - &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject); - connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui); - if (ignoreFullUpdate == false) - { - connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList); - } - - tool->setDialog(); - - dialog->show(); - } - if (showRemove) - { - if (selectedAction == actionRemove) - { - //deincrement referens - RemoveReferens(); - //remove form xml file - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomElement element; - bool ok = doc->GetActivCalculationElement(element); - if (ok) - { - element.removeChild(domElement); - //update xml file - emit FullUpdateTree(); - //remove form scene - emit RemoveTool(tool); - } - } - } - } - } - } -}; - -#endif // VMODELINGTOOL_H diff --git a/src/tools/modelingTools/vmodelingtriangle.cpp b/src/tools/modelingTools/vmodelingtriangle.cpp deleted file mode 100644 index 57db01474..000000000 --- a/src/tools/modelingTools/vmodelingtriangle.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingtriangle.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmodelingtriangle.h" -#include "../drawTools/vtooltriangle.h" - -const QString VModelingTriangle::ToolType = QStringLiteral("triangle"); - -VModelingTriangle::VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VModelingPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), - secondPointId(secondPointId), dialogTriangle(QSharedPointer()) -{ - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VModelingTriangle::setDialog() -{ - Q_ASSERT(dialogTriangle.isNull() == false); - VPointF p = VAbstractTool::data.GetPoint(id); - dialogTriangle->setAxisP1Id(axisP1Id, id); - dialogTriangle->setAxisP2Id(axisP2Id, id); - dialogTriangle->setFirstPointId(firstPointId, id); - dialogTriangle->setSecondPointId(secondPointId, id); - dialogTriangle->setPointName(p.name()); -} - -VModelingTriangle *VModelingTriangle::Create(QSharedPointer &dialog, VDomDocument *doc, - VContainer *data) -{ - qint64 axisP1Id = dialog->getAxisP1Id(); - qint64 axisP2Id = dialog->getAxisP2Id(); - qint64 firstPointId = dialog->getFirstPointId(); - qint64 secondPointId = dialog->getSecondPointId(); - QString pointName = dialog->getPointName(); - return Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, - Tool::FromGui); -} - -VModelingTriangle *VModelingTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, - const qint64 &secondPointId, const qreal &mx, const qreal &my, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VModelingTriangle *tool = 0; - VPointF axisP1 = data->GetPoint(axisP1Id); - VPointF axisP2 = data->GetPoint(axisP2Id); - VPointF firstPoint = data->GetPoint(firstPointId); - VPointF secondPoint = data->GetPoint(secondPointId); - - QPointF point = VToolTriangle::FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(), - secondPoint.toQPointF()); - qint64 id = _id; - if (typeCreation == Tool::FromGui) - { - id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); - } - else - { - data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - if (parse == Document::FullParse) - { - tool = new VModelingTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, secondPointId, typeCreation); - doc->AddTool(id, tool); - doc->IncrementReferens(axisP1Id); - doc->IncrementReferens(axisP2Id); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - } - return tool; -} - -void VModelingTriangle::FullUpdateFromFile() -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - axisP1Id = domElement.attribute(AttrAxisP1, "").toLongLong(); - axisP2Id = domElement.attribute(AttrAxisP2, "").toLongLong(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong(); - } - VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id)); -} - -void VModelingTriangle::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrName, dialogTriangle->getPointName()); - domElement.setAttribute(AttrAxisP1, QString().setNum(dialogTriangle->getAxisP1Id())); - domElement.setAttribute(AttrAxisP2, QString().setNum(dialogTriangle->getAxisP2Id())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogTriangle->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogTriangle->getSecondPointId())); - emit FullUpdateTree(); - } - - } - dialogTriangle.clear(); -} - -void VModelingTriangle::RemoveReferens() -{ - doc->DecrementReferens(axisP1Id); - doc->DecrementReferens(axisP2Id); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); -} - -void VModelingTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - ContextMenu(dialogTriangle, this, event); -} - -void VModelingTriangle::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPoint(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point.name()); - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddAttribute(domElement, AttrAxisP1, axisP1Id); - AddAttribute(domElement, AttrAxisP2, axisP2Id); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToModeling(domElement); -} diff --git a/src/tools/modelingTools/vmodelingtriangle.h b/src/tools/modelingTools/vmodelingtriangle.h deleted file mode 100644 index 62ad4e844..000000000 --- a/src/tools/modelingTools/vmodelingtriangle.h +++ /dev/null @@ -1,142 +0,0 @@ -/************************************************************************ - ** - ** @file vmodelingtriangle.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMODELINGTRIANGLE_H -#define VMODELINGTRIANGLE_H - -#include "vmodelingpoint.h" -#include "../drawTools/vtooltriangle.h" -#include "../../dialogs/dialogtriangle.h" - -/** - * @brief The VModelingTriangle class - */ -class VModelingTriangle : public VModelingPoint -{ - Q_OBJECT -public: - /** - * @brief VModelingTriangle - * @param doc dom document container - * @param data - * @param id - * @param axisP1Id - * @param axisP2Id - * @param firstPointId - * @param secondPointId - * @param typeCreation - * @param parent - */ - VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param doc dom document container - * @param data - * @return - */ - static VModelingTriangle* Create(QSharedPointer &dialog, VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param pointName - * @param axisP1Id - * @param axisP2Id - * @param firstPointId - * @param secondPointId - * @param mx - * @param my - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - * @return - */ - static VModelingTriangle* Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, - const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, - const Document::Documents &parse, const Tool::Sources &typeCreation); - /** - * @brief ToolType - */ - static const QString ToolType; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile(); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -protected: - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile - */ - virtual void AddToFile(); -private: - Q_DISABLE_COPY(VModelingTriangle) - /** - * @brief axisP1Id - */ - qint64 axisP1Id; - /** - * @brief axisP2Id - */ - qint64 axisP2Id; - /** - * @brief firstPointId - */ - qint64 firstPointId; - /** - * @brief secondPointId - */ - qint64 secondPointId; - /** - * @brief dialogTriangle - */ - QSharedPointer dialogTriangle; -}; - -#endif // VMODELINGTRIANGLE_H diff --git a/src/tools/nodeDetails/vabstractnode.cpp b/src/tools/nodeDetails/vabstractnode.cpp deleted file mode 100644 index 48374a891..000000000 --- a/src/tools/nodeDetails/vabstractnode.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************ - ** - ** @file vabstractnode.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vabstractnode.h" -#include - -const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); -const QString VAbstractNode::AttrTypeObject = QStringLiteral("typeObject"); -const QString VAbstractNode::TypeObjectCalculation = QStringLiteral("Calculation"); -const QString VAbstractNode::TypeObjectModeling = QStringLiteral("Modeling"); - -VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, Draw::Draws typeobject, - QObject *parent) - : VAbstractTool(doc, data, id, parent), idNode(idNode), typeobject(typeobject) -{ - _referens = 0; -} - -void VAbstractNode::AddToModeling(const QDomElement &domElement) -{ - QDomElement modelingElement; - bool ok = doc->GetActivModelingElement(modelingElement); - if (ok) - { - modelingElement.appendChild(domElement); - } - else - { - qCritical()< 0) - { - --_referens; - } - if (_referens <= 0) - { - doc->DecrementReferens(idNode); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNode element = domElement.parentNode(); - if (element.isNull() == false) - { - element.removeChild(domElement); - } - } - } -} diff --git a/src/tools/nodeDetails/vnodearc.cpp b/src/tools/nodeDetails/vnodearc.cpp deleted file mode 100644 index 27ebfdea5..000000000 --- a/src/tools/nodeDetails/vnodearc.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************ - ** - ** @file vnodearc.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vnodearc.h" - -#include - -const QString VNodeArc::TagName = QStringLiteral("arc"); -const QString VNodeArc::ToolType = QStringLiteral("modeling"); - -VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem * parent) - :VAbstractNode(doc, data, id, idArc, typeobject), QGraphicsPathItem(parent) -{ - RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Draw::Draws &typeobject, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - if (parse == Document::FullParse) - { - VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeobject, typeCreation); - Q_ASSERT(arc != 0); - doc->AddTool(id, arc); - doc->IncrementReferens(idArc); - } - else - { - doc->UpdateToolData(id, data); - } -} - -void VNodeArc::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VNodeArc::AddToFile() -{ - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); - if (typeobject == Draw::Calculation) - { - AddAttribute(domElement, AttrTypeObject, TypeObjectCalculation); - } - else - { - AddAttribute(domElement, AttrTypeObject, ToolType ); - } - - AddToModeling(domElement); -} - -void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Arc); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VNodeArc::RefreshGeometry() -{ - VArc arc = VAbstractTool::data.GetArcModeling(id); - QPainterPath path; - path.addPath(arc.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); -} diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp deleted file mode 100644 index f1ed87dc3..000000000 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************ - ** - ** @file vnodepoint.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vnodepoint.h" - -#include - -const QString VNodePoint::TagName = QStringLiteral("point"); -const QString VNodePoint::ToolType = QStringLiteral("modeling"); - -VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem *parent) - :VAbstractNode(doc, data, id, idPoint, typeobject), QGraphicsEllipseItem(parent), radius(toPixel(1.5)), - namePoint(0), lineName(0) -{ - namePoint = new VGraphicsSimpleTextItem(this); - lineName = new QGraphicsLineItem(this); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VNodePoint::NameChangePosition); - this->setPen(QPen(Qt::black, widthHairLine)); - this->setBrush(QBrush(Qt::NoBrush)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id)); - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, const Draw::Draws &typeobject, - const Document::Documents &parse, const Tool::Sources &typeCreation) -{ - if (parse == Document::FullParse) - { - VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeobject, typeCreation); - Q_ASSERT(point != 0); - doc->AddTool(id, point); - doc->IncrementReferens(idPoint); - } - else - { - doc->UpdateToolData(id, data); - } -} - -void VNodePoint::FullUpdateFromFile() -{ - RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id)); -} - -void VNodePoint::AddToFile() -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); - if (typeobject == Draw::Calculation) - { - AddAttribute(domElement, AttrTypeObject, TypeObjectCalculation); - } - else - { - AddAttribute(domElement, AttrTypeObject, TypeObjectModeling); - } - AddAttribute(domElement, AttrMx, toMM(point.mx())); - AddAttribute(domElement, AttrMy, toMM(point.my())); - - AddToModeling(domElement); -} - -void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Point); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - - -void VNodePoint::NameChangePosition(const QPointF &pos) -{ - VPointF point = VAbstractTool::data.GetPointModeling(id); - QPointF p = pos - this->pos(); - point.setMx(p.x()); - point.setMy(p.y()); - RefreshLine(); - UpdateNamePosition(point.mx(), point.my()); - VAbstractTool::data.UpdatePoint(id, point); -} - -void VNodePoint::UpdateNamePosition(qreal mx, qreal my) -{ - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrMx, QString().setNum(toMM(mx))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(my))); - emit toolhaveChange(); - } -} - -void VNodePoint::RefreshPointGeometry(const VPointF &point) -{ - QRectF rec = QRectF(0, 0, radius*2, radius*2); - rec.translate(-rec.center().x(), -rec.center().y()); - this->setRect(rec); - this->setPos(point.toQPointF()); - disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VNodePoint::NameChangePosition); - namePoint->setText(point.name()); - namePoint->setPos(QPointF(point.mx(), point.my())); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VNodePoint::NameChangePosition); - - RefreshLine(); -} - -void VNodePoint::RefreshLine() -{ - QRectF nameRec = namePoint->sceneBoundingRect(); - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); - QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); - lineName->setLine(QLineF(p1, pRec - scenePos())); - if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4)) - { - lineName->setVisible(false); - } - else - { - lineName->setVisible(true); - } -} diff --git a/src/tools/nodeDetails/vnodespline.cpp b/src/tools/nodeDetails/vnodespline.cpp deleted file mode 100644 index ac89eaac7..000000000 --- a/src/tools/nodeDetails/vnodespline.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************ - ** - ** @file vnodespline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vnodespline.h" - -#include - -const QString VNodeSpline::TagName = QStringLiteral("spline"); -const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline"); - -VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, Draw::Draws typeobject, - const Tool::Sources &typeCreation, QGraphicsItem * parent) - :VAbstractNode(doc, data, id, idSpline, typeobject), QGraphicsPathItem(parent) -{ - RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, - const Draw::Draws &typeobject, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - VNodeSpline *spl = 0; - if (parse == Document::FullParse) - { - spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation); - doc->AddTool(id, spl); - doc->IncrementReferens(idSpline); - } - else - { - doc->UpdateToolData(id, data); - } - return spl; -} - -void VNodeSpline::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VNodeSpline::AddToFile() -{ - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); - if (typeobject == Draw::Calculation) - { - AddAttribute(domElement, AttrTypeObject, TypeObjectCalculation); - } - else - { - AddAttribute(domElement, AttrTypeObject, TypeObjectModeling); - } - - AddToModeling(domElement); -} - -void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Spline); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VNodeSpline::RefreshGeometry() -{ - VSpline spl = VAbstractTool::data.GetSplineModeling(id); - QPainterPath path; - path.addPath(spl.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); -} diff --git a/src/tools/nodeDetails/vnodesplinepath.cpp b/src/tools/nodeDetails/vnodesplinepath.cpp deleted file mode 100644 index 250581c2d..000000000 --- a/src/tools/nodeDetails/vnodesplinepath.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************ - ** - ** @file vnodesplinepath.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vnodesplinepath.h" - -#include - -const QString VNodeSplinePath::TagName = QStringLiteral("spline"); -const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath"); - -VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, - Draw::Draws typeobject, const Tool::Sources &typeCreation, QGraphicsItem * parent) - :VAbstractNode(doc, data, id, idSpline, typeobject), QGraphicsPathItem(parent) -{ - RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setAcceptHoverEvents(true); - - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, - const Draw::Draws &typeobject, const Document::Documents &parse, - const Tool::Sources &typeCreation) -{ - if (parse == Document::FullParse) - { - VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeobject, typeCreation); - Q_ASSERT(splPath != 0); - doc->AddTool(id, splPath); - VSplinePath path = data->GetSplinePathModeling(id); - const QVector *points = path.GetPoint(); - for (qint32 i = 0; isize(); ++i) - { - doc->IncrementReferens(points->at(i).P()); - } - } - else - { - doc->UpdateToolData(id, data); - } -} - -void VNodeSplinePath::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VNodeSplinePath::AddToFile() -{ - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); - if (typeobject == Draw::Calculation) - { - AddAttribute(domElement, AttrTypeObject, TypeObjectCalculation); - } - else - { - AddAttribute(domElement, AttrTypeObject, TypeObjectModeling); - } - - AddToModeling(domElement); -} - -void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::SplinePath); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); -} - -void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); -} - -void VNodeSplinePath::RefreshGeometry() -{ - VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id); - QPainterPath path; - path.addPath(splPath.GetPath()); - path.setFillRule( Qt::WindingFill ); - this->setPath(path); -} diff --git a/src/tools/tools.pri b/src/tools/tools.pri deleted file mode 100644 index 513853538..000000000 --- a/src/tools/tools.pri +++ /dev/null @@ -1,93 +0,0 @@ -HEADERS += \ - src/tools/vtooldetail.h \ - src/tools/vdatatool.h \ - src/tools/vabstracttool.h \ - src/tools/tools.h \ - src/tools/drawTools/vtooltriangle.h \ - src/tools/drawTools/vtoolsplinepath.h \ - src/tools/drawTools/vtoolspline.h \ - src/tools/drawTools/vtoolsinglepoint.h \ - src/tools/drawTools/vtoolshoulderpoint.h \ - src/tools/drawTools/vtoolpointofintersection.h \ - src/tools/drawTools/vtoolpointofcontact.h \ - src/tools/drawTools/vtoolpoint.h \ - src/tools/drawTools/vtoolnormal.h \ - src/tools/drawTools/vtoollinepoint.h \ - src/tools/drawTools/vtoollineintersect.h \ - src/tools/drawTools/vtoolline.h \ - src/tools/drawTools/vtoolheight.h \ - src/tools/drawTools/vtoolendline.h \ - src/tools/drawTools/vtoolbisector.h \ - src/tools/drawTools/vtoolarc.h \ - src/tools/drawTools/vtoolalongline.h \ - src/tools/drawTools/vdrawtool.h \ - src/tools/drawTools/drawtools.h \ - src/tools/modelingTools/vmodelingtriangle.h \ - src/tools/modelingTools/vmodelingtool.h \ - src/tools/modelingTools/vmodelingsplinepath.h \ - src/tools/modelingTools/vmodelingspline.h \ - src/tools/modelingTools/vmodelingshoulderpoint.h \ - src/tools/modelingTools/vmodelingpointofintersection.h \ - src/tools/modelingTools/vmodelingpointofcontact.h \ - src/tools/modelingTools/vmodelingpoint.h \ - src/tools/modelingTools/vmodelingnormal.h \ - src/tools/modelingTools/vmodelinglinepoint.h \ - src/tools/modelingTools/vmodelinglineintersect.h \ - src/tools/modelingTools/vmodelingline.h \ - src/tools/modelingTools/vmodelingheight.h \ - src/tools/modelingTools/vmodelingendline.h \ - src/tools/modelingTools/vmodelingbisector.h \ - src/tools/modelingTools/vmodelingarc.h \ - src/tools/modelingTools/vmodelingalongline.h \ - src/tools/modelingTools/modelingtools.h \ - src/tools/nodeDetails/vnodesplinepath.h \ - src/tools/nodeDetails/vnodespline.h \ - src/tools/nodeDetails/vnodepoint.h \ - src/tools/nodeDetails/vnodearc.h \ - src/tools/nodeDetails/vabstractnode.h \ - src/tools/nodeDetails/nodedetails.h - -SOURCES += \ - src/tools/vtooldetail.cpp \ - src/tools/vdatatool.cpp \ - src/tools/vabstracttool.cpp \ - src/tools/drawTools/vtooltriangle.cpp \ - src/tools/drawTools/vtoolsplinepath.cpp \ - src/tools/drawTools/vtoolspline.cpp \ - src/tools/drawTools/vtoolsinglepoint.cpp \ - src/tools/drawTools/vtoolshoulderpoint.cpp \ - src/tools/drawTools/vtoolpointofintersection.cpp \ - src/tools/drawTools/vtoolpointofcontact.cpp \ - src/tools/drawTools/vtoolpoint.cpp \ - src/tools/drawTools/vtoolnormal.cpp \ - src/tools/drawTools/vtoollinepoint.cpp \ - src/tools/drawTools/vtoollineintersect.cpp \ - src/tools/drawTools/vtoolline.cpp \ - src/tools/drawTools/vtoolheight.cpp \ - src/tools/drawTools/vtoolendline.cpp \ - src/tools/drawTools/vtoolbisector.cpp \ - src/tools/drawTools/vtoolarc.cpp \ - src/tools/drawTools/vtoolalongline.cpp \ - src/tools/drawTools/vdrawtool.cpp \ - src/tools/modelingTools/vmodelingtriangle.cpp \ - src/tools/modelingTools/vmodelingtool.cpp \ - src/tools/modelingTools/vmodelingsplinepath.cpp \ - src/tools/modelingTools/vmodelingspline.cpp \ - src/tools/modelingTools/vmodelingshoulderpoint.cpp \ - src/tools/modelingTools/vmodelingpointofintersection.cpp \ - src/tools/modelingTools/vmodelingpointofcontact.cpp \ - src/tools/modelingTools/vmodelingpoint.cpp \ - src/tools/modelingTools/vmodelingnormal.cpp \ - src/tools/modelingTools/vmodelinglinepoint.cpp \ - src/tools/modelingTools/vmodelinglineintersect.cpp \ - src/tools/modelingTools/vmodelingline.cpp \ - src/tools/modelingTools/vmodelingheight.cpp \ - src/tools/modelingTools/vmodelingendline.cpp \ - src/tools/modelingTools/vmodelingbisector.cpp \ - src/tools/modelingTools/vmodelingarc.cpp \ - src/tools/modelingTools/vmodelingalongline.cpp \ - src/tools/nodeDetails/vnodesplinepath.cpp \ - src/tools/nodeDetails/vnodespline.cpp \ - src/tools/nodeDetails/vnodepoint.cpp \ - src/tools/nodeDetails/vnodearc.cpp \ - src/tools/nodeDetails/vabstractnode.cpp diff --git a/src/tools/vabstracttool.cpp b/src/tools/vabstracttool.cpp deleted file mode 100644 index 0d52f3faf..000000000 --- a/src/tools/vabstracttool.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/************************************************************************ - ** - ** @file vabstracttool.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vabstracttool.h" - -const QString VAbstractTool::AttrId = QStringLiteral("id"); -const QString VAbstractTool::AttrType = QStringLiteral("type"); -const QString VAbstractTool::AttrMx = QStringLiteral("mx"); -const QString VAbstractTool::AttrMy = QStringLiteral("my"); -const QString VAbstractTool::AttrName = QStringLiteral("name"); -const QString VAbstractTool::AttrX = QStringLiteral("x"); -const QString VAbstractTool::AttrY = QStringLiteral("y"); -const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine"); -const QString VAbstractTool::AttrLength = QStringLiteral("length"); -const QString VAbstractTool::AttrBasePoint = QStringLiteral("basePoint"); -const QString VAbstractTool::AttrFirstPoint = QStringLiteral("firstPoint"); -const QString VAbstractTool::AttrSecondPoint = QStringLiteral("secondPoint"); -const QString VAbstractTool::AttrThirdPoint = QStringLiteral("thirdPoint"); -const QString VAbstractTool::AttrCenter = QStringLiteral("center"); -const QString VAbstractTool::AttrRadius = QStringLiteral("radius"); -const QString VAbstractTool::AttrAngle = QStringLiteral("angle"); -const QString VAbstractTool::AttrAngle1 = QStringLiteral("angle1"); -const QString VAbstractTool::AttrAngle2 = QStringLiteral("angle2"); -const QString VAbstractTool::AttrP1Line = QStringLiteral("p1Line"); -const QString VAbstractTool::AttrP2Line = QStringLiteral("p2Line"); -const QString VAbstractTool::AttrP1Line1 = QStringLiteral("p1Line1"); -const QString VAbstractTool::AttrP2Line1 = QStringLiteral("p2Line1"); -const QString VAbstractTool::AttrP1Line2 = QStringLiteral("p1Line2"); -const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2"); -const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder"); -const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1"); -const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4"); -const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1"); -const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2"); -const QString VAbstractTool::AttrKCurve = QStringLiteral("kCurve"); -const QString VAbstractTool::AttrPathPoint = QStringLiteral("pathPoint"); -const QString VAbstractTool::AttrPSpline = QStringLiteral("pSpline"); -const QString VAbstractTool::AttrAxisP1 = QStringLiteral("axisP1"); -const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2"); -const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); -const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); - -VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) - :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black) -{ - connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange); - connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); - connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree); -} - -QPointF VAbstractTool::LineIntersectRect(QRectF rec, QLineF line) -{ - qreal x1, y1, x2, y2; - rec.getCoords(&x1, &y1, &x2, &y2); - QPointF point; - QLineF::IntersectType type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - type = line.intersect(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - type = line.intersect(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - type = line.intersect(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - Q_ASSERT_X(type != QLineF::BoundedIntersection, Q_FUNC_INFO, "There is no point of intersection."); - return point; -} - -qint32 VAbstractTool::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, - QPointF &p2) -{ - const qreal eps = 1e-8; - //коефіцієнти для рівняння відрізку - qreal a = 0, b = 0, c = 0; - LineCoefficients(line, &a, &b, &c); - // проекция центра окружности на прямую - QPointF p = ClosestPoint (line, center); - // сколько всего решений? - qint32 flag = 0; - qreal d = QLineF (center, p).length(); - if (qAbs (d - radius) <= eps) - { - flag = 1; - } - else - { - if (radius > d) - { - flag = 2; - } - else - { - return 0; - } - } - // находим расстояние от проекции до точек пересечения - qreal k = sqrt (radius * radius - d * d); - qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length(); - // добавляем к проекции векторы направленные к точкам пеерсечения - p1 = addVector (p, QPointF (0, 0), QPointF (- b, a), k / t); - p2 = addVector (p, QPointF (0, 0), QPointF (b, - a), k / t); - return flag; -} - -QPointF VAbstractTool::ClosestPoint(const QLineF &line, const QPointF &p) -{ - QLineF lineP2pointFrom = QLineF(line.p2(), p); - qreal angle = 180-line.angleTo(lineP2pointFrom)-90; - QLineF pointFromlineP2 = QLineF(p, line.p2()); - pointFromlineP2.setAngle(pointFromlineP2.angle()+angle); - QPointF point; - QLineF::IntersectType type = pointFromlineP2.intersect(line, &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - else - { - if ( type == QLineF::NoIntersection || type == QLineF::UnboundedIntersection ) - { - Q_ASSERT_X(type != QLineF::BoundedIntersection, Q_FUNC_INFO, "Don't have point of intersection."); - return point; - } - } - return point; -} - -QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k) -{ - return QPointF (p.x() + (p2.x() - p1.x()) * k, p.y() + (p2.y() - p1.y()) * k); -} - -void VAbstractTool::RemoveAllChild(QDomElement &domElement) -{ - if ( domElement.hasChildNodes() ) - { - while ( domElement.childNodes().length() >= 1 ) - { - domElement.removeChild( domElement.firstChild() ); - } - } -} - -void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c) -{ - //коефіцієнти для рівняння відрізку - QPointF p1 = line.p1(); - *a = line.p2().y() - p1.y(); - *b = p1.x() - line.p2().x(); - *c = - *a * p1.x() - *b * p1.y(); -} diff --git a/src/tools/vabstracttool.h b/src/tools/vabstracttool.h deleted file mode 100644 index 038b3e2d4..000000000 --- a/src/tools/vabstracttool.h +++ /dev/null @@ -1,326 +0,0 @@ -/************************************************************************ - ** - ** @file vabstracttool.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VABSTRACTTOOL_H -#define VABSTRACTTOOL_H - -#include "vdatatool.h" -#include "../xml/vdomdocument.h" - -/** - * @brief The VAbstractTool class - */ -class VAbstractTool: public VDataTool -{ - Q_OBJECT -public: - /** - * @brief VAbstractTool - * @param doc dom document container - * @param data - * @param id - * @param parent - */ - VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); - virtual ~VAbstractTool() {} - /** - * @brief LineIntersectRect - * @param rec - * @param line - * @return - */ - static QPointF LineIntersectRect(QRectF rec, QLineF line); - /** - * @brief LineIntersectCircle - * @param center - * @param radius - * @param line - * @param p1 - * @param p2 - * @return - */ - static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, - QPointF &p2); - /** - * @brief ClosestPoint - * @param line - * @param p - * @return - */ - static QPointF ClosestPoint(const QLineF &line, const QPointF &p); - /** - * @brief addVector - * @param p - * @param p1 - * @param p2 - * @param k - * @return - */ - static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k); - /** - * @brief getId - * @return - */ - inline qint64 getId() const {return id;} - /** - * @brief LineCoefficients - * @param line - * @param a - * @param b - * @param c - */ - static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c); - /** - * @brief AttrId - */ - static const QString AttrId; - /** - * @brief AttrType - */ - static const QString AttrType; - /** - * @brief AttrMx - */ - static const QString AttrMx; - /** - * @brief AttrMy - */ - static const QString AttrMy; - /** - * @brief AttrName - */ - static const QString AttrName; - /** - * @brief AttrX - */ - static const QString AttrX; - /** - * @brief AttrY - */ - static const QString AttrY; - /** - * @brief AttrTypeLine - */ - static const QString AttrTypeLine; - /** - * @brief AttrLength - */ - static const QString AttrLength; - /** - * @brief AttrBasePoint - */ - static const QString AttrBasePoint; - /** - * @brief AttrFirstPoint - */ - static const QString AttrFirstPoint; - /** - * @brief AttrSecondPoint - */ - static const QString AttrSecondPoint; - /** - * @brief AttrThirdPoint - */ - static const QString AttrThirdPoint; - /** - * @brief AttrCenter - */ - static const QString AttrCenter; - /** - * @brief AttrRadius - */ - static const QString AttrRadius; - /** - * @brief AttrAngle - */ - static const QString AttrAngle; - /** - * @brief AttrAngle1 - */ - static const QString AttrAngle1; - /** - * @brief AttrAngle2 - */ - static const QString AttrAngle2; - /** - * @brief AttrP1Line - */ - static const QString AttrP1Line; - /** - * @brief AttrP2Line - */ - static const QString AttrP2Line; - /** - * @brief AttrP1Line1 - */ - static const QString AttrP1Line1; - /** - * @brief AttrP2Line1 - */ - static const QString AttrP2Line1; - /** - * @brief AttrP1Line2 - */ - static const QString AttrP1Line2; - /** - * @brief AttrP2Line2 - */ - static const QString AttrP2Line2; - /** - * @brief AttrPShoulder - */ - static const QString AttrPShoulder; - /** - * @brief AttrPoint1 - */ - static const QString AttrPoint1; - /** - * @brief AttrPoint4 - */ - static const QString AttrPoint4; - /** - * @brief AttrKAsm1 - */ - static const QString AttrKAsm1; - /** - * @brief AttrKAsm2 - */ - static const QString AttrKAsm2; - /** - * @brief AttrKCurve - */ - static const QString AttrKCurve; - /** - * @brief AttrPathPoint - */ - static const QString AttrPathPoint; - /** - * @brief AttrPSpline - */ - static const QString AttrPSpline; - /** - * @brief AttrAxisP1 - */ - static const QString AttrAxisP1; - /** - * @brief AttrAxisP2 - */ - static const QString AttrAxisP2; - /** - * @brief TypeLineNone - */ - static const QString TypeLineNone; - /** - * @brief TypeLineLine - */ - static const QString TypeLineLine; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile()=0; -signals: - /** - * @brief toolhaveChange - */ - void toolhaveChange(); - /** - * @brief ChoosedTool - * @param id - * @param type - */ - void ChoosedTool(qint64 id, Scene::Scenes type); - /** - * @brief FullUpdateTree - */ - void FullUpdateTree(); - /** - * @brief RemoveTool - * @param tool - */ - void RemoveTool(QGraphicsItem *tool); -protected: - /** - * @brief doc dom document container - */ - VDomDocument *doc; - /** - * @brief id - */ - const qint64 id; - /** - * @brief baseColor - */ - const Qt::GlobalColor baseColor; - /** - * @brief currentColor - */ - Qt::GlobalColor currentColor; - /** - * @brief AddToFile - */ - virtual void AddToFile()=0; - /** - * @brief getData - * @return - */ - inline const VContainer *getData() const {return &data;} - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(){} - /** - * @brief RemoveAllChild - * @param domElement - */ - void RemoveAllChild(QDomElement &domElement); - template - /** - * @brief AddAttribute - * @param domElement - * @param name - * @param value - */ - void AddAttribute(QDomElement &domElement, const QString &name, const T &value) - { - QDomAttr domAttr = doc->createAttribute(name); - domAttr.setValue(QString().setNum(value)); - domElement.setAttributeNode(domAttr); - } -private: - Q_DISABLE_COPY(VAbstractTool) -}; - -template <> -inline void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const QString &value) -{ - QDomAttr domAttr = doc->createAttribute(name); - domAttr.setValue(value); - domElement.setAttributeNode(domAttr); -} -#endif // VABSTRACTTOOL_H diff --git a/src/tools/vdatatool.h b/src/tools/vdatatool.h deleted file mode 100644 index a7b0cfcf5..000000000 --- a/src/tools/vdatatool.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************ - ** - ** @file vdatatool.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VDATATOOL_H -#define VDATATOOL_H - -#include "../container/vcontainer.h" - -//We need QObject class because we use qobject_cast. -/** - * @brief The VDataTool class - */ -class VDataTool : public QObject -{ - Q_OBJECT -public: - /** - * @brief VDataTool - * @param data - * @param parent - */ - VDataTool(VContainer *data, QObject *parent = 0): QObject(parent), data(*data), _referens(1){} - virtual ~VDataTool(){} - /** - * @brief operator = - * @param tool - * @return - */ - VDataTool &operator= (const VDataTool &tool); - /** - * @brief getData - * @return - */ - inline VContainer getData() const { return data; } - /** - * @brief setData - * @param value - */ - inline void setData(const VContainer *value) {data = *value;} - /** - * @brief referens - * @return - */ - virtual inline qint64 referens() const {return _referens;} - /** - * @brief incrementReferens - */ - virtual inline void incrementReferens(){++_referens;} - /** - * @brief decrementReferens - */ - virtual void decrementReferens(); -protected: - /** - * @brief data container with data - */ - VContainer data; - /** - * @brief _referens - */ - qint64 _referens; -}; - -#endif // VDATATOOL_H diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp deleted file mode 100644 index aeffdcee5..000000000 --- a/src/tools/vtooldetail.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/************************************************************************ - ** - ** @file vtooldetail.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vtooldetail.h" -#include "nodeDetails/nodedetails.h" -#include "modelingTools/vmodelingtool.h" -#include "modelingTools/modelingtools.h" - -const QString VToolDetail::TagName = QStringLiteral("detail"); -const QString VToolDetail::TagNode = QStringLiteral("node"); -const QString VToolDetail::AttrSupplement = QStringLiteral("supplement"); -const QString VToolDetail::AttrClosed = QStringLiteral("closed"); -const QString VToolDetail::AttrWidth = QStringLiteral("width"); -const QString VToolDetail::AttrIdObject = QStringLiteral("idObject"); -const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType"); -const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); -const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); - -VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, const Tool::Sources &typeCreation, - VMainGraphicsScene *scene, QGraphicsItem *parent) - :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer()), - sceneDetails(scene) -{ - VDetail detail = data->GetDetail(id); - for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) - { - switch (detail[i].getTypeTool()) - { - case (Tool::NodePoint): - InitTool(scene, detail[i]); - break; - case (Tool::NodeArc): - InitTool(scene, detail[i]); - break; - case (Tool::NodeSpline): - InitTool(scene, detail[i]); - break; - case (Tool::NodeSplinePath): - InitTool(scene, detail[i]); - break; - case (Tool::AlongLineTool): - InitTool(scene, detail[i]); - break; - case (Tool::ArcTool): - InitTool(scene, detail[i]); - break; - case (Tool::BisectorTool): - InitTool(scene, detail[i]); - break; - case (Tool::EndLineTool): - InitTool(scene, detail[i]); - break; - case (Tool::LineIntersectTool): - InitTool(scene, detail[i]); - break; - case (Tool::LineTool): - InitTool(scene, detail[i]); - break; - case (Tool::NormalTool): - InitTool(scene, detail[i]); - break; - case (Tool::PointOfContact): - InitTool(scene, detail[i]); - break; - case (Tool::ShoulderPointTool): - InitTool(scene, detail[i]); - break; - case (Tool::SplinePathTool): - InitTool(scene, detail[i]); - break; - case (Tool::SplineTool): - InitTool(scene, detail[i]); - break; - case (Tool::Height): - InitTool(scene, detail[i]); - break; - case (Tool::Triangle): - InitTool(scene, detail[i]); - break; - case (Tool::PointOfIntersection): - InitTool(scene, detail[i]); - break; - default: - qWarning()<<"Get wrong tool type. Ignore."; - break; - } - doc->IncrementReferens(detail[i].getId()); - } - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - RefreshGeometry(); - this->setPos(detail.getMx(), detail.getMy()); - this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - if (typeCreation == Tool::FromGui) - { - AddToFile(); - } -} - -void VToolDetail::setDialog() -{ - Q_ASSERT(dialogDetail.isNull() == false); - VDetail detail = VAbstractTool::data.GetDetail(id); - dialogDetail->setDetails(detail); -} - -void VToolDetail::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, VDomDocument *doc, - VContainer *data) -{ - VDetail detail = dialog->getDetails(); - VDetail det; - for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) - { - qint64 id = 0; - switch (detail[i].getTypeTool()) - { - case (Tool::NodePoint): - { - VPointF point; - if (detail[i].getMode() == Draw::Calculation) - { - point = data->GetPoint(detail[i].getId()); - } - else - { - point = data->GetPointModeling(detail[i].getId()); - } - id = data->AddPointModeling(point); - VNodePoint::Create(doc, data, id, detail[i].getId(), detail[i].getMode(), - Document::FullParse, Tool::FromGui); - } - break; - case (Tool::NodeArc): - { - VArc arc; - if (detail[i].getMode() == Draw::Calculation) - { - arc = data->GetArc(detail[i].getId()); - } - else - { - arc = data->GetArcModeling(detail[i].getId()); - } - id = data->AddArcModeling(arc); - VNodeArc::Create(doc, data, id, detail[i].getId(), detail[i].getMode(), - Document::FullParse, Tool::FromGui); - } - break; - case (Tool::NodeSpline): - { - VSpline spline; - if (detail[i].getMode() == Draw::Calculation) - { - spline = data->GetSpline(detail[i].getId()); - } - else - { - spline = data->GetSplineModeling(detail[i].getId()); - } - id = data->AddSplineModeling(spline); - VNodeSpline::Create(doc, data, id, detail[i].getId(), detail[i].getMode(), - Document::FullParse, Tool::FromGui); - } - break; - case (Tool::NodeSplinePath): - { - VSplinePath splinePath; - if (detail[i].getMode() == Draw::Calculation) - { - splinePath = data->GetSplinePath(detail[i].getId()); - } - else - { - splinePath = data->GetSplinePathModeling(detail[i].getId()); - } - id = data->AddSplinePathModeling(splinePath); - VNodeSplinePath::Create(doc, data, id, detail[i].getId(), detail[i].getMode(), - Document::FullParse, Tool::FromGui); - } - break; - default: - qWarning()<<"May be wrong tool type!!! Ignoring."<AddDetail(newDetail); - } - else - { - data->UpdateDetail(id, newDetail); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } - if (parse == Document::FullParse) - { - VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene); - scene->addItem(detail); - connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - QHash* tools = doc->getTools(); - tools->insert(id, detail); - } -} - -void VToolDetail::FullUpdateFromFile() -{ - RefreshGeometry(); -} - -void VToolDetail::FullUpdateFromGui(int result) -{ - if (result == QDialog::Accepted) - { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - VDetail det = dialogDetail->getDetails(); - domElement.setAttribute(AttrName, det.getName()); - domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement())); - domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed())); - domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth())); - RemoveAllChild(domElement); - for (ptrdiff_t i = 0; i < det.CountNode(); ++i) - { - AddNode(domElement, det[i]); - } - emit FullUpdateTree(); - } - } - dialogDetail.clear(); -} - -void VToolDetail::AddToFile() -{ - VDetail detail = VAbstractTool::data.GetDetail(id); - QDomElement domElement = doc->createElement(TagName); - - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrName, detail.getName()); - AddAttribute(domElement, AttrMx, toMM(detail.getMx())); - AddAttribute(domElement, AttrMy, toMM(detail.getMy())); - AddAttribute(domElement, AttrSupplement, detail.getSupplement()); - AddAttribute(domElement, AttrClosed, detail.getClosed()); - AddAttribute(domElement, AttrWidth, detail.getWidth()); - - for (ptrdiff_t i = 0; i < detail.CountNode(); ++i) - { - AddNode(domElement, detail[i]); - } - - QDomElement element; - bool ok = doc->GetActivDetailsElement(element); - if (ok) - { - element.appendChild(domElement); - } -} - -QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionHasChanged && scene()) - { - // value - это новое положение. - QPointF newPos = value.toPointF(); - //qDebug()<elementById(QString().setNum(id)); - if (domElement.isElement()) - { - domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x()))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y()))); - //I don't now why but signal does not work. - doc->FullUpdateTree(); - } - } - return QGraphicsItem::itemChange(change, value); -} - -void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - emit ChoosedTool(id, Scene::Detail); - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - QMenu menu; - QAction *actionOption = menu.addAction(tr("Options")); - QAction *actionRemove = menu.addAction(tr("Delete")); - if (_referens > 1) - { - actionRemove->setEnabled(false); - } - else - { - actionRemove->setEnabled(true); - } - QAction *selectedAction = menu.exec(event->screenPos()); - if (selectedAction == actionOption) - { - dialogDetail = QSharedPointer(new DialogDetail(getData(), Draw::Modeling)); - connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject, - dialogDetail.data(), &DialogDetail::ChoosedObject); - connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &VToolDetail::FullUpdateFromGui); - setDialog(); - dialogDetail->show(); - } - if (selectedAction == actionRemove) - { - //remove form xml file - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNode element = domElement.parentNode(); - if (element.isNull() == false) - { - //deincrement referens - RemoveReferens(); - element.removeChild(domElement); - //update xml file - emit FullUpdateTree(); - //remove form scene - emit RemoveTool(this); - } - else - { - qWarning()<<"parentNode isNull"<setPath(path); -} - -template -void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) -{ - QHash* tools = doc->getTools(); - Q_ASSERT(tools != 0); - Tool *tool = qobject_cast(tools->value(node.getId())); - Q_ASSERT(tool != 0); - connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(tool, &Tool::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); - tool->setParentItem(this); -} diff --git a/src/tools/vtooldetail.h b/src/tools/vtooldetail.h deleted file mode 100644 index 571d13c05..000000000 --- a/src/tools/vtooldetail.h +++ /dev/null @@ -1,209 +0,0 @@ -/************************************************************************ - ** - ** @file vtooldetail.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLDETAIL_H -#define VTOOLDETAIL_H - -#include "vabstracttool.h" -#include -#include "../dialogs/dialogdetail.h" - -/** - * @brief The VToolDetail class - */ -class VToolDetail: public VAbstractTool, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VToolDetail - * @param doc dom document container - * @param data - * @param id - * @param typeCreation - * @param scene - * @param parent - */ - VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, - const Tool::Sources &typeCreation, VMainGraphicsScene *scene, - QGraphicsItem * parent = 0); - /** - * @brief setDialog - */ - virtual void setDialog(); - /** - * @brief Create - * @param dialog - * @param scene - * @param doc dom document container - * @param data - */ - static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data); - /** - * @brief Create - * @param _id - * @param newDetail - * @param scene - * @param doc dom document container - * @param data - * @param parse - * @param typeCreation - */ - static void Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, - const Tool::Sources &typeCreation); - template - /** - * @brief AddTool - * @param tool - * @param id - * @param typeTool - */ - void AddTool(T *tool, const qint64 &id, Tool::Tools typeTool) - { - tool->setParentItem(this); - connect(tool, &T::ChoosedTool, sceneDetails, &VMainGraphicsScene::ChoosedItem); - VNodeDetail node(id, typeTool, Draw::Modeling, NodeDetail::Modeling); - VDetail det = VAbstractTool::data.GetDetail(this->id); - det.append(node); - VAbstractTool::data.UpdateDetail(this->id, det); - QDomElement domElement = doc->elementById(QString().setNum(this->id)); - if (domElement.isElement()) - { - AddNode(domElement, node); - } - } - /** - * @brief TagName - */ - static const QString TagName; - /** - * @brief TagNode - */ - static const QString TagNode; - /** - * @brief AttrSupplement - */ - static const QString AttrSupplement; - /** - * @brief AttrClosed - */ - static const QString AttrClosed; - /** - * @brief AttrWidth - */ - static const QString AttrWidth; - /** - * @brief AttrIdObject - */ - static const QString AttrIdObject; - /** - * @brief AttrNodeType - */ - static const QString AttrNodeType; - /** - * @brief NodeTypeContour - */ - static const QString NodeTypeContour; - /** - * @brief NodeTypeModeling - */ - static const QString NodeTypeModeling; -public slots: - /** - * @brief FullUpdateFromFile - */ - virtual void FullUpdateFromFile (); - /** - * @brief FullUpdateFromGui - * @param result - */ - virtual void FullUpdateFromGui(int result); -signals: - /** - * @brief RemoveTool - * @param tool - */ - void RemoveTool(QGraphicsItem *tool); -protected: - /** - * @brief AddToFile - */ - virtual void AddToFile (); - /** - * @brief itemChange - * @param change - * @param value - * @return - */ - QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief mouseReleaseEvent - * @param event - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief contextMenuEvent - * @param event - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief RemoveReferens - */ - virtual void RemoveReferens(); -private: - Q_DISABLE_COPY(VToolDetail) - /** - * @brief dialogDetail - */ - QSharedPointer dialogDetail; - /** - * @brief sceneDetails - */ - VMainGraphicsScene *sceneDetails; - /** - * @brief RefreshGeometry - */ - void RefreshGeometry (); - /** - * @brief AddNode - * @param domElement - * @param node - */ - void AddNode(QDomElement &domElement, VNodeDetail &node); - template - /** - * @brief InitTool - * @param scene - * @param node - */ - void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node); -}; - -#endif // VTOOLDETAIL_H diff --git a/src/widgets/doubledelegate.cpp b/src/widgets/doubledelegate.cpp deleted file mode 100644 index 36e865905..000000000 --- a/src/widgets/doubledelegate.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************ - ** - ** @file doubledelegate.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 . - ** - *************************************************************************/ - - /* - doubledelegate.cpp - - A delegate that allows the user to change integer values from the model - using a spin box widget. - */ - -#include "doubledelegate.h" - -#include - -QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - Q_UNUSED(option); - Q_UNUSED(index); - QDoubleSpinBox *editor = new QDoubleSpinBox(parent); - editor->setMinimum(-10000.0); - editor->setMaximum(10000.0); - return editor; -} - -void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const -{ - qreal value = index.model()->data(index, Qt::EditRole).toDouble(); - - QDoubleSpinBox *spinBox = static_cast(editor); - spinBox->setValue(value); -} - -void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const -{ - QDoubleSpinBox *spinBox = static_cast(editor); - spinBox->interpretText(); - qreal value = spinBox->value(); - - model->setData(index, value, Qt::EditRole); -} - -void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - Q_UNUSED(index) - editor->setGeometry(option.rect); -} diff --git a/src/widgets/vapplication.cpp b/src/widgets/vapplication.cpp deleted file mode 100644 index e3e40bab9..000000000 --- a/src/widgets/vapplication.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************ - ** - ** @file vapplication.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vapplication.h" -#include "../exception/vexceptionobjecterror.h" -#include "../exception/vexceptionbadid.h" -#include "../exception/vexceptionconversionerror.h" -#include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionwrongparameterid.h" - -#include -#include - -// reimplemented from QApplication so we can throw exceptions in slots -bool VApplication::notify(QObject *receiver, QEvent *event) -{ - try - { - return QApplication::notify(receiver, event); - } - catch (const VExceptionObjectError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - abort(); - } - catch (const VExceptionBadId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error bad id. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - abort(); - } - catch (const VExceptionConversionError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error can't convert value. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - abort(); - } - catch (const VExceptionEmptyParameter &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error empty parameter. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - abort(); - } - catch (const VExceptionWrongParameterId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error wrong id. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - abort(); - } - catch (const VException &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Something wrong!!")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - } - catch (std::exception& e) - { - qCritical() << "Exception thrown:" << e.what(); - } - return false; -} diff --git a/src/widgets/vcontrolpointspline.cpp b/src/widgets/vcontrolpointspline.cpp deleted file mode 100644 index acd40cb39..000000000 --- a/src/widgets/vcontrolpointspline.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************ - ** - ** @file vcontrolpointspline.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vcontrolpointspline.h" - -#include - -VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &controlPoint, const QPointF &splinePoint, - QGraphicsItem *parent) - :QGraphicsEllipseItem(parent), radius(toPixel(1.5)), controlLine(0), indexSpline(indexSpline), position(position) -{ - //create circle - QRectF rec = QRectF(0, 0, radius*2, radius*2); - rec.translate(-rec.center().x(), -rec.center().y()); - this->setRect(rec); - this->setPen(QPen(Qt::black, widthHairLine)); - this->setBrush(QBrush(Qt::NoBrush)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setAcceptHoverEvents(true); - this->setPos(controlPoint); - - //Лінія, що з'єднує дві точки - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); - controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this); - controlLine->setPen(QPen(Qt::red, widthHairLine)); - controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); -} - -void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); -} - -void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); -} - -QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionChange && scene()) - { - // value - new position. - QPointF newPos = value.toPointF(); - emit ControlPointChangePosition(indexSpline, position, newPos); - } - return QGraphicsItem::itemChange(change, value); -} - -qint32 VControlPointSpline::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, - QPointF &p2) const -{ - const qreal eps = 1e-8; - //коефіцієнти для рівняння відрізку - qreal a = line.p2().y() - line.p1().y(); - qreal b = line.p1().x() - line.p2().x(); - // В даному випадку не використовується. - //qreal c = - a * line.p1().x() - b * line.p1().y(); - // проекция центра окружности на прямую - QPointF p = ClosestPoint (line, center); - // сколько всего решений? - qint32 flag = 0; - qreal d = QLineF (center, p).length(); - if (qAbs (d - radius) <= eps) - { - flag = 1; - } - else - { - if (radius > d) - { - flag = 2; - } - else - { - return 0; - } - } - // находим расстояние от проекции до точек пересечения - qreal k = sqrt (radius * radius - d * d); - qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length(); - // добавляем к проекции векторы направленные к точкам пеерсечения - p1 = addVector (p, QPointF (0, 0), QPointF (- b, a), k / t); - p2 = addVector (p, QPointF (0, 0), QPointF (b, - a), k / t); - return flag; -} - -QPointF VControlPointSpline::ClosestPoint(const QLineF &line, const QPointF &p) const -{ - QLineF lineP2pointFrom = QLineF(line.p2(), p); - qreal angle = 180-line.angleTo(lineP2pointFrom)-90; - QLineF pointFromlineP2 = QLineF(p, line.p2()); - pointFromlineP2.setAngle(pointFromlineP2.angle()+angle); - QPointF point; - QLineF::IntersectType type = pointFromlineP2.intersect(line, &point); - if ( type == QLineF::BoundedIntersection ) - { - return point; - } - else - { - if ( type == QLineF::NoIntersection || type == QLineF::UnboundedIntersection ) - { - Q_ASSERT_X(type != QLineF::BoundedIntersection, Q_FUNC_INFO, "Немає точки перетину."); - return point; - } - } - return point; -} - -QPointF VControlPointSpline::addVector(const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k) const -{ - return QPointF (p.x() + (p2.x() - p1.x()) * k, p.y() + (p2.y() - p1.y()) * k); -} - -void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, - const QPointF &controlPoint, const QPointF &splinePoint) -{ - if (this->indexSpline == indexSpline && this->position == pos) - { - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); - controlLine->setLine(QLineF(splinePoint-controlPoint, p1)); - } -} - -void VControlPointSpline::setEnabledPoint(bool enable) -{ - if (enable == true) - { - this->setPen(QPen(Qt::black, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setAcceptHoverEvents(true); - } - else - { - this->setPen(QPen(Qt::gray, widthHairLine)); - this->setFlag(QGraphicsItem::ItemIsSelectable, false); - this->setFlag(QGraphicsItem::ItemIsMovable, false); - this->setAcceptHoverEvents(false); - } -} diff --git a/src/widgets/vcontrolpointspline.h b/src/widgets/vcontrolpointspline.h deleted file mode 100644 index 6b34f77a9..000000000 --- a/src/widgets/vcontrolpointspline.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************ - ** - ** @file vcontrolpointspline.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VCONTROLPOINTSPLINE_H -#define VCONTROLPOINTSPLINE_H - -#include -#include -#include "../geometry/vsplinepath.h" - -/** - * @brief The VControlPointSpline class - */ -class VControlPointSpline : public QObject, public QGraphicsEllipseItem -{ - Q_OBJECT -public: - /** - * @brief VControlPointSpline - * @param indexSpline - * @param position - * @param controlPoint - * @param splinePoint - * @param parent - */ - VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &controlPoint, const QPointF &splinePoint, - QGraphicsItem * parent = 0); -signals: - /** - * @brief ControlPointChangePosition - * @param indexSpline - * @param position - * @param pos - */ - void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF pos); -public slots: - /** - * @brief RefreshLine - * @param indexSpline - * @param pos - * @param controlPoint - * @param splinePoint - */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, const QPointF &controlPoint, - const QPointF &splinePoint); - /** - * @brief setEnabledPoint - * @param enable - */ - void setEnabledPoint(bool enable); -protected: - /** - * @brief radius - */ - qreal radius; - /** - * @brief controlLine - */ - QGraphicsLineItem *controlLine; - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief itemChange - * @param change - * @param value - * @return - */ - QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); -private: - Q_DISABLE_COPY(VControlPointSpline) - /** - * @brief indexSpline - */ - qint32 indexSpline; - /** - * @brief position - */ - SplinePoint::Position position; - /** - * @brief LineIntersectCircle - * @param center - * @param radius - * @param line - * @param p1 - * @param p2 - * @return - */ - qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, - QPointF &p2) const; - /** - * @brief ClosestPoint - * @param line - * @param p - * @return - */ - QPointF ClosestPoint(const QLineF &line, const QPointF &p) const; - /** - * @brief addVector - * @param p - * @param p1 - * @param p2 - * @param k - * @return - */ - QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k) const; - -}; - -#endif // VCONTROLPOINTSPLINE_H diff --git a/src/widgets/vgraphicssimpletextitem.cpp b/src/widgets/vgraphicssimpletextitem.cpp deleted file mode 100644 index 80a908fbb..000000000 --- a/src/widgets/vgraphicssimpletextitem.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************ - ** - ** @file vgraphicssimpletextitem.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vgraphicssimpletextitem.h" - -#include - -VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) - :QGraphicsSimpleTextItem(parent), fontSize(0) -{ - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setAcceptHoverEvents(true); - QFont font = this->font(); - font.setPointSize(font.pointSize()+3); - fontSize = font.pointSize(); - this->setFont(font); -} - -VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent ) - :QGraphicsSimpleTextItem(text, parent), fontSize(0) -{ - this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setFlag(QGraphicsItem::ItemIsSelectable, true); - this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - this->setAcceptHoverEvents(true); -} - -QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionChange && scene()) - { - QPointF newPos = value.toPointF() + this->parentItem()->pos(); - emit NameChangePosition(newPos); - } - return QGraphicsItem::itemChange(change, value); -} - -void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setBrush(Qt::green); -} - -void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - this->setBrush(Qt::black); -} diff --git a/src/widgets/vgraphicssimpletextitem.h b/src/widgets/vgraphicssimpletextitem.h deleted file mode 100644 index 753a68497..000000000 --- a/src/widgets/vgraphicssimpletextitem.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************ - ** - ** @file vgraphicssimpletextitem.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VGRAPHICSSIMPLETEXTITEM_H -#define VGRAPHICSSIMPLETEXTITEM_H - -#include - -/** - * @brief The VGraphicsSimpleTextItem class - */ -class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem -{ - Q_OBJECT -public: - /** - * @brief VGraphicsSimpleTextItem - * @param parent - */ - VGraphicsSimpleTextItem(QGraphicsItem * parent = 0); - /** - * @brief VGraphicsSimpleTextItem - * @param text - * @param parent - */ - VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = 0 ); - /** - * @brief FontSize - * @return - */ - qint32 FontSize()const {return fontSize;} -signals: - /** - * @brief NameChangePosition - * @param pos - */ - void NameChangePosition(const QPointF pos); -protected: - /** - * @brief itemChange - * @param change - * @param value - * @return - */ - QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief hoverMoveEvent - * @param event - */ - virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent - * @param event - */ - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); -private: - /** - * @brief fontSize - */ - qint32 fontSize; -}; - -#endif // VGRAPHICSSIMPLETEXTITEM_H diff --git a/src/widgets/vitem.h b/src/widgets/vitem.h deleted file mode 100644 index 6d1f01254..000000000 --- a/src/widgets/vitem.h +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************ - ** - ** @file vitem.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VITEM_H -#define VITEM_H - -#include -#include - -/** - * @brief VItem клас, що реалізує деталь на сцені. - */ -class VItem : public QObject, public QGraphicsPathItem -{ - Q_OBJECT -public: - /** - * @brief VItem конструктор за замовчуванням - *Конструктор генерує пусту деталь з номером в списку, що дорівнює 0. - */ - VItem ():numInOutList(0), paper(0){} - /** - * @brief VItem конструктор - * @param numInList номер в списку деталей, що передається у вікно де - *укладаються деталі. - * @param parent батьківський об'єкт на сцені для даного. За замовчуванням немає. - */ - VItem (int numInList, QGraphicsItem * parent = 0):QGraphicsPathItem (parent), numInOutList(numInList), - paper(0){} - /** - * @brief VItem конструктор - * @param path зображення що буде показуватися на сцені - об’єкт класу QPainterPath. - * @param numInList номер в списку деталей, що передається у вікно де - *укладаються деталі. - * @param parent батьківський об'єкт на сцені для даного. За замовчуванням немає. - */ - VItem ( const QPainterPath & path, int numInList, QGraphicsItem * parent = 0 ); - /** - * @brief Rotate повертає об'єкт на кут в градусах - * @param angle кут в градусах на який повертається деталь. - */ - void Rotate ( qreal angle ); - /** - * @brief getPaper - * @return - */ - QGraphicsRectItem *getPaper() const {return paper;} - /** - * @brief setPaper - * @param value - */ - void setPaper(QGraphicsRectItem *value) {paper = value;} -public slots: - /** - * @brief LengthChanged слот який обробляє сигнал зміни довжини листа. - */ - void LengthChanged(); - /** - * @brief SetIndexInList встановлює номер деталі в списку деталей. - * @param index номер в списку. - */ - inline void SetIndexInList( qint32 index ) {numInOutList = index;} -protected: - /** - * @brief itemChange модифікація стандартного методу itemChange. Виконується перехоплення зміни - *положення і зміни батька. - * @param change - * @param value - * @return - */ - QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief checkItemChange перевіряє вихід деталі за рамки листа і факт колізії. Посилає відповідні - *сигнали. - */ - void checkItemChange (); -private: - Q_DISABLE_COPY(VItem) - /** - * @brief numInOutList для зберігання інформації про колізії від кожної деталі необхідно знати її - *номер. - */ - qint32 numInOutList; - /** - * @brief paper - */ - QGraphicsRectItem* paper; -signals: - /** - * @brief itemOut сигнал виходу за межі листа. Посилається у будь-якому випадку. - * @param numInOutList номер деталі яка вийшла за межі листа або тепер знаходиться в межах листа. - * @param flag був вихід чи ні. - */ - void itemOut ( int numInOutList, bool flag ); - /** - * @brief itemColliding сигнал колізії деталі з іншими. Посилається як для додавання деталі до - *списку тих що перетинаються, так і для виключення його з такого. - * @param list список усіх деталей які приймають участь в колізії включаючи самого себе. - * @param number 1 - перетин є, 0 - перетину немає. - */ - void itemColliding ( QList list, int number ); -}; -#endif // VITEM_H diff --git a/src/widgets/vmaingraphicsscene.h b/src/widgets/vmaingraphicsscene.h deleted file mode 100644 index fccc36ead..000000000 --- a/src/widgets/vmaingraphicsscene.h +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************ - ** - ** @file vmaingraphicsscene.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMAINGRAPHICSSCENE_H -#define VMAINGRAPHICSSCENE_H - -#include -#include "../options.h" - -/** - * @brief The VMainGraphicsScene class - */ -class VMainGraphicsScene : public QGraphicsScene -{ - Q_OBJECT -public: - /** - * @brief VMainGraphicsScene - */ - VMainGraphicsScene(); - /** - * @brief VMainGraphicsScene - * @param sceneRect - * @param parent - */ - VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = 0); - /** - * @brief getHorScrollBar - * @return - */ - inline qint32 getHorScrollBar() const {return horScrollBar;} - /** - * @brief setHorScrollBar - * @param value - */ - inline void setHorScrollBar(const qint32 &value) {horScrollBar = value;} - /** - * @brief getVerScrollBar - * @return - */ - inline qint32 getVerScrollBar() const {return verScrollBar;} - /** - * @brief setVerScrollBar - * @param value - */ - inline void setVerScrollBar(const qint32 &value) {verScrollBar = value;} -public slots: - /** - * @brief ChoosedItem - * @param id - * @param type - */ - void ChoosedItem(qint64 id, const Scene::Scenes &type); - /** - * @brief RemoveTool - * @param tool - */ - inline void RemoveTool(QGraphicsItem *tool) {this->removeItem(tool);} - /** - * @brief SetFactor - * @param factor - */ - void SetFactor(qreal factor); -protected: - /** - * @brief mouseMoveEvent - * @param event - */ - void mouseMoveEvent(QGraphicsSceneMouseEvent* event); - /** - * @brief mousePressEvent - * @param event - */ - void mousePressEvent(QGraphicsSceneMouseEvent *event); -signals: - /** - * @brief mouseMove - * @param scenePos - */ - void mouseMove(QPointF scenePos); - /** - * @brief mousePress - * @param scenePos - */ - void mousePress(QPointF scenePos); - /** - * @brief ChoosedObject - * @param id - * @param type - */ - void ChoosedObject(qint64 id, Scene::Scenes type); - /** - * @brief NewFactor - * @param factor - */ - void NewFactor(qreal factor); -private: - /** - * @brief horScrollBar - */ - qint32 horScrollBar; - /** - * @brief verScrollBar - */ - qint32 verScrollBar; - /** - * @brief scaleFactor - */ - qreal scaleFactor; -}; - -#endif // VMAINGRAPHICSSCENE_H diff --git a/src/widgets/vmaingraphicsview.cpp b/src/widgets/vmaingraphicsview.cpp deleted file mode 100644 index 162e2fc00..000000000 --- a/src/widgets/vmaingraphicsview.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************ - ** - ** @file vmaingraphicsview.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vmaingraphicsview.h" - -#include -#include -#include -#include - -VMainGraphicsView::VMainGraphicsView(QWidget *parent) - :QGraphicsView(parent), _numScheduledScalings(0) -{ - this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); - this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); -} - -void VMainGraphicsView::wheelEvent(QWheelEvent *event) -{ - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; // see QWheelEvent documentation - _numScheduledScalings += numSteps; - if (_numScheduledScalings * numSteps < 0) - { // if user moved the wheel in another direction, we reset - _numScheduledScalings = numSteps; // previously scheduled scalings - } - - QTimeLine *anim = new QTimeLine(350, this); - anim->setUpdateInterval(20); - - connect(anim, &QTimeLine::valueChanged, this, &VMainGraphicsView::scalingTime); - connect(anim, &QTimeLine::finished, this, &VMainGraphicsView::animFinished); - anim->start(); -} - -void VMainGraphicsView::scalingTime(qreal x) -{ - Q_UNUSED(x); - qreal factor = 1.0 + static_cast(_numScheduledScalings) / 300.0; - if (QApplication::keyboardModifiers() == Qt::ControlModifier) - {// If you press CTRL this code will execute - scale(factor, factor); - emit NewFactor(factor); - } - else - { - if (_numScheduledScalings < 0) - { - verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() + factor*3.5)); - emit NewFactor(factor); - } - else - { - if (verticalScrollBar()->value() > 0) - { - verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() - factor*3.5)); - emit NewFactor(factor); - } - } - } -} - -void VMainGraphicsView::animFinished() -{ - if (_numScheduledScalings > 0) - { - _numScheduledScalings--; - } - else - { - _numScheduledScalings++; - } - sender()->~QObject(); -} - -void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) -{ - if (mousePress->button() & Qt::LeftButton) - { - switch (QGuiApplication::keyboardModifiers()) - { - case Qt::ControlModifier: - QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag); - QGraphicsView::mousePressEvent(mousePress); - break; - default: - QGraphicsView::mousePressEvent(mousePress); - break; - } - } -} - -void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) -{ - QGraphicsView::mouseReleaseEvent ( event ); - QGraphicsView::setDragMode( QGraphicsView::RubberBandDrag ); -} diff --git a/src/widgets/vmaingraphicsview.h b/src/widgets/vmaingraphicsview.h deleted file mode 100644 index a42d53967..000000000 --- a/src/widgets/vmaingraphicsview.h +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************ - ** - ** @file vmaingraphicsview.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VMAINGRAPHICSVIEW_H -#define VMAINGRAPHICSVIEW_H - -#include - -/** - * @brief The VMainGraphicsView class - */ -class VMainGraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - /** - * @brief VMainGraphicsView - * @param parent - */ - explicit VMainGraphicsView(QWidget *parent = 0); -signals: - /** - * @brief NewFactor - * @param factor - */ - void NewFactor(qreal factor); -public slots: - /** - * @brief scalingTime - * @param x - */ - void scalingTime(qreal x); - /** - * @brief animFinished - */ - void animFinished(); -protected: - /** - * @brief wheelEvent обробник повороту колеса мишки. - * @param event передається подія. - */ - void wheelEvent ( QWheelEvent * event ); - /** - * @brief mousePressEvent - * @param mousePress - */ - void mousePressEvent(QMouseEvent *mousePress); - /** - * @brief mouseReleaseEvent - * @param event - */ - void mouseReleaseEvent(QMouseEvent *event); -private: - /** - * @brief _numScheduledScalings - */ - qint32 _numScheduledScalings; -}; - -#endif // VMAINGRAPHICSVIEW_H diff --git a/src/widgets/vtablegraphicsview.h b/src/widgets/vtablegraphicsview.h deleted file mode 100644 index fc93206b9..000000000 --- a/src/widgets/vtablegraphicsview.h +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************************ - ** - ** @file vtablegraphicsview.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTABLEGRAPHICSVIEW_H -#define VTABLEGRAPHICSVIEW_H - -#include - -/** - * @brief The VTableGraphicsView class - */ -class VTableGraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - /** - * @brief The typeMove_e enum - */ - enum typeMove_e { Left, Right, Up, Down }; - VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent = 0); -signals: - /** - * @brief itemChect Сигнал, що посилається коли змінюється стан вибору деталі. - * @param flag Зберігає стан вибору деталі: false - знайдено, true - не знайдено. - */ - void itemChect( bool flag ); -public slots: - /** - * @brief selectionChanged Слот виконується при зміні стану вибору деталей. - */ - void selectionChanged(); - /** - * @brief rotateItems слот, який виконується при натисненні кнопки повороту деталі. - */ - inline void rotateItems() {rotateIt();} - /** - * @brief MirrorItem дзеркалить об'єкт відносно вертикальної вісі семетрії об'єкта. - */ - void MirrorItem(); - /** - * @brief ZoomIn збільшує масштаб листа. - */ - inline void ZoomIn() {scale(1.1, 1.1);} - /** - * @brief ZoomOut зменшує масштаб листа. - */ - inline void ZoomOut() {scale(1/1.1, 1/1.1);} -protected: - /** - * @brief wheelEvent обробник повороту колеса мишки. - * @param event передається подія. - */ - void wheelEvent ( QWheelEvent * event ); - /** - * @brief mousePressEvent обробник натиснення кнопки миші. - * @param mousePress передається подія. - */ - void mousePressEvent(QMouseEvent *mousePress); - /** - * @brief mouseReleaseEvent обробник відпускання кнопки миші. - * @param event передається подія - */ - void mouseReleaseEvent ( QMouseEvent * event ); - /** - * @brief keyPressEvent обробник натиснення клавіші. - * @param event передається подія. - */ - void keyPressEvent ( QKeyEvent * event ); - /** - * @brief rotateIt виконує поворот вибраних деталей на 180 градусів. - */ - void rotateIt(); - /** - * @brief MoveItem переміщує виділені об'єкти сцени. - * @param move напрямок переміщення. - */ - void MoveItem( VTableGraphicsView::typeMove_e move ); - -}; - -#endif // VTABLEGRAPHICSVIEW_H diff --git a/src/widgets/widgets.pri b/src/widgets/widgets.pri deleted file mode 100644 index 6dbdb83e2..000000000 --- a/src/widgets/widgets.pri +++ /dev/null @@ -1,19 +0,0 @@ -HEADERS += \ - src/widgets/vtablegraphicsview.h \ - src/widgets/vmaingraphicsview.h \ - src/widgets/vmaingraphicsscene.h \ - src/widgets/vitem.h \ - src/widgets/vgraphicssimpletextitem.h \ - src/widgets/vcontrolpointspline.h \ - src/widgets/vapplication.h \ - src/widgets/doubledelegate.h - -SOURCES += \ - src/widgets/vtablegraphicsview.cpp \ - src/widgets/vmaingraphicsview.cpp \ - src/widgets/vmaingraphicsscene.cpp \ - src/widgets/vitem.cpp \ - src/widgets/vgraphicssimpletextitem.cpp \ - src/widgets/vcontrolpointspline.cpp \ - src/widgets/vapplication.cpp \ - src/widgets/doubledelegate.cpp diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp deleted file mode 100644 index fe556678f..000000000 --- a/src/xml/vdomdocument.cpp +++ /dev/null @@ -1,1477 +0,0 @@ -/************************************************************************ - ** - ** @file vdomdocument.cpp - ** @author Roman Telezhinsky - ** @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 - ** 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 "vdomdocument.h" -#include "../exception/vexceptionwrongparameterid.h" -#include "../exception/vexceptionconversionerror.h" -#include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionuniqueid.h" -#include "../tools/vtooldetail.h" -#include "../exception/vexceptionobjecterror.h" -#include "../exception/vexceptionbadid.h" -#include "../tools/drawTools/drawtools.h" -#include "../tools/modelingTools/modelingtools.h" -#include "../tools/nodeDetails/vnodepoint.h" -#include "../tools/nodeDetails/vnodespline.h" -#include "../tools/nodeDetails/vnodesplinepath.h" -#include "../tools/nodeDetails/vnodearc.h" - -#include - -VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) - : QDomDocument(), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode){} - -VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, - Draw::Draws *mode) - :QDomDocument(name), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode){} - -VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, - Draw::Draws *mode) - :QDomDocument(doctype), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode){} - -QDomElement VDomDocument::elementById(const QString& id) -{ - if (map.contains(id)) - { - QDomElement e = map[id]; - if (e.parentNode().nodeType() != QDomNode::BaseNode) - { - return e; - } - map.remove(id); - } - - bool res = this->find(this->documentElement(), id); - if (res) - { - return map[id]; - } - - return QDomElement(); -} - -bool VDomDocument::find(const QDomElement &node, const QString& id) -{ - if (node.hasAttribute("id")) - { - QString value = node.attribute("id"); - this->map[value] = node; - if (value == id) - { - return true; - } - } - - for (qint32 i=0; ifind(n.toElement(), id); - if (res) - { - return true; - } - } - } - - return false; -} - -void VDomDocument::CreateEmptyFile() -{ - QDomElement domElement = this->createElement("lekalo"); - this->appendChild(domElement); - QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); - this->insertBefore(xmlNode, this->firstChild()); - QDomElement incrElement = this->createElement("increments"); - domElement.appendChild(incrElement); -} - -bool VDomDocument::CheckNameDraw(const QString& name) const -{ - Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty"); - QDomNodeList elements = this->documentElement().elementsByTagName( "draw" ); - if (elements.size() == 0) - { - return false; - } - for ( qint32 i = 0; i < elements.count(); i++ ) - { - QDomElement elem = elements.at( i ).toElement(); - if (elem.isNull() == false) - { - QString fieldName = elem.attribute( "name" ); - if ( fieldName == name ) - { - return true; - } - } - } - return false; -} - -bool VDomDocument::appendDraw(const QString& name) -{ - Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty"); - if (name.isEmpty()) - { - return false; - } - if (CheckNameDraw(name)== false) - { - QDomElement rootElement = this->documentElement(); - - QDomElement drawElement = this->createElement("draw"); - QDomAttr drawAttr = this->createAttribute("name"); - drawAttr.setValue(name); - drawElement.setAttributeNode(drawAttr); - - QDomElement calculationElement = this->createElement("calculation"); - QDomElement modelingElement = this->createElement("modeling"); - QDomElement pathsElement = this->createElement("details"); - drawElement.appendChild(calculationElement); - drawElement.appendChild(modelingElement); - drawElement.appendChild(pathsElement); - - rootElement.appendChild(drawElement); - - if (nameActivDraw.isEmpty()) - { - SetActivDraw(name); - } - else - { - ChangeActivDraw(name); - } - return true; - } - else - { - return false; - } - return false; -} - -void VDomDocument::ChangeActivDraw(const QString& name, const Document::Documents &parse) -{ - Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty"); - if (CheckNameDraw(name) == true) - { - this->nameActivDraw = name; - if (parse == Document::FullParse) - { - emit ChangedActivDraw(name); - } - } -} - -bool VDomDocument::SetNameDraw(const QString& name) -{ - Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty"); - QString oldName = nameActivDraw; - QDomElement element; - if (GetActivDrawElement(element)) - { - nameActivDraw = name; - element.setAttribute("name", nameActivDraw); - emit haveChange(); - emit ChangedNameDraw(oldName, nameActivDraw); - return true; - } - else - { - qWarning()<<"Can't find activ draw"<nameActivDraw = name; -} - -bool VDomDocument::GetActivDrawElement(QDomElement &element) -{ - if (nameActivDraw.isEmpty() == false) - { - QDomNodeList elements = this->documentElement().elementsByTagName( "draw" ); - if (elements.size() == 0) - { - return false; - } - for ( qint32 i = 0; i < elements.count(); i++ ) - { - element = elements.at( i ).toElement(); - if (element.isNull() == false) - { - QString fieldName = element.attribute( "name" ); - if ( fieldName == nameActivDraw ) - { - return true; - } - } - } - } - return false; -} - -bool VDomDocument::GetActivCalculationElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("calculation", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivModelingElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("modeling", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivDetailsElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("details", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element) -{ - Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty"); - QDomElement drawElement; - bool drawOk = this->GetActivDrawElement(drawElement); - if (drawOk == true) - { - QDomNodeList listElement = drawElement.elementsByTagName(name); - if (listElement.size() == 0 || listElement.size() > 1) - { - return false; - } - element = listElement.at( 0 ).toElement(); - if (element.isNull() == false) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } -} - -void VDomDocument::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail) -{ - Q_ASSERT(sceneDraw != 0); - Q_ASSERT(sceneDetail != 0); - if (parse == Document::FullParse) - { - TestUniqueId(); - data->Clear(); - nameActivDraw.clear(); - sceneDraw->clear(); - sceneDetail->clear(); - comboBoxDraws->clear(); - tools.clear(); - cursor = 0; - } - data->ClearLengthLines(); - data->ClearLengthArcs(); - data->ClearLengthSplines(); - data->ClearLineAngles(); - history.clear(); - QDomElement rootElement = this->documentElement(); - QDomNode domNode = rootElement.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName()=="draw") - { - if (parse == Document::FullParse) - { - if (nameActivDraw.isEmpty()) - { - SetActivDraw(domElement.attribute("name")); - } - else - { - ChangeActivDraw(domElement.attribute("name")); - } - comboBoxDraws->addItem(domElement.attribute("name")); - } - else - { - ChangeActivDraw(domElement.attribute("name"), Document::LiteParse); - } - ParseDrawElement(sceneDraw, sceneDetail, domElement, parse); - } - if (domElement.tagName()=="increments") - { - ParseIncrementsElement(domElement); - } - } - } - domNode = domNode.nextSibling(); - } -} - -void VDomDocument::ParseIncrementsElement(const QDomNode &node) -{ - QDomNode domNode = node.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == "increment") - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal base = GetParametrDouble(domElement, "base"); - qreal ksize = GetParametrDouble(domElement, "ksize"); - qreal kgrowth = GetParametrDouble(domElement, "kgrowth"); - QString desc = GetParametrString(domElement, "description"); - data->UpdateId(id); - data->AddIncrementTableRow(name, - VIncrementTableRow(id, base, ksize, kgrowth, desc)); - } - } - } - domNode = domNode.nextSibling(); - } -} - -qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const -{ - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - qint64 id = GetParametrLongLong(domElement, "id"); - if (id <= 0) - { - throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement); - } - return id; -} - -qint64 VDomDocument::GetParametrLongLong(const QDomElement &domElement, const QString &name) const -{ - Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - bool ok = false; - QString parametr = GetParametrString(domElement, name); - qint64 id = parametr.toLongLong(&ok); - if (ok == false) - { - throw VExceptionConversionError(tr("Can't convert toLongLong parameter"), name); - } - return id; -} - -QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name) const -{ - Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QString parameter = domElement.attribute(name, ""); - if (parameter.isEmpty()) - { - throw VExceptionEmptyParameter(tr("Got empty parameter"), name, domElement); - } - return parameter; -} - -qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name) const -{ - Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - bool ok = false; - QString parametr = GetParametrString(domElement, name); - qreal param = parametr.replace(",", ".").toDouble(&ok); - if (ok == false) - { - throw VExceptionConversionError(tr("Can't convert toDouble parameter"), name); - } - return param; -} - -void VDomDocument::TestUniqueId() const -{ - QVector vector; - CollectId(this->documentElement(), vector); -} - -void VDomDocument::CollectId(const QDomElement &node, QVector &vector) const -{ - if (node.hasAttribute("id")) - { - qint64 id = GetParametrId(node); - if (vector.contains(id)) - { - throw VExceptionUniqueId(tr("This id is not unique."), node); - } - vector.append(id); - } - - for (qint32 i=0; iClearObject(); - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation); - } - if (domElement.tagName() == "modeling") - { - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling); - } - if (domElement.tagName() == "details") - { - ParseDetails(sceneDetail, domElement, parse); - } - } - } - domNode = domNode.nextSibling(); - } -} - -void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode) -{ - Q_ASSERT(sceneDraw != 0); - Q_ASSERT(sceneDetail != 0); - VMainGraphicsScene *scene = 0; - if (mode == Draw::Calculation) - { - scene = sceneDraw; - } - else - { - scene = sceneDetail; - } - QDomNodeList nodeList = node.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement domElement = nodeList.at(i).toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == "point") - { - ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""), mode); - continue; - } - if (domElement.tagName() == "line") - { - ParseLineElement(scene, domElement, parse, mode); - continue; - } - if (domElement.tagName() == "spline") - { - ParseSplineElement(scene, domElement, parse, domElement.attribute("type", ""), mode); - continue; - } - if (domElement.tagName() == "arc") - { - ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""), mode); - continue; - } - } - } -} - -void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse) -{ - Q_ASSERT(sceneDetail != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - try - { - VDetail detail; - VDetail oldDetail; - qint64 id = GetParametrId(domElement); - detail.setName(GetParametrString(domElement, "name")); - detail.setMx(toPixel(GetParametrDouble(domElement, "mx"))); - detail.setMy(toPixel(GetParametrDouble(domElement, "my"))); - detail.setSupplement(GetParametrLongLong(domElement, "supplement")); - detail.setWidth(GetParametrDouble(domElement, "width")); - detail.setClosed(GetParametrLongLong(domElement, "closed")); - - QDomNodeList nodeList = domElement.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) - { - if (element.tagName() == "node") - { - qint64 id = GetParametrLongLong(element, "idObject"); - qreal mx = toPixel(GetParametrDouble(element, "mx")); - qreal my = toPixel(GetParametrDouble(element, "my")); - Tool::Tools tool; - Draw::Draws mode; - NodeDetail::NodeDetails nodeType = NodeDetail::Contour; - QString t = GetParametrString(element, "type"); - if (t == "NodePoint") - { - tool = Tool::NodePoint; - VPointF point = data->GetPointModeling(id); - mode = point.getMode(); - oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode, NodeDetail::Contour)); - } - else if (t == "NodeArc") - { - tool = Tool::NodeArc; - VArc arc = data->GetArcModeling(id); - mode = arc.getMode(); - oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode, NodeDetail::Contour)); - } - else if (t == "NodeSpline") - { - tool = Tool::NodeSpline; - VSpline spl = data->GetSplineModeling(id); - mode = spl.getMode(); - oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode, NodeDetail::Contour)); - } - else if (t == "NodeSplinePath") - { - tool = Tool::NodeSplinePath; - VSplinePath splPath = data->GetSplinePathModeling(id); - mode = splPath.getMode(); - oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode, NodeDetail::Contour)); - } - else if (t == "AlongLineTool") - { - tool = Tool::AlongLineTool; - } - else if (t == "ArcTool") - { - tool = Tool::ArcTool; - } - else if (t == "BisectorTool") - { - tool = Tool::BisectorTool; - } - else if (t == "EndLineTool") - { - tool = Tool::EndLineTool; - } - else if (t == "LineIntersectTool") - { - tool = Tool::LineIntersectTool; - } - else if (t == "LineTool") - { - tool = Tool::LineTool; - } - else if (t == "NormalTool") - { - tool = Tool::NormalTool; - } - else if (t == "PointOfContact") - { - tool = Tool::PointOfContact; - } - else if (t == "ShoulderPointTool") - { - tool = Tool::ShoulderPointTool; - } - else if (t == "SplinePathTool") - { - tool = Tool::SplinePathTool; - } - else if (t == "SplineTool") - { - tool = Tool::SplineTool; - } - else if (t == "Height") - { - tool = Tool::Height; - } - else if (t == "Triangle") - { - tool = Tool::Triangle; - } - else if (t == "PointOfIntersection") - { - tool = Tool::PointOfIntersection; - } - detail.append(VNodeDetail(id, tool, Draw::Modeling, nodeType, mx, my)); - } - } - } - VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } -} - -void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse) -{ - Q_ASSERT(sceneDetail != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QDomNode domNode = domElement.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == "detail") - { - ParseDetailElement(sceneDetail, domElement, parse); - } - } - } - domNode = domNode.nextSibling(); - } -} - -void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type, const Draw::Draws &mode) -{ - Q_ASSERT(scene != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); - if (type == "single") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal x = toPixel(GetParametrDouble(domElement, "x")); - qreal y = toPixel(GetParametrDouble(domElement, "y")); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - - data->UpdatePoint(id, VPointF(x, y, name, mx, my)); - VDrawTool::AddRecord(id, Tool::SinglePointTool, this); - if (parse != Document::FullParse) - { - UpdateToolData(id, data); - } - if (parse == Document::FullParse) - { - VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile); - Q_ASSERT(spoint != 0); - scene->addItem(spoint); - connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); - tools[id] = spoint; - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating single point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "endLine") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - QString formula = GetParametrString(domElement, "length"); - qint64 basePointId = GetParametrLongLong(domElement, "basePoint"); - qreal angle = GetParametrDouble(domElement, "angle"); - if (mode == Draw::Calculation) - { - VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, - data, parse, Tool::FromFile); - } - else - { - VModelingEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, this, - data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "alongLine") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - QString formula = GetParametrString(domElement, "length"); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - - if (mode == Draw::Calculation) - { - VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, - scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, - this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "shoulder") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - QString formula = GetParametrString(domElement, "length"); - qint64 p1Line = GetParametrLongLong(domElement, "p1Line"); - qint64 p2Line = GetParametrLongLong(domElement, "p2Line"); - qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder"); - - if (mode == Draw::Calculation) - { - VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, - scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, - my, this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "normal") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - QString formula = GetParametrString(domElement, "length"); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - qreal angle = GetParametrDouble(domElement, "angle"); - - if (mode == Draw::Calculation) - { - VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, - mx, my, scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, - mx, my, this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "bisector") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - QString formula = GetParametrString(domElement, "length"); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint"); - - if (mode == Draw::Calculation) - { - VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, - name, mx, my, scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, - name, mx, my, this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "lineIntersect") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - qint64 p1Line1Id = GetParametrLongLong(domElement, "p1Line1"); - qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1"); - qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2"); - qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2"); - - if (mode == Draw::Calculation) - { - VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, - scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, - this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "pointOfContact") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString radius = GetParametrString(domElement, "radius"); - qint64 center = GetParametrLongLong(domElement, "center"); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - - if (mode == Draw::Calculation) - { - VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, - scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, - my, this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "modeling") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, "idObject"); - QString tObject = GetParametrString(domElement, "typeObject"); - VPointF point; - Draw::Draws typeObject; - if (tObject == "Calculation") - { - typeObject = Draw::Calculation; - point = data->GetPoint(idObject ); - } - else - { - typeObject = Draw::Modeling; - point = data->GetPointModeling(idObject); - } - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - data->UpdatePointModeling(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject, - idObject )); - VNodePoint::Create(this, data, id, idObject, mode, parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "height") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - QString typeLine = GetParametrString(domElement, "typeLine"); - qint64 basePointId = GetParametrLongLong(domElement, "basePoint"); - qint64 p1LineId = GetParametrLongLong(domElement, "p1Line"); - qint64 p2LineId = GetParametrLongLong(domElement, "p2Line"); - if (mode == Draw::Calculation) - { - VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, scene, - this, data, parse, Tool::FromFile); - } - else - { - VModelingHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, this, - data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating height"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "triangle") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - qint64 axisP1Id = GetParametrLongLong(domElement, "axisP1"); - qint64 axisP2Id = GetParametrLongLong(domElement, "axisP2"); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - - if (mode == Draw::Calculation) - { - VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, - scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, - this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "pointOfIntersection") - { - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name"); - qreal mx = toPixel(GetParametrDouble(domElement, "mx")); - qreal my = toPixel(GetParametrDouble(domElement, "my")); - qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); - - if (mode == Draw::Calculation) - { - VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, - parse, Tool::FromFile); - } - else - { - VModelingPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, this, data, - parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } -} - -void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const Draw::Draws &mode) -{ - Q_ASSERT(scene != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - try - { - qint64 id = GetParametrId(domElement); - qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint"); - qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint"); - - if (mode == Draw::Calculation) - { - VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingLine::Create(id, firstPoint, secondPoint, this, data, parse, Tool::FromFile); - } - - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } -} - -void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type, const Draw::Draws &mode) -{ - Q_ASSERT(scene != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - if (type == "simple") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 point1 = GetParametrLongLong(domElement, "point1"); - qint64 point4 = GetParametrLongLong(domElement, "point4"); - qreal angle1 = GetParametrDouble(domElement, "angle1"); - qreal angle2 = GetParametrDouble(domElement, "angle2"); - qreal kAsm1 = GetParametrDouble(domElement, "kAsm1"); - qreal kAsm2 = GetParametrDouble(domElement, "kAsm2"); - qreal kCurve = GetParametrDouble(domElement, "kCurve"); - - if (mode == Draw::Calculation) - { - VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, - data, parse, Tool::FromFile); - } - else - { - VModelingSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, this, - data, parse, Tool::FromFile); - } - - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "path") - { - try - { - qint64 id = GetParametrId(domElement); - qreal kCurve = GetParametrDouble(domElement, "kCurve"); - VSplinePath path(data->DataPoints(), kCurve); - - QDomNodeList nodeList = domElement.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) - { - if (element.tagName() == "pathPoint") - { - qreal kAsm1 = GetParametrDouble(element, "kAsm1"); - qreal angle = GetParametrDouble(element, "angle"); - qreal kAsm2 = GetParametrDouble(element, "kAsm2"); - qint64 pSpline = GetParametrLongLong(element, "pSpline"); - VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2); - path.append(splPoint); - if (parse == Document::FullParse) - { - IncrementReferens(pSpline); - } - } - } - } - if (mode == Draw::Calculation) - { - VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingSplinePath::Create(id, path, this, data, parse, Tool::FromFile); - } - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "modelingSpline") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, "idObject"); - QString tObject = GetParametrString(domElement, "typeObject"); - VSpline spl; - Draw::Draws typeObject; - if (tObject == "Calculation") - { - typeObject = Draw::Calculation; - spl = data->GetSpline(idObject); - } - else - { - typeObject = Draw::Modeling; - spl = data->GetSplineModeling(idObject); - } - spl.setMode(typeObject); - spl.setIdObject(idObject); - data->UpdateSplineModeling(id, spl); - VNodeSpline::Create(this, data, id, idObject, mode, parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "modelingPath") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, "idObject"); - QString tObject = GetParametrString(domElement, "typeObject"); - VSplinePath path; - Draw::Draws typeObject; - if (tObject == "Calculation") - { - typeObject = Draw::Calculation; - path = data->GetSplinePath(idObject); - } - else - { - typeObject = Draw::Modeling; - path = data->GetSplinePathModeling(idObject); - } - path.setMode(typeObject); - path.setIdObject(idObject); - data->UpdateSplinePathModeling(id, path); - VNodeSplinePath::Create(this, data, id, idObject, mode, parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } -} - -void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type, const Draw::Draws &mode) -{ - Q_ASSERT(scene != 0); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - if (type == "simple") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 center = GetParametrLongLong(domElement, "center"); - QString radius = GetParametrString(domElement, "radius"); - QString f1 = GetParametrString(domElement, "angle1"); - QString f2 = GetParametrString(domElement, "angle2"); - - if (mode == Draw::Calculation) - { - VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile); - } - else - { - VModelingArc::Create(id, center, radius, f1, f2, this, data, parse, Tool::FromFile); - } - - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } - if (type == "modeling") - { - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, "idObject"); - QString tObject = GetParametrString(domElement, "typeObject"); - VArc arc; - Draw::Draws typeObject; - if (tObject == "Calculation") - { - typeObject = Draw::Calculation; - arc = data->GetArc(idObject); - } - else - { - typeObject = Draw::Modeling; - arc = data->GetArcModeling(idObject); - } - arc.setMode(typeObject); - arc.setIdObject(idObject); - data->UpdateArcModeling(id, arc); - VNodeArc::Create(this, data, id, idObject, mode, parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - } -} - -void VDomDocument::FullUpdateTree() -{ - VMainGraphicsScene *scene = new VMainGraphicsScene(); - Q_ASSERT(scene != 0); - try - { - data->ClearObject(); - Parse(Document::LiteParse, scene, scene); - } - catch (const std::bad_alloc &) - { - delete scene; - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText("std::bad_alloc"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - catch (...) - { - delete scene; - throw; - } - - delete scene; - setCurrentData(); - emit FullUpdateFromFile(); - emit haveChange(); -} - -void VDomDocument::haveLiteChange() -{ - emit haveChange(); -} - -void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - emit ShowTool(id, color, enable); -} - -void VDomDocument::setCursor(const qint64 &value) -{ - cursor = value; - emit ChangedCursor(cursor); -} - -void VDomDocument::setCurrentData() -{ - if (*mode == Draw::Calculation) - { - QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); - if (nameActivDraw != nameDraw) - { - nameActivDraw = nameDraw; - qint64 id = 0; - if (history.size() == 0) - { - return; - } - for (qint32 i = 0; i < history.size(); ++i) - { - VToolRecord tool = history.at(i); - if (tool.getNameDraw() == nameDraw) - { - id = tool.getId(); - } - } - if (id == 0) - { - VToolRecord tool = history.at(history.size()-1); - id = tool.getId(); - if (id == 0) - { - return; - } - } - if (tools.size() > 0) - { - VDataTool *vTool = tools.value(id); - data->setData(vTool->getData()); - } - } - } -} - -void VDomDocument::AddTool(const qint64 &id, VDataTool *tool) -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - Q_ASSERT(tool != 0); - tools.insert(id, tool); -} - -void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data) -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - Q_ASSERT(data != 0); - VDataTool *tool = tools.value(id); - Q_ASSERT(tool != 0); - tool->VDataTool::setData(data); -} - -void VDomDocument::IncrementReferens(qint64 id) const -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - VDataTool *tool = tools.value(id); - Q_ASSERT(tool != 0); - tool->incrementReferens(); -} - -void VDomDocument::DecrementReferens(qint64 id) const -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - VDataTool *tool = tools.value(id); - Q_ASSERT(tool != 0); - tool->decrementReferens(); -} diff --git a/src/xml/vdomdocument.h b/src/xml/vdomdocument.h deleted file mode 100644 index 866421445..000000000 --- a/src/xml/vdomdocument.h +++ /dev/null @@ -1,428 +0,0 @@ -/************************************************************************ - ** - ** @file vdomdocument.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VDOMDOCUMENT_H -#define VDOMDOCUMENT_H - -#include "../container/vcontainer.h" -#include "../widgets/vmaingraphicsscene.h" -#include "../tools/vdatatool.h" -#include "vtoolrecord.h" - -#include -#include -#include - -namespace Document -{ - /** - * @brief The Document enum - */ - enum Document { LiteParse, FullParse}; - Q_DECLARE_FLAGS(Documents, Document) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents) - -#ifdef Q_CC_GNU - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Weffc++" -#endif - -/** - * @brief The VDomDocument class - */ -class VDomDocument : public QObject, public QDomDocument -{ - Q_OBJECT -public: - /** - * @brief VDomDocument - * @param data - * @param comboBoxDraws - * @param mode - */ - VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode); - /** - * @brief VDomDocument - * @param name - * @param data - * @param comboBoxDraws - * @param mode - */ - VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode); - /** - * @brief VDomDocument - * @param doc dom document containertype - * @param data - * @param comboBoxDraws - * @param mode - */ - VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, - Draw::Draws *mode); - ~VDomDocument(){} - /** - * @brief elementById - * @param id - * @return - */ - QDomElement elementById(const QString& id); - /** - * @brief CreateEmptyFile - */ - void CreateEmptyFile(); - /** - * @brief ChangeActivDraw - * @param name - * @param parse - */ - void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse); - /** - * @brief GetNameActivDraw - * @return - */ - inline QString GetNameActivDraw() const {return nameActivDraw;} - /** - * @brief GetActivDrawElement - * @param element - * @return - */ - bool GetActivDrawElement(QDomElement &element); - /** - * @brief GetActivCalculationElement - * @param element - * @return - */ - bool GetActivCalculationElement(QDomElement &element); - /** - * @brief GetActivModelingElement - * @param element - * @return - */ - bool GetActivModelingElement(QDomElement &element); - /** - * @brief GetActivDetailsElement - * @param element - * @return - */ - bool GetActivDetailsElement(QDomElement &element); - /** - * @brief appendDraw - * @param name - * @return - */ - bool appendDraw(const QString& name); - /** - * @brief SetNameDraw - * @param name - * @return - */ - bool SetNameDraw(const QString& name); - /** - * @brief Parse - * @param parse - * @param sceneDraw - * @param sceneDetail - */ - void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail); - /** - * @brief getTools - * @return - */ - inline QHash* getTools() {return &tools;} - /** - * @brief getHistory - * @return - */ - inline QVector *getHistory() {return &history;} - /** - * @brief getCursor - * @return - */ - inline qint64 getCursor() const {return cursor;} - /** - * @brief setCursor - * @param value - */ - void setCursor(const qint64 &value); - /** - * @brief setCurrentData - */ - void setCurrentData(); - /** - * @brief AddTool - * @param id - * @param tool - */ - void AddTool(const qint64 &id, VDataTool *tool); - /** - * @brief UpdateToolData - * @param id - * @param data - */ - void UpdateToolData(const qint64 &id, VContainer *data); - /** - * @brief IncrementReferens - * @param id - */ - void IncrementReferens(qint64 id) const; - /** - * @brief DecrementReferens - * @param id - */ - void DecrementReferens(qint64 id) const; - /** - * @brief TestUniqueId - */ - void TestUniqueId() const; -signals: - /** - * @brief ChangedActivDraw - * @param newName - */ - void ChangedActivDraw(const QString &newName); - /** - * @brief ChangedNameDraw - * @param oldName - * @param newName - */ - void ChangedNameDraw(const QString oldName, const QString newName); - /** - * @brief FullUpdateFromFile - */ - void FullUpdateFromFile(); - /** - * @brief haveChange - */ - void haveChange(); - /** - * @brief ShowTool - * @param id - * @param color - * @param enable - */ - void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief ChangedCursor - * @param id - */ - void ChangedCursor(qint64 id); -public slots: - /** - * @brief FullUpdateTree - */ - void FullUpdateTree(); - /** - * @brief haveLiteChange - */ - void haveLiteChange(); - /** - * @brief ShowHistoryTool - * @param id - * @param color - * @param enable - */ - void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); -private: - Q_DISABLE_COPY(VDomDocument) - /** - * @brief map - */ - QHash map; - /** - * @brief nameActivDraw - */ - QString nameActivDraw; - /** - * @brief data container with data - */ - VContainer *data; - /** - * @brief tools - */ - QHash tools; - /** - * @brief history - */ - QVector history; - /** - * @brief cursor - */ - qint64 cursor; - /** - * @brief comboBoxDraws - */ - QComboBox *comboBoxDraws; - /** - * @brief mode - */ - Draw::Draws *mode; - /** - * @brief find - * @param node - * @param id - * @return - */ - bool find(const QDomElement &node, const QString& id); - /** - * @brief CheckNameDraw - * @param name - * @return - */ - bool CheckNameDraw(const QString& name) const; - /** - * @brief SetActivDraw - * @param name - */ - void SetActivDraw(const QString& name); - /** - * @brief GetActivNodeElement - * @param name - * @param element - * @return - */ - bool GetActivNodeElement(const QString& name, QDomElement& element); - /** - * @brief ParseDrawElement - * @param sceneDraw - * @param sceneDetail - * @param node - * @param parse - */ - void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse); - /** - * @brief ParseDrawMode - * @param sceneDraw - * @param sceneDetail - * @param node - * @param parse - * @param mode - */ - void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode); - /** - * @brief ParseDetailElement - * @param sceneDetail - * @param domElement - * @param parse - */ - void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParseDetails - * @param sceneDetail - * @param domElement - * @param parse - */ - void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParsePointElement - * @param scene - * @param domElement - * @param parse - * @param type - * @param mode - */ - void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString &type, const Draw::Draws &mode); - /** - * @brief ParseLineElement - * @param scene - * @param domElement - * @param parse - * @param mode - */ - void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const Draw::Draws &mode); - /** - * @brief ParseSplineElement - * @param scene - * @param domElement - * @param parse - * @param type - * @param mode - */ - void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type, const Draw::Draws &mode); - /** - * @brief ParseArcElement - * @param scene - * @param domElement - * @param parse - * @param type - * @param mode - */ - void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type, const Draw::Draws &mode); - /** - * @brief ParseIncrementsElement - * @param node - */ - void ParseIncrementsElement(const QDomNode& node); - /** - * @brief GetParametrId - * @param domElement - * @return - */ - qint64 GetParametrId(const QDomElement& domElement) const; - /** - * @brief GetParametrLongLong - * @param domElement - * @param name - * @return - */ - qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name) const; - /** - * @brief GetParametrString - * @param domElement - * @param name - * @return - */ - QString GetParametrString(const QDomElement& domElement, const QString &name) const; - /** - * @brief GetParametrDouble - * @param domElement - * @param name - * @return - */ - qreal GetParametrDouble(const QDomElement& domElement, const QString &name) const; - /** - * @brief CollectId - * @param node - * @param vector - */ - void CollectId(const QDomElement &node, QVector &vector)const; -}; - -#ifdef Q_CC_GNU - #pragma GCC diagnostic pop -#endif - -#endif // VDOMDOCUMENT_H diff --git a/src/xml/vtoolrecord.h b/src/xml/vtoolrecord.h deleted file mode 100644 index bbd3d72e1..000000000 --- a/src/xml/vtoolrecord.h +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************************ - ** - ** @file vtoolrecord.h - ** @author Roman Telezhinsky - ** @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 - ** 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 VTOOLRECORD_H -#define VTOOLRECORD_H - -#include "../options.h" - -#include - -/** - * @brief The VToolRecord class - */ -class VToolRecord -{ -public: - /** - * @brief VToolRecord - */ - VToolRecord(); - /** - * @brief VToolRecord - * @param id - * @param typeTool - * @param nameDraw - */ - VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw); - /** - * @brief getId - * @return - */ - inline qint64 getId() const {return id;} - /** - * @brief setId - * @param value - */ - inline void setId(const qint64 &value) {id = value;} - /** - * @brief getTypeTool - * @return - */ - inline Tool::Tools getTypeTool() const {return typeTool;} - /** - * @brief setTypeTool - * @param value - */ - inline void setTypeTool(const Tool::Tools &value) {typeTool = value;} - /** - * @brief getNameDraw - * @return - */ - inline QString getNameDraw() const {return nameDraw;} - /** - * @brief setNameDraw - * @param value - */ - inline void setNameDraw(const QString &value) {nameDraw = value;} -private: - /** - * @brief id - */ - qint64 id; - /** - * @brief typeTool - */ - Tool::Tools typeTool; - /** - * @brief nameDraw - */ - QString nameDraw; -}; - -#endif // VTOOLRECORD_H diff --git a/src/xml/xml.pri b/src/xml/xml.pri deleted file mode 100644 index 0214e42b5..000000000 --- a/src/xml/xml.pri +++ /dev/null @@ -1,7 +0,0 @@ -HEADERS += \ - src/xml/vtoolrecord.h \ - src/xml/vdomdocument.h - -SOURCES += \ - src/xml/vtoolrecord.cpp \ - src/xml/vdomdocument.cpp