Compare commits

..

24 Commits

Author SHA1 Message Date
turn211 7b5e18a075 Gui: ProDark Stylesheet QT Icon Fix
forum thread: https://forum.freecadweb.org/viewtopic.php?f=34&t=57427
2021-04-15 11:17:08 +02:00
turn211 ed87d3aceb [Stylesheet] ProDark: major bugfix for add-ons
https://forum.freecadweb.org/viewtopic.php?f=34&t=55134&start=100
2021-04-15 11:15:49 +02:00
turn211 133ef7173d Gui: Update usability enhancements to ProDark theme
forum thread: https://forum.freecadweb.org/viewtopic.php?f=34&t=55134
2021-04-15 11:15:33 +02:00
donovaly 8e7a8b1e7b [FEM] fix specific heat of air
- also adjust values slightly according to various sources

Since a factor 1000 is a big mistake and air is the most common gas, please commit this also for FC 0.19
2021-04-14 14:06:58 +02:00
Chris Hennes b3abe32683 [Draft] Eliminate required GUI for importDXF 2021-04-14 13:59:36 +02:00
Chris Hennes 53b4eb0b2e [Start] Correct TestStart installation location 2021-04-14 13:57:42 +02:00
Chris Hennes 51855e5341 [GUI] Stylesheet fix for icons in Qt file dialog
Work by @turn211.
2021-04-14 13:34:28 +02:00
wmayer 12055a22d8 Py: fix memory leak 2021-04-14 13:24:32 +02:00
Chris Hennes 6f67fbc425 [GUI] Remove explicit triangle styling from tabs
On Windows the lower tabs of the PropertyView were being set to
triangular, which breaks stylesheets. This removes that code, so they
now take on whatever the standard shape is on the system.

Fixes #0004599
2021-04-04 09:58:35 +02:00
Matthijs Kooijman 83e308c8eb Gui: Enable compression of tablet motion events
By default (on platforms that support it, X11 and Windows currently) QT
applies compression for high frequency events (mouse move, touch, window
resizes) to keep things smooth even when handling the event takes a
while (e.g. to calculate snapping).

However, tablet pen move events (and mouse move events synthesised from
those, which is what FreeCAD uses) are not compressed by default (to
allow maximum precision when e.g. hand-drawing curves), leading to
unacceptable slowdowns using a tablet pen.

This commit enable compression for tablet events here to solve that and
make use of a tablet just as smooth as a mouse with FreeCAD.

This can (and likely will) lead to some movement events being dropped,
but since there is no freeform curve drawing tool, that should not be
problematic (and if it is ever added, it could still work without
compression if the mouse movement event handler is written to be fast
enough).
2021-03-29 14:10:56 +02:00
donovaly de1d0acaea [installer] improve uninstalling
- fix missing removal of the *.FCStd extension for local users
- FC-specific file extensions might appear in the Windows registry. The aim of the uninstaller is to leave a clear registry without traces of FC.
2021-03-28 16:44:20 +02:00
wmayer e239684102 TD: fixes #0004598: Segfault when deleting template without page 2021-03-28 13:40:35 +02:00
tomate44 aedd1f96e4 PartDesign Helix: update NbTurns in Pitch-Height-Angle mode 2021-03-28 13:17:09 +02:00
lvk88 e7c796edb4 [GUI] Enable dragging in dependency graph view
This commit makes it possible to drag the dependency graph using the
left mouse button.

See issue #3896.
2021-03-28 12:10:43 +02:00
wmayer 6858586642 Import: [skip ci] avoid conflicting class names in global namespace 2021-03-19 15:18:57 +01:00
wmayer a88db11e0a Fem: [skip ci] set backend of matplotlib to Qt5Agg 2021-03-11 20:48:53 +01:00
donovaly f4574cf02d [Gui] fix HiDPI rounding bug
As reported in https://forum.freecadweb.org/viewtopic.php?f=10&t=56425&start=20#p485809
this PR fixes the problem reported here: https://forum.freecadweb.org/viewtopic.php?f=10&t=56425&start=20#p485759
2021-03-10 15:23:33 +01:00
Chris Hennes 159a71bba7 [0.19][Web] Remove HiDPI fix when using QTWEBVIEW
The screen scale adjustment code here should not be necessary when using
the Chromium-based QtWebView widget, which correctly handles logical vs.
device px units. The scaling causes poor font size choice when used on
ultrawide monitors, as reported in
https://forum.freecadweb.org/viewtopic.php?p=485431
2021-03-08 18:51:06 +01:00
donovaly dfc3e2b9a6 [Main] set Coin environment variable
as discussed in https://forum.freecadweb.org/viewtopic.php?f=10&t=56386&start=10 we need to set this environment variable for Coin on Windows
2021-03-08 15:21:17 +01:00
donovaly 27b568e4e4 update for FC 0.19.0 2021-03-05 12:24:05 +01:00
wmayer a266852510 PD: AddressSanitizer: heap-use-after-free
Fix crash inside TaskDlgSketchBasedParameters::reject()
2021-03-03 15:53:44 +01:00
donovaly 408128838c [PD] fix multi-transform View
- fixes bug 4581
  See the first issue reported here:
  https://forum.freecadweb.org/viewtopic.php?f=3&t=56093#p482553

- also fix issue that one could set 1 occurrence for polar patterns despite 2 are required at least

- also fix potential dereferencing null pointer (reported by MSVC)
2021-03-02 10:40:13 +01:00
Yorik van Havre fc0c1069d2 Arch: Fixed SectionPlane outside objects bug in ArchSectionPlane - Fixes #4549 2021-03-01 16:50:10 +01:00
wmayer 5ea583466d Gui: [skip ci] allow to unbind() an ExpressionBinding and automatically unbind it if the observed object has been deleted
For more details see: https://forum.freecadweb.org/viewtopic.php?f=8&t=56097
2021-03-01 16:00:08 +01:00
7382 changed files with 1337293 additions and 2087255 deletions
-66
View File
@@ -1,66 +0,0 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: DontAlign
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: MultiLine
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 100
CompactNamespaces: false
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
-491
View File
@@ -1,491 +0,0 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,boost-*,bugprone-*,
performance-*,readability-*,portability-*,modernize-*,cppcoreguidelines-*,
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard,
-readability-redundant-access-specifiers'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: florians
CheckOptions:
- key: readability-suspicious-call-argument.PrefixSimilarAbove
value: '30'
- key: cppcoreguidelines-no-malloc.Reallocations
value: '::realloc'
- key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
value: '::free;::realloc;::freopen;::fclose'
- key: bugprone-reserved-identifier.Invert
value: 'false'
- key: bugprone-narrowing-conversions.PedanticMode
value: 'false'
- key: bugprone-unused-return-value.CheckedFunctions
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname'
- key: modernize-use-auto.MinTypeNameLength
value: '5'
- key: cppcoreguidelines-macro-usage.CheckCapsOnly
value: 'false'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 'false'
- key: readability-suspicious-call-argument.DiceDissimilarBelow
value: '60'
- key: bugprone-assert-side-effect.IgnoredFunctions
value: __builtin_expect
- key: readability-suspicious-call-argument.Equality
value: 'true'
- key: bugprone-easily-swappable-parameters.QualifiersMix
value: 'false'
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
value: 'true'
- key: bugprone-argument-comment.CommentNullPtrs
value: '0'
- key: cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 'true'
- key: cppcoreguidelines-init-variables.IncludeStyle
value: llvm
- key: modernize-use-nodiscard.ReplacementString
value: '[[nodiscard]]'
- key: modernize-loop-convert.MakeReverseRangeHeader
value: ''
- key: readability-suspicious-call-argument.SuffixSimilarAbove
value: '30'
- key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion
value: 'true'
- key: bugprone-easily-swappable-parameters.IgnoredParameterNames
value: '"";iterator;Iterator;begin;Begin;end;End;first;First;last;Last;lhs;LHS;rhs;RHS'
- key: modernize-loop-convert.UseCxx20ReverseRanges
value: 'true'
- key: cppcoreguidelines-prefer-member-initializer.UseAssignment
value: 'false'
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: readability-function-cognitive-complexity.DescribeBasicIncrements
value: 'true'
- key: bugprone-suspicious-include.ImplementationFileExtensions
value: 'c;cc;cpp;cxx'
- key: modernize-loop-convert.MakeReverseRangeFunction
value: ''
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: 'true'
- key: bugprone-suspicious-missing-comma.SizeThreshold
value: '5'
- key: readability-identifier-naming.IgnoreFailedSplit
value: 'false'
- key: readability-qualified-auto.AddConstToQualified
value: 'true'
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
value: 'true'
- key: bugprone-string-constructor.WarnOnLargeLength
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.OverrideSpelling
value: override
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: 'true'
- key: modernize-make-shared.IgnoreMacros
value: 'true'
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: bugprone-suspicious-enum-usage.StrictMode
value: 'false'
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: ''
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
value: '5'
- key: modernize-use-transparent-functors.SafeMode
value: 'false'
- key: readability-suspicious-call-argument.Levenshtein
value: 'true'
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
value: 'true'
- key: bugprone-string-constructor.LargeLengthThreshold
value: '8388608'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: 'false'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: 'false'
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
value: ''
- key: performance-inefficient-vector-operation.EnableProto
value: 'false'
- key: modernize-make-shared.MakeSmartPtrFunction
value: 'std::make_shared'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: readability-suspicious-call-argument.PrefixDissimilarBelow
value: '25'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: bugprone-easily-swappable-parameters.MinimumLength
value: '2'
- key: portability-simd-intrinsics.Suggest
value: 'false'
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
- key: modernize-use-override.IgnoreDestructors
value: 'false'
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
value: '<memory>'
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
value: 'true'
- key: readability-redundant-string-init.StringNames
value: '::std::basic_string_view;::std::basic_string'
- key: modernize-make-unique.IgnoreDefaultInitialization
value: 'true'
- key: modernize-use-emplace.ContainersWithPushBack
value: '::std::vector;::std::list;::std::deque'
- key: readability-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: modernize-make-unique.IncludeStyle
value: llvm
- key: modernize-use-override.OverrideSpelling
value: override
- key: readability-suspicious-call-argument.LevenshteinDissimilarBelow
value: '50'
- key: bugprone-argument-comment.CommentStringLiterals
value: '0'
- key: concurrency-mt-unsafe.FunctionSet
value: any
- key: readability-identifier-length.IgnoredExceptionVariableNames
value: '^[e]$'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: bugprone-reserved-identifier.AllowedIdentifiers
value: ''
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: 'false'
- key: readability-else-after-return.WarnOnUnfixable
value: 'true'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: modernize-use-emplace.IgnoreImplicitConstructors
value: 'false'
- key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros
value: 'true'
- key: readability-suspicious-call-argument.Substring
value: 'true'
- key: modernize-use-equals-delete.IgnoreMacros
value: 'true'
- key: readability-identifier-length.IgnoredVariableNames
value: ''
- key: readability-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
value: llvm
- key: readability-suspicious-call-argument.Abbreviations
value: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address'
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: 'false'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: performance-unnecessary-value-param.AllowedTypes
value: ''
- key: readability-uniqueptr-delete-release.PreferResetCall
value: 'false'
- key: readability-identifier-length.MinimumExceptionNameLength
value: '2'
- key: cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: cppcoreguidelines-no-malloc.Allocations
value: '::malloc;::calloc'
- key: bugprone-narrowing-conversions.IgnoreConversionFromTypes
value: ''
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: bugprone-suspicious-missing-comma.RatioThreshold
value: '0.200000'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 'false'
- key: readability-identifier-length.IgnoredParameterNames
value: '^[n]$'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 'false'
- key: cppcoreguidelines-init-variables.MathHeader
value: '<math.h>'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: bugprone-reserved-identifier.AggressiveDependentMemberLookup
value: 'false'
- key: readability-suspicious-call-argument.DiceSimilarAbove
value: '70'
- key: modernize-use-equals-default.IgnoreMacros
value: 'true'
- key: readability-suspicious-call-argument.Abbreviation
value: 'true'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 'false'
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: '2'
- key: modernize-use-emplace.SmartPointers
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
- key: cppcoreguidelines-no-malloc.Deallocations
value: '::free'
- key: bugprone-dangling-handle.HandleClasses
value: 'std::basic_string_view;std::experimental::basic_string_view'
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: readability-suspicious-call-argument.JaroWinklerSimilarAbove
value: '85'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: performance-unnecessary-copy-initialization.ExcludedContainerTypes
value: ''
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: 'true'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 'true'
- key: readability-identifier-naming.GetConfigPerFile
value: 'true'
- key: modernize-use-default-member-init.UseAssignment
value: 'false'
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: modernize-use-override.AllowOverrideAndFinal
value: 'false'
- key: cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes
value: ''
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: modernize-pass-by-value.ValuesOnly
value: 'false'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 'false'
- key: modernize-loop-convert.IncludeStyle
value: llvm
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: 'false'
- key: bugprone-narrowing-conversions.WarnWithinTemplateInstantiation
value: 'false'
- key: cert-err33-c.CheckedFunctions
value: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
value: 'false'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
value: 'false'
- key: readability-identifier-naming.AggressiveDependentMemberLookup
value: 'false'
- key: readability-identifier-length.MinimumParameterNameLength
value: '3'
- key: modernize-use-emplace.TupleTypes
value: '::std::pair;::std::tuple'
- key: modernize-use-emplace.TupleMakeFunctions
value: '::std::make_pair;::std::make_tuple'
- key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
value: 'true'
- key: cppcoreguidelines-owning-memory.LegacyResourceProducers
value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
- key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether
value: 'true'
- key: bugprone-argument-comment.StrictMode
value: '0'
- key: modernize-replace-random-shuffle.IncludeStyle
value: llvm
- key: modernize-use-bool-literals.IgnoreMacros
value: 'true'
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
value: 'true'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
value: ''
- key: modernize-avoid-bind.PermissiveParameterList
value: 'false'
- key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold
value: '1'
- key: readability-suspicious-call-argument.Suffix
value: 'true'
- key: readability-suspicious-call-argument.JaroWinklerDissimilarBelow
value: '75'
- key: modernize-use-noexcept.ReplacementString
value: ''
- key: modernize-use-override.FinalSpelling
value: final
- key: modernize-use-using.IgnoreMacros
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.FinalSpelling
value: final
- key: readability-suspicious-call-argument.MinimumIdentifierNameLength
value: '3'
- key: bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion
value: 'true'
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: cppcoreguidelines-pro-type-member-init.UseAssignment
value: 'false'
- key: bugprone-suspicious-include.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: performance-no-automatic-move.AllowedTypes
value: ''
- key: readability-suspicious-call-argument.SubstringDissimilarBelow
value: '40'
- key: bugprone-argument-comment.CommentIntegerLiterals
value: '0'
- key: bugprone-stringview-nullptr.IncludeStyle
value: llvm
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: 'false'
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: bugprone-argument-comment.CommentFloatLiterals
value: '0'
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
value: '16'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: 'false'
- key: readability-else-after-return.WarnOnConditionVariables
value: 'true'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-suspicious-call-argument.SuffixDissimilarBelow
value: '25'
- key: bugprone-argument-comment.CommentCharacterLiterals
value: '0'
- key: cppcoreguidelines-macro-usage.AllowedRegexp
value: '^DEBUG_*'
- key: readability-suspicious-call-argument.LevenshteinSimilarAbove
value: '66'
- key: cppcoreguidelines-narrowing-conversions.PedanticMode
value: 'false'
- key: modernize-make-shared.IgnoreDefaultInitialization
value: 'true'
- key: readability-suspicious-call-argument.JaroWinkler
value: 'true'
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources
value: 'true'
- key: modernize-make-shared.IncludeStyle
value: llvm
- key: readability-suspicious-call-argument.Prefix
value: 'true'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: 'false'
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources
value: 'true'
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: ''
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 'false'
- key: modernize-make-unique.IgnoreMacros
value: 'true'
- key: performance-for-range-copy.AllowedTypes
value: ''
- key: bugprone-argument-comment.CommentBoolLiterals
value: '0'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: bugprone-argument-comment.CommentUserDefinedLiterals
value: '0'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: performance-inefficient-string-concatenation.StrictMode
value: 'false'
- key: readability-redundant-declaration.IgnoreMacros
value: 'true'
- key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes
value: 'bool;Bool;_Bool;it;It;iterator;Iterator;inputit;InputIt;forwardit;ForwardIt;bidirit;BidirIt;constiterator;const_iterator;Const_Iterator;Constiterator;ConstIterator;RandomIt;randomit;random_iterator;ReverseIt;reverse_iterator;reverse_const_iterator;ConstReverseIterator;Const_Reverse_Iterator;const_reverse_iterator;Constreverseiterator;constreverseiterator'
- key: modernize-make-unique.MakeSmartPtrFunction
value: 'std::make_unique'
- key: portability-restrict-system-includes.Includes
value: '*'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 'false'
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
value: '<memory>'
- key: bugprone-signal-handler.AsyncSafeFunctionSet
value: POSIX
- key: bugprone-easily-swappable-parameters.ModelImplicitConversions
value: 'true'
- key: readability-suspicious-call-argument.SubstringSimilarAbove
value: '50'
- key: cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation
value: 'false'
- key: readability-identifier-length.MinimumVariableNameLength
value: '3'
- key: cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth
value: 'true'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables
value: 'false'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
value: 'false'
- key: modernize-use-noexcept.UseNoexceptFalse
value: 'true'
- key: readability-function-cognitive-complexity.Threshold
value: '25'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 'true'
- key: bugprone-argument-comment.IgnoreSingleArgument
value: '0'
- key: bugprone-narrowing-conversions.WarnOnEquivalentBitWidth
value: 'true'
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
value: 'false'
- key: performance-faster-string-find.StringLikeClasses
value: '::std::basic_string;::std::basic_string_view'
- key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
value: 'true'
- key: bugprone-assert-side-effect.CheckFunctionCalls
value: 'false'
- key: bugprone-string-constructor.StringNames
value: '::std::basic_string;::std::basic_string_view'
- key: bugprone-assert-side-effect.AssertMacros
value: assert,NSAssert,NSCAssert
- key: bugprone-exception-escape.IgnoredExceptions
value: ''
- key: bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons
value: 'true'
- key: modernize-use-default-member-init.IgnoreMacros
value: 'true'
- key: llvm-qualified-auto.AddConstToQualified
value: 'false'
- key: llvm-else-after-return.WarnOnConditionVariables
value: 'false'
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
value: 'true'
- key: modernize-raw-string-literal.DelimiterStem
value: lit
- key: readability-suspicious-call-argument.Dice
value: 'true'
- key: readability-identifier-length.IgnoredLoopCounterNames
value: '^[ijk_]$'
- key: modernize-raw-string-literal.ReplaceShorterLiterals
value: 'false'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: performance-inefficient-vector-operation.VectorLikeClasses
value: '::std::vector'
- key: modernize-use-auto.RemoveStars
value: 'false'
- key: bugprone-implicit-widening-of-multiplication-result.IncludeStyle
value: llvm
- key: portability-simd-intrinsics.Std
value: ''
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 'false'
- key: modernize-replace-disallow-copy-and-assign-macro.MacroName
value: DISALLOW_COPY_AND_ASSIGN
- key: llvm-else-after-return.WarnOnUnfixable
value: 'false'
...
-58
View File
@@ -1,58 +0,0 @@
78d0fc786aece120146b5c7a2367b593d3498e43
eef27b845f5409dafbe3434ef16cd0fd3c06b311
a5bfba266593eeea4e1970b03b01ce360511d67d
bfc8111d19e05f578e4f0567cb93a6288c8f39ee
e901e584acaa1de1aa817448dbf1936f17c7f474
3da6ced354983790f027514284a4aab1daf33022
4543c982670a0d6044ebed7812ac7df43feb1c4a
c4b1ec01baed0a6e2698fc2f8d6557193f6b15df
2a8c1271d53bb9d4daad270e729661b7a35d7337
7c43b059df1b33ceffb3aa57d7e2b162a310f5e1
5bd5f3a9637c09a2537b5563c244c5db87b8a14a
5abfdb140531c1c59254eb5dc4a62cb6bbd60e34
298c67787377a06aee01d76477ba696b1335307b
d5f6c096b8089d5835a22a80667b00eda6721526
d84071275a76cea3ae96f12be6405e12305c98c7
bfdffb50beb8064b15f3eaadee983c7c95ae57bd
59fcb80a801e94248ae3184a0d8ca67745c96954
31c0099a59ab76ac7282f60bb8308fad5ac59ddd
67381e957984c0a3958e5c71f605f9a8a2fa3c5a
a3cb87b11763504f86aac23a640ebf3cb840034a
b75cd3dd522c7c2589016160f5bb342ea6a7ed94
ae7cb9e30081b0c23643e69ff08d0d836b03b5f2
8fb5c657365efb3fddce465b98ce8f5b39eca5f6
c7f9874422ecccc791f35b02da521dcf76e60b22
9d4b58ae85bfbac752b439b4146f8a0c119fd436
d9237989467a036fa0095917b15ed30a34a1846a
f11783a49876564eec5c9f6f9f0215db810fb1c4
6f11ed298a9896c2b693cb2a5c6d540467496ca0
4f308dc03cbb1d67482ba41d251a3c6bd8e9b194
b2ffebf1c0ecee57bf5329f4d2546fd98f3f6399
53bb216b571bdbacb5ac978a5ac3f6e5cd13c23f
d38f18af23bfa76138d1c8b5e87672d57f3734eb
1baf5da3cfb24d9fcc1a1389cbd502f60002e7ab
7fe10182a9c2a1ca97beb8a8e82742fae6a80c8d
0c6786d4bfe1814119c00a2b2816f2770885386d
cbdba0b5bb19ffc0ff5450a3ff63281ef03d8bd9
a5135efd879abcfb34868c775f4178124ccd771c
e0399e83c3d48c7d43fa2d1ed2ad1f6d52e68a0a
3ef6811dae41b0d5aa2343feea37cca12c5d23e3
c44ccc0ff231b7a91deb4425fa7b484725e98683
cb21ac7bf8ac998be93849b75c8ff94e9b1c1b54
1ee046788d50bb2512dfb4454d3e8f6c4aff0f9f
190d64bdae81af46a60241af9b8f4a8e381248fb
ec74d351f0c533da1626b05d1db9e20b678a8f72
1e9236abd416f998ccc3d052556338d4988ea709
bac451cc537be8beb4826c89fd4429ca73e69f4d
5f31fb74f6445fda5632b5f2545362f85a379c74
6f230d740401f914d5340a4b4be1a1c1df7b444a
0a65575c2c1b23fcae6354277fee264df6d163d8
702238a99c80ff2e6c91b4880f91bb38ab7833ac
35156cdce3b2716071e994467c607e5175693a12
bb0e2f1c5186ae3008b9aad1f0ba3e35370d18db
b13088664fea77e6ac4779dddfdea7aac3c50b30
1ea364379f64314ea47549a2f625c34eafdd262d
3b42d4aface8c64feb9c86533f3b847e9aa9c563
bedf9207023d6d594f2c03d2a8d799b34759a8fb
132a1d7e55eadd0cb5a09760d471780eb5bd9340
3ef438eaf03f840958a2f7a9ec585a3d2728e447
+3 -3
View File
@@ -1,12 +1,12 @@
# These are supported funding model platforms
github: FreeCAD
liberapay: FreeCAD
open_collective: freecad
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: FreeCAD
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://wiki.freecadweb.org/Donate"]
-91
View File
@@ -1,91 +0,0 @@
name: 🐛 Report a Bug
description: File a bug report
title: "[Bug] <title>"
labels: ["🐛 bug", "needs triage"]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file a bug report! Please make sure you've posted about your issue in the FreeCAD Forums before submitting here.
- type: checkboxes
id: existing_issue
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: input
id: forum_link
attributes:
label: Forums discussion
description: Please start a discussion about your issue at [the FreeCAD Forum](https://forum.freecad.org) and wait for confirmation there before creating an issue
placeholder: Paste link to forum discussion here
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: What version of FreeCAD are you running?
options:
- 0.19 (Release)
- 0.20 (Development)
validations:
required: true
- type: textarea
id: full_version
attributes:
label: Full version info
description: Please use the About FreeCAD dialog to copy your full version information and paste it here.
render: shell
validations:
required: true
- type: dropdown
id: wb
attributes:
label: Subproject(s) affected?
options:
- Addon Manager
- Arch
- Core
- Draft
- Expressions
- FEM
- File formats
- GCS
- OpenSCAD
- Part
- PartDesign
- Path
- Project Tools & Websites
- Sketcher
- Spreadsheet
- Techdraw
- Other (specify in description)
- type: textarea
id: description
attributes:
label: Issue description
description: Please include as much detail as possible so that testers can reproduce the bug
placeholder: Description of the problem
validations:
required: true
- type: textarea
id: anything_else
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. To attach a FCStd file, ZIP it first (GitHub won't recognize the extension otherwise).
validations:
required: false
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/FreeCAD/FreeCAD/blob/master/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
@@ -1,73 +0,0 @@
name: 🌱 Feature Request
description: Submit an idea for a new feature
title: "[Feature Request] <title>"
labels: ["feature", "needs triage"]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to request a feature! Please make sure you've posted about your idea in the FreeCAD Forums before submitting here.
- type: checkboxes
id: existing_issue
attributes:
label: Is there an existing request for this?
description: Please search to see if a request already exists for your suggestion
options:
- label: I have searched the existing requests
required: true
- type: input
id: forum_link
attributes:
label: Forums discussion
description: Please start a discussion about your idea at [the FreeCAD Forum](https://forum.freecad.org) and wait for confirmation there before creating a request.
placeholder: Paste link to forum discussion here
validations:
required: true
- type: dropdown
id: wb
attributes:
label: Subproject(s) affected?
options:
- Addon Manager
- Arch
- Core
- Draft
- Expressions
- FEM
- File formats
- GCS
- OpenSCAD
- Part
- PartDesign
- Path
- Project Tools & Websites
- Sketcher
- Spreadsheet
- Techdraw
- Other (specify in description)
- type: textarea
id: description
attributes:
label: Idea description
description: Please include as much detail as possible so that developers understand the request
placeholder: Description of the feature
validations:
required: true
- type: textarea
id: anything_else
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about your idea.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. To attach a FCStd file, ZIP it first (GitHub won't recognize the extension otherwise).
validations:
required: false
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/FreeCAD/FreeCAD/blob/master/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
-5
View File
@@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: 💬 START HERE -- FreeCAD Forum
url: https://forum.freecad.org/
about: Please start a topic at the forums first and wait for others to confirm your issue before creating a bug report on GitHub
+2 -2
View File
@@ -6,9 +6,9 @@ Thank you for creating a pull request to contribute to FreeCAD! To ease integrat
- [ ] All FreeCAD unit tests are confirmed to pass by running `./bin/FreeCAD --run-test 0`
- [ ] All commit messages are [well-written](https://chris.beams.io/posts/git-commit/) ex: `Fixes typo in Draft Move command text`
- [ ] Your pull request is well written and has a good description, and its title starts with the module name, ex: `Draft: Fixed typos`
- [ ] Commit messages include `issue #<id>` or `fixes #<id>` where `<id>` is the issue ID number from our [Issues database](https://github.com/FreeCAD/FreeCAD/issues) in case a particular commit solves or is related to an existing issue. Ex: `Draft: fix typos - fixes #4805`
- [ ] Commit messages include `issue #<id>` or `fixes #<id>` where `<id>` is the [FreeCAD bug tracker issue number](https://freecadweb.org/wiki/tracker#GitHub_and_MantisBT) in case a particular commit solves or is related to an existing issue on the tracker. Ex: `Draft: fix typos - fixes #0004805`
And please remember to update the Wiki with the features added or changed once this PR is merged.
**Note**: If you don't have wiki access, then please mention your contribution on the [0.20 Changelog Forum Thread](https://forum.freecadweb.org/viewtopic.php?f=10&t=56135).
**Note**: If you don't have wiki access, then please mention your contribution on the [0.19 Changelog Forum Thread](https://forum.freecadweb.org/viewtopic.php?f=10&t=34586).
---
-70
View File
@@ -1,70 +0,0 @@
aci
ake
aline
alle
alledges
alocation
anid
anormal
apoints
appy
ba
beginn
bloaded
bottome
childrens
childs
connexion
currenty
curvelinear
detet
doubleclick
dum
eiter
ende
extaction
finde
findn
fle
fo
freez
froms
hist
indicies
inout
ist
lod
mantatory
mata
methode
modell
nd
nin
normale
normaly
numer
ontop
ot
parm
parms
programm
propt
rady
recurrance
rougly
seh
serie
som
strack
substraction
sur
te
thist
tread
ue
uptodate
usind
vas
vertexes
wallthickness
zuser
-63
View File
@@ -1,63 +0,0 @@
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
# source:
# - any: ['src/**/*', '!src/docs/*']
Core:
- 'src/App/**/*'
- 'src/Base/**/*'
- 'src/Gui/**/*'
:octocat::
- '.github/**/*'
Addon Manager:
- 'src/Mod/AddonManager/**/*'
WB Arch:
- 'src/Mod/Arch/**/*'
WB Draft:
- 'src/Mod/Draft/**/*'
WB FEM:
- 'src/Mod/Fem/**/*'
WB Mesh:
- 'src/Mod/Mesh/**/*'
WB MeshPart:
- 'src/Mod/MeshPart/**/*'
WB OpenSCAD:
- 'src/Mod/OpenSCAD/**/*'
WB Part:
- 'src/Mod/Part/**/*'
WB PartDesign:
- 'src/Mod/PartDesign/**/*'
WB Path:
- 'src/Mod/Path/**/*'
WB Points:
- 'src/Mod/Points/**/*'
WB ReverseEngineering:
- 'src/Mod/ReverseEngineering/**/*'
WB Sketcher:
- 'src/Mod/Sketcher/**/*'
WB Spreadsheet:
- 'src/Mod/Spreadsheet/**/*'
WB Surface:
- 'src/Mod/Surface/**/*/'
WB TechDraw:
- 'src/Mod/TechDraw/**/*'
WB Test:
- 'src/Mod/Test/**/*'
-15
View File
@@ -1,15 +0,0 @@
{
"problemMatcher": [
{
"owner": "black-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(would reformat (.*))$",
"file": 2,
"message": 1
}
]
}
]
}
-17
View File
@@ -1,17 +0,0 @@
{
"problemMatcher": [
{
"owner": "clang",
"pattern": [
{
"regexp": "^(.+):([0-9]+):([0-9]+): (error|warning|note): (.+)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
-16
View File
@@ -1,16 +0,0 @@
{
"problemMatcher": [
{
"owner": "codespell-matcher",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):\\s+(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
-16
View File
@@ -1,16 +0,0 @@
{
"problemMatcher": [
{
"owner": "cpplint",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):([0-9]+): (.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
@@ -1,16 +0,0 @@
{
"problemMatcher": [
{
"owner": "grepMatcher-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):([0-9]+):(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
-18
View File
@@ -1,18 +0,0 @@
{
"problemMatcher": [
{
"owner": "pylint-error",
"severity": "error",
"pattern": [
{
"regexp": "^(.+?):([0-9]+):([0-9]+): ([([E|F][0-9]+): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
-18
View File
@@ -1,18 +0,0 @@
{
"problemMatcher": [
{
"owner": "pylint-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+?):([0-9]+):([0-9]+): ([^E|F][0-9]+): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
File diff suppressed because it is too large Load Diff
-24
View File
@@ -1,24 +0,0 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# For more information, see:
# https://github.com/actions/labeler
name: Labeler
on:
pull_request_target:
types: [opened, reopened]
jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: ".github/labels.yml"
sync-labels: false
+5 -10
View File
@@ -1,11 +1,5 @@
# file types to ignore
.*
!/.gitignore
!/.travis/
!/.travis.yml
!/.clang-format
!/.git-blame-ignore-revs
!/.gitattributes
*.DS_Store
*.pyc
*.obj
@@ -40,10 +34,11 @@ install_manifest.txt
/src/Tools/offlinedoc/localwiki/
/src/Tools/offlinedoc/*.txt
OpenSCAD_rc.py
.subuser-dev
/\.idea/
.tags
tags
/\.vscode/
# crowdin file
src/Tools/freecad.zip
tsupdate_stderr.log
tsupdate_stdout.log
files_to_translate.txt
-614
View File
@@ -1,614 +0,0 @@
[MAIN]
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Load and enable all available extensions. Use --list-extensions to see a list
# all available extensions.
#enable-all-extensions=
# In error mode, messages with a category besides ERROR or FATAL are
# suppressed, and no reports are done by default. Error mode is compatible with
# disabling specific errors.
#errors-only=
# Always return a 0 (non-error) status code, even if lint errors are found.
# This is primarily useful in continuous integration scripts.
#exit-zero=
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-allow-list=
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
# for backward compatibility.)
extension-pkg-whitelist=
# Return non-zero exit code if any of these messages/categories are detected,
# even if score is above --fail-under value. Syntax same as enable. Messages
# specified are enabled, while categories only check already-enabled messages.
fail-on=
# Specify a score threshold to be exceeded before program exits with error.
fail-under=10
# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
#from-stdin=
# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
ignore-paths=
# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths. The default value ignores Emacs file
# locks
ignore-patterns=^\.#
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100
# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.10
# Discover python modules and packages in the file system subtree.
recursive=no
# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
# In verbose mode, extra non-checker-related info will be displayed.
#verbose=
[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'fatal', 'error', 'warning', 'refactor',
# 'convention', and 'info' which contain the number of messages in each
# category, as well as 'statement' which is the total number of statements
# analyzed. This score is used by the global evaluation report (RP0004).
evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
#output-format=
# Tells whether to display a full report or only the messages.
reports=yes
# Activate the evaluation score.
score=yes
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE,
# UNDEFINED.
confidence=HIGH,
CONTROL_FLOW,
INFERENCE,
INFERENCE_FAILURE,
UNDEFINED
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
invalid-name,
wrong-import-order,
import-error,
undefined-variable
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
[BASIC]
# Naming style matching correct argument names.
argument-naming-style=snake_case
# Regular expression matching correct argument names. Overrides argument-
# naming-style. If left empty, argument names will be checked with the set
# naming style.
#argument-rgx=
# Naming style matching correct attribute names.
attr-naming-style=snake_case
# Regular expression matching correct attribute names. Overrides attr-naming-
# style. If left empty, attribute names will be checked with the set naming
# style.
#attr-rgx=
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
# Bad variable names regexes, separated by a comma. If names match any regex,
# they will always be refused
bad-names-rgxs=
# Naming style matching correct class attribute names.
class-attribute-naming-style=any
# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style. If left empty, class attribute names will be checked
# with the set naming style.
#class-attribute-rgx=
# Naming style matching correct class constant names.
class-const-naming-style=UPPER_CASE
# Regular expression matching correct class constant names. Overrides class-
# const-naming-style. If left empty, class constant names will be checked with
# the set naming style.
#class-const-rgx=
# Naming style matching correct class names.
class-naming-style=PascalCase
# Regular expression matching correct class names. Overrides class-naming-
# style. If left empty, class names will be checked with the set naming style.
#class-rgx=
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming-
# style. If left empty, constant names will be checked with the set naming
# style.
#const-rgx=
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=snake_case
# Regular expression matching correct function names. Overrides function-
# naming-style. If left empty, function names will be checked with the set
# naming style.
#function-rgx=
# Good variable names which should always be accepted, separated by a comma.
good-names=i,
j,
k,
ex,
Run,
_
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
good-names-rgxs=
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=any
# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style. If left empty, inline iteration names will be checked
# with the set naming style.
#inlinevar-rgx=
# Naming style matching correct method names.
method-naming-style=snake_case
# Regular expression matching correct method names. Overrides method-naming-
# style. If left empty, method names will be checked with the set naming style.
#method-rgx=
# Naming style matching correct module names.
module-naming-style=snake_case
# Regular expression matching correct module names. Overrides module-naming-
# style. If left empty, module names will be checked with the set naming style.
#module-rgx=
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Regular expression matching correct type variable names. If left empty, type
# variable names will be checked with the set naming style.
#typevar-rgx=
# Naming style matching correct variable names.
variable-naming-style=snake_case
# Regular expression matching correct variable names. Overrides variable-
# naming-style. If left empty, variable names will be checked with the set
# naming style.
#variable-rgx=
[CLASSES]
# Warn about protected attribute access inside special methods
check-protected-access-in-special-methods=no
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit,argparse.parse_error
[DESIGN]
# List of regular expressions of class ancestor names to ignore when counting
# public methods (see R0903)
exclude-too-few-public-methods=
# List of qualified class names to ignore when counting class parents (see
# R0901)
ignored-parents=
# Maximum number of arguments for function / method.
max-args=5
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=12
# Maximum number of locals for function / method body.
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=6
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
[EXCEPTIONS]
# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module.
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[IMPORTS]
# List of modules that can be imported at any level, not just the top level
# one.
allow-any-import-level=
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=
# Output a graph (.gv or any supported image format) of external dependencies
# to the given file (report RP0402 must not be disabled).
ext-import-graph=
# Output a graph (.gv or any supported image format) of all (i.e. internal and
# external) dependencies to the given file (report RP0402 must not be
# disabled).
import-graph=
# Output a graph (.gv or any supported image format) of internal dependencies
# to the given file (report RP0402 must not be disabled).
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Couples of modules and preferred modules, separated by a comma.
preferred-modules=
[LOGGING]
# The type of string formatting that logging methods do. `old` means using %
# formatting, `new` is for `{}` formatting.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
# Regular expression of note tags to take in consideration.
notes-rgx=
[SIMILARITIES]
# Comments are removed from the similarity computation
ignore-comments=yes
# Docstrings are removed from the similarity computation
ignore-docstrings=yes
# Imports are removed from the similarity computation
ignore-imports=yes
# Signatures are removed from the similarity computation
ignore-signatures=yes
# Minimum lines number of a similarity.
min-similarity-lines=4
[SPELLING]
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4
# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the 'python-enchant' package.
spelling-dict=
# List of comma separated words that should be considered directives if they
# appear at the beginning of a comment and should not be checked.
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=no
[STRING]
# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=no
# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
check-str-concat-over-line-jumps=no
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of symbolic message names to ignore for Mixin members.
ignored-checks-for-mixins=no-member,
not-async-context-manager,
not-context-manager,
attribute-defined-outside-init
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
# Regex pattern to define which classes are considered mixins.
mixin-class-rgx=.*[Mm]ixin
# List of decorators that change the signature of a decorated function.
signature-mutators=
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of names allowed to shadow builtins
allowed-redefined-builtins=
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
_cb
# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
+1
View File
@@ -0,0 +1 @@
{"image-sources-dir": "./subuser"}
+20 -7
View File
@@ -66,7 +66,7 @@ jobs:
env:
- CC=clang-10
- CXX=clang++-10
- CMAKE_ARGS="-DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON"
- CMAKE_ARGS="-DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON -DBUILD_QT5=ON"
- CACHE_NAME=JOB1
- os: linux
@@ -86,9 +86,22 @@ jobs:
- CXX=g++-10
- CC_FOR_BUILD=gcc-10
- CXX_FOR_BUILD=g++-10
- CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON"
- CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_FEM_NETGEN=ON -DBUILD_QT5=ON"
- CACHE_NAME=JOB2
- os: linux
dist: bionic
language: cpp
compiler: gcc-7
cache: ccache
env:
- CC=gcc-7
- CXX=g++-7
- CC_FOR_BUILD=gcc-7
- CXX_FOR_BUILD=g++-7
- CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc"
- CACHE_NAME=JOB3
# - os: osx
# osx_image: xcode11.6
# language: cpp
@@ -106,7 +119,7 @@ jobs:
- os: windows
language: cpp
env:
- CMAKE_OPTS="-DBUILD_FEM_NETGEN=OFF -DFREECAD_RELEASE_PDB=OFF -DFREECAD_RELEASE_SEH=OFF"
- CMAKE_OPTS="-DBUILD_FEM_NETGEN=ON -DFREECAD_RELEASE_PDB=OFF -DFREECAD_RELEASE_SEH=OFF"
- GENERATOR="Visual Studio 15 2017 Win64"
- PYTHON_MAJOR_VERSION=3
- MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
@@ -271,12 +284,12 @@ before_install:
# clcache stats before compilation
cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\clcache.exe -s'
curl -L https://github.com/FreeCAD/FreeCAD/releases/download/0.19.1/FreeCADLibs_12.5.3_x64_VC17.7z --output FreeCADLibs.7z
curl -L https://github.com/FreeCAD/FreeCAD/releases/download/0.19_pre/FreeCADLibs_12.1.6_x64_VC15.7z --output FreeCADLibs.7z
7z x FreeCADLibs.7z -oFreeCADLibs > /dev/null
rm -f FreeCADLibs.7z
export FREECAD_LIBPACK_DIR="$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.5.3_x64_VC17"
export FREECAD_LIBPACK_DIR="$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.6_x64_VC15"
export CMAKE_ARGS="${CMAKE_OPTS} -DFREECAD_LIBPACK_DIR=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.5.3_x64_VC17 -DPYTHON_EXECUTABLE=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.5.3_x64_VC17\bin\python.exe \
export CMAKE_ARGS="${CMAKE_OPTS} -DFREECAD_LIBPACK_DIR=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.6_x64_VC15 -DPYTHON_EXECUTABLE=$TRAVIS_BUILD_DIR\FreeCADLibs\FreeCADLibs_12.1.6_x64_VC15\bin\python.exe \
-DBUILD_QT5=TRUE"
export PATH=$MSBUILD_PATH:$PATH
;;
@@ -308,7 +321,7 @@ script:
cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\.travis\build.bat'
# ls -lahR
mkdir bin/
mv ../FreeCADLibs/FreeCADLibs_12.5.3_x64_VC17/bin/* bin/
mv ../FreeCADLibs/FreeCADLibs_12.1.6_x64_VC15/bin/* bin/
du -hs bin/
# show clcache hit stats
cmd.exe //C 'C:\Users\travis\build\FreeCAD\FreeCAD\clcache.exe -s'
+2 -263
View File
@@ -1,33 +1,11 @@
# Contents
<a name="contents"></a>
- [Building FreeCAD on Mac OS 10.15.x -- Catalina](#build-freecad-macos-catalina)
- [Directions](#directions)
- [Install Xcode Command line tools](#install-xcode-cli-tools)
- [Install Conda](#install-conda)
- [Run the shell script](#run-the-shell-script)
- [Building FreeCAD on macOS using homebrew packages with & without formula file](#homebrew-build-fc-on-macos)
- [Requirements](#homebrew-requirements)
- [Install required FreeCAD dependencies](#homebrew-install-required-deps)
- [Limitations of using freecad formula file](#homebrew-limits-of-formula-file)
- [Directions, Installing FreeCAD using brew packages without formula file](#homebrew-install-no-form-file)
- [Expanded Directions](#homebrew-expanded-directions)
- [Boost v1.75 fix](#homebrew-boost-175-fix)
- [Errors, Issues, & Possible Solutions](#errors-issues-solutions)
<!-- SEE: https://stackoverflow.com/a/7335259/708807 for explanation of using `name` attribute for in page linking within a MD doc -->
# Building FreeCAD on Mac OS 10.15.x -- Catalina #
<a name="build-freecad-macos-catalina"></a>
General notes on how the tooling works:
This setup uses [conda](https://docs.conda.io) for dependency management.
Conda is able to pull the deps from a repository called conda-forge and
setup an isolated build environment. Not quite as isolated as docker, but
it is a good option for Mac and is what the FreeCAD CI system uses.
it is a good option for Mac and its what the FreeCAD CI system uses.
Once the dependencies are installed into a conda environment, then the
build uses the standard `cmake` configuration process to configure the build
@@ -37,26 +15,18 @@ that architecture.
All of this, and some sanity checks, are in a unified shell script. See below.
# Directions
<a name="directions"></a>
# Directions #
## Install XCode Command line tools ##
<a name="install-xcode-cli-tools"></a>
Run `xcode-select --install` and click through.
## Install Conda ##
<a name="install-conda"></a>
Refer to [MiniConda Docs](https://docs.conda.io/en/latest/miniconda.html).
## Run the shell script ##
<a name="run-the-shell-script"></a>
Run the `./build_unix_dev_conda.sh` and go get coffee. Builds take
an hour+ on a 2012 Retina MacBook.
@@ -66,234 +36,3 @@ Output binaries will be in the `./build/bin/FreeCAD` *and*
You can code/build/test using the cmake configuration folder `./build` in
the standard way *from within the freecad_dev conda environment*.
---
# Building FreeCAD on macOS using homebrew with & without a formula file
<a name="homebrew-build-fc-on-macos"></a>
> The below procedure provides an alternative way to install FreeCAD from the git source on macOS without having to use conda, but rather relies on [**mac homebrew**][lnk1] to manage dependencies.
## Requirements
<a name="homebrew-requirements"></a>
- macOS, running High Sierra _10.13_ or later
- homebrew installed and working
- All required dependencies to build FreeCAD installed using `brew install`
There is an official [**homebrew tap**][lnk2] that provides a list of formulas along with FreeCAD to setup all the dependencies to build FreeCAD from source on macOS, and also provides prebuilt bottles to install FreeCAD from a package rather than building from source.
> 💡 The below steps will build a FreeCAD binary that will launch FreeCAD from a command line interface, and will **NOT** build the **FreeCAD.app** bundle, ie. a double clickable app icon that can be launched from a Finder window.
### Install required FreeCAD dependencies
<a name="homebrew-install-required-deps"></a>
- Setup homebrew to use the official [**freecad-homebrew**][lnk2] tap.
```shell
brew tap FreeCAD/freecad
```
- Install FreeCAD dependencies provided by the tap
```shell
brew install --only-dependencies freecad
```
> The above step will install FreeCAD dependencies provided by the tap, and if a _bottle_ is provided by the tap homebrew will install the bottled version of the dep rather than building from source, unless the `install` command explicitly uses a _flag_ to build from source.
After all the dependencies have been installed, it should be possible to install FreeCAD from the provided bottle.
```shell
brew install freecad/freecad/freecad
```
> As of writing this, there are bottles provided for macOS Catalina and Big Sur
> > If running a different version of macOS then building FreeCAD from source will be required.
To explicitly build FreeCAD from source using the formula file provided by the tap
```shell
brew install freecad/freecad/freecad --build-from-source --HEAD --verbose
```
The above command will grab the latest git source of FreeCAD and output the build process to the terminal.
> NOTE: On a MacBookPro 2013 late model it takes ~60 minutes to build FreeCAD from source.
After the _make_ and _make install_ process completes it should be possible to launch FreeCAD from any directory using a terminal with the below commands,
```shell
FreeCAD
FreeCADCmd
```
- `FreeCAD` will launch a GUI version of FreeCAD
- `FreeCADCmd` will launch **only** a command line version of FreeCAD
## Limitations of using the FreeCAD formula file
<a name="homebrew-limits-of-formula-file"></a>
If FreeCAD is installed via the bottle then one will have to wait for a new bottle to be generated to install a later version of FreeCAD. However, if FreeCAD is built from source, then FreeCAD will have all the updates up to the time the build process was started.
If any of the dependencies FreeCAD relies on is updated FreeCAD will likely require a rebuild. Mac homebrew does provide a feature to pin packages at specific versions to prevent them from updating, and also allows setting of an environment variable to prevent homebrew from automatically checking for updates (which can slow things down). All that said, FreeCAD can be built using all the dependencies provided by Mac homebrew, but not using the formula file: instead cloning the source to an arbitrary path on a local filesystem. This provides a couple of advantages:
- If `brew cleanup` is run and FreeCAD was installed using the above-provided command, all source tarballs or bottles that were _checked out_ or downloaded during the install process will be deleted from the system. If a reinstall or upgrade is later required then homebrew will have to refetch the bottles, or reclone the git source again.
- Mac homebrew provides a method, _install flag_, for keeping the source regardless if the build succeeds or fails. The options are limited, however, and performing a standard `git clone` outside of homebrew is **much** preferred.
- Cloning the FreeCAD source allows passing **any** cmake flags not provided by the formula file
- Allowing the use of other build systems such as _ninja_
- Allowing the use of alternate compilers, e.g. _ccache_
- Pulling in subsequent updates are quicker because the `git clone` of the FreeCAD source will remain on the local filesystem even if a `brew cleanup` is run
- Subsequent recompiles should not take 60 minutes if using a caching strategy such as _ccache_.
## Directions, Installing FreeCAD using brew packages without a formula file
<a name="homebrew-install-no-form-file"></a>
> ⚠️ The below directions assume macOS High Sierra or later is being used, homebrew is setup properly, and all dependencies were installed successfully.
**TL;DR**
- Clone the FreeCAD source, pass cmake args/flags within source dir, run make, and make install, then profit 💰
### Expanded Directions
<a name="homebrew-expanded-directions"></a>
- Clone the FreeCAD source from GitHub
```shell
git clone https://github.com/freecad/freecad
cd ./freecad
git fetch
```
> The above _fetch_ cmd will take some time to fetch the commit history for the repo, but if a shallow clone is performed then FreeCAD will not show to correct build number in the About dialog [**learn more**][lnk3].
Advanced users may alter the process below to build in a different location, use a different compiler, etc. but these instructions represent a procedure that works successfully for this author.
Set the path / environment variables for specifying the compilers to use
```
export CC="/usr/local/opt/llvm/bin/clang"
export CXX="/usr/local/opt/llvm/bin/clang++"
```
- Linking the brew-provided install of python 3 will be required in order for cmake to find the proper python and python libraries.
```shell
brew link python@3.9
```
#### Boost v1.75 fix
<a name="homebrew-boost-175-fix"></a>
- Due to recent changes in boost v1.75, building FreeCAD will fail with the below linking error message (for a more exhaustive error message, [**learn more**][lnk4])
To work around the linking issue until the [**PR**][lnk5] is merged install boost will the patches applied within the PR.
```shell
ld: library not found for -licudata
```
```shell
git checkout -b mybuild
cmake \
-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG \
-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG \
-DCMAKE_INSTALL_PREFIX=/opt/beta/freecad \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON \
-Wno-dev \
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/macOSX10.14.sdk \
-std=c++14 \
-DCMAKE_CXX_STANDARD=14 \
-DBUILD_ENABLE_CXX_STD:STRING=C++14 \
-Wno-deprecated-declarations \
-DUSE_PYTHON3=1 -DPYTHON_EXECUTABLE=/usr/local/bin/python3 \
-DBUILD_FEM_NETGEN=1 \
-DBUILD_FEM=1 \
-DBUILD_TECHDRAW=0 \
-DFREECAD_USE_EXTERNAL_KDL=ON \
-DFREECAD_CREATE_MAC_APP=OFF
-DCMAKE_PREFIX_PATH="/usr/local/opt/qt/lib/cmake;/usr/local/opt/nglib/Contents/Resources;/usr/local/opt/vtk@8.2/lib/cmake;/usr/local;" .
```
After the configuration completes run the below commands to start the build & install process
```shell
make
make install
```
> 💡 Author's note: The above cmake build flags are the ones I've had good luck with, but that's not to say other ones can be added or removed. And for reasons unknown to me the above build process takes ~ twice along than using `brew install --build-from-source`
If everything goes well FreeCAD should be able to launch from a terminal
## Errors and Issues + possible solutions
<a name="errors-issues-solutions"></a>
Some common pitfalls are listed in this section.
---
<details>
<summary><strong>error:</strong> no member named </summary>
```shell
[ 18%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/DlgProjectInformationImp.cpp.o
cd /opt/code/github/public/forks/freecad/build/src/Gui && /usr/local/bin/ccache /usr/local/opt/llvm/bin/clang++ -DBOOST_ALL_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PP_VARIADICS=1 -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBUILD_ADDONMGR -DCMAKE_BUILD_TYPE=\"Release\" -DFreeCADGui_EXPORTS -DGL_SILENCE_DEPRECATION -DHAVE_CONFIG_H -DHAVE_FREEIMAGE -DHAVE_PYSIDE2 -DHAVE_RAPIDJSON -DHAVE_SHIBOKEN2 -DHAVE_TBB -DNDEBUG -DOCC_CONVERT_SIGNALS -DPYSIDE_QML_SUPPORT=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_SVG_LIB -DQT_UITOOLS_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -D_OCC64 -I/opt/code/github/public/forks/freecad/build -I/opt/code/github/public/forks/freecad/build/src -I/opt/code/github/public/forks/freecad/src -I/opt/code/github/public/forks/freecad/src/Gui -I/opt/code/github/public/forks/freecad/src/Gui/Quarter -I/opt/code/github/public/forks/freecad/build/src/Gui -I/opt/code/github/public/forks/freecad/src/Gui/.. -I/opt/code/github/public/forks/freecad/build/src/Gui/.. -I/opt/code/github/public/forks/freecad/build/src/Gui/Language -I/opt/code/github/public/forks/freecad/build/src/Gui/propertyeditor -I/opt/code/github/public/forks/freecad/build/src/Gui/TaskView -I/opt/code/github/public/forks/freecad/build/src/Gui/Quarter -I/opt/code/github/public/forks/freecad/build/src/Gui/DAGView -I/usr/local/include/eigen3 -I/usr/local/include/PySide2/QtCore -I/usr/local/include/PySide2/QtGui -I/usr/local/include/PySide2/QtWidgets -isystem /usr/local/include -isystem /usr/local/Frameworks/Python.framework/Versions/3.9/include/python3.9 -iframework /usr/local/opt/qt/lib -isystem /usr/local/opt/qt/lib/QtCore.framework/Headers -isystem /usr/local/opt/qt/./mkspecs/macx-clang -isystem /usr/local/opt/qt/lib/QtWidgets.framework/Headers -isystem /usr/local/opt/qt/lib/QtGui.framework/Headers -isystem /Library/Developer/CommandLineTools/SDKs/macOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /usr/local/opt/qt/lib/QtOpenGL.framework/Headers -isystem /usr/local/opt/qt/lib/QtPrintSupport.framework/Headers -isystem /usr/local/opt/qt/lib/QtSvg.framework/Headers -isystem /usr/local/opt/qt/lib/QtNetwork.framework/Headers -isystem /usr/local/opt/qt/include -isystem /usr/local/opt/qt/include/QtUiTools -isystem /usr/local/include/shiboken2 -isystem /usr/local/include/PySide2 -isystem /usr/local/opt/qt/lib/QtXml.framework/Headers -Wall -Wextra -Wpedantic -Wno-write-strings -Wno-undefined-var-template -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/macOSX10.14.sdk -fPIC -I/usr/local/Cellar/open-mpi/4.0.5/include -fPIC -std=gnu++14 -o CMakeFiles/FreeCADGui.dir/DlgProjectInformationImp.cpp.o -c /opt/code/github/public/forks/freecad/src/Gui/DlgProjectInformationImp.cpp
/opt/code/github/public/forks/freecad/src/Gui/DlgProjectInformationImp.cpp:56:9: error: no member named 'lineEditProgramVersion' in 'Gui::Dialog::Ui_DlgProjectInformation'
ui->lineEditProgramVersion->setText(QString::fromUtf8(doc->getProgramVersion()));
~~ ^
1 error generated.
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/DlgProjectInformationImp.cpp.o] Error 1
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Error 2
make: *** [all] Error 2
```
</details>
FreeCAD may fail to build if creating a build directory within the _src_ directory and running `cmake ..` within the newly created _build_ directory. As it currently stands, `cmake` needs run within the _src_ directory or the this error message will likely appear during the build process.
---
<details>
<summary> ⚠️ <strong>warning:</strong> specified path differs in case from file name on disk</summary>
```
/opt/code/github/public/forks/FreeCAD/src/Gui/moc_DlgParameterFind.cpp:10:10: warning: non-portable path to file '"../../../FreeCAD/src/Gui/DlgParameterFind.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "../../../freecad/src/Gui/DlgParameterFind.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"../../../FreeCAD/src/Gui/DlgParameterFind.h"
1 warning generated.
```
</details>
On macOS most filesystems are case **insensitive**, whereas most GNU+Linux distros use _case sensitive_ file systems. So if FreeCAD source is cloned within a `FreeCAD` directory the build process on macOS may look for a `freecad` that is _case sensitive_ however the file system isn't case sensitive, thus the compiler will provide the above warning message.
One way to resolve such error message is to rename `FreeCAD` to `freecad`
```shell
mv FreeCAD freecadd;
mv freecadd freecad;
```
---
<!-- links -->
[lnk1]: <http://brew.sh>
[lnk2]: <https://github.com/FreeCAD/homebrew-freecad>
[lnk3]: <https://forum.freecadweb.org/viewtopic.php?f=4&t=51981#p446796>
[lnk4]: <https://gist.github.com/ipatch/6116824ab1f2a99b526cb07e43317b91#gistcomment-3577066>
[lnk5]: <https://github.com/Homebrew/homebrew-core/pull/67615>
+8 -10
View File
@@ -1,11 +1,11 @@
# March 2021, the oldest we have to support : Ununtu 18.04 LTS
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
# april 2020, the oldest we have to support : Ununtu 16.04 LTS (Xenial)
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
# policy CMP0072 was introduced with CMake 3.11
# relates to FindOpenGL module
# and cache variables OPENGL_gl_LIBRARY, OPENGL_glu_LIBRARY
if (POLICY CMP0072)
set(OpenGL_GL_PREFERENCE LEGACY)
cmake_policy(SET CMP0072 OLD)
endif(POLICY CMP0072)
find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
@@ -17,10 +17,10 @@ project(FreeCAD)
set(PACKAGE_VERSION_NAME "Vulcan")
set(PACKAGE_VERSION_MAJOR "0")
set(PACKAGE_VERSION_MINOR "20")
set(PACKAGE_VERSION_PATCH "2")
set(PACKAGE_VERSION_SUFFIX "") # either "dev" for development snapshot or "" (empty string)
set(FREECAD_VERSION_PATCH "2") # number of patch release (e.g. "4" for the 0.18.4 release)
set(PACKAGE_VERSION_MINOR "19")
set(PACKAGE_VERSION_PATCH "16100")
set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string)
set(FREECAD_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release)
set(FREECAD_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
@@ -45,6 +45,7 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
SetupPython()
SetupPCL()
SetupPybind11()
SetupBoost()
SetupXercesC()
find_package(ZLIB REQUIRED)
find_package(PyCXX REQUIRED)
@@ -56,7 +57,6 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER)
SetupOpenGL()
endif(BUILD_GUI)
SetupSalomeSMESH()
SetupBoost()
if (BUILD_FEM_NETGEN)
find_package(NETGEN)
endif(BUILD_FEM_NETGEN)
@@ -87,8 +87,6 @@ SetGlobalCompilerAndLinkerSettings()
add_subdirectory(src)
add_subdirectory(data)
BuildAndInstallDesignerPlugin()
CreatePackagingTargets()
PrintFinalReport()
-42
View File
@@ -9,47 +9,5 @@
# include <${OCC_INCLUDE_DIR}/Standard_Version.hxx>
#endif
/* No need for Boost (version info is always included in the source) */
/* No need for Python (version info is always included in the source) */
/* No need for Qt (version info is always included in the source) */
/* No need for zlib (version info is always included in the source) */
// No CMake version info for SMESH, libarea, Zipios, or KDL
// Coin3D
constexpr char * FC_COIN3D_VERSION = "${COIN3D_VERSION}";
// Eigen3
constexpr char * FC_EIGEN3_VERSION = "${EIGEN3_VERSION}";
// FreeType
constexpr char * FC_FREETYPE_VERSION = "${FREETYPE_VERSION_STRING}";
// pcl
constexpr char * FC_PCL_VERSION = "${PCL_VERSION}";
// PyCXX
constexpr char * FC_PYCXX_VERSION = "${PYCXX_VERSION}";
// PySide
constexpr char * FC_PYSIDE_VERSION = "${PySide2_VERSION}";
// PyBind
constexpr char * FC_PYBIND11_VERSION = "${pybind11_VERSION}";
// Shiboken
constexpr char * FC_SHIBOKEN_VERSION = "${Shiboken2_VERSION}";
// vtk
constexpr char * FC_VTK_VERSION = "${VTK_VERSION}";
// Xerces-C
constexpr char * FC_XERCESC_VERSION = "${XercesC_VERSION}";
// Pivy
constexpr char * FC_PIVY_VERSION = "${PIVY_VERSION}";
#endif // LIBRARY_VERSIONS_H
+17 -21
View File
@@ -9,9 +9,15 @@
[Git repository](https://github.com/FreeCAD/FreeCAD)
[![Release](https://img.shields.io/github/release/freecad/freecad.svg)](https://github.com/freecad/freecad/releases/latest) [![Master][freecad-master-status]][gitlab-branch-master] [![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad) [![Gitter](https://img.shields.io/gitter/room/freecad/freecad.svg)](https://gitter.im/freecad/freecad?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/FreeCAD/FreeCAD.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/FreeCAD/FreeCAD/context:python) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/FreeCAD/FreeCAD.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/FreeCAD/FreeCAD/context:cpp) [![Liberapay](https://img.shields.io/liberapay/receives/FreeCAD.svg?logo=liberapay)](https://liberapay.com/FreeCAD)
[![Release](https://img.shields.io/github/release/freecad/freecad.svg)](https://github.com/freecad/freecad/releases/latest) [![Master][freecad-master-status]][travis-branches] [![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad) [![Gitter](https://img.shields.io/gitter/room/freecad/freecad.svg)](https://gitter.im/freecad/freecad?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/FreeCAD/FreeCAD.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/FreeCAD/FreeCAD/context:python) [![Liberapay](https://img.shields.io/liberapay/receives/FreeCAD.svg?logo=liberapay)](https://liberapay.com/FreeCAD)
<img src="https://user-images.githubusercontent.com/1828501/174066870-1692005b-f8d7-43fb-a289-6d2f07f73d7f.png" width="800"/>
<p>This project receives generous infrastructure support from
<a href="https://www.digitalocean.com/">
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg" width="91px">
</a>
</p>
![screenshot](https://wiki.freecadweb.org/images/thumb/7/72/Freecad016_screenshot1.jpg/800px-Freecad016_screenshot1.jpg)
Overview
--------
@@ -42,27 +48,24 @@ whether you are a hobbyist, programmer, experienced CAD user, student or teacher
Installing
----------
Precompiled packages for stable releases are available for Windows, macOS and Linux on the
Precompiled (installable) packages are available for Windows and macOS on the
[Releases page](https://github.com/FreeCAD/FreeCAD/releases).
On most Linux distributions, FreeCAD is also directly installable from the
On most Linux distributions, FreeCAD is directly installable from the
software center application.
For development releases check the [weekly-builds page](https://github.com/FreeCAD/FreeCAD-Bundle/releases/tag/weekly-builds).
Other options are described at the [wiki Download page](https://wiki.freecadweb.org/Download).
Build Status
Build Status <img src="https://blog.travis-ci.com/images/travis-mascot-200px.png" height="30"/>
------------
| Master | 0.20 | Translation |
| Master | 0.18 | Translation |
|:------:|:----:|:-----------:|
|[![Master][freecad-master-status]][gitlab-branch-master]|[![0.20][freecad-0.20-status]][gitlab-branch-0.20]|[![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad)|
|[![Master][freecad-master-status]][travis-branches]|[![0.18][freecad-0.18-status]][travis-branches]|[![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad)|
[freecad-0.20-status]: https://gitlab.com/freecad/FreeCAD-CI/badges/releases/FreeCAD-0-20/pipeline.svg
[freecad-master-status]: https://gitlab.com/freecad/FreeCAD-CI/badges/master/pipeline.svg
[gitlab-branch-0.20]: https://gitlab.com/freecad/FreeCAD-CI/-/commits/releases/FreeCAD-0-20
[gitlab-branch-master]: https://gitlab.com/freecad/FreeCAD-CI/-/commits/master
[freecad-0.18-status]: https://travis-ci.org/FreeCAD/FreeCAD.svg?branch=releases/FreeCAD-0-18
[freecad-master-status]: https://travis-ci.org/FreeCAD/FreeCAD.svg?branch=master
[travis-branches]: https://travis-ci.org/FreeCAD/FreeCAD/branches
[travis-builds]: https://travis-ci.org/FreeCAD/FreeCAD/builds
Compiling
@@ -99,7 +102,7 @@ To report an issue please:
For more detail see:
- [Wiki Page about the Bug Tracker](https://wiki.freecadweb.org/Tracker)
- [Bug Tracker](https://tracker.freecadweb.org)
- [Help Forum](https://forum.freecadweb.org/viewforum.php?f=3)
- [Help Forum](http://forum.freecadweb.org/viewforum.php?f=3)
Usage & Getting help
@@ -119,10 +122,3 @@ pages might help you get started:
The [FreeCAD forum](https://forum.freecadweb.org) is also a great place
to find help and solve specific problems you might encounter when
learning to use FreeCAD.
<p>This project receives generous infrastructure support from
<a href="https://www.digitalocean.com/">
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg" width="91px">
</a> and <a href="https://www.kipro-pcb.com/">KiCad Services Corp.</a>
</p>
-20
View File
@@ -63,23 +63,3 @@ SET(HAVE_QT_KEYPAD_DEFINE 1)
SET(HAVE_QWIDGET_SHOWFULLSCREEN 1)
file(WRITE ${CMAKE_BINARY_DIR}/backtrace.cpp
"#include <cstddef>\n"
"#include <execinfo.h>\n\n"
"int main() {\n"
" void *callstack[128];\n"
" size_t nMaxFrames = sizeof(callstack) / sizeof(callstack[0]);\n"
" size_t nFrames = backtrace(callstack, nMaxFrames);\n"
" char **symbols = backtrace_symbols(callstack, nFrames);\n"
" return 0;\n"
"}"
)
try_compile(
RESULT_VAR
${CMAKE_BINARY_DIR}
SOURCES
${CMAKE_BINARY_DIR}/backtrace.cpp
)
SET(HAVE_BACKTRACE_SYMBOLS ${RESULT_VAR})
+3 -19
View File
@@ -9,7 +9,7 @@
SET( COIN3D_FOUND "NO" )
IF (WIN32)
IF (CYGWIN OR MINGW)
IF (CYGWIN)
FIND_PATH(COIN3D_INCLUDE_DIRS Inventor/So.h
${CMAKE_INCLUDE_PATH}
@@ -24,7 +24,7 @@ IF (WIN32)
/usr/local/lib
)
ELSE (CYGWIN OR MINGW)
ELSE (CYGWIN)
FIND_PATH(COIN3D_INCLUDE_DIRS Inventor/So.h
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\Coin3D\\2;Installation Path]/include"
@@ -61,7 +61,7 @@ IF (WIN32)
# SET (COIN3D_LIBRARIES coin2d CACHE STRING "Coin3D Library (Debug) - Open Inventor API")
ENDIF (COIN3D_LIBRARIES)
ENDIF (CYGWIN OR MINGW)
ENDIF (CYGWIN)
ELSE (WIN32)
IF(APPLE)
@@ -105,21 +105,5 @@ ENDIF (WIN32)
IF(COIN3D_LIBRARIES)
SET( COIN3D_FOUND "YES" )
message(STATUS "Coin3D libraries found")
IF(NOT COIN3D_VERSION)
file(READ "${COIN3D_INCLUDE_DIRS}/Inventor/C/basic.h" _coin3d_basic_h)
string(REGEX MATCH "define[ \t]+COIN_MAJOR_VERSION[ \t]+([0-9?])" _coin3d_major_version_match "${_coin3d_basic_h}")
set(COIN3D_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+COIN_MINOR_VERSION[ \t]+([0-9?])" _coin3d_minor_version_match "${_coin3d_basic_h}")
set(COIN3D_MINOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+COIN_MICRO_VERSION[ \t]+([0-9?])" _coin3d_micro_version_match "${_coin3d_basic_h}")
set(COIN3D_MICRO_VERSION "${CMAKE_MATCH_1}")
set(COIN3D_VERSION "${COIN3D_MAJOR_VERSION}.${COIN3D_MINOR_VERSION}.${COIN3D_MICRO_VERSION}")
ENDIF()
IF(NOT PIVY_VERSION)
execute_process (COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.__version__,end='')" OUTPUT_VARIABLE PIVY_VERSION)
ENDIF()
ENDIF(COIN3D_LIBRARIES)
-12
View File
@@ -5,7 +5,6 @@
# MEDFILE_LIBRARIES
# MEDFILE_C_LIBRARIES
# MEDFILE_F_LIBRARIES
# MEDFILE_VERSION
#
# The CMake (or environment) variable MEDFILE_ROOT_DIR can be set to
# guide the detection and indicate a root directory to look into.
@@ -57,14 +56,3 @@ ENDIF(MEDFILE_F_LIBRARIES)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MEDFile REQUIRED_VARS MEDFILE_INCLUDE_DIRS MEDFILE_LIBRARIES)
IF(meddotH)
FILE(READ "${meddotH}" _med_h)
STRING(REGEX MATCH "define[ \t]+MED_MAJOR_NUM[ \t]+([0-9?])" _med_major_version_match "${_med_h}")
SET(MED_MAJOR_VERSION "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "define[ \t]+MED_MINOR_NUM[ \t]+([0-9?])" _med_minor_version_match "${_med_h}")
SET(MED_MINOR_VERSION "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "define[ \t]+MED_RELEASE_NUM[ \t]+([0-9?])" _med_release_version_match "${_med_h}")
SET(MED_RELEASE_VERSION "${CMAKE_MATCH_1}")
SET(MEDFILE_VERSION "${MED_MAJOR_VERSION}.${MED_MINOR_VERSION}.${MED_RELEASE_VERSION}")
ENDIF()
+1 -1
View File
@@ -9,7 +9,7 @@
# MATPLOTLIB_VERSION_PATCH - the patch version number of matplotlib
# MATPLOTLIB_PATH_DIRS - path to the matplotlib include files
IF(Python3_Interpreter_FOUND)
IF(PYTHONINTERP_FOUND)
# Try to import matplotlib into Python interpreter. Python
# interpreter was found previously as required package, so
# don't take care about this.
-1
View File
@@ -5,7 +5,6 @@
# PYCXX_SOURCE_DIR
# PYCXX_FOUND
# PYCXX_SOURCES
# PYCXX_VERSION
#
# The PYCXX_*_DIR variables can be set to tell this module where
# the files are.
+13 -20
View File
@@ -23,7 +23,7 @@ endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Since Qt v5.14, pyside2-uic and pyside2-rcc are directly provided by Qt5Core uic and rcc, with '-g python' option
# We test Qt5Core version to act accordingly
FIND_PACKAGE(Qt5 COMPONENTS Core Widgets)
FIND_PACKAGE(Qt5Core)
IF(Qt5Core_VERSION VERSION_LESS 5.14)
# Legacy (< 5.14)
@@ -31,22 +31,15 @@ IF(Qt5Core_VERSION VERSION_LESS 5.14)
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} pyrcc5 HINTS ${PYSIDE_BIN_DIR})
set(UICOPTIONS "")
set(RCCOPTIONS "")
ELSE()
ELSE(Qt5Core_VERSION VERSION_LESS 5.14)
# New (>= 5.14)
if (TARGET Qt::uic)
get_property(PYSIDE2UICBINARY TARGET Qt::uic PROPERTY LOCATION)
set(UICOPTIONS "--generator=python")
endif()
if (TARGET Qt::rcc)
get_property(PYSIDE2RCCBINARY TARGET Qt::rcc PROPERTY LOCATION)
set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
endif()
FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic-qt5 uic pyside2-uic)
set(UICOPTIONS "--generator=python")
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc-qt5 rcc pyside2-rcc)
set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
ENDIF(Qt5Core_VERSION VERSION_LESS 5.14)
MACRO(PYSIDE_WRAP_UI outfiles)
if (NOT PYSIDE2UICBINARY)
message(FATAL_ERROR "Qt uic is required for generating ${ARGN}")
endif()
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
@@ -62,10 +55,10 @@ MACRO(PYSIDE_WRAP_UI outfiles)
else()
# Especially on Open Build Service we don't want changing date like
# pyside2-uic generates in comments at beginning., which is why
# we follow the tool command with a POSIX-friendly sed.
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND "${PYSIDE2UICBINARY}" ${UICOPTIONS} "${infile}" -o "${outfile}"
COMMAND sed "/^# /d" "${outfile}" >"${outfile}.tmp" && mv "${outfile}.tmp" "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
endif()
@@ -74,9 +67,6 @@ MACRO(PYSIDE_WRAP_UI outfiles)
ENDMACRO (PYSIDE_WRAP_UI)
MACRO(PYSIDE_WRAP_RC outfiles)
if (NOT PYSIDE2RCCBINARY)
message(FATAL_ERROR "Qt rcc is required for generating ${ARGN}")
endif()
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
@@ -95,7 +85,7 @@ MACRO(PYSIDE_WRAP_RC outfiles)
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
COMMAND "${PYSIDE2RCCBINARY}" ${RCCOPTIONS} "${infile}" ${PY_ATTRIBUTE} -o "${outfile}"
COMMAND sed "/^# /d" "${outfile}" >"${outfile}.tmp" && mv "${outfile}.tmp" "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
endif()
@@ -103,8 +93,11 @@ MACRO(PYSIDE_WRAP_RC outfiles)
ENDFOREACH(it)
ENDMACRO (PYSIDE_WRAP_RC)
IF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY})
set(PYSIDE2_TOOLS_FOUND TRUE)
ENDIF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY})
if(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY)
set(PYSIDE2_TOOLS_FOUND TRUE)
if (NOT PySide2Tools_FIND_QUIETLY)
message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}")
endif (NOT PySide2Tools_FIND_QUIETLY)
+101
View File
@@ -0,0 +1,101 @@
# Try to find PySide utilities, PYSIDEUIC4 and PYSIDERCC4:
# PYSIDEUIC4BINARY - Location of PYSIDEUIC4 executable
# PYSIDERCC4BINARY - Location of PYSIDERCC4 executable
# PYSIDE_TOOLS_FOUND - PySide utilities found.
# Also provides macro similar to FindQt4.cmake's WRAP_UI and WRAP_RC,
# for the automatic generation of Python code from Qt4's user interface
# ('.ui') and resource ('.qrc') files. These macros are called:
# - PYSIDE_WRAP_UI
# - PYSIDE_WRAP_RC
IF(PYSIDEUIC4BINARY AND PYSIDERCC4BINARY)
# Already in cache, be silent
set(PYSIDE_TOOLS_FOUND_QUIETLY TRUE)
ENDIF(PYSIDEUIC4BINARY AND PYSIDERCC4BINARY)
if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#pyside tools are often in same location as python interpreter
get_filename_component(PYTHON_BIN_DIR ${PYTHON_EXECUTABLE} PATH)
set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR})
endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
FIND_PROGRAM(PYSIDEUIC4BINARY NAMES python2-pyside-uic pyside-uic pyside-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
FIND_PROGRAM(PYSIDERCC4BINARY NAMES pyside-rcc pyside-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR})
MACRO(PYSIDE_WRAP_UI outfiles)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py)
#ADD_CUSTOM_TARGET(${it} ALL
# DEPENDS ${outfile}
#)
if(WIN32)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDEUIC4BINARY} ${infile} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
else(WIN32)
# Especially on Open Build Service we don't want changing date like
# pyside-uic generates in comments at beginning, which is why
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND "${PYSIDEUIC4BINARY}" "${infile}" -o "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
endif(WIN32)
list(APPEND ${outfiles} ${outfile})
ENDFOREACH(it)
ENDMACRO (PYSIDE_WRAP_UI)
MACRO(PYSIDE_WRAP_RC outfiles)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py")
#ADD_CUSTOM_TARGET(${it} ALL
# DEPENDS ${outfile}
#)
if (${PYTHON_VERSION_MAJOR} LESS 3)
SET(PY_ATTRIBUTE "")
else (${PYTHON_VERSION_MAJOR} LESS 3)
SET(PY_ATTRIBUTE "-py3")
endif (${PYTHON_VERSION_MAJOR} LESS 3)
if(WIN32)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${PYSIDERCC4BINARY} ${infile} ${PY_ATTRIBUTE} -o ${outfile}
MAIN_DEPENDENCY ${infile}
)
else(WIN32)
# Especially on Open Build Service we don't want changing date like
# pyside-rcc generates in comments at beginning, which is why
# we follow the tool command with in-place sed.
ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
COMMAND "${PYSIDERCC4BINARY}" "${infile}" ${PY_ATTRIBUTE} -o "${outfile}"
COMMAND sed -i "/^# /d" "${outfile}"
MAIN_DEPENDENCY "${infile}"
)
endif(WIN32)
list(APPEND ${outfiles} ${outfile})
ENDFOREACH(it)
ENDMACRO (PYSIDE_WRAP_RC)
IF(EXISTS ${PYSIDEUIC4BINARY} AND EXISTS ${PYSIDERCC4BINARY})
set(PYSIDE_TOOLS_FOUND TRUE)
ENDIF(EXISTS ${PYSIDEUIC4BINARY} AND EXISTS ${PYSIDERCC4BINARY})
if(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)
if (NOT PySideTools_FIND_QUIETLY)
message(STATUS "Found PySide Tools: ${PYSIDEUIC4BINARY}, ${PYSIDERCC4BINARY}")
endif (NOT PySideTools_FIND_QUIETLY)
else(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)
if(PySideTools_FIND_REQUIRED)
message(FATAL_ERROR "PySideTools could not be found, but are required.")
else(PySideTools_FIND_REQUIRED)
if (NOT PySideTools_FIND_QUIETLY)
message(STATUS "PySideTools: not found.")
endif (NOT PySideTools_FIND_QUIETLY)
endif(PySideTools_FIND_REQUIRED)
endif(PYSIDERCC4BINARY AND PYSIDEUIC4BINARY)
+164
View File
@@ -0,0 +1,164 @@
# - Try to find Windows Installer XML
# See http://wix.sourceforge.net
#
# The following variables are optionally searched for defaults
# WIX_ROOT_DIR: Base directory of WIX2 tree to use.
#
# The following are set after configuration is done:
# WIX_FOUND
# WIX_ROOT_DIR
# WIX_CANDLE
# WIX_LIGHT
#
# 2009/02 Petr Pytelka (pyta at lightcomp.cz)
#
MACRO(DBG_MSG _MSG)
# MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}):\n ${_MSG}")
ENDMACRO(DBG_MSG)
# typical root dirs of installations, exactly one of them is used
SET (WIX_POSSIBLE_ROOT_DIRS
"${WIX_ROOT_DIR}"
"$ENV{WIX_ROOT_DIR}"
"$ENV{ProgramFiles}/Windows Installer XML"
)
#DBG_MSG("DBG (WIX_POSSIBLE_ROOT_DIRS=${WIX_POSSIBLE_ROOT_DIRS}")
#
# select exactly ONE WIX base directory/tree
# to avoid mixing different version headers and libs
#
FIND_PATH(WIX_ROOT_DIR
NAMES
bin/candle.exe
bin/light.exe
PATHS ${WIX_POSSIBLE_ROOT_DIRS})
DBG_MSG("WIX_ROOT_DIR=${WIX_ROOT_DIR}")
#
# Logic selecting required libs and headers
#
SET(WIX_FOUND OFF)
IF(WIX_ROOT_DIR)
SET(WIX_FOUND ON)
ENDIF(WIX_ROOT_DIR)
# display help message
IF(NOT WIX_FOUND)
# make FIND_PACKAGE friendly
IF(NOT WIX_FIND_QUIETLY)
IF(WIX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR
"Windows Installer XML required but some files not found. Please specify it's location with WIX_ROOT_DIR env. variable.")
ELSE(WIX_FIND_REQUIRED)
MESSAGE(STATUS
"ERROR: Windows Installer XML was not found.")
ENDIF(WIX_FIND_REQUIRED)
ENDIF(NOT WIX_FIND_QUIETLY)
ELSE(NOT WIX_FOUND)
SET(WIX_CANDLE ${WIX_ROOT_DIR}/bin/candle.exe)
SET(WIX_LIGHT ${WIX_ROOT_DIR}/bin/light.exe)
# MESSAGE(STATUS "Windows Installer XML found.")
ENDIF(NOT WIX_FOUND)
MARK_AS_ADVANCED(
WIX_ROOT_DIR
WIX_CANDLE
WIX_LIGHT
)
#
# Call wix compiler
#
# Parameters:
# _sources - name of list with sources
# _obj - name of list for target objects
#
MACRO(WIX_COMPILE _sources _objs _extra_dep)
DBG_MSG("WIX compile: ${${_sources}}")
FOREACH (_current_FILE ${${_sources}})
GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
SET (SOURCE_WIX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE} )
DBG_MSG("WIX source file: ${SOURCE_WIX_FILE}")
# Check whether source exists
IF(EXISTS ${SOURCE_WIX_FILE})
ELSE(EXISTS ${SOURCE_WIX_FILE})
MESSAGE(FATAL_ERROR "Path not exists: ${SOURCE_WIX_FILE}")
ENDIF(EXISTS ${SOURCE_WIX_FILE})
SET (OUTPUT_WIXOBJ ${_basename}.wixobj )
DBG_MSG("WIX output: ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}")
DBG_MSG("WIX command: ${WIX_CANDLE}")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}
COMMAND ${WIX_CANDLE}
ARGS ${WIX_CANDLE_FLAGS} ${SOURCE_WIX_FILE}
DEPENDS ${SOURCE_WIX_FILE} ${${_extra_dep}}
COMMENT "Compiling ${SOURCE_WIX_FILE} -> ${OUTPUT_WIXOBJ}"
)
SET(${_objs} ${${_objs}} ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ} )
DBG_MSG("WIX compile output: ${${_objs}}")
ENDFOREACH (_current_FILE)
ENDMACRO(WIX_COMPILE)
#
# Call wix compiler
#
# Parameters:
# _sources - name of list with sources
# _obj - name of list for target objects
#
MACRO(WIX_COMPILE_ALL _target _sources _extra_dep)
DBG_MSG("WIX compile all: ${${_sources}}, dependencies: ${${_extra_dep}}")
ADD_CUSTOM_COMMAND(
OUTPUT ${_target}
COMMAND ${WIX_CANDLE}
ARGS ${WIX_CANDLE_FLAGS} -out "${_target}" ${${_sources}}
DEPENDS ${${_sources}} ${${_extra_dep}}
COMMENT "Compiling ${${_sources}} -> ${_target}"
)
ENDMACRO(WIX_COMPILE_ALL)
#
# Link MSI file
#
# Parameters
# _target - Name of target file
# _sources - Name of list with sources
#
MACRO(WIX_LINK _target _sources _loc_files)
DBG_MSG("WIX command: ${WIX_LIGHT}\n WIX target: ${_target} objs: ${${_sources}}")
SET( WIX_LINK_FLAGS_A "" )
# Add localization
FOREACH (_current_FILE ${${_loc_files}})
SET( WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS_A} -loc "${_current_FILE}" )
DBG_MSG("WIX link localization: ${_current_FILE}")
ENDFOREACH (_current_FILE)
DBG_MSG("WIX link flags: ${WIX_LINK_FLAGS_A}")
ADD_CUSTOM_COMMAND(
OUTPUT ${_target}
COMMAND ${WIX_LIGHT}
ARGS ${WIX_LINK_FLAGS_A} -out "${_target}" ${${_sources}}
DEPENDS ${${_sources}}
COMMENT "Linking ${${_sources}} -> ${_target}"
)
ENDMACRO(WIX_LINK)
+51
View File
@@ -0,0 +1,51 @@
# Locate Xerces-C include paths and libraries
# Xerces-C can be found at http://xml.apache.org/xerces-c/
# Written by Frederic Heem, frederic.heem _at_ telsey.it
# Modified by Jos van den Oever
# This module defines
# XercesC_INCLUDE_DIRS, where to find ptlib.h, etc.
# XercesC_LIBRARIES, the libraries to link against to use pwlib.
# XercesC_FOUND, If false, don't try to use pwlib.
FIND_PATH(XercesC_INCLUDE_DIRS xercesc/dom/DOM.hpp
${CMAKE_INCLUDE_PATH}
"[HKEY_CURRENT_USER\\software\\xerces-c\\src]"
"[HKEY_CURRENT_USER\\xerces-c\\src]"
$ENV{XERCESCROOT}/src/
/usr/local/include
/usr/include
)
FIND_LIBRARY(XercesC_LIBRARIES
NAMES
xerces-c
xerces-c_3
PATHS
${CMAKE_LIBRARY_PATH}
"[HKEY_CURRENT_USER\\software\\xerces-c\\lib]"
"[HKEY_CURRENT_USER\\xerces-c\\lib]"
$ENV{XERCESCROOT}/${LIB_DESTINATION}
/usr/local/${LIB_DESTINATION}
/usr/${LIB_DESTINATION}
)
# if the include a the library are found then we have it
IF(XercesC_INCLUDE_DIRS AND XercesC_LIBRARIES)
SET(XercesC_FOUND "YES" )
IF(NOT XERCESC__FIND_QUIETLY)
MESSAGE(STATUS "Found Xerces-C: ${XercesC_LIBRARIES}")
ENDIF(NOT XERCESC__FIND_QUIETLY)
ELSE(XercesC_INCLUDE_DIRS AND XercesC_LIBRARIES)
IF(XERCESC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Xerces-C was not found.")
ENDIF(XERCESC_FIND_REQUIRED)
IF(NOT XERCESC__FIND_QUIETLY)
MESSAGE(STATUS "Xerces-C was not found.")
ENDIF(NOT XERCESC__FIND_QUIETLY)
ENDIF(XercesC_INCLUDE_DIRS AND XercesC_LIBRARIES)
#MARK_AS_ADVANCED(
# XercesC_INCLUDE_DIRS
# XercesC_LIBRARIES
#)
@@ -1,9 +0,0 @@
macro(BuildAndInstallDesignerPlugin)
# =================================================================
# ============= Build and install the designer plugin =============
# =================================================================
if(BUILD_DESIGNER_PLUGIN)
add_subdirectory(src/Tools/plugins/widget)
endif(BUILD_DESIGNER_PLUGIN)
endmacro(BuildAndInstallDesignerPlugin)
@@ -34,6 +34,7 @@ macro(CheckInterModuleDependencies)
REQUIRES_MODS(BUILD_REVERSEENGINEERING BUILD_PART BUILD_MESH)
REQUIRES_MODS(BUILD_ROBOT BUILD_PART)
REQUIRES_MODS(BUILD_SANDBOX BUILD_PART BUILD_MESH)
REQUIRES_MODS(BUILD_SHIP BUILD_PART BUILD_PLOT BUILD_IMAGE)
REQUIRES_MODS(BUILD_SKETCHER BUILD_PART)
REQUIRES_MODS(BUILD_SPREADSHEET BUILD_DRAFT)
REQUIRES_MODS(BUILD_START BUILD_WEB)
@@ -28,18 +28,22 @@ macro(CompilerChecksAndSetups)
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION)
# Enabled C++17 for Freecad 0.20 and later
set(BUILD_ENABLE_CXX_STD "C++17" CACHE STRING "Enable C++ standard")
# Enabled C++11 for Freecad 0.17 and later
if (FREECAD_VERSION VERSION_GREATER 0.16)
set(BUILD_ENABLE_CXX_STD "C++11" CACHE STRING "Enable C++ standard")
set_property(CACHE BUILD_ENABLE_CXX_STD PROPERTY STRINGS
"C++11"
"C++14"
"C++17"
"C++20"
)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
message(FATAL_ERROR "FreeCAD 0.20 and later requires C++17. G++ must be 7.3 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
message(FATAL_ERROR "FreeCAD 0.20 and later requires C++17. Clang must be 6.0 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "FreeCAD 0.17 and later requires C++11. G++ must be 4.7 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
elseif(CMAKE_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "FreeCAD 0.17 and later requires C++11. Clang must be 3.3 or later, the used version is ${CMAKE_CXX_COMPILER_VERSION}")
endif()
endif(FREECAD_VERSION VERSION_GREATER 0.16)
# Escape the two plus chars as otherwise cmake complains about invalid regex
if(${BUILD_ENABLE_CXX_STD} MATCHES "C\\+\\+20")
@@ -24,7 +24,6 @@ macro(ConfigureCMakeVariables)
# used as compiler defines
set(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}")
set(LIBRARYDIR "${CMAKE_INSTALL_LIBDIR}")
set(DOCDIR "${CMAKE_INSTALL_DOCDIR}")
message(STATUS "prefix: ${CMAKE_INSTALL_PREFIX}")
@@ -5,37 +5,25 @@ macro(CreatePackagingTargets)
#add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_custom_target(dist-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(distdfsg-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--dfsg
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX OR MINGW)
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
add_custom_target(distcheck-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--check
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(distcheckdfsg-git
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/Tools/makedist.py
--bindir=${CMAKE_BINARY_DIR}
--major=${PACKAGE_VERSION_MAJOR}
--minor=${PACKAGE_VERSION_MINOR}
--dfsg
--check
--srcdir=${CMAKE_SOURCE_DIR} --bindir=${CMAKE_BINARY_DIR} --dfsg --check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
endif(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
endmacro(CreatePackagingTargets)
@@ -31,8 +31,18 @@ macro(InitializeFreeCADBuildOptions)
if (DEFINED ENV{FREECAD_LIBPACK_DIR})
set(FREECAD_LIBPACK_DIR $ENV{FREECAD_LIBPACK_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
message(STATUS "Found libpack env variable: ${FREECAD_LIBPACK_DIR}")
if (EXISTS ${FREECAD_LIBPACK_DIR}/lib/Qt5Core.lib)
option(BUILD_QT5 "Build with Qt5." ON)
else()
option(BUILD_QT5 "Build with Qt5." OFF)
endif()
else()
set(FREECAD_LIBPACK_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
if (EXISTS ${FREECAD_LIBPACK_DIR}/lib/Qt5Core.lib)
option(BUILD_QT5 "Build with Qt5." ON)
else()
option(BUILD_QT5 "Build with Qt5." OFF)
endif()
endif()
set(LIBPACK_FOUND OFF )
@@ -58,10 +68,10 @@ macro(InitializeFreeCADBuildOptions)
message(STATUS "Visit: https://github.com/apeltauer/FreeCAD/releases/ for Windows libpack downloads.")
endif()
else(MSVC)
option(BUILD_QT5 "Build with Qt5." OFF)
option(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF)
set(FREECAD_LIBPACK_DIR "" CACHE PATH "Directory of the FreeCAD LibPack")
endif(MSVC)
option(BUILD_QT5 "Build with Qt5." ON)
# https://blog.kitware.com/constraining-values-with-comboboxes-in-cmake-cmake-gui/
set(FREECAD_USE_OCC_VARIANT "Community Edition" CACHE STRING "Official OpenCASCADE version or community edition")
@@ -71,6 +81,10 @@ macro(InitializeFreeCADBuildOptions)
)
if (BUILD_QT5)
option(FREECAD_USE_QTOPENGL_WIDGET "Replace QGLWidget with QOpenGLWidget." ON)
if (FREECAD_USE_QTOPENGL_WIDGET)
set(HAVE_QT5_OPENGL 1 )
endif()
set(FREECAD_USE_QTWEBMODULE "Automatic" CACHE STRING "Qt Webkit or Qt WebEngine")
set_property(CACHE FREECAD_USE_QTWEBMODULE PROPERTY STRINGS
"Automatic"
@@ -80,8 +94,6 @@ macro(InitializeFreeCADBuildOptions)
endif()
configure_file(${CMAKE_SOURCE_DIR}/src/QtOpenGL.h.cmake ${CMAKE_BINARY_DIR}/src/QtOpenGL.h)
option(BUILD_DESIGNER_PLUGIN "Build and install the designer plugin" OFF)
if(APPLE)
option(FREECAD_CREATE_MAC_APP "Create app bundle on install" OFF)
@@ -111,6 +123,7 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_TEMPLATE "Build the FreeCAD template module which is only for testing purposes" OFF)
option(BUILD_ADDONMGR "Build the FreeCAD addon manager module" ON)
option(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
option(BUILD_ASSEMBLY "Build the FreeCAD Assembly module" OFF)
option(BUILD_COMPLETE "Build the FreeCAD complete module" OFF)
option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
option(BUILD_DRAWING "Build the FreeCAD drawing module" ON)
@@ -127,11 +140,12 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_PART "Build the FreeCAD part module" ON)
option(BUILD_PART_DESIGN "Build the FreeCAD part design module" ON)
option(BUILD_PATH "Build the FreeCAD path module" ON)
option(BUILD_PLOT "Build the FreeCAD plot module" ON)
option(BUILD_PLOT "Build the FreeCAD plot module" OFF)
option(BUILD_POINTS "Build the FreeCAD points module" ON)
option(BUILD_RAYTRACING "Build the FreeCAD ray tracing module" ON)
option(BUILD_REVERSEENGINEERING "Build the FreeCAD reverse engineering module" ON)
option(BUILD_ROBOT "Build the FreeCAD robot module" ON)
option(BUILD_SHIP "Build the FreeCAD ship module" OFF)
option(BUILD_SHOW "Build the FreeCAD Show module (helper module for visibility automation)" ON)
option(BUILD_SKETCHER "Build the FreeCAD sketcher module" ON)
option(BUILD_SPREADSHEET "Build the FreeCAD spreadsheet module" ON)
@@ -146,7 +160,7 @@ macro(InitializeFreeCADBuildOptions)
if(MSVC)
option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF) # 3/5/2021 current LibPack uses non-C++17 FLANN
option(FREECAD_USE_PCL "Build the features that use PCL libs" ON)
option(FREECAD_USE_3DCONNEXION "Use the 3D connexion SDK to support 3d mouse." ON)
elseif(APPLE)
find_library(3DCONNEXIONCLIENT_FRAMEWORK 3DconnexionClient)
+82 -76
View File
@@ -13,7 +13,7 @@ macro(PrintFinalReport)
message(STATUS "Standard: Requires C++${CMAKE_CXX_STANDARD}")
# Qt5 needs/sets PYTHON_CONFIG_SUFFIX regarding Shiboken
message(STATUS "Python: ${PYTHON_VERSION_STRING} [${PYTHON_EXECUTABLE}] [${PYTHON_CONFIG_SUFFIX}]")
message(STATUS "Python: [${PYTHON_EXECUTABLE}] [${PYTHON_CONFIG_SUFFIX}]")
if(DEFINED PCL_FOUND)
message(STATUS "PCL: ${PCL_VERSION}")
@@ -29,11 +29,11 @@ macro(PrintFinalReport)
message(STATUS "Boost: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} (${Boost_VERSION})")
message(STATUS "XercesC: ${XercesC_VERSION} [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]")
message(STATUS "XercesC: [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]")
message(STATUS "ZLIB: ${ZLIB_VERSION_STRING}")
message(STATUS "PyCXX: ${PYCXX_VERSION} [${PYCXX_INCLUDE_DIR}]")
message(STATUS "PyCXX: [${PYCXX_INCLUDE_DIR}]")
message(STATUS "OCC: ${OCC_VERSION_STRING} [${OCC_LIBRARIES}] [${OCC_LIBRARY_DIR}] [${OCC_INCLUDE_DIR}]")
@@ -42,7 +42,7 @@ macro(PrintFinalReport)
message(STATUS "SMESH: ${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK}")
else(FREECAD_USE_EXTERNAL_SMESH)
message(STATUS "SMESH: build internal")
message(STATUS " MEDFile: ${MEDFILE_VERSION} [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]")
message(STATUS " MEDFile: [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]")
message(STATUS " HDF5: ${HDF5_VERSION}")
message(STATUS " VTK: ${VTK_VERSION}")
endif(FREECAD_USE_EXTERNAL_SMESH)
@@ -70,81 +70,88 @@ macro(PrintFinalReport)
message(STATUS "Eigen3: not found")
endif(DEFINED EIGEN3_FOUND)
message(STATUS "Qt5Core: ${Qt5Core_VERSION}")
message(STATUS "Qt5Network: ${Qt5Network_VERSION}")
message(STATUS "Qt5Xml: ${Qt5Xml_VERSION}")
message(STATUS "Qt5XmlPatterns: ${Qt5XmlPatterns_VERSION}")
if (BUILD_GUI)
message(STATUS "Qt5Widgets: ${Qt5Widgets_VERSION}")
message(STATUS "Qt5PrintSupport: ${Qt5PrintSupport_VERSION}")
message(STATUS "Qt5OpenGL: ${Qt5OpenGL_VERSION}")
message(STATUS "Qt5Svg: ${Qt5Svg_VERSION}")
message(STATUS "Qt5UiTools: ${Qt5UiTools_VERSION}")
message(STATUS "Qt5Concurrent: ${Qt5Concurrent_VERSION}")
if(BUILD_WEB)
if (Qt5WebKitWidgets_FOUND)
message(STATUS "Qt5WebKitWidgets: ${Qt5WebKitWidgets_VERSION}")
if(NOT BUILD_QT5)
message(STATUS "Qt4: ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
if(QT_QTWEBKIT_FOUND)
message(STATUS "QtWebKit: found")
else(QT_QTWEBKIT_FOUND)
message(STATUS "QtWebKit: not found")
endif(QT_QTWEBKIT_FOUND)
message(STATUS "Shiboken: ${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]")
message(STATUS "PySide: ${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]")
message(STATUS "PySideTools: [${PYSIDEUIC4BINARY}] [${PYSIDERCC4BINARY}]")
else(NOT BUILD_QT5)
message(STATUS "Qt5Core: ${Qt5Core_VERSION}")
message(STATUS "Qt5Network: ${Qt5Network_VERSION}")
message(STATUS "Qt5Xml: ${Qt5Xml_VERSION}")
message(STATUS "Qt5XmlPatterns: ${Qt5XmlPatterns_VERSION}")
if (BUILD_GUI)
message(STATUS "Qt5Widgets: ${Qt5Widgets_VERSION}")
message(STATUS "Qt5PrintSupport: ${Qt5PrintSupport_VERSION}")
message(STATUS "Qt5OpenGL: ${Qt5OpenGL_VERSION}")
message(STATUS "Qt5Svg: ${Qt5Svg_VERSION}")
message(STATUS "Qt5UiTools: ${Qt5UiTools_VERSION}")
message(STATUS "Qt5Concurrent: ${Qt5Concurrent_VERSION}")
if(BUILD_WEB)
if (Qt5WebKitWidgets_FOUND)
message(STATUS "Qt5WebKitWidgets: ${Qt5WebKitWidgets_VERSION}")
endif()
if (Qt5WebEngineWidgets_FOUND)
message(STATUS "Qt5WebEngineWidgets: ${Qt5WebEngineWidgets_VERSION}")
endif()
else(BUILD_WEB)
message(STATUS "Qt5WebKitWidgets: not needed (BUILD_WEB)")
message(STATUS "Qt5WebEngineWidgets: not needed (BUILD_WEB)")
endif(BUILD_WEB)
if(${Qt5WinExtras_FOUND})
message(STATUS "Qt5WinExtras: ${Qt5WinExtras_VERSION}")
endif()
if (Qt5WebEngineWidgets_FOUND)
message(STATUS "Qt5WebEngineWidgets: ${Qt5WebEngineWidgets_VERSION}")
endif()
else(BUILD_WEB)
message(STATUS "Qt5WebKitWidgets: not needed (BUILD_WEB)")
message(STATUS "Qt5WebEngineWidgets: not needed (BUILD_WEB)")
endif(BUILD_WEB)
if(BUILD_DESIGNER_PLUGIN)
message(STATUS "Designer plugin: ${DESIGNER_PLUGIN_LOCATION}/${libFreeCAD_widgets}")
else(BUILD_DESIGNER_PLUGIN)
message(STATUS "Designer plugin: not built per user request (BUILD_DESIGNER_PLUGIN)")
endif(BUILD_DESIGNER_PLUGIN)
if(${Qt5WinExtras_FOUND})
message(STATUS "Qt5WinExtras: ${Qt5WinExtras_VERSION}")
endif()
else(BUILD_GUI)
message(STATUS "Qt5Widgets: not needed")
message(STATUS "Qt5PrintSupport: not needed")
message(STATUS "Qt5OpenGL: not needed")
message(STATUS "Qt5Svg: not needed")
message(STATUS "Qt5UiTools: not needed")
message(STATUS "Qt5Concurrent: not needed")
message(STATUS "Qt5WebKitWidgets: not needed")
endif(BUILD_GUI)
else(BUILD_GUI)
message(STATUS "Qt5Widgets: not needed")
message(STATUS "Qt5PrintSupport: not needed")
message(STATUS "Qt5OpenGL: not needed")
message(STATUS "Qt5Svg: not needed")
message(STATUS "Qt5UiTools: not needed")
message(STATUS "Qt5Concurrent: not needed")
message(STATUS "Qt5WebKitWidgets: not needed")
endif(BUILD_GUI)
if(DEFINED MACPORTS_PREFIX)
if(DEFINED Shiboken_FOUND)
message(STATUS "Shiboken: ${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]")
else(DEFINED Shiboken_FOUND)
message(STATUS "Shiboken: not found (only searched if MACPORTS_PREFIX is defined)")
endif(DEFINED Shiboken_FOUND)
if(DEFINED PySide_FOUND)
message(STATUS "PySide: ${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]")
if(DEFINED MACPORTS_PREFIX)
if(DEFINED Shiboken_FOUND)
message(STATUS "Shiboken: ${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]")
else(DEFINED Shiboken_FOUND)
message(STATUS "Shiboken: not found (only searched if MACPORTS_PREFIX is defined)")
endif(DEFINED Shiboken_FOUND)
if(DEFINED PySide_FOUND)
message(STATUS "PySide: ${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]")
if(NOT PYSIDE_INCLUDE_DIR)
message(STATUS " IncludeDir: Unable to find, python version mismatch?")
endif(NOT PYSIDE_INCLUDE_DIR)
else(DEFINED PySide_FOUND)
message(STATUS "PySide: not found (only searched if MACPORTS_PREFIX is defined)")
endif(DEFINED PySide_FOUND)
endif(DEFINED MACPORTS_PREFIX)
if(DEFINED Shiboken2_FOUND)
message(STATUS "Shiboken2: ${Shiboken2_VERSION} [${Shiboken2_DIR}] [${SHIBOKEN_INCLUDE_DIR}]")
else(DEFINED Shiboken2_FOUND)
message(STATUS "Shiboken2: not found")
endif(DEFINED Shiboken2_FOUND)
if(DEFINED PySide2_FOUND)
message(STATUS "PySide2: ${PySide2_VERSION} [${PYSIDE_INCLUDE_DIR}]")
if(NOT PYSIDE_INCLUDE_DIR)
message(STATUS " IncludeDir: Unable to find, python version mismatch?")
endif(NOT PYSIDE_INCLUDE_DIR)
else(DEFINED PySide_FOUND)
message(STATUS "PySide: not found (only searched if MACPORTS_PREFIX is defined)")
endif(DEFINED PySide_FOUND)
endif(DEFINED MACPORTS_PREFIX)
if(DEFINED Shiboken2_FOUND)
message(STATUS "Shiboken2: ${Shiboken2_VERSION} [${Shiboken2_DIR}] [${SHIBOKEN_INCLUDE_DIR}]")
else(DEFINED Shiboken2_FOUND)
message(STATUS "Shiboken2: not found")
endif(DEFINED Shiboken2_FOUND)
if(DEFINED PySide2_FOUND)
message(STATUS "PySide2: ${PySide2_VERSION} [${PYSIDE_INCLUDE_DIR}]")
if(NOT PYSIDE_INCLUDE_DIR)
message(STATUS " IncludeDir: Unable to find, python version mismatch?")
endif(NOT PYSIDE_INCLUDE_DIR)
else(DEFINED PySide2_FOUND)
message(STATUS "PySide2: not found")
endif(DEFINED PySide2_FOUND)
if(DEFINED PYSIDE2_TOOLS_FOUND)
message(STATUS "PySide2Tools: [${PYSIDE2UICBINARY}] [${PYSIDE2RCCBINARY}]")
else(DEFINED PYSIDE2_TOOLS_FOUND)
message(STATUS "PySide2Tools: not found")
endif(DEFINED PYSIDE2_TOOLS_FOUND)
else(DEFINED PySide2_FOUND)
message(STATUS "PySide2: not found")
endif(DEFINED PySide2_FOUND)
if(DEFINED PYSIDE2_TOOLS_FOUND)
message(STATUS "PySide2Tools: [${PYSIDE2UICBINARY}] [${PYSIDE2RCCBINARY}]")
else(DEFINED PYSIDE2_TOOLS_FOUND)
message(STATUS "PySide2Tools: not found")
endif(DEFINED PYSIDE2_TOOLS_FOUND)
endif(NOT BUILD_QT5)
if(FREECAD_USE_FREETYPE)
if(DEFINED FREETYPE_FOUND)
@@ -157,10 +164,9 @@ macro(PrintFinalReport)
endif(FREECAD_USE_FREETYPE)
message(STATUS "OpenGL: ${OPENGL_gl_LIBRARY}")
message(STATUS "OpenGLU: [${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]")
message(STATUS "OpenGLU: ${OPENGL_glu_LIBRARY} [${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]")
message(STATUS "Coin3D: ${COIN3D_VERSION} [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
message(STATUS "Pivy: ${PIVY_VERSION}")
message(STATUS "Coin3D: [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]")
if (WIN32)
@@ -43,7 +43,7 @@ macro(SetGlobalCompilerAndLinkerSettings)
endif()
endif(FREECAD_RELEASE_SEH)
option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" ON)
option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" OFF)
if(FREECAD_USE_MP_COMPILE_FLAG)
# set "Build with Multiple Processes"
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
@@ -62,25 +62,17 @@ macro(SetGlobalCompilerAndLinkerSettings)
endif(MSVC)
if(MINGW)
if(CMAKE_COMPILER_IS_CLANGXX)
# clang for MSYS doesn't support -mthreads
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols")
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
else()
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12477
# Actually '-Wno-inline-dllimport' should work to suppress warnings of the form:
# inline function 'foo' is declared as dllimport: attribute ignored
# But it doesn't work with MinGW gcc 4.5.0 while using '-Wno-attributes' seems to
# do the trick.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols")
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
# http://stackoverflow.com/questions/8375310/warning-auto-importing-has-been-activated-without-enable-auto-import-specifie
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
link_libraries(-lgdi32)
endif()
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12477
# Actually '-Wno-inline-dllimport' should work to suppress warnings of the form:
# inline function 'foo' is declared as dllimport: attribute ignored
# But it doesn't work with MinGW gcc 4.5.0 while using '-Wno-attributes' seems to
# do the trick.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthreads -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
# http://stackoverflow.com/questions/8375310/warning-auto-importing-has-been-activated-without-enable-auto-import-specifie
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
link_libraries(-lgdi32)
endif(MINGW)
endmacro(SetGlobalCompilerAndLinkerSettings)
+1 -1
View File
@@ -3,7 +3,7 @@ macro(SetupBoost)
set(_boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS})
set (BOOST_COMPONENTS filesystem program_options regex system thread date_time)
set (BOOST_COMPONENTS filesystem program_options regex system thread)
find_package(Boost ${BOOST_MIN_VERSION}
COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
+2 -2
View File
@@ -3,10 +3,10 @@ macro(SetupMatplotlib)
find_package(Matplotlib)
if (MATPLOTLIB_FOUND)
message(STATUS "Found Matplotlib: ${MATPLOTLIB_PATH_DIRS} (found version \"${MATPLOTLIB_VERSION}\")")
message(STATUS "-- matplotlib-${MATPLOTLIB_VERSION} has been found.")
else(MATPLOTLIB_FOUND)
message("=====================================================\n"
"Matplotlib not found, Plot module won't be available.\n"
"matplotlib not found, Plot module won't be available.\n"
"=====================================================\n")
endif(MATPLOTLIB_FOUND)
+1 -1
View File
@@ -1,7 +1,7 @@
macro(SetupOpenCasCade)
# -------------------------------- OpenCasCade --------------------------------
find_package(OCC)
find_package(OpenCasCade)
if(NOT OCC_FOUND)
message(FATAL_ERROR "================================================================\n"
"Neither OpenCASCADE Community Edition nor OpenCASCADE was found!\n"
+30 -43
View File
@@ -1,6 +1,10 @@
macro(SetupPython)
# -------------------------------- Python --------------------------------
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677598
# Acceptable versions of Python
set(Python_ADDITIONAL_VERSIONS "2.7")
# For building on OS X
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT BUILD_WITH_CONDA)
@@ -114,49 +118,32 @@ macro(SetupPython)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT BUILD_WITH_CONDA)
if(${CMAKE_VERSION} VERSION_LESS "3.12")
set(Python_ADDITIONAL_VERSIONS ${Python_ADDITIONAL_VERSIONS} "3.10" "3.9" "3.8" "3.7" "3.6")
find_package(PythonInterp REQUIRED)
set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
if (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs REQUIRED)
else (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
endif(NOT DEFINED PYTHON_VERSION_STRING)
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "=================================\n"
"Python not found, install Python!\n"
"=================================\n")
endif()
# For forward compatibility with new CMake scripts
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARY_DIRS ${PYTHON_LIBRARY_DIRS})
set(Python3_VERSION ${PYTHON_VERSION_STRING})
set(Python3_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR})
set(Python3_VERSION_PATCH ${PYTHON_VERSION_PATCH})
set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND})
else()
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
# For backwards compatibility with old CMake scripts
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
set(PYTHON_LIBRARY_DIRS ${Python3_LIBRARY_DIRS})
set(PYTHON_VERSION_STRING ${Python3_VERSION})
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
set(PYTHON_VERSION_PATCH ${Python3_VERSION_PATCH})
set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND})
endif()
find_package(PythonInterp REQUIRED)
# prevent python3 lower than 3.6
if (${PYTHON_VERSION_STRING} VERSION_LESS "3.6")
message(FATAL_ERROR "To build FreeCAD you need at least Python 3.6\n")
endif()
# Issue in cmake prevents finding pythonlibs 3.x when python 2.7 is present
# setting NOTFOUND here resolves the issue
set(PYTHON_INCLUDE_DIR "NOTFOUND")
set(PYTHON_LIBRARY "NOTFOUND")
set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
if (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs REQUIRED)
else (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
endif(NOT DEFINED PYTHON_VERSION_STRING)
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "=================================\n"
"Python not found, install Python!\n"
"=================================\n")
else(NOT PYTHONLIBS_FOUND)
# prevent python3 lower than 3.3 (not enough utf8<->unicode tools)
if(PYTHON_VERSION_MAJOR EQUAL 3)
if(PYTHON_VERSION_MINOR LESS 4)
message(FATAL_ERROR "To build FreeCAD with Python3, you need at least version 3.4\n")
endif(PYTHON_VERSION_MINOR LESS 4)
endif(PYTHON_VERSION_MAJOR EQUAL 3)
endif(NOT PYTHONLIBS_FOUND)
endmacro(SetupPython)
+113 -34
View File
@@ -1,38 +1,117 @@
# -------------------------------- Qt --------------------------------
find_package(Qt5Core REQUIRED)
set(CMAKE_AUTOMOC TRUE)
# For FreeCAD 0.20, pegged to Ubuntu 18.04 LTS:
if(${Qt5Core_VERSION} VERSION_LESS "5.9")
message (FATAL_ERROR "FreeCAD v0.20 requires Qt5 5.9 or later")
endif()
find_package(Qt5Network REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5XmlPatterns REQUIRED)
find_package(Qt5Concurrent REQUIRED)
if(BUILD_GUI)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5UiTools REQUIRED)
if (BUILD_WEB)
if (${FREECAD_USE_QTWEBMODULE} MATCHES "Qt Webkit")
find_package(Qt5WebKitWidgets REQUIRED)
elseif(${FREECAD_USE_QTWEBMODULE} MATCHES "Qt WebEngine")
find_package(Qt5WebEngineWidgets REQUIRED)
else() # Automatic
find_package(Qt5WebEngineWidgets QUIET)
if(NOT Qt5WebEngineWidgets_FOUND)
find_package(Qt5WebKitWidgets REQUIRED)
endif()
if (NOT BUILD_QT5)
# If using MacPorts, help the Qt4 finder.
if(MACPORTS_PREFIX)
if(NOT QT_QMAKE_EXECUTABLE)
set(QT_QMAKE_EXECUTABLE ${MACPORTS_PREFIX}/libexec/qt4/bin/qmake)
endif()
endif()
if(BUILD_DESIGNER_PLUGIN)
find_package(Qt5Designer REQUIRED)
endif()
if(MSVC)
find_package(Qt5WinExtras QUIET)
endif()
endif(BUILD_GUI)
set(QT_MIN_VERSION 4.5.0)
set(QT_USE_QTNETWORK TRUE)
set(QT_USE_QTXML TRUE)
if(BUILD_GUI)
set(QT_USE_QTOPENGL TRUE)
set(QT_USE_QTSVG TRUE)
set(QT_USE_QTUITOOLS TRUE)
set(QT_USE_QTWEBKIT TRUE)
endif(BUILD_GUI)
find_package(Qt4)# REQUIRED
include(${QT_USE_FILE})
if(NOT QT4_FOUND)
message(FATAL_ERROR "========================\n"
"Qt4 libraries not found.\n"
"========================\n")
endif(NOT QT4_FOUND)
if(NOT QT_QTWEBKIT_FOUND)
message("========================================================\n"
"Qt Webkit not found, will not build browser integration.\n"
"========================================================\n")
endif(NOT QT_QTWEBKIT_FOUND)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
macro(fc_wrap_cpp outfiles)
# get include dirs
QT4_GET_MOC_FLAGS(moc_flags)
QT4_EXTRACT_OPTIONS(moc_files moc_options moc_target ${ARGN})
# fixes bug 0000585: bug with boost 1.48
set(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
set(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
elseif (BUILD_QT5)
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5XmlPatterns REQUIRED)
find_package(Qt5Concurrent REQUIRED)
if(BUILD_GUI)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5UiTools REQUIRED)
if (BUILD_WEB)
if (${FREECAD_USE_QTWEBMODULE} MATCHES "Qt Webkit")
find_package(Qt5WebKitWidgets REQUIRED)
elseif(${FREECAD_USE_QTWEBMODULE} MATCHES "Qt WebEngine")
find_package(Qt5WebEngineWidgets REQUIRED)
if (Qt5WebEngineWidgets_VERSION VERSION_LESS 5.7.0)
message(FATAL_ERROR "** Minimum supported Qt5WebEngine version is 5.7.0!\n")
endif()
else() # Automatic
find_package(Qt5WebKitWidgets QUIET)
if(NOT Qt5WebKitWidgets_FOUND)
find_package(Qt5WebEngineWidgets REQUIRED)
if (Qt5WebEngineWidgets_VERSION VERSION_LESS 5.7.0)
message(FATAL_ERROR "** Minimum supported Qt5WebEngine version is 5.7.0!\n")
endif()
endif()
endif()
endif()
if(MSVC AND ${Qt5Core_VERSION} VERSION_GREATER "5.2.0")
find_package(Qt5WinExtras QUIET)
endif()
endif(BUILD_GUI)
# This is a special version of the built in macro qt5_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
macro(fc_wrap_cpp outfiles )
# get include dirs
qt5_get_moc_flags(moc_flags)
set(moc_files ${ARGN})
# fixes bug 0000585: bug with boost 1.48
set(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
set(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
endif (NOT BUILD_QT5)
+7 -22
View File
@@ -27,24 +27,13 @@ macro(SetupSalomeSMESH)
# check which modules are available
if(UNIX OR WIN32)
find_package(VTK COMPONENTS vtkCommonCore REQUIRED NO_MODULE)
if(${VTK_MAJOR_VERSION} LESS 9)
list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI vtkhdf5 vtkFiltersParallelDIY2 vtkRenderingCore vtkInteractionStyle vtkRenderingFreeType vtkRenderingOpenGL2)
foreach(_module ${VTK_COMPONENTS})
list (FIND VTK_MODULES_ENABLED ${_module} _index)
if(${_index} GREATER -1)
list(APPEND AVAILABLE_VTK_COMPONENTS ${_module})
endif()
endforeach()
else()
set(VTK_COMPONENTS "CommonCore;CommonDataModel;FiltersVerdict;IOXML;FiltersCore;FiltersGeneral;IOLegacy;FiltersExtraction;FiltersSources;FiltersGeometry")
list(APPEND VTK_COMPONENTS "IOMPIParallel;ParallelMPI;hdf5;FiltersParallelDIY2;RenderingCore;InteractionStyle;RenderingFreeType;RenderingOpenGL2")
foreach(_module ${VTK_COMPONENTS})
list (FIND VTK_AVAILABLE_COMPONENTS ${_module} _index)
if(${_index} GREATER -1)
list(APPEND AVAILABLE_VTK_COMPONENTS ${_module})
endif()
endforeach()
endif()
list(APPEND VTK_COMPONENTS vtkIOMPIParallel vtkParallelMPI vtkhdf5 vtkFiltersParallelDIY2 vtkRenderingCore vtkInteractionStyle vtkRenderingFreeType vtkRenderingOpenGL2)
foreach(_module ${VTK_COMPONENTS})
list (FIND VTK_MODULES_ENABLED ${_module} _index)
if (${_index} GREATER -1)
list(APPEND AVAILABLE_VTK_COMPONENTS ${_module})
endif()
endforeach()
endif()
# don't check VERSION 6 as this would exclude VERSION 7
@@ -121,10 +110,6 @@ macro(SetupSalomeSMESH)
find_package(SMESH CONFIG)
set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH})
set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES})
# If this definition is not set, linker errors will occur against SMESH on 64 bit machines.
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DSALOME_USE_64BIT_IDS)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(NOT SMESH_FOUND)
message(ERROR "================\n"
"SMESH not found.\n"
@@ -1,91 +1,140 @@
macro(SetupShibokenAndPyside)
# -------------------------------- Shiboken/PySide ------------------------
if(DEFINED MACPORTS_PREFIX)
find_package(Shiboken REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
find_package(PySide REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
endif(DEFINED MACPORTS_PREFIX)
# Shiboken2Config.cmake may explicitly set CMAKE_BUILD_TYPE to Release which causes
# CMake to fail to create Makefiles for a debug build.
# So as a workaround we save and restore the value after checking for Shiboken2.
set (SAVE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
find_package(Shiboken2 QUIET)# REQUIRED
set (CMAKE_BUILD_TYPE ${SAVE_BUILD_TYPE})
if (Shiboken2_FOUND)
# Shiboken2 config file was found but it may use the wrong Python version
# Try to get the matching config suffix and repeat finding the package
set(SHIBOKEN_PATTERN .cpython-${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake")
if (SHIBOKEN_CONFIG)
get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME)
string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX)
string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX})
message(STATUS "PYTHON_CONFIG_SUFFIX: ${PYTHON_CONFIG_SUFFIX}")
find_package(Shiboken2 QUIET)
if(BUILD_QT5)
# set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
# Below are two variables that can be left empty for standard python 3 version,
# but must be set by the user for different python versions such as 2.7, 3.5 ...
if (PYTHON_VERSION_MAJOR LESS 3)
set(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
set(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
else()
#set(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
#set(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
endif()
endif()
# pyside2 changed its cmake files, this is the dance we have
# to dance to be compatible with the old (<5.12) and the new versions (>=5.12)
if(NOT SHIBOKEN_INCLUDE_DIR AND TARGET Shiboken2::libshiboken)
get_property(SHIBOKEN_INCLUDE_DIR TARGET Shiboken2::libshiboken PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
endif(NOT SHIBOKEN_INCLUDE_DIR AND TARGET Shiboken2::libshiboken)
if(DEFINED MACPORTS_PREFIX)
find_package(Shiboken REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
find_package(PySide REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
endif(DEFINED MACPORTS_PREFIX)
if(NOT SHIBOKEN_INCLUDE_DIR)
message("====================\n"
"shiboken2 not found.\n"
"====================\n")
endif(NOT SHIBOKEN_INCLUDE_DIR)
# Shiboken2Config.cmake may explicitly set CMAKE_BUILD_TYPE to Release which causes
# CMake to fail to create Makefiles for a debug build.
# So as a workaround we save and restore the value after checking for Shiboken2.
set (SAVE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
find_package(Shiboken2 QUIET)# REQUIRED
set (CMAKE_BUILD_TYPE ${SAVE_BUILD_TYPE})
if (Shiboken2_FOUND)
# Shiboken2 config file was found but it may use the wrong Python version
# Try to get the matching config suffix and repeat finding the package
if (PYTHON_VERSION_MAJOR LESS 3)
set(SHIBOKEN_PATTERN -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
else()
set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
endif()
find_package(PySide2 QUIET)# REQUIRED
file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake")
if (SHIBOKEN_CONFIG)
get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME)
string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX)
string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX})
message(STATUS "PYTHON_CONFIG_SUFFIX: ${PYTHON_CONFIG_SUFFIX}")
find_package(Shiboken2 QUIET)
endif()
endif()
if(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide2::pyside2)
get_property(PYSIDE_INCLUDE_DIR TARGET PySide2::pyside2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
endif(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide2::pyside2)
# pyside2 changed its cmake files, this is the dance we have
# to dance to be compatible with the old (<5.12) and the new versions (>=5.12)
if(NOT SHIBOKEN_INCLUDE_DIR AND TARGET Shiboken2::libshiboken)
get_property(SHIBOKEN_INCLUDE_DIR TARGET Shiboken2::libshiboken PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
endif(NOT SHIBOKEN_INCLUDE_DIR AND TARGET Shiboken2::libshiboken)
if(NOT PYSIDE_INCLUDE_DIR)
message("==================\n"
"PySide2 not found.\n"
"==================\n")
endif(NOT PYSIDE_INCLUDE_DIR)
if(NOT SHIBOKEN_INCLUDE_DIR)
message("====================\n"
"shiboken2 not found.\n"
"====================\n")
endif(NOT SHIBOKEN_INCLUDE_DIR)
find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc)
if(NOT PYSIDE2_TOOLS_FOUND)
message("=======================\n"
"PySide2Tools not found.\n"
"=======================\n")
endif(NOT PYSIDE2_TOOLS_FOUND)
find_package(PySide2 QUIET)# REQUIRED
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide)
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n"
"from PySide2 import __version__\n"
"from PySide2 import __version_info__\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n"
"#QCoreApplication.CodecForTr=0\n"
"#QCoreApplication.UnicodeUTF8=1\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n"
"from PySide2.QtWidgets import *\n"
"QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtUiTools.py "from PySide2.QtUiTools import *\n")
if(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide2::pyside2)
get_property(PYSIDE_INCLUDE_DIR TARGET PySide2::pyside2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
endif(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide2::pyside2)
if(APPLE AND NOT BUILD_WITH_CONDA)
install(
DIRECTORY
${CMAKE_BINARY_DIR}/Ext/PySide
DESTINATION
MacOS
)
else()
install(
DIRECTORY
${CMAKE_BINARY_DIR}/Ext/PySide
DESTINATION
Ext
)
endif()
if(NOT PYSIDE_INCLUDE_DIR)
message("==================\n"
"PySide2 not found.\n"
"==================\n")
endif(NOT PYSIDE_INCLUDE_DIR)
find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc)
if(NOT PYSIDE2_TOOLS_FOUND)
message("=======================\n"
"PySide2Tools not found.\n"
"=======================\n")
endif(NOT PYSIDE2_TOOLS_FOUND)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide)
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n"
"from PySide2 import __version__\n"
"from PySide2 import __version_info__\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n"
"#QCoreApplication.CodecForTr=0\n"
"#QCoreApplication.UnicodeUTF8=1\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n"
"from PySide2.QtWidgets import *\n"
"QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n")
file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtUiTools.py "from PySide2.QtUiTools import *\n")
if(APPLE AND NOT BUILD_WITH_CONDA)
install(
DIRECTORY
${CMAKE_BINARY_DIR}/Ext/PySide
DESTINATION
MacOS
)
else()
install(
DIRECTORY
${CMAKE_BINARY_DIR}/Ext/PySide
DESTINATION
Ext
)
endif()
else(BUILD_QT5)
# set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
# Below are two variables that can be left empty for standard python 3 version,
# but must be set by the user for different python versions such as 2.7, 3.5 ...
if (PYTHON_VERSION_MAJOR LESS 3)
set(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
set(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
else()
set(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: <ShibokenConfigPYTHON_CONFIG_SUFFIX.cmake>")
set(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: <PySideConfigPYTHON_BASENAME.cmake>")
endif()
if(DEFINED MACPORTS_PREFIX)
find_package(Shiboken REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
find_package(PySide REQUIRED HINTS "${PYTHON_LIBRARY_DIR}/cmake")
endif(DEFINED MACPORTS_PREFIX)
find_package(Shiboken)# REQUIRED
if(NOT SHIBOKEN_INCLUDE_DIR)
message(FATAL_ERROR "===================\n"
"shiboken not found.\n"
"===================\n")
endif(NOT SHIBOKEN_INCLUDE_DIR)
find_package(PySide)# REQUIRED
if(NOT PYSIDE_INCLUDE_DIR)
message(FATAL_ERROR "=================\n"
"PySide not found.\n"
"=================\n")
endif(NOT PYSIDE_INCLUDE_DIR)
find_package(PySideTools REQUIRED) # PySide utilities (pyside-uic & pyside-rcc)
endif(BUILD_QT5)
# If shiboken cannot be found the build option will be set to OFF
if(SHIBOKEN_INCLUDE_DIR)
@@ -94,11 +143,19 @@ macro(SetupShibokenAndPyside)
option(FREECAD_USE_SHIBOKEN "Links to the shiboken library at build time. If OFF its Python module is imported at runtime" OFF)
# Now try to import the shiboken Python module and print a warning if it can't be loaded
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import shiboken2"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
if(BUILD_QT5)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import shiboken2"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
else()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import shiboken"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
endif()
if(FAILURE)
message("=================================\n"
@@ -115,17 +172,36 @@ macro(SetupShibokenAndPyside)
endif()
# Independent of the build option PySide modules must be loaded at runtime. Print a warning if it fails.
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import PySide2;import os;print(os.path.dirname(PySide2.__file__), end='')"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
if(FAILURE)
message("================================\n"
"PySide2 Python module not found.\n"
"================================\n")
if(BUILD_QT5)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import PySide2;import os;print(os.path.dirname(PySide2.__file__), end='')"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
if(FAILURE)
message("================================\n"
"PySide2 Python module not found.\n"
"================================\n")
else()
message(STATUS "===============================================\n"
"PySide2 Python module found at ${PRINT_OUTPUT}.\n"
"===============================================\n")
endif()
else()
message(STATUS "PySide2 Python module found at ${PRINT_OUTPUT}.\n")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import PySide;import os;print(os.path.dirname(PySide.__file__))"
RESULT_VARIABLE FAILURE
OUTPUT_VARIABLE PRINT_OUTPUT
)
if(FAILURE)
message("===============================\n"
"PySide Python module not found.\n"
"===============================\n")
else()
message(STATUS "==============================================\n"
"PySide Python module found at ${PRINT_OUTPUT}.\n"
"==============================================\n")
endif()
endif()
endmacro(SetupShibokenAndPyside)
+5
View File
@@ -175,6 +175,11 @@ macro(generate_from_any INPUT_FILE OUTPUT_FILE VARIABLE)
endmacro(generate_from_any)
# generates the ui -> cpp h files
#macro(qt4_wrap_ui infiles )
#
#endmacro(qt4_wrap_ui)
MACRO(ADD_MSVC_PRECOMPILED_HEADER TargetName PrecompiledHeader PrecompiledSource SourcesVar)
IF(MSVC)
+536
View File
@@ -0,0 +1,536 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python27.lib debug python27_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/Python-2.7.5)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/Python-2.7.5)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xerces-c-3.1.1)
set(XercesC_LIBRARIES xerces-c_3.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_3D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/boost-1_55)
set(Boost_LIBRARIES
optimized boost_filesystem-vc110-mt-1_55.lib
optimized boost_system-vc110-mt-1_55.lib
optimized boost_graph-vc110-mt-1_55.lib
optimized boost_program_options-vc110-mt-1_55.lib
optimized boost_python-vc110-mt-1_55.lib
optimized boost_regex-vc110-mt-1_55.lib
optimized boost_signals-vc110-mt-1_55.lib
optimized boost_thread-vc110-mt-1_55.lib
debug boost_filesystem-vc110-mt-gd-1_55.lib
debug boost_system-vc110-mt-gd-1_55.lib
debug boost_graph-vc110-mt-gd-1_55.lib
debug boost_program_options-vc110-mt-gd-1_55.lib
debug boost_python-vc110-mt-gd-1_55.lib
debug boost_regex-vc110-mt-gd-1_55.lib
debug boost_signals-vc110-mt-gd-1_55.lib
debug boost_thread-vc110-mt-gd-1_55.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib-1.2.7)
set(ZLIB_LIBRARIES zlib.lib)
set(ZLIB_FOUND TRUE)
# SMESH
#set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
#set(SMESH_LIBRARIES
# StdMeshers.lib
# MEFISTO2.lib
# SMESH.lib
# DriverUNV.lib
# SMESHDS.lib
# DriverSTL.lib
# DriverDAT.lib
# Driver.lib
# SMDS.lib
#)
set(SMESH_FOUND TRUE)
# Coin3D
find_path(COIN3D_INCLUDE_DIRS Inventor/So.h
${FREECAD_LIBPACK_DIR}/include/Coin-4.0.0
)
find_library(COIN3D_LIBRARY_RELEASE coin4
"${FREECAD_LIBPACK_DIR}/lib"
)
find_library(COIN3D_LIBRARY_DEBUG coin4d
"${FREECAD_LIBPACK_DIR}/lib"
)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/Qt
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtCore
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtGui
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtDesigner
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtSvg
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtNetwork
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtSql
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtTest
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtUiTools
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtXml
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/QtCore
)
set(QT_QT3SUPPORT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.6/Qt3Support
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib debug QtXmld4.lib
)
set(QT_QT3SUPPORT_LIBRARY
optimized Qt3Support4.lib debug Qt3Supportd4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/SoQt-1.6.0)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV2_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV2_LIBRARIES
optimized opencv_calib3d249.lib
debug opencv_calib3d249d.lib
optimized opencv_contrib249.lib
debug opencv_contrib249d.lib
optimized opencv_core249.lib
debug opencv_core249d.lib
optimized opencv_features2d249.lib
debug opencv_features2d249d.lib
optimized opencv_flann249.lib
debug opencv_flann249d.lib
optimized opencv_gpu249.lib
debug opencv_gpu249d.lib
optimized opencv_highgui249.lib
debug opencv_highgui249d.lib
optimized opencv_imgproc249.lib
debug opencv_imgproc249d.lib
optimized opencv_legacy249.lib
debug opencv_legacy249d.lib
optimized opencv_ml249.lib
debug opencv_ml249d.lib
optimized opencv_nonfree249.lib
debug opencv_nonfree249d.lib
optimized opencv_objdetect249.lib
debug opencv_objdetect249d.lib
optimized opencv_ocl249.lib
debug opencv_ocl249d.lib
optimized opencv_photo249.lib
debug opencv_photo249d.lib
optimized opencv_stitching249.lib
debug opencv_stitching249d.lib
optimized opencv_superres249.lib
debug opencv_superres249d.lib
optimized opencv_ts249.lib
debug opencv_ts249d.lib
optimized opencv_video249.lib
debug opencv_video249d.lib
optimized opencv_videostab249.lib
debug opencv_videostab249d.lib
)
set(OPENCV2_FOUND TRUE)
# NGLIB (NetGen)
set(NGLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/nglib/include)
set(NGLIB_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(NGLIB_LIBRARIES
optimized nglib
)
set(NGLIB_DEBUG_LIBRARIES
debug nglibd
)
# Pointscloud library
set(PCL_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/pcl-1.7)
set(PCL_LIBRARY_DIRS ${FREECAD_LIBPACK_DIR}/lib)
set(PCL_COMMON_LIBRARIES optimized pcl_common_release debug pcl_common_debug)
set(PCL_FEATURES_LIBRARIES optimized pcl_features_release debug pcl_features_debug)
set(PCL_FILTERS_LIBRARIES optimized pcl_filters_release debug pcl_filters_debug)
set(PCL_IO_LIBRARIES optimized pcl_io_release debug pcl_io_debug)
set(PCL_IO_PLY_LIBRARIES optimized pcl_io_ply_release debug pcl_io_ply_debug)
set(PCL_KDTREE_LIBRARIES optimized pcl_kdtree_release debug pcl_kdtree_debug)
set(PCL_KEYPOINTS_LIBRARIES optimized pcl_keypoints_release debug pcl_keypoints_debug)
set(PCL_ML_LIBRARIES optimized pcl_ml_release debug pcl_ml_debug)
set(PCL_OCTREE_LIBRARIES optimized pcl_octree_release debug pcl_octree_debug)
set(PCL_RECOGNITION_LIBRARIES optimized pcl_recognition_release debug pcl_recognition_debug)
set(PCL_REGISTRATION_LIBRARIES optimized pcl_registration_release debug pcl_registration_debug)
set(PCL_SAMPLE_CONSENSUS_LIBRARIES optimized pcl_sample_consensus_release debug pcl_sample_consensus_debug)
set(PCL_SEARCH_LIBRARIES optimized pcl_search_release debug pcl_search_debug)
set(PCL_SEGMENTATION_LIBRARIES optimized pcl_segmentation_release debug pcl_segmentation_debug)
set(PCL_STEREO_LIBRARIES optimized pcl_stereo_release debug pcl_stereo_debug)
set(PCL_SURFACE_LIBRARIES optimized pcl_surface_release debug pcl_surface_debug)
set(PCL_TRACKING_LIBRARIES optimized pcl_tracking_release debug pcl_tracking_debug)
set(PCL_LIBRARIES
${PCL_COMMON_LIBRARIES}
${PCL_FEATURES_LIBRARIES}
${PCL_FILTERS_LIBRARIES}
${PCL_IO_LIBRARIES}
${PCL_IO_PLY_LIBRARIES}
${PCL_KDTREE_LIBRARIES}
${PCL_KEYPOINTS_LIBRARIES}
${PCL_ML_LIBRARIES}
${PCL_OCTREE_LIBRARIES}
${PCL_RECOGNITION_LIBRARIES}
${PCL_REGISTRATION_LIBRARIES}
${PCL_SAMPLE_CONSENSUS_LIBRARIES}
${PCL_SEARCH_LIBRARIES}
${PCL_SEGMENTATION_LIBRARIES}
${PCL_STEREO_LIBRARIES}
${PCL_SURFACE_LIBRARIES}
${PCL_TRACKING_LIBRARIES}
)
set(PCL_FOUND TRUE)
set(PCL_COMMON_FOUND TRUE)
set(PCL_FEATURES_FOUND TRUE)
set(PCL_FILTERS_FOUND TRUE)
set(PCL_IO_FOUND TRUE)
set(PCL_IO_PLY_FOUND TRUE)
set(PCL_KDTREE_FOUND TRUE)
set(PCL_KEYPOINTS_FOUND TRUE)
set(PCL_ML_FOUND TRUE)
set(PCL_OCTREE_FOUND TRUE)
set(PCL_RECOGNITION_FOUND TRUE)
set(PCL_REGISTRATION_FOUND TRUE)
set(PCL_SAMPLE_CONSENSUS_FOUND TRUE)
set(PCL_SEARCH_FOUND TRUE)
set(PCL_SEGMENTATION_FOUND TRUE)
set(PCL_STEREO_FOUND TRUE)
set(PCL_SURFACE_FOUND TRUE)
set(PCL_TRACKING_FOUND TRUE)
set(FLANN_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/flann-1.8)
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/oce-0.15)
set(OCC_LIBRARY_DIR ${FREECAD_LIBPACK_DIR}/lib)
set(OCC_LIBRARIES
optimized TKFillet
optimized TKMesh
optimized TKernel
optimized TKG2d
optimized TKG3d
optimized TKMath
optimized TKIGES
optimized TKSTL
optimized TKShHealing
optimized TKXSBase
optimized TKBin
optimized TKBool
optimized TKBO
optimized TKBRep
optimized TKTopAlgo
optimized TKGeomAlgo
optimized TKGeomBase
optimized TKOffset
optimized TKPrim
optimized TKSTEP
optimized TKSTEPBase
optimized TKSTEPAttr
optimized TKHLR
optimized TKFeat
)
set(OCC_DEBUG_LIBRARIES
debug TKFilletd
debug TKMeshd
debug TKerneld
debug TKG2dd
debug TKG3dd
debug TKMathd
debug TKIGESd
debug TKSTLd
debug TKShHealingd
debug TKXSBased
debug TKBind
debug TKBoold
debug TKBOd
debug TKBRepd
debug TKTopAlgod
debug TKGeomAlgod
debug TKGeomBased
debug TKOffsetd
debug TKPrimd
debug TKSTEPd
debug TKSTEPBased
debug TKSTEPAttrd
debug TKHLRd
debug TKFeatd
)
set(OCC_OCAF_LIBRARIES
optimized TKCAF
optimized TKXCAF
optimized TKLCAF
optimized TKXDESTEP
optimized TKXDEIGES
optimized TKMeshVS
optimized TKAdvTools
)
set(OCC_OCAF_DEBUG_LIBRARIES
debug TKCAFd
debug TKXCAFd
debug TKLCAFd
debug TKXDESTEPd
debug TKXDEIGESd
debug TKMeshVSd
debug TKAdvToolsd
)
set(OCC_FOUND TRUE)
set(EIGEN3_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/eigen3)
set(EIGEN3_FOUND TRUE)
# FreeType
if(FREECAD_USE_FREETYPE)
set(FREETYPE_LIBRARIES
optimized ${FREECAD_LIBPACK_DIR}/lib/freetype.lib
debug ${FREECAD_LIBPACK_DIR}/lib/freetyped.lib
)
set(FREETYPE_INCLUDE_DIRS
${FREECAD_LIBPACK_DIR}/include/FreeType-2.4.12
)
set(FREETYPE_VERSION_STRING
"2.4.12"
)
set(FREETYPE_FOUND
TRUE
)
endif(FREECAD_USE_FREETYPE)
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
SET(SHIBOKEN_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/shiboken-1.2.2)
SET(SHIBOKEN_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7_d.lib)
set(SHIBOKEN_BINARY ${FREECAD_LIBPACK_DIR}/bin/shiboken)
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide
# PYSIDE_LIBRARY - Files to link against to use PySide
# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide
SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide-1.2.2)
SET(PYSIDE_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7_d.lib)
SET(PYSIDE_PYTHONPATH ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
+328
View File
@@ -0,0 +1,328 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python25.lib debug python25_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xercesc)
set(XercesC_LIBRARIES xerces-c_2.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_2D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/boost)
set(Boost_LIBRARIES
optimized boost_filesystem-vc80-mt.lib
#optimized boost_graph-vc80-mt.lib
optimized boost_program_options-vc80-mt.lib
optimized boost_python-vc80-mt.lib
optimized boost_regex-vc80-mt.lib
optimized boost_signals-vc80-mt.lib
debug boost_filesystem-vc80-mt-gd.lib
#debug boost_graph-vc80-mt-gd.lib
debug boost_program_options-vc80-mt-gd.lib
debug boost_python-vc80-mt-gd.lib
debug boost_regex-vc80-mt-gd.lib
debug boost_signals-vc80-mt-gd.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib)
set(ZLIB_LIBRARIES zlib1.lib)
set(ZLIB_FOUND TRUE)
# SMESH
set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
set(SMESH_LIBRARIES
StdMeshers.lib
MEFISTO2.lib
SMESH.lib
DriverUNV.lib
SMESHDS.lib
DriverSTL.lib
DriverDAT.lib
Driver.lib
SMDS.lib
)
set(SMESH_FOUND TRUE)
# Coin3D
set(COIN3D_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/coin)
set(COIN3D_LIBRARY_DEBUG coin2d.lib)
set(COIN3D_LIBRARY_RELEASE coin2.lib)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/Qt
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
${FREECAD_LIBPACK_DIR}/include/QT/QtGui
${FREECAD_LIBPACK_DIR}/include/QT/QtDesigner
${FREECAD_LIBPACK_DIR}/include/QT/QtSvg
${FREECAD_LIBPACK_DIR}/include/QT/QtNetwork
${FREECAD_LIBPACK_DIR}/include/QT/QtSql
${FREECAD_LIBPACK_DIR}/include/QT/QtTest
${FREECAD_LIBPACK_DIR}/include/QT/QtUiTools
${FREECAD_LIBPACK_DIR}/include/QT/QtXml
${FREECAD_LIBPACK_DIR}/include/QT/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/QT/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/QT/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib
debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib
debug QtXmld4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib
debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib
optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/soqt)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBin
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
)
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)
+346
View File
@@ -0,0 +1,346 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python26.lib debug python26_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xercesc)
set(XercesC_LIBRARIES xerces-c_2.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_2D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/boost)
set(Boost_LIBRARIES
optimized boost_filesystem-vc90-mt-1_39.lib
optimized boost_system-vc90-mt-1_39.lib
optimized boost_graph-vc90-mt-1_39.lib
optimized boost_program_options-vc90-mt-1_39.lib
optimized boost_python-vc90-mt-1_39.lib
optimized boost_regex-vc90-mt-1_39.lib
optimized boost_signals-vc90-mt-1_39.lib
optimized boost_thread-vc90-mt-1_39.lib
debug boost_filesystem-vc90-mt-gd-1_39.lib
debug boost_date_time-vc90-mt-gd-1_39.lib
debug boost_filesystem-vc90-mt-gd-1_39.lib
debug boost_iostreams-vc90-mt-gd-1_39.lib
debug boost_math_c99f-vc90-mt-gd-1_39.lib
debug boost_math_tr1f-vc90-mt-gd-1_39.lib
debug boost_thread-vc90-mt-gd-1_39.lib
debug boost_system-vc90-mt-gd-1_39.lib
debug boost_graph-vc90-mt-gd-1_39.lib
debug boost_program_options-vc90-mt-gd-1_39.lib
debug boost_python-vc90-mt-gd-1_39.lib
debug boost_regex-vc90-mt-gd-1_39.lib
debug boost_signals-vc90-mt-gd-1_39.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib)
set(ZLIB_LIBRARIES zdll.lib)
set(ZLIB_FOUND TRUE)
# SMESH
set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
set(SMESH_LIBRARIES
StdMeshers.lib
MEFISTO2.lib
SMESH.lib
DriverUNV.lib
SMESHDS.lib
DriverSTL.lib
DriverDAT.lib
Driver.lib
SMDS.lib
)
set(SMESH_FOUND TRUE)
# Coin3D
set(COIN3D_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/coin)
set(COIN3D_LIBRARY_DEBUG coin3d.lib)
set(COIN3D_LIBRARY_RELEASE coin3.lib)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/Qt
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
${FREECAD_LIBPACK_DIR}/include/QT/QtGui
${FREECAD_LIBPACK_DIR}/include/QT/QtDesigner
${FREECAD_LIBPACK_DIR}/include/QT/QtSvg
${FREECAD_LIBPACK_DIR}/include/QT/QtNetwork
${FREECAD_LIBPACK_DIR}/include/QT/QtSql
${FREECAD_LIBPACK_DIR}/include/QT/QtTest
${FREECAD_LIBPACK_DIR}/include/QT/QtUiTools
${FREECAD_LIBPACK_DIR}/include/QT/QtXml
${FREECAD_LIBPACK_DIR}/include/QT/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/QT/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/QT/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib
debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib
debug QtXmld4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib
debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib
optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/soqt)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBin
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
)
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
set(OCC_FOUND TRUE)
SET(EIGEN3_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/eigen3)
set(EIGEN3_FOUND TRUE)
+444
View File
@@ -0,0 +1,444 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python26.lib debug python26_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/python)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xercesc)
set(XercesC_LIBRARIES xerces-c_2.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_2D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/boost)
set(Boost_LIBRARIES
optimized boost_filesystem-vc90-mt-1_48.lib
optimized boost_system-vc90-mt-1_48.lib
optimized boost_graph-vc90-mt-1_48.lib
optimized boost_program_options-vc90-mt-1_48.lib
optimized boost_python-vc90-mt-1_48.lib
optimized boost_regex-vc90-mt-1_48.lib
optimized boost_signals-vc90-mt-1_48.lib
optimized boost_thread-vc90-mt-1_48.lib
debug boost_filesystem-vc90-mt-gd-1_48.lib
debug boost_date_time-vc90-mt-gd-1_48.lib
debug boost_filesystem-vc90-mt-gd-1_48.lib
debug boost_iostreams-vc90-mt-gd-1_48.lib
debug boost_math_c99f-vc90-mt-gd-1_48.lib
debug boost_math_tr1f-vc90-mt-gd-1_48.lib
debug boost_thread-vc90-mt-gd-1_48.lib
debug boost_system-vc90-mt-gd-1_48.lib
debug boost_graph-vc90-mt-gd-1_48.lib
debug boost_program_options-vc90-mt-gd-1_48.lib
debug boost_python-vc90-mt-gd-1_48.lib
debug boost_regex-vc90-mt-gd-1_48.lib
debug boost_signals-vc90-mt-gd-1_48.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib)
set(ZLIB_LIBRARIES zdll.lib)
set(ZLIB_FOUND TRUE)
# SMESH
#set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
#set(SMESH_LIBRARIES
# optimized StdMeshers.lib
# optimized MEFISTO2.lib
# optimized SMESH.lib
# optimized DriverUNV.lib
# optimized SMESHDS.lib
# optimized NETGENPlugin.lib
# optimized DriverSTL.lib
# optimized DriverDAT.lib
# optimized Driver.lib
# optimized SMDS.lib
#)
#set(SMESH_DEBUG_LIBRARIES
# debug StdMeshersd.lib
# debug MEFISTO2d.lib
# debug SMESHd.lib
# debug DriverUNVd.lib
# debug SMESHDSd.lib
# debug NETGENPlugind.lib
# debug DriverSTLd.lib
# debug DriverDATd.lib
# debug Driverd.lib
# debug SMDSd.lib
#)
#set(SMESH_FOUND TRUE)
# Coin3D
set(COIN3D_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/coin)
set(COIN3D_LIBRARY_DEBUG coin3d.lib)
set(COIN3D_LIBRARY_RELEASE coin3.lib)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/Qt
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
${FREECAD_LIBPACK_DIR}/include/QT/QtGui
${FREECAD_LIBPACK_DIR}/include/QT/QtDesigner
${FREECAD_LIBPACK_DIR}/include/QT/QtSvg
${FREECAD_LIBPACK_DIR}/include/QT/QtNetwork
${FREECAD_LIBPACK_DIR}/include/QT/QtSql
${FREECAD_LIBPACK_DIR}/include/QT/QtTest
${FREECAD_LIBPACK_DIR}/include/QT/QtUiTools
${FREECAD_LIBPACK_DIR}/include/QT/QtXml
${FREECAD_LIBPACK_DIR}/include/QT/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/QT/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/QT/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/QT/
${FREECAD_LIBPACK_DIR}/include/QT/QtCore
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib
debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib
debug QtXmld4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib
debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib
optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
if(FREECAD_LIBPACK_USEPYSIDE)
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
SET(SHIBOKEN_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/shiboken)
SET(SHIBOKEN_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6_d.lib)
set(SHIBOKEN_BINARY ${FREECAD_LIBPACK_DIR}/bin/shiboken)
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide
# PYSIDE_LIBRARY - Files to link against to use PySide
# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide
SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide)
SET(PYSIDE_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6_d.lib)
#SET(PYSIDE_PYTHONPATH ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
#SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
endif(FREECAD_LIBPACK_USEPYSIDE)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/soqt)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# NGLIB (NetGen)
set(NGLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/nglib/Include)
set(NGLIB_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(NGLIB_LIBRARIES
optimized nglib
)
set(NGLIB_DEBUG_LIBRARIES
debug nglibd
)
# OCC
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade)
set(OCC_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(OCC_LIBRARIES
optimized TKFillet
optimized TKMesh
optimized TKernel
optimized TKG2d
optimized TKG3d
optimized TKMath
optimized TKIGES
optimized TKSTL
optimized TKShHealing
optimized TKXSBase
optimized TKBin
optimized TKBool
optimized TKXSBase
optimized TKBO
optimized TKBRep
optimized TKTopAlgo
optimized TKGeomAlgo
optimized TKGeomBase
optimized TKOffset
optimized TKPrim
optimized TKSTEP
optimized TKSTEPBase
optimized TKSTEPAttr
optimized TKHLR
optimized TKFeat
)
set(OCC_OCAF_LIBRARIES
optimized TKCAF
optimized TKXCAF
optimized TKLCAF
optimized TKXDESTEP
optimized TKXDEIGES
optimized TKMeshVS
optimized TKAdvTools
)
set(OCC_DEBUG_LIBRARIES
debug TKFilletd
debug TKMeshd
debug TKerneld
debug TKG2dd
debug TKG3dd
debug TKMathd
debug TKIGESd
debug TKSTLd
debug TKShHealingd
debug TKXSBased
debug TKBind
debug TKBoold
debug TKXSBased
debug TKBOd
debug TKBRepd
debug TKTopAlgod
debug TKGeomAlgod
debug TKGeomBased
debug TKOffsetd
debug TKPrimd
debug TKSTEPd
debug TKSTEPBased
debug TKSTEPAttrd
debug TKHLRd
debug TKFeatd
)
set(OCC_OCAF_DEBUG_LIBRARIES
debug TKCAFd
debug TKXCAFd
debug TKLCAFd
debug TKXDESTEPd
debug TKXDEIGESd
debug TKMeshVSd
debug TKAdvToolsd
)
set(OCC_FOUND TRUE)
SET(EIGEN3_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/eigen3)
set(EIGEN3_FOUND TRUE)
# FreeType
if(FREECAD_USE_FREETYPE)
set(FREETYPE_LIBRARIES
optimized ${FREECAD_LIBPACK_DIR}/lib/freetype.lib
debug ${FREECAD_LIBPACK_DIR}/lib/freetyped.lib
)
set(FREETYPE_INCLUDE_DIRS
${FREECAD_LIBPACK_DIR}/include/FreeType-2.4.12
)
set(FREETYPE_VERSION_STRING
"2.4.12"
)
set(FREETYPE_FOUND
TRUE
)
endif(FREECAD_USE_FREETYPE)
+530
View File
@@ -0,0 +1,530 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python27.lib debug python27_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/Python-2.7.6)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/Python-2.7.6)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xerces-c-3.1.0)
set(XercesC_LIBRARIES xerces-c_3.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_3D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/boost-1_54)
set(Boost_LIBRARIES
optimized boost_filesystem-vc90-mt-1_54.lib
optimized boost_system-vc90-mt-1_54.lib
optimized boost_graph-vc90-mt-1_54.lib
optimized boost_program_options-vc90-mt-1_54.lib
optimized boost_python-vc90-mt-1_54.lib
optimized boost_regex-vc90-mt-1_54.lib
optimized boost_signals-vc90-mt-1_54.lib
optimized boost_thread-vc90-mt-1_54.lib
debug boost_filesystem-vc90-mt-gd-1_54.lib
debug boost_system-vc90-mt-gd-1_54.lib
debug boost_graph-vc90-mt-gd-1_54.lib
debug boost_program_options-vc90-mt-gd-1_54.lib
debug boost_python-vc90-mt-gd-1_54.lib
debug boost_regex-vc90-mt-gd-1_54.lib
debug boost_signals-vc90-mt-gd-1_54.lib
debug boost_thread-vc90-mt-gd-1_54.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib-1.2.3)
set(ZLIB_LIBRARIES zdll.lib)
set(ZLIB_FOUND TRUE)
# SMESH
set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
set(SMESH_LIBRARIES
StdMeshers.lib
MEFISTO2.lib
SMESH.lib
DriverUNV.lib
SMESHDS.lib
DriverSTL.lib
DriverDAT.lib
Driver.lib
SMDS.lib
)
set(SMESH_FOUND TRUE)
# Coin3D
find_path(COIN3D_INCLUDE_DIRS Inventor/So.h
${FREECAD_LIBPACK_DIR}/include/Coin-4.0.0
)
find_library(COIN3D_LIBRARY_RELEASE coin4
"${FREECAD_LIBPACK_DIR}/lib"
)
find_library(COIN3D_LIBRARY_DEBUG coin4d
"${FREECAD_LIBPACK_DIR}/lib"
)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/Qt
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtCore
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtGui
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtDesigner
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtSvg
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtNetwork
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtSql
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtTest
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtUiTools
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtXml
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtCore
)
set(QT_QTXML_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/QtXml
)
set(QT_QT3SUPPORT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.8.5/Qt3Support
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib
debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib
debug QtXmld4.lib
)
set(QT_QT3SUPPORT_LIBRARY
optimized Qt3Support4.lib
debug Qt3Supportd4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib
debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib
optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/SoQt-1.6.0)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# NGLIB (NetGen)
set(NGLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/nglib/include)
set(NGLIB_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(NGLIB_LIBRARIES
optimized nglib
)
set(NGLIB_DEBUG_LIBRARIES
debug nglibd
)
# OCC
#set(OCC_INCLUDE_DIR C:/Projects/LibPack/oce-0.10.0/include/oce)
#set(OCC_LIBRARY_DIR C:/Projects/LibPack/oce-0.10.0/Win64/lib)
#set(OCC_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKFillet.lib
# ${OCC_LIBRARY_DIR}/TKMesh.lib
# ${OCC_LIBRARY_DIR}/TKernel.lib
# ${OCC_LIBRARY_DIR}/TKG2d.lib
# ${OCC_LIBRARY_DIR}/TKG3d.lib
# ${OCC_LIBRARY_DIR}/TKMath.lib
# ${OCC_LIBRARY_DIR}/TKIGES.lib
# ${OCC_LIBRARY_DIR}/TKSTL.lib
# ${OCC_LIBRARY_DIR}/TKShHealing.lib
# ${OCC_LIBRARY_DIR}/TKXSBase.lib
# ${OCC_LIBRARY_DIR}/TKBool.lib
# ${OCC_LIBRARY_DIR}/TKBO.lib
# ${OCC_LIBRARY_DIR}/TKBRep.lib
# ${OCC_LIBRARY_DIR}/TKTopAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomBase.lib
# ${OCC_LIBRARY_DIR}/TKOffset.lib
# ${OCC_LIBRARY_DIR}/TKPrim.lib
# ${OCC_LIBRARY_DIR}/TKSTEP.lib
# ${OCC_LIBRARY_DIR}/TKSTEPBase.lib
# ${OCC_LIBRARY_DIR}/TKSTEPAttr.lib
# ${OCC_LIBRARY_DIR}/TKHLR.lib
# ${OCC_LIBRARY_DIR}/TKFeat.lib
#)
#set(OCC_OCAF_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKCAF.lib
# ${OCC_LIBRARY_DIR}/TKXCAF.lib
# ${OCC_LIBRARY_DIR}/TKLCAF.lib
# ${OCC_LIBRARY_DIR}/TKXDESTEP.lib
# ${OCC_LIBRARY_DIR}/TKXDEIGES.lib
#)
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/oce-0.13)
set(OCC_LIBRARY_DIR ${FREECAD_LIBPACK_DIR}/lib)
set(OCC_LIBRARIES
optimized TKFillet
optimized TKMesh
optimized TKernel
optimized TKG2d
optimized TKG3d
optimized TKMath
optimized TKIGES
optimized TKSTL
optimized TKShHealing
optimized TKXSBase
optimized TKBin
optimized TKBool
optimized TKBO
optimized TKBRep
optimized TKTopAlgo
optimized TKGeomAlgo
optimized TKGeomBase
optimized TKOffset
optimized TKPrim
optimized TKSTEP
optimized TKSTEPBase
optimized TKSTEPAttr
optimized TKHLR
optimized TKFeat
)
set(OCC_DEBUG_LIBRARIES
debug TKFilletd
debug TKMeshd
debug TKerneld
debug TKG2dd
debug TKG3dd
debug TKMathd
debug TKIGESd
debug TKSTLd
debug TKShHealingd
debug TKXSBased
debug TKBind
debug TKBoold
debug TKBOd
debug TKBRepd
debug TKTopAlgod
debug TKGeomAlgod
debug TKGeomBased
debug TKOffsetd
debug TKPrimd
debug TKSTEPd
debug TKSTEPBased
debug TKSTEPAttrd
debug TKHLRd
debug TKFeatd
)
set(OCC_OCAF_LIBRARIES
optimized TKCAF
optimized TKXCAF
optimized TKLCAF
optimized TKXDESTEP
optimized TKXDEIGES
optimized TKMeshVS
optimized TKAdvTools
)
set(OCC_OCAF_DEBUG_LIBRARIES
debug TKCAFd
debug TKXCAFd
debug TKLCAFd
debug TKXDESTEPd
debug TKXDEIGESd
debug TKMeshVSd
debug TKAdvToolsd
)
set(OCC_FOUND TRUE)
set(EIGEN3_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/eigen3)
set(EIGEN3_FOUND TRUE)
# FreeType
if(FREECAD_USE_FREETYPE)
set(FREETYPE_LIBRARIES
optimized ${FREECAD_LIBPACK_DIR}/lib/freetype.lib
debug ${FREECAD_LIBPACK_DIR}/lib/freetyped.lib
)
set(FREETYPE_INCLUDE_DIRS
${FREECAD_LIBPACK_DIR}/include/FreeType-2.4.12
)
set(FREETYPE_VERSION_STRING
"2.4.12"
)
set(FREETYPE_FOUND
TRUE
)
endif(FREECAD_USE_FREETYPE)
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
SET(SHIBOKEN_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/shiboken-1.2.1)
SET(SHIBOKEN_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.7_d.lib)
set(SHIBOKEN_BINARY ${FREECAD_LIBPACK_DIR}/bin/shiboken)
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide
# PYSIDE_LIBRARY - Files to link against to use PySide
# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide
SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide-1.2.1)
SET(PYSIDE_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.7_d.lib)
SET(PYSIDE_PYTHONPATH ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
SET(PYSIDE_BIN_DIR ${FREECAD_LIBPACK_DIR}/pyside-tools/bin)
# Pointscloud library
set(PCL_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/pcl-1.6)
set(PCL_LIBRARY_DIRS ${FREECAD_LIBPACK_DIR}/lib)
set(PCL_COMMON_LIBRARIES optimized pcl_common_release debug pcl_common_debug)
set(PCL_FEATURES_LIBRARIES optimized pcl_features_release debug pcl_features_debug)
set(PCL_FILTERS_LIBRARIES optimized pcl_filters_release debug pcl_filters_debug)
set(PCL_IO_LIBRARIES optimized pcl_io_release debug pcl_io_debug)
set(PCL_IO_PLY_LIBRARIES optimized pcl_io_ply_release debug pcl_io_ply_debug)
set(PCL_KDTREE_LIBRARIES optimized pcl_kdtree_release debug pcl_kdtree_debug)
set(PCL_KEYPOINTS_LIBRARIES optimized pcl_keypoints_release debug pcl_keypoints_debug)
set(PCL_OCTREE_LIBRARIES optimized pcl_octree_release debug pcl_octree_debug)
set(PCL_REGISTRATION_LIBRARIES optimized pcl_registration_release debug pcl_registration_debug)
set(PCL_SAMPLE_CONSENSUS_LIBRARIES optimized pcl_sample_consensus_release debug pcl_sample_consensus_debug)
set(PCL_SEARCH_LIBRARIES optimized pcl_search_release debug pcl_search_debug)
set(PCL_SEGMENTATION_LIBRARIES optimized pcl_segmentation_release debug pcl_segmentation_debug)
set(PCL_SURFACE_LIBRARIES optimized pcl_surface_release debug pcl_surface_debug)
set(PCL_TRACKING_LIBRARIES optimized pcl_tracking_release debug pcl_tracking_debug)
set(PCL_LIBRARIES
${PCL_COMMON_LIBRARIES}
${PCL_FEATURES_LIBRARIES}
${PCL_FILTERS_LIBRARIES}
${PCL_IO_LIBRARIES}
${PCL_IO_PLY_LIBRARIES}
${PCL_KDTREE_LIBRARIES}
${PCL_KEYPOINTS_LIBRARIES}
${PCL_OCTREE_LIBRARIES}
${PCL_REGISTRATION_LIBRARIES}
${PCL_SAMPLE_CONSENSUS_LIBRARIES}
${PCL_SEARCH_LIBRARIES}
${PCL_SEGMENTATION_LIBRARIES}
${PCL_SURFACE_LIBRARIES}
${PCL_TRACKING_LIBRARIES}
)
set(PCL_FOUND TRUE)
set(PCL_COMMON_FOUND TRUE)
set(PCL_FEATURES_FOUND TRUE)
set(PCL_FILTERS_FOUND TRUE)
set(PCL_IO_FOUND TRUE)
set(PCL_IO_PLY_FOUND TRUE)
set(PCL_KDTREE_FOUND TRUE)
set(PCL_KEYPOINTS_FOUND TRUE)
set(PCL_OCTREE_FOUND TRUE)
set(PCL_REGISTRATION_FOUND TRUE)
set(PCL_SAMPLE_CONSENSUS_FOUND TRUE)
set(PCL_SEARCH_FOUND TRUE)
set(PCL_SEGMENTATION_FOUND TRUE)
set(PCL_SURFACE_FOUND TRUE)
set(PCL_TRACKING_FOUND TRUE)
set(FLANN_LIBRARIES optimized flann debug flann)
set(FLANN_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/flann-1.7.1)
+9
View File
@@ -7,7 +7,14 @@ set(OCE_DIR ${FREECAD_LIBPACK_DIR}/lib/cmake CACHE PATH "" FORCE)
set(SWIG_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/swig/swig.exe CACHE FILEPATH "Swig" FORCE)
#set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe CACHE FILEPATH "" FORCE)
#set(PYTHON_LIBRARY ${FREECAD_LIBPACK_DIR}/lib/python27.lib CACHE FILEPATH "" FORCE)
#set(PYTHON_DEBUG_LIBRARY ${FREECAD_LIBPACK_DIR}/lib/python27_d.lib CACHE FILEPATH "" FORCE)
#set(PYTHON_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/python2.7 CACHE PATH "" FORCE)
if (BUILD_QT5)
# default Qt5 stuff
# Set paths to cmake config files for each Qt module
set(Qt5_ROOT_DIR ${FREECAD_LIBPACK_DIR} CACHE PATH "")
@@ -41,6 +48,8 @@ set (Qt5Widgets_DIR ${Qt5_ROOT_DIR}/lib/cmake/Qt5Widgets CACHE PATH "")
set (Qt5Xml_DIR ${Qt5_ROOT_DIR}/lib/cmake/Qt5Xml CACHE PATH "")
set (Qt5XmlPatterns_DIR ${Qt5_ROOT_DIR}/lib/cmake/Qt5XmlPatterns CACHE PATH "")
endif (BUILD_QT5)
find_library(XercesC_LIBRARY_RELEASE xerces-c_3 "${FREECAD_LIBPACK_DIR}/lib")
find_library(XercesC_LIBRARY_DEBUG xerces-c_3D "${FREECAD_LIBPACK_DIR}/lib")
set (XercesC_LIBRARIES debug ${XercesC_LIBRARY_DEBUG} optimized ${XercesC_LIBRARY_RELEASE})
+426
View File
@@ -0,0 +1,426 @@
# ================================================================================
# == Win32 is default behaviour use the LibPack copied in Source tree ============
# --------------------------------------------------------------------------------
# General includes
link_directories(${FREECAD_LIBPACK_DIR}/lib)
include_directories(${FREECAD_LIBPACK_DIR}/include)
# OpenGL
set(OPENGL_gl_LIBRARY opengl32 glu32)
# Python
set(PYTHON_LIBRARIES optimized python26.lib debug python26_d.lib)
set(PYTHON_INCLUDE_PATH ${FREECAD_LIBPACK_DIR}/include/Python-2.6.4)
set(PYTHON_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/Python-2.6.4)
set(PYTHON_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/python.exe)
set(PYTHONLIBS_FOUND TRUE)
# XercesC
set(XercesC_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/xerces-c-3.1.0)
set(XercesC_LIBRARIES xerces-c_3.lib)
set(XercesC_DEBUG_LIBRARIES xerces-c_3D.lib)
set(XercesC_FOUND TRUE)
# Boost
set(Boost_INCLUDE_DIRS ${FREECAD_LIBPACK_DIR}/include/boost-1_41)
set(Boost_LIBRARIES
optimized boost_filesystem-vc90-mt-1_41.lib
optimized boost_system-vc90-mt-1_41.lib
optimized boost_graph-vc90-mt-1_41.lib
optimized boost_program_options-vc90-mt-1_41.lib
optimized boost_python-vc90-mt-1_41.lib
optimized boost_regex-vc90-mt-1_41.lib
optimized boost_signals-vc90-mt-1_41.lib
optimized boost_thread-vc90-mt-1_41.lib
debug boost_filesystem-vc90-mt-gd-1_41.lib
debug boost_system-vc90-mt-gd-1_41.lib
debug boost_graph-vc90-mt-gd-1_41.lib
debug boost_program_options-vc90-mt-gd-1_41.lib
debug boost_python-vc90-mt-gd-1_41.lib
debug boost_regex-vc90-mt-gd-1_41.lib
debug boost_signals-vc90-mt-gd-1_41.lib
debug boost_thread-vc90-mt-gd-1_41.lib
)
set(Boost_FOUND TRUE)
# Zlib
set(ZLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/zlib-1.2.3)
set(ZLIB_LIBRARIES zdll.lib)
set(ZLIB_FOUND TRUE)
# SMESH
set(SMESH_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/smesh)
set(SMESH_LIBRARIES
StdMeshers.lib
MEFISTO2.lib
SMESH.lib
DriverUNV.lib
SMESHDS.lib
DriverSTL.lib
DriverDAT.lib
Driver.lib
SMDS.lib
)
set(SMESH_FOUND TRUE)
# Coin3D
find_path(COIN3D_INCLUDE_DIRS Inventor/So.h
${FREECAD_LIBPACK_DIR}/include/Coin-2.4.5
)
find_path(COIN3D_INCLUDE_DIRS Inventor/So.h
${FREECAD_LIBPACK_DIR}/include/Coin-3.1.3
)
find_library(COIN3D_LIBRARY_RELEASE coin2
"${FREECAD_LIBPACK_DIR}/lib"
)
find_library(COIN3D_LIBRARY_DEBUG coin2d
"${FREECAD_LIBPACK_DIR}/lib"
)
find_library(COIN3D_LIBRARY_RELEASE coin3
"${FREECAD_LIBPACK_DIR}/lib"
)
find_library(COIN3D_LIBRARY_DEBUG coin3d
"${FREECAD_LIBPACK_DIR}/lib"
)
set(COIN3D_LIBRARIES optimized ${COIN3D_LIBRARY_RELEASE}
debug ${COIN3D_LIBRARY_DEBUG})
set(COIN3D_FOUND TRUE)
# QT
set(QT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/Qt
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtCore
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtGui
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtDesigner
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtSvg
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtNetwork
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtSql
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtTest
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtUiTools
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtXml
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtXmlPatterns
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtOpenGl
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtWebKit
)
set(QT_QTCORE_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/QtCore
)
set(QT_QT3SUPPORT_INCLUDE_DIR
${FREECAD_LIBPACK_DIR}/include/Qt-4.5.3/Qt3Support
)
set(QT_LIBRARIES
optimized QtCore4.lib
optimized QtGui4.lib
optimized QtDesigner4.lib
optimized QtSvg4.lib
optimized QtNetwork4.lib
optimized QtSql4.lib
optimized QtTest4.lib
optimized QtXml4.lib
optimized QtXmlPatterns4.lib
optimized QtOpenGl4.lib
optimized QtWebKit4.lib
debug QtCored4.lib
debug QtGuid4.lib
debug QtDesignerd4.lib
debug QtSvgd4.lib
debug QtNetworkd4.lib
debug QtSqld4.lib
debug QtTestd4.lib
debug QtXmld4.lib
debug QtXmlPatternsd4.lib
debug QtOpenGld4.lib
debug QtWebKitd4.lib
)
set(QT_QTCORE_LIBRARY
optimized QtCore4.lib
debug QtCored4.lib
)
set(QT_QTXML_LIBRARY
optimized QtXml4.lib
debug QtXmld4.lib
)
set(QT_QT3SUPPORT_LIBRARY
optimized Qt3Support4.lib
debug Qt3Supportd4.lib
)
set(QT_QTUITOOLS_LIBRARY
optimized QtUiTools.lib
debug QtUiToolsd.lib
)
set(QT_QTMAIN_LIBRARY
debug qtmaind.lib
optimized qtmain.lib
)
set(QT_UIC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/uic.exe)
set(QT_MOC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/moc.exe)
set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
SET(${_qt4_options})
#SET(_QT4_DOING_OPTIONS FALSE)
FOREACH(_currentArg ${ARGN})
# IF ("${_currentArg}" STREQUAL "OPTIONS")
# SET(_QT4_DOING_OPTIONS TRUE)
# ELSE ("${_currentArg}" STREQUAL "OPTIONS")
# IF(_QT4_DOING_OPTIONS)
# LIST(APPEND ${_qt4_options} "${_currentArg}")
# ELSE(_QT4_DOING_OPTIONS)
LIST(APPEND ${_qt4_files} "${_currentArg}")
# ENDIF(_QT4_DOING_OPTIONS)
# ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
ENDFOREACH(_currentArg)
ENDMACRO (QT4_EXTRACT_OPTIONS)
# macro used to create the names of output files preserving relative dirs
MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
STRING(LENGTH ${infile} _infileLength)
SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
IF(_infileLength GREATER _binlength)
STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
ELSE(_infileLength GREATER _binlength)
FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
ENDIF(_infileLength GREATER _binlength)
SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
STRING(REPLACE ".." "__" _outfile ${_outfile})
GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
FILE(MAKE_DIRECTORY ${outpath})
SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
ENDMACRO (QT4_MAKE_OUTPUT_FILE )
MACRO (QT4_WRAP_CPP outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
endforeach(it)
ENDMACRO (QT4_WRAP_CPP)
# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
# It adds a reverse dependency to solve this
# This has the unfortunate side effect that some files are always rebuilt
# There is probably a cleaner solution than this
include(AddFileDependencies)
macro(fc_wrap_cpp outfiles )
QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
# fixes bug 0000585: bug with boost 1.48
SET(moc_options ${moc_options} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
SET(ARGN)
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cpp outfile)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_options} ${it} -o ${outfile}
MAIN_DEPENDENCY ${it}
)
SET(${outfiles} ${${outfiles}} ${outfile})
add_file_dependencies(${it} ${outfile})
endforeach(it)
endmacro(fc_wrap_cpp)
MACRO (QT4_ADD_RESOURCES outfiles )
QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
SET(ARGN)
FOREACH (it ${rcc_files})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
FILE(READ "${infile}" _RC_FILE_CONTENTS)
STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
SET(_RC_DEPENDS)
FOREACH(_RC_FILE ${_RC_FILES})
STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
IF(NOT _ABS_PATH_INDICATOR)
SET(_RC_FILE "${rc_path}/${_RC_FILE}")
ENDIF(NOT _ABS_PATH_INDICATOR)
SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
ENDFOREACH(_RC_FILE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO (QT4_WRAP_UI outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
set(QT4_FOUND TRUE)
# SoQt
set(SOQT_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/SoQt-1.4.1)
set(SOQT_LIBRARY_RELEASE soqt1.lib)
set(SOQT_LIBRARY_DEBUG soqt1d.lib)
set(SOQT_FOUND TRUE)
# OpenCV
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
set(OPENCV_FOUND TRUE)
# NGLIB (NetGen)
set(NGLIB_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/nglib/include)
set(NGLIB_LIBRARY_DIR
${FREECAD_LIBPACK_DIR}/lib
)
set(NGLIB_LIBRARIES
optimized nglib
)
set(NGLIB_DEBUG_LIBRARIES
debug nglibd
)
# OCC
#set(OCC_INCLUDE_DIR C:/Projects/LibPack/oce-0.10.0/include/oce)
#set(OCC_LIBRARY_DIR C:/Projects/LibPack/oce-0.10.0/Win64/lib)
#set(OCC_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKFillet.lib
# ${OCC_LIBRARY_DIR}/TKMesh.lib
# ${OCC_LIBRARY_DIR}/TKernel.lib
# ${OCC_LIBRARY_DIR}/TKG2d.lib
# ${OCC_LIBRARY_DIR}/TKG3d.lib
# ${OCC_LIBRARY_DIR}/TKMath.lib
# ${OCC_LIBRARY_DIR}/TKIGES.lib
# ${OCC_LIBRARY_DIR}/TKSTL.lib
# ${OCC_LIBRARY_DIR}/TKShHealing.lib
# ${OCC_LIBRARY_DIR}/TKXSBase.lib
# ${OCC_LIBRARY_DIR}/TKBool.lib
# ${OCC_LIBRARY_DIR}/TKBO.lib
# ${OCC_LIBRARY_DIR}/TKBRep.lib
# ${OCC_LIBRARY_DIR}/TKTopAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomAlgo.lib
# ${OCC_LIBRARY_DIR}/TKGeomBase.lib
# ${OCC_LIBRARY_DIR}/TKOffset.lib
# ${OCC_LIBRARY_DIR}/TKPrim.lib
# ${OCC_LIBRARY_DIR}/TKSTEP.lib
# ${OCC_LIBRARY_DIR}/TKSTEPBase.lib
# ${OCC_LIBRARY_DIR}/TKSTEPAttr.lib
# ${OCC_LIBRARY_DIR}/TKHLR.lib
# ${OCC_LIBRARY_DIR}/TKFeat.lib
#)
#set(OCC_OCAF_LIBRARIES
# ${OCC_LIBRARY_DIR}/TKCAF.lib
# ${OCC_LIBRARY_DIR}/TKXCAF.lib
# ${OCC_LIBRARY_DIR}/TKLCAF.lib
# ${OCC_LIBRARY_DIR}/TKXDESTEP.lib
# ${OCC_LIBRARY_DIR}/TKXDEIGES.lib
#)
set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade-6.3.0)
set(OCC_LIBRARY_DIR ${FREECAD_LIBPACK_DIR}/lib)
set(OCC_LIBRARIES
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBin
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
)
set(OCC_OCAF_LIBRARIES
TKCAF
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
TKMeshVS
TKAdvTools
)
set(OCC_FOUND TRUE)
set(EIGEN3_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/eigen3)
set(EIGEN3_FOUND TRUE)
# FreeType
if(FREECAD_USE_FREETYPE)
set(FREETYPE_LIBRARIES
optimized ${FREECAD_LIBPACK_DIR}/lib/freetype.lib
debug ${FREECAD_LIBPACK_DIR}/lib/freetyped.lib
)
set(FREETYPE_INCLUDE_DIRS
${FREECAD_LIBPACK_DIR}/include/FreeType-2.4.12
)
set(FREETYPE_VERSION_STRING
"2.4.12"
)
set(FREETYPE_FOUND
TRUE
)
endif(FREECAD_USE_FREETYPE)
-43
View File
@@ -1,43 +0,0 @@
# gitlab CI config file
# this image is on dockerhub. Dockerfile is here: https://gitlab.com/PrzemoF/FreeCAD/-/blob/gitlab-v1/ci/Dockerfile
image: freecadci/runner
stages: # List of stages for jobs, and their order of execution
- build
- test
before_script:
- apt-get update -yqq
# CCache Config
- mkdir -p ccache
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/ccache
cache:
paths:
- ccache/
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- mkdir build
- cd build
- ccache cmake ../
- ccache cmake --build ./ -j$(nproc)
- echo "Compile complete."
artifacts:
paths:
- build/
test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... "
- cd build/bin/
# Testing currently doesn't work due to problems with libraries ot being visible by the binary.
- ./FreeCADCmd -t 0
-118
View File
@@ -1,118 +0,0 @@
FROM ubuntu:20.04
MAINTAINER Przemo Firszt
# This is the docker image definition used to build FreeCAD. It's currently accessible on:
# https://hub.docker.com/repository/docker/freecadci/runner
# on under name freecadci/runner when using docker
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get update -y && apt-get install -y gnupg2
RUN echo "deb http://ppa.launchpad.net/freecad-maintainers/freecad-daily/ubuntu focal main" >> /etc/apt/sources.list.d/freecad-daily.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 83193AA3B52FF6FCF10A1BBF005EAE8119BB5BCA
RUN apt-get update -y
# those 3 are for debugging purposes only. Not required to build FreeCAD
RUN apt-get install -y \
vim \
nano \
bash
# Main set of FreeCAD dependencies. To be verified.
RUN apt-get install -y \
ccache \
cmake \
debhelper \
dh-exec \
dh-python \
doxygen \
git \
graphviz \
libboost-date-time-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-filesystem1.71-dev \
libboost-graph-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-program-options1.71-dev \
libboost-python1.71-dev \
libboost-regex-dev \
libboost-regex1.71-dev \
libboost-serialization-dev \
libboost-system1.71-dev \
libboost-thread-dev \
libboost-thread1.71-dev \
libboost1.71-dev \
libcoin-dev \
libdouble-conversion-dev \
libeigen3-dev \
libglew-dev \
libgts-bin \
libgts-dev \
libkdtree++-dev \
liblz4-dev \
libmedc-dev \
libmetis-dev \
libnglib-dev \
libocct-data-exchange-dev \
libocct-ocaf-dev \
libocct-visualization-dev \
libopencv-dev \
libproj-dev \
libpyside2-dev \
libqt5opengl5 \
libqt5opengl5-dev \
libqt5svg5-dev \
libqt5webkit5 \
libqt5webkit5-dev \
libqt5x11extras5-dev \
libqt5xmlpatterns5-dev \
libshiboken2-dev \
libspnav-dev \
libvtk7-dev \
libvtk7.1p \
libvtk7.1p-qt \
libx11-dev \
libxerces-c-dev \
libzipios++-dev \
lsb-release \
nastran \
netgen \
netgen-headers \
occt-draw \
pybind11-dev \
pyqt5-dev-tools \
pyside2-tools \
python3-dev \
python3-matplotlib \
python3-pivy \
python3-ply \
python3-pyqt5 \
python3-pyside2.* \
python3-pyside2.qtcore \
python3-pyside2.qtgui \
python3-pyside2.qtsvg \
python3-pyside2.qtuitools \
python3-pyside2.qtwidgets \
python3-pyside2.qtxml \
python3-requests \
python3-yaml \
qt5-default \
qt5-qmake \
qtbase5-dev \
qttools5-dev \
qtwebengine5-dev \
swig
RUN apt-get update -y --fix-missing
# Clean
RUN apt-get clean \
&& rm /var/lib/apt/lists/* \
/usr/share/doc/* \
/usr/share/locale/* \
/usr/share/man/* \
/usr/share/info/* -fR
+2
View File
@@ -35,6 +35,8 @@ cmake -G "Ninja" ^
-D SMESH_INCLUDE_DIR:FILEPATH=%LIBRARY_PREFIX%/include/smesh ^
-D FREECAD_USE_EXTERNAL_SMESH:BOOL=ON ^
-D BUILD_FLAT_MESH:BOOL=ON ^
-D BUILD_PLOT:BOOL=OFF ^
-D BUILD_SHIP:BOOL=OFF ^
-D OCCT_CMAKE_FALLBACK:BOOL=ON ^
-D PYTHON_EXECUTABLE:FILEPATH=%PREFIX%/python ^
-D BUILD_DYNAMIC_LINK_PYTHON:BOOL=ON ^
+3 -1
View File
@@ -31,7 +31,7 @@ if [[ ${HOST} =~ "Darwin" ]]; then
# install space-mouse
if [ ! -d "/Library/Frameworks/3DconnexionClient.framework" ]; then
echo "Installing 3D connexion spacemouse drivers."
echo "Installing 3D connexion space mouse drivers."
curl -o /tmp/3dFW.dmg -L 'https://download.3dconnexion.com/drivers/mac/10-6-6_360DF97D-ED08-4ccf-A55E-0BF905E58476/3DxWareMac_v10-6-6_r3234.dmg'
hdiutil attach -readonly /tmp/3dFW.dmg
sudo installer -package /Volumes/3Dconnexion\ Software/Install\ 3Dconnexion\ software.pkg -target /
@@ -62,6 +62,8 @@ cmake \
-D BUILD_WITH_CONDA:BOOL=ON \
-D PYTHON_EXECUTABLE:FILEPATH=$PREFIX/bin/python \
-D BUILD_FEM_NETGEN:BOOL=ON \
-D BUILD_PLOT:BOOL=OFF \
-D BUILD_SHIP:BOOL=OFF \
-D OCCT_CMAKE_FALLBACK:BOOL=OFF \
-D FREECAD_USE_QT_DIALOG:BOOL=ON \
-D BUILD_DYNAMIC_LINK_PYTHON:BOOL=OFF \
-3
View File
@@ -114,9 +114,6 @@
/* Define to 1 if you have the <values.h> header file. */
#cmakedefine HAVE_VALUES_H
/* Define to 1 if you have a C runtime with backtrace symbols. */
#cmakedefine HAVE_BACKTRACE_SYMBOLS
/* Name of package */
#define PACKAGE "FreeCAD"
Binary file not shown.
Binary file not shown.
-5
View File
@@ -12,17 +12,12 @@ path_classifiers:
- "src/CXX/"
template:
- "src/Tools/examplePy2wiki.py"
- "src/Tools/wiki2qhelp.py"
- "src/Mode/TemplatePyMod/"
unmaintained:
- "src/Mod/Robot/"
- "src/Mod/Ship/"
legacy:
- "src/Mod/Assembly/"
- "src/Mod/Drawing/"
- "src/Mod/Raytracing/"
- "src/Mod/Spreadsheet/App/Spreadsheet_legacy.py"
- "src/Mod/OpenSCAD/prototype.py"
extraction:
javascript:
+4 -7
View File
@@ -7,7 +7,7 @@
# Maintainers: keep this list of plugins up to date
# List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here
%global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libE57Format libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator
%global plugins Drawing Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator
# Some configuration options for other environments
# rpmbuild --with=bundled_zipios: use bundled version of zipios++
@@ -31,8 +31,8 @@
Name: %{name}
Epoch: 1
Version: 0.20
Release: pre_{{{git_commit_no}}}%{?dist}
Version: 0.19
Release: pre_{{{ git_commit_no }}}
Summary: A general purpose 3D CAD modeler
Group: Applications/Engineering
@@ -50,9 +50,7 @@ BuildRequires: git
# Development Libraries
BuildRequires: Coin4-devel
%if 0%{?fedora} < 35
BuildRequires: Inventor-devel
%endif
BuildRequires: opencascade-devel
BuildRequires: boost-devel
BuildRequires: boost-python3-devel
@@ -329,7 +327,6 @@ fi
%{_metainfodir}/*
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/bin/
%{_libdir}/%{name}/include/E57Format/E57Export.h
%{_libdir}/%{name}/%{_lib}/
%{_libdir}/%{name}/Mod/
%{_libdir}/%{name}/Ext/
@@ -341,4 +338,4 @@ fi
%files data
%{_datadir}/%{name}/
%{_docdir}/%{name}/LICENSE.html
%{_docdir}/%{name}/%{name}.q*
-1
View File
@@ -1,3 +1,2 @@
[rpkg]
auto_pack = False
user_macros = "${git_props:root}/rpkg.macros"
+1 -1
View File
@@ -1,4 +1,4 @@
function git_commit_no {
commits=$(curl -s 'https://api.github.com/repos/FreeCAD/FreeCAD/compare/120ca87015...master' | grep "ahead_by" | sed -s 's/ //g' | sed -s 's/"ahead_by"://' | sed -s 's/,//')
echo -n $((commits + 1))
echo $((commits + 1))
}
+2 -1
View File
@@ -1,4 +1,5 @@
matplotlib==3.0.2
matplotlib==2.2.3; python_version < '3.0'
matplotlib==3.0.2; python_version >= '3.0'
PySide==1.2.4
# PySide2==5.12.0
Shiboken==1.2.2
+1
View File
@@ -1,5 +1,6 @@
ANN export-ignore
atlas export-ignore
CxImage export-ignore
CoinBinding.sln export-ignore
boost.CMakeLists.txt export-ignore
zlib.CMakeLists.txt export-ignore
+1 -2
View File
@@ -3,5 +3,4 @@ if (BUILD_SMESH AND NOT FREECAD_USE_EXTERNAL_SMESH)
add_subdirectory(salomesmesh)
endif()
add_subdirectory(lazy_loader)
add_subdirectory(libE57Format)
add_subdirectory(lazy_loader)
+364
View File
@@ -0,0 +1,364 @@
# Microsoft Developer Studio Project File - Name="CxImage" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=CxImage - Win32 Unicode Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "cximage.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "cximage.mak" CFG="CxImage - Win32 Unicode Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "CxImage - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "CxImage - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "CxImage - Win32 Unicode Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "CxImage - Win32 Unicode Release" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "CxImage - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "_DEBUG" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "_CRT_SECURE_NO_DEPRECATE" /FD /GZ /c
# SUBTRACT CPP /Fr /YX
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "CxImage - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "_CRT_SECURE_NO_DEPRECATE" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "CxImage - Win32 Unicode Debug"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "CxImage___Win32_Unicode_Debug"
# PROP BASE Intermediate_Dir "CxImage___Win32_Unicode_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Unicode_Debug"
# PROP Intermediate_Dir "Unicode_Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_AFXDLL" /D "JAS_WIN_MSVC_BUILD" /FD /GZ /c
# SUBTRACT BASE CPP /Fr /YX
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NON_CONFORMING_SWPRINTFS" /FD /GZ /c
# SUBTRACT CPP /Fr /YX
# ADD BASE RSC /l 0x410 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "CxImage - Win32 Unicode Release"
# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "CxImage___Win32_Unicode_Release"
# PROP BASE Intermediate_Dir "CxImage___Win32_Unicode_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Unicode_Release"
# PROP Intermediate_Dir "Unicode_Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_AFXDLL" /D "JAS_WIN_MSVC_BUILD" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "WIN32" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NON_CONFORMING_SWPRINTFS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x410 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "CxImage - Win32 Debug"
# Name "CxImage - Win32 Release"
# Name "CxImage - Win32 Unicode Debug"
# Name "CxImage - Win32 Unicode Release"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\tif_xfile.cpp
# End Source File
# Begin Source File
SOURCE=.\ximabmp.cpp
# End Source File
# Begin Source File
SOURCE=.\ximadsp.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaenc.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaexif.cpp
# End Source File
# Begin Source File
SOURCE=.\xImage.cpp
# End Source File
# Begin Source File
SOURCE=.\ximagif.cpp
# End Source File
# Begin Source File
SOURCE=.\ximahist.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaico.cpp
# End Source File
# Begin Source File
SOURCE=.\ximainfo.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaint.cpp
# End Source File
# Begin Source File
SOURCE=.\ximajas.cpp
# End Source File
# Begin Source File
SOURCE=.\ximajbg.cpp
# End Source File
# Begin Source File
SOURCE=.\ximajpg.cpp
# End Source File
# Begin Source File
SOURCE=.\ximalpha.cpp
# End Source File
# Begin Source File
SOURCE=.\ximalyr.cpp
# End Source File
# Begin Source File
SOURCE=.\ximamng.cpp
# End Source File
# Begin Source File
SOURCE=.\ximapal.cpp
# End Source File
# Begin Source File
SOURCE=.\ximapcx.cpp
# End Source File
# Begin Source File
SOURCE=.\ximapng.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaraw.cpp
# End Source File
# Begin Source File
SOURCE=.\ximasel.cpp
# End Source File
# Begin Source File
SOURCE=.\ximaska.cpp
# End Source File
# Begin Source File
SOURCE=.\ximatga.cpp
# End Source File
# Begin Source File
SOURCE=.\ximath.cpp
# End Source File
# Begin Source File
SOURCE=.\ximatif.cpp
# End Source File
# Begin Source File
SOURCE=.\ximatran.cpp
# End Source File
# Begin Source File
SOURCE=.\ximawbmp.cpp
# End Source File
# Begin Source File
SOURCE=.\ximawmf.cpp
# End Source File
# Begin Source File
SOURCE=.\ximawnd.cpp
# End Source File
# Begin Source File
SOURCE=.\xmemfile.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\xfile.h
# End Source File
# Begin Source File
SOURCE=.\ximabmp.h
# End Source File
# Begin Source File
SOURCE=.\ximacfg.h
# End Source File
# Begin Source File
SOURCE=.\ximadef.h
# End Source File
# Begin Source File
SOURCE=.\ximage.h
# End Source File
# Begin Source File
SOURCE=.\ximagif.h
# End Source File
# Begin Source File
SOURCE=.\ximaico.h
# End Source File
# Begin Source File
SOURCE=.\ximaiter.h
# End Source File
# Begin Source File
SOURCE=.\ximajas.h
# End Source File
# Begin Source File
SOURCE=.\ximajbg.h
# End Source File
# Begin Source File
SOURCE=.\ximajpg.h
# End Source File
# Begin Source File
SOURCE=.\ximamng.h
# End Source File
# Begin Source File
SOURCE=.\ximapcx.h
# End Source File
# Begin Source File
SOURCE=.\ximapng.h
# End Source File
# Begin Source File
SOURCE=.\ximaraw.h
# End Source File
# Begin Source File
SOURCE=.\ximaska.h
# End Source File
# Begin Source File
SOURCE=.\ximatga.h
# End Source File
# Begin Source File
SOURCE=.\ximath.h
# End Source File
# Begin Source File
SOURCE=.\ximatif.h
# End Source File
# Begin Source File
SOURCE=.\ximawbmp.h
# End Source File
# Begin Source File
SOURCE=.\ximawmf.h
# End Source File
# Begin Source File
SOURCE=.\xiofile.h
# End Source File
# Begin Source File
SOURCE=.\xmemfile.h
# End Source File
# End Group
# End Target
# End Project
+29
View File
@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "CxImage"=.\CxImage.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
File diff suppressed because it is too large Load Diff
+48
View File
@@ -0,0 +1,48 @@
This copy of the CxImage notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file ximage.h that is
included in the CxImage distribution, the latter shall prevail.
If you modify CxImage you may insert additional notices immediately following
this sentence.
--------------------------------------------------------------------------------
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
CxImage version 6.0.0 02/Feb/2008
CxImage : Copyright (C) 2001 - 2008, Davide Pizzolato
Original CImage and CImageIterator implementation are:
Copyright (C) 1995, Alejandro Aguilar Sierra (asierra(at)servidor(dot)unam(dot)mx)
Covered code is provided under this license on an "as is" basis, without warranty
of any kind, either expressed or implied, including, without limitation, warranties
that the covered code is free of defects, merchantable, fit for a particular purpose
or non-infringing. The entire risk as to the quality and performance of the covered
code is with you. Should any covered code prove defective in any respect, you (not
the initial developer or any other contributor) assume the cost of any necessary
servicing, repair or correction. This disclaimer of warranty constitutes an essential
part of this license. No use of any covered code is authorized hereunder except under
this disclaimer.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, including commercial applications,
freely and without fee, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
Other information: about CxImage, and the latest version, can be found at the
CxImage home page: http://www.xdp.it
--------------------------------------------------------------------------------
+218
View File
@@ -0,0 +1,218 @@
/*
* TIFF file IO, using CxFile.
*/
#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include "ximage.h"
#if CXIMAGE_SUPPORT_TIF
#include "../tiff/tiffiop.h"
#include "xfile.h"
static tsize_t
_tiffReadProcEx(thandle_t fd, tdata_t buf, tsize_t size)
{
return (tsize_t)((CxFile*)fd)->Read(buf, 1, size);
}
static tsize_t
_tiffWriteProcEx(thandle_t fd, tdata_t buf, tsize_t size)
{
return (tsize_t)((CxFile*)fd)->Write(buf, 1, size);
}
static toff_t
_tiffSeekProcEx(thandle_t fd, toff_t off, int whence)
{
if ( off == 0xFFFFFFFF )
return 0xFFFFFFFF;
if (!((CxFile*)fd)->Seek(off, whence))
return 0xFFFFFFFF;
if (whence == SEEK_SET)
return off;
return (toff_t)((CxFile*)fd)->Tell();
}
// Return nonzero if error
static int
_tiffCloseProcEx(thandle_t /*fd*/)
{
// return !((CxFile*)fd)->Close(); // "//" needed for memory files <DP>
return 0;
}
#include <sys/stat.h>
static toff_t
_tiffSizeProcEx(thandle_t fd)
{
return ((CxFile*)fd)->Size();
}
static int
_tiffMapProcEx(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/)
{
return (0);
}
static void
_tiffUnmapProcEx(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/)
{
}
// Open a TIFF file descriptor for read/writing.
/*
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
FILE* stream = fopen(name, mode);
if (stream == NULL)
{
TIFFError(module, "%s: Cannot open", name);
return NULL;
}
return (TIFFFdOpen((int)stream, name, mode));
}
*/
TIFF*
_TIFFFdOpen(void* fd, const char* name, const char* mode)
{
TIFF* tif;
tif = TIFFClientOpen(name, mode,
(thandle_t) fd,
_tiffReadProcEx, _tiffWriteProcEx, _tiffSeekProcEx, _tiffCloseProcEx,
_tiffSizeProcEx, _tiffMapProcEx, _tiffUnmapProcEx);
if (tif)
tif->tif_fd = fd;
return (tif);
}
extern "C" TIFF* _TIFFOpenEx(CxFile* stream, const char* mode)
{
return (_TIFFFdOpen(stream, "TIFF IMAGE", mode));
}
#ifdef __GNUC__
extern char* malloc();
extern char* realloc();
#else
#include <malloc.h>
#endif
tdata_t
_TIFFmalloc(tsize_t s)
{
return (malloc((size_t) s));
}
void
_TIFFfree(tdata_t p)
{
free(p);
}
tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
return (realloc(p, (size_t) s));
}
void
_TIFFmemset(tdata_t p, int v, tsize_t c)
{
memset(p, v, (size_t) c);
}
void
_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
{
memcpy(d, s, (size_t) c);
}
int
_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
{
return (memcmp(p1, p2, (size_t) c));
}
#ifndef UNICODE
#define DbgPrint wvsprintf
#define DbgPrint2 wsprintf
#define DbgMsgBox MessageBox
#else
#define DbgPrint wvsprintfA
#define DbgPrint2 wsprintfA
#define DbgMsgBox MessageBoxA
#endif
static void
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
{
#ifdef _DEBUG
#if (!defined(_CONSOLE) && !defined(_WIN32_WCE) && defined(WIN32))
LPSTR szTitle;
LPSTR szTmp;
LPCSTR szTitleText = "%s Warning";
LPCSTR szDefaultModule = "TIFFLIB";
szTmp = (module == NULL) ? (LPSTR)szDefaultModule : (LPSTR)module;
if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmp) +
strlen(szTitleText) + strlen(fmt) + 128))) == NULL)
return;
DbgPrint2(szTitle, szTitleText, szTmp);
szTmp = szTitle + (strlen(szTitle)+2);
DbgPrint(szTmp, fmt, ap);
DbgMsgBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
LocalFree(szTitle);
return;
#else
if (module != NULL)
fprintf(stderr, "%s: ", module);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
#endif
#endif
}
TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;
static void
Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
{
#ifdef _DEBUG
#if (!defined(_CONSOLE) && !defined(_WIN32_WCE) && defined(WIN32))
LPSTR szTitle;
LPSTR szTmp;
LPCSTR szTitleText = "%s Error";
LPCSTR szDefaultModule = "TIFFLIB";
szTmp = (module == NULL) ? (LPSTR)szDefaultModule : (LPSTR)module;
if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmp) +
strlen(szTitleText) + strlen(fmt) + 128))) == NULL)
return;
DbgPrint2(szTitle, szTitleText, szTmp);
szTmp = szTitle + (strlen(szTitle)+2);
DbgPrint(szTmp, fmt, ap);
DbgMsgBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
LocalFree(szTitle);
return;
#else
if (module != NULL)
fprintf(stderr, "%s: ", module);
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
#endif
#endif
}
TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;
#endif
+79
View File
@@ -0,0 +1,79 @@
/*
* File: xfile.h
* Purpose: General Purpose File Class
*/
/*
--------------------------------------------------------------------------------
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
CxFile (c) 11/May/2002 Davide Pizzolato - www.xdp.it
CxFile version 2.00 23/Aug/2002
CxFile version 2.10 16/Dec/2007
Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes
Covered code is provided under this license on an "as is" basis, without warranty
of any kind, either expressed or implied, including, without limitation, warranties
that the covered code is free of defects, merchantable, fit for a particular purpose
or non-infringing. The entire risk as to the quality and performance of the covered
code is with you. Should any covered code prove defective in any respect, you (not
the initial developer or any other contributor) assume the cost of any necessary
servicing, repair or correction. This disclaimer of warranty constitutes an essential
part of this license. No use of any covered code is authorized hereunder except under
this disclaimer.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, including commercial applications,
freely and without fee, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
*/
#if !defined(__xfile_h)
#define __xfile_h
#if defined (WIN32) || defined (_WIN32_WCE)
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "ximadef.h"
class DLL_EXP CxFile
{
public:
CxFile(void) { };
virtual ~CxFile() { };
virtual bool Close() = 0;
virtual size_t Read(void *buffer, size_t size, size_t count) = 0;
virtual size_t Write(const void *buffer, size_t size, size_t count) = 0;
virtual bool Seek(long offset, int origin) = 0;
virtual long Tell() = 0;
virtual long Size() = 0;
virtual bool Flush() = 0;
virtual bool Eof() = 0;
virtual long Error() = 0;
virtual bool PutC(unsigned char c)
{
// Default implementation
size_t nWrote = Write(&c, 1, 1);
return (bool)(nWrote == 1);
}
virtual long GetC() = 0;
virtual char * GetS(char *string, int n) = 0;
virtual long Scanf(const char *format, void* output) = 0;
};
#endif //__xfile_h
+444
View File
@@ -0,0 +1,444 @@
/*
* File: ximabmp.cpp
* Purpose: Platform Independent BMP Image Class Loader and Writer
* 07/Aug/2001 Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximabmp.h"
#if CXIMAGE_SUPPORT_BMP
#include "ximaiter.h"
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageBMP::Encode(CxFile * hFile)
{
if (EncodeSafeCheck(hFile)) return false;
BITMAPFILEHEADER hdr;
hdr.bfType = 0x4d42; // 'BM' WINDOWS_BITMAP_SIGNATURE
hdr.bfSize = GetSize() + 14 /*sizeof(BITMAPFILEHEADER)*/;
hdr.bfReserved1 = hdr.bfReserved2 = 0;
hdr.bfOffBits = 14 /*sizeof(BITMAPFILEHEADER)*/ + head.biSize + GetPaletteSize();
hdr.bfType = ntohs(hdr.bfType);
hdr.bfSize = ntohl(hdr.bfSize);
hdr.bfOffBits = ntohl(hdr.bfOffBits);
#if CXIMAGE_SUPPORT_ALPHA
if (GetNumColors()==0 && AlphaIsValid()){
BITMAPINFOHEADER infohdr;
memcpy(&infohdr,&head,sizeof(BITMAPINFOHEADER));
infohdr.biCompression = BI_RGB;
infohdr.biBitCount = 32;
DWORD dwEffWidth = ((((infohdr.biBitCount * infohdr.biWidth) + 31) / 32) * 4);
infohdr.biSizeImage = dwEffWidth * infohdr.biHeight;
hdr.bfSize = infohdr.biSize + infohdr.biSizeImage + 14 /*sizeof(BITMAPFILEHEADER)*/;
hdr.bfSize = ntohl(hdr.bfSize);
bihtoh(&infohdr);
// Write the file header
hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
hFile->Write(&infohdr,sizeof(BITMAPINFOHEADER),1);
//and DIB+ALPHA interlaced
BYTE *srcalpha = AlphaGetPointer();
for(long y = 0; y < infohdr.biHeight; ++y){
BYTE *srcdib = GetBits(y);
for(long x = 0; x < infohdr.biWidth; ++x){
hFile->Write(srcdib,3,1);
hFile->Write(srcalpha,1,1);
srcdib += 3;
++srcalpha;
}
}
} else
#endif //CXIMAGE_SUPPORT_ALPHA
{
// Write the file header
hFile->Write(&hdr,min(14,sizeof(BITMAPFILEHEADER)),1);
//copy attributes
memcpy(pDib,&head,sizeof(BITMAPINFOHEADER));
bihtoh((BITMAPINFOHEADER*)pDib);
// Write the DIB header and the pixels
hFile->Write(pDib,GetSize(),1);
bihtoh((BITMAPINFOHEADER*)pDib);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageBMP::Decode(CxFile * hFile)
{
if (hFile == NULL) return false;
BITMAPFILEHEADER bf;
DWORD off = hFile->Tell(); //<CSC>
cx_try {
if (hFile->Read(&bf,min(14,sizeof(bf)),1)==0) cx_throw("Not a BMP");
bf.bfSize = ntohl(bf.bfSize);
bf.bfOffBits = ntohl(bf.bfOffBits);
if (bf.bfType != BFT_BITMAP) { //do we have a RC HEADER?
bf.bfOffBits = 0L;
hFile->Seek(off,SEEK_SET);
}
BITMAPINFOHEADER bmpHeader;
if (!DibReadBitmapInfo(hFile,&bmpHeader)) cx_throw("Error reading BMP info");
DWORD dwCompression=bmpHeader.biCompression;
DWORD dwBitCount=bmpHeader.biBitCount; //preserve for BI_BITFIELDS compression <Thomas Ernst>
bool bIsOldBmp = bmpHeader.biSize == sizeof(BITMAPCOREHEADER);
bool bTopDownDib = bmpHeader.biHeight<0; //<Flanders> check if it's a top-down bitmap
if (bTopDownDib) bmpHeader.biHeight=-bmpHeader.biHeight;
if (info.nEscape == -1) {
// Return output dimensions only
head.biWidth = bmpHeader.biWidth;
head.biHeight = bmpHeader.biHeight;
info.dwType = CXIMAGE_FORMAT_BMP;
cx_throw("output dimensions returned");
}
if (!Create(bmpHeader.biWidth,bmpHeader.biHeight,bmpHeader.biBitCount,CXIMAGE_FORMAT_BMP))
cx_throw("");
SetXDPI((long) floor(bmpHeader.biXPelsPerMeter * 254.0 / 10000.0 + 0.5));
SetYDPI((long) floor(bmpHeader.biYPelsPerMeter * 254.0 / 10000.0 + 0.5));
if (info.nEscape) cx_throw("Cancelled"); // <vho> - cancel decoding
RGBQUAD *pRgb = GetPalette();
if (pRgb){
if (bIsOldBmp){
// convert a old color table (3 byte entries) to a new
// color table (4 byte entries)
hFile->Read((void*)pRgb,DibNumColors(&bmpHeader) * sizeof(RGBTRIPLE),1);
for (int i=DibNumColors(&head)-1; i>=0; i--){
pRgb[i].rgbRed = ((RGBTRIPLE *)pRgb)[i].rgbtRed;
pRgb[i].rgbBlue = ((RGBTRIPLE *)pRgb)[i].rgbtBlue;
pRgb[i].rgbGreen = ((RGBTRIPLE *)pRgb)[i].rgbtGreen;
pRgb[i].rgbReserved = (BYTE)0;
}
} else {
hFile->Read((void*)pRgb,DibNumColors(&bmpHeader) * sizeof(RGBQUAD),1);
//force rgbReserved=0, to avoid problems with some WinXp bitmaps
for (unsigned int i=0; i<head.biClrUsed; i++) pRgb[i].rgbReserved=0;
}
}
if (info.nEscape) cx_throw("Cancelled"); // <vho> - cancel decoding
switch (dwBitCount) {
case 32 :
DWORD bfmask[3];
if (dwCompression == BI_BITFIELDS)
{
hFile->Read(bfmask, 12, 1);
} else {
bfmask[0]=0x00FF0000;
bfmask[1]=0x0000FF00;
bfmask[2]=0x000000FF;
}
if (bf.bfOffBits != 0L) hFile->Seek(off + bf.bfOffBits,SEEK_SET);
if (dwCompression == BI_BITFIELDS || dwCompression == BI_RGB){
long imagesize=4*head.biHeight*head.biWidth;
BYTE* buff32=(BYTE*)malloc(imagesize);
if (buff32){
hFile->Read(buff32, imagesize,1); // read in the pixels
#if CXIMAGE_SUPPORT_ALPHA
if (dwCompression == BI_RGB){
AlphaCreate();
if (AlphaIsValid()){
bool bAlphaOk = false;
BYTE* p;
for (long y=0; y<head.biHeight; y++){
p = buff32 + 3 + head.biWidth * 4 * y;
for (long x=0; x<head.biWidth; x++){
if (*p) bAlphaOk = true;
AlphaSet(x,y,*p);
p+=4;
}
}
// fix if alpha pixels are all zero
if (!bAlphaOk) AlphaInvert();
}
}
#endif //CXIMAGE_SUPPORT_ALPHA
Bitfield2RGB(buff32,bfmask[0],bfmask[1],bfmask[2],32);
free(buff32);
} else cx_throw("can't allocate memory");
} else cx_throw("unknown compression");
break;
case 24 :
if (bf.bfOffBits != 0L) hFile->Seek(off + bf.bfOffBits,SEEK_SET);
if (dwCompression == BI_RGB){
hFile->Read(info.pImage, head.biSizeImage,1); // read in the pixels
} else cx_throw("unknown compression");
break;
case 16 :
{
DWORD bfmask[3];
if (dwCompression == BI_BITFIELDS)
{
hFile->Read(bfmask, 12, 1);
} else {
bfmask[0]=0x7C00; bfmask[1]=0x3E0; bfmask[2]=0x1F; //RGB555
}
// bf.bfOffBits required after the bitfield mask <Cui Ying Jie>
if (bf.bfOffBits != 0L) hFile->Seek(off + bf.bfOffBits,SEEK_SET);
// read in the pixels
hFile->Read(info.pImage, head.biHeight*((head.biWidth+1)/2)*4,1);
// transform into RGB
Bitfield2RGB(info.pImage,bfmask[0],bfmask[1],bfmask[2],16);
break;
}
case 8 :
case 4 :
case 1 :
if (bf.bfOffBits != 0L) hFile->Seek(off + bf.bfOffBits,SEEK_SET);
switch (dwCompression) {
case BI_RGB :
hFile->Read(info.pImage, head.biSizeImage,1); // read in the pixels
break;
case BI_RLE4 :
{
BYTE status_byte = 0;
BYTE second_byte = 0;
int scanline = 0;
int bits = 0;
BOOL low_nibble = FALSE;
CImageIterator iter(this);
for (BOOL bContinue = TRUE; bContinue && hFile->Read(&status_byte, sizeof(BYTE), 1);) {
switch (status_byte) {
case RLE_COMMAND :
hFile->Read(&status_byte, sizeof(BYTE), 1);
switch (status_byte) {
case RLE_ENDOFLINE :
bits = 0;
scanline++;
low_nibble = FALSE;
break;
case RLE_ENDOFBITMAP :
bContinue=FALSE;
break;
case RLE_DELTA :
{
// read the delta values
BYTE delta_x;
BYTE delta_y;
hFile->Read(&delta_x, sizeof(BYTE), 1);
hFile->Read(&delta_y, sizeof(BYTE), 1);
// apply them
bits += delta_x / 2;
scanline += delta_y;
break;
}
default :
hFile->Read(&second_byte, sizeof(BYTE), 1);
BYTE *sline = iter.GetRow(scanline);
for (int i = 0; i < status_byte; i++) {
if ((BYTE*)(sline+bits) < (BYTE*)(info.pImage+head.biSizeImage)){
if (low_nibble) {
if (i&1)
*(sline + bits) |= (second_byte & 0x0f);
else
*(sline + bits) |= (second_byte & 0xf0)>>4;
bits++;
} else {
if (i&1)
*(sline + bits) = (BYTE)(second_byte & 0x0f)<<4;
else
*(sline + bits) = (BYTE)(second_byte & 0xf0);
}
}
if ((i & 1) && (i != (status_byte - 1)))
hFile->Read(&second_byte, sizeof(BYTE), 1);
low_nibble = !low_nibble;
}
if ((((status_byte+1) >> 1) & 1 ) == 1)
hFile->Read(&second_byte, sizeof(BYTE), 1);
break;
};
break;
default :
{
BYTE *sline = iter.GetRow(scanline);
hFile->Read(&second_byte, sizeof(BYTE), 1);
for (unsigned i = 0; i < status_byte; i++) {
if ((BYTE*)(sline+bits) < (BYTE*)(info.pImage+head.biSizeImage)){
if (low_nibble) {
if (i&1)
*(sline + bits) |= (second_byte & 0x0f);
else
*(sline + bits) |= (second_byte & 0xf0)>>4;
bits++;
} else {
if (i&1)
*(sline + bits) = (BYTE)(second_byte & 0x0f)<<4;
else
*(sline + bits) = (BYTE)(second_byte & 0xf0);
}
}
low_nibble = !low_nibble;
}
}
break;
};
}
break;
}
case BI_RLE8 :
{
BYTE status_byte = 0;
BYTE second_byte = 0;
int scanline = 0;
int bits = 0;
CImageIterator iter(this);
for (BOOL bContinue = TRUE; bContinue && hFile->Read(&status_byte, sizeof(BYTE), 1);) {
switch (status_byte) {
case RLE_COMMAND :
hFile->Read(&status_byte, sizeof(BYTE), 1);
switch (status_byte) {
case RLE_ENDOFLINE :
bits = 0;
scanline++;
break;
case RLE_ENDOFBITMAP :
bContinue=FALSE;
break;
case RLE_DELTA :
{
// read the delta values
BYTE delta_x;
BYTE delta_y;
hFile->Read(&delta_x, sizeof(BYTE), 1);
hFile->Read(&delta_y, sizeof(BYTE), 1);
// apply them
bits += delta_x;
scanline += delta_y;
break;
}
default :
hFile->Read((void *)(iter.GetRow(scanline) + bits), sizeof(BYTE) * status_byte, 1);
// align run length to even number of bytes
if ((status_byte & 1) == 1)
hFile->Read(&second_byte, sizeof(BYTE), 1);
bits += status_byte;
break;
};
break;
default :
BYTE *sline = iter.GetRow(scanline);
hFile->Read(&second_byte, sizeof(BYTE), 1);
for (unsigned i = 0; i < status_byte; i++) {
if ((DWORD)bits<info.dwEffWidth){
*(sline + bits) = second_byte;
bits++;
} else {
break;
}
}
break;
};
}
break;
}
default :
cx_throw("compression type not supported");
}
}
if (bTopDownDib) Flip(); //<Flanders>
} cx_catch {
if (strcmp(message,"")) strncpy(info.szLastError,message,255);
if (info.nEscape == -1 && info.dwType == CXIMAGE_FORMAT_BMP) return true;
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/* ReadDibBitmapInfo()
*
* Will read a file in DIB format and return a global HANDLE to its
* BITMAPINFO. This function will work with both "old" and "new"
* bitmap formats, but will always return a "new" BITMAPINFO.
*/
bool CxImageBMP::DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib)
{
if ((fh==NULL)||(pdib==NULL)) return false;
if (fh->Read(pdib,sizeof(BITMAPINFOHEADER),1)==0) return false;
bihtoh(pdib);
switch (pdib->biSize) // what type of bitmap info is this?
{
case sizeof(BITMAPINFOHEADER):
break;
case 64: //sizeof(OS2_BMP_HEADER):
fh->Seek((long)(64 - sizeof(BITMAPINFOHEADER)),SEEK_CUR);
break;
case sizeof(BITMAPCOREHEADER):
{
BITMAPCOREHEADER bc = *(BITMAPCOREHEADER*)pdib;
pdib->biSize = bc.bcSize;
pdib->biWidth = (DWORD)bc.bcWidth;
pdib->biHeight = (DWORD)bc.bcHeight;
pdib->biPlanes = bc.bcPlanes;
pdib->biBitCount = bc.bcBitCount;
pdib->biCompression = BI_RGB;
pdib->biSizeImage = 0;
pdib->biXPelsPerMeter = 0;
pdib->biYPelsPerMeter = 0;
pdib->biClrUsed = 0;
pdib->biClrImportant = 0;
fh->Seek((long)(sizeof(BITMAPCOREHEADER)-sizeof(BITMAPINFOHEADER)), SEEK_CUR);
}
break;
default:
//give a last chance
if (pdib->biSize>(sizeof(BITMAPINFOHEADER))&&
(pdib->biSizeImage>=(unsigned long)(pdib->biHeight*((((pdib->biBitCount*pdib->biWidth)+31)/32)*4)))&&
(pdib->biPlanes==1)&&(pdib->biClrUsed==0))
{
if (pdib->biCompression==BI_RGB)
fh->Seek((long)(pdib->biSize - sizeof(BITMAPINFOHEADER)),SEEK_CUR);
break;
}
return false;
}
FixBitmapInfo(pdib);
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_BMP
////////////////////////////////////////////////////////////////////////////////
+79
View File
@@ -0,0 +1,79 @@
/*
* File: ximabmp.h
* Purpose: BMP Image Class Loader and Writer
*/
/* ==========================================================
* CxImageBMP (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it
* For conditions of distribution and use, see copyright notice in ximage.h
*
* Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes
*
* original CImageBMP and CImageIterator implementation are:
* Copyright: (c) 1995, Alejandro Aguilar Sierra <asierra(at)servidor(dot)unam(dot)mx>
*
* ==========================================================
*/
#if !defined(__ximaBMP_h)
#define __ximaBMP_h
#include "ximage.h"
const int RLE_COMMAND = 0;
const int RLE_ENDOFLINE = 0;
const int RLE_ENDOFBITMAP = 1;
const int RLE_DELTA = 2;
#if !defined(BI_RLE8)
#define BI_RLE8 1L
#endif
#if !defined(BI_RLE4)
#define BI_RLE4 2L
#endif
#if CXIMAGE_SUPPORT_BMP
class CxImageBMP: public CxImage
{
public:
CxImageBMP(): CxImage(CXIMAGE_FORMAT_BMP) {};
bool Decode(CxFile * hFile);
bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
#if CXIMAGE_SUPPORT_ENCODE
bool Encode(CxFile * hFile);
bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }
#endif // CXIMAGE_SUPPORT_ENCODE
protected:
bool DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib);
};
#define BFT_ICON 0x4349 /* 'IC' */
#define BFT_BITMAP 0x4d42 /* 'BM' */
#define BFT_CURSOR 0x5450 /* 'PT' */
#ifndef WIDTHBYTES
#define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */
#endif
#endif
#define DibWidthBytesN(lpbi, n) (UINT)WIDTHBYTES((UINT)(lpbi)->biWidth * (UINT)(n))
#define DibWidthBytes(lpbi) DibWidthBytesN(lpbi, (lpbi)->biBitCount)
#define DibSizeImage(lpbi) ((lpbi)->biSizeImage == 0 \
? ((DWORD)(UINT)DibWidthBytes(lpbi) * (DWORD)(UINT)(lpbi)->biHeight) \
: (lpbi)->biSizeImage)
#define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \
? (int)(1 << (int)(lpbi)->biBitCount) \
: (int)(lpbi)->biClrUsed)
#define FixBitmapInfo(lpbi) if ((lpbi)->biSizeImage == 0) \
(lpbi)->biSizeImage = DibSizeImage(lpbi); \
if ((lpbi)->biClrUsed == 0) \
(lpbi)->biClrUsed = DibNumColors(lpbi); \
#endif
+57
View File
@@ -0,0 +1,57 @@
#if !defined(__ximaCFG_h)
#define __ximaCFG_h
/////////////////////////////////////////////////////////////////////////////
// CxImage supported features
#define CXIMAGE_SUPPORT_ALPHA 1
#define CXIMAGE_SUPPORT_SELECTION 1
#define CXIMAGE_SUPPORT_TRANSFORMATION 1
#define CXIMAGE_SUPPORT_DSP 1
#define CXIMAGE_SUPPORT_LAYERS 1
#define CXIMAGE_SUPPORT_INTERPOLATION 1
#define CXIMAGE_SUPPORT_DECODE 1
#define CXIMAGE_SUPPORT_ENCODE 1 //<vho><T.Peck>
#define CXIMAGE_SUPPORT_WINDOWS 1
/////////////////////////////////////////////////////////////////////////////
// CxImage supported formats
#define CXIMAGE_SUPPORT_BMP 0
#define CXIMAGE_SUPPORT_GIF 0
#define CXIMAGE_SUPPORT_JPG 0
#define CXIMAGE_SUPPORT_PNG 1
#define CXIMAGE_SUPPORT_ICO 0
#define CXIMAGE_SUPPORT_TIF 0
#define CXIMAGE_SUPPORT_TGA 0
#define CXIMAGE_SUPPORT_PCX 0
#define CXIMAGE_SUPPORT_WBMP 0
#define CXIMAGE_SUPPORT_WMF 0
#define CXIMAGE_SUPPORT_JP2 0
#define CXIMAGE_SUPPORT_JPC 0
#define CXIMAGE_SUPPORT_PGX 0
#define CXIMAGE_SUPPORT_PNM 0
#define CXIMAGE_SUPPORT_RAS 0
#define CXIMAGE_SUPPORT_JBG 0 // GPL'd see ../jbig/copying.txt & ../jbig/patents.htm
#define CXIMAGE_SUPPORT_MNG 0
#define CXIMAGE_SUPPORT_SKA 0
#define CXIMAGE_SUPPORT_RAW 0
/////////////////////////////////////////////////////////////////////////////
#define CXIMAGE_MAX_MEMORY 268435456
#define CXIMAGE_DEFAULT_DPI 96
#define CXIMAGE_ERR_NOFILE "null file handler"
#define CXIMAGE_ERR_NOIMAGE "null image!!!"
#define CXIMAGE_SUPPORT_EXCEPTION_HANDLING 1
/////////////////////////////////////////////////////////////////////////////
//color to grey mapping <H. Muelner> <jurgene>
//#define RGB2GRAY(r,g,b) (((b)*114 + (g)*587 + (r)*299)/1000)
#define RGB2GRAY(r,g,b) (((b)*117 + (g)*601 + (r)*306) >> 10)
#endif
+206
View File
@@ -0,0 +1,206 @@
#if !defined(__ximadefs_h)
#define __ximadefs_h
#include "ximacfg.h"
#if defined(_AFXDLL)||defined(_USRDLL)
#define DLL_EXP __declspec(dllexport)
#elif defined(_MSC_VER)&&(_MSC_VER<1200)
#define DLL_EXP __declspec(dllimport)
#else
#define DLL_EXP
#endif
#if CXIMAGE_SUPPORT_EXCEPTION_HANDLING
#define cx_try try
#define cx_throw(message) throw(message)
#define cx_catch catch (const char *message)
#else
#define cx_try bool cx_error=false;
#define cx_throw(message) {cx_error=true; if(strcmp(message,"")) strncpy(info.szLastError,message,255); goto cx_error_catch;}
#define cx_catch cx_error_catch: char message[]=""; if(cx_error)
#endif
#if CXIMAGE_SUPPORT_JP2 || CXIMAGE_SUPPORT_JPC || CXIMAGE_SUPPORT_PGX || CXIMAGE_SUPPORT_PNM || CXIMAGE_SUPPORT_RAS
#define CXIMAGE_SUPPORT_JASPER 1
#else
#define CXIMAGE_SUPPORT_JASPER 0
#endif
#if CXIMAGE_SUPPORT_DSP
#undef CXIMAGE_SUPPORT_TRANSFORMATION
#define CXIMAGE_SUPPORT_TRANSFORMATION 1
#endif
#if CXIMAGE_SUPPORT_TRANSFORMATION || CXIMAGE_SUPPORT_TIF || CXIMAGE_SUPPORT_TGA || CXIMAGE_SUPPORT_BMP || CXIMAGE_SUPPORT_WINDOWS
#define CXIMAGE_SUPPORT_BASICTRANSFORMATIONS 1
#endif
#if CXIMAGE_SUPPORT_DSP || CXIMAGE_SUPPORT_TRANSFORMATION
#undef CXIMAGE_SUPPORT_INTERPOLATION
#define CXIMAGE_SUPPORT_INTERPOLATION 1
#endif
#if defined (_WIN32_WCE)
#undef CXIMAGE_SUPPORT_WMF
#define CXIMAGE_SUPPORT_WMF 0
#endif
#if !defined(WIN32) && !defined(_WIN32_WCE)
#undef CXIMAGE_SUPPORT_WINDOWS
#define CXIMAGE_SUPPORT_WINDOWS 0
#endif
#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef max
#define max(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef PI
#define PI 3.141592653589793f
#endif
#if defined(WIN32) || defined(_WIN32_WCE)
#include <windows.h>
#include <tchar.h>
#endif
#include <stdio.h>
#include <math.h>
#ifdef __BORLANDC__
#ifndef _COMPLEX_DEFINED
typedef struct tagcomplex {
double x,y;
} _complex;
#endif
#define _cabs(c) sqrt(c.x*c.x+c.y*c.y)
#endif
#if !defined(WIN32) && !defined(_WIN32_WCE)
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned int UINT;
typedef DWORD COLORREF;
typedef unsigned int HANDLE;
typedef void* HRGN;
#ifndef BOOL
#define BOOL bool
#endif
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
#ifndef TCHAR
#define TCHAR char
#define _T
#endif
typedef struct tagRECT
{
long left;
long top;
long right;
long bottom;
} RECT;
typedef struct tagPOINT
{
long x;
long y;
} POINT;
typedef struct tagRGBQUAD {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
#pragma pack(1)
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
long biWidth;
long biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER;
typedef struct tagBITMAPCOREHEADER {
DWORD bcSize;
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes;
WORD bcBitCount;
} BITMAPCOREHEADER;
typedef struct tagRGBTRIPLE {
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} RGBTRIPLE;
#pragma pack()
#define BI_RGB 0L
#define BI_RLE8 1L
#define BI_RLE4 2L
#define BI_BITFIELDS 3L
#define GetRValue(rgb) ((BYTE)(rgb))
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
#define GetBValue(rgb) ((BYTE)((rgb)>>16))
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#ifndef _COMPLEX_DEFINED
typedef struct tagcomplex {
double x,y;
} _complex;
#endif
#define _cabs(c) sqrt(c.x*c.x+c.y*c.y)
#endif
#endif //__ximadefs
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+878
View File
@@ -0,0 +1,878 @@
/*
* File: ximaexif.cpp
* Purpose: EXIF reader
* 18/Aug/2002 Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
* based on jhead-1.8 by Matthias Wandel <mwandel(at)rim(dot)net>
*/
#include "ximajpg.h"
#if CXIMAGEJPG_SUPPORT_EXIF
////////////////////////////////////////////////////////////////////////////////
CxImageJPG::CxExifInfo::CxExifInfo(EXIFINFO* info)
{
if (info) {
m_exifinfo = info;
freeinfo = false;
} else {
m_exifinfo = new EXIFINFO;
memset(m_exifinfo,0,sizeof(EXIFINFO));
freeinfo = true;
}
m_szLastError[0]='\0';
ExifImageWidth = MotorolaOrder = 0;
SectionsRead=0;
memset(&Sections, 0, MAX_SECTIONS * sizeof(Section_t));
}
////////////////////////////////////////////////////////////////////////////////
CxImageJPG::CxExifInfo::~CxExifInfo()
{
for(int i=0;i<MAX_SECTIONS;i++) if(Sections[i].Data) free(Sections[i].Data);
if (freeinfo) delete m_exifinfo;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImageJPG::CxExifInfo::DecodeExif(CxFile * hFile, int nReadMode)
{
int a;
int HaveCom = FALSE;
a = hFile->GetC();
if (a != 0xff || hFile->GetC() != M_SOI){
return FALSE;
}
for(;;){
int itemlen;
int marker = 0;
int ll,lh, got;
BYTE * Data;
if (SectionsRead >= MAX_SECTIONS){
strcpy(m_szLastError,"Too many sections in jpg file");
return false;
}
for (a=0;a<7;a++){
marker = hFile->GetC();
if (marker != 0xff) break;
if (a >= 6){
printf("too many padding bytes\n");
return false;
}
}
if (marker == 0xff){
// 0xff is legal padding, but if we get that many, something's wrong.
strcpy(m_szLastError,"too many padding bytes!");
return false;
}
Sections[SectionsRead].Type = marker;
// Read the length of the section.
lh = hFile->GetC();
ll = hFile->GetC();
itemlen = (lh << 8) | ll;
if (itemlen < 2){
strcpy(m_szLastError,"invalid marker");
return false;
}
Sections[SectionsRead].Size = itemlen;
Data = (BYTE *)malloc(itemlen);
if (Data == NULL){
strcpy(m_szLastError,"Could not allocate memory");
return false;
}
Sections[SectionsRead].Data = Data;
// Store first two pre-read bytes.
Data[0] = (BYTE)lh;
Data[1] = (BYTE)ll;
got = hFile->Read(Data+2, 1, itemlen-2); // Read the whole section.
if (got != itemlen-2){
strcpy(m_szLastError,"Premature end of file?");
return false;
}
SectionsRead += 1;
switch(marker){
case M_SOS: // stop before hitting compressed data
// If reading entire image is requested, read the rest of the data.
if (nReadMode & EXIF_READ_IMAGE){
int cp, ep, size;
// Determine how much file is left.
cp = hFile->Tell();
hFile->Seek(0, SEEK_END);
ep = hFile->Tell();
hFile->Seek(cp, SEEK_SET);
size = ep-cp;
Data = (BYTE *)malloc(size);
if (Data == NULL){
strcpy(m_szLastError,"could not allocate data for entire image");
return false;
}
got = hFile->Read(Data, 1, size);
if (got != size){
strcpy(m_szLastError,"could not read the rest of the image");
return false;
}
Sections[SectionsRead].Data = Data;
Sections[SectionsRead].Size = size;
Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER;
SectionsRead ++;
}
return true;
case M_EOI: // in case it's a tables-only JPEG stream
printf("No image in jpeg!\n");
return FALSE;
case M_COM: // Comment section
if (HaveCom || ((nReadMode & EXIF_READ_EXIF) == 0)){
// Discard this section.
free(Sections[--SectionsRead].Data);
Sections[SectionsRead].Data=0;
}else{
process_COM(Data, itemlen);
HaveCom = TRUE;
}
break;
case M_JFIF:
// Regular jpegs always have this tag, exif images have the exif
// marker instead, althogh ACDsee will write images with both markers.
// this program will re-create this marker on absence of exif marker.
// hence no need to keep the copy from the file.
free(Sections[--SectionsRead].Data);
Sections[SectionsRead].Data=0;
break;
case M_EXIF:
// Seen files from some 'U-lead' software with Vivitar scanner
// that uses marker 31 for non exif stuff. Thus make sure
// it says 'Exif' in the section before treating it as exif.
if ((nReadMode & EXIF_READ_EXIF) && memcmp(Data+2, "Exif", 4) == 0){
m_exifinfo->IsExif = process_EXIF((BYTE *)Data+2, itemlen);
}else{
// Discard this section.
free(Sections[--SectionsRead].Data);
Sections[SectionsRead].Data=0;
}
break;
case M_SOF0:
case M_SOF1:
case M_SOF2:
case M_SOF3:
case M_SOF5:
case M_SOF6:
case M_SOF7:
case M_SOF9:
case M_SOF10:
case M_SOF11:
case M_SOF13:
case M_SOF14:
case M_SOF15:
process_SOFn(Data, marker);
break;
default:
// Skip any other sections.
//if (ShowTags) printf("Jpeg section marker 0x%02x size %d\n",marker, itemlen);
break;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------
Process a EXIF marker
Describes all the drivel that most digital cameras include...
--------------------------------------------------------------------------*/
bool CxImageJPG::CxExifInfo::process_EXIF(unsigned char * CharBuf, unsigned int length)
{
m_exifinfo->FlashUsed = 0;
/* If it's from a digicam, and it used flash, it says so. */
m_exifinfo->Comments[0] = '\0'; /* Initial value - null string */
ExifImageWidth = 0;
{ /* Check the EXIF header component */
static const unsigned char ExifHeader[] = "Exif\0\0";
if (memcmp(CharBuf+0, ExifHeader,6)){
strcpy(m_szLastError,"Incorrect Exif header");
return false;
}
}
if (memcmp(CharBuf+6,"II",2) == 0){
MotorolaOrder = 0;
}else{
if (memcmp(CharBuf+6,"MM",2) == 0){
MotorolaOrder = 1;
}else{
strcpy(m_szLastError,"Invalid Exif alignment marker.");
return false;
}
}
/* Check the next two values for correctness. */
if (Get16u(CharBuf+8) != 0x2a){
strcpy(m_szLastError,"Invalid Exif start (1)");
return false;
}
int FirstOffset = Get32u(CharBuf+10);
/* <Richard Collins>
if (FirstOffset < 8 || FirstOffset > 16){
// I used to ensure this was set to 8 (website I used indicated its 8)
// but PENTAX Optio 230 has it set differently, and uses it as offset. (Sept 11 2002)
strcpy(m_szLastError,"Suspicious offset of first IFD value");
return false;
}*/
unsigned char * LastExifRefd = CharBuf;
/* First directory starts 16 bytes in. Offsets start at 8 bytes in. */
if (!ProcessExifDir(CharBuf+14, CharBuf+6, length-6, m_exifinfo, &LastExifRefd))
return false;
/* <Richard Collins> give a chance for a second directory */
if (FirstOffset > 8) {
if (!ProcessExifDir(CharBuf+14+FirstOffset-8, CharBuf+6, length-6, m_exifinfo, &LastExifRefd))
return false;
}
/* This is how far the interesting (non thumbnail) part of the exif went. */
// int ExifSettingsLength = LastExifRefd - CharBuf;
/* Compute the CCD width, in milimeters. */
if (m_exifinfo->FocalplaneXRes != 0){
m_exifinfo->CCDWidth = (float)(ExifImageWidth * m_exifinfo->FocalplaneUnits / m_exifinfo->FocalplaneXRes);
}
return true;
}
//--------------------------------------------------------------------------
// Get 16 bits motorola order (always) for jpeg header stuff.
//--------------------------------------------------------------------------
int CxImageJPG::CxExifInfo::Get16m(void * Short)
{
return (((unsigned char *)Short)[0] << 8) | ((unsigned char *)Short)[1];
}
////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------
Convert a 16 bit unsigned value from file's native byte order
--------------------------------------------------------------------------*/
int CxImageJPG::CxExifInfo::Get16u(void * Short)
{
if (MotorolaOrder){
return (((unsigned char *)Short)[0] << 8) | ((unsigned char *)Short)[1];
}else{
return (((unsigned char *)Short)[1] << 8) | ((unsigned char *)Short)[0];
}
}
////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------
Convert a 32 bit signed value from file's native byte order
--------------------------------------------------------------------------*/
long CxImageJPG::CxExifInfo::Get32s(void * Long)
{
if (MotorolaOrder){
return ((( char *)Long)[0] << 24) | (((unsigned char *)Long)[1] << 16)
| (((unsigned char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 );
}else{
return ((( char *)Long)[3] << 24) | (((unsigned char *)Long)[2] << 16)
| (((unsigned char *)Long)[1] << 8 ) | (((unsigned char *)Long)[0] << 0 );
}
}
////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------
Convert a 32 bit unsigned value from file's native byte order
--------------------------------------------------------------------------*/
unsigned long CxImageJPG::CxExifInfo::Get32u(void * Long)
{
return (unsigned long)Get32s(Long) & 0xffffffff;
}
////////////////////////////////////////////////////////////////////////////////
/* Describes format descriptor */
static const int BytesPerFormat[] = {0,1,1,2,4,8,1,1,2,4,8,4,8};
#define NUM_FORMATS 12
#define FMT_BYTE 1
#define FMT_STRING 2
#define FMT_USHORT 3
#define FMT_ULONG 4
#define FMT_URATIONAL 5
#define FMT_SBYTE 6
#define FMT_UNDEFINED 7
#define FMT_SSHORT 8
#define FMT_SLONG 9
#define FMT_SRATIONAL 10
#define FMT_SINGLE 11
#define FMT_DOUBLE 12
/* Describes tag values */
#define TAG_EXIF_VERSION 0x9000
#define TAG_EXIF_OFFSET 0x8769
#define TAG_INTEROP_OFFSET 0xa005
#define TAG_MAKE 0x010F
#define TAG_MODEL 0x0110
#define TAG_ORIENTATION 0x0112
#define TAG_XRESOLUTION 0x011A
#define TAG_YRESOLUTION 0x011B
#define TAG_RESOLUTIONUNIT 0x0128
#define TAG_EXPOSURETIME 0x829A
#define TAG_FNUMBER 0x829D
#define TAG_SHUTTERSPEED 0x9201
#define TAG_APERTURE 0x9202
#define TAG_BRIGHTNESS 0x9203
#define TAG_MAXAPERTURE 0x9205
#define TAG_FOCALLENGTH 0x920A
#define TAG_DATETIME_ORIGINAL 0x9003
#define TAG_USERCOMMENT 0x9286
#define TAG_SUBJECT_DISTANCE 0x9206
#define TAG_FLASH 0x9209
#define TAG_FOCALPLANEXRES 0xa20E
#define TAG_FOCALPLANEYRES 0xa20F
#define TAG_FOCALPLANEUNITS 0xa210
#define TAG_EXIF_IMAGEWIDTH 0xA002
#define TAG_EXIF_IMAGELENGTH 0xA003
/* the following is added 05-jan-2001 vcs */
#define TAG_EXPOSURE_BIAS 0x9204
#define TAG_WHITEBALANCE 0x9208
#define TAG_METERING_MODE 0x9207
#define TAG_EXPOSURE_PROGRAM 0x8822
#define TAG_ISO_EQUIVALENT 0x8827
#define TAG_COMPRESSION_LEVEL 0x9102
#define TAG_THUMBNAIL_OFFSET 0x0201
#define TAG_THUMBNAIL_LENGTH 0x0202
/*--------------------------------------------------------------------------
Process one of the nested EXIF directories.
--------------------------------------------------------------------------*/
bool CxImageJPG::CxExifInfo::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength,
EXIFINFO * const m_exifinfo, unsigned char ** const LastExifRefdP, int NestingLevel)
{
int de;
int a;
int NumDirEntries;
unsigned ThumbnailOffset = 0;
unsigned ThumbnailSize = 0;
if (NestingLevel > 4){
strcpy(m_szLastError,"Maximum directory nesting exceeded (corrupt exif header)");
return false;
}
NumDirEntries = Get16u(DirStart);
if ((DirStart+2+NumDirEntries*12) > (OffsetBase+ExifLength)){
strcpy(m_szLastError,"Illegally sized directory");
return false;
}
for (de=0;de<NumDirEntries;de++){
int Tag, Format, Components;
unsigned char * ValuePtr;
/* This actually can point to a variety of things; it must be
cast to other types when used. But we use it as a byte-by-byte
cursor, so we declare it as a pointer to a generic byte here.
*/
int ByteCount;
unsigned char * DirEntry;
DirEntry = DirStart+2+12*de;
Tag = Get16u(DirEntry);
Format = Get16u(DirEntry+2);
Components = Get32u(DirEntry+4);
if ((Format-1) >= NUM_FORMATS) {
/* (-1) catches illegal zero case as unsigned underflows to positive large */
strcpy(m_szLastError,"Illegal format code in EXIF dir");
return false;
}
ByteCount = Components * BytesPerFormat[Format];
if (ByteCount > 4){
unsigned OffsetVal;
OffsetVal = Get32u(DirEntry+8);
/* If its bigger than 4 bytes, the dir entry contains an offset.*/
if (OffsetVal+ByteCount > ExifLength){
/* Bogus pointer offset and / or bytecount value */
strcpy(m_szLastError,"Illegal pointer offset value in EXIF.");
return false;
}
ValuePtr = OffsetBase+OffsetVal;
}else{
/* 4 bytes or less and value is in the dir entry itself */
ValuePtr = DirEntry+8;
}
if (*LastExifRefdP < ValuePtr+ByteCount){
/* Keep track of last byte in the exif header that was
actually referenced. That way, we know where the
discardable thumbnail data begins.
*/
*LastExifRefdP = ValuePtr+ByteCount;
}
/* Extract useful components of tag */
switch(Tag){
case TAG_MAKE:
strncpy(m_exifinfo->CameraMake, (char*)ValuePtr, 31);
break;
case TAG_MODEL:
strncpy(m_exifinfo->CameraModel, (char*)ValuePtr, 39);
break;
case TAG_EXIF_VERSION:
strncpy(m_exifinfo->Version,(char*)ValuePtr, 4);
break;
case TAG_DATETIME_ORIGINAL:
strncpy(m_exifinfo->DateTime, (char*)ValuePtr, 19);
break;
case TAG_USERCOMMENT:
// Olympus has this padded with trailing spaces. Remove these first.
for (a=ByteCount;;){
a--;
if (((char*)ValuePtr)[a] == ' '){
((char*)ValuePtr)[a] = '\0';
}else{
break;
}
if (a == 0) break;
}
/* Copy the comment */
if (memcmp(ValuePtr, "ASCII",5) == 0){
for (a=5;a<10;a++){
char c;
c = ((char*)ValuePtr)[a];
if (c != '\0' && c != ' '){
strncpy(m_exifinfo->Comments, (char*)ValuePtr+a, 199);
break;
}
}
}else{
strncpy(m_exifinfo->Comments, (char*)ValuePtr, 199);
}
break;
case TAG_FNUMBER:
/* Simplest way of expressing aperture, so I trust it the most.
(overwrite previously computd value if there is one)
*/
m_exifinfo->ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_APERTURE:
case TAG_MAXAPERTURE:
/* More relevant info always comes earlier, so only
use this field if we don't have appropriate aperture
information yet.
*/
if (m_exifinfo->ApertureFNumber == 0){
m_exifinfo->ApertureFNumber = (float)exp(ConvertAnyFormat(ValuePtr, Format)*log(2.0f)*0.5);
}
break;
case TAG_BRIGHTNESS:
m_exifinfo->Brightness = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_FOCALLENGTH:
/* Nice digital cameras actually save the focal length
as a function of how farthey are zoomed in.
*/
m_exifinfo->FocalLength = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_SUBJECT_DISTANCE:
/* Inidcates the distacne the autofocus camera is focused to.
Tends to be less accurate as distance increases.
*/
m_exifinfo->Distance = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_EXPOSURETIME:
/* Simplest way of expressing exposure time, so I
trust it most. (overwrite previously computd value
if there is one)
*/
m_exifinfo->ExposureTime =
(float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_SHUTTERSPEED:
/* More complicated way of expressing exposure time,
so only use this value if we don't already have it
from somewhere else.
*/
if (m_exifinfo->ExposureTime == 0){
m_exifinfo->ExposureTime = (float)
(1/exp(ConvertAnyFormat(ValuePtr, Format)*log(2.0f)));
}
break;
case TAG_FLASH:
if ((int)ConvertAnyFormat(ValuePtr, Format) & 7){
m_exifinfo->FlashUsed = 1;
}else{
m_exifinfo->FlashUsed = 0;
}
break;
case TAG_ORIENTATION:
m_exifinfo->Orientation = (int)ConvertAnyFormat(ValuePtr, Format);
if (m_exifinfo->Orientation < 1 || m_exifinfo->Orientation > 8){
strcpy(m_szLastError,"Undefined rotation value");
m_exifinfo->Orientation = 0;
}
break;
case TAG_EXIF_IMAGELENGTH:
case TAG_EXIF_IMAGEWIDTH:
/* Use largest of height and width to deal with images
that have been rotated to portrait format.
*/
a = (int)ConvertAnyFormat(ValuePtr, Format);
if (ExifImageWidth < a) ExifImageWidth = a;
break;
case TAG_FOCALPLANEXRES:
m_exifinfo->FocalplaneXRes = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_FOCALPLANEYRES:
m_exifinfo->FocalplaneYRes = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_RESOLUTIONUNIT:
switch((int)ConvertAnyFormat(ValuePtr, Format)){
case 1: m_exifinfo->ResolutionUnit = 1.0f; break; /* 1 inch */
case 2: m_exifinfo->ResolutionUnit = 1.0f; break;
case 3: m_exifinfo->ResolutionUnit = 0.3937007874f; break; /* 1 centimeter*/
case 4: m_exifinfo->ResolutionUnit = 0.03937007874f; break; /* 1 millimeter*/
case 5: m_exifinfo->ResolutionUnit = 0.00003937007874f; /* 1 micrometer*/
}
break;
case TAG_FOCALPLANEUNITS:
switch((int)ConvertAnyFormat(ValuePtr, Format)){
case 1: m_exifinfo->FocalplaneUnits = 1.0f; break; /* 1 inch */
case 2: m_exifinfo->FocalplaneUnits = 1.0f; break;
case 3: m_exifinfo->FocalplaneUnits = 0.3937007874f; break; /* 1 centimeter*/
case 4: m_exifinfo->FocalplaneUnits = 0.03937007874f; break; /* 1 millimeter*/
case 5: m_exifinfo->FocalplaneUnits = 0.00003937007874f; /* 1 micrometer*/
}
break;
// Remaining cases contributed by: Volker C. Schoech <schoech(at)gmx(dot)de>
case TAG_EXPOSURE_BIAS:
m_exifinfo->ExposureBias = (float) ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_WHITEBALANCE:
m_exifinfo->Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_METERING_MODE:
m_exifinfo->MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_EXPOSURE_PROGRAM:
m_exifinfo->ExposureProgram = (int)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_ISO_EQUIVALENT:
m_exifinfo->ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format);
if ( m_exifinfo->ISOequivalent < 50 ) m_exifinfo->ISOequivalent *= 200;
break;
case TAG_COMPRESSION_LEVEL:
m_exifinfo->CompressionLevel = (int)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_XRESOLUTION:
m_exifinfo->Xresolution = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_YRESOLUTION:
m_exifinfo->Yresolution = (float)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_THUMBNAIL_OFFSET:
ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format);
break;
case TAG_THUMBNAIL_LENGTH:
ThumbnailSize = (unsigned)ConvertAnyFormat(ValuePtr, Format);
break;
}
if (Tag == TAG_EXIF_OFFSET || Tag == TAG_INTEROP_OFFSET){
unsigned char * SubdirStart;
unsigned Offset = Get32u(ValuePtr);
if (Offset>8){
SubdirStart = OffsetBase + Offset;
if (SubdirStart < OffsetBase ||
SubdirStart > OffsetBase+ExifLength){
strcpy(m_szLastError,"Illegal subdirectory link");
return false;
}
ProcessExifDir(SubdirStart, OffsetBase, ExifLength, m_exifinfo, LastExifRefdP, NestingLevel+1);
}
continue;
}
}
{
/* In addition to linking to subdirectories via exif tags,
there's also a potential link to another directory at the end
of each directory. This has got to be the result of a
committee!
*/
unsigned char * SubdirStart;
unsigned Offset;
Offset = Get16u(DirStart+2+12*NumDirEntries);
if (Offset){
SubdirStart = OffsetBase + Offset;
if (SubdirStart < OffsetBase
|| SubdirStart > OffsetBase+ExifLength){
strcpy(m_szLastError,"Illegal subdirectory link");
return false;
}
ProcessExifDir(SubdirStart, OffsetBase, ExifLength, m_exifinfo, LastExifRefdP, NestingLevel+1);
}
}
if (ThumbnailSize && ThumbnailOffset){
if (ThumbnailSize + ThumbnailOffset <= ExifLength){
/* The thumbnail pointer appears to be valid. Store it. */
m_exifinfo->ThumbnailPointer = OffsetBase + ThumbnailOffset;
m_exifinfo->ThumbnailSize = ThumbnailSize;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/*--------------------------------------------------------------------------
Evaluate number, be it int, rational, or float from directory.
--------------------------------------------------------------------------*/
double CxImageJPG::CxExifInfo::ConvertAnyFormat(void * ValuePtr, int Format)
{
double Value;
Value = 0;
switch(Format){
case FMT_SBYTE: Value = *(signed char *)ValuePtr; break;
case FMT_BYTE: Value = *(unsigned char *)ValuePtr; break;
case FMT_USHORT: Value = Get16u(ValuePtr); break;
case FMT_ULONG: Value = Get32u(ValuePtr); break;
case FMT_URATIONAL:
case FMT_SRATIONAL:
{
int Num,Den;
Num = Get32s(ValuePtr);
Den = Get32s(4+(char *)ValuePtr);
if (Den == 0){
Value = 0;
}else{
Value = (double)Num/Den;
}
break;
}
case FMT_SSHORT: Value = (signed short)Get16u(ValuePtr); break;
case FMT_SLONG: Value = Get32s(ValuePtr); break;
/* Not sure if this is correct (never seen float used in Exif format)
*/
case FMT_SINGLE: Value = (double)*(float *)ValuePtr; break;
case FMT_DOUBLE: Value = *(double *)ValuePtr; break;
}
return Value;
}
////////////////////////////////////////////////////////////////////////////////
void CxImageJPG::CxExifInfo::process_COM (const BYTE * Data, int length)
{
int ch;
char Comment[MAX_COMMENT+1];
int nch;
int a;
nch = 0;
if (length > MAX_COMMENT) length = MAX_COMMENT; // Truncate if it won't fit in our structure.
for (a=2;a<length;a++){
ch = Data[a];
if (ch == '\r' && Data[a+1] == '\n') continue; // Remove cr followed by lf.
if (isprint(ch) || ch == '\n' || ch == '\t'){
Comment[nch++] = (char)ch;
}else{
Comment[nch++] = '?';
}
}
Comment[nch] = '\0'; // Null terminate
//if (ShowTags) printf("COM marker comment: %s\n",Comment);
strcpy(m_exifinfo->Comments,Comment);
}
////////////////////////////////////////////////////////////////////////////////
void CxImageJPG::CxExifInfo::process_SOFn (const BYTE * Data, int marker)
{
int data_precision, num_components;
data_precision = Data[2];
m_exifinfo->Height = Get16m((void*)(Data+3));
m_exifinfo->Width = Get16m((void*)(Data+5));
num_components = Data[7];
if (num_components == 3){
m_exifinfo->IsColor = 1;
}else{
m_exifinfo->IsColor = 0;
}
m_exifinfo->Process = marker;
//if (ShowTags) printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n",
// ImageInfo.Width, ImageInfo.Height, num_components, data_precision);
}
////////////////////////////////////////////////////////////////////////////////
/**
* this will work only on a CxImageJPG object, if the image originally has valid EXIF data
\verbatim
CxImageJPG jpg;
CxIOFile in,out;
in.Open("D:\\exif_in.jpg","rb");
out.Open("D:\\exif_out.jpg","w+b");
jpg.Decode(&in);
if (jpg.IsValid()){
jpg.RotateLeft();
jpg.Encode(&out);
}
\endverbatim
*/
bool CxImageJPG::CxExifInfo::EncodeExif(CxFile * hFile)
{
int a;
if (FindSection(M_SOS)==NULL){
strcpy(m_szLastError,"Can't write exif : didn't read all");
return false;
}
// Initial static jpeg marker.
hFile->PutC(0xff);
hFile->PutC(0xd8);
if (Sections[0].Type != M_EXIF && Sections[0].Type != M_JFIF){
// The image must start with an exif or jfif marker. If we threw those away, create one.
static BYTE JfifHead[18] = {
0xff, M_JFIF,
0x00, 0x10, 'J' , 'F' , 'I' , 'F' , 0x00, 0x01,
0x01, 0x01, 0x01, 0x2C, 0x01, 0x2C, 0x00, 0x00
};
hFile->Write(JfifHead, 18, 1);
}
// Write all the misc sections
for (a=0;a<SectionsRead-1;a++){
hFile->PutC(0xff);
hFile->PutC((unsigned char)(Sections[a].Type));
hFile->Write(Sections[a].Data, Sections[a].Size, 1);
}
// Write the remaining image data.
hFile->Write(Sections[a].Data, Sections[a].Size, 1);
return true;
}
////////////////////////////////////////////////////////////////////////////////
void CxImageJPG::CxExifInfo::DiscardAllButExif()
{
Section_t ExifKeeper;
Section_t CommentKeeper;
int a;
memset(&ExifKeeper, 0, sizeof(ExifKeeper));
memset(&CommentKeeper, 0, sizeof(ExifKeeper));
for (a=0;a<SectionsRead;a++){
if (Sections[a].Type == M_EXIF && ExifKeeper.Type == 0){
ExifKeeper = Sections[a];
}else if (Sections[a].Type == M_COM && CommentKeeper.Type == 0){
CommentKeeper = Sections[a];
}else{
free(Sections[a].Data);
Sections[a].Data = 0;
}
}
SectionsRead = 0;
if (ExifKeeper.Type){
Sections[SectionsRead++] = ExifKeeper;
}
if (CommentKeeper.Type){
Sections[SectionsRead++] = CommentKeeper;
}
}
////////////////////////////////////////////////////////////////////////////////
void* CxImageJPG::CxExifInfo::FindSection(int SectionType)
{
int a;
for (a=0;a<SectionsRead-1;a++){
if (Sections[a].Type == SectionType){
return &Sections[a];
}
}
// Could not be found.
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGEJPG_SUPPORT_EXIF
+537
View File
@@ -0,0 +1,537 @@
// ximage.cpp : main implementation file
/* 07/08/2001 v1.00 - Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximage.h"
////////////////////////////////////////////////////////////////////////////////
// CxImage
////////////////////////////////////////////////////////////////////////////////
/**
* Initialize the internal structures
*/
void CxImage::Startup(DWORD imagetype)
{
//init pointers
pDib = pSelection = pAlpha = NULL;
ppLayers = ppFrames = NULL;
//init structures
memset(&head,0,sizeof(BITMAPINFOHEADER));
memset(&info,0,sizeof(CXIMAGEINFO));
//init default attributes
info.dwType = imagetype;
info.fQuality = 90.0f;
info.nAlphaMax = 255;
info.nBkgndIndex = -1;
info.bEnabled = true;
SetXDPI(CXIMAGE_DEFAULT_DPI);
SetYDPI(CXIMAGE_DEFAULT_DPI);
short test = 1;
info.bLittleEndianHost = (*((char *) &test) == 1);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Empty image constructor
* \param imagetype: (optional) set the image format, see ENUM_CXIMAGE_FORMATS
*/
CxImage::CxImage(DWORD imagetype)
{
Startup(imagetype);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Call this function to destroy image pixels, alpha channel, selection and sub layers.
* - Attributes are not erased, but IsValid returns false.
*
* \return true if everything is freed, false if the image is a Ghost
*/
bool CxImage::Destroy()
{
//free this only if it's valid and it's not a ghost
if (info.pGhost==NULL){
if (ppLayers) {
for(long n=0; n<info.nNumLayers;n++){ delete ppLayers[n]; }
delete [] ppLayers; ppLayers=0; info.nNumLayers = 0;
}
if (pSelection) {free(pSelection); pSelection=0;}
if (pAlpha) {free(pAlpha); pAlpha=0;}
if (pDib) {free(pDib); pDib=0;}
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::DestroyFrames()
{
if (info.pGhost==NULL) {
if (ppFrames) {
for (long n=0; n<info.nNumFrames; n++) { delete ppFrames[n]; }
delete [] ppFrames; ppFrames = NULL; info.nNumFrames = 0;
}
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sized image constructor
* \param dwWidth: width
* \param dwHeight: height
* \param wBpp: bit per pixel, can be 1, 4, 8, 24
* \param imagetype: (optional) set the image format, see ENUM_CXIMAGE_FORMATS
*/
CxImage::CxImage(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype)
{
Startup(imagetype);
Create(dwWidth,dwHeight,wBpp,imagetype);
}
////////////////////////////////////////////////////////////////////////////////
/**
* image constructor from existing source
* \param src: source image.
* \param copypixels: copy the pixels from the source image into the new image.
* \param copyselection: copy the selection from source
* \param copyalpha: copy the alpha channel from source
* \sa Copy
*/
CxImage::CxImage(const CxImage &src, bool copypixels, bool copyselection, bool copyalpha)
{
Startup(src.GetType());
Copy(src,copypixels,copyselection,copyalpha);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Copies the image from an exsisting source
* \param src: source image.
* \param copypixels: copy the pixels from the source image into the new image.
* \param copyselection: copy the selection from source
* \param copyalpha: copy the alpha channel from source
*/
void CxImage::Copy(const CxImage &src, bool copypixels, bool copyselection, bool copyalpha)
{
// if the source is a ghost, the copy is still a ghost
if (src.info.pGhost){
Ghost(&src);
return;
}
//copy the attributes
memcpy(&info,&src.info,sizeof(CXIMAGEINFO));
memcpy(&head,&src.head,sizeof(BITMAPINFOHEADER)); // [andy] - fix for bitmap header DPI
//rebuild the image
Create(src.GetWidth(),src.GetHeight(),src.GetBpp(),src.GetType());
//copy the pixels and the palette, or at least copy the palette only.
if (copypixels && pDib && src.pDib) memcpy(pDib,src.pDib,GetSize());
else SetPalette(src.GetPalette());
long nSize = head.biWidth * head.biHeight;
//copy the selection
if (copyselection && src.pSelection){
if (pSelection) free(pSelection);
pSelection = (BYTE*)malloc(nSize);
memcpy(pSelection,src.pSelection,nSize);
}
//copy the alpha channel
if (copyalpha && src.pAlpha){
if (pAlpha) free(pAlpha);
pAlpha = (BYTE*)malloc(nSize);
memcpy(pAlpha,src.pAlpha,nSize);
}
}
////////////////////////////////////////////////////////////////////////////////
/**
* Copies the image attributes from an existing image.
* - Works only on an empty image, and the image will be still empty.
* - <b> Use it before Create() </b>
*/
void CxImage::CopyInfo(const CxImage &src)
{
if (pDib==NULL) memcpy(&info,&src.info,sizeof(CXIMAGEINFO));
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa Copy
*/
CxImage& CxImage::operator = (const CxImage& isrc)
{
if (this != &isrc) Copy(isrc);
return *this;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Initializes or rebuilds the image.
* \param dwWidth: width
* \param dwHeight: height
* \param wBpp: bit per pixel, can be 1, 4, 8, 24
* \param imagetype: (optional) set the image format, see ENUM_CXIMAGE_FORMATS
* \return pointer to the internal pDib object; NULL if an error occurs.
*/
void* CxImage::Create(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype)
{
// destroy the existing image (if any)
if (!Destroy())
return NULL;
// prevent further actions if width or height are not vaild <Balabasnia>
if ((dwWidth == 0) || (dwHeight == 0)){
strcpy(info.szLastError,"CxImage::Create : width and height must be greater than zero");
return NULL;
}
// Make sure bits per pixel is valid
if (wBpp <= 1) wBpp = 1;
else if (wBpp <= 4) wBpp = 4;
else if (wBpp <= 8) wBpp = 8;
else wBpp = 24;
// limit memory requirements (and also a check for bad parameters)
if (((dwWidth*dwHeight*wBpp)>>3) > CXIMAGE_MAX_MEMORY ||
((dwWidth*dwHeight*wBpp)/wBpp) != (dwWidth*dwHeight))
{
strcpy(info.szLastError,"CXIMAGE_MAX_MEMORY exceeded");
return NULL;
}
// set the correct bpp value
switch (wBpp){
case 1:
head.biClrUsed = 2; break;
case 4:
head.biClrUsed = 16; break;
case 8:
head.biClrUsed = 256; break;
default:
head.biClrUsed = 0;
}
//set the common image informations
info.dwEffWidth = ((((wBpp * dwWidth) + 31) / 32) * 4);
info.dwType = imagetype;
// initialize BITMAPINFOHEADER
head.biSize = sizeof(BITMAPINFOHEADER); //<ralphw>
head.biWidth = dwWidth; // fill in width from parameter
head.biHeight = dwHeight; // fill in height from parameter
head.biPlanes = 1; // must be 1
head.biBitCount = (WORD)wBpp; // from parameter
head.biCompression = BI_RGB;
head.biSizeImage = info.dwEffWidth * dwHeight;
// head.biXPelsPerMeter = 0; See SetXDPI
// head.biYPelsPerMeter = 0; See SetYDPI
// head.biClrImportant = 0; See SetClrImportant
pDib = malloc(GetSize()); // alloc memory block to store our bitmap
if (!pDib){
strcpy(info.szLastError,"CxImage::Create can't allocate memory");
return NULL;
}
//clear the palette
RGBQUAD* pal=GetPalette();
if (pal) memset(pal,0,GetPaletteSize());
//Destroy the existing selection
#if CXIMAGE_SUPPORT_SELECTION
if (pSelection) SelectionDelete();
#endif //CXIMAGE_SUPPORT_SELECTION
//Destroy the existing alpha channel
#if CXIMAGE_SUPPORT_ALPHA
if (pAlpha) AlphaDelete();
#endif //CXIMAGE_SUPPORT_ALPHA
// use our bitmap info structure to fill in first part of
// our DIB with the BITMAPINFOHEADER
BITMAPINFOHEADER* lpbi;
lpbi = (BITMAPINFOHEADER*)(pDib);
*lpbi = head;
info.pImage=GetBits();
return pDib; //return handle to the DIB
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return pointer to the image pixels. <b> USE CAREFULLY </b>
*/
BYTE* CxImage::GetBits(DWORD row)
{
if (pDib){
if (row) {
if (row<(DWORD)head.biHeight){
return ((BYTE*)pDib + *(DWORD*)pDib + GetPaletteSize() + (info.dwEffWidth * row));
} else {
return NULL;
}
} else {
return ((BYTE*)pDib + *(DWORD*)pDib + GetPaletteSize());
}
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return the size in bytes of the internal pDib object
*/
long CxImage::GetSize()
{
return head.biSize + head.biSizeImage + GetPaletteSize();
}
////////////////////////////////////////////////////////////////////////////////
/**
* Checks if the coordinates are inside the image
* \return true if x and y are both inside the image
*/
bool CxImage::IsInside(long x, long y)
{
return (0<=y && y<head.biHeight && 0<=x && x<head.biWidth);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the image bits to the specified value
* - for indexed images, the output color is set by the palette entries.
* - for RGB images, the output color is a shade of gray.
*/
void CxImage::Clear(BYTE bval)
{
if (pDib == 0) return;
if (GetBpp() == 1){
if (bval > 0) bval = 255;
}
if (GetBpp() == 4){
bval = (BYTE)(17*(0x0F & bval));
}
memset(info.pImage,bval,head.biSizeImage);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Transfers the image from an existing source image. The source becomes empty.
* \return true if everything is ok
*/
bool CxImage::Transfer(CxImage &from, bool bTransferFrames /*=true*/)
{
if (!Destroy())
return false;
memcpy(&head,&from.head,sizeof(BITMAPINFOHEADER));
memcpy(&info,&from.info,sizeof(CXIMAGEINFO));
pDib = from.pDib;
pSelection = from.pSelection;
pAlpha = from.pAlpha;
ppLayers = from.ppLayers;
memset(&from.head,0,sizeof(BITMAPINFOHEADER));
memset(&from.info,0,sizeof(CXIMAGEINFO));
from.pDib = from.pSelection = from.pAlpha = NULL;
from.ppLayers = NULL;
if (bTransferFrames){
DestroyFrames();
ppFrames = from.ppFrames;
from.ppFrames = NULL;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/**
* (this) points to the same pDib owned by (*from), the image remains in (*from)
* but (this) has the access to the pixels. <b>Use carefully !!!</b>
*/
void CxImage::Ghost(const CxImage *from)
{
if (from){
memcpy(&head,&from->head,sizeof(BITMAPINFOHEADER));
memcpy(&info,&from->info,sizeof(CXIMAGEINFO));
pDib = from->pDib;
pSelection = from->pSelection;
pAlpha = from->pAlpha;
ppLayers = from->ppLayers;
ppFrames = from->ppFrames;
info.pGhost=(CxImage *)from;
}
}
////////////////////////////////////////////////////////////////////////////////
/**
* turns a 16 or 32 bit bitfield image into a RGB image
*/
void CxImage::Bitfield2RGB(BYTE *src, DWORD redmask, DWORD greenmask, DWORD bluemask, BYTE bpp)
{
switch (bpp){
case 16:
{
DWORD ns[3]={0,0,0};
// compute the number of shift for each mask
for (int i=0;i<16;i++){
if ((redmask>>i)&0x01) ns[0]++;
if ((greenmask>>i)&0x01) ns[1]++;
if ((bluemask>>i)&0x01) ns[2]++;
}
ns[1]+=ns[0]; ns[2]+=ns[1]; ns[0]=8-ns[0]; ns[1]-=8; ns[2]-=8;
// dword aligned width for 16 bit image
long effwidth2=(((head.biWidth + 1) / 2) * 4);
WORD w;
long y2,y3,x2,x3;
BYTE *p=info.pImage;
// scan the buffer in reverse direction to avoid reallocations
for (long y=head.biHeight-1; y>=0; y--){
y2=effwidth2*y;
y3=info.dwEffWidth*y;
for (long x=head.biWidth-1; x>=0; x--){
x2 = 2*x+y2;
x3 = 3*x+y3;
w = (WORD)(src[x2]+256*src[1+x2]);
p[ x3]=(BYTE)((w & bluemask)<<ns[0]);
p[1+x3]=(BYTE)((w & greenmask)>>ns[1]);
p[2+x3]=(BYTE)((w & redmask)>>ns[2]);
}
}
break;
}
case 32:
{
DWORD ns[3]={0,0,0};
// compute the number of shift for each mask
for (int i=8;i<32;i+=8){
if (redmask>>i) ns[0]++;
if (greenmask>>i) ns[1]++;
if (bluemask>>i) ns[2]++;
}
// dword aligned width for 32 bit image
long effwidth4 = head.biWidth * 4;
long y4,y3,x4,x3;
BYTE *p=info.pImage;
// scan the buffer in reverse direction to avoid reallocations
for (long y=head.biHeight-1; y>=0; y--){
y4=effwidth4*y;
y3=info.dwEffWidth*y;
for (long x=head.biWidth-1; x>=0; x--){
x4 = 4*x+y4;
x3 = 3*x+y3;
p[ x3]=src[ns[2]+x4];
p[1+x3]=src[ns[1]+x4];
p[2+x3]=src[ns[0]+x4];
}
}
}
}
return;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Creates an image from a generic buffer
* \param pArray: source memory buffer
* \param dwWidth: image width
* \param dwHeight: image height
* \param dwBitsperpixel: can be 1,4,8,24,32
* \param dwBytesperline: line alignment, in bytes, for a single row stored in pArray
* \param bFlipImage: tune this parameter if the image is upsidedown
* \return true if everything is ok
*/
bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage)
{
if (pArray==NULL) return false;
if (!((dwBitsperpixel==1)||(dwBitsperpixel==4)||(dwBitsperpixel==8)||
(dwBitsperpixel==24)||(dwBitsperpixel==32))) return false;
if (!Create(dwWidth,dwHeight,dwBitsperpixel)) return false;
if (dwBitsperpixel<24) SetGrayPalette();
#if CXIMAGE_SUPPORT_ALPHA
if (dwBitsperpixel==32) AlphaCreate();
#endif //CXIMAGE_SUPPORT_ALPHA
BYTE *dst,*src;
for (DWORD y = 0; y<dwHeight; y++) {
dst = info.pImage + (bFlipImage?(dwHeight-1-y):y) * info.dwEffWidth;
src = pArray + y * dwBytesperline;
if (dwBitsperpixel==32){
for(DWORD x=0;x<dwWidth;x++){
*dst++=src[0];
*dst++=src[1];
*dst++=src[2];
#if CXIMAGE_SUPPORT_ALPHA
AlphaSet(x,(bFlipImage?(dwHeight-1-y):y),src[3]);
#endif //CXIMAGE_SUPPORT_ALPHA
src+=4;
}
} else {
memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa CreateFromArray
*/
bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage)
{
if (ppMatrix==NULL) return false;
if (!((dwBitsperpixel==1)||(dwBitsperpixel==4)||(dwBitsperpixel==8)||
(dwBitsperpixel==24)||(dwBitsperpixel==32))) return false;
if (!Create(dwWidth,dwHeight,dwBitsperpixel)) return false;
if (dwBitsperpixel<24) SetGrayPalette();
#if CXIMAGE_SUPPORT_ALPHA
if (dwBitsperpixel==32) AlphaCreate();
#endif //CXIMAGE_SUPPORT_ALPHA
BYTE *dst,*src;
for (DWORD y = 0; y<dwHeight; y++) {
dst = info.pImage + (bFlipImage?(dwHeight-1-y):y) * info.dwEffWidth;
src = ppMatrix[y];
if (src){
if (dwBitsperpixel==32){
for(DWORD x=0;x<dwWidth;x++){
*dst++=src[0];
*dst++=src[1];
*dst++=src[2];
#if CXIMAGE_SUPPORT_ALPHA
AlphaSet(x,(bFlipImage?(dwHeight-1-y):y),src[3]);
#endif //CXIMAGE_SUPPORT_ALPHA
src+=4;
}
} else {
memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
}
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return lightness difference between elem1 and elem2
*/
int CxImage::CompareColors(const void *elem1, const void *elem2)
{
RGBQUAD* c1 = (RGBQUAD*)elem1;
RGBQUAD* c2 = (RGBQUAD*)elem2;
int g1 = (int)RGB2GRAY(c1->rgbRed,c1->rgbGreen,c1->rgbBlue);
int g2 = (int)RGB2GRAY(c2->rgbRed,c2->rgbGreen,c2->rgbBlue);
return (g1-g2);
}
////////////////////////////////////////////////////////////////////////////////
/**
* simply calls "if (memblock) free(memblock);".
* Useful when calling Encode for a memory buffer,
* from a DLL compiled with different memory management options.
* CxImage::FreeMemory will use the same memory environment used by Encode.
* \author [livecn]
*/
void CxImage::FreeMemory(void* memblock)
{
if (memblock)
free(memblock);
}
////////////////////////////////////////////////////////////////////////////////
//EOF
+735
View File
@@ -0,0 +1,735 @@
/*
* File: ximage.h
* Purpose: General Purpose Image Class
*/
/*
--------------------------------------------------------------------------------
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
CxImage version 6.0.0 02/Feb/2008
CxImage : Copyright (C) 2001 - 2008, Davide Pizzolato
Original CImage and CImageIterator implementation are:
Copyright (C) 1995, Alejandro Aguilar Sierra (asierra(at)servidor(dot)unam(dot)mx)
Covered code is provided under this license on an "as is" basis, without warranty
of any kind, either expressed or implied, including, without limitation, warranties
that the covered code is free of defects, merchantable, fit for a particular purpose
or non-infringing. The entire risk as to the quality and performance of the covered
code is with you. Should any covered code prove defective in any respect, you (not
the initial developer or any other contributor) assume the cost of any necessary
servicing, repair or correction. This disclaimer of warranty constitutes an essential
part of this license. No use of any covered code is authorized hereunder except under
this disclaimer.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, including commercial applications,
freely and without fee, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
Other information about CxImage, and the latest version, can be found at the
CxImage home page: http://www.xdp.it/cximage/
--------------------------------------------------------------------------------
*/
#if !defined(__CXIMAGE_H)
#define __CXIMAGE_H
#if _MSC_VER > 1000
#pragma once
#endif
/////////////////////////////////////////////////////////////////////////////
#include "xfile.h"
#include "xiofile.h"
#include "xmemfile.h"
#include "ximadef.h" //<vho> adjust some #define
/* see "ximacfg.h" for CxImage configuration options */
/////////////////////////////////////////////////////////////////////////////
// CxImage formats enumerator
enum ENUM_CXIMAGE_FORMATS{
CXIMAGE_FORMAT_UNKNOWN = 0,
#if CXIMAGE_SUPPORT_BMP
CXIMAGE_FORMAT_BMP = 1,
#endif
#if CXIMAGE_SUPPORT_GIF
CXIMAGE_FORMAT_GIF = 2,
#endif
#if CXIMAGE_SUPPORT_JPG
CXIMAGE_FORMAT_JPG = 3,
#endif
#if CXIMAGE_SUPPORT_PNG
CXIMAGE_FORMAT_PNG = 4,
#endif
#if CXIMAGE_SUPPORT_ICO
CXIMAGE_FORMAT_ICO = 5,
#endif
#if CXIMAGE_SUPPORT_TIF
CXIMAGE_FORMAT_TIF = 6,
#endif
#if CXIMAGE_SUPPORT_TGA
CXIMAGE_FORMAT_TGA = 7,
#endif
#if CXIMAGE_SUPPORT_PCX
CXIMAGE_FORMAT_PCX = 8,
#endif
#if CXIMAGE_SUPPORT_WBMP
CXIMAGE_FORMAT_WBMP = 9,
#endif
#if CXIMAGE_SUPPORT_WMF
CXIMAGE_FORMAT_WMF = 10,
#endif
#if CXIMAGE_SUPPORT_JP2
CXIMAGE_FORMAT_JP2 = 11,
#endif
#if CXIMAGE_SUPPORT_JPC
CXIMAGE_FORMAT_JPC = 12,
#endif
#if CXIMAGE_SUPPORT_PGX
CXIMAGE_FORMAT_PGX = 13,
#endif
#if CXIMAGE_SUPPORT_PNM
CXIMAGE_FORMAT_PNM = 14,
#endif
#if CXIMAGE_SUPPORT_RAS
CXIMAGE_FORMAT_RAS = 15,
#endif
#if CXIMAGE_SUPPORT_JBG
CXIMAGE_FORMAT_JBG = 16,
#endif
#if CXIMAGE_SUPPORT_MNG
CXIMAGE_FORMAT_MNG = 17,
#endif
#if CXIMAGE_SUPPORT_SKA
CXIMAGE_FORMAT_SKA = 18,
#endif
#if CXIMAGE_SUPPORT_RAW
CXIMAGE_FORMAT_RAW = 19,
#endif
CMAX_IMAGE_FORMATS = CXIMAGE_SUPPORT_BMP + CXIMAGE_SUPPORT_GIF + CXIMAGE_SUPPORT_JPG +
CXIMAGE_SUPPORT_PNG + CXIMAGE_SUPPORT_MNG + CXIMAGE_SUPPORT_ICO +
CXIMAGE_SUPPORT_TIF + CXIMAGE_SUPPORT_TGA + CXIMAGE_SUPPORT_PCX +
CXIMAGE_SUPPORT_WBMP+ CXIMAGE_SUPPORT_WMF +
CXIMAGE_SUPPORT_JBG + CXIMAGE_SUPPORT_JP2 + CXIMAGE_SUPPORT_JPC +
CXIMAGE_SUPPORT_PGX + CXIMAGE_SUPPORT_PNM + CXIMAGE_SUPPORT_RAS +
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + 1
};
/////////////////////////////////////////////////////////////////////////////
// CxImage class
/////////////////////////////////////////////////////////////////////////////
class DLL_EXP CxImage
{
//extensible information collector
typedef struct tagCxImageInfo {
DWORD dwEffWidth; ///< DWORD aligned scan line width
BYTE* pImage; ///< THE IMAGE BITS
CxImage* pGhost; ///< if this is a ghost, pGhost points to the body
CxImage* pParent; ///< if this is a layer, pParent points to the body
DWORD dwType; ///< original image format
char szLastError[256]; ///< debugging
long nProgress; ///< monitor
long nEscape; ///< escape
long nBkgndIndex; ///< used for GIF, PNG, MNG
RGBQUAD nBkgndColor; ///< used for RGB transparency
float fQuality; ///< used for JPEG, JPEG2000 (0.0f ... 100.0f)
BYTE nJpegScale; ///< used for JPEG [ignacio]
long nFrame; ///< used for TIF, GIF, MNG : actual frame
long nNumFrames; ///< used for TIF, GIF, MNG : total number of frames
DWORD dwFrameDelay; ///< used for GIF, MNG
long xDPI; ///< horizontal resolution
long yDPI; ///< vertical resolution
RECT rSelectionBox; ///< bounding rectangle
BYTE nAlphaMax; ///< max opacity (fade)
bool bAlphaPaletteEnabled; ///< true if alpha values in the palette are enabled.
bool bEnabled; ///< enables the painting functions
long xOffset;
long yOffset;
DWORD dwCodecOpt[CMAX_IMAGE_FORMATS]; ///< for GIF, TIF : 0=def.1=unc,2=fax3,3=fax4,4=pack,5=jpg
RGBQUAD last_c; ///< for GetNearestIndex optimization
BYTE last_c_index;
bool last_c_isvalid;
long nNumLayers;
DWORD dwFlags; ///< 0x??00000 = reserved, 0x00??0000 = blend mode, 0x0000???? = layer id - user flags
BYTE dispmeth;
bool bGetAllFrames;
bool bLittleEndianHost;
} CXIMAGEINFO;
public:
//public structures
struct rgb_color { BYTE r,g,b; };
#if CXIMAGE_SUPPORT_WINDOWS
// <VATI> text placement data
// members must be initialized with the InitTextInfo(&this) function.
typedef struct tagCxTextInfo
{
#if defined (_WIN32_WCE)
TCHAR text[256]; ///< text for windows CE
#else
TCHAR text[4096]; ///< text (char -> TCHAR for UNICODE [Cesar M])
#endif
LOGFONT lfont; ///< font and codepage data
COLORREF fcolor; ///< foreground color
long align; ///< DT_CENTER, DT_RIGHT, DT_LEFT aligment for multiline text
BYTE smooth; ///< text smoothing option. Default is false.
BYTE opaque; ///< text has background or hasn't. Default is true.
///< data for background (ignored if .opaque==FALSE)
COLORREF bcolor; ///< background color
float b_opacity; ///< opacity value for background between 0.0-1.0 Default is 0. (opaque)
BYTE b_outline; ///< outline width for background (zero: no outline)
BYTE b_round; ///< rounding radius for background rectangle. % of the height, between 0-50. Default is 10.
///< (backgr. always has a frame: width = 3 pixel + 10% of height by default.)
} CXTEXTINFO;
#endif
public:
/** \addtogroup Constructors */ //@{
CxImage(DWORD imagetype = 0);
CxImage(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0);
CxImage(const CxImage &src, bool copypixels = true, bool copyselection = true, bool copyalpha = true);
CxImage(const TCHAR * filename, DWORD imagetype); // For UNICODE support: char -> TCHAR
CxImage(FILE * stream, DWORD imagetype);
CxImage(CxFile * stream, DWORD imagetype);
CxImage(BYTE * buffer, DWORD size, DWORD imagetype);
virtual ~CxImage() { DestroyFrames(); Destroy(); };
CxImage& operator = (const CxImage&);
//@}
/** \addtogroup Initialization */ //@{
void* Create(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0);
bool Destroy();
bool DestroyFrames();
void Clear(BYTE bval=0);
void Copy(const CxImage &src, bool copypixels = true, bool copyselection = true, bool copyalpha = true);
bool Transfer(CxImage &from, bool bTransferFrames = true);
bool CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);
bool CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);
void FreeMemory(void* memblock);
DWORD Dump(BYTE * dst);
DWORD UnDump(const BYTE * src);
DWORD DumpSize();
//@}
/** \addtogroup Attributes */ //@{
long GetSize();
BYTE* GetBits(DWORD row = 0);
BYTE GetColorType();
void* GetDIB() const;
DWORD GetHeight() const;
DWORD GetWidth() const;
DWORD GetEffWidth() const;
DWORD GetNumColors() const;
WORD GetBpp() const;
DWORD GetType() const;
const char* GetLastError();
static const TCHAR* GetVersion();
static const float GetVersionNumber();
DWORD GetFrameDelay() const;
void SetFrameDelay(DWORD d);
void GetOffset(long *x,long *y);
void SetOffset(long x,long y);
BYTE GetJpegQuality() const;
void SetJpegQuality(BYTE q);
float GetJpegQualityF() const;
void SetJpegQualityF(float q);
BYTE GetJpegScale() const;
void SetJpegScale(BYTE q);
long GetXDPI() const;
long GetYDPI() const;
void SetXDPI(long dpi);
void SetYDPI(long dpi);
DWORD GetClrImportant() const;
void SetClrImportant(DWORD ncolors = 0);
long GetProgress() const;
long GetEscape() const;
void SetProgress(long p);
void SetEscape(long i);
long GetTransIndex() const;
RGBQUAD GetTransColor();
void SetTransIndex(long idx);
void SetTransColor(RGBQUAD rgb);
bool IsTransparent() const;
DWORD GetCodecOption(DWORD imagetype = 0);
bool SetCodecOption(DWORD opt, DWORD imagetype = 0);
DWORD GetFlags() const;
void SetFlags(DWORD flags, bool bLockReservedFlags = true);
BYTE GetDisposalMethod() const;
void SetDisposalMethod(BYTE dm);
bool SetType(DWORD type);
static DWORD GetNumTypes();
static DWORD GetTypeIdFromName(const TCHAR* ext);
static DWORD GetTypeIdFromIndex(const DWORD index);
static DWORD GetTypeIndexFromId(const DWORD id);
bool GetRetreiveAllFrames() const;
void SetRetreiveAllFrames(bool flag);
CxImage * GetFrame(long nFrame) const;
//void* GetUserData() const {return info.pUserData;}
//void SetUserData(void* pUserData) {info.pUserData = pUserData;}
//@}
/** \addtogroup Palette
* These functions have no effects on RGB images and in this case the returned value is always 0.
* @{ */
bool IsGrayScale();
bool IsIndexed() const;
bool IsSamePalette(CxImage &img, bool bCheckAlpha = true);
DWORD GetPaletteSize();
RGBQUAD* GetPalette() const;
RGBQUAD GetPaletteColor(BYTE idx);
bool GetPaletteColor(BYTE i, BYTE* r, BYTE* g, BYTE* b);
BYTE GetNearestIndex(RGBQUAD c);
void BlendPalette(COLORREF cr,long perc);
void SetGrayPalette();
void SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b);
void SetPalette(RGBQUAD* pPal,DWORD nColors=256);
void SetPalette(rgb_color *rgb,DWORD nColors=256);
void SetPaletteColor(BYTE idx, BYTE r, BYTE g, BYTE b, BYTE alpha=0);
void SetPaletteColor(BYTE idx, RGBQUAD c);
void SetPaletteColor(BYTE idx, COLORREF cr);
void SwapIndex(BYTE idx1, BYTE idx2);
void SwapRGB2BGR();
void SetStdPalette();
//@}
/** \addtogroup Pixel */ //@{
bool IsInside(long x, long y);
bool IsTransparent(long x,long y);
bool GetTransparentMask(CxImage* iDst = 0);
RGBQUAD GetPixelColor(long x,long y, bool bGetAlpha = true);
BYTE GetPixelIndex(long x,long y);
BYTE GetPixelGray(long x, long y);
void SetPixelColor(long x,long y,RGBQUAD c, bool bSetAlpha = false);
void SetPixelColor(long x,long y,COLORREF cr);
void SetPixelIndex(long x,long y,BYTE i);
void DrawLine(int StartX, int EndX, int StartY, int EndY, RGBQUAD color, bool bSetAlpha=false);
void DrawLine(int StartX, int EndX, int StartY, int EndY, COLORREF cr);
void BlendPixelColor(long x,long y,RGBQUAD c, float blend, bool bSetAlpha = false);
//@}
protected:
/** \addtogroup Protected */ //@{
BYTE BlindGetPixelIndex(const long x,const long y);
RGBQUAD BlindGetPixelColor(const long x,const long y, bool bGetAlpha = true);
void *BlindGetPixelPointer(const long x,const long y);
void BlindSetPixelColor(long x,long y,RGBQUAD c, bool bSetAlpha = false);
void BlindSetPixelIndex(long x,long y,BYTE i);
//@}
public:
#if CXIMAGE_SUPPORT_INTERPOLATION
/** \addtogroup Interpolation */ //@{
//overflow methods:
enum OverflowMethod {
OM_COLOR=1,
OM_BACKGROUND=2,
OM_TRANSPARENT=3,
OM_WRAP=4,
OM_REPEAT=5,
OM_MIRROR=6
};
void OverflowCoordinates(float &x, float &y, OverflowMethod const ofMethod);
void OverflowCoordinates(long &x, long &y, OverflowMethod const ofMethod);
RGBQUAD GetPixelColorWithOverflow(long x, long y, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD* const rplColor=0);
//interpolation methods:
enum InterpolationMethod {
IM_NEAREST_NEIGHBOUR=1,
IM_BILINEAR =2,
IM_BSPLINE =3,
IM_BICUBIC =4,
IM_BICUBIC2 =5,
IM_LANCZOS =6,
IM_BOX =7,
IM_HERMITE =8,
IM_HAMMING =9,
IM_SINC =10,
IM_BLACKMAN =11,
IM_BESSEL =12,
IM_GAUSSIAN =13,
IM_QUADRATIC =14,
IM_MITCHELL =15,
IM_CATROM =16,
IM_HANNING =17,
IM_POWER =18
};
RGBQUAD GetPixelColorInterpolated(float x,float y, InterpolationMethod const inMethod=IM_BILINEAR, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD* const rplColor=0);
RGBQUAD GetAreaColorInterpolated(float const xc, float const yc, float const w, float const h, InterpolationMethod const inMethod, OverflowMethod const ofMethod=OM_BACKGROUND, RGBQUAD* const rplColor=0);
//@}
protected:
/** \addtogroup Protected */ //@{
void AddAveragingCont(RGBQUAD const &color, float const surf, float &rr, float &gg, float &bb, float &aa);
//@}
/** \addtogroup Kernels */ //@{
public:
static float KernelBSpline(const float x);
static float KernelLinear(const float t);
static float KernelCubic(const float t);
static float KernelGeneralizedCubic(const float t, const float a=-1);
static float KernelLanczosSinc(const float t, const float r = 3);
static float KernelBox(const float x);
static float KernelHermite(const float x);
static float KernelHamming(const float x);
static float KernelSinc(const float x);
static float KernelBlackman(const float x);
static float KernelBessel_J1(const float x);
static float KernelBessel_P1(const float x);
static float KernelBessel_Q1(const float x);
static float KernelBessel_Order1(float x);
static float KernelBessel(const float x);
static float KernelGaussian(const float x);
static float KernelQuadratic(const float x);
static float KernelMitchell(const float x);
static float KernelCatrom(const float x);
static float KernelHanning(const float x);
static float KernelPower(const float x, const float a = 2);
//@}
#endif //CXIMAGE_SUPPORT_INTERPOLATION
/** \addtogroup Painting */ //@{
#if CXIMAGE_SUPPORT_WINDOWS
long Blt(HDC pDC, long x=0, long y=0);
HBITMAP MakeBitmap(HDC hdc = NULL);
HANDLE CopyToHandle();
bool CreateFromHANDLE(HANDLE hMem); //Windows objects (clipboard)
bool CreateFromHBITMAP(HBITMAP hbmp, HPALETTE hpal=0); //Windows resource
bool CreateFromHICON(HICON hico);
long Draw(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0, bool bSmooth = false);
long Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL, bool bSmooth = false);
long Stretch(HDC hdc, long xoffset, long yoffset, long xsize, long ysize, DWORD dwRop = SRCCOPY);
long Stretch(HDC hdc, const RECT& rect, DWORD dwRop = SRCCOPY);
long Tile(HDC hdc, RECT *rc);
long Draw2(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1);
long Draw2(HDC hdc, const RECT& rect);
//long DrawString(HDC hdc, long x, long y, const char* text, RGBQUAD color, const char* font, long lSize=0, long lWeight=400, BYTE bItalic=0, BYTE bUnderline=0, bool bSetAlpha=false);
long DrawString(HDC hdc, long x, long y, const TCHAR* text, RGBQUAD color, const TCHAR* font, long lSize=0, long lWeight=400, BYTE bItalic=0, BYTE bUnderline=0, bool bSetAlpha=false);
// <VATI> extensions
long DrawStringEx(HDC hdc, long x, long y, CXTEXTINFO *pTextType, bool bSetAlpha=false );
void InitTextInfo( CXTEXTINFO *txt );
#endif //CXIMAGE_SUPPORT_WINDOWS
//@}
// file operations
#if CXIMAGE_SUPPORT_DECODE
/** \addtogroup Decode */ //@{
#ifdef WIN32
//bool Load(LPCWSTR filename, DWORD imagetype=0);
bool LoadResource(HRSRC hRes, DWORD imagetype, HMODULE hModule=NULL);
#endif
// For UNICODE support: char -> TCHAR
bool Load(const TCHAR* filename, DWORD imagetype=0);
//bool Load(const char * filename, DWORD imagetype=0);
bool Decode(FILE * hFile, DWORD imagetype);
bool Decode(CxFile * hFile, DWORD imagetype);
bool Decode(BYTE * buffer, DWORD size, DWORD imagetype);
bool CheckFormat(CxFile * hFile, DWORD imagetype = 0);
bool CheckFormat(BYTE * buffer, DWORD size, DWORD imagetype = 0);
//@}
#endif //CXIMAGE_SUPPORT_DECODE
#if CXIMAGE_SUPPORT_ENCODE
protected:
/** \addtogroup Protected */ //@{
bool EncodeSafeCheck(CxFile *hFile);
//@}
public:
/** \addtogroup Encode */ //@{
#ifdef WIN32
//bool Save(LPCWSTR filename, DWORD imagetype=0);
#endif
// For UNICODE support: char -> TCHAR
bool Save(const TCHAR* filename, DWORD imagetype);
//bool Save(const char * filename, DWORD imagetype=0);
bool Encode(FILE * hFile, DWORD imagetype);
bool Encode(CxFile * hFile, DWORD imagetype);
bool Encode(CxFile * hFile, CxImage ** pImages, int pagecount, DWORD imagetype);
bool Encode(FILE *hFile, CxImage ** pImages, int pagecount, DWORD imagetype);
bool Encode(BYTE * &buffer, long &size, DWORD imagetype);
bool Encode2RGBA(CxFile *hFile, bool bFlipY = false);
bool Encode2RGBA(BYTE * &buffer, long &size, bool bFlipY = false);
//@}
#endif //CXIMAGE_SUPPORT_ENCODE
/** \addtogroup Attributes */ //@{
//misc.
bool IsValid() const;
bool IsEnabled() const;
void Enable(bool enable=true);
// frame operations
long GetNumFrames() const;
long GetFrame() const;
void SetFrame(long nFrame);
//@}
#if CXIMAGE_SUPPORT_BASICTRANSFORMATIONS
/** \addtogroup BasicTransformations */ //@{
bool GrayScale();
bool Flip(bool bFlipSelection = false, bool bFlipAlpha = true);
bool Mirror(bool bMirrorSelection = false, bool bMirrorAlpha = true);
bool Negative();
bool RotateLeft(CxImage* iDst = NULL);
bool RotateRight(CxImage* iDst = NULL);
//@}
#endif //CXIMAGE_SUPPORT_BASICTRANSFORMATIONS
#if CXIMAGE_SUPPORT_TRANSFORMATION
/** \addtogroup Transformations */ //@{
// image operations
bool Rotate(float angle, CxImage* iDst = NULL);
bool Rotate2(float angle, CxImage *iDst = NULL, InterpolationMethod inMethod=IM_BILINEAR,
OverflowMethod ofMethod=OM_BACKGROUND, RGBQUAD *replColor=0,
bool const optimizeRightAngles=true, bool const bKeepOriginalSize=false);
bool Rotate180(CxImage* iDst = NULL);
bool Resample(long newx, long newy, int mode = 1, CxImage* iDst = NULL);
bool Resample2(long newx, long newy, InterpolationMethod const inMethod=IM_BICUBIC2,
OverflowMethod const ofMethod=OM_REPEAT, CxImage* const iDst = NULL,
bool const disableAveraging=false);
bool DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal = 0, DWORD clrimportant = 0);
bool IncreaseBpp(DWORD nbit);
bool Dither(long method = 0);
bool Crop(long left, long top, long right, long bottom, CxImage* iDst = NULL);
bool Crop(const RECT& rect, CxImage* iDst = NULL);
bool CropRotatedRectangle( long topx, long topy, long width, long height, float angle, CxImage* iDst = NULL);
bool Skew(float xgain, float ygain, long xpivot=0, long ypivot=0, bool bEnableInterpolation = false);
bool Expand(long left, long top, long right, long bottom, RGBQUAD canvascolor, CxImage* iDst = 0);
bool Expand(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0);
bool Thumbnail(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0);
bool CircleTransform(int type,long rmax=0,float Koeff=1.0f);
bool RedEyeRemove(float strength = 0.8f);
bool QIShrink(long newx, long newy, CxImage* const iDst = NULL, bool bChangeBpp = false);
//@}
#endif //CXIMAGE_SUPPORT_TRANSFORMATION
#if CXIMAGE_SUPPORT_DSP
/** \addtogroup DSP */ //@{
bool Contour();
bool HistogramStretch(long method = 0, double threshold = 0);
bool HistogramEqualize();
bool HistogramNormalize();
bool HistogramRoot();
bool HistogramLog();
long Histogram(long* red, long* green = 0, long* blue = 0, long* gray = 0, long colorspace = 0);
bool Jitter(long radius=2);
bool Repair(float radius = 0.25f, long niterations = 1, long colorspace = 0);
bool Combine(CxImage* r,CxImage* g,CxImage* b,CxImage* a, long colorspace = 0);
bool FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage* dstImag, long direction = 1, bool bForceFFT = true, bool bMagnitude = true);
bool Noise(long level);
bool Median(long Ksize=3);
bool Gamma(float gamma);
bool GammaRGB(float gammaR, float gammaG, float gammaB);
bool ShiftRGB(long r, long g, long b);
bool Threshold(BYTE level);
bool Threshold(CxImage* pThresholdMask);
bool Threshold2(BYTE level, bool bDirection, RGBQUAD nBkgndColor, bool bSetAlpha = false);
bool Colorize(BYTE hue, BYTE sat, float blend = 1.0f);
bool Light(long brightness, long contrast = 0);
float Mean();
bool Filter(long* kernel, long Ksize, long Kfactor, long Koffset);
bool Erode(long Ksize=2);
bool Dilate(long Ksize=2);
bool Edge(long Ksize=2);
void HuePalette(float correction=1);
enum ImageOpType { OpAdd, OpAnd, OpXor, OpOr, OpMask, OpSrcCopy, OpDstCopy, OpSub, OpSrcBlend, OpScreen, OpAvg };
void Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset = 0, long lYOffset = 0, bool bMixAlpha = false);
void MixFrom(CxImage & imagesrc2, long lXOffset, long lYOffset);
bool UnsharpMask(float radius = 5.0f, float amount = 0.5f, int threshold = 0);
bool Lut(BYTE* pLut);
bool Lut(BYTE* pLutR, BYTE* pLutG, BYTE* pLutB, BYTE* pLutA = 0);
bool GaussianBlur(float radius = 1.0f, CxImage* iDst = 0);
bool TextBlur(BYTE threshold = 100, BYTE decay = 2, BYTE max_depth = 5, bool bBlurHorizontal = true, bool bBlurVertical = true, CxImage* iDst = 0);
bool SelectiveBlur(float radius = 1.0f, BYTE threshold = 25, CxImage* iDst = 0);
bool Solarize(BYTE level = 128, bool bLinkedChannels = true);
bool FloodFill(const long xStart, const long yStart, const RGBQUAD cFillColor, const BYTE tolerance = 0,
BYTE nOpacity = 255, const bool bSelectFilledArea = false, const BYTE nSelectionLevel = 255);
bool Saturate(const long saturation, const long colorspace = 1);
bool ConvertColorSpace(const long dstColorSpace, const long srcColorSpace);
int OptimalThreshold(long method = 0, RECT * pBox = 0, CxImage* pContrastMask = 0);
bool AdaptiveThreshold(long method = 0, long nBoxSize = 64, CxImage* pContrastMask = 0, long nBias = 0, float fGlobalLocalBalance = 0.5f);
//@}
protected:
/** \addtogroup Protected */ //@{
bool IsPowerof2(long x);
bool FFT(int dir,int m,double *x,double *y);
bool DFT(int dir,long m,double *x1,double *y1,double *x2,double *y2);
bool RepairChannel(CxImage *ch, float radius);
// <nipper>
int gen_convolve_matrix (float radius, float **cmatrix_p);
float* gen_lookup_table (float *cmatrix, int cmatrix_length);
void blur_line (float *ctable, float *cmatrix, int cmatrix_length, BYTE* cur_col, BYTE* dest_col, int y, long bytes);
void blur_text (BYTE threshold, BYTE decay, BYTE max_depth, CxImage* iSrc, CxImage* iDst, BYTE bytes);
//@}
public:
/** \addtogroup ColorSpace */ //@{
bool SplitRGB(CxImage* r,CxImage* g,CxImage* b);
bool SplitYUV(CxImage* y,CxImage* u,CxImage* v);
bool SplitHSL(CxImage* h,CxImage* s,CxImage* l);
bool SplitYIQ(CxImage* y,CxImage* i,CxImage* q);
bool SplitXYZ(CxImage* x,CxImage* y,CxImage* z);
bool SplitCMYK(CxImage* c,CxImage* m,CxImage* y,CxImage* k);
static RGBQUAD HSLtoRGB(COLORREF cHSLColor);
static RGBQUAD RGBtoHSL(RGBQUAD lRGBColor);
static RGBQUAD HSLtoRGB(RGBQUAD lHSLColor);
static RGBQUAD YUVtoRGB(RGBQUAD lYUVColor);
static RGBQUAD RGBtoYUV(RGBQUAD lRGBColor);
static RGBQUAD YIQtoRGB(RGBQUAD lYIQColor);
static RGBQUAD RGBtoYIQ(RGBQUAD lRGBColor);
static RGBQUAD XYZtoRGB(RGBQUAD lXYZColor);
static RGBQUAD RGBtoXYZ(RGBQUAD lRGBColor);
#endif //CXIMAGE_SUPPORT_DSP
static RGBQUAD RGBtoRGBQUAD(COLORREF cr);
static COLORREF RGBQUADtoRGB (RGBQUAD c);
//@}
#if CXIMAGE_SUPPORT_SELECTION
/** \addtogroup Selection */ //@{
bool SelectionClear(BYTE level = 0);
bool SelectionCreate();
bool SelectionDelete();
bool SelectionInvert();
bool SelectionMirror();
bool SelectionFlip();
bool SelectionAddRect(RECT r, BYTE level = 255);
bool SelectionAddEllipse(RECT r, BYTE level = 255);
bool SelectionAddPolygon(POINT *points, long npoints, BYTE level = 255);
bool SelectionAddColor(RGBQUAD c, BYTE level = 255);
bool SelectionAddPixel(long x, long y, BYTE level = 255);
bool SelectionCopy(CxImage &from);
bool SelectionIsInside(long x, long y);
bool SelectionIsValid();
void SelectionGetBox(RECT& r);
bool SelectionToHRGN(HRGN& region);
bool SelectionSplit(CxImage *dest);
BYTE SelectionGet(const long x,const long y);
bool SelectionSet(CxImage &from);
void SelectionRebuildBox();
BYTE* SelectionGetPointer(const long x = 0,const long y = 0);
//@}
protected:
/** \addtogroup Protected */ //@{
bool BlindSelectionIsInside(long x, long y);
BYTE BlindSelectionGet(const long x,const long y);
void SelectionSet(const long x,const long y,const BYTE level);
//@}
public:
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
/** \addtogroup Alpha */ //@{
void AlphaClear();
bool AlphaCreate();
void AlphaDelete();
void AlphaInvert();
bool AlphaMirror();
bool AlphaFlip();
bool AlphaCopy(CxImage &from);
bool AlphaSplit(CxImage *dest);
void AlphaStrip();
void AlphaSet(BYTE level);
bool AlphaSet(CxImage &from);
void AlphaSet(const long x,const long y,const BYTE level);
BYTE AlphaGet(const long x,const long y);
BYTE AlphaGetMax() const;
void AlphaSetMax(BYTE nAlphaMax);
bool AlphaIsValid();
BYTE* AlphaGetPointer(const long x = 0,const long y = 0);
bool AlphaFromTransparency();
void AlphaPaletteClear();
void AlphaPaletteEnable(bool enable=true);
bool AlphaPaletteIsEnabled();
bool AlphaPaletteIsValid();
bool AlphaPaletteSplit(CxImage *dest);
//@}
protected:
/** \addtogroup Protected */ //@{
BYTE BlindAlphaGet(const long x,const long y);
//@}
#endif //CXIMAGE_SUPPORT_ALPHA
public:
#if CXIMAGE_SUPPORT_LAYERS
/** \addtogroup Layers */ //@{
bool LayerCreate(long position = -1);
bool LayerDelete(long position = -1);
void LayerDeleteAll();
CxImage* GetLayer(long position);
CxImage* GetParent() const;
long GetNumLayers() const;
long LayerDrawAll(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0, bool bSmooth = false);
long LayerDrawAll(HDC hdc, const RECT& rect, RECT* pClipRect=NULL, bool bSmooth = false);
//@}
#endif //CXIMAGE_SUPPORT_LAYERS
protected:
/** \addtogroup Protected */ //@{
void Startup(DWORD imagetype = 0);
void CopyInfo(const CxImage &src);
void Ghost(const CxImage *src);
void RGBtoBGR(BYTE *buffer, int length);
static float HueToRGB(float n1,float n2, float hue);
void Bitfield2RGB(BYTE *src, DWORD redmask, DWORD greenmask, DWORD bluemask, BYTE bpp);
static int CompareColors(const void *elem1, const void *elem2);
short ntohs(const short word);
long ntohl(const long dword);
void bihtoh(BITMAPINFOHEADER* bih);
void* pDib; //contains the header, the palette, the pixels
BITMAPINFOHEADER head; //standard header
CXIMAGEINFO info; //extended information
BYTE* pSelection; //selected region
BYTE* pAlpha; //alpha channel
CxImage** ppLayers; //generic layers
CxImage** ppFrames;
//@}
};
////////////////////////////////////////////////////////////////////////////
#endif // !defined(__CXIMAGE_H)
File diff suppressed because it is too large Load Diff
+242
View File
@@ -0,0 +1,242 @@
/*
* File: ximagif.h
* Purpose: GIF Image Class Loader and Writer
*/
/* ==========================================================
* CxImageGIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it
* For conditions of distribution and use, see copyright notice in ximage.h
*
* Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes
*
* original CImageGIF and CImageIterator implementation are:
* Copyright: (c) 1995, Alejandro Aguilar Sierra <asierra(at)servidor(dot)unam(dot)mx>
*
* 6/15/97 Randy Spann: Added GIF87a writing support
* R.Spann@ConnRiver.net
*
* DECODE.C - An LZW decoder for GIF
* Copyright (C) 1987, by Steven A. Bennett
* Copyright (C) 1994, C++ version by Alejandro Aguilar Sierra
*
* In accordance with the above, I want to credit Steve Wilhite who wrote
* the code which this is heavily inspired by...
*
* GIF and 'Graphics Interchange Format' are trademarks (tm) of
* Compuserve, Incorporated, an H&R Block Company.
*
* Release Notes: This file contains a decoder routine for GIF images
* which is similar, structurally, to the original routine by Steve Wilhite.
* It is, however, somewhat noticably faster in most cases.
*
* ==========================================================
*/
#if !defined(__ximaGIF_h)
#define __ximaGIF_h
#include "ximage.h"
#if CXIMAGE_SUPPORT_GIF
typedef short int code_int;
/* Various error codes used by decoder */
#define OUT_OF_MEMORY -10
#define BAD_CODE_SIZE -20
#define READ_ERROR -1
#define WRITE_ERROR -2
#define OPEN_ERROR -3
#define CREATE_ERROR -4
#define MAX_CODES 4095
#define GIFBUFTAM 16383
#define TRANSPARENCY_CODE 0xF9
//LZW GIF Image compression
#define MAXBITSCODES 12
#define HSIZE 5003 /* 80% occupancy */
#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1)
#define HashTabOf(i) htab[i]
#define CodeTabOf(i) codetab[i]
class CImageIterator;
class DLL_EXP CxImageGIF: public CxImage
{
#pragma pack(1)
typedef struct tag_gifgce{
BYTE flags; /*res:3|dispmeth:3|userinputflag:1|transpcolflag:1*/
WORD delaytime;
BYTE transpcolindex;
} struct_gifgce;
typedef struct tag_dscgif{ /* Logic Screen Descriptor */
char header[6]; /* Firma and version */
WORD scrwidth;
WORD scrheight;
char pflds;
char bcindx;
char pxasrat;
} struct_dscgif;
typedef struct tag_image{ /* Image Descriptor */
WORD l;
WORD t;
WORD w;
WORD h;
BYTE pf;
} struct_image;
typedef struct tag_TabCol{ /* Tabla de colores */
short colres; /* color resolution */
short sogct; /* size of global color table */
rgb_color paleta[256]; /* paleta */
} struct_TabCol;
typedef struct tag_RLE{
int rl_pixel;
int rl_basecode;
int rl_count;
int rl_table_pixel;
int rl_table_max;
int just_cleared;
int out_bits;
int out_bits_init;
int out_count;
int out_bump;
int out_bump_init;
int out_clear;
int out_clear_init;
int max_ocodes;
int code_clear;
int code_eof;
unsigned int obuf;
int obits;
unsigned char oblock[256];
int oblen;
} struct_RLE;
#pragma pack()
public:
CxImageGIF(): CxImage(CXIMAGE_FORMAT_GIF) {m_loops=0; info.dispmeth=0; m_comment[0]='\0';}
// bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_GIF);}
// bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_GIF);}
bool Decode(CxFile * fp);
bool Decode(FILE *fp) { CxIOFile file(fp); return Decode(&file); }
#if CXIMAGE_SUPPORT_ENCODE
bool Encode(CxFile * fp);
bool Encode(CxFile * fp, CxImage ** pImages, int pagecount, bool bLocalColorMap = false, bool bLocalDispMeth = false);
bool Encode(FILE *fp) { CxIOFile file(fp); return Encode(&file); }
bool Encode(FILE *fp, CxImage ** pImages, int pagecount, bool bLocalColorMap = false)
{ CxIOFile file(fp); return Encode(&file, pImages, pagecount, bLocalColorMap); }
#endif // CXIMAGE_SUPPORT_ENCODE
void SetLoops(int loops);
long GetLoops();
void SetComment(const char* sz_comment_in);
void GetComment(char* sz_comment_out);
protected:
bool DecodeExtension(CxFile *fp);
void EncodeHeader(CxFile *fp);
void EncodeLoopExtension(CxFile *fp);
void EncodeExtension(CxFile *fp);
void EncodeBody(CxFile *fp, bool bLocalColorMap = false);
void EncodeComment(CxFile *fp);
bool EncodeRGB(CxFile *fp);
void GifMix(CxImage & imgsrc2, struct_image & imgdesc);
struct_gifgce gifgce;
int curx, cury;
long CountDown;
unsigned long cur_accum;
int cur_bits;
int interlaced, iypos, istep, iheight, ipass;
int ibf;
int ibfmax;
BYTE buf[GIFBUFTAM + 1];
// Implementation
int GifNextPixel ();
void Putword (int w, CxFile* fp );
void compressNONE (int init_bits, CxFile* outfile);
void compressLZW (int init_bits, CxFile* outfile);
void output (code_int code );
void cl_hash (long hsize);
void char_out (int c);
void flush_char ();
short init_exp(short size);
short get_next_code(CxFile*);
short decoder(CxFile*, CImageIterator* iter, short linewidth, int &bad_code_count);
int get_byte(CxFile*);
int out_line(CImageIterator* iter, unsigned char *pixels, int linelen);
int get_num_frames(CxFile *f,struct_TabCol* TabColSrc,struct_dscgif* dscgif);
long seek_next_image(CxFile* fp, long position);
short curr_size; /* The current code size */
short clear; /* Value for a clear code */
short ending; /* Value for a ending code */
short newcodes; /* First available code */
short top_slot; /* Highest code for current size */
short slot; /* Last read code */
/* The following static variables are used
* for seperating out codes */
short navail_bytes; /* # bytes left in block */
short nbits_left; /* # bits left in current BYTE */
BYTE b1; /* Current BYTE */
BYTE byte_buff[257]; /* Current block */
BYTE *pbytes; /* Pointer to next BYTE in block */
/* The reason we have these seperated like this instead of using
* a structure like the original Wilhite code did, is because this
* stuff generally produces significantly faster code when compiled...
* This code is full of similar speedups... (For a good book on writing
* C for speed or for space optomisation, see Efficient C by Tom Plum,
* published by Plum-Hall Associates...)
*/
BYTE stack[MAX_CODES + 1]; /* Stack for storing pixels */
BYTE suffix[MAX_CODES + 1]; /* Suffix table */
WORD prefix[MAX_CODES + 1]; /* Prefix linked list */
//LZW GIF Image compression routines
long htab [HSIZE];
unsigned short codetab [HSIZE];
int n_bits; /* number of bits/code */
code_int maxcode; /* maximum code, given n_bits */
code_int free_ent; /* first unused entry */
int clear_flg;
int g_init_bits;
CxFile* g_outfile;
int ClearCode;
int EOFCode;
int a_count;
char accum[256];
char m_comment[256];
int m_loops;
//RLE compression routines
void compressRLE( int init_bits, CxFile* outfile);
void rle_clear(struct_RLE* rle);
void rle_flush(struct_RLE* rle);
void rle_flush_withtable(int count, struct_RLE* rle);
void rle_flush_clearorrep(int count, struct_RLE* rle);
void rle_flush_fromclear(int count,struct_RLE* rle);
void rle_output_plain(int c,struct_RLE* rle);
void rle_reset_out_clear(struct_RLE* rle);
unsigned int rle_compute_triangle_count(unsigned int count, unsigned int nrepcodes);
unsigned int rle_isqrt(unsigned int x);
void rle_write_block(struct_RLE* rle);
void rle_block_out(unsigned char c, struct_RLE* rle);
void rle_block_flush(struct_RLE* rle);
void rle_output(int val, struct_RLE* rle);
void rle_output_flush(struct_RLE* rle);
};
#endif
#endif
+627
View File
@@ -0,0 +1,627 @@
// xImaHist.cpp : histogram functions
/* 28/01/2004 v1.00 - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximage.h"
#if CXIMAGE_SUPPORT_DSP
////////////////////////////////////////////////////////////////////////////////
long CxImage::Histogram(long* red, long* green, long* blue, long* gray, long colorspace)
{
if (!pDib) return 0;
RGBQUAD color;
if (red) memset(red,0,256*sizeof(long));
if (green) memset(green,0,256*sizeof(long));
if (blue) memset(blue,0,256*sizeof(long));
if (gray) memset(gray,0,256*sizeof(long));
long xmin,xmax,ymin,ymax;
if (pSelection){
xmin = info.rSelectionBox.left; xmax = info.rSelectionBox.right;
ymin = info.rSelectionBox.bottom; ymax = info.rSelectionBox.top;
} else {
xmin = ymin = 0;
xmax = head.biWidth; ymax=head.biHeight;
}
for(long y=ymin; y<ymax; y++){
for(long x=xmin; x<xmax; x++){
#if CXIMAGE_SUPPORT_SELECTION
if (BlindSelectionIsInside(x,y))
#endif //CXIMAGE_SUPPORT_SELECTION
{
switch (colorspace){
case 1:
color = HSLtoRGB(BlindGetPixelColor(x,y));
break;
case 2:
color = YUVtoRGB(BlindGetPixelColor(x,y));
break;
case 3:
color = YIQtoRGB(BlindGetPixelColor(x,y));
break;
case 4:
color = XYZtoRGB(BlindGetPixelColor(x,y));
break;
default:
color = BlindGetPixelColor(x,y);
}
if (red) red[color.rgbRed]++;
if (green) green[color.rgbGreen]++;
if (blue) blue[color.rgbBlue]++;
if (gray) gray[(BYTE)RGB2GRAY(color.rgbRed,color.rgbGreen,color.rgbBlue)]++;
}
}
}
long n=0;
for (int i=0; i<256; i++){
if (red && red[i]>n) n=red[i];
if (green && green[i]>n) n=green[i];
if (blue && blue[i]>n) n=blue[i];
if (gray && gray[i]>n) n=gray[i];
}
return n;
}
////////////////////////////////////////////////////////////////////////////////
/**
* HistogramStretch
* \param method: 0 = luminance (default), 1 = linked channels , 2 = independent channels.
* \param threshold: minimum percentage level in the histogram to recognize it as meaningful. Range: 0.0 to 1.0; default = 0; typical = 0.005 (0.5%);
* \return true if everything is ok
* \author [dave] and [nipper]; changes [DP]
*/
bool CxImage::HistogramStretch(long method, double threshold)
{
if (!pDib) return false;
double dbScaler = 50.0/head.biHeight;
long x,y;
if ((head.biBitCount==8) && IsGrayScale()){
double p[256];
memset(p, 0, 256*sizeof(double));
for (y=0; y<head.biHeight; y++)
{
info.nProgress = (long)(y*dbScaler);
if (info.nEscape) break;
for (x=0; x<head.biWidth; x++) {
p[BlindGetPixelIndex(x, y)]++;
}
}
double maxh = 0;
for (y=0; y<255; y++) if (maxh < p[y]) maxh = p[y];
threshold *= maxh;
int minc = 0;
while (minc<255 && p[minc]<=threshold) minc++;
int maxc = 255;
while (maxc>0 && p[maxc]<=threshold) maxc--;
if (minc == 0 && maxc == 255) return true;
if (minc >= maxc) return true;
// calculate LUT
BYTE lut[256];
for (x = 0; x <256; x++){
lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
}
for (y=0; y<head.biHeight; y++) {
if (info.nEscape) break;
info.nProgress = (long)(50.0+y*dbScaler);
for (x=0; x<head.biWidth; x++)
{
BlindSetPixelIndex(x, y, lut[BlindGetPixelIndex(x, y)]);
}
}
} else {
switch(method){
case 1:
{ // <nipper>
double p[256];
memset(p, 0, 256*sizeof(double));
for (y=0; y<head.biHeight; y++)
{
info.nProgress = (long)(y*dbScaler);
if (info.nEscape) break;
for (x=0; x<head.biWidth; x++) {
RGBQUAD color = BlindGetPixelColor(x, y);
p[color.rgbRed]++;
p[color.rgbBlue]++;
p[color.rgbGreen]++;
}
}
double maxh = 0;
for (y=0; y<255; y++) if (maxh < p[y]) maxh = p[y];
threshold *= maxh;
int minc = 0;
while (minc<255 && p[minc]<=threshold) minc++;
int maxc = 255;
while (maxc>0 && p[maxc]<=threshold) maxc--;
if (minc == 0 && maxc == 255) return true;
if (minc >= maxc) return true;
// calculate LUT
BYTE lut[256];
for (x = 0; x <256; x++){
lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
}
// normalize image
for (y=0; y<head.biHeight; y++) {
if (info.nEscape) break;
info.nProgress = (long)(50.0+y*dbScaler);
for (x=0; x<head.biWidth; x++)
{
RGBQUAD color = BlindGetPixelColor(x, y);
color.rgbRed = lut[color.rgbRed];
color.rgbBlue = lut[color.rgbBlue];
color.rgbGreen = lut[color.rgbGreen];
BlindSetPixelColor(x, y, color);
}
}
}
break;
case 2:
{ // <nipper>
double pR[256];
memset(pR, 0, 256*sizeof(double));
double pG[256];
memset(pG, 0, 256*sizeof(double));
double pB[256];
memset(pB, 0, 256*sizeof(double));
for (y=0; y<head.biHeight; y++)
{
info.nProgress = (long)(y*dbScaler);
if (info.nEscape) break;
for (long x=0; x<head.biWidth; x++) {
RGBQUAD color = BlindGetPixelColor(x, y);
pR[color.rgbRed]++;
pB[color.rgbBlue]++;
pG[color.rgbGreen]++;
}
}
double maxh = 0;
for (y=0; y<255; y++) if (maxh < pR[y]) maxh = pR[y];
double threshold2 = threshold*maxh;
int minR = 0;
while (minR<255 && pR[minR]<=threshold2) minR++;
int maxR = 255;
while (maxR>0 && pR[maxR]<=threshold2) maxR--;
maxh = 0;
for (y=0; y<255; y++) if (maxh < pG[y]) maxh = pG[y];
threshold2 = threshold*maxh;
int minG = 0;
while (minG<255 && pG[minG]<=threshold2) minG++;
int maxG = 255;
while (maxG>0 && pG[maxG]<=threshold2) maxG--;
maxh = 0;
for (y=0; y<255; y++) if (maxh < pB[y]) maxh = pB[y];
threshold2 = threshold*maxh;
int minB = 0;
while (minB<255 && pB[minB]<=threshold2) minB++;
int maxB = 255;
while (maxB>0 && pB[maxB]<=threshold2) maxB--;
if (minR == 0 && maxR == 255 && minG == 0 && maxG == 255 && minB == 0 && maxB == 255)
return true;
// calculate LUT
BYTE lutR[256];
BYTE range = maxR - minR;
if (range != 0) {
for (x = 0; x <256; x++){
lutR[x] = (BYTE)max(0,min(255,(255 * (x - minR) / range)));
}
} else lutR[minR] = minR;
BYTE lutG[256];
range = maxG - minG;
if (range != 0) {
for (x = 0; x <256; x++){
lutG[x] = (BYTE)max(0,min(255,(255 * (x - minG) / range)));
}
} else lutG[minG] = minG;
BYTE lutB[256];
range = maxB - minB;
if (range != 0) {
for (x = 0; x <256; x++){
lutB[x] = (BYTE)max(0,min(255,(255 * (x - minB) / range)));
}
} else lutB[minB] = minB;
// normalize image
for (y=0; y<head.biHeight; y++)
{
info.nProgress = (long)(50.0+y*dbScaler);
if (info.nEscape) break;
for (x=0; x<head.biWidth; x++)
{
RGBQUAD color = BlindGetPixelColor(x, y);
color.rgbRed = lutR[color.rgbRed];
color.rgbBlue = lutB[color.rgbBlue];
color.rgbGreen = lutG[color.rgbGreen];
BlindSetPixelColor(x, y, color);
}
}
}
break;
default:
{ // <dave>
double p[256];
memset(p, 0, 256*sizeof(double));
for (y=0; y<head.biHeight; y++)
{
info.nProgress = (long)(y*dbScaler);
if (info.nEscape) break;
for (x=0; x<head.biWidth; x++) {
RGBQUAD color = BlindGetPixelColor(x, y);
p[RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue)]++;
}
}
double maxh = 0;
for (y=0; y<255; y++) if (maxh < p[y]) maxh = p[y];
threshold *= maxh;
int minc = 0;
while (minc<255 && p[minc]<=threshold) minc++;
int maxc = 255;
while (maxc>0 && p[maxc]<=threshold) maxc--;
if (minc == 0 && maxc == 255) return true;
if (minc >= maxc) return true;
// calculate LUT
BYTE lut[256];
for (x = 0; x <256; x++){
lut[x] = (BYTE)max(0,min(255,(255 * (x - minc) / (maxc - minc))));
}
for(y=0; y<head.biHeight; y++){
info.nProgress = (long)(50.0+y*dbScaler);
if (info.nEscape) break;
for(x=0; x<head.biWidth; x++){
RGBQUAD color = BlindGetPixelColor( x, y );
RGBQUAD yuvClr = RGBtoYUV(color);
yuvClr.rgbRed = lut[yuvClr.rgbRed];
color = YUVtoRGB(yuvClr);
BlindSetPixelColor( x, y, color );
}
}
}
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// HistogramEqualize function by <dave> : dave(at)posortho(dot)com
bool CxImage::HistogramEqualize()
{
if (!pDib) return false;
int histogram[256];
int map[256];
int equalize_map[256];
int x, y, i, j;
RGBQUAD color;
RGBQUAD yuvClr;
unsigned int YVal, high, low;
memset( &histogram, 0, sizeof(int) * 256 );
memset( &map, 0, sizeof(int) * 256 );
memset( &equalize_map, 0, sizeof(int) * 256 );
// form histogram
for(y=0; y < head.biHeight; y++){
info.nProgress = (long)(50*y/head.biHeight);
if (info.nEscape) break;
for(x=0; x < head.biWidth; x++){
color = BlindGetPixelColor( x, y );
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
histogram[YVal]++;
}
}
// integrate the histogram to get the equalization map.
j = 0;
for(i=0; i <= 255; i++){
j += histogram[i];
map[i] = j;
}
// equalize
low = map[0];
high = map[255];
if (low == high) return false;
for( i = 0; i <= 255; i++ ){
equalize_map[i] = (unsigned int)((((double)( map[i] - low ) ) * 255) / ( high - low ) );
}
// stretch the histogram
if(head.biClrUsed == 0){ // No Palette
for( y = 0; y < head.biHeight; y++ ){
info.nProgress = (long)(50+50*y/head.biHeight);
if (info.nEscape) break;
for( x = 0; x < head.biWidth; x++ ){
color = BlindGetPixelColor( x, y );
yuvClr = RGBtoYUV(color);
yuvClr.rgbRed = (BYTE)equalize_map[yuvClr.rgbRed];
color = YUVtoRGB(yuvClr);
BlindSetPixelColor( x, y, color );
}
}
} else { // Palette
for( i = 0; i < (int)head.biClrUsed; i++ ){
color = GetPaletteColor((BYTE)i);
yuvClr = RGBtoYUV(color);
yuvClr.rgbRed = (BYTE)equalize_map[yuvClr.rgbRed];
color = YUVtoRGB(yuvClr);
SetPaletteColor( (BYTE)i, color );
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// HistogramNormalize function by <dave> : dave(at)posortho(dot)com
bool CxImage::HistogramNormalize()
{
if (!pDib) return false;
int histogram[256];
int threshold_intensity, intense;
int x, y, i;
unsigned int normalize_map[256];
unsigned int high, low, YVal;
RGBQUAD color;
RGBQUAD yuvClr;
memset( &histogram, 0, sizeof( int ) * 256 );
memset( &normalize_map, 0, sizeof( unsigned int ) * 256 );
// form histogram
for(y=0; y < head.biHeight; y++){
info.nProgress = (long)(50*y/head.biHeight);
if (info.nEscape) break;
for(x=0; x < head.biWidth; x++){
color = BlindGetPixelColor( x, y );
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
histogram[YVal]++;
}
}
// find histogram boundaries by locating the 1 percent levels
threshold_intensity = ( head.biWidth * head.biHeight) / 100;
intense = 0;
for( low = 0; low < 255; low++ ){
intense += histogram[low];
if( intense > threshold_intensity ) break;
}
intense = 0;
for( high = 255; high != 0; high--){
intense += histogram[ high ];
if( intense > threshold_intensity ) break;
}
if ( low == high ){
// Unreasonable contrast; use zero threshold to determine boundaries.
threshold_intensity = 0;
intense = 0;
for( low = 0; low < 255; low++){
intense += histogram[low];
if( intense > threshold_intensity ) break;
}
intense = 0;
for( high = 255; high != 0; high-- ){
intense += histogram [high ];
if( intense > threshold_intensity ) break;
}
}
if( low == high ) return false; // zero span bound
// Stretch the histogram to create the normalized image mapping.
for(i = 0; i <= 255; i++){
if ( i < (int) low ){
normalize_map[i] = 0;
} else {
if(i > (int) high)
normalize_map[i] = 255;
else
normalize_map[i] = ( 255 - 1) * ( i - low) / ( high - low );
}
}
// Normalize
if( head.biClrUsed == 0 ){
for( y = 0; y < head.biHeight; y++ ){
info.nProgress = (long)(50+50*y/head.biHeight);
if (info.nEscape) break;
for( x = 0; x < head.biWidth; x++ ){
color = BlindGetPixelColor( x, y );
yuvClr = RGBtoYUV( color );
yuvClr.rgbRed = (BYTE)normalize_map[yuvClr.rgbRed];
color = YUVtoRGB( yuvClr );
BlindSetPixelColor( x, y, color );
}
}
} else {
for(i = 0; i < (int)head.biClrUsed; i++){
color = GetPaletteColor( (BYTE)i );
yuvClr = RGBtoYUV( color );
yuvClr.rgbRed = (BYTE)normalize_map[yuvClr.rgbRed];
color = YUVtoRGB( yuvClr );
SetPaletteColor( (BYTE)i, color );
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// HistogramLog function by <dave> : dave(at)posortho(dot)com
bool CxImage::HistogramLog()
{
if (!pDib) return false;
//q(i,j) = 255/log(1 + |high|) * log(1 + |p(i,j)|);
int x, y, i;
RGBQUAD color;
RGBQUAD yuvClr;
unsigned int YVal, high = 1;
// Find Highest Luminance Value in the Image
if( head.biClrUsed == 0 ){ // No Palette
for(y=0; y < head.biHeight; y++){
info.nProgress = (long)(50*y/head.biHeight);
if (info.nEscape) break;
for(x=0; x < head.biWidth; x++){
color = BlindGetPixelColor( x, y );
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
if (YVal > high ) high = YVal;
}
}
} else { // Palette
for(i = 0; i < (int)head.biClrUsed; i++){
color = GetPaletteColor((BYTE)i);
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
if (YVal > high ) high = YVal;
}
}
// Logarithm Operator
double k = 255.0 / ::log( 1.0 + (double)high );
if( head.biClrUsed == 0 ){
for( y = 0; y < head.biHeight; y++ ){
info.nProgress = (long)(50+50*y/head.biHeight);
if (info.nEscape) break;
for( x = 0; x < head.biWidth; x++ ){
color = BlindGetPixelColor( x, y );
yuvClr = RGBtoYUV( color );
yuvClr.rgbRed = (BYTE)(k * ::log( 1.0 + (double)yuvClr.rgbRed ) );
color = YUVtoRGB( yuvClr );
BlindSetPixelColor( x, y, color );
}
}
} else {
for(i = 0; i < (int)head.biClrUsed; i++){
color = GetPaletteColor( (BYTE)i );
yuvClr = RGBtoYUV( color );
yuvClr.rgbRed = (BYTE)(k * ::log( 1.0 + (double)yuvClr.rgbRed ) );
color = YUVtoRGB( yuvClr );
SetPaletteColor( (BYTE)i, color );
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// HistogramRoot function by <dave> : dave(at)posortho(dot)com
bool CxImage::HistogramRoot()
{
if (!pDib) return false;
//q(i,j) = sqrt(|p(i,j)|);
int x, y, i;
RGBQUAD color;
RGBQUAD yuvClr;
double dtmp;
unsigned int YVal, high = 1;
// Find Highest Luminance Value in the Image
if( head.biClrUsed == 0 ){ // No Palette
for(y=0; y < head.biHeight; y++){
info.nProgress = (long)(50*y/head.biHeight);
if (info.nEscape) break;
for(x=0; x < head.biWidth; x++){
color = BlindGetPixelColor( x, y );
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
if (YVal > high ) high = YVal;
}
}
} else { // Palette
for(i = 0; i < (int)head.biClrUsed; i++){
color = GetPaletteColor((BYTE)i);
YVal = (unsigned int)RGB2GRAY(color.rgbRed, color.rgbGreen, color.rgbBlue);
if (YVal > high ) high = YVal;
}
}
// Root Operator
double k = 128.0 / ::log( 1.0 + (double)high );
if( head.biClrUsed == 0 ){
for( y = 0; y < head.biHeight; y++ ){
info.nProgress = (long)(50+50*y/head.biHeight);
if (info.nEscape) break;
for( x = 0; x < head.biWidth; x++ ){
color = BlindGetPixelColor( x, y );
yuvClr = RGBtoYUV( color );
dtmp = k * ::sqrt( (double)yuvClr.rgbRed );
if ( dtmp > 255.0 ) dtmp = 255.0;
if ( dtmp < 0 ) dtmp = 0;
yuvClr.rgbRed = (BYTE)dtmp;
color = YUVtoRGB( yuvClr );
BlindSetPixelColor( x, y, color );
}
}
} else {
for(i = 0; i < (int)head.biClrUsed; i++){
color = GetPaletteColor( (BYTE)i );
yuvClr = RGBtoYUV( color );
dtmp = k * ::sqrt( (double)yuvClr.rgbRed );
if ( dtmp > 255.0 ) dtmp = 255.0;
if ( dtmp < 0 ) dtmp = 0;
yuvClr.rgbRed = (BYTE)dtmp;
color = YUVtoRGB( yuvClr );
SetPaletteColor( (BYTE)i, color );
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif
+472
View File
@@ -0,0 +1,472 @@
/*
* File: ximaico.cpp
* Purpose: Platform Independent ICON Image Class Loader and Writer (MS version)
* 07/Aug/2001 Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximaico.h"
#if CXIMAGE_SUPPORT_ICO
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageICO::Decode(CxFile *hFile)
{
if (hFile==NULL) return false;
DWORD off = hFile->Tell(); //<yuandi>
int page=info.nFrame; //internal icon structure indexes
// read the first part of the header
ICONHEADER icon_header;
hFile->Read(&icon_header,sizeof(ICONHEADER),1);
icon_header.idType = ntohs(icon_header.idType);
icon_header.idCount = ntohs(icon_header.idCount);
// check if it's an icon or a cursor
if ((icon_header.idReserved == 0) && ((icon_header.idType == 1)||(icon_header.idType == 2))) {
info.nNumFrames = icon_header.idCount;
// load the icon descriptions
ICONDIRENTRY *icon_list = (ICONDIRENTRY *)malloc(icon_header.idCount * sizeof(ICONDIRENTRY));
int c;
for (c = 0; c < icon_header.idCount; c++) {
hFile->Read(icon_list + c, sizeof(ICONDIRENTRY), 1);
icon_list[c].wPlanes = ntohs(icon_list[c].wPlanes);
icon_list[c].wBitCount = ntohs(icon_list[c].wBitCount);
icon_list[c].dwBytesInRes = ntohl(icon_list[c].dwBytesInRes);
icon_list[c].dwImageOffset = ntohl(icon_list[c].dwImageOffset);
}
if ((page>=0)&&(page<icon_header.idCount)){
if (info.nEscape == -1) {
// Return output dimensions only
head.biWidth = icon_list[page].bWidth;
head.biHeight = icon_list[page].bHeight;
#if CXIMAGE_SUPPORT_PNG
if (head.biWidth==0 && head.biHeight==0)
{ // Vista icon support
hFile->Seek(off + icon_list[page].dwImageOffset, SEEK_SET);
CxImage png;
png.SetEscape(-1);
if (png.Decode(hFile,CXIMAGE_FORMAT_PNG)){
Transfer(png);
info.nNumFrames = icon_header.idCount;
}
}
#endif //CXIMAGE_SUPPORT_PNG
free(icon_list);
info.dwType = CXIMAGE_FORMAT_ICO;
return true;
}
// get the bit count for the colors in the icon <CoreyRLucier>
BITMAPINFOHEADER bih;
hFile->Seek(off + icon_list[page].dwImageOffset, SEEK_SET);
if (icon_list[page].bWidth==0 && icon_list[page].bHeight==0)
{ // Vista icon support
#if CXIMAGE_SUPPORT_PNG
CxImage png;
if (png.Decode(hFile,CXIMAGE_FORMAT_PNG)){
Transfer(png);
info.nNumFrames = icon_header.idCount;
}
SetType(CXIMAGE_FORMAT_ICO);
#endif //CXIMAGE_SUPPORT_PNG
}
else
{ // standard icon
hFile->Read(&bih,sizeof(BITMAPINFOHEADER),1);
bihtoh(&bih);
c = bih.biBitCount;
// allocate memory for one icon
Create(icon_list[page].bWidth,icon_list[page].bHeight, c, CXIMAGE_FORMAT_ICO); //image creation
// read the palette
RGBQUAD pal[256];
if (bih.biClrUsed)
hFile->Read(pal,bih.biClrUsed*sizeof(RGBQUAD), 1);
else
hFile->Read(pal,head.biClrUsed*sizeof(RGBQUAD), 1);
SetPalette(pal,head.biClrUsed); //palette assign
//read the icon
if (c<=24){
hFile->Read(info.pImage, head.biSizeImage, 1);
} else { // 32 bit icon
BYTE* buf=(BYTE*)malloc(4*head.biHeight*head.biWidth);
BYTE* src = buf;
hFile->Read(buf, 4*head.biHeight*head.biWidth, 1);
#if CXIMAGE_SUPPORT_ALPHA
if (!AlphaIsValid()) AlphaCreate();
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y = 0; y < head.biHeight; y++) {
BYTE* dst = GetBits(y);
for(long x=0;x<head.biWidth;x++){
*dst++=src[0];
*dst++=src[1];
*dst++=src[2];
#if CXIMAGE_SUPPORT_ALPHA
AlphaSet(x,y,src[3]);
#endif //CXIMAGE_SUPPORT_ALPHA
src+=4;
}
}
free(buf);
}
// apply the AND and XOR masks
int maskwdt = ((head.biWidth+31) / 32) * 4; //line width of AND mask (always 1 Bpp)
int masksize = head.biHeight * maskwdt; //size of mask
BYTE *mask = (BYTE *)malloc(masksize);
if (hFile->Read(mask, masksize, 1)){
bool bGoodMask=false;
for (int im=0;im<masksize;im++){
if (mask[im]!=255){
bGoodMask=true;
break;
}
}
if (bGoodMask){
#if CXIMAGE_SUPPORT_ALPHA
bool bNeedAlpha = false;
if (!AlphaIsValid()){
AlphaCreate();
} else {
bNeedAlpha=true; //32bit icon
}
int x,y;
for (y = 0; y < head.biHeight; y++) {
for (x = 0; x < head.biWidth; x++) {
if (((mask[y*maskwdt+(x>>3)]>>(7-x%8))&0x01)){
AlphaSet(x,y,0);
bNeedAlpha=true;
}
}
}
if (!bNeedAlpha) AlphaDelete();
#endif //CXIMAGE_SUPPORT_ALPHA
//check if there is only one transparent color
RGBQUAD cc,ct;
long* pcc = (long*)&cc;
long* pct = (long*)&ct;
int nTransColors=0;
int nTransIndex=0;
for (y = 0; y < head.biHeight; y++){
for (x = 0; x < head.biWidth; x++){
if (((mask[y*maskwdt+(x>>3)] >> (7-x%8)) & 0x01)){
cc = GetPixelColor(x,y,false);
if (nTransColors==0){
nTransIndex = GetPixelIndex(x,y);
nTransColors++;
ct = cc;
} else {
if (*pct!=*pcc){
nTransColors++;
}
}
}
}
}
if (nTransColors==1){
SetTransColor(ct);
SetTransIndex(nTransIndex);
#if CXIMAGE_SUPPORT_ALPHA
AlphaDelete(); //because we have a unique transparent color in the image
#endif //CXIMAGE_SUPPORT_ALPHA
}
// <vho> - Transparency support w/o Alpha support
if (c <= 8){ // only for icons with less than 256 colors (XP icons need alpha).
// find a color index, which is not used in the image
// it is almost sure to find one, bcs. nobody uses all possible colors for an icon
BYTE colorsUsed[256];
memset(colorsUsed, 0, sizeof(colorsUsed));
for (y = 0; y < head.biHeight; y++){
for (x = 0; x < head.biWidth; x++){
colorsUsed[BlindGetPixelIndex(x,y)] = 1;
}
}
int iTransIdx = -1;
for (x = (int)(head.biClrUsed-1); x>=0 ; x--){
if (colorsUsed[x] == 0){
iTransIdx = x; // this one is not in use. we may use it as transparent color
break;
}
}
// Go thru image and set unused color as transparent index if needed
if (iTransIdx >= 0){
bool bNeedTrans = false;
for (y = 0; y < head.biHeight; y++){
for (x = 0; x < head.biWidth; x++){
// AND mask (Each Byte represents 8 Pixels)
if (((mask[y*maskwdt+(x>>3)] >> (7-x%8)) & 0x01)){
// AND mask is set (!=0). This is a transparent part
SetPixelIndex(x, y, (BYTE)iTransIdx);
bNeedTrans = true;
}
}
}
// set transparent index if needed
if (bNeedTrans) SetTransIndex(iTransIdx);
#if CXIMAGE_SUPPORT_ALPHA
AlphaDelete(); //because we have a transparent color in the palette
#endif //CXIMAGE_SUPPORT_ALPHA
}
}
} else {
SetTransIndex(0); //empty mask, set black as transparent color
Negative();
}
}
free(mask);
}
free(icon_list);
// icon has been loaded successfully!
return true;
}
free(icon_list);
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
// Thanks to <Alas>
bool CxImageICO::Encode(CxFile * hFile, CxImage ** pImages, int nPageCount)
{
cx_try
{
if (hFile==NULL) cx_throw("invalid file pointer");
if (pImages==NULL || nPageCount<=0) cx_throw("multipage ICO, no images!");
int i;
for (i=0; i<nPageCount; i++){
if (pImages[i]==NULL)
cx_throw("Bad image pointer");
if (!(pImages[i]->IsValid()))
cx_throw("Empty image");
}
CxImageICO ghost;
for (i=0; i<nPageCount; i++){ //write headers
ghost.Ghost(pImages[i]);
ghost.info.nNumFrames = nPageCount;
if (i==0) {
if (!ghost.Encode(hFile,false,nPageCount))
cx_throw("Error writing ICO file header");
}
if (!ghost.Encode(hFile,true,nPageCount))
cx_throw("Error saving ICO image header");
}
for (i=0; i<nPageCount; i++){ //write bodies
ghost.Ghost(pImages[i]);
ghost.info.nNumFrames = nPageCount;
if (!ghost.Encode(hFile,true,i))
cx_throw("Error saving ICO body");
}
} cx_catch {
if (strcmp(message,"")) strncpy(info.szLastError,message,255);
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int nPageCount)
{
if (EncodeSafeCheck(hFile)) return false;
#if CXIMAGE_SUPPORT_PNG == 0
//check format limits
if ((head.biWidth>255)||(head.biHeight>255)){
strcpy(info.szLastError,"Can't save this image as icon");
return false;
}
#endif
//prepare the palette struct
RGBQUAD* pal=GetPalette();
if (head.biBitCount<=8 && pal==NULL) return false;
int maskwdt=((head.biWidth+31)/32)*4; //mask line width
int masksize=head.biHeight * maskwdt; //size of mask
int bitcount=head.biBitCount;
int imagesize=head.biSizeImage;
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid() && head.biClrUsed==0){
bitcount=32;
imagesize=4*head.biHeight*head.biWidth;
}
#endif
//fill the icon headers
int nPages = nPageCount;
if (nPages<1) nPages = 1;
ICONHEADER icon_header={0,1,nPages};
if (!bAppend)
m_dwImageOffset = sizeof(ICONHEADER) + nPages * sizeof(ICONDIRENTRY);
DWORD dwBytesInRes = sizeof(BITMAPINFOHEADER)+head.biClrUsed*sizeof(RGBQUAD)+imagesize+masksize;
ICONDIRENTRY icon_list={
(BYTE)head.biWidth,
(BYTE)head.biHeight,
(BYTE)head.biClrUsed,
0, 0,
(WORD)bitcount,
dwBytesInRes,
m_dwImageOffset
};
BITMAPINFOHEADER bi={
sizeof(BITMAPINFOHEADER),
head.biWidth,
2*head.biHeight,
1,
(WORD)bitcount,
0, imagesize,
0, 0, 0, 0
};
#if CXIMAGE_SUPPORT_PNG // Vista icon support
CxImage png(*this);
CxMemFile memfile;
if (head.biWidth>255 || head.biHeight>255){
icon_list.bWidth = icon_list.bHeight = 0;
memfile.Open();
png.Encode(&memfile,CXIMAGE_FORMAT_PNG);
icon_list.dwBytesInRes = dwBytesInRes = memfile.Size();
}
#endif //CXIMAGE_SUPPORT_PNG
if (!bAppend){
icon_header.idType = ntohs(icon_header.idType);
icon_header.idCount = ntohs(icon_header.idCount);
hFile->Write(&icon_header,sizeof(ICONHEADER),1); //write the file header
icon_header.idType = ntohs(icon_header.idType);
icon_header.idCount = ntohs(icon_header.idCount);
}
if ((bAppend && nPageCount==info.nNumFrames) || (!bAppend && nPageCount==0)){
icon_list.wPlanes = ntohs(icon_list.wPlanes);
icon_list.wBitCount = ntohs(icon_list.wBitCount);
icon_list.dwBytesInRes = ntohl(icon_list.dwBytesInRes);
icon_list.dwImageOffset = ntohl(icon_list.dwImageOffset);
hFile->Write(&icon_list,sizeof(ICONDIRENTRY),1); //write the image entry
icon_list.wPlanes = ntohs(icon_list.wPlanes);
icon_list.wBitCount = ntohs(icon_list.wBitCount);
icon_list.dwBytesInRes = ntohl(icon_list.dwBytesInRes);
icon_list.dwImageOffset = ntohl(icon_list.dwImageOffset);
m_dwImageOffset += dwBytesInRes; //update offset for next header
}
if ((bAppend && nPageCount<info.nNumFrames) || (!bAppend && nPageCount==0))
{
#if CXIMAGE_SUPPORT_PNG
if (icon_list.bWidth==0 && icon_list.bHeight==0) { // Vista icon support
hFile->Write(memfile.GetBuffer(false),dwBytesInRes,1);
} else
#endif //CXIMAGE_SUPPORT_PNG
{ // standard icon
bihtoh(&bi);
hFile->Write(&bi,sizeof(BITMAPINFOHEADER),1); //write the image header
bihtoh(&bi);
bool bTransparent = info.nBkgndIndex >= 0;
RGBQUAD ct = GetTransColor();
if (pal){
if (bTransparent) SetPaletteColor((BYTE)info.nBkgndIndex,0,0,0,0);
hFile->Write(pal,head.biClrUsed*sizeof(RGBQUAD),1); //write palette
if (bTransparent) SetPaletteColor((BYTE)info.nBkgndIndex,ct);
}
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid() && head.biClrUsed==0){
BYTE* buf=(BYTE*)malloc(imagesize);
BYTE* dst = buf;
for (long y = 0; y < head.biHeight; y++) {
BYTE* src = GetBits(y);
for(long x=0;x<head.biWidth;x++){
*dst++=*src++;
*dst++=*src++;
*dst++=*src++;
*dst++=AlphaGet(x,y);
}
}
hFile->Write(buf,imagesize, 1);
free(buf);
} else {
hFile->Write(info.pImage,imagesize,1); //write image
}
#else
hFile->Write(info.pImage,imagesize,1); //write image
#endif
//save transparency mask
BYTE* mask=(BYTE*)calloc(masksize,1); //create empty AND/XOR masks
if (!mask) return false;
//prepare the variables to build the mask
BYTE* iDst;
int pos,i;
RGBQUAD c={0,0,0,0};
long* pc = (long*)&c;
long* pct= (long*)&ct;
#if CXIMAGE_SUPPORT_ALPHA
bool bAlphaPaletteIsValid = AlphaPaletteIsValid();
bool bAlphaIsValid = AlphaIsValid();
#endif
//build the mask
for (int y = 0; y < head.biHeight; y++) {
for (int x = 0; x < head.biWidth; x++) {
i=0;
#if CXIMAGE_SUPPORT_ALPHA
if (bAlphaIsValid && AlphaGet(x,y)==0) i=1;
if (bAlphaPaletteIsValid && BlindGetPixelColor(x,y).rgbReserved==0) i=1;
#endif
c=GetPixelColor(x,y,false);
if (bTransparent && *pc==*pct) i=1;
iDst = mask + y*maskwdt + (x>>3);
pos = 7-x%8;
*iDst &= ~(0x01<<pos);
*iDst |= ((i & 0x01)<<pos);
}
}
//write AND/XOR masks
hFile->Write(mask,masksize,1);
free(mask);
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_ICO
+58
View File
@@ -0,0 +1,58 @@
/*
* File: ximaico.h
* Purpose: ICON Image Class Loader and Writer
*/
/* ==========================================================
* CxImageICO (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it
* For conditions of distribution and use, see copyright notice in ximage.h
* ==========================================================
*/
#if !defined(__ximaICO_h)
#define __ximaICO_h
#include "ximage.h"
#if CXIMAGE_SUPPORT_ICO
class CxImageICO: public CxImage
{
typedef struct tagIconDirectoryEntry {
BYTE bWidth;
BYTE bHeight;
BYTE bColorCount;
BYTE bReserved;
WORD wPlanes;
WORD wBitCount;
DWORD dwBytesInRes;
DWORD dwImageOffset;
} ICONDIRENTRY;
typedef struct tagIconDir {
WORD idReserved;
WORD idType;
WORD idCount;
} ICONHEADER;
public:
CxImageICO(): CxImage(CXIMAGE_FORMAT_ICO) {m_dwImageOffset=0;}
// bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);}
// bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);}
bool Decode(CxFile * hFile);
bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
#if CXIMAGE_SUPPORT_ENCODE
bool Encode(CxFile * hFile, bool bAppend=false, int nPageCount=0);
bool Encode(CxFile * hFile, CxImage ** pImages, int nPageCount);
bool Encode(FILE *hFile, bool bAppend=false, int nPageCount=0)
{ CxIOFile file(hFile); return Encode(&file,bAppend,nPageCount); }
bool Encode(FILE *hFile, CxImage ** pImages, int nPageCount)
{ CxIOFile file(hFile); return Encode(&file, pImages, nPageCount); }
#endif // CXIMAGE_SUPPORT_ENCODE
protected:
DWORD m_dwImageOffset;
};
#endif
#endif
+917
View File
@@ -0,0 +1,917 @@
// ximainfo.cpp : main attributes
/* 03/10/2004 v1.00 - Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximage.h"
////////////////////////////////////////////////////////////////////////////////
/**
* \return the color used for transparency, and/or for background color
*/
RGBQUAD CxImage::GetTransColor()
{
if (head.biBitCount<24 && info.nBkgndIndex>=0) return GetPaletteColor((BYTE)info.nBkgndIndex);
return info.nBkgndColor;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Gets the index used for transparency. Returns -1 for no transparancy.
*/
long CxImage::GetTransIndex() const
{
return info.nBkgndIndex;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the index used for transparency with 1, 4 and 8 bpp images. Set to -1 to remove the effect.
*/
void CxImage::SetTransIndex(long idx)
{
if (idx<(long)head.biClrUsed)
info.nBkgndIndex = idx;
else
info.nBkgndIndex = 0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the color used for transparency with 24 bpp images.
* You must call SetTransIndex(0) to enable the effect, SetTransIndex(-1) to disable it.
*/
void CxImage::SetTransColor(RGBQUAD rgb)
{
rgb.rgbReserved=0;
info.nBkgndColor = rgb;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::IsTransparent() const
{
return info.nBkgndIndex>=0; // <vho>
}
////////////////////////////////////////////////////////////////////////////////
/**
* Returns true if the image has 256 colors or less.
*/
bool CxImage::IsIndexed() const
{
return head.biClrUsed!=0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return 1 = indexed, 2 = RGB, 4 = RGBA
*/
BYTE CxImage::GetColorType()
{
BYTE b = (BYTE)((head.biBitCount>8) ? 2 /*COLORTYPE_COLOR*/ : 1 /*COLORTYPE_PALETTE*/);
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()) b = 4 /*COLORTYPE_ALPHA*/;
#endif //CXIMAGE_SUPPORT_ALPHA
return b;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
*/
long CxImage::GetXDPI() const
{
return info.xDPI;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
*/
long CxImage::GetYDPI() const
{
return info.yDPI;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Set resolution for TIFF, JPEG, PNG and BMP formats.
*/
void CxImage::SetXDPI(long dpi)
{
if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
info.xDPI = dpi;
head.biXPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
if (pDib) ((BITMAPINFOHEADER*)pDib)->biXPelsPerMeter = head.biXPelsPerMeter;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Set resolution for TIFF, JPEG, PNG and BMP formats.
*/
void CxImage::SetYDPI(long dpi)
{
if (dpi<=0) dpi = CXIMAGE_DEFAULT_DPI;
info.yDPI = dpi;
head.biYPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
if (pDib) ((BITMAPINFOHEADER*)pDib)->biYPelsPerMeter = head.biYPelsPerMeter;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetFlags
*/
DWORD CxImage::GetFlags() const
{
return info.dwFlags;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Image flags, for future use
* \param flags
* - 0x??00000 = reserved for 16 bit, CMYK, multilayer
* - 0x00??0000 = blend modes
* - 0x0000???? = layer id or user flags
*
* \param bLockReservedFlags protects the "reserved" and "blend modes" flags
*/
void CxImage::SetFlags(DWORD flags, bool bLockReservedFlags)
{
if (bLockReservedFlags) info.dwFlags = flags & 0x0000ffff;
else info.dwFlags = flags;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetCodecOption
*/
DWORD CxImage::GetCodecOption(DWORD imagetype)
{
imagetype = GetTypeIndexFromId(imagetype);
if (imagetype==0){
imagetype = GetTypeIndexFromId(GetType());
}
return info.dwCodecOpt[imagetype];
}
////////////////////////////////////////////////////////////////////////////////
/**
* Encode option for GIF, TIF and JPG.
* - GIF : 0 = LZW (default), 1 = none, 2 = RLE.
* - TIF : 0 = automatic (default), or a valid compression code as defined in "tiff.h" (COMPRESSION_NONE = 1, COMPRESSION_CCITTRLE = 2, ...)
* - JPG : valid values stored in enum CODEC_OPTION ( ENCODE_BASELINE = 0x01, ENCODE_PROGRESSIVE = 0x10, ...)
* - RAW : valid values stored in enum CODEC_OPTION ( DECODE_QUALITY_LIN = 0x00, DECODE_QUALITY_VNG = 0x01, ...)
*
* \return true if everything is ok
*/
bool CxImage::SetCodecOption(DWORD opt, DWORD imagetype)
{
imagetype = GetTypeIndexFromId(imagetype);
if (imagetype==0){
imagetype = GetTypeIndexFromId(GetType());
}
info.dwCodecOpt[imagetype] = opt;
return true;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return internal hDib object..
*/
void* CxImage::GetDIB() const
{
return pDib;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetHeight() const
{
return head.biHeight;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetWidth() const
{
return head.biWidth;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return DWORD aligned width of the image.
*/
DWORD CxImage::GetEffWidth() const
{
return info.dwEffWidth;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return 2, 16, 256; 0 for RGB images.
*/
DWORD CxImage::GetNumColors() const
{
return head.biClrUsed;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return: 1, 4, 8, 24.
*/
WORD CxImage::GetBpp() const
{
return head.biBitCount;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return original image format
* \sa ENUM_CXIMAGE_FORMATS.
*/
DWORD CxImage::GetType() const
{
return info.dwType;
}
////////////////////////////////////////////////////////////////////////////////
/**
* change image format identifier
* \sa ENUM_CXIMAGE_FORMATS.
*/
bool CxImage::SetType(DWORD type)
{
switch (type){
#if CXIMAGE_SUPPORT_BMP
case CXIMAGE_FORMAT_BMP:
#endif
#if CXIMAGE_SUPPORT_GIF
case CXIMAGE_FORMAT_GIF:
#endif
#if CXIMAGE_SUPPORT_JPG
case CXIMAGE_FORMAT_JPG:
#endif
#if CXIMAGE_SUPPORT_PNG
case CXIMAGE_FORMAT_PNG:
#endif
#if CXIMAGE_SUPPORT_MNG
case CXIMAGE_FORMAT_MNG:
#endif
#if CXIMAGE_SUPPORT_ICO
case CXIMAGE_FORMAT_ICO:
#endif
#if CXIMAGE_SUPPORT_TIF
case CXIMAGE_FORMAT_TIF:
#endif
#if CXIMAGE_SUPPORT_TGA
case CXIMAGE_FORMAT_TGA:
#endif
#if CXIMAGE_SUPPORT_PCX
case CXIMAGE_FORMAT_PCX:
#endif
#if CXIMAGE_SUPPORT_WBMP
case CXIMAGE_FORMAT_WBMP:
#endif
#if CXIMAGE_SUPPORT_WMF
case CXIMAGE_FORMAT_WMF:
#endif
#if CXIMAGE_SUPPORT_JBG
case CXIMAGE_FORMAT_JBG:
#endif
#if CXIMAGE_SUPPORT_JP2
case CXIMAGE_FORMAT_JP2:
#endif
#if CXIMAGE_SUPPORT_JPC
case CXIMAGE_FORMAT_JPC:
#endif
#if CXIMAGE_SUPPORT_PGX
case CXIMAGE_FORMAT_PGX:
#endif
#if CXIMAGE_SUPPORT_PNM
case CXIMAGE_FORMAT_PNM:
#endif
#if CXIMAGE_SUPPORT_RAS
case CXIMAGE_FORMAT_RAS:
#endif
#if CXIMAGE_SUPPORT_SKA
case CXIMAGE_FORMAT_SKA:
#endif
#if CXIMAGE_SUPPORT_RAW
case CXIMAGE_FORMAT_RAW:
#endif
info.dwType = type;
return true;
}
info.dwType = CXIMAGE_FORMAT_UNKNOWN;
return false;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetNumTypes()
{
return CMAX_IMAGE_FORMATS-1;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetTypeIdFromName(const TCHAR* ext)
{
#if CXIMAGE_SUPPORT_BMP
if (_tcsnicmp(ext,_T("bmp"),3)==0 ) return CXIMAGE_FORMAT_BMP;
#endif
#if CXIMAGE_SUPPORT_JPG
if (_tcsnicmp(ext,_T("jpg"),3)==0 ||
_tcsnicmp(ext,_T("jpe"),3)==0 ||
_tcsnicmp(ext,_T("jfi"),3)==0 ) return CXIMAGE_FORMAT_JPG;
#endif
#if CXIMAGE_SUPPORT_GIF
if (_tcsnicmp(ext,_T("gif"),3)==0 ) return CXIMAGE_FORMAT_GIF;
#endif
#if CXIMAGE_SUPPORT_PNG
if (_tcsnicmp(ext,_T("png"),3)==0 ) return CXIMAGE_FORMAT_PNG;
#endif
#if CXIMAGE_SUPPORT_ICO
if (_tcsnicmp(ext,_T("ico"),3)==0 ||
_tcsnicmp(ext,_T("cur"),3)==0 ) return CXIMAGE_FORMAT_ICO;
#endif
#if CXIMAGE_SUPPORT_TIF
if (_tcsnicmp(ext,_T("tif"),3)==0 ) return CXIMAGE_FORMAT_TIF;
#endif
#if CXIMAGE_SUPPORT_TGA
if (_tcsnicmp(ext,_T("tga"),3)==0 ) return CXIMAGE_FORMAT_TGA;
#endif
#if CXIMAGE_SUPPORT_PCX
if (_tcsnicmp(ext,_T("pcx"),3)==0 ) return CXIMAGE_FORMAT_PCX;
#endif
#if CXIMAGE_SUPPORT_WBMP
if (_tcsnicmp(ext,_T("wbm"),3)==0 ) return CXIMAGE_FORMAT_WBMP;
#endif
#if CXIMAGE_SUPPORT_WMF
if (_tcsnicmp(ext,_T("wmf"),3)==0 ||
_tcsnicmp(ext,_T("emf"),3)==0 ) return CXIMAGE_FORMAT_WMF;
#endif
#if CXIMAGE_SUPPORT_JP2
if (_tcsnicmp(ext,_T("jp2"),3)==0 ||
_tcsnicmp(ext,_T("j2k"),3)==0 ) return CXIMAGE_FORMAT_JP2;
#endif
#if CXIMAGE_SUPPORT_JPC
if (_tcsnicmp(ext,_T("jpc"),3)==0 ||
_tcsnicmp(ext,_T("j2c"),3)==0 ) return CXIMAGE_FORMAT_JPC;
#endif
#if CXIMAGE_SUPPORT_PGX
if (_tcsnicmp(ext,_T("pgx"),3)==0 ) return CXIMAGE_FORMAT_PGX;
#endif
#if CXIMAGE_SUPPORT_RAS
if (_tcsnicmp(ext,_T("ras"),3)==0 ) return CXIMAGE_FORMAT_RAS;
#endif
#if CXIMAGE_SUPPORT_PNM
if (_tcsnicmp(ext,_T("pnm"),3)==0 ||
_tcsnicmp(ext,_T("pgm"),3)==0 ||
_tcsnicmp(ext,_T("ppm"),3)==0 ) return CXIMAGE_FORMAT_PNM;
#endif
#if CXIMAGE_SUPPORT_JBG
if (_tcsnicmp(ext,_T("jbg"),3)==0 ) return CXIMAGE_FORMAT_JBG;
#endif
#if CXIMAGE_SUPPORT_MNG
if (_tcsnicmp(ext,_T("mng"),3)==0 ||
_tcsnicmp(ext,_T("jng"),3)==0 ) return CXIMAGE_FORMAT_MNG;
#endif
#if CXIMAGE_SUPPORT_SKA
if (_tcsnicmp(ext,_T("ska"),3)==0 ) return CXIMAGE_FORMAT_SKA;
#endif
#if CXIMAGE_SUPPORT_RAW
if (_tcsnicmp(ext,_T("nef"),3)==0 ||
_tcsnicmp(ext,_T("crw"),3)==0 ||
_tcsnicmp(ext,_T("cr2"),3)==0 ||
_tcsnicmp(ext,_T("dng"),3)==0 ||
_tcsnicmp(ext,_T("arw"),3)==0 ||
_tcsnicmp(ext,_T("erf"),3)==0 ||
_tcsnicmp(ext,_T("3fr"),3)==0 ||
_tcsnicmp(ext,_T("dcr"),3)==0 ||
_tcsnicmp(ext,_T("raw"),3)==0 ||
_tcsnicmp(ext,_T("x3f"),3)==0 ||
_tcsnicmp(ext,_T("mef"),3)==0 ||
_tcsnicmp(ext,_T("raf"),3)==0 ||
_tcsnicmp(ext,_T("mrw"),3)==0 ||
_tcsnicmp(ext,_T("pef"),3)==0 ||
_tcsnicmp(ext,_T("sr2"),3)==0 ||
_tcsnicmp(ext,_T("orf"),3)==0 ) return CXIMAGE_FORMAT_RAW;
#endif
return CXIMAGE_FORMAT_UNKNOWN;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetTypeIdFromIndex(const DWORD index)
{
DWORD n;
n=0; if (index == n) return CXIMAGE_FORMAT_UNKNOWN;
#if CXIMAGE_SUPPORT_BMP
n++; if (index == n) return CXIMAGE_FORMAT_BMP;
#endif
#if CXIMAGE_SUPPORT_GIF
n++; if (index == n) return CXIMAGE_FORMAT_GIF;
#endif
#if CXIMAGE_SUPPORT_JPG
n++; if (index == n) return CXIMAGE_FORMAT_JPG;
#endif
#if CXIMAGE_SUPPORT_PNG
n++; if (index == n) return CXIMAGE_FORMAT_PNG;
#endif
#if CXIMAGE_SUPPORT_ICO
n++; if (index == n) return CXIMAGE_FORMAT_ICO;
#endif
#if CXIMAGE_SUPPORT_TIF
n++; if (index == n) return CXIMAGE_FORMAT_TIF;
#endif
#if CXIMAGE_SUPPORT_TGA
n++; if (index == n) return CXIMAGE_FORMAT_TGA;
#endif
#if CXIMAGE_SUPPORT_PCX
n++; if (index == n) return CXIMAGE_FORMAT_PCX;
#endif
#if CXIMAGE_SUPPORT_WBMP
n++; if (index == n) return CXIMAGE_FORMAT_WBMP;
#endif
#if CXIMAGE_SUPPORT_WMF
n++; if (index == n) return CXIMAGE_FORMAT_WMF;
#endif
#if CXIMAGE_SUPPORT_JP2
n++; if (index == n) return CXIMAGE_FORMAT_JP2;
#endif
#if CXIMAGE_SUPPORT_JPC
n++; if (index == n) return CXIMAGE_FORMAT_JPC;
#endif
#if CXIMAGE_SUPPORT_PGX
n++; if (index == n) return CXIMAGE_FORMAT_PGX;
#endif
#if CXIMAGE_SUPPORT_PNM
n++; if (index == n) return CXIMAGE_FORMAT_PNM;
#endif
#if CXIMAGE_SUPPORT_RAS
n++; if (index == n) return CXIMAGE_FORMAT_RAS;
#endif
#if CXIMAGE_SUPPORT_JBG
n++; if (index == n) return CXIMAGE_FORMAT_JBG;
#endif
#if CXIMAGE_SUPPORT_MNG
n++; if (index == n) return CXIMAGE_FORMAT_MNG;
#endif
#if CXIMAGE_SUPPORT_SKA
n++; if (index == n) return CXIMAGE_FORMAT_SKA;
#endif
#if CXIMAGE_SUPPORT_RAW
n++; if (index == n) return CXIMAGE_FORMAT_RAW;
#endif
return CXIMAGE_FORMAT_UNKNOWN;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::GetTypeIndexFromId(const DWORD id)
{
DWORD n;
n=0; if (id == CXIMAGE_FORMAT_UNKNOWN) return n;
#if CXIMAGE_SUPPORT_BMP
n++; if (id == CXIMAGE_FORMAT_BMP) return n;
#endif
#if CXIMAGE_SUPPORT_GIF
n++; if (id == CXIMAGE_FORMAT_GIF) return n;
#endif
#if CXIMAGE_SUPPORT_JPG
n++; if (id == CXIMAGE_FORMAT_JPG) return n;
#endif
#if CXIMAGE_SUPPORT_PNG
n++; if (id == CXIMAGE_FORMAT_PNG) return n;
#endif
#if CXIMAGE_SUPPORT_ICO
n++; if (id == CXIMAGE_FORMAT_ICO) return n;
#endif
#if CXIMAGE_SUPPORT_TIF
n++; if (id == CXIMAGE_FORMAT_TIF) return n;
#endif
#if CXIMAGE_SUPPORT_TGA
n++; if (id == CXIMAGE_FORMAT_TGA) return n;
#endif
#if CXIMAGE_SUPPORT_PCX
n++; if (id == CXIMAGE_FORMAT_PCX) return n;
#endif
#if CXIMAGE_SUPPORT_WBMP
n++; if (id == CXIMAGE_FORMAT_WBMP) return n;
#endif
#if CXIMAGE_SUPPORT_WMF
n++; if (id == CXIMAGE_FORMAT_WMF) return n;
#endif
#if CXIMAGE_SUPPORT_JP2
n++; if (id == CXIMAGE_FORMAT_JP2) return n;
#endif
#if CXIMAGE_SUPPORT_JPC
n++; if (id == CXIMAGE_FORMAT_JPC) return n;
#endif
#if CXIMAGE_SUPPORT_PGX
n++; if (id == CXIMAGE_FORMAT_PGX) return n;
#endif
#if CXIMAGE_SUPPORT_PNM
n++; if (id == CXIMAGE_FORMAT_PNM) return n;
#endif
#if CXIMAGE_SUPPORT_RAS
n++; if (id == CXIMAGE_FORMAT_RAS) return n;
#endif
#if CXIMAGE_SUPPORT_JBG
n++; if (id == CXIMAGE_FORMAT_JBG) return n;
#endif
#if CXIMAGE_SUPPORT_MNG
n++; if (id == CXIMAGE_FORMAT_MNG) return n;
#endif
#if CXIMAGE_SUPPORT_SKA
n++; if (id == CXIMAGE_FORMAT_SKA) return n;
#endif
#if CXIMAGE_SUPPORT_RAW
n++; if (id == CXIMAGE_FORMAT_RAW) return n;
#endif
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return current frame delay in milliseconds. Only for GIF and MNG formats.
*/
DWORD CxImage::GetFrameDelay() const
{
return info.dwFrameDelay;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets current frame delay. Only for GIF format.
* \param d = delay in milliseconds
*/
void CxImage::SetFrameDelay(DWORD d)
{
info.dwFrameDelay=d;
}
////////////////////////////////////////////////////////////////////////////////
void CxImage::GetOffset(long *x,long *y)
{
*x=info.xOffset;
*y=info.yOffset;
}
////////////////////////////////////////////////////////////////////////////////
void CxImage::SetOffset(long x,long y)
{
info.xOffset=x;
info.yOffset=y;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetJpegQuality, GetJpegQualityF
* \author [DP]; changes [Stefan Schürmans]
*/
BYTE CxImage::GetJpegQuality() const
{
return (BYTE)(info.fQuality + 0.5f);
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetJpegQuality, GetJpegQuality
* \author [Stefan Schürmans]
*/
float CxImage::GetJpegQualityF() const
{
return info.fQuality;
}
////////////////////////////////////////////////////////////////////////////////
/**
* quality level for JPEG and JPEG2000
* \param q: can be from 0 to 100
* \author [DP]; changes [Stefan Schürmans]
*/
void CxImage::SetJpegQuality(BYTE q){
info.fQuality = (float)q;
}
////////////////////////////////////////////////////////////////////////////////
/**
* quality level for JPEG and JPEG2000
* necessary for JPEG2000 when quality is between 0.0 and 1.0
* \param q: can be from 0.0 to 100.0
* \author [Stefan Schürmans]
*/
void CxImage::SetJpegQualityF(float q){
if (q>0) info.fQuality = q;
else info.fQuality = 0.0f;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetJpegScale
*/
BYTE CxImage::GetJpegScale() const
{
return info.nJpegScale;
}
////////////////////////////////////////////////////////////////////////////////
/**
* scaling down during JPEG decoding valid numbers are 1, 2, 4, 8
* \author [ignacio]
*/
void CxImage::SetJpegScale(BYTE q){
info.nJpegScale = q;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Used to monitor the slow loops.
* \return value is from 0 to 100.
* \sa SetProgress
*/
long CxImage::GetProgress() const
{
return info.nProgress;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return the escape code.
* \sa SetEscape
*/
long CxImage::GetEscape() const
{
return info.nEscape;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Forces the value of the internal progress variable.
* \param p should be from 0 to 100.
* \sa GetProgress
*/
void CxImage::SetProgress(long p)
{
info.nProgress = p;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Used to quit the slow loops or the codecs.
* - SetEscape(-1) before Decode forces the function to exit, right after
* the image width and height are available ( for bmp, jpg, gif, tif )
*/
void CxImage::SetEscape(long i)
{
info.nEscape = i;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Checks if the image is correctly initializated.
*/
bool CxImage::IsValid() const
{
return pDib!=0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* True if the image is enabled for painting.
*/
bool CxImage::IsEnabled() const
{
return info.bEnabled;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Enables/disables the image.
*/
void CxImage::Enable(bool enable)
{
info.bEnabled=enable;
}
////////////////////////////////////////////////////////////////////////////////
/**
* This function must be used after a Decode() / Load() call.
* Use the sequence SetFrame(-1); Load(...); GetNumFrames();
* to get the number of images without loading the first image.
* \return the number of images in the file.
*/
long CxImage::GetNumFrames() const
{
return info.nNumFrames;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return the current selected image (zero-based index).
*/
long CxImage::GetFrame() const
{
return info.nFrame;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the image number that the next Decode() / Load() call will load
*/
void CxImage::SetFrame(long nFrame){
info.nFrame=nFrame;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the method for drawing the frame related to others
* \sa GetDisposalMethod
*/
void CxImage::SetDisposalMethod(BYTE dm)
{ info.dispmeth=dm; }
////////////////////////////////////////////////////////////////////////////////
/**
* Gets the method for drawing the frame related to others
* Values : 0 - No disposal specified. The decoder is
* not required to take any action.
* 1 - Do not dispose. The graphic is to be left
* in place.
* 2 - Restore to background color. The area used by the
* graphic must be restored to the background color.
* 3 - Restore to previous. The decoder is required to
* restore the area overwritten by the graphic with
* what was there prior to rendering the graphic.
* 4-7 - To be defined.
*/
BYTE CxImage::GetDisposalMethod() const
{ return info.dispmeth; }
////////////////////////////////////////////////////////////////////////////////
bool CxImage::GetRetreiveAllFrames() const
{ return info.bGetAllFrames; }
////////////////////////////////////////////////////////////////////////////////
void CxImage::SetRetreiveAllFrames(bool flag)
{ info.bGetAllFrames = flag; }
////////////////////////////////////////////////////////////////////////////////
CxImage * CxImage::GetFrame(long nFrame) const
{
if ( ppFrames == NULL) return NULL;
if ( info.nNumFrames == 0) return NULL;
if ( nFrame >= info.nNumFrames ) return NULL;
if ( nFrame < 0) nFrame = info.nNumFrames - 1;
return ppFrames[nFrame];
}
////////////////////////////////////////////////////////////////////////////////
short CxImage::ntohs(const short word)
{
if (info.bLittleEndianHost) return word;
return ( (word & 0xff) << 8 ) | ( (word >> 8) & 0xff );
}
////////////////////////////////////////////////////////////////////////////////
long CxImage::ntohl(const long dword)
{
if (info.bLittleEndianHost) return dword;
return ((dword & 0xff) << 24 ) | ((dword & 0xff00) << 8 ) |
((dword >> 8) & 0xff00) | ((dword >> 24) & 0xff);
}
////////////////////////////////////////////////////////////////////////////////
void CxImage::bihtoh(BITMAPINFOHEADER* bih)
{
bih->biSize = ntohl(bih->biSize);
bih->biWidth = ntohl(bih->biWidth);
bih->biHeight = ntohl(bih->biHeight);
bih->biPlanes = ntohs(bih->biPlanes);
bih->biBitCount = ntohs(bih->biBitCount);
bih->biCompression = ntohl(bih->biCompression);
bih->biSizeImage = ntohl(bih->biSizeImage);
bih->biXPelsPerMeter = ntohl(bih->biXPelsPerMeter);
bih->biYPelsPerMeter = ntohl(bih->biYPelsPerMeter);
bih->biClrUsed = ntohl(bih->biClrUsed);
bih->biClrImportant = ntohl(bih->biClrImportant);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Returns the last reported error.
*/
const char* CxImage::GetLastError()
{
return info.szLastError;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::DumpSize()
{
DWORD n;
n = sizeof(BITMAPINFOHEADER) + sizeof(CXIMAGEINFO) + GetSize();
if (pAlpha){
n += 1 + head.biWidth * head.biHeight;
} else n++;
if (pSelection){
n += 1 + head.biWidth * head.biHeight;
} else n++;
if (ppLayers){
for (long m=0; m<GetNumLayers(); m++){
if (GetLayer(m)){
n += 1 + GetLayer(m)->DumpSize();
}
}
} else n++;
if (ppFrames){
for (long m=0; m<GetNumFrames(); m++){
if (GetFrame(m)){
n += 1 + GetFrame(m)->DumpSize();
}
}
} else n++;
return n;
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::Dump(BYTE * dst)
{
if (!dst) return 0;
memcpy(dst,&head,sizeof(BITMAPINFOHEADER));
dst += sizeof(BITMAPINFOHEADER);
memcpy(dst,&info,sizeof(CXIMAGEINFO));
dst += sizeof(CXIMAGEINFO);
memcpy(dst,pDib,GetSize());
dst += GetSize();
if (pAlpha){
memset(dst++, 1, 1);
memcpy(dst,pAlpha,head.biWidth * head.biHeight);
dst += head.biWidth * head.biHeight;
} else {
memset(dst++, 0, 1);
}
if (pSelection){
memset(dst++, 1, 1);
memcpy(dst,pSelection,head.biWidth * head.biHeight);
dst += head.biWidth * head.biHeight;
} else {
memset(dst++, 0, 1);
}
if (ppLayers){
memset(dst++, 1, 1);
for (long m=0; m<GetNumLayers(); m++){
if (GetLayer(m)){
dst += GetLayer(m)->Dump(dst);
}
}
} else {
memset(dst++, 0, 1);
}
if (ppFrames){
memset(dst++, 1, 1);
for (long m=0; m<GetNumFrames(); m++){
if (GetFrame(m)){
dst += GetFrame(m)->Dump(dst);
}
}
} else {
memset(dst++, 0, 1);
}
return DumpSize();
}
////////////////////////////////////////////////////////////////////////////////
DWORD CxImage::UnDump(const BYTE * src)
{
if (!src)
return 0;
if (!Destroy())
return 0;
if (!DestroyFrames())
return 0;
DWORD n = 0;
memcpy(&head,src,sizeof(BITMAPINFOHEADER));
n += sizeof(BITMAPINFOHEADER);
memcpy(&info,&src[n],sizeof(CXIMAGEINFO));
n += sizeof(CXIMAGEINFO);
if (!Create(head.biWidth, head.biHeight, head.biBitCount, info.dwType))
return 0;
memcpy(pDib,&src[n],GetSize());
n += GetSize();
if (src[n++]){
if (AlphaCreate()){
memcpy(pAlpha, &src[n], head.biWidth * head.biHeight);
}
n += head.biWidth * head.biHeight;
}
if (src[n++]){
RECT box = info.rSelectionBox;
if (SelectionCreate()){
info.rSelectionBox = box;
memcpy(pSelection, &src[n], head.biWidth * head.biHeight);
}
n += head.biWidth * head.biHeight;
}
if (src[n++]){
ppLayers = new CxImage*[info.nNumLayers];
for (long m=0; m<GetNumLayers(); m++){
ppLayers[m] = new CxImage();
n += ppLayers[m]->UnDump(&src[n]);
}
}
if (src[n++]){
ppFrames = new CxImage*[info.nNumFrames];
for (long m=0; m<GetNumFrames(); m++){
ppFrames[m] = new CxImage();
n += ppFrames[m]->UnDump(&src[n]);
}
}
return n;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return A.BBCCCDDDD
* - A = main version
* - BB = main revision
* - CCC = minor revision (letter)
* - DDDD = experimental revision
*/
const float CxImage::GetVersionNumber()
{
return 6.000000015f;
}
////////////////////////////////////////////////////////////////////////////////
const TCHAR* CxImage::GetVersion()
{
static const TCHAR CxImageVersion[] = _T("CxImage 6.0.0");
return (CxImageVersion);
}
////////////////////////////////////////////////////////////////////////////////
File diff suppressed because it is too large Load Diff
+253
View File
@@ -0,0 +1,253 @@
/*
* File: ImaIter.h
* Purpose: Declaration of the Platform Independent Image Base Class
* Author: Alejandro Aguilar Sierra
* Created: 1995
* Copyright: (c) 1995, Alejandro Aguilar Sierra <asierra(at)servidor(dot)unam(dot)mx>
*
* 07/08/2001 Davide Pizzolato - www.xdp.it
* - removed slow loops
* - added safe checks
*
* Permission is given by the author to freely redistribute and include
* this code in any program as long as this credit is given where due.
*
* COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
* OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
* THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
* OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
* CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
* THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
* SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
* PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
* THIS DISCLAIMER.
*
* Use at your own risk!
* ==========================================================
*/
#if !defined(__ImaIter_h)
#define __ImaIter_h
#include "ximage.h"
#include "ximadef.h"
class CImageIterator
{
friend class CxImage;
protected:
int Itx, Ity; // Counters
int Stepx, Stepy;
BYTE* IterImage; // Image pointer
CxImage *ima;
public:
// Constructors
CImageIterator ( void );
CImageIterator ( CxImage *image );
operator CxImage* ();
// Iterators
BOOL ItOK ();
void Reset ();
void Upset ();
void SetRow(BYTE *buf, int n);
void GetRow(BYTE *buf, int n);
BYTE GetByte( ) { return IterImage[Itx]; }
void SetByte(BYTE b) { IterImage[Itx] = b; }
BYTE* GetRow(void);
BYTE* GetRow(int n);
BOOL NextRow();
BOOL PrevRow();
BOOL NextByte();
BOOL PrevByte();
void SetSteps(int x, int y=0) { Stepx = x; Stepy = y; }
void GetSteps(int *x, int *y) { *x = Stepx; *y = Stepy; }
BOOL NextStep();
BOOL PrevStep();
void SetY(int y); /* AD - for interlace */
int GetY() {return Ity;}
BOOL GetCol(BYTE* pCol, DWORD x);
BOOL SetCol(BYTE* pCol, DWORD x);
};
/////////////////////////////////////////////////////////////////////
inline
CImageIterator::CImageIterator(void)
{
ima = 0;
IterImage = 0;
Itx = Ity = 0;
Stepx = Stepy = 0;
}
/////////////////////////////////////////////////////////////////////
inline
CImageIterator::CImageIterator(CxImage *imageImpl): ima(imageImpl)
{
if (ima) IterImage = ima->GetBits();
Itx = Ity = 0;
Stepx = Stepy = 0;
}
/////////////////////////////////////////////////////////////////////
inline
CImageIterator::operator CxImage* ()
{
return ima;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::ItOK ()
{
if (ima) return ima->IsInside(Itx, Ity);
else return FALSE;
}
/////////////////////////////////////////////////////////////////////
inline void CImageIterator::Reset()
{
if (ima) IterImage = ima->GetBits();
else IterImage=0;
Itx = Ity = 0;
}
/////////////////////////////////////////////////////////////////////
inline void CImageIterator::Upset()
{
Itx = 0;
Ity = ima->GetHeight()-1;
IterImage = ima->GetBits() + ima->GetEffWidth()*(ima->GetHeight()-1);
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::NextRow()
{
if (++Ity >= (int)ima->GetHeight()) return 0;
IterImage += ima->GetEffWidth();
return 1;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::PrevRow()
{
if (--Ity < 0) return 0;
IterImage -= ima->GetEffWidth();
return 1;
}
/* AD - for interlace */
inline void CImageIterator::SetY(int y)
{
if ((y < 0) || (y > (int)ima->GetHeight())) return;
Ity = y;
IterImage = ima->GetBits() + ima->GetEffWidth()*y;
}
/////////////////////////////////////////////////////////////////////
inline void CImageIterator::SetRow(BYTE *buf, int n)
{
if (n<0) n = (int)ima->GetEffWidth();
else n = min(n,(int)ima->GetEffWidth());
if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
}
/////////////////////////////////////////////////////////////////////
inline void CImageIterator::GetRow(BYTE *buf, int n)
{
if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
}
/////////////////////////////////////////////////////////////////////
inline BYTE* CImageIterator::GetRow()
{
return IterImage;
}
/////////////////////////////////////////////////////////////////////
inline BYTE* CImageIterator::GetRow(int n)
{
SetY(n);
return IterImage;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::NextByte()
{
if (++Itx < (int)ima->GetEffWidth()) return 1;
else
if (++Ity < (int)ima->GetHeight()){
IterImage += ima->GetEffWidth();
Itx = 0;
return 1;
} else
return 0;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::PrevByte()
{
if (--Itx >= 0) return 1;
else
if (--Ity >= 0){
IterImage -= ima->GetEffWidth();
Itx = 0;
return 1;
} else
return 0;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::NextStep()
{
Itx += Stepx;
if (Itx < (int)ima->GetEffWidth()) return 1;
else {
Ity += Stepy;
if (Ity < (int)ima->GetHeight()){
IterImage += ima->GetEffWidth();
Itx = 0;
return 1;
} else
return 0;
}
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::PrevStep()
{
Itx -= Stepx;
if (Itx >= 0) return 1;
else {
Ity -= Stepy;
if (Ity >= 0 && Ity < (int)ima->GetHeight()) {
IterImage -= ima->GetEffWidth();
Itx = 0;
return 1;
} else
return 0;
}
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::GetCol(BYTE* pCol, DWORD x)
{
if ((pCol==0)||(ima->GetBpp()<8)||(x>=ima->GetWidth()))
return 0;
DWORD h = ima->GetHeight();
//DWORD line = ima->GetEffWidth();
BYTE bytes = (BYTE)(ima->GetBpp()>>3);
BYTE* pSrc;
for (DWORD y=0;y<h;y++){
pSrc = ima->GetBits(y) + x*bytes;
for (BYTE w=0;w<bytes;w++){
*pCol++=*pSrc++;
}
}
return 1;
}
/////////////////////////////////////////////////////////////////////
inline BOOL CImageIterator::SetCol(BYTE* pCol, DWORD x)
{
if ((pCol==0)||(ima->GetBpp()<8)||(x>=ima->GetWidth()))
return 0;
DWORD h = ima->GetHeight();
//DWORD line = ima->GetEffWidth();
BYTE bytes = (BYTE)(ima->GetBpp()>>3);
BYTE* pSrc;
for (DWORD y=0;y<h;y++){
pSrc = ima->GetBits(y) + x*bytes;
for (BYTE w=0;w<bytes;w++){
*pSrc++=*pCol++;
}
}
return 1;
}
/////////////////////////////////////////////////////////////////////
#endif
+325
View File
@@ -0,0 +1,325 @@
/*
* File: ximajas.cpp
* Purpose: Platform Independent JasPer Image Class Loader and Writer
* 12/Apr/2003 Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximajas.h"
#if CXIMAGE_SUPPORT_JASPER
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageJAS::Decode(CxFile *hFile, DWORD imagetype)
{
if (hFile == NULL) return false;
jas_image_t *image=0;
jas_stream_t *in=0;
jas_matrix_t **bufs=0;
long i,error=0;
int fmt;
//jas_setdbglevel(0);
cx_try
{
if (jas_init())
cx_throw("cannot initialize jasper");
in = jas_stream_fdopen(0, "rb");
if (!in)
cx_throw("error: cannot open standard input");
CxFileJas src(hFile,in);
fmt = jas_image_getfmt(in);
if (fmt<0)
cx_throw("error: unknowm format");
image = jas_image_decode(in, fmt, 0);
if (!image){
fmt = -1;
cx_throw("error: cannot load image data");
}
char szfmt[4];
*szfmt = '\0';
strncpy(szfmt,jas_image_fmttostr(fmt),3);
szfmt[3] = '\0';
fmt = -1;
#if CXIMAGE_SUPPORT_JP2
if (strcmp(szfmt,"jp2")==0) fmt = CXIMAGE_FORMAT_JP2;
#endif
#if CXIMAGE_SUPPORT_JPC
if (strcmp(szfmt,"jpc")==0) fmt = CXIMAGE_FORMAT_JPC;
#endif
#if CXIMAGE_SUPPORT_RAS
if (strcmp(szfmt,"ras")==0) fmt = CXIMAGE_FORMAT_RAS;
#endif
#if CXIMAGE_SUPPORT_PNM
if (strcmp(szfmt,"pnm")==0) fmt = CXIMAGE_FORMAT_PNM;
#endif
#if CXIMAGE_SUPPORT_PGX
if (strcmp(szfmt,"pgx")==0) fmt = CXIMAGE_FORMAT_PGX;
#endif
//if (fmt<0)
// cx_throw("error: unknowm format");
long x,y,w,h,depth,cmptno;
w = jas_image_cmptwidth(image,0);
h = jas_image_cmptheight(image,0);
depth = jas_image_cmptprec(image,0);
if (info.nEscape == -1){
head.biWidth = w;
head.biHeight= h;
info.dwType = fmt<0 ? 0 : fmt;
cx_throw("output dimensions returned");
}
if (image->numcmpts_ > 64 || image->numcmpts_ < 0)
cx_throw("error: too many components");
// <LD> 01/Jan/2005: Always force conversion to sRGB. Seems to be required for many types of JPEG2000 file.
// if (depth!=1 && depth!=4 && depth!=8)
if (image->numcmpts_>=3 && depth <=8)
{
jas_image_t *newimage;
jas_cmprof_t *outprof;
//jas_eprintf("forcing conversion to sRGB\n");
outprof = jas_cmprof_createfromclrspc(JAS_CLRSPC_SRGB);
if (!outprof) {
cx_throw("cannot create sRGB profile");
}
newimage = jas_image_chclrspc(image, outprof, JAS_CMXFORM_INTENT_PER);
if (!newimage) {
jas_cmprof_destroy(outprof); // <LD> 01/Jan/2005: Destroy color profile on error.
cx_throw("cannot convert to sRGB");
}
jas_image_destroy(image);
jas_cmprof_destroy(outprof);
image = newimage;
}
bufs = (jas_matrix_t **)calloc(image->numcmpts_, sizeof(jas_matrix_t**));
for (i = 0; i < image->numcmpts_; ++i) {
bufs[i] = jas_matrix_create(1, w);
if (!bufs[i]) {
cx_throw("error: cannot allocate memory");
}
}
int nshift = (depth>8) ? (depth-8) : 0;
if (image->numcmpts_==3 &&
image->cmpts_[0]->width_ == image->cmpts_[1]->width_ &&
image->cmpts_[1]->width_ == image->cmpts_[2]->width_ &&
image->cmpts_[0]->height_ == image->cmpts_[1]->height_ &&
image->cmpts_[1]->height_ == image->cmpts_[2]->height_ &&
image->cmpts_[0]->prec_ == image->cmpts_[1]->prec_ &&
image->cmpts_[1]->prec_ == image->cmpts_[2]->prec_ )
{
if(!Create(w,h,24,fmt))
cx_throw("");
RGBQUAD c;
for (y=0; y<h; y++) {
for (cmptno = 0; cmptno < image->numcmpts_; ++cmptno) {
jas_image_readcmpt(image, cmptno, 0, y, w, 1, bufs[cmptno]);
}
for (x=0; x<w; x++){
c.rgbRed = (BYTE)((jas_matrix_getv(bufs[0], x)>>nshift));
c.rgbGreen = (BYTE)((jas_matrix_getv(bufs[1], x)>>nshift));
c.rgbBlue = (BYTE)((jas_matrix_getv(bufs[2], x)>>nshift));
SetPixelColor(x,h-1-y,c);
}
}
} else {
info.nNumFrames = image->numcmpts_;
if ((info.nFrame<0)||(info.nFrame>=info.nNumFrames)){
cx_throw("wrong frame!");
}
for (cmptno=0; cmptno<=info.nFrame; cmptno++) {
w = jas_image_cmptwidth(image,cmptno);
h = jas_image_cmptheight(image,cmptno);
depth = jas_image_cmptprec(image,cmptno);
if (depth>8) depth=8;
if(!Create(w,h,depth,imagetype))
cx_throw("");
SetGrayPalette();
for (y=0; y<h; y++) {
jas_image_readcmpt(image, cmptno, 0, y, w, 1, bufs[0]);
for (x=0; x<w; x++){
SetPixelIndex(x,h-1-y,(BYTE)((jas_matrix_getv(bufs[0], x)>>nshift)));
}
}
}
}
} cx_catch {
if (strcmp(message,"")) strncpy(info.szLastError,message,255);
if (info.nEscape == -1 && fmt>0){
error = 0;
} else {
error = 1;
}
}
if (bufs) {
for (i = 0; i < image->numcmpts_; ++i){ if (bufs[i]) jas_matrix_destroy(bufs[i]);}
free(bufs);
}
jas_cleanup();
if (image) jas_image_destroy(image);
if (in) jas_stream_close(in);
return (error==0);
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageJAS::Encode(CxFile * hFile, DWORD imagetype)
{
if (EncodeSafeCheck(hFile)) return false;
if (head.biClrUsed!=0 && !IsGrayScale()){
strcpy(info.szLastError,"JasPer can save only RGB or GrayScale images");
return false;
}
jas_image_t *image=0;
jas_stream_t *out=0;
jas_matrix_t *cmpts[3];
long x,y,yflip,error=0;
uint_fast16_t cmptno, numcmpts=0;
jas_image_cmptparm_t cmptparms[3], *cmptparm;
cx_try {
if (jas_init())
cx_throw("cannot initialize jasper");
out = jas_stream_fdopen(0, "wb");
if (!out)
cx_throw("error: cannot open standard output");
CxFileJas src(hFile,out);
numcmpts = head.biClrUsed==0 ? 3 : 1;
for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno, ++cmptparm) {
cmptparm->tlx = 0;
cmptparm->tly = 0;
cmptparm->hstep = 1;
cmptparm->vstep = 1;
cmptparm->width = head.biWidth;
cmptparm->height = head.biHeight;
cmptparm->prec = 8;
cmptparm->sgnd = false;
}
/* Create image object. */
image = jas_image_create(numcmpts, cmptparms, JAS_CLRSPC_UNKNOWN);
if (!image)
cx_throw("error : jas_image_create");
if (numcmpts == 3) {
jas_image_setclrspc(image, JAS_CLRSPC_SRGB);
jas_image_setcmpttype(image, 0,
JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R));
jas_image_setcmpttype(image, 1,
JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G));
jas_image_setcmpttype(image, 2,
JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B));
} else {
jas_image_setclrspc(image, JAS_CLRSPC_SGRAY);
jas_image_setcmpttype(image, 0,
JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y));
}
for (x = 0; x < numcmpts; ++x) { cmpts[x] = 0; }
/* Create temporary matrices to hold component data. */
for (x = 0; x < numcmpts; ++x) {
cmpts[x] = jas_matrix_create(1, head.biWidth);
if (!cmpts[x]) {
cx_throw("error : can't allocate memory");
}
}
RGBQUAD c;
for (y = 0; y < head.biHeight; ++y) {
for (x = 0; x < head.biWidth; ++x) {
if (head.biClrUsed==0){
c = GetPixelColor(x,y);
jas_matrix_setv(cmpts[0], x, c.rgbRed);
jas_matrix_setv(cmpts[1], x, c.rgbGreen);
jas_matrix_setv(cmpts[2], x, c.rgbBlue);
} else {
jas_matrix_setv(cmpts[0], x, GetPixelIndex(x,y));
}
}
yflip = head.biHeight - 1 - y;
for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
if (jas_image_writecmpt(image, cmptno, 0, yflip, head.biWidth, 1, cmpts[cmptno])) {
cx_throw("error : jas_image_writecmpt");
}
}
}
char szfmt[4];
*szfmt = '\0';
#if CXIMAGE_SUPPORT_JP2
if (imagetype == CXIMAGE_FORMAT_JP2) strcpy(szfmt,"jp2");
#endif
#if CXIMAGE_SUPPORT_JPC
if (imagetype == CXIMAGE_FORMAT_JPC) strcpy(szfmt,"jpc");
#endif
#if CXIMAGE_SUPPORT_RAS
if (imagetype == CXIMAGE_FORMAT_RAS) strcpy(szfmt,"ras");
#endif
#if CXIMAGE_SUPPORT_PNM
if (imagetype == CXIMAGE_FORMAT_PNM) strcpy(szfmt,"pnm");
#endif
#if CXIMAGE_SUPPORT_PGX
if (imagetype == CXIMAGE_FORMAT_PGX){
strcpy(szfmt,"pgx");
if (head.biClrUsed==0) cx_throw("PGX can save only GrayScale images");
}
#endif
int outfmt = jas_image_strtofmt(szfmt);
char szoutopts[32];
sprintf(szoutopts,"rate=%.3f", info.fQuality/100.0f);
if (jas_image_encode(image, out, outfmt, szoutopts)) {
cx_throw("error: cannot encode image");
}
jas_stream_flush(out);
} cx_catch {
if (strcmp(message,"")) strncpy(info.szLastError,message,255);
error = 1;
}
for (x = 0; x < numcmpts; ++x) { if (cmpts[x]) { jas_matrix_destroy(cmpts[x]); } }
jas_cleanup();
if (image) jas_image_destroy(image);
if (out) jas_stream_close(out);
return (error==0);
}
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_ENCODE
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_JASPER
+84
View File
@@ -0,0 +1,84 @@
/*
* File: ximajas.h
* Purpose: Jasper Image Class Loader and Writer
*/
/* ==========================================================
* CxImageJAS (c) 12/Apr/2003 Davide Pizzolato - www.xdp.it
* For conditions of distribution and use, see copyright notice in ximage.h
*
* based on JasPer Copyright (c) 2001-2003 Michael David Adams - All rights reserved.
* ==========================================================
*/
#if !defined(__ximaJAS_h)
#define __ximaJAS_h
#include "ximage.h"
#if CXIMAGE_SUPPORT_JASPER
#include "../jasper/include/jasper/jasper.h"
class CxImageJAS: public CxImage
{
public:
CxImageJAS(): CxImage((DWORD)0) {} // <vho> cast to DWORD
// bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,0);}
// bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,0);}
bool Decode(CxFile * hFile, DWORD imagetype = 0);
bool Decode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Decode(&file,imagetype); }
#if CXIMAGE_SUPPORT_ENCODE
bool Encode(CxFile * hFile, DWORD imagetype = 0);
bool Encode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Encode(&file,imagetype); }
#endif // CXIMAGE_SUPPORT_ENCODE
protected:
class CxFileJas
{
public:
CxFileJas(CxFile* pFile,jas_stream_t *stream)
{
if (stream->obj_) jas_free(stream->obj_);
stream->obj_ = pFile;
// <vho> - cannot set the stream->ops_->functions here,
// because this overwrites a static structure in the Jasper library.
// This structure is used by Jasper for internal operations too, e.g. tempfile.
// However the ops_ pointer in the stream can be overwritten.
//stream->ops_->close_ = JasClose;
//stream->ops_->read_ = JasRead;
//stream->ops_->seek_ = JasSeek;
//stream->ops_->write_ = JasWrite;
jas_stream_CxFile.close_ = JasClose;
jas_stream_CxFile.read_ = JasRead;
jas_stream_CxFile.seek_ = JasSeek;
jas_stream_CxFile.write_ = JasWrite;
stream->ops_ = &jas_stream_CxFile;
// <vho> - end
}
static int JasRead(jas_stream_obj_t *obj, char *buf, int cnt)
{ return ((CxFile*)obj)->Read(buf,1,cnt); }
static int JasWrite(jas_stream_obj_t *obj, char *buf, int cnt)
{ return ((CxFile*)obj)->Write(buf,1,cnt); }
static long JasSeek(jas_stream_obj_t *obj, long offset, int origin)
{ return ((CxFile*)obj)->Seek(offset,origin); }
static int JasClose(jas_stream_obj_t * /*obj*/)
{ return 1; }
// <vho>
private:
jas_stream_ops_t jas_stream_CxFile;
// <vho> - end
};
};
#endif
#endif
+174
View File
@@ -0,0 +1,174 @@
/*
* File: ximajbg.cpp
* Purpose: Platform Independent JBG Image Class Loader and Writer
* 18/Aug/2002 Davide Pizzolato - www.xdp.it
* CxImage version 6.0.0 02/Feb/2008
*/
#include "ximajbg.h"
#if CXIMAGE_SUPPORT_JBG
#include "ximaiter.h"
#define JBIG_BUFSIZE 8192
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageJBG::Decode(CxFile *hFile)
{
if (hFile == NULL) return false;
struct jbg_dec_state jbig_state;
unsigned long xmax = 4294967295UL, ymax = 4294967295UL;
unsigned int len, cnt;
BYTE *buffer,*p;
int result;
cx_try
{
jbg_dec_init(&jbig_state);
jbg_dec_maxsize(&jbig_state, xmax, ymax);
buffer = (BYTE*)malloc(JBIG_BUFSIZE);
if (!buffer) cx_throw("Sorry, not enough memory available!");
result = JBG_EAGAIN;
do {
len = hFile->Read(buffer, 1, JBIG_BUFSIZE);
if (!len) break;
cnt = 0;
p = buffer;
while (len > 0 && (result == JBG_EAGAIN || result == JBG_EOK)) {
result = jbg_dec_in(&jbig_state, p, len, &cnt);
p += cnt;
len -= cnt;
}
} while (result == JBG_EAGAIN || result == JBG_EOK);
if (hFile->Error())
cx_throw("Problem while reading input file");
if (result != JBG_EOK && result != JBG_EOK_INTR)
cx_throw("Problem with input file");
int w, h, bpp, planes, ew;
w = jbg_dec_getwidth(&jbig_state);
h = jbg_dec_getheight(&jbig_state);
planes = jbg_dec_getplanes(&jbig_state);
bpp = (planes+7)>>3;
ew = (w + 7)>>3;
if (info.nEscape == -1){
head.biWidth = w;
head.biHeight= h;
info.dwType = CXIMAGE_FORMAT_JBG;
cx_throw("output dimensions returned");
}
switch (planes){
case 1:
{
BYTE* binary_image = jbg_dec_getimage(&jbig_state, 0);
if (!Create(w,h,1,CXIMAGE_FORMAT_JBG))
cx_throw("");
SetPaletteColor(0,255,255,255);
SetPaletteColor(1,0,0,0);
CImageIterator iter(this);
iter.Upset();
for (int i=0;i<h;i++){
iter.SetRow(binary_image+i*ew,ew);
iter.PrevRow();
}
break;
}
default:
cx_throw("cannot decode images with more than 1 plane");
}
jbg_dec_free(&jbig_state);
free(buffer);
} cx_catch {
jbg_dec_free(&jbig_state);
if (buffer) free(buffer);
if (strcmp(message,"")) strncpy(info.szLastError,message,255);
if (info.nEscape == -1 && info.dwType == CXIMAGE_FORMAT_JBG) return true;
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_DECODE
////////////////////////////////////////////////////////////////////////////////
bool CxImageJBG::Encode(CxFile * hFile)
{
if (EncodeSafeCheck(hFile)) return false;
if (head.biBitCount != 1){
strcpy(info.szLastError,"JBG can save only 1-bpp images");
return false;
}
int w, h, bpp, planes, ew, i, j, x, y;
w = head.biWidth;
h = head.biHeight;
planes = 1;
bpp = (planes+7)>>3;
ew = (w + 7)>>3;
BYTE mask;
RGBQUAD *rgb = GetPalette();
if (CompareColors(&rgb[0],&rgb[1])<0) mask=255; else mask=0;
BYTE *buffer = (BYTE*)malloc(ew*h*2);
if (!buffer) {
strcpy(info.szLastError,"Sorry, not enough memory available!");
return false;
}
for (y=0; y<h; y++){
i= y*ew;
j= (h-y-1)*info.dwEffWidth;
for (x=0; x<ew; x++){
buffer[i + x]=info.pImage[j + x]^mask;
}
}
struct jbg_enc_state jbig_state;
jbg_enc_init(&jbig_state, w, h, planes, &buffer, jbig_data_out, hFile);
//jbg_enc_layers(&jbig_state, 2);
//jbg_enc_lrlmax(&jbig_state, 800, 600);
// Specify a few other options (each is ignored if negative)
int dl = -1, dh = -1, d = -1, l0 = -1, mx = -1;
int options = JBG_TPDON | JBG_TPBON | JBG_DPON;
int order = JBG_ILEAVE | JBG_SMID;
jbg_enc_lrange(&jbig_state, dl, dh);
jbg_enc_options(&jbig_state, order, options, l0, mx, -1);
// now encode everything and send it to data_out()
jbg_enc_out(&jbig_state);
// give encoder a chance to free its temporary data structures
jbg_enc_free(&jbig_state);
free(buffer);
if (hFile->Error()){
strcpy(info.szLastError,"Problem while writing JBG file");
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif // CXIMAGE_SUPPORT_JBG

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