Merge branch 'develop' into feature/manual-layout

This commit is contained in:
Roman Telezhynskyi 2021-05-03 18:39:56 +03:00
commit 68990ef5b4
15 changed files with 310 additions and 136 deletions

View File

@ -1,4 +1,7 @@
language: cpp
env:
global:
- secure: Zo+BbyV3sgNmKHwWvn7cCt3leXCLGbE9rSrAYoCrl22OEDZjPj7KeGzQ/59xLosE5v8PA5MV8KceH7aQB9GoIbDt6sHLw5mws13VXmy5HWtM7yhk2RpNnn1gTZIfEz33QGYuPG1geapTcZtZfaVKFU04PMkvk3f7zxA1HuS6zGRgzrNv1AmcpuOGH4LIGxbk3Z1S6xGcUMj/z9calyLlmPTOfbDLJWChU11FMVmvdTzyeDLE0oQZ5IkmsowluCfDHARfIijeRuPiuU8RzJptYEIzcWvpQ6gfDb4qDWndA9BgPDkN2aTmPL5/TA/S9zfs8BKjo07sg0TaVbTboPisyS/gGDf3SBYxlAS9B95KKdRzGGD41ZYe+cHod5tgWUt5gO/Obq2MPY/GltSwuq5KEsR+R/pKVLby/k7+R5oCO8avXJPL5HBgn46ZehEzpw0I8LFQ/ed+dLqykrxaSiA2/zHAkHSeVZptzegoCF5xeDf6T/rJFNqxr1BV3kVLPiXW90z0m63Hv2K6rz8LmBUNTQcR/mrLpkpdbQ8UQ/et30o7CE2GcJLLzUDNcjxYfA1fe66oR9L+euqyBtZc8dNuzy1iIaUOLazGWYkdlUpiYnGvWrxv6BUwzAJYpiXjWELtcTVUGMjMBpkvAmwV1FjZN45isX2iHGz5XhoVDrjbE5c=
jobs:
include:
- stage: main test
@ -9,10 +12,10 @@ jobs:
- DEPLOY=false
- CCACHE_CPP2=yes
- RUN_TESTS=true
cache:
ccache: true
directories:
- "$HOME/.sonar/cache"
cache:
ccache: true
directories:
- "$HOME/.sonar/cache"
- os: linux
dist: bionic
compiler: clang
@ -21,9 +24,9 @@ jobs:
- CCACHE_CPP2=yes
- RUN_TESTS=true
cache:
ccache: true
directories:
- "$HOME/.sonar/cache"
ccache: true
directories:
- "$HOME/.sonar/cache"
- os: osx
compiler: clang
env:
@ -32,8 +35,8 @@ jobs:
osx_image: xcode11
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
- "$HOME/Library/Caches/Homebrew"
- "/usr/local/Homebrew"
- os: osx
compiler: clang
env:
@ -42,8 +45,8 @@ jobs:
osx_image: xcode8
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
- "$HOME/Library/Caches/Homebrew"
- "/usr/local/Homebrew"
before_cache:
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew cleanup; fi
# Credit https://discourse.brew.sh/t/best-practice-for-homebrew-on-travis-brew-update-is-5min-to-build-time/5215/9
@ -76,10 +79,13 @@ before_install:
chmod -R 755 /usr/local/opt/qt5/*
else
unset SSL_CERT_FILE;
HOMEBREW_NO_AUTO_UPDATE=1 brew install https://gist.githubusercontent.com/dismine/c3ac01de38e12edcf22d9e05791adf82/raw/f553c39bbc5f3a2b231a767924e846bdd2a56d8d/qt.rb;
HOMEBREW_NO_AUTO_UPDATE=1 brew install https://gist.githubusercontent.com/dismine/c3ac01de38e12edcf22d9e05791adf82/raw/1218041ffba3ff4b64d109e64a9a867f8fe394c1/qt.rb;
brew link qt --force;
chmod -R 755 /usr/local/opt/qt/*
chmod -R 755 /usr/local/opt/qt/*;
HOMEBREW_NO_AUTO_UPDATE=1 brew install python3;
fi
python3 --version;
pip3 install dropbox;
fi
before_script:
- |
@ -129,23 +135,15 @@ notifications:
- dismine@gmail.com
on_success: change
on_failure: always
before_deploy:
after_success:
- |
if [[ "$DEPLOY" == "true" ]]; then
../scripts/macfixqtdylibrpath.py $TRAVIS_BUILD_DIR/build/src/app/valentina/bin/Valentina.app;
if [[ "$LEGACY" = false ]]; then
tar -C $TRAVIS_BUILD_DIR/build/src/app/valentina/bin --exclude "*.DS_Store" -cvzf valentina-osx-${TRAVIS_COMMIT}.tar.gz Valentina.app/;
python3 $TRAVIS_BUILD_DIR/scripts/deploy.py upload $ACCESS_TOKEN $TRAVIS_BUILD_DIR/build/valentina-osx-${TRAVIS_COMMIT}.tar.gz "/0.7.x/Mac OS X/valentina-osx-${TRAVIS_COMMIT}.tar.xz";
else
tar -C $TRAVIS_BUILD_DIR/build/src/app/valentina/bin --exclude "*.DS_Store" -cvzf valentina-osx-${TRAVIS_COMMIT}-legacy.tar.gz Valentina.app/;
python3 $TRAVIS_BUILD_DIR/scripts/deploy.py upload $ACCESS_TOKEN $TRAVIS_BUILD_DIR/build/valentina-osx-${TRAVIS_COMMIT}-legacy.tar.gz "/0.7.x/Mac OS X/valentina-osx-${TRAVIS_COMMIT}-legacy.tar.xz";
fi
fi
deploy:
provider: bintray
skip_cleanup: true
file: "../share/bintray.json"
user: dismine
key:
secure: q9rcswyUyOqHAnxL0FLEQ8tdFkE21kNlv/TUpZgk0MbcsWRhBWaKJVv5kz6ABkjeLMB7c7eS7KfYRui0RFBKHI7ZnpzHBZN4f1aGd/rf9m5qaZdKFFBlpz4tXPHvXOVyXRwOReqFj7brAz6NB+oqJN8HFA4Q1y039yZOaHt28JkwYSDqS5lRvbwegYS8kaJupGZcm8NaNeB8tuXuZ/8DIQpZdVKmBUwpgpPAewCEqYP4z9DUpsmMZ5h63g7mJKm9di91cQr65eS24io6m1ZfAx8M6kTaKwyR5nz8a8bnqR48AAnbNoM8Xj1sgJqnT40DZKPCNr7KL3JSNRglKNgHVMFBOj0v9F5YxsDs8twWuqFVbywB+lNSHDyvGVgmS2+EdwKLQT0YBxYfIL1nh34ed7GffZZmBcAJGfxo8ieAMRgyylSyQIHJ0ZBl6X6DzOvLpvFlcva9yhqZfkx3P/Dgarqklnj3DdvzTDW2vxCT4yVLpMySlBXW2I3s7m8xpOjZbM7eZfMZkwjd/e8IYp8jxdQnxlzNe15mzxSXnZjLz3Rwi1qzhJZyZf4OGVxuQuR9oW+c5q55OOY5hImtZELlJyu1K0zKTd85g0D+WwKj4J30J0QWl1pxZlln59Q5cMmpyQ7sc8zN1WPoWAEyavwPrf4028TpEJqaUw/0cQGg9I4=
on:
all_branches: true
condition: "$DEPLOY = true"

View File

@ -7,6 +7,7 @@
- [smart-pattern/valentina#122] Extend piece bounding rect.
- Remember last selected export format.
- [smart-pattern/valentina#123] Error inside Save layout dialog.
- Improve error handling for the dxf export.
# Version 0.7.46 Mar 31, 2021
- Fix incorrect calculation of value for multisize measurements in Valentina.

View File

@ -37,24 +37,28 @@ clone_depth: 1 # clone entire repository history if not de
shallow_clone: false # default is "false"
environment:
ACCESS_TOKEN:
secure: RUhnEHqaR8KhalOMWwZZOoO342Ja50QV4KpEWdm9g3pG+jG7i6aJqUmeKF1l5VN6dzksk1u+yN6pOLnU8oGcaVQ6v+1dpKK1oZvF0tyHhNE=
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.15\mingw81_32
QT_VERSION: Qt5.15
QT_VERSION: Qt5_15
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw810_32\bin
PYTHON: "C:\\Python38-x64"
PLATFORM: x86
DEPLOY: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
QT5: Qt\5.6\mingw49_32
QT_VERSION: Qt5.6
QT_VERSION: Qt5_6
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw492_32\bin
PYTHON: "C:\\Python38-x64"
PLATFORM: x86
DEPLOY: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.15\mingw81_64
QT_VERSION: Qt5.15
QT_VERSION: Qt5_15
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw810_64\bin
PLATFORM: x64
@ -67,14 +71,14 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.14\mingw73_32
QT_VERSION: Qt5.14
QT_VERSION: Qt5_14
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw730_32\bin
PLATFORM: x86
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.14\mingw73_64
QT_VERSION: Qt5.14
QT_VERSION: Qt5_14
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw730_64\bin
PLATFORM: x64
@ -87,7 +91,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.13\mingw73_64
QT_VERSION: Qt5.13
QT_VERSION: Qt5_13
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw730_64\bin
PLATFORM: x64
@ -100,7 +104,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
QT5: Qt\5.12\mingw73_64
QT_VERSION: Qt5.12
QT_VERSION: Qt5_12
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw730_64\bin
PLATFORM: x64
@ -113,7 +117,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
QT5: Qt\5.11\mingw53_32
QT_VERSION: Qt5.11
QT_VERSION: Qt5_11
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw530_32\bin
PLATFORM: x86
@ -126,7 +130,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
QT5: Qt\5.10\mingw53_32
QT_VERSION: Qt5.10
QT_VERSION: Qt5_10
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw530_32\bin
PLATFORM: x86
@ -139,7 +143,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
QT5: Qt\5.9\mingw53_32
QT_VERSION: Qt5.9
QT_VERSION: Qt5_9
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw530_32\bin
PLATFORM: x86
@ -152,7 +156,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
QT5: Qt\5.7\mingw53_32
QT_VERSION: Qt5.7
QT_VERSION: Qt5_7
QMAKE_GENERATOR: "MinGW Makefiles"
MINGW_PATH: C:\Qt\Tools\mingw530_32\bin
PLATFORM: x86
@ -165,7 +169,7 @@ environment:
DEPLOY: false
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
QT5: Qt\5.6\msvc2015_64
QT_VERSION: Qt5.6
QT_VERSION: Qt5_6
QMAKE_GENERATOR: "NMake Makefiles JOM"
VSVER: 14
PLATFORM: x64
@ -191,9 +195,16 @@ init:
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" if "%QMAKE_GENERATOR%"=="NMake Makefiles JOM" if "%PLATFORM%"=="x64" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
- if "%QMAKE_GENERATOR%" == "MinGW Makefiles" set PATH=%MINGW_PATH%;%PATH%
- if "%QMAKE_GENERATOR%" == "NMake Makefiles JOM" set PATH=C:\Qt\Tools\QtCreator\bin;%PATH%
- if "%DEPLOY%" == "true" set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
# Set paths to libraries
- set PATH=C:\projects\valentina\build\src\libs\vpropertyexplorer\bin;C:\projects\valentina\build\src\libs\qmuparser\bin;%PATH%
# Path after
- path
# Check that we have the expected version for Python
- if "%DEPLOY%" == "true" (python --version)
# Install the build dependencies of the project.
- if "%DEPLOY%" == "true" (python -m pip install --upgrade pip)
- if "%DEPLOY%" == "true" (python -m pip install dropbox)
# Trick qmake to not work through MSYS
- del /F "C:\Program Files\Git\usr\bin\sh.exe"
- del /F "C:\Program Files\Git\bin\sh.exe"
@ -244,21 +255,7 @@ notifications:
after_test:
- if "%DEPLOY%" == "true" (mingw32-make install)
artifacts:
- path: build/package/valentina
name: valentina-win-$(QT_VERSION)-$(APPVEYOR_REPO_BRANCH)-$(APPVEYOR_REPO_COMMIT)
# to run your custom scripts instead of provider deployments
deploy_script:
- ps: ../scripts/appveyor-deploy.ps1
deploy:
- provider: BinTray
username: dismine
api_key:
secure: dlVBgPG66AfYTbgi9EQFaK4lZeF77H6/aiuKlmCWP02/i85HLtCMnlOkyWJR5XCu
subject: dismine
repo: Valentina
package: valentina-win_auto-upload
publish: true
override: true
version: 0.7.46
on:
DEPLOY: true
artifact: valentina-win-$(QT_VERSION)-$(APPVEYOR_REPO_BRANCH)-$(APPVEYOR_REPO_COMMIT)

View File

@ -0,0 +1,29 @@
$env:ROOT_FOLDER = "C:\projects\valentina";
$env:BUILD_FOLDER = "$env:ROOT_FOLDER\build";
$file_name = "valentina-win-$env:PLATFORM-$env:QT_VERSION-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT.tar.xz";
if($env:DEPLOY -eq "true") {
Write-Host "[CI] Starting packing." -ForegroundColor Green;
& $env:PYTHON\python.exe "$env:ROOT_FOLDER\scripts\deploy.py" pack "$env:BUILD_FOLDER\package\valentina" "$env:BUILD_FOLDER\package\$file_name";
if ($LastExitCode -ne 0) {
Write-Error -Message "[CI] Error creating an archive." -Category InvalidResult;
exit 1;
} else {
Write-Host "[CI] Done." -ForegroundColor Green;
}
Write-Host "[CI] Uploading." -ForegroundColor Green;
& $env:PYTHON\python.exe "$env:ROOT_FOLDER\scripts\deploy.py" upload $env:ACCESS_TOKEN "$env:BUILD_FOLDER\package\$file_name" "/0.7.x/Windows/$file_name";
if ($LastExitCode -ne 0) {
Write-Error -Message "[CI] Error uploading an artifact." -Category InvalidResult;
exit 1;
} else {
Write-Host "[CI] Uploading has been finished." -ForegroundColor Green;
}
Exit 0;
}
else {
Write-Host "[CI] No deployment needed." -ForegroundColor Green;
Exit 0;
}

129
scripts/deploy.py Normal file
View File

@ -0,0 +1,129 @@
import argparse
import os
import pathlib
import shutil
import sys
import dropbox
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.exceptions import ApiError, AuthError
from dropbox.files import WriteMode
APP_KEY = "v33m5tjz020h7uy"
def run_auth():
"""
Use to generate a refresh token
"""
auth_flow = DropboxOAuth2FlowNoRedirect(APP_KEY, use_pkce=True, token_access_type='offline')
authorize_url = auth_flow.start()
print("1. Go to: " + authorize_url)
print("2. Click \"Allow\" (you might have to log in first).")
print("3. Copy the authorization code.")
auth_code = input("Enter the authorization code here: ").strip()
try:
oauth_result = auth_flow.finish(auth_code)
except Exception as e:
print('Error: %s' % (e,))
exit(1)
print("Refresh token: %s" % oauth_result.refresh_token)
def run_pack(source, destination):
"""
Pack folder. Automatically fills arguments for shutil.make_archive.
:param source: path to source root directory. Example: '/path/to/folder/'
:param destination: path to resulting zip archive. The path must include a format suffix.
Example: '/path/to/folder.zip'
"""
base = os.path.basename(destination)
name = base.split('.')[0]
formats = {
".zip": "zip",
".tar.xz": "xztar"
}
suffix = ''.join(pathlib.Path(base).suffixes)
format = formats.get(suffix, None)
archive_from = pathlib.Path(source).parent
archive_to = os.path.basename(source.strip(os.sep))
print(source, destination, archive_from)
shutil.make_archive(name, format, archive_from, archive_to)
shutil.move('%s%s' % (name, suffix), destination)
def run_upload(refresh_token, file, path):
with dropbox.Dropbox(oauth2_refresh_token=refresh_token, app_key=APP_KEY) as dbx:
# Check that the access token is valid
try:
dbx.users_get_current_account()
except AuthError:
sys.exit("ERROR: Invalid access token; try re-generating an "
"access token from the app console on the web.")
print("Uploading " + file + " to Dropbox as " + path + "...")
try:
with open(file, "rb") as f:
dbx.files_upload(f.read(), path, mode=WriteMode('overwrite'))
except ApiError as err:
# This checks for the specific error where a user doesn't have
# enough Dropbox space quota to upload this file
if (err.error.is_path() and
err.error.get_path().reason.is_insufficient_space()):
sys.exit("ERROR: Cannot deploy; insufficient space.")
elif err.user_message_text:
print(err.user_message_text)
sys.exit()
else:
print(err)
sys.exit()
print("Successfully uploaded")
def parse_args(args=None):
parser = argparse.ArgumentParser(prog='app')
cmds = parser.add_subparsers(help='commands')
def cmd(name, **kw):
p = cmds.add_parser(name, **kw)
p.set_defaults(cmd=name)
p.arg = lambda *a, **kw: p.add_argument(*a, **kw) and p
p.exe = lambda f: p.set_defaults(exe=f) and p
# global options
# p.arg('-s', '--settings', help='application settings')
return p
cmd('auth', help='Authorize application') \
.exe(lambda _: (
run_auth()
))
cmd('pack', help='Compress folder') \
.arg('source', type=str, help='Path to folder or file') \
.arg('destination', type=str, help='Path to resulting zip archive') \
.exe(lambda a: (
run_pack(a.source, a.destination)
))
cmd('upload', help='Upload file with override') \
.arg('refresh_token', type=str, help='Refresh token') \
.arg('file', type=str, help='Path to file') \
.arg('path', type=str, help='Path on disk') \
.exe(lambda a: (
run_upload(a.refresh_token, a.file, a.path)
))
args = parser.parse_args(args)
if not hasattr(args, 'exe'):
parser.print_usage()
else:
args.exe(args)
if __name__ == '__main__':
parse_args()

View File

@ -1,33 +0,0 @@
{
"package": {
"name": "valentina-osx_auto-upload",
"repo": "Valentina",
"subject": "dismine",
"desc": "Was pushed completely automatically",
"website_url": "https://valentinaproject.bitbucket.io",
"issue_tracker_url": "https://gitlab.com/smart-pattern/valentina/-/issues",
"vcs_url": "https://gitlab.com/smart-pattern/valentina",
"github_use_tag_release_notes": false,
"licenses": ["GPL-3.0"],
"labels": ["patternmaking"],
"public_download_numbers": false,
"public_stats": false
},
"version": {
"name": "0.7.46",
"desc": "Test branch release",
"released": "2021-03-31",
"vcs_tag": "v0.7.46",
"gpgSign": false
},
"files":
[
{"includePattern": "./(valentina-osx-.*\\.tar.gz)", "uploadPattern": "$1",
"matrixParams": {
"override": 1 }
}
],
"publish": true
}

View File

@ -110,6 +110,11 @@ void dx_iface::writeEntity(DRW_Entity* e){
}
}
std::string dx_iface::ErrorString() const
{
return dxfW->ErrorString();
}
void dx_iface::writeHeader(DRW_Header &data){
//complete copy of header vars:
data = cData.headerC;

View File

@ -101,6 +101,8 @@ public:
bool fileExport(bool binary);
void writeEntity(DRW_Entity* e);
std::string ErrorString() const;
//reimplement virtual DRW_Interface functions
//writer part, send all in class dx_data to writer
virtual void writeHeader(DRW_Header& data) override;

View File

@ -123,55 +123,66 @@ bool dxfRW::read(DRW_Interface *interface_, bool ext){
bool dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin){
bool isOk = false;
std::ofstream filestr;
filestr.exceptions(std::ifstream::failbit | std::ifstream::badbit);
version = ver;
binFile = bin;
iface = interface_;
if (binFile) {
filestr.open (fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc);
//write sentinel
filestr << "AutoCAD Binary DXF\r\n" << static_cast<char>(26) << '\0';
writer = new dxfWriterBinary(&filestr);
DRW_DBG("dxfRW::read binary file\n");
} else {
filestr.open (fileName.c_str(), std::ios_base::out | std::ios::trunc);
writer = new dxfWriterAscii(&filestr);
std::string comm = std::string("dxfrw ") + std::string(DRW_VERSION);
writer->writeString(999, comm);
}
DRW_Header header;
iface->writeHeader(header);
writer->writeString(0, "SECTION");
entCount =FIRSTHANDLE;
header.write(writer, version);
writer->writeString(0, "ENDSEC");
if (ver > DRW::AC1009) {
try
{
if (binFile) {
filestr.open (fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc);
//write sentinel
filestr << "AutoCAD Binary DXF\r\n" << static_cast<char>(26) << '\0';
writer = new dxfWriterBinary(&filestr);
DRW_DBG("dxfRW::read binary file\n");
} else {
filestr.open (fileName.c_str(), std::ios_base::out | std::ios::trunc);
writer = new dxfWriterAscii(&filestr);
std::string comm = std::string("dxfrw ") + std::string(DRW_VERSION);
writer->writeString(999, comm);
}
DRW_Header header;
iface->writeHeader(header);
writer->writeString(0, "SECTION");
writer->writeString(2, "CLASSES");
entCount =FIRSTHANDLE;
header.write(writer, version);
writer->writeString(0, "ENDSEC");
}
writer->writeString(0, "SECTION");
writer->writeString(2, "TABLES");
writeTables();
writer->writeString(0, "ENDSEC");
writer->writeString(0, "SECTION");
writer->writeString(2, "BLOCKS");
writeBlocks();
writer->writeString(0, "ENDSEC");
writer->writeString(0, "SECTION");
writer->writeString(2, "ENTITIES");
iface->writeEntities();
writer->writeString(0, "ENDSEC");
if (version > DRW::AC1009) {
if (ver > DRW::AC1009) {
writer->writeString(0, "SECTION");
writer->writeString(2, "CLASSES");
writer->writeString(0, "ENDSEC");
}
writer->writeString(0, "SECTION");
writer->writeString(2, "OBJECTS");
writeObjects();
writer->writeString(2, "TABLES");
writeTables();
writer->writeString(0, "ENDSEC");
writer->writeString(0, "SECTION");
writer->writeString(2, "BLOCKS");
writeBlocks();
writer->writeString(0, "ENDSEC");
writer->writeString(0, "SECTION");
writer->writeString(2, "ENTITIES");
iface->writeEntities();
writer->writeString(0, "ENDSEC");
if (version > DRW::AC1009) {
writer->writeString(0, "SECTION");
writer->writeString(2, "OBJECTS");
writeObjects();
writer->writeString(0, "ENDSEC");
}
writer->writeString(0, "EOF");
filestr.flush();
filestr.close();
}
catch(std::ofstream::failure &writeErr)
{
errorString = writeErr.what();
delete writer;
writer = nullptr;
return isOk;
}
writer->writeString(0, "EOF");
filestr.flush();
filestr.close();
isOk = true;
delete writer;
writer = nullptr;
@ -1160,6 +1171,11 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) {
return true;
}
std::string dxfRW::ErrorString() const
{
return errorString;
}
bool dxfRW::writeInsert(DRW_Insert *ent){
writer->writeString(0, "INSERT");
writeEntity(ent);

View File

@ -72,6 +72,8 @@ public:
bool writeDimension(DRW_Dimension *ent);
void setEllipseParts(int parts){elParts = parts;} /*!< set parts munber when convert ellipse to polyline */
std::string ErrorString() const;
private:
Q_DISABLE_COPY(dxfRW)
/// used by read() to parse the content of the file
@ -144,6 +146,7 @@ private:
int currHandle;
std::string errorString{};
};
#endif // LIBDXFRW_H

