diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-25 19:25:11 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-25 19:25:11 +0200 |
| commit | 6549d8672a93893599e921d9f1938af7dcabb8bf (patch) | |
| tree | dc64b671e2186ab2252ace2f7cbf592b967b3cb2 /Software/Visual_Studio/Embroidery | |
| parent | a89c62d8fc0401b437ecb51d1bbf46b8c66b9b77 (diff) | |
| download | Tango-6549d8672a93893599e921d9f1938af7dcabb8bf.tar.gz Tango-6549d8672a93893599e921d9f1938af7dcabb8bf.zip | |
Working on PES embroidery...
Diffstat (limited to 'Software/Visual_Studio/Embroidery')
14 files changed, 653 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/ReadMe.txt b/Software/Visual_Studio/Embroidery/libEmbroideryTest/ReadMe.txt new file mode 100644 index 000000000..1db00ff6b --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/ReadMe.txt @@ -0,0 +1,40 @@ +======================================================================== + CONSOLE APPLICATION : libEmbroideryTest Project Overview +======================================================================== + +AppWizard has created this libEmbroideryTest application for you. + +This file contains a summary of what you will find in each of the files that +make up your libEmbroideryTest application. + + +libEmbroideryTest.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +libEmbroideryTest.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +libEmbroideryTest.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named libEmbroideryTest.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp new file mode 100644 index 000000000..64c581400 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp @@ -0,0 +1,48 @@ +#include "stdafx.h" +#include "emb-pattern.h" +#include <iostream> +#include <iomanip> +#include "thread-color.h" + +using namespace std; + + + +int main() +{ + EmbPattern* p = embPattern_create(); + + int ok = embPattern_read(p, "C:\\Tests\\Blueangel.pes"); + + if (ok) + { + cout << "Embroidery file read OK" << endl; + cout << "Writing Stitches..." << endl; + + int stitchCount = embStitchList_count(p->stitchList); + + int t_count = embThreadList_count(p->threadList); + + for (size_t i = 0; i < t_count; i++) + { + cout << "R: " << (int)p->threadList[i].thread.color.r << ", "; + cout << "G: " << (int)p->threadList[i].thread.color.g << ", "; + cout << "B: " << (int)p->threadList[i].thread.color.b << endl; + } + + for (size_t i = 0; i < 100; i++) + { + + EmbStitch stitch = p->stitchList[i].stitch; + cout << i << " X: " << setprecision(3) << stitch.xx << " Y: " << setprecision(3) << stitch.yy << " Color Index: " << stitch.color << endl; + } + } + else + { + cout << "Embroidery file read failed!"; + } + + getchar(); + + return 0; +} diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj new file mode 100644 index 000000000..e0fa10d62 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>15.0</VCProjectVersion> + <ProjectGuid>{0565AEEC-ED1B-4F0E-A277-D33F852207BC}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>libEmbroideryTest</RootNamespace> + <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\libembroidery;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <Text Include="ReadMe.txt" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="stdafx.h" /> + <ClInclude Include="targetver.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="libEmbroideryTest.cpp" /> + <ClCompile Include="stdafx.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\project-files\visualstudio\libEmbroideryVS2008.vcxproj"> + <Project>{bd30c7bd-9230-4ed7-b581-11f14041909d}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj.filters b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj.filters new file mode 100644 index 000000000..0c38977dc --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.vcxproj.filters @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <Text Include="ReadMe.txt" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="stdafx.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="targetver.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="stdafx.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="libEmbroideryTest.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.cpp b/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.cpp new file mode 100644 index 000000000..22d9737e8 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// libEmbroideryTest.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.h b/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.h new file mode 100644 index 000000000..b005a839d --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#include <stdio.h> +#include <tchar.h> + + + +// TODO: reference additional headers your program requires here diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/targetver.h b/Software/Visual_Studio/Embroidery/libEmbroideryTest/targetver.h new file mode 100644 index 000000000..87c0086de --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include <SDKDDKVer.h> diff --git a/Software/Visual_Studio/Embroidery/libembroidery-convert/README.md b/Software/Visual_Studio/Embroidery/libembroidery-convert/README.md new file mode 100644 index 000000000..cca769bb6 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libembroidery-convert/README.md @@ -0,0 +1,12 @@ +libembroidery-convert +--------------------- + +This folder contains the command line conversion tool: libembroidery-convert. + +Usage +----- + +Display usage information and supported formats: +``` +./libembroidery-convert --help +``` diff --git a/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-generate-todo b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-generate-todo new file mode 100644 index 000000000..34117835e --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-generate-todo @@ -0,0 +1,49 @@ +#!/bin/sh + +OUTPUTFILE="TODO" +#include the line number in output +#do not search temporary, object, and moc files +GREPCMD="grep --line-number --recursive --exclude=*.*~ --exclude=*.o --exclude=moc*.cpp --exclude=*Makefile* --exclude=*TODO* --exclude=*generate-todo* --exclude=*_memleak*" +DIRECTORY="./" +TODOSTRING="TODO" +BUGSTRING="BUG" +HACKSTRING="HACK" +WARNSTRING="WARNING" +NOTESTRING="NOTE" + +rm -f ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +echo "This list was generated on:" >> ${OUTPUTFILE} +date >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE} + +echo "==================================================" >> ${OUTPUTFILE} +echo "TODO" >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +${GREPCMD} ${TODOSTRING} ${DIRECTORY} >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE} + +echo "==================================================" >> ${OUTPUTFILE} +echo "BUG" >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +${GREPCMD} ${BUGSTRING} ${DIRECTORY} >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE} + +echo "==================================================" >> ${OUTPUTFILE} +echo "HACK" >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +${GREPCMD} ${HACKSTRING} ${DIRECTORY} >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE} + +echo "==================================================" >> ${OUTPUTFILE} +echo "WARNING" >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +${GREPCMD} ${WARNSTRING} ${DIRECTORY} >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE} + +echo "==================================================" >> ${OUTPUTFILE} +echo "NOTE" >> ${OUTPUTFILE} +echo "==================================================" >> ${OUTPUTFILE} +${GREPCMD} ${NOTESTRING} ${DIRECTORY} >> ${OUTPUTFILE} +echo "" >> ${OUTPUTFILE}
\ No newline at end of file diff --git a/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-main.c b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-main.c new file mode 100644 index 000000000..f557b1f7c --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-main.c @@ -0,0 +1,196 @@ +#include "emb-reader-writer.h" +#include "emb-logging.h" +#include "emb-format.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +void usage(void) +{ + EmbFormatList* formatList = 0; + EmbFormatList* curFormat = 0; + const char* extension = 0; + const char* description = 0; + char readerState; + char writerState; + int numReaders = 0; + int numWriters = 0; + printf(" _____________________________________________________________________________ \n"); + printf("| _ _ ___ ___ _____ ___ ___ __ _ ___ ___ ___ _ _ |\n"); + printf("| | | | | _ \\| __| | _ \\| _ \\ / \\| | \\| __| _ \\ | | | |\n"); + printf("| | |_| | _ <| __| | | | _ <| /| () | | |) | __| / |__ | |\n"); + printf("| |___|_|___/|___|_|_|_|___/|_|\\_\\\\__/|_|___/|___|_|\\_\\|___| |\n"); + printf("| ___ __ ___ _ _ _ ___ ___ _____ |\n"); + printf("| / __|/ \\| | | \\ / | __| _ \\|_ _| |\n"); + printf("| ( (__| () | | | |\\ \\/ /| __| / | | |\n"); + printf("| \\___|\\__/|_|___| \\__/ |___|_|\\_\\ |_| |\n"); +#if defined(EMSCRIPTEN) + printf("| |\n"); + printf("| * Emscripten Version * |\n"); +#endif + printf("|_____________________________________________________________________________|\n"); + printf("| |\n"); + printf("| Usage: libembroidery-convert fileToRead filesToWrite ... |\n"); + printf("|_____________________________________________________________________________|\n"); + printf(" \n"); + printf(" _____________________________________________________________________________ \n"); + printf("| |\n"); + printf("| List of Formats |\n"); + printf("|_____________________________________________________________________________|\n"); + printf("| |\n"); + printf("| 'S' = Yes, and is considered stable. |\n"); + printf("| 'U' = Yes, but may be unstable. |\n"); + printf("| ' ' = No. |\n"); + printf("|_____________________________________________________________________________|\n"); + printf("| | | | |\n"); + printf("| Format | Read | Write | Description |\n"); + printf("|________|_______|_______|____________________________________________________|\n"); + printf("| | | | |\n"); + + formatList = embFormatList_create(); + if(!formatList) { embLog_error("libembroidery-convert-main.c usage(), cannot allocate memory for formatList\n"); return; } + curFormat = formatList; + while(curFormat) + { + extension = embFormat_extension(curFormat); + description = embFormat_description(curFormat); + readerState = embFormat_readerState(curFormat); + writerState = embFormat_writerState(curFormat); + + numReaders += readerState != ' '? 1 : 0; + numWriters += writerState != ' '? 1 : 0; + printf("| %-4s | %c | %c | %-49s |\n", extension, readerState, writerState, description); + + curFormat = curFormat->next; + } + embFormatList_free(formatList); + formatList = 0; + + printf("|________|_______|_______|____________________________________________________|\n"); + printf("| | | | |\n"); + printf("| Total: | %3d | %3d | |\n", numReaders, numWriters); + printf("|________|_______|_______|____________________________________________________|\n"); + printf("| |\n"); + printf("| http://embroidermodder.org |\n"); + printf("|_____________________________________________________________________________|\n"); + printf("\n"); +} + +/* TODO: Add capability for converting multiple files of various types to a single format. Currently, we only convert a single file to multiple formats. */ + +/*! Developers incorporating libembroidery into another project should use the SHORT_WAY of using libembroidery. It uses + * convenience functions and is approximately 20 lines shorter than the long way. + * + * Developers who are interested improving libembroidery or using it to its fullest extent should use the LONG_WAY. + * It essentially does the same work the convenience function do. + * + * Both methods are acceptable and it is up to you which to choose. Both will stay here for regression testing. + */ + +#define SHORT_WAY + +int main(int argc, const char* argv[]) +{ + EmbPattern* p = 0; + int successful = 0, i = 0; + int formatType; +#ifdef SHORT_WAY + if(argc < 3) + { + usage(); + exit(0); + } + + p = embPattern_create(); + if(!p) { embLog_error("libembroidery-convert-main.c main(), cannot allocate memory for p\n"); exit(1); } + + successful = embPattern_read(p, argv[1]); + if(!successful) + { + embLog_error("libembroidery-convert-main.c main(), reading file %s was unsuccessful\n", argv[1]); + embPattern_free(p); + exit(1); + } + + formatType = embFormat_typeFromName(argv[1]); + if(formatType == EMBFORMAT_OBJECTONLY && argc == 3) /* TODO: fix this to work when writing multiple files */ + { + formatType = embFormat_typeFromName(argv[2]); + if(formatType == EMBFORMAT_STITCHONLY) + embPattern_movePolylinesToStitchList(p); + } + + i = 2; + for(i = 2; i < argc; i++) + { + successful = embPattern_write(p, argv[i]); + if(!successful) + embLog_error("libembroidery-convert-main.c main(), writing file %s was unsuccessful\n", argv[i]); + } + + embPattern_free(p); + return 0; +#else /* LONG_WAY */ + + EmbReaderWriter* reader = 0, *writer = 0; + + if(argc < 3) + { + usage(); + exit(0); + } + + p = embPattern_create(); + if(!p) { embLog_error("libembroidery-convert-main.c main(), cannot allocate memory for p\n"); exit(1); } + + successful = 0; + reader = embReaderWriter_getByFileName(argv[1]); + if(!reader) + { + successful = 0; + embLog_error("libembroidery-convert-main.c main(), unsupported read file type: %s\n", argv[1]); + } + else + { + successful = reader->reader(p, argv[1]); + if(!successful) embLog_error("libembroidery-convert-main.c main(), reading file was unsuccessful: %s\n", argv[1]); + } + free(reader); + if(!successful) + { + embPattern_free(p); + exit(1); + } + + formatType = embFormat_typeFromName(argv[1]); + if(formatType == EMBFORMAT_OBJECTONLY && argc == 3) /* TODO: fix this to work when writing multiple files */ + { + formatType = embFormat_typeFromName(argv[2]); + if(formatType == EMBFORMAT_STITCHONLY) + embPattern_movePolylinesToStitchList(p); + } + + i = 2; + for(i = 2; i < argc; i++) + { + writer = embReaderWriter_getByFileName(argv[i]); + if(!writer) + { + embLog_error("libembroidery-convert-main.c main(), unsupported write file type: %s\n", argv[i]); + } + else + { + successful = writer->writer(p, argv[i]); + if(!successful) + embLog_error("libembroidery-convert-main.c main(), writing file %s was unsuccessful\n", argv[i]); + } + free(writer); + } + + embPattern_free(p); + return 0; +#endif /* SHORT_WAY */ + +} + +/* kate: bom off; indent-mode cstyle; indent-width 4; replace-trailing-space-save on; */ diff --git a/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-valgrind b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-valgrind new file mode 100644 index 000000000..450b1ecac --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert-valgrind @@ -0,0 +1,18 @@ +#!/bin/bash +valgrind --leak-check=full --show-reachable=yes --error-limit=no --suppressions=../valgrind-supp/./valgrind-qt.supp --suppressions=../valgrind-supp/./valgrind-misc.supp --gen-suppressions=all --log-file=_memleak.txt -v ./libembroidery-convert "$@" +cat ./_memleak.txt | ../valgrind-supp/./valgrind-create-suppressions.sh > _memleak.supp + +MEMORYLEAKS=$(cat "_memleak.txt" | grep "All heap blocks were freed -- no leaks are possible") + +echo "==============================" +if [[ -z "$MEMORYLEAKS" ]]; then + echo $(cat "_memleak.txt" | grep "LEAK SUMMARY:") + echo $(cat "_memleak.txt" | grep "definitely lost:") + echo $(cat "_memleak.txt" | grep "indirectly lost:") + echo $(cat "_memleak.txt" | grep "possibly lost:") + echo $(cat "_memleak.txt" | grep "still reachable:") + echo "Review _memleak.txt for more information." +else + echo "No memory leaks found :D" +fi +echo "==============================" diff --git a/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert.pro b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert.pro new file mode 100644 index 000000000..e5c662e07 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/libembroidery-convert/libembroidery-convert.pro @@ -0,0 +1,49 @@ +TEMPLATE = app +CONFIG -= debug_and_release qt +CONFIG += console +CONFIG -= app_bundle +CONFIG += silent #Comment this out for verbose output +#CONFIG += deploy #Uncomment this to create a release build or by running this from the terminal: qmake CONFIG+=deploy + +deploy { + message("release build") + CONFIG -= debug + CONFIG += release +} else { + message("debug build") + CONFIG += debug #This adds -g to the compiler flags so valgrind can locate the exact line. + CONFIG -= release +} + +!msvc { + !macx { #TODO: better clang support + #QMAKE_LFLAGS += -static-libgcc #TODO: Only static link when targeting Windows and building with MinGW (natively or cross-compile) + } +} + +TARGET = libembroidery-convert + +OBJECTS_DIR = .obj +MOC_DIR = .moc + +INCLUDEPATH += \ +../libembroidery \ +../libcgeometry \ +$$PWD \ + +SOURCES += libembroidery-convert-main.c + +include( ../libembroidery/libembroidery.pri ) + +#Install Linux/Unix +unix:!macx { +QMAKE_STRIP = echo #Suppress strip errors "File format not recognized" +QMAKE_DEL_DIR += --ignore-fail-on-non-empty #Suppress rmdir errors "Directory not empty" + +convertbin.path = "/usr/bin" +convertbin.files = "libembroidery-convert" +convertbin.extra = "strip libembroidery-convert; cp -f libembroidery-convert /usr/bin/libembroidery-convert" #ensure the binary gets stripped of debug symbols + +INSTALLS += convertbin \ + +}
\ No newline at end of file diff --git a/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj b/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj index 5582f9322..3814fd65c 100644 --- a/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj +++ b/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj @@ -25,7 +25,7 @@ <WholeProgramOptimization>true</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> + <ConfigurationType>StaticLibrary</ConfigurationType> <PlatformToolset>v141</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> diff --git a/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj.filters b/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj.filters index 3a249cc5a..330d10aa8 100644 --- a/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj.filters +++ b/Software/Visual_Studio/Embroidery/project-files/visualstudio/libEmbroideryVS2008.vcxproj.filters @@ -306,6 +306,12 @@ <ClCompile Include="..\..\libembroidery\geom-line.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\..\libembroidery\format-gc.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\libembroidery\format-t01.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\libembroidery\compound-file-common.h"> @@ -599,13 +605,16 @@ <ClInclude Include="..\..\libembroidery\thread-color.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\..\libembroidery\geom-arc.h"> + <ClInclude Include="..\..\libembroidery\format-t01.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\libgeometry\geom-arc.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\..\libembroidery\geom-circle.h"> + <ClInclude Include="..\..\libgeometry\geom-circle.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\..\libembroidery\geom-line.h"> + <ClInclude Include="..\..\libgeometry\geom-line.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> |