View File

@ -138,8 +138,7 @@ bool VDxfEngine::begin(QPaintDevice *pdev)
//---------------------------------------------------------------------------------------------------------------------
bool VDxfEngine::end()
{
const bool res = input->fileExport(m_binary);
return res;
return input->fileExport(m_binary);
}
//---------------------------------------------------------------------------------------------------------------------
@ -611,6 +610,12 @@ void VDxfEngine::SetYScale(const qreal &yscale)
m_yscale = yscale;
}
//---------------------------------------------------------------------------------------------------------------------
QString VDxfEngine::ErrorString() const
{
return QString::fromStdString(input->ErrorString());
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
@ -668,7 +673,7 @@ bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
for(auto detail : details)
{
dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
auto *detailBlock = new dx_ifaceBlock();
QString blockName = detail.GetName();
if (m_version <= DRW::AC1009)
@ -691,7 +696,7 @@ bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
input->AddBlock(detailBlock);
DRW_Insert *insert = new DRW_Insert();
auto *insert = new DRW_Insert();
insert->name = blockName.toStdString();
insert->layer = '1';
@ -869,7 +874,7 @@ bool VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details)
for(auto detail : details)
{
dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
auto *detailBlock = new dx_ifaceBlock();
QString blockName = detail.GetName();
if (m_version <= DRW::AC1009)
@ -894,7 +899,7 @@ bool VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details)
input->AddBlock(detailBlock);
DRW_Insert *insert = new DRW_Insert();
auto *insert = new DRW_Insert();
insert->name = blockName.toStdString();
insert->layer = '1';

View File

@ -98,6 +98,8 @@ public:
qreal GetYScale() const;
void SetYScale(const qreal &yscale);
QString ErrorString() const;
private:
Q_DISABLE_COPY(VDxfEngine)
QSize size;

View File

@ -214,6 +214,12 @@ bool VDxfPaintDevice::ExportToASTM(const QVector<VLayoutPiece> &details) const
return res;
}
//---------------------------------------------------------------------------------------------------------------------
QString VDxfPaintDevice::ErrorString() const
{
return engine->ErrorString();
}
//---------------------------------------------------------------------------------------------------------------------
int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
{

View File

@ -75,6 +75,8 @@ public:
bool ExportToAAMA(const QVector<VLayoutPiece> &details) const;
bool ExportToASTM(const QVector<VLayoutPiece> &details) const;
QString ErrorString() const;
protected:
virtual int metric(PaintDeviceMetric metric) const override;
private:

View File

@ -304,7 +304,11 @@ void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QList<Q
{
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
painter.end();
if (not painter.end())
{
qCritical() << tr("Can't create an flat dxf file.")
<< generator.ErrorString();
}
}
RestoreTextAfterDXF(endStringPlaceholder, details);
@ -322,7 +326,11 @@ void VLayoutExporter::ExportToAAMADXF(const QVector<VLayoutPiece> &details) cons
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale);
generator.ExportToAAMA(details);
if (not generator.ExportToAAMA(details))
{
qCritical() << tr("Can't create an AAMA dxf file.")
<< generator.ErrorString();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -337,7 +345,11 @@ void VLayoutExporter::ExportToASTMDXF(const QVector<VLayoutPiece> &details) cons
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale);
generator.ExportToASTM(details);
if (not generator.ExportToASTM(details))
{
qCritical() << tr("Can't create an ASTM dxf file.")
<< generator.ErrorString();
}
}
//---------------------------------------------------------------------------------------------------------------------