Merge pull request #21019 from kadet1090/update-formatting-style
This commit is contained in:
125
.clang-format
125
.clang-format
@@ -1,22 +1,22 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
# --- Based on Qt Coding Style ---
|
||||
BasedOnStyle: LLVM
|
||||
|
||||
# --- Bracket and Indentation Behavior ---
|
||||
IndentWidth: 4
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
TabWidth: 4
|
||||
ColumnLimit: 100
|
||||
UseTab: Never
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: DontAlign
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BinPackArguments: false
|
||||
BreakBeforeBraces: Custom
|
||||
BreakTemplateDeclarations: Yes
|
||||
BreakBeforeBinaryOperators: All
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
@@ -31,41 +31,68 @@ BraceWrapping:
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 100
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 4
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
InsertBraces: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PackConstructorInitializers: Never
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: Never
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: false
|
||||
|
||||
# --- Special: Lambdas and Short Things ---
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
|
||||
# --- Spaces ---
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAfterCStyleCast: false
|
||||
Cpp11BracedListStyle: true
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeInheritanceColon: false
|
||||
|
||||
# --- Alignment & Formatting Tweaks ---
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignOperands: DontAlign
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
PointerAlignment: Left
|
||||
ReferenceAlignment: Left
|
||||
|
||||
# --- Comment Style ---
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
|
||||
# --- Namespace handling ---
|
||||
NamespaceIndentation: None
|
||||
|
||||
# --- Others ---
|
||||
SortIncludes: Never
|
||||
IncludeBlocks: Preserve
|
||||
MaxEmptyLinesToKeep: 2
|
||||
IndentCaseLabels: true
|
||||
InsertBraces: true
|
||||
AlignEscapedNewlines: DontAlign
|
||||
PPIndentWidth: 1
|
||||
IndentPPDirectives: AfterHash
|
||||
ReflowComments: true
|
||||
|
||||
# --- Penalties (Fine-tuning when to break lines) ---
|
||||
PenaltyBreakAssignment: 80
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 60
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakOpenParenthesis: 5
|
||||
PenaltyExcessCharacter: 10
|
||||
PenaltyReturnTypeOnItsOwnLine: 600
|
||||
|
||||
@@ -105,3 +105,4 @@ cbea6b60942f8327e6105b12e8c1d5db4647984c # FEM: Apply pre-commit to FEM files
|
||||
f9d66096878c7d89c273522b9ca57bdb14fee3bc # Rearranged CommandCreateGeo.cpp
|
||||
b23d5809414d63ea90bcc744212c126645051438 # BIM: add to pre-commit and apply Black formatting
|
||||
50e4864efb06faf3e2126e8cb9ff9058a08a54b2 # Draft: add to pre-commit and apply Black formatting
|
||||
25c3ba733889264bcb3b3c8d2287b79053c0c8ec # All: Reformat according to new standard
|
||||
3
.github/problemMatcher/msvc.json
vendored
3
.github/problemMatcher/msvc.json
vendored
@@ -6,8 +6,7 @@
|
||||
"owner": "msvc-problem-matcher",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp":
|
||||
"^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
|
||||
@@ -6,9 +6,9 @@ files: |
|
||||
(?x)^(
|
||||
.github|
|
||||
src/Base|
|
||||
src/Gui|
|
||||
src/Main|
|
||||
src/Tools|
|
||||
tests/src|
|
||||
src/Mod/Assembly|
|
||||
src/Mod/BIM|
|
||||
src/Mod/CAM|
|
||||
@@ -20,8 +20,10 @@ files: |
|
||||
src/Mod/Inspection|
|
||||
src/Mod/JtReader|
|
||||
src/Mod/Measure|
|
||||
src/Mod/Mesh|
|
||||
src/Mod/MeshPart|
|
||||
src/Mod/Mesh|
|
||||
src/Mod/PartDesign|
|
||||
src/Mod/Part|
|
||||
src/Mod/Plot|
|
||||
src/Mod/Points|
|
||||
src/Mod/ReverseEngineering|
|
||||
@@ -33,7 +35,8 @@ files: |
|
||||
src/Mod/Surface|
|
||||
src/Mod/Test|
|
||||
src/Mod/Tux|
|
||||
src/Mod/Web
|
||||
src/Mod/Web|
|
||||
tests/src
|
||||
)
|
||||
exclude: |
|
||||
(?x)^(
|
||||
|
||||
@@ -72,8 +72,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyObject* d {};
|
||||
if (PyArg_ParseTuple(args, "O!O!", &(VectorPy::Type), &o, &(VectorPy::Type), &d)) {
|
||||
// NOTE: The first parameter defines the base (origin) and the second the direction.
|
||||
*getAxisPtr() =
|
||||
Axis(static_cast<VectorPy*>(o)->value(), static_cast<VectorPy*>(d)->value());
|
||||
*getAxisPtr() = Axis(static_cast<VectorPy*>(o)->value(), static_cast<VectorPy*>(d)->value());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,8 +113,7 @@ std::size_t Base::base64_encode(char* out, void const* in, std::size_t in_len)
|
||||
return ret - out;
|
||||
}
|
||||
|
||||
std::pair<std::size_t, std::size_t>
|
||||
Base::base64_decode(void* _out, char const* in, std::size_t in_len)
|
||||
std::pair<std::size_t, std::size_t> Base::base64_decode(void* _out, char const* in, std::size_t in_len)
|
||||
{
|
||||
auto* out = reinterpret_cast<unsigned char*>(_out); // NOLINT
|
||||
unsigned char* ret = out;
|
||||
|
||||
@@ -85,8 +85,7 @@ BaseExport std::array<const signed char, base64DecodeTableSize> base64_decode_ta
|
||||
* @return Return a pair of output size and input read size. Compare the
|
||||
* read size to input size to check for error.
|
||||
*/
|
||||
BaseExport std::pair<std::size_t, std::size_t>
|
||||
base64_decode(void* out, char const*, std::size_t len);
|
||||
BaseExport std::pair<std::size_t, std::size_t> base64_decode(void* out, char const*, std::size_t len);
|
||||
|
||||
/** Encode input binary into base64 string
|
||||
* @param out: output string. Note that the string is not cleared before
|
||||
|
||||
@@ -59,9 +59,7 @@ struct base64_encoder
|
||||
{
|
||||
|
||||
using char_type = char;
|
||||
struct category: bio::multichar_output_filter_tag,
|
||||
bio::closable_tag,
|
||||
bio::optimally_buffered_tag
|
||||
struct category: bio::multichar_output_filter_tag, bio::closable_tag, bio::optimally_buffered_tag
|
||||
{
|
||||
};
|
||||
|
||||
@@ -77,7 +75,8 @@ struct base64_encoder
|
||||
{
|
||||
static constexpr int defaultBufferSize {1024};
|
||||
return static_cast<std::streamsize>(
|
||||
base64_encode_size(line_size != 0U ? line_size : defaultBufferSize));
|
||||
base64_encode_size(line_size != 0U ? line_size : defaultBufferSize)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
@@ -174,7 +173,8 @@ struct base64_decoder
|
||||
{
|
||||
static constexpr int defaultBufferSize {1024};
|
||||
return static_cast<std::streamsize>(
|
||||
base64_encode_size(line_size != 0U ? line_size : defaultBufferSize));
|
||||
base64_encode_size(line_size != 0U ? line_size : defaultBufferSize)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
@@ -226,12 +226,15 @@ struct base64_decoder
|
||||
}
|
||||
if (pending_in == 4) {
|
||||
pending_out = pending_in = 0;
|
||||
char_array_3[0] =
|
||||
static_cast<char>((char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4));
|
||||
char_array_3[1] = static_cast<char>(((char_array_4[1] & 0xf) << 4)
|
||||
+ ((char_array_4[2] & 0x3c) >> 2));
|
||||
char_array_3[2] =
|
||||
static_cast<char>(((char_array_4[2] & 0x3) << 6) + char_array_4[3]);
|
||||
char_array_3[0] = static_cast<char>(
|
||||
(char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4)
|
||||
);
|
||||
char_array_3[1] = static_cast<char>(
|
||||
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2)
|
||||
);
|
||||
char_array_3[2] = static_cast<char>(
|
||||
((char_array_4[2] & 0x3) << 6) + char_array_4[3]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -256,8 +259,10 @@ struct base64_decoder
|
||||
* @return A unique pointer to an output stream that can transforms the
|
||||
* input binary data to base64 strings.
|
||||
*/
|
||||
inline std::unique_ptr<std::ostream>
|
||||
create_base64_encoder(std::ostream& out, std::size_t line_size = base64DefaultBufferSize)
|
||||
inline std::unique_ptr<std::ostream> create_base64_encoder(
|
||||
std::ostream& out,
|
||||
std::size_t line_size = base64DefaultBufferSize
|
||||
)
|
||||
{
|
||||
std::unique_ptr<std::ostream> res(new bio::filtering_ostream);
|
||||
auto* filteringStream = dynamic_cast<bio::filtering_ostream*>(res.get());
|
||||
@@ -274,8 +279,10 @@ create_base64_encoder(std::ostream& out, std::size_t line_size = base64DefaultBu
|
||||
* @return A unique pointer to an output stream that can transforms the
|
||||
* input binary data to base64 strings.
|
||||
*/
|
||||
inline std::unique_ptr<std::ostream>
|
||||
create_base64_encoder(const std::string& filepath, std::size_t line_size = base64DefaultBufferSize)
|
||||
inline std::unique_ptr<std::ostream> create_base64_encoder(
|
||||
const std::string& filepath,
|
||||
std::size_t line_size = base64DefaultBufferSize
|
||||
)
|
||||
{
|
||||
std::unique_ptr<std::ostream> res(new bio::filtering_ostream);
|
||||
auto* filteringStream = dynamic_cast<bio::filtering_ostream*>(res.get());
|
||||
@@ -294,10 +301,11 @@ create_base64_encoder(const std::string& filepath, std::size_t line_size = base6
|
||||
* @return A unique pointer to an input stream that read from the given
|
||||
* upstream and transform the read base64 strings into binary data.
|
||||
*/
|
||||
inline std::unique_ptr<std::istream>
|
||||
create_base64_decoder(std::istream& in,
|
||||
std::size_t line_size = base64DefaultBufferSize,
|
||||
Base64ErrorHandling errHandling = Base64ErrorHandling::silent)
|
||||
inline std::unique_ptr<std::istream> create_base64_decoder(
|
||||
std::istream& in,
|
||||
std::size_t line_size = base64DefaultBufferSize,
|
||||
Base64ErrorHandling errHandling = Base64ErrorHandling::silent
|
||||
)
|
||||
{
|
||||
std::unique_ptr<std::istream> res(new bio::filtering_istream);
|
||||
auto* filteringStream = dynamic_cast<bio::filtering_istream*>(res.get());
|
||||
@@ -320,10 +328,11 @@ create_base64_decoder(std::istream& in,
|
||||
* @return A unique pointer to an input stream that read from the given
|
||||
* file and transform the read base64 strings into binary data.
|
||||
*/
|
||||
inline std::unique_ptr<std::istream>
|
||||
create_base64_decoder(const std::string& filepath,
|
||||
std::size_t line_size = base64DefaultBufferSize,
|
||||
Base64ErrorHandling errHandling = Base64ErrorHandling::silent)
|
||||
inline std::unique_ptr<std::istream> create_base64_decoder(
|
||||
const std::string& filepath,
|
||||
std::size_t line_size = base64DefaultBufferSize,
|
||||
Base64ErrorHandling errHandling = Base64ErrorHandling::silent
|
||||
)
|
||||
{
|
||||
std::unique_ptr<std::istream> res(new bio::filtering_istream);
|
||||
auto* filteringStream = dynamic_cast<bio::filtering_istream*>(res.get());
|
||||
|
||||
@@ -74,10 +74,12 @@ Type BaseClass::getTypeId() const
|
||||
}
|
||||
|
||||
|
||||
void BaseClass::initSubclass(Base::Type& toInit,
|
||||
const char* ClassName,
|
||||
const char* ParentName,
|
||||
Type::instantiationMethod method)
|
||||
void BaseClass::initSubclass(
|
||||
Base::Type& toInit,
|
||||
const char* ClassName,
|
||||
const char* ParentName,
|
||||
Type::instantiationMethod method
|
||||
)
|
||||
{
|
||||
// don't init twice!
|
||||
assert(toInit.isBad());
|
||||
|
||||
@@ -34,103 +34,103 @@ using PyObject = struct _object;
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||
/// define for subclassing Base::BaseClass
|
||||
#define TYPESYSTEM_HEADER() \
|
||||
public: \
|
||||
static Base::Type getClassTypeId(void); \
|
||||
virtual Base::Type getTypeId(void) const; \
|
||||
static void init(void); \
|
||||
static void* create(void); \
|
||||
\
|
||||
private: \
|
||||
#define TYPESYSTEM_HEADER() \
|
||||
public: \
|
||||
static Base::Type getClassTypeId(void); \
|
||||
virtual Base::Type getTypeId(void) const; \
|
||||
static void init(void); \
|
||||
static void* create(void); \
|
||||
\
|
||||
private: \
|
||||
static Base::Type classTypeId
|
||||
|
||||
|
||||
/// Like TYPESYSTEM_HEADER, but declare getTypeId as 'override'
|
||||
#define TYPESYSTEM_HEADER_WITH_OVERRIDE() \
|
||||
public: \
|
||||
static Base::Type getClassTypeId(void); \
|
||||
Base::Type getTypeId(void) const override; \
|
||||
static void init(void); \
|
||||
static void* create(void); \
|
||||
\
|
||||
private: \
|
||||
#define TYPESYSTEM_HEADER_WITH_OVERRIDE() \
|
||||
public: \
|
||||
static Base::Type getClassTypeId(void); \
|
||||
Base::Type getTypeId(void) const override; \
|
||||
static void init(void); \
|
||||
static void* create(void); \
|
||||
\
|
||||
private: \
|
||||
static Base::Type classTypeId
|
||||
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE_P(_class_) \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::classTypeId = Base::Type::BadType; \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return new _class_(); \
|
||||
#define TYPESYSTEM_SOURCE_P(_class_) \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::classTypeId = Base::Type::BadType; \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return new _class_(); \
|
||||
}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
|
||||
template<> \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
template<> \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
template<> \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return new _class_(); \
|
||||
#define TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
|
||||
template<> \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
template<> \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
template<> \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return new _class_(); \
|
||||
}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::classTypeId = Base::Type::BadType; \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return nullptr; \
|
||||
#define TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
|
||||
Base::Type _class_::getClassTypeId(void) \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::getTypeId(void) const \
|
||||
{ \
|
||||
return _class_::classTypeId; \
|
||||
} \
|
||||
Base::Type _class_::classTypeId = Base::Type::BadType; \
|
||||
void* _class_::create(void) \
|
||||
{ \
|
||||
return nullptr; \
|
||||
}
|
||||
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_P(_class_) \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
|
||||
#define TYPESYSTEM_SOURCE(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_P(_class_) \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
|
||||
}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE_TEMPLATE_T(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
|
||||
template<> \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
|
||||
#define TYPESYSTEM_SOURCE_TEMPLATE_T(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_TEMPLATE_P(_class_) \
|
||||
template<> \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
|
||||
}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define TYPESYSTEM_SOURCE_ABSTRACT(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, nullptr); \
|
||||
#define TYPESYSTEM_SOURCE_ABSTRACT(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
|
||||
void _class_::init(void) \
|
||||
{ \
|
||||
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, nullptr); \
|
||||
}
|
||||
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||
|
||||
@@ -167,10 +167,12 @@ private:
|
||||
static Type classTypeId; // NOLINT
|
||||
|
||||
protected:
|
||||
static void initSubclass(Base::Type& toInit,
|
||||
const char* ClassName,
|
||||
const char* ParentName,
|
||||
Type::instantiationMethod method = nullptr);
|
||||
static void initSubclass(
|
||||
Base::Type& toInit,
|
||||
const char* ClassName,
|
||||
const char* ParentName,
|
||||
Type::instantiationMethod method = nullptr
|
||||
);
|
||||
|
||||
public:
|
||||
/// Construction
|
||||
|
||||
@@ -61,12 +61,14 @@ public:
|
||||
//@}
|
||||
|
||||
/** Builds box from pairs of x,y,z values. */
|
||||
inline explicit BoundBox3(Precision fMinX = std::numeric_limits<Precision>::max(),
|
||||
Precision fMinY = std::numeric_limits<Precision>::max(),
|
||||
Precision fMinZ = std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxX = -std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxY = -std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxZ = -std::numeric_limits<Precision>::max());
|
||||
inline explicit BoundBox3(
|
||||
Precision fMinX = std::numeric_limits<Precision>::max(),
|
||||
Precision fMinY = std::numeric_limits<Precision>::max(),
|
||||
Precision fMinZ = std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxX = -std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxY = -std::numeric_limits<Precision>::max(),
|
||||
Precision fMaxZ = -std::numeric_limits<Precision>::max()
|
||||
);
|
||||
BoundBox3(const BoundBox3<Precision>& rcBB) = default;
|
||||
BoundBox3(BoundBox3<Precision>&& rcBB) noexcept = default;
|
||||
/** Builds box from an array of points. */
|
||||
@@ -178,8 +180,7 @@ public:
|
||||
*/
|
||||
inline Vector3<Precision> CalcPoint(unsigned short usPoint) const;
|
||||
/** Returns the plane of the given side. */
|
||||
void
|
||||
CalcPlane(unsigned short usPlane, Vector3<Precision>& rBase, Vector3<Precision>& rNormal) const;
|
||||
void CalcPlane(unsigned short usPlane, Vector3<Precision>& rBase, Vector3<Precision>& rNormal) const;
|
||||
/** Calculates the two points of an edge.
|
||||
*/
|
||||
bool CalcEdge(unsigned short usEdge, Vector3<Precision>& rcP0, Vector3<Precision>& rcP1) const;
|
||||
@@ -187,36 +188,47 @@ public:
|
||||
* the base \a rcVct and the direction \a rcVctDir. \a rcVct must lie inside the
|
||||
* bounding box.
|
||||
*/
|
||||
bool IntersectionPoint(const Vector3<Precision>& rcVct,
|
||||
const Vector3<Precision>& rcVctDir,
|
||||
Vector3<Precision>& cVctRes,
|
||||
Precision epsilon) const;
|
||||
bool IntersectionPoint(
|
||||
const Vector3<Precision>& rcVct,
|
||||
const Vector3<Precision>& rcVctDir,
|
||||
Vector3<Precision>& cVctRes,
|
||||
Precision epsilon
|
||||
) const;
|
||||
/** Checks for intersection with line incl. search tolerance. */
|
||||
bool IsCutLine(const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Precision fTolerance = 0.0F) const;
|
||||
bool IsCutLine(
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Precision fTolerance = 0.0F
|
||||
) const;
|
||||
/** Checks if this plane specified by (point,normal) cuts this box.
|
||||
* @note It's up to the client programmer to make sure that this bounding box is valid.
|
||||
*/
|
||||
inline bool IsCutPlane(const Vector3<Precision>& rclBase,
|
||||
const Vector3<Precision>& rclNormal) const;
|
||||
inline bool IsCutPlane(const Vector3<Precision>& rclBase, const Vector3<Precision>& rclNormal) const;
|
||||
/** Computes the intersection points of line and bounding box. */
|
||||
bool IntersectWithLine(const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1) const;
|
||||
bool IntersectWithLine(
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1
|
||||
) const;
|
||||
/** Computes the intersection point of line and a plane of the bounding box. */
|
||||
bool IntersectPlaneWithLine(unsigned short usSide,
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0) const;
|
||||
bool IntersectPlaneWithLine(
|
||||
unsigned short usSide,
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0
|
||||
) const;
|
||||
/** Returns the side of the bounding box the ray exits. */
|
||||
typename BoundBox3<Precision>::SIDE GetSideFromRay(const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir) const;
|
||||
typename BoundBox3<Precision>::SIDE GetSideFromRay(
|
||||
const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir
|
||||
) const;
|
||||
/** Returns the side of the bounding box the ray exits. */
|
||||
typename BoundBox3<Precision>::SIDE GetSideFromRay(const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir,
|
||||
Vector3<Precision>& rcInt) const;
|
||||
typename BoundBox3<Precision>::SIDE GetSideFromRay(
|
||||
const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir,
|
||||
Vector3<Precision>& rcInt
|
||||
) const;
|
||||
|
||||
/**
|
||||
* Searches for the closest point of the bounding box.
|
||||
@@ -288,12 +300,14 @@ bool BoundBox3<Precision>::isOnRayS(Precision min, Precision max, Precision val)
|
||||
|
||||
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
|
||||
template<class Precision>
|
||||
inline BoundBox3<Precision>::BoundBox3(Precision fMinX,
|
||||
Precision fMinY,
|
||||
Precision fMinZ,
|
||||
Precision fMaxX,
|
||||
Precision fMaxY,
|
||||
Precision fMaxZ)
|
||||
inline BoundBox3<Precision>::BoundBox3(
|
||||
Precision fMinX,
|
||||
Precision fMinY,
|
||||
Precision fMinZ,
|
||||
Precision fMaxX,
|
||||
Precision fMaxY,
|
||||
Precision fMaxZ
|
||||
)
|
||||
: MinX(fMinX)
|
||||
, MinY(fMinY)
|
||||
, MinZ(fMinZ)
|
||||
@@ -377,8 +391,7 @@ inline bool BoundBox3<Precision>::operator&&(const BoundBox2d& rcBB) const
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline BoundBox3<Precision>
|
||||
BoundBox3<Precision>::Intersected(const BoundBox3<Precision>& rcBB) const
|
||||
inline BoundBox3<Precision> BoundBox3<Precision>::Intersected(const BoundBox3<Precision>& rcBB) const
|
||||
{
|
||||
BoundBox3<Precision> cBBRes;
|
||||
|
||||
@@ -478,8 +491,10 @@ inline bool BoundBox3<Precision>::IsValid() const
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::GetOctantFromVector(const Vector3<Precision>& rclVct,
|
||||
OCTANT& rclOctant) const
|
||||
inline bool BoundBox3<Precision>::GetOctantFromVector(
|
||||
const Vector3<Precision>& rclVct,
|
||||
OCTANT& rclOctant
|
||||
) const
|
||||
{
|
||||
if (!IsInBox(rclVct)) {
|
||||
return false;
|
||||
@@ -500,8 +515,9 @@ inline bool BoundBox3<Precision>::GetOctantFromVector(const Vector3<Precision>&
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline BoundBox3<Precision>
|
||||
BoundBox3<Precision>::CalcOctant(typename BoundBox3<Precision>::OCTANT Octant) const
|
||||
inline BoundBox3<Precision> BoundBox3<Precision>::CalcOctant(
|
||||
typename BoundBox3<Precision>::OCTANT Octant
|
||||
) const
|
||||
{
|
||||
BoundBox3<Precision> cOct(*this);
|
||||
|
||||
@@ -584,9 +600,11 @@ inline Vector3<Precision> BoundBox3<Precision>::CalcPoint(unsigned short usPoint
|
||||
|
||||
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
|
||||
template<class Precision>
|
||||
inline void BoundBox3<Precision>::CalcPlane(unsigned short usPlane,
|
||||
Vector3<Precision>& rBase,
|
||||
Vector3<Precision>& rNormal) const
|
||||
inline void BoundBox3<Precision>::CalcPlane(
|
||||
unsigned short usPlane,
|
||||
Vector3<Precision>& rBase,
|
||||
Vector3<Precision>& rNormal
|
||||
) const
|
||||
// NOLINTEND(bugprone-easily-swappable-parameters)
|
||||
{
|
||||
switch (usPlane) {
|
||||
@@ -625,9 +643,11 @@ inline void BoundBox3<Precision>::CalcPlane(unsigned short usPlane,
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::CalcEdge(unsigned short usEdge,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1) const
|
||||
inline bool BoundBox3<Precision>::CalcEdge(
|
||||
unsigned short usEdge,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1
|
||||
) const
|
||||
{
|
||||
switch (usEdge) {
|
||||
case TLB_TLF:
|
||||
@@ -686,10 +706,12 @@ inline bool BoundBox3<Precision>::CalcEdge(unsigned short usEdge,
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::IntersectionPoint(const Vector3<Precision>& rcVct,
|
||||
const Vector3<Precision>& rcVctDir,
|
||||
Vector3<Precision>& cVctRes,
|
||||
Precision epsilon) const
|
||||
inline bool BoundBox3<Precision>::IntersectionPoint(
|
||||
const Vector3<Precision>& rcVct,
|
||||
const Vector3<Precision>& rcVctDir,
|
||||
Vector3<Precision>& cVctRes,
|
||||
Precision epsilon
|
||||
) const
|
||||
{
|
||||
const unsigned short num = 6;
|
||||
bool rc = false;
|
||||
@@ -721,9 +743,11 @@ inline bool BoundBox3<Precision>::IntersectionPoint(const Vector3<Precision>& rc
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::IsCutLine(const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Precision fTolerance) const
|
||||
inline bool BoundBox3<Precision>::IsCutLine(
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Precision fTolerance
|
||||
) const
|
||||
{
|
||||
const unsigned short num = 6;
|
||||
Precision fDist;
|
||||
@@ -777,8 +801,10 @@ inline bool BoundBox3<Precision>::IsCutLine(const Vector3<Precision>& rcBase,
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::IsCutPlane(const Vector3<Precision>& rclBase,
|
||||
const Vector3<Precision>& rclNormal) const
|
||||
inline bool BoundBox3<Precision>::IsCutPlane(
|
||||
const Vector3<Precision>& rclBase,
|
||||
const Vector3<Precision>& rclNormal
|
||||
) const
|
||||
{
|
||||
const unsigned short num = 8;
|
||||
if (fabs(GetCenter().DistanceToPlane(rclBase, rclNormal)) < CalcDiagonalLength()) {
|
||||
@@ -794,10 +820,12 @@ inline bool BoundBox3<Precision>::IsCutPlane(const Vector3<Precision>& rclBase,
|
||||
|
||||
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::IntersectWithLine(const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1) const
|
||||
inline bool BoundBox3<Precision>::IntersectWithLine(
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0,
|
||||
Vector3<Precision>& rcP1
|
||||
) const
|
||||
// NOLINTEND(bugprone-easily-swappable-parameters)
|
||||
{
|
||||
const unsigned short num = 6;
|
||||
@@ -819,18 +847,24 @@ inline bool BoundBox3<Precision>::IntersectWithLine(const Vector3<Precision>& rc
|
||||
switch (i) {
|
||||
case LEFT: // left and right plane
|
||||
case RIGHT:
|
||||
checkIntersect(Vector3<Precision> {MinY, MaxY, clVectRes.y},
|
||||
Vector3<Precision> {MinZ, MaxZ, clVectRes.z});
|
||||
checkIntersect(
|
||||
Vector3<Precision> {MinY, MaxY, clVectRes.y},
|
||||
Vector3<Precision> {MinZ, MaxZ, clVectRes.z}
|
||||
);
|
||||
break;
|
||||
case TOP: // top and bottom plane
|
||||
case BOTTOM:
|
||||
checkIntersect(Vector3<Precision> {MinX, MaxX, clVectRes.x},
|
||||
Vector3<Precision> {MinZ, MaxZ, clVectRes.z});
|
||||
checkIntersect(
|
||||
Vector3<Precision> {MinX, MaxX, clVectRes.x},
|
||||
Vector3<Precision> {MinZ, MaxZ, clVectRes.z}
|
||||
);
|
||||
break;
|
||||
case FRONT: // front and back plane
|
||||
case BACK:
|
||||
checkIntersect(Vector3<Precision> {MinX, MaxX, clVectRes.x},
|
||||
Vector3<Precision> {MinY, MaxY, clVectRes.y});
|
||||
checkIntersect(
|
||||
Vector3<Precision> {MinX, MaxX, clVectRes.x},
|
||||
Vector3<Precision> {MinY, MaxY, clVectRes.y}
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -857,10 +891,12 @@ inline bool BoundBox3<Precision>::IntersectWithLine(const Vector3<Precision>& rc
|
||||
|
||||
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
|
||||
template<class Precision>
|
||||
inline bool BoundBox3<Precision>::IntersectPlaneWithLine(unsigned short usSide,
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0) const
|
||||
inline bool BoundBox3<Precision>::IntersectPlaneWithLine(
|
||||
unsigned short usSide,
|
||||
const Vector3<Precision>& rcBase,
|
||||
const Vector3<Precision>& rcDir,
|
||||
Vector3<Precision>& rcP0
|
||||
) const
|
||||
// NOLINTEND(bugprone-easily-swappable-parameters)
|
||||
{
|
||||
Precision value;
|
||||
@@ -880,19 +916,21 @@ inline bool BoundBox3<Precision>::IntersectPlaneWithLine(unsigned short usSide,
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline typename BoundBox3<Precision>::SIDE
|
||||
BoundBox3<Precision>::GetSideFromRay(const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir) const
|
||||
inline typename BoundBox3<Precision>::SIDE BoundBox3<Precision>::GetSideFromRay(
|
||||
const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir
|
||||
) const
|
||||
{
|
||||
Vector3<Precision> cIntersection;
|
||||
return GetSideFromRay(rclPt, rclDir, cIntersection);
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
inline typename BoundBox3<Precision>::SIDE
|
||||
BoundBox3<Precision>::GetSideFromRay(const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir,
|
||||
Vector3<Precision>& rcInt) const
|
||||
inline typename BoundBox3<Precision>::SIDE BoundBox3<Precision>::GetSideFromRay(
|
||||
const Vector3<Precision>& rclPt,
|
||||
const Vector3<Precision>& rclDir,
|
||||
Vector3<Precision>& rcInt
|
||||
) const
|
||||
{
|
||||
Vector3<Precision> cP0;
|
||||
Vector3<Precision> cP1;
|
||||
@@ -1027,9 +1065,10 @@ inline Vector3<Precision> BoundBox3<Precision>::GetMaximum() const
|
||||
template<class Precision>
|
||||
inline Precision BoundBox3<Precision>::CalcDiagonalLength() const
|
||||
{
|
||||
return static_cast<Precision>(sqrt(((MaxX - MinX) * (MaxX - MinX))
|
||||
+ ((MaxY - MinY) * (MaxY - MinY))
|
||||
+ ((MaxZ - MinZ) * (MaxZ - MinZ))));
|
||||
return static_cast<Precision>(sqrt(
|
||||
((MaxX - MinX) * (MaxX - MinX)) + ((MaxY - MinY) * (MaxY - MinY))
|
||||
+ ((MaxZ - MinZ) * (MaxZ - MinZ))
|
||||
));
|
||||
}
|
||||
|
||||
template<class Precision>
|
||||
|
||||
@@ -103,9 +103,11 @@ int BoundBoxPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Either six floats, two instances of "
|
||||
"Vector/Tuple or instance of BoundBox expected");
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"Either six floats, two instances of "
|
||||
"Vector/Tuple or instance of BoundBox expected"
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -152,16 +154,20 @@ PyObject* BoundBoxPy::add(PyObject* args)
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args,
|
||||
"O!;Need a Vector, BoundBox or three floats as argument",
|
||||
&(BoundBoxPy::Type),
|
||||
&object)) {
|
||||
if (PyArg_ParseTuple(
|
||||
args,
|
||||
"O!;Need a Vector, BoundBox or three floats as argument",
|
||||
&(BoundBoxPy::Type),
|
||||
&object
|
||||
)) {
|
||||
getBoundBoxPtr()->Add(*(static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()));
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Either three floats, instance of Vector or instance of BoundBox expected");
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"Either three floats, instance of Vector or instance of BoundBox expected"
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -248,15 +254,11 @@ PyObject* BoundBoxPy::intersect(PyObject* args)
|
||||
}
|
||||
|
||||
do {
|
||||
if (PyArg_ParseTuple(args,
|
||||
"O!O!",
|
||||
&(VectorPy::Type),
|
||||
&object1,
|
||||
&(VectorPy::Type),
|
||||
&object2)) {
|
||||
retVal =
|
||||
getBoundBoxPtr()->IsCutLine(*(static_cast<VectorPy*>(object1)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr()));
|
||||
if (PyArg_ParseTuple(args, "O!O!", &(VectorPy::Type), &object1, &(VectorPy::Type), &object2)) {
|
||||
retVal = getBoundBoxPtr()->IsCutLine(
|
||||
*(static_cast<VectorPy*>(object1)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr())
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -266,8 +268,9 @@ PyObject* BoundBoxPy::intersect(PyObject* args)
|
||||
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
|
||||
return nullptr;
|
||||
}
|
||||
retVal =
|
||||
getBoundBoxPtr()->Intersect(*(static_cast<BoundBoxPy*>(object1)->getBoundBoxPtr()));
|
||||
retVal = getBoundBoxPtr()->Intersect(
|
||||
*(static_cast<BoundBoxPy*>(object1)->getBoundBoxPtr())
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -294,8 +297,9 @@ PyObject* BoundBoxPy::intersected(PyObject* args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BoundBox3d bbox =
|
||||
getBoundBoxPtr()->Intersected(*static_cast<BoundBoxPy*>(object)->getBoundBoxPtr());
|
||||
BoundBox3d bbox = getBoundBoxPtr()->Intersected(
|
||||
*static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()
|
||||
);
|
||||
return new BoundBoxPy(new BoundBox3d(bbox));
|
||||
}
|
||||
|
||||
@@ -334,22 +338,25 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
|
||||
PyObject* object1 {};
|
||||
PyObject* object2 {};
|
||||
double epsilon = 0.0001;
|
||||
if (!PyArg_ParseTuple(args,
|
||||
"O!O!|d;Need base and direction vector",
|
||||
&(VectorPy::Type),
|
||||
&object1,
|
||||
&(VectorPy::Type),
|
||||
&object2,
|
||||
&epsilon)) {
|
||||
if (!PyArg_ParseTuple(
|
||||
args,
|
||||
"O!O!|d;Need base and direction vector",
|
||||
&(VectorPy::Type),
|
||||
&object1,
|
||||
&(VectorPy::Type),
|
||||
&object2,
|
||||
&epsilon
|
||||
)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector3d point;
|
||||
bool ok =
|
||||
getBoundBoxPtr()->IntersectionPoint(*(static_cast<VectorPy*>(object1)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr()),
|
||||
point,
|
||||
epsilon);
|
||||
bool ok = getBoundBoxPtr()->IntersectionPoint(
|
||||
*(static_cast<VectorPy*>(object1)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr()),
|
||||
point,
|
||||
epsilon
|
||||
);
|
||||
if (ok) {
|
||||
return new VectorPy(point);
|
||||
}
|
||||
@@ -460,17 +467,21 @@ PyObject* BoundBoxPy::isCutPlane(PyObject* args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTuple(args,
|
||||
"O!O!;Need base and normal vector of a plane",
|
||||
&(VectorPy::Type),
|
||||
&object,
|
||||
&(VectorPy::Type),
|
||||
&object2)) {
|
||||
if (!PyArg_ParseTuple(
|
||||
args,
|
||||
"O!O!;Need base and normal vector of a plane",
|
||||
&(VectorPy::Type),
|
||||
&object,
|
||||
&(VectorPy::Type),
|
||||
&object2
|
||||
)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
retVal = getBoundBoxPtr()->IsCutPlane(*(static_cast<VectorPy*>(object)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr()));
|
||||
retVal = getBoundBoxPtr()->IsCutPlane(
|
||||
*(static_cast<VectorPy*>(object)->getVectorPtr()),
|
||||
*(static_cast<VectorPy*>(object2)->getVectorPtr())
|
||||
);
|
||||
|
||||
return Py::new_reference_to(retVal);
|
||||
}
|
||||
@@ -512,8 +523,7 @@ PyObject* BoundBoxPy::isInside(PyObject* args)
|
||||
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
|
||||
return nullptr;
|
||||
}
|
||||
retVal =
|
||||
getBoundBoxPtr()->IsInBox(*(static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()));
|
||||
retVal = getBoundBoxPtr()->IsInBox(*(static_cast<BoundBoxPy*>(object)->getBoundBoxPtr()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,9 +248,11 @@ public:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void InventorFieldWriter::write(const char* fieldName,
|
||||
const std::vector<T>& fieldData,
|
||||
InventorOutput& out) const
|
||||
void InventorFieldWriter::write(
|
||||
const char* fieldName,
|
||||
const std::vector<T>& fieldData,
|
||||
InventorOutput& out
|
||||
) const
|
||||
{
|
||||
if (fieldData.empty()) {
|
||||
return;
|
||||
@@ -273,9 +275,11 @@ void InventorFieldWriter::write(const char* fieldName,
|
||||
}
|
||||
|
||||
template<>
|
||||
void InventorFieldWriter::write<int>(const char* fieldName,
|
||||
const std::vector<int>& fieldData,
|
||||
InventorOutput& out) const
|
||||
void InventorFieldWriter::write<int>(
|
||||
const char* fieldName,
|
||||
const std::vector<int>& fieldData,
|
||||
InventorOutput& out
|
||||
) const
|
||||
{
|
||||
if (fieldData.empty()) {
|
||||
return;
|
||||
@@ -472,10 +476,12 @@ void ArrowItem::write(InventorOutput& out) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
BoundingBoxItem::BoundingBoxItem(const Vector3f& pt1,
|
||||
const Vector3f& pt2,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb)
|
||||
BoundingBoxItem::BoundingBoxItem(
|
||||
const Vector3f& pt1,
|
||||
const Vector3f& pt2,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb
|
||||
)
|
||||
: pt1 {pt1}
|
||||
, pt2 {pt2}
|
||||
, drawStyle {drawStyle}
|
||||
@@ -871,8 +877,7 @@ void NurbsSurfaceItem::setControlPoints(int numU, int numV)
|
||||
numVControlPoints = numV;
|
||||
}
|
||||
|
||||
void NurbsSurfaceItem::setKnotVector(const std::vector<float>& uKnots,
|
||||
const std::vector<float>& vKnots)
|
||||
void NurbsSurfaceItem::setKnotVector(const std::vector<float>& uKnots, const std::vector<float>& vKnots)
|
||||
{
|
||||
uKnotVector = uKnots;
|
||||
vKnotVector = vKnots;
|
||||
@@ -1010,11 +1015,13 @@ void Builder3D::saveToLog()
|
||||
{
|
||||
ILogger* obs = Base::Console().get("StatusBar");
|
||||
if (obs) {
|
||||
obs->sendLog("Builder3D",
|
||||
result.str(),
|
||||
Base::LogStyle::Log,
|
||||
Base::IntendedRecipient::Developer,
|
||||
Base::ContentType::Untranslatable);
|
||||
obs->sendLog(
|
||||
"Builder3D",
|
||||
result.str(),
|
||||
Base::LogStyle::Log,
|
||||
Base::IntendedRecipient::Developer,
|
||||
Base::ContentType::Untranslatable
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1152,8 +1159,9 @@ std::vector<std::vector<int32_t>> InventorLoader::split(const std::vector<int32_
|
||||
return splitdata;
|
||||
}
|
||||
|
||||
std::vector<InventorLoader::Face>
|
||||
InventorLoader::convert(const std::vector<std::vector<int32_t>>& coordIndex) const
|
||||
std::vector<InventorLoader::Face> InventorLoader::convert(
|
||||
const std::vector<std::vector<int32_t>>& coordIndex
|
||||
) const
|
||||
{
|
||||
std::vector<Face> faces;
|
||||
faces.reserve(coordIndex.size());
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <cstdint>
|
||||
#include <Base/Tools3D.h>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
#include "Placement.h"
|
||||
@@ -167,9 +167,7 @@ public:
|
||||
class BaseExport Triangle
|
||||
{
|
||||
public:
|
||||
explicit Triangle(const Base::Vector3f& pt1,
|
||||
const Base::Vector3f& pt2,
|
||||
const Base::Vector3f& pt3)
|
||||
explicit Triangle(const Base::Vector3f& pt1, const Base::Vector3f& pt2, const Base::Vector3f& pt3)
|
||||
: pt1(pt1)
|
||||
, pt2(pt2)
|
||||
, pt3(pt3)
|
||||
@@ -297,9 +295,11 @@ private:
|
||||
class BaseExport PointItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit PointItem(const Base::Vector3f& point,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
explicit PointItem(
|
||||
const Base::Vector3f& point,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}
|
||||
);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -311,9 +311,11 @@ private:
|
||||
class BaseExport LineItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit LineItem(const Base::Line3f& line,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
explicit LineItem(
|
||||
const Base::Line3f& line,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}
|
||||
);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -327,9 +329,11 @@ class BaseExport MultiLineItem: public NodeItem
|
||||
public:
|
||||
/// add a line defined by a list of points whereat always a pair (i.e. a point and the following
|
||||
/// point) builds a line.
|
||||
explicit MultiLineItem(std::vector<Vector3f> points,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
explicit MultiLineItem(
|
||||
std::vector<Vector3f> points,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}
|
||||
);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -341,9 +345,11 @@ private:
|
||||
class BaseExport ArrowItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit ArrowItem(const Base::Line3f& line,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
explicit ArrowItem(
|
||||
const Base::Line3f& line,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}
|
||||
);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
@@ -355,10 +361,12 @@ private:
|
||||
class BaseExport BoundingBoxItem: public NodeItem
|
||||
{
|
||||
public:
|
||||
explicit BoundingBoxItem(const Vector3f& pt1,
|
||||
const Vector3f& pt2,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
|
||||
explicit BoundingBoxItem(
|
||||
const Vector3f& pt1,
|
||||
const Vector3f& pt2,
|
||||
DrawStyle drawStyle,
|
||||
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}
|
||||
);
|
||||
void write(InventorOutput& out) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define APP_COLOR_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <cstdint>
|
||||
# include <cstdint>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
@@ -165,10 +165,12 @@ public:
|
||||
template<typename T>
|
||||
static T fromPackedRGBA(uint32_t color)
|
||||
{
|
||||
return color_traits<T>::makeColor((color >> 24) & 0xff,
|
||||
(color >> 16) & 0xff,
|
||||
(color >> 8) & 0xff,
|
||||
(color & 0xff));
|
||||
return color_traits<T>::makeColor(
|
||||
(color >> 24) & 0xff,
|
||||
(color >> 16) & 0xff,
|
||||
(color >> 8) & 0xff,
|
||||
(color & 0xff)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -181,9 +183,7 @@ public:
|
||||
template<typename T>
|
||||
static T fromPackedRGB(uint32_t color)
|
||||
{
|
||||
return color_traits<T>::makeColor((color >> 24) & 0xff,
|
||||
(color >> 16) & 0xff,
|
||||
(color >> 8) & 0xff);
|
||||
return color_traits<T>::makeColor((color >> 24) & 0xff, (color >> 16) & 0xff, (color >> 8) & 0xff);
|
||||
}
|
||||
/**
|
||||
* creates FC Color from template type, e.g. Qt QColor
|
||||
@@ -308,10 +308,12 @@ struct color_traits<Base::Color>
|
||||
}
|
||||
static color_type makeColor(int red, int green, int blue, int alpha = 255)
|
||||
{
|
||||
return color_type {static_cast<float>(red) / 255.0F,
|
||||
static_cast<float>(green) / 255.0F,
|
||||
static_cast<float>(blue) / 255.0F,
|
||||
static_cast<float>(alpha) / 255.0F};
|
||||
return color_type {
|
||||
static_cast<float>(red) / 255.0F,
|
||||
static_cast<float>(green) / 255.0F,
|
||||
static_cast<float>(blue) / 255.0F,
|
||||
static_cast<float>(alpha) / 255.0F
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#if defined(FC_OS_WIN32)
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX)
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
@@ -55,11 +55,13 @@ public:
|
||||
std::string notifier;
|
||||
std::string msg;
|
||||
|
||||
ConsoleEvent(const ConsoleSingleton::FreeCAD_ConsoleMsgType type,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifier,
|
||||
const std::string& msg)
|
||||
ConsoleEvent(
|
||||
const ConsoleSingleton::FreeCAD_ConsoleMsgType type,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifier,
|
||||
const std::string& msg
|
||||
)
|
||||
: QEvent(QEvent::User) // NOLINT
|
||||
, msgtype(type)
|
||||
, recipient(recipient)
|
||||
@@ -90,46 +92,58 @@ public:
|
||||
if (ev->type() == QEvent::User) {
|
||||
switch (const auto ce = static_cast<ConsoleEvent*>(ev); ce->msgtype) {
|
||||
case ConsoleSingleton::MsgType_Txt:
|
||||
Console().notifyPrivate(LogStyle::Message,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Message,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
case ConsoleSingleton::MsgType_Log:
|
||||
Console().notifyPrivate(LogStyle::Log,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Log,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
case ConsoleSingleton::MsgType_Wrn:
|
||||
Console().notifyPrivate(LogStyle::Warning,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Warning,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
case ConsoleSingleton::MsgType_Err:
|
||||
Console().notifyPrivate(LogStyle::Error,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Error,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
case ConsoleSingleton::MsgType_Critical:
|
||||
Console().notifyPrivate(LogStyle::Critical,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Critical,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
case ConsoleSingleton::MsgType_Notification:
|
||||
Console().notifyPrivate(LogStyle::Notification,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg);
|
||||
Console().notifyPrivate(
|
||||
LogStyle::Notification,
|
||||
ce->recipient,
|
||||
ce->content,
|
||||
ce->notifier,
|
||||
ce->msg
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -185,9 +199,11 @@ ConsoleSingleton::~ConsoleSingleton()
|
||||
* switches off warnings and error messages and restore the state before the modification.
|
||||
* If the observer \a sObs doesn't exist then nothing happens.
|
||||
*/
|
||||
ConsoleMsgFlags ConsoleSingleton::setEnabledMsgType(const char* sObs,
|
||||
const ConsoleMsgFlags type,
|
||||
const bool on) const
|
||||
ConsoleMsgFlags ConsoleSingleton::setEnabledMsgType(
|
||||
const char* sObs,
|
||||
const ConsoleMsgFlags type,
|
||||
const bool on
|
||||
) const
|
||||
{
|
||||
if (ILogger* pObs = get(sObs)) {
|
||||
ConsoleMsgFlags flags = 0;
|
||||
@@ -296,31 +312,39 @@ void ConsoleSingleton::detachObserver(ILogger* pcObserver)
|
||||
_aclObservers.erase(pcObserver);
|
||||
}
|
||||
|
||||
void ConsoleSingleton::notifyPrivate(const LogStyle category,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg) const
|
||||
void ConsoleSingleton::notifyPrivate(
|
||||
const LogStyle category,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg
|
||||
) const
|
||||
{
|
||||
for (ILogger* Iter : _aclObservers) {
|
||||
if (Iter->isActive(category)) {
|
||||
Iter->sendLog(notifiername,
|
||||
msg,
|
||||
category,
|
||||
recipient,
|
||||
content); // send string to the listener
|
||||
Iter->sendLog(
|
||||
notifiername,
|
||||
msg,
|
||||
category,
|
||||
recipient,
|
||||
content
|
||||
); // send string to the listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleSingleton::postEvent(const FreeCAD_ConsoleMsgType type,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg)
|
||||
void ConsoleSingleton::postEvent(
|
||||
const FreeCAD_ConsoleMsgType type,
|
||||
const IntendedRecipient recipient,
|
||||
const ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg
|
||||
)
|
||||
{
|
||||
QCoreApplication::postEvent(ConsoleOutput::getInstance(),
|
||||
new ConsoleEvent(type, recipient, content, notifiername, msg));
|
||||
QCoreApplication::postEvent(
|
||||
ConsoleOutput::getInstance(),
|
||||
new ConsoleEvent(type, recipient, content, notifiername, msg)
|
||||
);
|
||||
}
|
||||
|
||||
ILogger* ConsoleSingleton::get(const char* Name) const
|
||||
@@ -552,35 +576,36 @@ PyObject* ConsoleSingleton::sPyMessage(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Message, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Message, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyWarning(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance().warning(notifier, "%s", msg);
|
||||
},
|
||||
args);
|
||||
[](const std::string& notifier, const char* msg) { instance().warning(notifier, "%s", msg); },
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyDeveloperWarning(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Warning, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Warning, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyUserWarning(PyObject* /*self*/, PyObject* args)
|
||||
@@ -590,9 +615,11 @@ PyObject* ConsoleSingleton::sPyUserWarning(PyObject* /*self*/, PyObject* args)
|
||||
instance().send<LogStyle::Warning, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyTranslatedUserWarning(PyObject* /*self*/, PyObject* args)
|
||||
@@ -602,9 +629,11 @@ PyObject* ConsoleSingleton::sPyTranslatedUserWarning(PyObject* /*self*/, PyObjec
|
||||
instance().send<LogStyle::Warning, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyError(PyObject* /*self*/, PyObject* args)
|
||||
@@ -614,22 +643,25 @@ PyObject* ConsoleSingleton::sPyError(PyObject* /*self*/, PyObject* args)
|
||||
instance().send<LogStyle::Error, IntendedRecipient::All, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyDeveloperError(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Error, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Error, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyUserError(PyObject* /*self*/, PyObject* args)
|
||||
@@ -639,9 +671,11 @@ PyObject* ConsoleSingleton::sPyUserError(PyObject* /*self*/, PyObject* args)
|
||||
instance().send<LogStyle::Error, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyTranslatedUserError(PyObject* /*self*/, PyObject* args)
|
||||
@@ -651,22 +685,25 @@ PyObject* ConsoleSingleton::sPyTranslatedUserError(PyObject* /*self*/, PyObject*
|
||||
instance().send<LogStyle::Error, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyLog(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Log, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Log, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyCritical(PyObject* /*self*/, PyObject* args)
|
||||
@@ -676,35 +713,39 @@ PyObject* ConsoleSingleton::sPyCritical(PyObject* /*self*/, PyObject* args)
|
||||
instance().send<LogStyle::Critical, IntendedRecipient::All, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyNotification(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Notification, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Notification, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyTranslatedNotification(PyObject* /*self*/, PyObject* args)
|
||||
{
|
||||
return FC_PYCONSOLE_MSG(
|
||||
[](const std::string& notifier, const char* msg) {
|
||||
instance()
|
||||
.send<LogStyle::Notification, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg);
|
||||
instance().send<LogStyle::Notification, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
"%s",
|
||||
msg
|
||||
);
|
||||
},
|
||||
args);
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* ConsoleSingleton::sPyGetStatus(PyObject* /*self*/, PyObject* args)
|
||||
@@ -742,9 +783,11 @@ PyObject* ConsoleSingleton::sPyGetStatus(PyObject* /*self*/, PyObject* args)
|
||||
b = pObs->bNotification;
|
||||
}
|
||||
else {
|
||||
Py_Error(Base::PyExc_FC_GeneralError,
|
||||
"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or "
|
||||
"'Notification')");
|
||||
Py_Error(
|
||||
Base::PyExc_FC_GeneralError,
|
||||
"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or "
|
||||
"'Notification')"
|
||||
);
|
||||
}
|
||||
|
||||
return PyBool_FromLong(b ? 1 : 0);
|
||||
@@ -784,9 +827,11 @@ PyObject* ConsoleSingleton::sPySetStatus(PyObject* /*self*/, PyObject* args)
|
||||
pObs->bNotification = status;
|
||||
}
|
||||
else {
|
||||
Py_Error(Base::PyExc_FC_GeneralError,
|
||||
"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or "
|
||||
"'Notification')");
|
||||
Py_Error(
|
||||
Base::PyExc_FC_GeneralError,
|
||||
"Unknown message type (use 'Log', 'Err', 'Wrn', 'Msg', 'Critical' or "
|
||||
"'Notification')"
|
||||
);
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
|
||||
@@ -44,8 +44,8 @@ using PyMethodDef = struct PyMethodDef;
|
||||
|
||||
// FIXME: Even with parameter packs this is necessary for MSYS2
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
||||
#endif
|
||||
|
||||
//**************************************************************************
|
||||
@@ -53,11 +53,11 @@ using PyMethodDef = struct PyMethodDef;
|
||||
|
||||
#ifdef FC_DEBUG
|
||||
/// switch on the logging of python object creation and destruction
|
||||
#undef FC_LOGPYOBJECTS
|
||||
# undef FC_LOGPYOBJECTS
|
||||
/// switch on the logging of Feature update and execution
|
||||
#define FC_LOGFEATUREUPDATE
|
||||
# define FC_LOGFEATUREUPDATE
|
||||
/// switch on the logging of the Update execution through Doc, App, GuiApp and GuiDoc
|
||||
#undef FC_LOGUPDATECHAIN
|
||||
# undef FC_LOGUPDATECHAIN
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -572,11 +572,13 @@ public:
|
||||
* translated (are untranslatable). Or conversely, may decide not to process already translated
|
||||
* notifications. It is up to the intended behaviour of the observer.
|
||||
*/
|
||||
virtual void sendLog(const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content) = 0;
|
||||
virtual void sendLog(
|
||||
const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* Returns whether a LogStyle category is active or not
|
||||
@@ -713,10 +715,7 @@ public:
|
||||
|
||||
Notification can be direct or via queue.
|
||||
*/
|
||||
template<LogStyle,
|
||||
IntendedRecipient = IntendedRecipient::All,
|
||||
ContentType = ContentType::Untranslated,
|
||||
typename... Args>
|
||||
template<LogStyle, IntendedRecipient = IntendedRecipient::All, ContentType = ContentType::Untranslated, typename... Args>
|
||||
void send(const std::string& notifiername, const char* pMsg, Args&&... args);
|
||||
|
||||
/// Prints a Message
|
||||
@@ -781,9 +780,7 @@ public:
|
||||
void userTranslatedNotification(const std::string& notifier, const char* pMsg, Args&&... args);
|
||||
|
||||
// Notify a message directly to observers
|
||||
template<LogStyle,
|
||||
IntendedRecipient = IntendedRecipient::All,
|
||||
ContentType = ContentType::Untranslated>
|
||||
template<LogStyle, IntendedRecipient = IntendedRecipient::All, ContentType = ContentType::Untranslated>
|
||||
void notify(const std::string& notifiername, const std::string& msg);
|
||||
|
||||
/// Attaches an Observer to FCConsole
|
||||
@@ -877,16 +874,20 @@ public:
|
||||
ConsoleSingleton& operator=(ConsoleSingleton&&) = delete;
|
||||
|
||||
private:
|
||||
void postEvent(FreeCAD_ConsoleMsgType type,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg);
|
||||
void notifyPrivate(LogStyle category,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg) const;
|
||||
void postEvent(
|
||||
FreeCAD_ConsoleMsgType type,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg
|
||||
);
|
||||
void notifyPrivate(
|
||||
LogStyle category,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content,
|
||||
const std::string& notifiername,
|
||||
const std::string& msg
|
||||
) const;
|
||||
|
||||
// singleton
|
||||
static void Destruct();
|
||||
@@ -912,13 +913,15 @@ inline ConsoleSingleton& Console()
|
||||
|
||||
constexpr ConsoleSingleton::FreeCAD_ConsoleMsgType ConsoleSingleton::getConsoleMsg(LogStyle style)
|
||||
{
|
||||
constexpr std::array msgTypes {// In order of LogStyle
|
||||
MsgType_Wrn,
|
||||
MsgType_Txt,
|
||||
MsgType_Err,
|
||||
MsgType_Log,
|
||||
MsgType_Critical,
|
||||
MsgType_Notification};
|
||||
constexpr std::array msgTypes {
|
||||
// In order of LogStyle
|
||||
MsgType_Wrn,
|
||||
MsgType_Txt,
|
||||
MsgType_Err,
|
||||
MsgType_Log,
|
||||
MsgType_Critical,
|
||||
MsgType_Notification
|
||||
};
|
||||
|
||||
return msgTypes.at(static_cast<std::size_t>(style));
|
||||
}
|
||||
@@ -955,12 +958,14 @@ public:
|
||||
bool add_eol;
|
||||
bool refresh;
|
||||
|
||||
LogLevel(const char* tag,
|
||||
const bool print_tag = true,
|
||||
const int print_src = 0,
|
||||
const bool print_time = false,
|
||||
const bool add_eol = true,
|
||||
const bool refresh = false)
|
||||
LogLevel(
|
||||
const char* tag,
|
||||
const bool print_tag = true,
|
||||
const int print_src = 0,
|
||||
const bool print_time = false,
|
||||
const bool add_eol = true,
|
||||
const bool refresh = false
|
||||
)
|
||||
: tag(tag)
|
||||
, lvl(*Console().getLogLevel(tag))
|
||||
, print_tag(print_tag)
|
||||
@@ -1026,36 +1031,37 @@ void Base::ConsoleSingleton::warning(const std::string& notifier, const char* pM
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::developerWarning(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::developerWarning(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
{
|
||||
send<LogStyle::Warning, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::userWarning(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::userWarning(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
{
|
||||
send<LogStyle::Warning, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::translatedUserWarning(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::translatedUserWarning(
|
||||
const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args
|
||||
)
|
||||
{
|
||||
send<LogStyle::Warning, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
@@ -1071,26 +1077,28 @@ void Base::ConsoleSingleton::error(const std::string& notifier, const char* pMsg
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::developerError(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::developerError(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
{
|
||||
send<LogStyle::Error, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::destructorError(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args) noexcept
|
||||
void Base::ConsoleSingleton::destructorError(
|
||||
const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args
|
||||
) noexcept
|
||||
{
|
||||
try {
|
||||
send<LogStyle::Error, IntendedRecipient::Developer, ContentType::Untranslatable>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
catch (...) {
|
||||
assert("An exception was thrown while attempting console output in a destructor" && false);
|
||||
@@ -1098,25 +1106,27 @@ void Base::ConsoleSingleton::destructorError(const std::string& notifier,
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::userError(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::userError(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
{
|
||||
send<LogStyle::Error, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::translatedUserError(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::translatedUserError(
|
||||
const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args
|
||||
)
|
||||
{
|
||||
send<LogStyle::Error, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
@@ -1138,14 +1148,13 @@ void Base::ConsoleSingleton::userNotification(const char* pMsg, Args&&... args)
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::userNotification(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::userNotification(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
{
|
||||
send<LogStyle::Notification, IntendedRecipient::User, ContentType::Untranslated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
@@ -1155,14 +1164,17 @@ void Base::ConsoleSingleton::userTranslatedNotification(const char* pMsg, Args&&
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Base::ConsoleSingleton::userTranslatedNotification(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args)
|
||||
void Base::ConsoleSingleton::userTranslatedNotification(
|
||||
const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args
|
||||
)
|
||||
{
|
||||
send<LogStyle::Notification, IntendedRecipient::User, ContentType::Translated>(
|
||||
notifier,
|
||||
pMsg,
|
||||
std::forward<Args>(args)...);
|
||||
std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
@@ -1177,10 +1189,11 @@ void Base::ConsoleSingleton::log(const std::string& notifier, const char* pMsg,
|
||||
send<LogStyle::Log>(notifier, pMsg, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<Base::LogStyle category,
|
||||
Base::IntendedRecipient recipient /*= Base::IntendedRecipient::All*/,
|
||||
Base::ContentType contenttype /*= Base::ContentType::Untranslated*/,
|
||||
typename... Args>
|
||||
template<
|
||||
Base::LogStyle category,
|
||||
Base::IntendedRecipient recipient /*= Base::IntendedRecipient::All*/,
|
||||
Base::ContentType contenttype /*= Base::ContentType::Untranslated*/,
|
||||
typename... Args>
|
||||
void Base::ConsoleSingleton::send(const std::string& notifiername, const char* pMsg, Args&&... args)
|
||||
{
|
||||
std::string format;
|
||||
@@ -1206,16 +1219,17 @@ void Base::ConsoleSingleton::send(const std::string& notifiername, const char* p
|
||||
}
|
||||
}
|
||||
|
||||
template<Base::LogStyle category,
|
||||
Base::IntendedRecipient recipient /*= Base::IntendedRecipient::All*/,
|
||||
Base::ContentType contenttype /*= Base::ContentType::Untranslated*/>
|
||||
template<
|
||||
Base::LogStyle category,
|
||||
Base::IntendedRecipient recipient /*= Base::IntendedRecipient::All*/,
|
||||
Base::ContentType contenttype /*= Base::ContentType::Untranslated*/>
|
||||
void Base::ConsoleSingleton::notify(const std::string& notifiername, const std::string& msg)
|
||||
{
|
||||
notifyPrivate(category, recipient, contenttype, notifiername, msg);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // BASE_CONSOLE_H
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <Python.h>
|
||||
@@ -60,11 +60,13 @@ ConsoleObserverFile::~ConsoleObserverFile()
|
||||
cFileStream.close();
|
||||
}
|
||||
|
||||
void ConsoleObserverFile::sendLog(const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content)
|
||||
void ConsoleObserverFile::sendLog(
|
||||
const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content
|
||||
)
|
||||
{
|
||||
(void)notifiername;
|
||||
|
||||
@@ -113,11 +115,13 @@ ConsoleObserverStd::ConsoleObserverStd()
|
||||
|
||||
ConsoleObserverStd::~ConsoleObserverStd() = default;
|
||||
|
||||
void ConsoleObserverStd::sendLog(const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content)
|
||||
void ConsoleObserverStd::sendLog(
|
||||
const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content
|
||||
)
|
||||
{
|
||||
(void)notifiername;
|
||||
|
||||
@@ -156,8 +160,7 @@ void ConsoleObserverStd::Warning(const char* sWarn)
|
||||
{
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[1;33m");
|
||||
#endif
|
||||
@@ -167,8 +170,10 @@ void ConsoleObserverStd::Warning(const char* sWarn)
|
||||
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(
|
||||
::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
||||
);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[0m");
|
||||
#endif
|
||||
@@ -179,8 +184,10 @@ void ConsoleObserverStd::Error(const char* sErr)
|
||||
{
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_INTENSITY);
|
||||
::SetConsoleTextAttribute(
|
||||
::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_INTENSITY
|
||||
);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[1;31m");
|
||||
#endif
|
||||
@@ -190,8 +197,10 @@ void ConsoleObserverStd::Error(const char* sErr)
|
||||
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(
|
||||
::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
||||
);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[0m");
|
||||
#endif
|
||||
@@ -202,8 +211,7 @@ void ConsoleObserverStd::Log(const char* sLog)
|
||||
{
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN);
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[1;36m");
|
||||
#endif
|
||||
@@ -213,8 +221,10 @@ void ConsoleObserverStd::Log(const char* sLog)
|
||||
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(
|
||||
::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
||||
);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[0m");
|
||||
#endif
|
||||
@@ -225,8 +235,7 @@ void ConsoleObserverStd::Critical(const char* sCritical)
|
||||
{
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[1;33m");
|
||||
#endif
|
||||
@@ -236,8 +245,10 @@ void ConsoleObserverStd::Critical(const char* sCritical)
|
||||
|
||||
if (useColorStderr) {
|
||||
#if defined(FC_OS_WIN32)
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
::SetConsoleTextAttribute(
|
||||
::GetStdHandle(STD_ERROR_HANDLE),
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
||||
);
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
fprintf(stderr, "\033[0m");
|
||||
#endif
|
||||
|
||||
@@ -45,11 +45,13 @@ public:
|
||||
explicit ConsoleObserverFile(const char* sFileName);
|
||||
~ConsoleObserverFile() override;
|
||||
|
||||
void sendLog(const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content) override;
|
||||
void sendLog(
|
||||
const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content
|
||||
) override;
|
||||
const char* name() override
|
||||
{
|
||||
return "File";
|
||||
@@ -72,11 +74,13 @@ class BaseExport ConsoleObserverStd: public ILogger
|
||||
public:
|
||||
ConsoleObserverStd();
|
||||
~ConsoleObserverStd() override;
|
||||
void sendLog(const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content) override;
|
||||
void sendLog(
|
||||
const std::string& notifiername,
|
||||
const std::string& msg,
|
||||
LogStyle level,
|
||||
IntendedRecipient recipient,
|
||||
ContentType content
|
||||
) override;
|
||||
const char* name() override
|
||||
{
|
||||
return "Console";
|
||||
@@ -105,13 +109,12 @@ class BaseExport ILoggerBlocker
|
||||
public:
|
||||
// Constructor that will block message types passed as parameter. By default, all types are
|
||||
// blocked.
|
||||
inline explicit ILoggerBlocker(const char* co,
|
||||
ConsoleMsgFlags msgTypes = ConsoleSingleton::MsgType_Txt
|
||||
| ConsoleSingleton::MsgType_Log
|
||||
| ConsoleSingleton::MsgType_Wrn
|
||||
| ConsoleSingleton::MsgType_Err
|
||||
| ConsoleSingleton::MsgType_Critical
|
||||
| ConsoleSingleton::MsgType_Notification);
|
||||
inline explicit ILoggerBlocker(
|
||||
const char* co,
|
||||
ConsoleMsgFlags msgTypes = ConsoleSingleton::MsgType_Txt | ConsoleSingleton::MsgType_Log
|
||||
| ConsoleSingleton::MsgType_Wrn | ConsoleSingleton::MsgType_Err
|
||||
| ConsoleSingleton::MsgType_Critical | ConsoleSingleton::MsgType_Notification
|
||||
);
|
||||
// Disable copy & move constructors
|
||||
ILoggerBlocker(ILoggerBlocker const&) = delete;
|
||||
ILoggerBlocker(ILoggerBlocker const&&) = delete;
|
||||
@@ -138,8 +141,7 @@ ILoggerBlocker::~ILoggerBlocker()
|
||||
#ifdef FC_DEBUG
|
||||
auto debug = Console().setEnabledMsgType(conObs, msgTypesBlocked, true);
|
||||
if (debug != msgTypesBlocked) {
|
||||
Console().warning(
|
||||
"Enabled message types have been changed while ILoggerBlocker was set\n");
|
||||
Console().warning("Enabled message types have been changed while ILoggerBlocker was set\n");
|
||||
}
|
||||
#else
|
||||
Console().setEnabledMsgType(conObs, msgTypesBlocked, true);
|
||||
|
||||
@@ -101,9 +101,11 @@ Vec make_vec(const std::tuple<float_type, float_type, float_type>&& ft)
|
||||
{
|
||||
using traits_type = vec_traits<Vec>;
|
||||
using float_traits_type = typename traits_type::float_type;
|
||||
return Vec(float_traits_type(std::get<0>(ft)),
|
||||
float_traits_type(std::get<1>(ft)),
|
||||
float_traits_type(std::get<2>(ft)));
|
||||
return Vec(
|
||||
float_traits_type(std::get<0>(ft)),
|
||||
float_traits_type(std::get<1>(ft)),
|
||||
float_traits_type(std::get<2>(ft))
|
||||
);
|
||||
}
|
||||
|
||||
// type with four floats
|
||||
@@ -112,10 +114,12 @@ Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&&
|
||||
{
|
||||
using traits_type = vec_traits<Vec>;
|
||||
using float_traits_type = typename traits_type::float_type;
|
||||
return Vec(float_traits_type(std::get<0>(ft)),
|
||||
float_traits_type(std::get<1>(ft)),
|
||||
float_traits_type(std::get<2>(ft)),
|
||||
float_traits_type(std::get<3>(ft)));
|
||||
return Vec(
|
||||
float_traits_type(std::get<0>(ft)),
|
||||
float_traits_type(std::get<1>(ft)),
|
||||
float_traits_type(std::get<2>(ft)),
|
||||
float_traits_type(std::get<3>(ft))
|
||||
);
|
||||
}
|
||||
|
||||
template<class Vec1, class Vec2>
|
||||
|
||||
@@ -41,8 +41,7 @@ std::string CoordinateSystemPy::representation() const
|
||||
return {"<CoordinateSystem object>"};
|
||||
}
|
||||
|
||||
PyObject*
|
||||
CoordinateSystemPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
|
||||
PyObject* CoordinateSystemPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
|
||||
{
|
||||
// create a new instance of CoordinateSystemPy and the Twin object
|
||||
return new CoordinateSystemPy(new CoordinateSystem);
|
||||
@@ -59,15 +58,19 @@ PyObject* CoordinateSystemPy::setAxes(PyObject* args)
|
||||
PyObject* axis {};
|
||||
PyObject* xdir {};
|
||||
if (PyArg_ParseTuple(args, "O!O!", &(AxisPy::Type), &axis, &(VectorPy::Type), &xdir)) {
|
||||
getCoordinateSystemPtr()->setAxes(*static_cast<AxisPy*>(axis)->getAxisPtr(),
|
||||
*static_cast<VectorPy*>(xdir)->getVectorPtr());
|
||||
getCoordinateSystemPtr()->setAxes(
|
||||
*static_cast<AxisPy*>(axis)->getAxisPtr(),
|
||||
*static_cast<VectorPy*>(xdir)->getVectorPtr()
|
||||
);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O!O!", &(VectorPy::Type), &axis, &(VectorPy::Type), &xdir)) {
|
||||
getCoordinateSystemPtr()->setAxes(*static_cast<VectorPy*>(axis)->getVectorPtr(),
|
||||
*static_cast<VectorPy*>(xdir)->getVectorPtr());
|
||||
getCoordinateSystemPtr()->setAxes(
|
||||
*static_cast<VectorPy*>(axis)->getVectorPtr(),
|
||||
*static_cast<VectorPy*>(xdir)->getVectorPtr()
|
||||
);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
@@ -82,7 +85,8 @@ PyObject* CoordinateSystemPy::displacement(PyObject* args) const
|
||||
return nullptr;
|
||||
}
|
||||
Placement plm = getCoordinateSystemPtr()->displacement(
|
||||
*static_cast<CoordinateSystemPy*>(cs)->getCoordinateSystemPtr());
|
||||
*static_cast<CoordinateSystemPy*>(cs)->getCoordinateSystemPtr()
|
||||
);
|
||||
return new PlacementPy(new Placement(plm));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <QEventLoop>
|
||||
#include <QObject>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
namespace Base
|
||||
|
||||
@@ -39,10 +39,12 @@ Base::DualQuat Base::operator-(Base::DualQuat a, Base::DualQuat b)
|
||||
|
||||
Base::DualQuat Base::operator*(Base::DualQuat a, Base::DualQuat b)
|
||||
{
|
||||
return {a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
||||
a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z,
|
||||
a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x,
|
||||
a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z};
|
||||
return {
|
||||
a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
||||
a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z,
|
||||
a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x,
|
||||
a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z
|
||||
};
|
||||
}
|
||||
|
||||
Base::DualQuat Base::operator*(Base::DualQuat a, double b)
|
||||
@@ -109,9 +111,9 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const
|
||||
|
||||
DualQuat self = *this;
|
||||
if (shorten) {
|
||||
if (dot(self, identity())
|
||||
< -1e-12) { // using negative tolerance instead of zero, for stability in situations
|
||||
// the choice is ambiguous (180-degree rotations)
|
||||
if (dot(self, identity()) < -1e-12) { // using negative tolerance instead of zero, for
|
||||
// stability in situations the choice is ambiguous
|
||||
// (180-degree rotations)
|
||||
self = -self;
|
||||
}
|
||||
}
|
||||
@@ -128,8 +130,10 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const
|
||||
pitch *= t;
|
||||
|
||||
// back to quaternion
|
||||
return {l * sin(theta / 2) + DualQuat(0, 0, 0, cos(theta / 2)),
|
||||
m * sin(theta / 2) + pitch / 2 * cos(theta / 2) * l
|
||||
+ DualQuat(0, 0, 0, -pitch / 2 * sin(theta / 2))};
|
||||
return {
|
||||
l * sin(theta / 2) + DualQuat(0, 0, 0, cos(theta / 2)),
|
||||
m * sin(theta / 2) + pitch / 2 * cos(theta / 2) * l
|
||||
+ DualQuat(0, 0, 0, -pitch / 2 * sin(theta / 2))
|
||||
};
|
||||
}
|
||||
// NOLINTEND(readability-identifier-length)
|
||||
|
||||
@@ -590,9 +590,9 @@ PyObject* RestoreError::getPyExceptionType() const
|
||||
// ---------------------------------------------------------
|
||||
|
||||
#if defined(__GNUC__) && defined(FC_OS_LINUX)
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <csignal>
|
||||
# include <stdexcept>
|
||||
# include <iostream>
|
||||
# include <csignal>
|
||||
|
||||
SignalException::SignalException()
|
||||
{
|
||||
@@ -601,17 +601,17 @@ SignalException::SignalException()
|
||||
sigemptyset(&new_action.sa_mask);
|
||||
new_action.sa_flags = 0;
|
||||
ok = (sigaction(SIGSEGV, &new_action, &old_action) < 0);
|
||||
#ifdef _DEBUG
|
||||
# ifdef _DEBUG
|
||||
std::cout << "Set new signal handler" << std::endl;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
SignalException::~SignalException()
|
||||
{
|
||||
sigaction(SIGSEGV, &old_action, nullptr);
|
||||
#ifdef _DEBUG
|
||||
# ifdef _DEBUG
|
||||
std::cout << "Restore old signal handler" << std::endl;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void SignalException::throw_signal(const int signum)
|
||||
|
||||
@@ -39,13 +39,13 @@ using PyObject = struct _object; // NOLINT
|
||||
|
||||
// Remove once all used compilers support this
|
||||
#if defined(__cpp_lib_source_location)
|
||||
#define HAVE_STD_SOURCE_LOCATION 1
|
||||
# define HAVE_STD_SOURCE_LOCATION 1
|
||||
#else
|
||||
#undef HAVE_STD_SOURCE_LOCATION
|
||||
# undef HAVE_STD_SOURCE_LOCATION
|
||||
#endif
|
||||
// std::source_location is implemented, but buggy in Clang 15
|
||||
#if defined(__clang__) && __clang_major__ <= 15
|
||||
#undef HAVE_STD_SOURCE_LOCATION
|
||||
# undef HAVE_STD_SOURCE_LOCATION
|
||||
#endif
|
||||
|
||||
/// The macros do NOT mark any message for translation
|
||||
@@ -62,23 +62,25 @@ using PyObject = struct _object; // NOLINT
|
||||
|
||||
#if defined(HAVE_STD_SOURCE_LOCATION)
|
||||
// NOLINTBEGIN(*-macro-usage)
|
||||
#define THROWM(exc, msg) Base::setupAndThrowException<exc>((msg), std::source_location::current());
|
||||
#define THROWMT(exc, msg) \
|
||||
Base::setupAndThrowException<exc>((msg), std::source_location::current(), true);
|
||||
#define FC_THROWM(exception, msg) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << msg; \
|
||||
THROWM(exception, ss.str()); \
|
||||
} while (0)
|
||||
# define THROWM(exc, msg) Base::setupAndThrowException<exc>((msg), std::source_location::current());
|
||||
# define THROWMT(exc, msg) \
|
||||
Base::setupAndThrowException<exc>((msg), std::source_location::current(), true);
|
||||
# define FC_THROWM(exception, msg) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << msg; \
|
||||
THROWM(exception, ss.str()); \
|
||||
} while (0)
|
||||
// NOLINTEND(*-macro-usage)
|
||||
|
||||
namespace Base
|
||||
{
|
||||
template<typename ExceptionType>
|
||||
[[noreturn]] void setupAndThrowException(const std::string message,
|
||||
const std::source_location location,
|
||||
const bool translatable = false)
|
||||
[[noreturn]] void setupAndThrowException(
|
||||
const std::string message,
|
||||
const std::source_location location,
|
||||
const bool translatable = false
|
||||
)
|
||||
{
|
||||
ExceptionType exception {message};
|
||||
exception.setTranslatable(translatable);
|
||||
@@ -89,30 +91,32 @@ template<typename ExceptionType>
|
||||
|
||||
#else // HAVE_STD_SOURCE_LOCATION
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FC_THROW_INFO __FILE__, __LINE__, __FUNCSIG__
|
||||
#elif __GNUC__
|
||||
#define FC_THROW_INFO __FILE__, __LINE__, __PRETTY_FUNCTION__
|
||||
#else
|
||||
#define FC_THROW_INFO __FILE__, __LINE__, __func__
|
||||
#endif
|
||||
# ifdef _MSC_VER
|
||||
# define FC_THROW_INFO __FILE__, __LINE__, __FUNCSIG__
|
||||
# elif __GNUC__
|
||||
# define FC_THROW_INFO __FILE__, __LINE__, __PRETTY_FUNCTION__
|
||||
# else
|
||||
# define FC_THROW_INFO __FILE__, __LINE__, __func__
|
||||
# endif
|
||||
|
||||
#define THROWM(exc, msg) Base::setupAndThrowException<exc>(msg, FC_THROW_INFO);
|
||||
#define THROWMT(exc, msg) Base::setupAndThrowException<exc>(msg, FC_THROW_INFO, true);
|
||||
#define FC_THROWM(exception, msg) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << msg; \
|
||||
THROWM(exception, ss.str()); \
|
||||
} while (0)
|
||||
# define THROWM(exc, msg) Base::setupAndThrowException<exc>(msg, FC_THROW_INFO);
|
||||
# define THROWMT(exc, msg) Base::setupAndThrowException<exc>(msg, FC_THROW_INFO, true);
|
||||
# define FC_THROWM(exception, msg) \
|
||||
do { \
|
||||
std::stringstream ss; \
|
||||
ss << msg; \
|
||||
THROWM(exception, ss.str()); \
|
||||
} while (0)
|
||||
namespace Base
|
||||
{
|
||||
template<typename ExceptionType>
|
||||
[[noreturn]] void setupAndThrowException(const std::string message,
|
||||
const char* file,
|
||||
const int line,
|
||||
const char* func,
|
||||
const bool translatable = false)
|
||||
[[noreturn]] void setupAndThrowException(
|
||||
const std::string message,
|
||||
const char* file,
|
||||
const int line,
|
||||
const char* func,
|
||||
const bool translatable = false
|
||||
)
|
||||
{
|
||||
ExceptionType exception {message};
|
||||
exception.setTranslatable(translatable);
|
||||
@@ -126,22 +130,28 @@ template<typename ExceptionType>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
template<typename Exception>
|
||||
constexpr void THROWM_(const std::string& msg,
|
||||
const std::source_location location = std::source_location::current())
|
||||
constexpr void THROWM_(
|
||||
const std::string& msg,
|
||||
const std::source_location location = std::source_location::current()
|
||||
)
|
||||
{
|
||||
Base::setupAndThrowException<Exception>(msg, location);
|
||||
}
|
||||
|
||||
template<typename Exception>
|
||||
constexpr void THROWMT_(const std::string& msg,
|
||||
const std::source_location location = std::source_location::current())
|
||||
constexpr void THROWMT_(
|
||||
const std::string& msg,
|
||||
const std::source_location location = std::source_location::current()
|
||||
)
|
||||
{
|
||||
Base::setupAndThrowException<Exception>(msg, location, true);
|
||||
}
|
||||
|
||||
template<typename Exception>
|
||||
constexpr void FC_THROWM_(const std::string& raw_msg,
|
||||
const std::source_location location = std::source_location::current())
|
||||
constexpr void FC_THROWM_(
|
||||
const std::string& raw_msg,
|
||||
const std::source_location location = std::source_location::current()
|
||||
)
|
||||
{
|
||||
THROWM_<Exception>(raw_msg, location);
|
||||
}
|
||||
@@ -241,8 +251,10 @@ public:
|
||||
class BaseExport FileException: public Exception
|
||||
{
|
||||
public:
|
||||
explicit FileException(const std::string& message = "Unknown file exception happened",
|
||||
const std::string& fileName = "");
|
||||
explicit FileException(
|
||||
const std::string& message = "Unknown file exception happened",
|
||||
const std::string& fileName = ""
|
||||
);
|
||||
FileException(const std::string& message, const FileInfo& File);
|
||||
|
||||
const char* what() const noexcept override;
|
||||
@@ -319,8 +331,7 @@ public:
|
||||
class BaseExport AbnormalProgramTermination: public Exception
|
||||
{
|
||||
public:
|
||||
explicit AbnormalProgramTermination(
|
||||
const std::string& message = "Abnormal program termination");
|
||||
explicit AbnormalProgramTermination(const std::string& message = "Abnormal program termination");
|
||||
PyObject* getPyExceptionType() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
#include <iostream>
|
||||
#include <system_error>
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <Windows.h>
|
||||
# include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "FileInfo.h"
|
||||
@@ -285,9 +285,7 @@ bool FileInfo::hasExtension(const char* Ext) const
|
||||
|
||||
bool FileInfo::hasExtension(std::initializer_list<const char*> Exts) const
|
||||
{
|
||||
return std::ranges::any_of(Exts, [this](const char* ext) {
|
||||
return hasExtension(ext);
|
||||
});
|
||||
return std::ranges::any_of(Exts, [this](const char* ext) { return hasExtension(ext); });
|
||||
}
|
||||
|
||||
bool FileInfo::exists() const
|
||||
@@ -404,8 +402,7 @@ template<typename TP>
|
||||
std::time_t to_time_t(TP tp)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto sctp =
|
||||
time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
|
||||
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
|
||||
return system_clock::to_time_t(sctp);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +117,9 @@ Py::PythonClassObject<Vector2dPy> Vector2dPy::create(double vx, double vy)
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(vx));
|
||||
arg.setItem(1, Py::Float(vy));
|
||||
Py::PythonClassObject<Vector2dPy> py =
|
||||
Py::PythonClassObject<Vector2dPy>(class_type.apply(arg, Py::Dict()));
|
||||
Py::PythonClassObject<Vector2dPy> py = Py::PythonClassObject<Vector2dPy>(
|
||||
class_type.apply(arg, Py::Dict())
|
||||
);
|
||||
return py;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,12 +284,10 @@ private:
|
||||
};
|
||||
|
||||
// PyCXX wrapper classes Py::Matrix, Py::Rotation, Py::Placement, ...
|
||||
using BoundingBox =
|
||||
GeometryT<Base::BoundBox3d, Base::BoundBoxPy, &Base::BoundBoxPy::getBoundBoxPtr>;
|
||||
using BoundingBox = GeometryT<Base::BoundBox3d, Base::BoundBoxPy, &Base::BoundBoxPy::getBoundBoxPtr>;
|
||||
using Matrix = GeometryT<Base::Matrix4D, Base::MatrixPy, &Base::MatrixPy::getMatrixPtr>;
|
||||
using Rotation = GeometryT<Base::Rotation, Base::RotationPy, &Base::RotationPy::getRotationPtr>;
|
||||
using Placement =
|
||||
GeometryT<Base::Placement, Base::PlacementPy, &Base::PlacementPy::getPlacementPtr>;
|
||||
using Placement = GeometryT<Base::Placement, Base::PlacementPy, &Base::PlacementPy::getPlacementPtr>;
|
||||
|
||||
} // namespace Py
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define BASE_HANDLE_H
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#include <qglobal.h>
|
||||
#if QT_VERSION < 0x060000
|
||||
#include <QTextCodec>
|
||||
# include <QTextCodec>
|
||||
#else
|
||||
#include <QByteArray>
|
||||
#include <QStringDecoder>
|
||||
#include <QStringEncoder>
|
||||
# include <QByteArray>
|
||||
# include <QStringDecoder>
|
||||
# include <QStringEncoder>
|
||||
#endif
|
||||
|
||||
#include "InputSource.h"
|
||||
#include "XMLTools.h"
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
using namespace XERCES_CPP_NAMESPACE;
|
||||
#else
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
@@ -66,9 +66,8 @@ struct StdInputStream::TextCodec
|
||||
QTextCodec* textCodec = QTextCodec::codecForName("UTF-8");
|
||||
if (textCodec) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
const QString text = textCodec->toUnicode(reinterpret_cast<char*>(toFill),
|
||||
static_cast<int>(len),
|
||||
&state);
|
||||
const QString text
|
||||
= textCodec->toUnicode(reinterpret_cast<char*>(toFill), static_cast<int>(len), &state);
|
||||
if (state.invalidChars > 0) {
|
||||
// In case invalid characters were found decode back to 'utf-8' and replace
|
||||
// them with '?'
|
||||
@@ -114,8 +113,10 @@ struct StdInputStream::TextCodec
|
||||
};
|
||||
#endif
|
||||
|
||||
StdInputStream::StdInputStream(std::istream& Stream,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager)
|
||||
StdInputStream::StdInputStream(
|
||||
std::istream& Stream,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager
|
||||
)
|
||||
: stream(Stream)
|
||||
, codec(new TextCodec)
|
||||
{
|
||||
@@ -153,9 +154,11 @@ XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxTo
|
||||
// ---------------------------------------------------------------------------
|
||||
// StdInputSource: Constructors and Destructor
|
||||
// ---------------------------------------------------------------------------
|
||||
StdInputSource::StdInputSource(std::istream& Stream,
|
||||
const char* filePath,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager)
|
||||
StdInputSource::StdInputSource(
|
||||
std::istream& Stream,
|
||||
const char* filePath,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager
|
||||
)
|
||||
: InputSource(manager)
|
||||
, stream(Stream)
|
||||
{
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
#include <xercesc/util/BinInputStream.hpp>
|
||||
#include <xercesc/sax/InputSource.hpp>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
namespace XERCES_CPP_NAMESPACE
|
||||
{
|
||||
class BinInputStream;
|
||||
@@ -95,10 +95,12 @@ private:
|
||||
class BaseExport StdInputSource: public XERCES_CPP_NAMESPACE_QUALIFIER InputSource
|
||||
{
|
||||
public:
|
||||
StdInputSource(std::istream& Stream,
|
||||
const char* filePath,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager =
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
|
||||
StdInputSource(
|
||||
std::istream& Stream,
|
||||
const char* filePath,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const manager
|
||||
= XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager
|
||||
);
|
||||
~StdInputSource() override;
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream* makeStream() const override;
|
||||
|
||||
@@ -127,11 +127,13 @@ void PyException::reportException() const
|
||||
// set sys.last_vars to make post-mortem debugging work
|
||||
PyGILStateLocker locker;
|
||||
PySys_SetObject("last_traceback", PP_last_traceback);
|
||||
Console().developerError("pyException",
|
||||
"%s%s: %s\n",
|
||||
_stackTrace.c_str(),
|
||||
_errorType.c_str(),
|
||||
what());
|
||||
Console().developerError(
|
||||
"pyException",
|
||||
"%s%s: %s\n",
|
||||
_stackTrace.c_str(),
|
||||
_errorType.c_str(),
|
||||
what()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,9 +277,11 @@ std::string InterpreterSingleton::runString(const char* sCmd)
|
||||
* if the error occurs after changing it inside the script.
|
||||
*/
|
||||
|
||||
std::string InterpreterSingleton::runStringWithKey(const char* psCmd,
|
||||
const char* key,
|
||||
const char* key_initial_value)
|
||||
std::string InterpreterSingleton::runStringWithKey(
|
||||
const char* psCmd,
|
||||
const char* key,
|
||||
const char* key_initial_value
|
||||
)
|
||||
{
|
||||
PyGILStateLocker locker;
|
||||
Py::Module module("__main__");
|
||||
@@ -286,8 +290,8 @@ std::string InterpreterSingleton::runStringWithKey(const char* psCmd,
|
||||
Py::String initial_value(key_initial_value);
|
||||
localDictionary.setItem(key, initial_value);
|
||||
|
||||
PyObject* presult =
|
||||
PyRun_String(psCmd, Py_file_input, globalDictionary.ptr(), localDictionary.ptr());
|
||||
PyObject* presult
|
||||
= PyRun_String(psCmd, Py_file_input, globalDictionary.ptr(), localDictionary.ptr());
|
||||
if (!presult) {
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
@@ -508,12 +512,12 @@ void InterpreterSingleton::cleanupModules()
|
||||
{
|
||||
// This is only needed to make the address sanitizer happy
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
# if __has_feature(address_sanitizer)
|
||||
for (auto it : _modules) {
|
||||
delete it;
|
||||
}
|
||||
_modules.clear();
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -587,7 +591,8 @@ std::string InterpreterSingleton::init(int argc, char* argv[])
|
||||
"base_path = os.getenv(\"VIRTUAL_ENV\")\n"
|
||||
"if not base_path is None:\n"
|
||||
" activate_this = os.path.join(base_path, \"bin\", \"activate_this.py\")\n"
|
||||
" exec(open(activate_this).read(), {'__file__':activate_this})\n");
|
||||
" exec(open(activate_this).read(), {'__file__':activate_this})\n"
|
||||
);
|
||||
}
|
||||
|
||||
size_t size = argc;
|
||||
@@ -734,11 +739,13 @@ int InterpreterSingleton::runCommandLine(const char* prompt)
|
||||
void InterpreterSingleton::runMethodVoid(PyObject* pobject, const char* method)
|
||||
{
|
||||
PyGILStateLocker locker;
|
||||
if (PP_Run_Method(pobject, // object
|
||||
method, // run method
|
||||
nullptr, // no return type
|
||||
nullptr, // so no return object
|
||||
"()") // no arguments
|
||||
if (PP_Run_Method(
|
||||
pobject, // object
|
||||
method, // run method
|
||||
nullptr, // no return type
|
||||
nullptr, // so no return object
|
||||
"()"
|
||||
) // no arguments
|
||||
!= 0) {
|
||||
throw PyException(/*"Error running InterpreterSingleton::RunMethodVoid()"*/);
|
||||
}
|
||||
@@ -749,11 +756,13 @@ PyObject* InterpreterSingleton::runMethodObject(PyObject* pobject, const char* m
|
||||
PyObject* pcO {};
|
||||
|
||||
PyGILStateLocker locker;
|
||||
if (PP_Run_Method(pobject, // object
|
||||
method, // run method
|
||||
"O", // return type
|
||||
&pcO, // return object
|
||||
"()") // no arguments
|
||||
if (PP_Run_Method(
|
||||
pobject, // object
|
||||
method, // run method
|
||||
"O", // return type
|
||||
&pcO, // return object
|
||||
"()"
|
||||
) // no arguments
|
||||
!= 0) {
|
||||
throw PyException();
|
||||
}
|
||||
@@ -761,12 +770,14 @@ PyObject* InterpreterSingleton::runMethodObject(PyObject* pobject, const char* m
|
||||
return pcO;
|
||||
}
|
||||
|
||||
void InterpreterSingleton::runMethod(PyObject* pobject,
|
||||
const char* method,
|
||||
const char* resfmt,
|
||||
void* cresult, /* convert to c/c++ */
|
||||
const char* argfmt,
|
||||
...) /* convert to python */
|
||||
void InterpreterSingleton::runMethod(
|
||||
PyObject* pobject,
|
||||
const char* method,
|
||||
const char* resfmt,
|
||||
void* cresult, /* convert to c/c++ */
|
||||
const char* argfmt,
|
||||
...
|
||||
) /* convert to python */
|
||||
{
|
||||
PyObject* pmeth {};
|
||||
PyObject* pargs {};
|
||||
@@ -779,8 +790,9 @@ void InterpreterSingleton::runMethod(PyObject* pobject,
|
||||
if (!pmeth) { /* get callable object */
|
||||
va_end(argslist);
|
||||
throw AttributeError(
|
||||
"Error running InterpreterSingleton::RunMethod() method not defined"); /* bound method?
|
||||
has self */
|
||||
"Error running InterpreterSingleton::RunMethod() method not defined"
|
||||
); /* bound method?
|
||||
has self */
|
||||
}
|
||||
|
||||
pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */
|
||||
@@ -800,7 +812,8 @@ void InterpreterSingleton::runMethod(PyObject* pobject,
|
||||
PyErr_Print();
|
||||
}
|
||||
throw RuntimeError(
|
||||
"Error running InterpreterSingleton::RunMethod() exception in called method");
|
||||
"Error running InterpreterSingleton::RunMethod() exception in called method"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,10 +938,12 @@ extern int getSWIGPointerTypeObj_T(const char* TypeName, PyTypeObject** ptr);
|
||||
} // namespace Swig_python
|
||||
#endif
|
||||
|
||||
PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module,
|
||||
const char* TypeName,
|
||||
void* Pointer,
|
||||
int own)
|
||||
PyObject* InterpreterSingleton::createSWIGPointerObj(
|
||||
const char* Module,
|
||||
const char* TypeName,
|
||||
void* Pointer,
|
||||
int own
|
||||
)
|
||||
{
|
||||
int result = 0;
|
||||
PyObject* proxy = nullptr;
|
||||
@@ -951,11 +966,13 @@ PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module,
|
||||
throw Base::RuntimeError("No SWIG wrapped library loaded");
|
||||
}
|
||||
|
||||
bool InterpreterSingleton::convertSWIGPointerObj(const char* Module,
|
||||
const char* TypeName,
|
||||
PyObject* obj,
|
||||
void** ptr,
|
||||
int flags)
|
||||
bool InterpreterSingleton::convertSWIGPointerObj(
|
||||
const char* Module,
|
||||
const char* TypeName,
|
||||
PyObject* obj,
|
||||
void** ptr,
|
||||
int flags
|
||||
)
|
||||
{
|
||||
int result = 0;
|
||||
PyGILStateLocker locker;
|
||||
|
||||
@@ -27,22 +27,22 @@
|
||||
#define BASE_INTERPRETER_H
|
||||
|
||||
#if defined(_POSIX_C_SOURCE)
|
||||
#undef _POSIX_C_SOURCE
|
||||
# undef _POSIX_C_SOURCE
|
||||
#endif // (re-)defined in pyconfig.h
|
||||
#if defined(_XOPEN_SOURCE)
|
||||
#undef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE
|
||||
#endif // (re-)defined in pyconfig.h
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_MACOSX
|
||||
#undef toupper
|
||||
#undef tolower
|
||||
#undef isupper
|
||||
#undef islower
|
||||
#undef isspace
|
||||
#undef isalpha
|
||||
#undef isalnum
|
||||
# undef toupper
|
||||
# undef tolower
|
||||
# undef isupper
|
||||
# undef islower
|
||||
# undef isspace
|
||||
# undef isalpha
|
||||
# undef isalnum
|
||||
#endif
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
@@ -60,14 +60,14 @@
|
||||
*
|
||||
* See FeaturePythonImp::init() for example usage
|
||||
*/
|
||||
#define FC_PY_GetCallable(_pyobj, _name, _var) \
|
||||
do { \
|
||||
_var = Py::Object(); \
|
||||
if (PyObject_HasAttrString(_pyobj, _name)) { \
|
||||
Py::Object _obj(PyObject_GetAttrString(_pyobj, _name), true); \
|
||||
if (_obj.isCallable()) \
|
||||
_var = _obj; \
|
||||
} \
|
||||
#define FC_PY_GetCallable(_pyobj, _name, _var) \
|
||||
do { \
|
||||
_var = Py::Object(); \
|
||||
if (PyObject_HasAttrString(_pyobj, _name)) { \
|
||||
Py::Object _obj(PyObject_GetAttrString(_pyobj, _name), true); \
|
||||
if (_obj.isCallable()) \
|
||||
_var = _obj; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/** Helper macro to obtain attribute from an object
|
||||
@@ -78,11 +78,11 @@
|
||||
*
|
||||
* See FeaturePythonImp::init() for example usage
|
||||
*/
|
||||
#define FC_PY_GetObject(_pyobj, _name, _var) \
|
||||
do { \
|
||||
_var = Py::Object(); \
|
||||
if (PyObject_HasAttrString(_pyobj, _name)) \
|
||||
_var = Py::asObject(PyObject_GetAttrString(_pyobj, _name)); \
|
||||
#define FC_PY_GetObject(_pyobj, _name, _var) \
|
||||
do { \
|
||||
_var = Py::Object(); \
|
||||
if (PyObject_HasAttrString(_pyobj, _name)) \
|
||||
_var = Py::asObject(PyObject_GetAttrString(_pyobj, _name)); \
|
||||
} while (0)
|
||||
// NOLINTEND
|
||||
|
||||
@@ -257,8 +257,7 @@ public:
|
||||
/// the result.
|
||||
std::string runString(const char* psCmd);
|
||||
/// Run a statement on the python interpreter with a key for exchanging strings
|
||||
std::string
|
||||
runStringWithKey(const char* psCmd, const char* key, const char* key_initial_value = "");
|
||||
std::string runStringWithKey(const char* psCmd, const char* key, const char* key_initial_value = "");
|
||||
/// Run a statement on the python interpreter and return back the result object.
|
||||
Py::Object runStringObject(const char* sCmd);
|
||||
/// Run a statement on the python interpreter and gives back a string with the representation of
|
||||
@@ -273,12 +272,14 @@ public:
|
||||
/// runs a python object method which returns a arbitrary object
|
||||
PyObject* runMethodObject(PyObject* pobject, const char* method);
|
||||
/// runs a python method with arbitrary params
|
||||
void runMethod(PyObject* pobject,
|
||||
const char* method,
|
||||
const char* resfmt = nullptr,
|
||||
void* cresult = nullptr,
|
||||
const char* argfmt = "()",
|
||||
...);
|
||||
void runMethod(
|
||||
PyObject* pobject,
|
||||
const char* method,
|
||||
const char* resfmt = nullptr,
|
||||
void* cresult = nullptr,
|
||||
const char* argfmt = "()",
|
||||
...
|
||||
);
|
||||
//@}
|
||||
|
||||
/** @name Module handling
|
||||
@@ -332,13 +333,14 @@ public:
|
||||
*/
|
||||
//@{
|
||||
/// generate a SWIG object
|
||||
PyObject*
|
||||
createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own);
|
||||
bool convertSWIGPointerObj(const char* Module,
|
||||
const char* TypeName,
|
||||
PyObject* obj,
|
||||
void** ptr,
|
||||
int flags);
|
||||
PyObject* createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own);
|
||||
bool convertSWIGPointerObj(
|
||||
const char* Module,
|
||||
const char* TypeName,
|
||||
PyObject* obj,
|
||||
void** ptr,
|
||||
int flags
|
||||
);
|
||||
void cleanupSWIG(const char* TypeName);
|
||||
PyTypeObject* getSWIGPointerTypeObj(const char* Module, const char* TypeName);
|
||||
//@}
|
||||
|
||||
@@ -349,10 +349,7 @@ void Matrix4D::rotLine(const Vector3f& rclBase, const Vector3f& rclDir, float fA
|
||||
* Note: In case the \a fTranslation part is zero then passing \a rclBase, \a rclDir and \a rfAngle
|
||||
* to a new matrix object creates an identical matrix.
|
||||
*/
|
||||
bool Matrix4D::toAxisAngle(Vector3f& rclBase,
|
||||
Vector3f& rclDir,
|
||||
float& rfAngle,
|
||||
float& fTranslation) const
|
||||
bool Matrix4D::toAxisAngle(Vector3f& rclBase, Vector3f& rclDir, float& rfAngle, float& fTranslation) const
|
||||
{
|
||||
Vector3d pnt = convertTo<Vector3d>(rclBase);
|
||||
Vector3d dir = convertTo<Vector3d>(rclDir);
|
||||
@@ -370,22 +367,23 @@ bool Matrix4D::toAxisAngle(Vector3f& rclBase,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool Matrix4D::toAxisAngle(Vector3d& rclBase,
|
||||
Vector3d& rclDir,
|
||||
double& rfAngle,
|
||||
double& fTranslation) const
|
||||
bool Matrix4D::toAxisAngle(Vector3d& rclBase, Vector3d& rclDir, double& rfAngle, double& fTranslation) const
|
||||
{
|
||||
// First check if the 3x3 submatrix is orthogonal
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// length must be one
|
||||
if (fabs(dMtrx4D[0][i] * dMtrx4D[0][i] + dMtrx4D[1][i] * dMtrx4D[1][i]
|
||||
+ dMtrx4D[2][i] * dMtrx4D[2][i] - 1.0)
|
||||
if (fabs(
|
||||
dMtrx4D[0][i] * dMtrx4D[0][i] + dMtrx4D[1][i] * dMtrx4D[1][i]
|
||||
+ dMtrx4D[2][i] * dMtrx4D[2][i] - 1.0
|
||||
)
|
||||
> 0.01) {
|
||||
return false;
|
||||
}
|
||||
// scalar product with other rows must be zero
|
||||
if (fabs(dMtrx4D[0][i] * dMtrx4D[0][(i + 1) % 3] + dMtrx4D[1][i] * dMtrx4D[1][(i + 1) % 3]
|
||||
+ dMtrx4D[2][i] * dMtrx4D[2][(i + 1) % 3])
|
||||
if (fabs(
|
||||
dMtrx4D[0][i] * dMtrx4D[0][(i + 1) % 3] + dMtrx4D[1][i] * dMtrx4D[1][(i + 1) % 3]
|
||||
+ dMtrx4D[2][i] * dMtrx4D[2][(i + 1) % 3]
|
||||
)
|
||||
> 0.01) {
|
||||
return false;
|
||||
}
|
||||
@@ -688,11 +686,7 @@ void Matrix4D::Print() const
|
||||
{
|
||||
// NOLINTBEGIN
|
||||
for (int i = 0; i < 4; i++) {
|
||||
printf("%9.3f %9.3f %9.3f %9.3f\n",
|
||||
dMtrx4D[i][0],
|
||||
dMtrx4D[i][1],
|
||||
dMtrx4D[i][2],
|
||||
dMtrx4D[i][3]);
|
||||
printf("%9.3f %9.3f %9.3f %9.3f\n", dMtrx4D[i][0], dMtrx4D[i][1], dMtrx4D[i][2], dMtrx4D[i][3]);
|
||||
}
|
||||
// NOLINTEND
|
||||
}
|
||||
@@ -957,9 +951,7 @@ std::array<Matrix4D, 4> Matrix4D::decompose() const
|
||||
residualMatrix.setCol(3, Vector3d());
|
||||
// find and extract rotation
|
||||
int prim_dir = -1;
|
||||
std::array<Vector3d, 3> dirs = {Vector3d(1., 0., 0.),
|
||||
Vector3d(0., 1., 0.),
|
||||
Vector3d(0., 0., 1.)};
|
||||
std::array<Vector3d, 3> dirs = {Vector3d(1., 0., 0.), Vector3d(0., 1., 0.), Vector3d(0., 0., 1.)};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (residualMatrix.getCol(i).IsNull()) {
|
||||
continue;
|
||||
@@ -1016,9 +1008,11 @@ std::array<Matrix4D, 4> Matrix4D::decompose() const
|
||||
scaleMatrix.dMtrx4D[1][1] = yScale;
|
||||
scaleMatrix.dMtrx4D[2][2] = zScale;
|
||||
// The remaining shear
|
||||
residualMatrix.scale(xScale != 0 ? 1.0 / xScale : 1.0,
|
||||
yScale != 0 ? 1.0 / yScale : 1.0,
|
||||
zScale != 0 ? 1.0 / zScale : 1.0);
|
||||
residualMatrix.scale(
|
||||
xScale != 0 ? 1.0 / xScale : 1.0,
|
||||
yScale != 0 ? 1.0 / yScale : 1.0,
|
||||
zScale != 0 ? 1.0 / zScale : 1.0
|
||||
);
|
||||
// Restore trace in shear matrix
|
||||
residualMatrix.setDiagonal(Vector3d(1.0, 1.0, 1.0));
|
||||
// Remove values close to zero
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "Vector3D.h"
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -215,8 +215,7 @@ public:
|
||||
void rotLine(const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
|
||||
/// Extract the rotation axis and angle. Therefore the 3x3 submatrix must be orthogonal.
|
||||
bool toAxisAngle(Vector3f& rclBase, Vector3f& rclDir, float& fAngle, float& fTranslation) const;
|
||||
bool
|
||||
toAxisAngle(Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
|
||||
bool toAxisAngle(Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
|
||||
/// transform (move,scale,rotate) around a point
|
||||
void transform(const Vector3f& vec, const Matrix4D& mat);
|
||||
void transform(const Vector3d& vec, const Matrix4D& mat);
|
||||
|
||||
@@ -286,10 +286,12 @@ PyObject* MatrixPy::move(PyObject* args)
|
||||
}
|
||||
// clears the error from previous PyArg_ParseTuple()
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args,
|
||||
"O!;three floats, or a tuple, or a vector is needed",
|
||||
&(VectorPy::Type),
|
||||
&pcVecObj)) {
|
||||
if (PyArg_ParseTuple(
|
||||
args,
|
||||
"O!;three floats, or a tuple, or a vector is needed",
|
||||
&(VectorPy::Type),
|
||||
&pcVecObj
|
||||
)) {
|
||||
VectorPy* pcObject = static_cast<VectorPy*>(pcVecObj);
|
||||
Vector3d* val = pcObject->getVectorPtr();
|
||||
vec.Set(val->x, val->y, val->z);
|
||||
@@ -335,10 +337,12 @@ PyObject* MatrixPy::scale(PyObject* args)
|
||||
}
|
||||
// clears the error from previous PyArg_ParseTuple()
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args,
|
||||
"O!;one or three floats, or a tuple, or a vector is needed",
|
||||
&(VectorPy::Type),
|
||||
&pcVecObj)) {
|
||||
if (PyArg_ParseTuple(
|
||||
args,
|
||||
"O!;one or three floats, or a tuple, or a vector is needed",
|
||||
&(VectorPy::Type),
|
||||
&pcVecObj
|
||||
)) {
|
||||
VectorPy* pcObject = static_cast<VectorPy*>(pcVecObj);
|
||||
Vector3d* val = pcObject->getVectorPtr();
|
||||
vec.Set(val->x, val->y, val->z);
|
||||
@@ -365,7 +369,8 @@ PyObject* MatrixPy::hasScale(PyObject* args) const
|
||||
ScaleType type = getMatrixPtr()->hasScale(tol);
|
||||
Py::Module mod("FreeCAD");
|
||||
return Py::new_reference_to(
|
||||
mod.callMemberFunction("ScaleType", Py::TupleN(Py::Long(static_cast<int>(type)))));
|
||||
mod.callMemberFunction("ScaleType", Py::TupleN(Py::Long(static_cast<int>(type))))
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* MatrixPy::decompose(PyObject* args) const
|
||||
@@ -440,7 +445,8 @@ PyObject* MatrixPy::transform(PyObject* args)
|
||||
&(VectorPy::Type),
|
||||
&pcVecObj,
|
||||
&(MatrixPy::Type),
|
||||
&pcMatObj)) {
|
||||
&pcMatObj
|
||||
)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,8 +124,10 @@ public:
|
||||
virtual ~Subject()
|
||||
{
|
||||
if (_ObserverSet.size() > 0) {
|
||||
Base::Console().developerWarning(std::string("~Subject()"),
|
||||
"Not detached all observers yet\n");
|
||||
Base::Console().developerWarning(
|
||||
std::string("~Subject()"),
|
||||
"Not detached all observers yet\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +143,11 @@ public:
|
||||
size_t count = _ObserverSet.size();
|
||||
_ObserverSet.insert(ToObserv);
|
||||
if (_ObserverSet.size() == count) {
|
||||
Base::Console().developerWarning(std::string("Subject::Attach"),
|
||||
"Observer %p already attached\n",
|
||||
static_cast<void*>(ToObserv));
|
||||
Base::Console().developerWarning(
|
||||
std::string("Subject::Attach"),
|
||||
"Observer %p already attached\n",
|
||||
static_cast<void*>(ToObserv)
|
||||
);
|
||||
}
|
||||
#else
|
||||
_ObserverSet.insert(ToObserv);
|
||||
@@ -162,9 +166,11 @@ public:
|
||||
size_t count = _ObserverSet.size();
|
||||
_ObserverSet.erase(ToObserv);
|
||||
if (_ObserverSet.size() == count) {
|
||||
Base::Console().developerWarning(std::string("Subject::Detach"),
|
||||
"Observer %p already detached\n",
|
||||
static_cast<void*>(ToObserv));
|
||||
Base::Console().developerWarning(
|
||||
std::string("Subject::Detach"),
|
||||
"Observer %p already detached\n",
|
||||
static_cast<void*>(ToObserv)
|
||||
);
|
||||
}
|
||||
#else
|
||||
_ObserverSet.erase(ToObserv);
|
||||
@@ -186,18 +192,23 @@ public:
|
||||
(*Iter)->OnChange(*this, rcReason); // send OnChange-signal
|
||||
}
|
||||
catch (Base::Exception& e) {
|
||||
Base::Console().error("Unhandled Base::Exception caught when notifying observer.\n"
|
||||
"The error message is: %s\n",
|
||||
e.what());
|
||||
Base::Console().error(
|
||||
"Unhandled Base::Exception caught when notifying observer.\n"
|
||||
"The error message is: %s\n",
|
||||
e.what()
|
||||
);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
Base::Console().error("Unhandled std::exception caught when notifying observer\n"
|
||||
"The error message is: %s\n",
|
||||
e.what());
|
||||
Base::Console().error(
|
||||
"Unhandled std::exception caught when notifying observer\n"
|
||||
"The error message is: %s\n",
|
||||
e.what()
|
||||
);
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().error(
|
||||
"Unhandled unknown exception caught in when notifying observer.\n");
|
||||
"Unhandled unknown exception caught in when notifying observer.\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,9 +250,9 @@ private:
|
||||
|
||||
// Workaround for MSVC
|
||||
#if defined(FreeCADBase_EXPORTS) && defined(_MSC_VER)
|
||||
#define Base_EXPORT
|
||||
# define Base_EXPORT
|
||||
#else
|
||||
#define Base_EXPORT BaseExport
|
||||
# define Base_EXPORT BaseExport
|
||||
#endif
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_LINUX
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@@ -62,7 +62,7 @@
|
||||
FC_LOG_LEVEL_INIT("Parameter", true, true)
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
using namespace XERCES_CPP_NAMESPACE;
|
||||
#else
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
@@ -176,9 +176,11 @@ inline bool DOMTreeErrorReporter::getSawErrors() const
|
||||
|
||||
/** Default construction
|
||||
*/
|
||||
ParameterGrp::ParameterGrp(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* GroupNode,
|
||||
const char* sName,
|
||||
ParameterGrp* Parent)
|
||||
ParameterGrp::ParameterGrp(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* GroupNode,
|
||||
const char* sName,
|
||||
ParameterGrp* Parent
|
||||
)
|
||||
: _pGroupNode(GroupNode)
|
||||
, _Parent(Parent)
|
||||
{
|
||||
@@ -358,19 +360,21 @@ void ParameterGrp::revert(const Base::Reference<ParameterGrp>& Grp)
|
||||
}
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
ParameterGrp::CreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name)
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* ParameterGrp::CreateElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name
|
||||
)
|
||||
{
|
||||
if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm())
|
||||
!= 0
|
||||
if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm()) != 0
|
||||
&& XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParameters").unicodeForm())
|
||||
!= 0) {
|
||||
Base::Console().warning("CreateElement: %s cannot have the element %s of type %s\n",
|
||||
StrX(Start->getNodeName()).c_str(),
|
||||
Name,
|
||||
Type);
|
||||
Base::Console().warning(
|
||||
"CreateElement: %s cannot have the element %s of type %s\n",
|
||||
StrX(Start->getNodeName()).c_str(),
|
||||
Name,
|
||||
Type
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -610,10 +614,12 @@ void ParameterGrp::RemoveAttribute(ParamType Type, const char* Name)
|
||||
}
|
||||
}
|
||||
|
||||
const char* ParameterGrp::GetAttribute(ParamType Type,
|
||||
const char* Name,
|
||||
std::string& Value,
|
||||
const char* Default) const
|
||||
const char* ParameterGrp::GetAttribute(
|
||||
ParamType Type,
|
||||
const char* Name,
|
||||
std::string& Value,
|
||||
const char* Default
|
||||
) const
|
||||
{
|
||||
if (!_pGroupNode) {
|
||||
return Default;
|
||||
@@ -638,8 +644,10 @@ const char* ParameterGrp::GetAttribute(ParamType Type,
|
||||
return Value.c_str();
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
ParameterGrp::GetAttributeMap(ParamType Type, const char* sFilter) const
|
||||
std::vector<std::pair<std::string, std::string>> ParameterGrp::GetAttributeMap(
|
||||
ParamType Type,
|
||||
const char* sFilter
|
||||
) const
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> res;
|
||||
if (!_pGroupNode) {
|
||||
@@ -655,10 +663,12 @@ ParameterGrp::GetAttributeMap(ParamType Type, const char* sFilter) const
|
||||
|
||||
DOMElement* pcTemp = FindElement(_pGroupNode, T);
|
||||
while (pcTemp) {
|
||||
Name = StrX(static_cast<DOMElement*>(pcTemp)
|
||||
->getAttributes()
|
||||
->getNamedItem(XStrLiteral("Name").unicodeForm())
|
||||
->getNodeValue())
|
||||
Name = StrX(
|
||||
static_cast<DOMElement*>(pcTemp)
|
||||
->getAttributes()
|
||||
->getNamedItem(XStrLiteral("Name").unicodeForm())
|
||||
->getNodeValue()
|
||||
)
|
||||
.c_str();
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
@@ -666,10 +676,11 @@ ParameterGrp::GetAttributeMap(ParamType Type, const char* sFilter) const
|
||||
res.emplace_back(Name, std::string());
|
||||
}
|
||||
else {
|
||||
res.emplace_back(Name,
|
||||
StrX(static_cast<DOMElement*>(pcTemp)->getAttribute(
|
||||
XStrLiteral("Value").unicodeForm()))
|
||||
.c_str());
|
||||
res.emplace_back(
|
||||
Name,
|
||||
StrX(static_cast<DOMElement*>(pcTemp)->getAttribute(XStrLiteral("Value").unicodeForm()))
|
||||
.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, T);
|
||||
@@ -692,8 +703,7 @@ void ParameterGrp::_SetAttribute(ParamType T, const char* Name, const char* Valu
|
||||
}
|
||||
if (!_pGroupNode) {
|
||||
if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) {
|
||||
FC_WARN("Setting attribute " << Type << ":" << Name << " in an orphan group "
|
||||
<< _cName);
|
||||
FC_WARN("Setting attribute " << Type << ":" << Name << " in an orphan group " << _cName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -734,8 +744,7 @@ bool ParameterGrp::GetBool(const char* Name, bool bPreset) const
|
||||
}
|
||||
|
||||
// if yes check the value and return
|
||||
return (strcmp(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), "1")
|
||||
== 0);
|
||||
return (strcmp(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), "1") == 0);
|
||||
}
|
||||
|
||||
void ParameterGrp::SetBool(const char* Name, bool bValue)
|
||||
@@ -836,7 +845,8 @@ std::vector<long> ParameterGrp::GetInts(const char* sFilter) const
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.push_back(
|
||||
atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()));
|
||||
atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())
|
||||
);
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCInt");
|
||||
}
|
||||
@@ -860,7 +870,8 @@ std::vector<std::pair<std::string, long>> ParameterGrp::GetIntMap(const char* sF
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.emplace_back(
|
||||
Name,
|
||||
(atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())));
|
||||
(atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()))
|
||||
);
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCInt");
|
||||
}
|
||||
@@ -883,9 +894,7 @@ unsigned long ParameterGrp::GetUnsigned(const char* Name, unsigned long lPreset)
|
||||
|
||||
// if yes check the value and return
|
||||
const int base = 10;
|
||||
return strtoul(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
|
||||
nullptr,
|
||||
base);
|
||||
return strtoul(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), nullptr, base);
|
||||
}
|
||||
|
||||
void ParameterGrp::SetUnsigned(const char* Name, unsigned long lValue)
|
||||
@@ -909,10 +918,11 @@ std::vector<unsigned long> ParameterGrp::GetUnsigneds(const char* sFilter) const
|
||||
Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.push_back(
|
||||
strtoul(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
|
||||
nullptr,
|
||||
base));
|
||||
vrValues.push_back(strtoul(
|
||||
StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
|
||||
nullptr,
|
||||
base
|
||||
));
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCUInt");
|
||||
}
|
||||
@@ -920,8 +930,7 @@ std::vector<unsigned long> ParameterGrp::GetUnsigneds(const char* sFilter) const
|
||||
return vrValues;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, unsigned long>>
|
||||
ParameterGrp::GetUnsignedMap(const char* sFilter) const
|
||||
std::vector<std::pair<std::string, unsigned long>> ParameterGrp::GetUnsignedMap(const char* sFilter) const
|
||||
{
|
||||
std::vector<std::pair<std::string, unsigned long>> vrValues;
|
||||
if (!_pGroupNode) {
|
||||
@@ -938,9 +947,12 @@ ParameterGrp::GetUnsignedMap(const char* sFilter) const
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.emplace_back(
|
||||
Name,
|
||||
(strtoul(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
|
||||
nullptr,
|
||||
base)));
|
||||
(strtoul(
|
||||
StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
|
||||
nullptr,
|
||||
base
|
||||
))
|
||||
);
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCUInt");
|
||||
}
|
||||
@@ -986,7 +998,8 @@ std::vector<double> ParameterGrp::GetFloats(const char* sFilter) const
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.push_back(
|
||||
atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()));
|
||||
atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())
|
||||
);
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCFloat");
|
||||
}
|
||||
@@ -1010,7 +1023,8 @@ std::vector<std::pair<std::string, double>> ParameterGrp::GetFloatMap(const char
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
vrValues.emplace_back(
|
||||
Name,
|
||||
(atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())));
|
||||
(atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()))
|
||||
);
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCFloat");
|
||||
}
|
||||
@@ -1112,8 +1126,7 @@ std::vector<std::string> ParameterGrp::GetASCIIs(const char* sFilter) const
|
||||
return vrValues;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
ParameterGrp::GetASCIIMap(const char* sFilter) const
|
||||
std::vector<std::pair<std::string, std::string>> ParameterGrp::GetASCIIMap(const char* sFilter) const
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> vrValues;
|
||||
if (!_pGroupNode) {
|
||||
@@ -1135,7 +1148,8 @@ ParameterGrp::GetASCIIMap(const char* sFilter) const
|
||||
else {
|
||||
vrValues.emplace_back(
|
||||
Name,
|
||||
std::string()); // For a string, an empty value is possible and allowed
|
||||
std::string()
|
||||
); // For a string, an empty value is possible and allowed
|
||||
}
|
||||
}
|
||||
pcTemp = FindNextElement(pcTemp, "FCText");
|
||||
@@ -1270,29 +1284,29 @@ std::vector<Base::Color> ParameterGrp::GetColors(const char* sFilter) const
|
||||
auto packed = GetUnsigneds(sFilter);
|
||||
std::vector<Base::Color> result;
|
||||
|
||||
std::transform(packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const unsigned long lValue) {
|
||||
return Color(static_cast<uint32_t>(lValue));
|
||||
});
|
||||
std::transform(
|
||||
packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const unsigned long lValue) { return Color(static_cast<uint32_t>(lValue)); }
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, Base::Color>>
|
||||
ParameterGrp::GetColorMap(const char* sFilter) const
|
||||
std::vector<std::pair<std::string, Base::Color>> ParameterGrp::GetColorMap(const char* sFilter) const
|
||||
{
|
||||
auto packed = GetUnsignedMap(sFilter);
|
||||
std::vector<std::pair<std::string, Base::Color>> result;
|
||||
|
||||
std::transform(packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const std::pair<std::string, unsigned long>& lValue) {
|
||||
return std::make_pair(lValue.first,
|
||||
Color(static_cast<uint32_t>(lValue.second)));
|
||||
});
|
||||
std::transform(
|
||||
packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const std::pair<std::string, unsigned long>& lValue) {
|
||||
return std::make_pair(lValue.first, Color(static_cast<uint32_t>(lValue.second)));
|
||||
}
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1404,11 +1418,11 @@ void ParameterGrp::Clear(bool notify)
|
||||
next = next->getNextSibling();
|
||||
ParamType type = TypeValue(StrX(child->getNodeName()).c_str());
|
||||
if (type != ParamType::FCInvalid && type != ParamType::FCGroup) {
|
||||
params.emplace_back(type,
|
||||
StrX(child->getAttributes()
|
||||
->getNamedItem(XStrLiteral("Name").unicodeForm())
|
||||
->getNodeValue())
|
||||
.c_str());
|
||||
params.emplace_back(
|
||||
type,
|
||||
StrX(child->getAttributes()->getNamedItem(XStrLiteral("Name").unicodeForm())->getNodeValue())
|
||||
.c_str()
|
||||
);
|
||||
}
|
||||
DOMNode* node = _pGroupNode->removeChild(child);
|
||||
node->release();
|
||||
@@ -1439,19 +1453,21 @@ bool ParameterGrp::ShouldRemove() const
|
||||
});
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name) const
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* ParameterGrp::FindElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name
|
||||
) const
|
||||
{
|
||||
if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm())
|
||||
!= 0
|
||||
if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm()) != 0
|
||||
&& XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParameters").unicodeForm())
|
||||
!= 0) {
|
||||
Base::Console().warning("FindElement: %s cannot have the element %s of type %s\n",
|
||||
StrX(Start->getNodeName()).c_str(),
|
||||
Name,
|
||||
Type);
|
||||
Base::Console().warning(
|
||||
"FindElement: %s cannot have the element %s of type %s\n",
|
||||
StrX(Start->getNodeName()).c_str(),
|
||||
Name,
|
||||
Type
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
const XStr xType(Type);
|
||||
@@ -1466,8 +1482,7 @@ ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
if (Name) {
|
||||
DOMNode* attr = attrs->getNamedItem(XStrLiteral("Name").unicodeForm());
|
||||
if (attr
|
||||
&& !XMLString::compareString(xName.unicodeForm(),
|
||||
attr->getNodeValue())) {
|
||||
&& !XMLString::compareString(xName.unicodeForm(), attr->getNodeValue())) {
|
||||
return dynamic_cast<DOMElement*>(clChild);
|
||||
}
|
||||
}
|
||||
@@ -1481,8 +1496,10 @@ ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
ParameterGrp::FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev, const char* Type) const
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* ParameterGrp::FindNextElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev,
|
||||
const char* Type
|
||||
) const
|
||||
{
|
||||
DOMNode* clChild = Prev;
|
||||
if (!clChild) {
|
||||
@@ -1501,10 +1518,11 @@ ParameterGrp::FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev, cons
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
ParameterGrp::FindOrCreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name)
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* ParameterGrp::FindOrCreateElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name
|
||||
)
|
||||
{
|
||||
// first try to find it
|
||||
DOMElement* pcElem = FindElement(Start, Type, Name);
|
||||
@@ -1515,8 +1533,10 @@ ParameterGrp::FindOrCreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Sta
|
||||
return CreateElement(Start, Type, Name);
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode*
|
||||
ParameterGrp::FindAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Node, const char* Name) const
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* ParameterGrp::FindAttribute(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Node,
|
||||
const char* Name
|
||||
) const
|
||||
{
|
||||
DOMNamedNodeMap* attr = Node->getAttributes();
|
||||
if (attr) {
|
||||
@@ -1525,8 +1545,9 @@ ParameterGrp::FindAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Node, const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::pair<ParameterGrp::ParamType, std::string>>
|
||||
ParameterGrp::GetParameterNames(const char* sFilter) const
|
||||
std::vector<std::pair<ParameterGrp::ParamType, std::string>> ParameterGrp::GetParameterNames(
|
||||
const char* sFilter
|
||||
) const
|
||||
{
|
||||
std::vector<std::pair<ParameterGrp::ParamType, std::string>> res;
|
||||
if (!_pGroupNode) {
|
||||
@@ -1900,13 +1921,11 @@ int ParameterManager::LoadDocument(const XERCES_CPP_NAMESPACE_QUALIFIER InputSou
|
||||
parser->parse(inputSource);
|
||||
}
|
||||
catch (const XMLException& e) {
|
||||
std::cerr << "An error occurred during parsing\n Message: " << StrX(e.getMessage())
|
||||
<< "\n";
|
||||
std::cerr << "An error occurred during parsing\n Message: " << StrX(e.getMessage()) << "\n";
|
||||
errorsOccurred = true;
|
||||
}
|
||||
catch (const DOMException& e) {
|
||||
std::cerr << "A DOM error occurred during parsing\n DOMException code: " << e.code
|
||||
<< "\n";
|
||||
std::cerr << "A DOM error occurred during parsing\n DOMException code: " << e.code << "\n";
|
||||
errorsOccurred = true;
|
||||
}
|
||||
catch (...) {
|
||||
@@ -1982,8 +2001,7 @@ void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
XMLCh tempStr[100];
|
||||
XMLString::transcode("LS", tempStr, 99);
|
||||
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
|
||||
DOMLSSerializer* theSerializer =
|
||||
static_cast<DOMImplementationLS*>(impl)->createLSSerializer();
|
||||
DOMLSSerializer* theSerializer = static_cast<DOMImplementationLS*>(impl)->createLSSerializer();
|
||||
// NOLINTEND
|
||||
|
||||
// set user specified end of line sequence and output encoding
|
||||
@@ -2000,7 +2018,8 @@ void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
if (gUseFilter) {
|
||||
myFilter = std::make_unique<DOMPrintFilter>(
|
||||
DOMNodeFilter::SHOW_ELEMENT | DOMNodeFilter::SHOW_ATTRIBUTE
|
||||
| DOMNodeFilter::SHOW_DOCUMENT_TYPE | DOMNodeFilter::SHOW_TEXT);
|
||||
| DOMNodeFilter::SHOW_DOCUMENT_TYPE | DOMNodeFilter::SHOW_TEXT
|
||||
);
|
||||
theSerializer->setFilter(myFilter.get());
|
||||
}
|
||||
|
||||
@@ -2016,8 +2035,7 @@ void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
config->setParameter(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections);
|
||||
}
|
||||
|
||||
if (config->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent,
|
||||
gDiscardDefaultContent)) {
|
||||
if (config->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent)) {
|
||||
config->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent);
|
||||
}
|
||||
|
||||
@@ -2043,13 +2061,15 @@ void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
void ParameterManager::CreateDocument()
|
||||
{
|
||||
// creating a document from screatch
|
||||
DOMImplementation* impl =
|
||||
DOMImplementationRegistry::getDOMImplementation(XStrLiteral("Core").unicodeForm());
|
||||
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(
|
||||
XStrLiteral("Core").unicodeForm()
|
||||
);
|
||||
delete _pDocument;
|
||||
_pDocument =
|
||||
impl->createDocument(nullptr, // root element namespace URI.
|
||||
XStrLiteral("FCParameters").unicodeForm(), // root element name
|
||||
nullptr); // document type object (DTD).
|
||||
_pDocument = impl->createDocument(
|
||||
nullptr, // root element namespace URI.
|
||||
XStrLiteral("FCParameters").unicodeForm(), // root element name
|
||||
nullptr
|
||||
); // document type object (DTD).
|
||||
|
||||
// creating the node for the root group
|
||||
DOMElement* rootElem = _pDocument->getDocumentElement();
|
||||
@@ -2083,9 +2103,11 @@ void ParameterManager::CheckDocument() const
|
||||
// const char* xsdFile = "...";
|
||||
std::string xsdStr(xmlSchemeString); // NOLINT
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
MemBufInputSource xsdFile(reinterpret_cast<const XMLByte*>(xsdStr.c_str()),
|
||||
xsdStr.size(),
|
||||
"Parameter.xsd");
|
||||
MemBufInputSource xsdFile(
|
||||
reinterpret_cast<const XMLByte*>(xsdStr.c_str()),
|
||||
xsdStr.size(),
|
||||
"Parameter.xsd"
|
||||
);
|
||||
|
||||
// See
|
||||
// http://apache-xml-project.6118.n7.nabble.com/validating-xml-with-xsd-schema-td17515.html
|
||||
@@ -2111,8 +2133,10 @@ void ParameterManager::CheckDocument() const
|
||||
parser.parse(xmlFile);
|
||||
|
||||
if (parser.getErrorCount() > 0) {
|
||||
Base::Console().error("Unexpected XML structure detected: %zu errors\n",
|
||||
parser.getErrorCount());
|
||||
Base::Console().error(
|
||||
"Unexpected XML structure detected: %zu errors\n",
|
||||
parser.getErrorCount()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (XMLException& e) {
|
||||
|
||||
@@ -40,13 +40,13 @@ using PyObject = struct _object;
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_MACOSX
|
||||
#undef toupper
|
||||
#undef tolower
|
||||
#undef isupper
|
||||
#undef islower
|
||||
#undef isspace
|
||||
#undef isalpha
|
||||
#undef isalnum
|
||||
# undef toupper
|
||||
# undef tolower
|
||||
# undef isupper
|
||||
# undef islower
|
||||
# undef isspace
|
||||
# undef isalpha
|
||||
# undef isalnum
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
@@ -59,15 +59,15 @@ using PyObject = struct _object;
|
||||
#include "Color.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4251)
|
||||
#pragma warning(disable : 4503)
|
||||
#pragma warning(disable : 4786) // specifier longer then 255 chars
|
||||
#pragma warning(disable : 4290) // not implemented throw specification
|
||||
#pragma warning(disable : 4275)
|
||||
# pragma warning(disable : 4251)
|
||||
# pragma warning(disable : 4503)
|
||||
# pragma warning(disable : 4786) // specifier longer then 255 chars
|
||||
# pragma warning(disable : 4290) // not implemented throw specification
|
||||
# pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
namespace XERCES_CPP_NAMESPACE
|
||||
{
|
||||
class DOMNode;
|
||||
@@ -280,8 +280,7 @@ public:
|
||||
* @param[out] Value The value of attribute or the fallback value.
|
||||
* @param[in] Default The fallback value.
|
||||
*/
|
||||
const char*
|
||||
GetAttribute(ParamType Type, const char* Name, std::string& Value, const char* Default) const;
|
||||
const char* GetAttribute(ParamType Type, const char* Name, std::string& Value, const char* Default) const;
|
||||
|
||||
/**
|
||||
* Returns all attributes with the given type.
|
||||
@@ -293,8 +292,10 @@ public:
|
||||
* @param[in] sFilter String that has to be present in the names of the attributes.
|
||||
* @returns Vector of attribute name & value pairs.
|
||||
*/
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
GetAttributeMap(ParamType Type, const char* sFilter = nullptr) const;
|
||||
std::vector<std::pair<std::string, std::string>> GetAttributeMap(
|
||||
ParamType Type,
|
||||
const char* sFilter = nullptr
|
||||
) const;
|
||||
|
||||
|
||||
/**
|
||||
@@ -306,8 +307,9 @@ public:
|
||||
* @param[in] sFilter String that has to be present in the names of the attributes.
|
||||
* @returns Vector of attribute type & name pairs.
|
||||
*/
|
||||
std::vector<std::pair<ParamType, std::string>>
|
||||
GetParameterNames(const char* sFilter = nullptr) const;
|
||||
std::vector<std::pair<ParamType, std::string>> GetParameterNames(
|
||||
const char* sFilter = nullptr
|
||||
) const;
|
||||
|
||||
//@}
|
||||
|
||||
@@ -348,8 +350,9 @@ public:
|
||||
/// get a vector of all uint values in this group
|
||||
std::vector<unsigned long> GetUnsigneds(const char* sFilter = nullptr) const;
|
||||
/// get a map with all uint values and the keys of this group
|
||||
std::vector<std::pair<std::string, unsigned long>>
|
||||
GetUnsignedMap(const char* sFilter = nullptr) const;
|
||||
std::vector<std::pair<std::string, unsigned long>> GetUnsignedMap(
|
||||
const char* sFilter = nullptr
|
||||
) const;
|
||||
/// remove a uint value from this group
|
||||
void RemoveUnsigned(const char* Name);
|
||||
//@}
|
||||
@@ -363,8 +366,7 @@ public:
|
||||
/// get a vector of all color values in this group
|
||||
std::vector<Base::Color> GetColors(const char* sFilter = nullptr) const;
|
||||
/// get a map with all color values and the keys of this group
|
||||
std::vector<std::pair<std::string, Base::Color>>
|
||||
GetColorMap(const char* sFilter = nullptr) const;
|
||||
std::vector<std::pair<std::string, Base::Color>> GetColorMap(const char* sFilter = nullptr) const;
|
||||
/// remove a color value from this group
|
||||
void RemoveColor(const char* Name);
|
||||
//@}
|
||||
@@ -405,8 +407,7 @@ public:
|
||||
*/
|
||||
std::vector<std::string> GetASCIIs(const char* sFilter = nullptr) const;
|
||||
/// Same as GetASCIIs() but with key,value map
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
GetASCIIMap(const char* sFilter = nullptr) const;
|
||||
std::vector<std::pair<std::string, std::string>> GetASCIIMap(const char* sFilter = nullptr) const;
|
||||
//@}
|
||||
|
||||
friend class ParameterManager;
|
||||
@@ -436,9 +437,11 @@ public:
|
||||
|
||||
protected:
|
||||
/// constructor is protected (handle concept)
|
||||
ParameterGrp(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* GroupNode = nullptr,
|
||||
const char* sName = nullptr,
|
||||
ParameterGrp* Parent = nullptr);
|
||||
ParameterGrp(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* GroupNode = nullptr,
|
||||
const char* sName = nullptr,
|
||||
ParameterGrp* Parent = nullptr
|
||||
);
|
||||
/// destructor is protected (handle concept)
|
||||
~ParameterGrp() override;
|
||||
/// helper function for GetGroup
|
||||
@@ -450,8 +453,10 @@ protected:
|
||||
void _SetAttribute(ParamType Type, const char* Name, const char* Value);
|
||||
void _Notify(ParamType Type, const char* Name, const char* Value);
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev, const char* Type) const;
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* FindNextElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev,
|
||||
const char* Type
|
||||
) const;
|
||||
|
||||
/** Find an element specified by Type and Name
|
||||
* Search in the parent element Start for the first occurrence of an
|
||||
@@ -459,30 +464,35 @@ protected:
|
||||
* the pointer to that element, otherwise NULL
|
||||
* If the names not given it returns the first occurrence of Type.
|
||||
*/
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name = nullptr) const;
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* FindElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name = nullptr
|
||||
) const;
|
||||
|
||||
/** Find an element specified by Type and Name or create it if not found
|
||||
* Search in the parent element Start for the first occurrence of an
|
||||
* element of Type and with the attribute Name=Name. On success it returns
|
||||
* the pointer to that element, otherwise it creates the element and returns the pointer.
|
||||
*/
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
FindOrCreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* FindOrCreateElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name
|
||||
);
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*
|
||||
CreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* CreateElement(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
|
||||
const char* Type,
|
||||
const char* Name
|
||||
);
|
||||
|
||||
/** Find an attribute specified by Name
|
||||
*/
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode*
|
||||
FindAttribute(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Node, const char* Name) const;
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* FindAttribute(
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Node,
|
||||
const char* Name
|
||||
) const;
|
||||
|
||||
/// DOM Node of the Base node of this group
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* _pGroupNode;
|
||||
@@ -566,10 +576,8 @@ public:
|
||||
* - Group removal: both 'name' and 'value' are empty
|
||||
* - Group rename: 'name' is the new name, and 'value' is the old name
|
||||
*/
|
||||
boost::signals2::signal<void(ParameterGrp* /*param*/,
|
||||
ParamType /*type*/,
|
||||
const char* /*name*/,
|
||||
const char* /*value*/)>
|
||||
boost::signals2::signal<
|
||||
void(ParameterGrp* /*param*/, ParamType /*type*/, const char* /*name*/, const char* /*value*/)>
|
||||
signalParamChanged;
|
||||
|
||||
int LoadDocument(const char* sFileName);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <xercesc/sax/SAXParseException.hpp>
|
||||
# include <xercesc/sax/SAXParseException.hpp>
|
||||
#endif
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <utility>
|
||||
|
||||
#ifdef FC_OS_LINUX
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "Parameter.h"
|
||||
@@ -166,11 +166,13 @@ public:
|
||||
// NOLINTEND
|
||||
|
||||
private:
|
||||
void tryCall(ParameterGrpObserver* obs,
|
||||
ParameterGrp* Param,
|
||||
ParameterGrp::ParamType Type,
|
||||
const char* Name,
|
||||
const char* Value);
|
||||
void tryCall(
|
||||
ParameterGrpObserver* obs,
|
||||
ParameterGrp* Param,
|
||||
ParameterGrp::ParamType Type,
|
||||
const char* Name,
|
||||
const char* Value
|
||||
);
|
||||
|
||||
private:
|
||||
ParameterGrp::handle _cParamGrp;
|
||||
@@ -223,7 +225,8 @@ void ParameterGrpPy::init_type()
|
||||
"For 'FCParamGroup' type, the observer will be notified in the following events.\n"
|
||||
"* Group creation: both 'name' and 'value' contain the name of the new group\n"
|
||||
"* Group removal: both 'name' and 'value' are empty\n"
|
||||
"* Group rename: 'name' is the new name, and 'value' is the old name");
|
||||
"* Group rename: 'name' is the new name, and 'value' is the old name"
|
||||
);
|
||||
add_varargs_method("Detach", &ParameterGrpPy::detach, "Detach()");
|
||||
add_varargs_method("Notify", &ParameterGrpPy::notify, "Notify()");
|
||||
add_varargs_method("NotifyAll", &ParameterGrpPy::notifyAll, "NotifyAll()");
|
||||
@@ -760,17 +763,21 @@ Py::Object ParameterGrpPy::attach(const Py::Tuple& args)
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
void ParameterGrpPy::tryCall(ParameterGrpObserver* obs,
|
||||
ParameterGrp* Param,
|
||||
ParameterGrp::ParamType Type,
|
||||
const char* Name,
|
||||
const char* Value)
|
||||
void ParameterGrpPy::tryCall(
|
||||
ParameterGrpObserver* obs,
|
||||
ParameterGrp* Param,
|
||||
ParameterGrp::ParamType Type,
|
||||
const char* Name,
|
||||
const char* Value
|
||||
)
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
Py::TupleN args(Py::asObject(new ParameterGrpPy(Param)),
|
||||
Py::String(ParameterGrp::TypeName(Type)),
|
||||
Py::String(Name ? Name : ""),
|
||||
Py::String(Value ? Value : ""));
|
||||
Py::TupleN args(
|
||||
Py::asObject(new ParameterGrpPy(Param)),
|
||||
Py::String(ParameterGrp::TypeName(Type)),
|
||||
Py::String(Name ? Name : ""),
|
||||
Py::String(Value ? Value : "")
|
||||
);
|
||||
try {
|
||||
Py::Callable(obs->callable).apply(args);
|
||||
}
|
||||
@@ -809,20 +816,20 @@ Py::Object ParameterGrpPy::attachManager(const Py::Tuple& args)
|
||||
|
||||
auto obs = new ParameterGrpObserver(o, attr, _cParamGrp);
|
||||
ParameterManager* man = _cParamGrp->Manager();
|
||||
obs->conn = man->signalParamChanged.connect([obs, this](ParameterGrp* Param,
|
||||
ParameterGrp::ParamType Type,
|
||||
const char* Name,
|
||||
const char* Value) {
|
||||
if (!Param) {
|
||||
return;
|
||||
}
|
||||
for (auto p = Param; p; p = p->Parent()) {
|
||||
if (p == obs->_target) {
|
||||
tryCall(obs, Param, Type, Name, Value);
|
||||
break;
|
||||
obs->conn = man->signalParamChanged.connect(
|
||||
[obs,
|
||||
this](ParameterGrp* Param, ParameterGrp::ParamType Type, const char* Name, const char* Value) {
|
||||
if (!Param) {
|
||||
return;
|
||||
}
|
||||
for (auto p = Param; p; p = p->Parent()) {
|
||||
if (p == obs->_target) {
|
||||
tryCall(obs, Param, Type, Name, Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
_observers.push_back(obs);
|
||||
return Py::None();
|
||||
|
||||
@@ -66,14 +66,17 @@ PyObject* PersistencePy::dumpContent(PyObject* args, PyObject* kwds) const
|
||||
}
|
||||
|
||||
// setup the stream. the in flag is needed to make "read" work
|
||||
std::stringstream stream(std::stringstream::out | std::stringstream::in
|
||||
| std::stringstream::binary);
|
||||
std::stringstream stream(
|
||||
std::stringstream::out | std::stringstream::in | std::stringstream::binary
|
||||
);
|
||||
try {
|
||||
getPersistencePtr()->dumpToStream(stream, compression);
|
||||
}
|
||||
catch (NotImplementedError&) {
|
||||
PyErr_SetString(PyExc_NotImplementedError,
|
||||
"Dumping content of this object type is not implemented");
|
||||
PyErr_SetString(
|
||||
PyExc_NotImplementedError,
|
||||
"Dumping content of this object type is not implemented"
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
catch (...) {
|
||||
|
||||
@@ -109,8 +109,7 @@ public:
|
||||
//@}
|
||||
|
||||
static Placement slerp(const Placement& p0, const Placement& p1, double t);
|
||||
static Placement
|
||||
sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
|
||||
static Placement sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
|
||||
|
||||
/// Returns string representation of the placement, useful for debugging
|
||||
std::string toString() const;
|
||||
|
||||
@@ -139,8 +139,7 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyObject* PlacementPy::richCompare(PyObject* v, PyObject* w, int op)
|
||||
{
|
||||
if (PyObject_TypeCheck(v, &(PlacementPy::Type))
|
||||
&& PyObject_TypeCheck(w, &(PlacementPy::Type))) {
|
||||
if (PyObject_TypeCheck(v, &(PlacementPy::Type)) && PyObject_TypeCheck(w, &(PlacementPy::Type))) {
|
||||
Placement p1 = *static_cast<PlacementPy*>(v)->getPlacementPtr();
|
||||
Placement p2 = *static_cast<PlacementPy*>(w)->getPlacementPtr();
|
||||
|
||||
@@ -287,13 +286,7 @@ PyObject* PlacementPy::sclerp(PyObject* args) const
|
||||
PyObject* pyplm2 {};
|
||||
double t {};
|
||||
PyObject* shorten = Py_True;
|
||||
if (!PyArg_ParseTuple(args,
|
||||
"O!d|O!",
|
||||
&(PlacementPy::Type),
|
||||
&pyplm2,
|
||||
&t,
|
||||
&(PyBool_Type),
|
||||
&shorten)) {
|
||||
if (!PyArg_ParseTuple(args, "O!d|O!", &(PlacementPy::Type), &pyplm2, &t, &(PyBool_Type), &shorten)) {
|
||||
return nullptr;
|
||||
}
|
||||
Placement plm2 = static_cast<PlacementPy*>(pyplm2)->value();
|
||||
@@ -362,10 +355,12 @@ void PlacementPy::setRotation(Py::Object arg)
|
||||
Py::Tuple tuple;
|
||||
if (tuple.accepts(arg.ptr())) {
|
||||
tuple = arg;
|
||||
getPlacementPtr()->setRotation(Rotation(static_cast<double>(Py::Float(tuple[0])),
|
||||
static_cast<double>(Py::Float(tuple[1])),
|
||||
static_cast<double>(Py::Float(tuple[2])),
|
||||
static_cast<double>(Py::Float(tuple[3]))));
|
||||
getPlacementPtr()->setRotation(Rotation(
|
||||
static_cast<double>(Py::Float(tuple[0])),
|
||||
static_cast<double>(Py::Float(tuple[1])),
|
||||
static_cast<double>(Py::Float(tuple[2])),
|
||||
static_cast<double>(Py::Float(tuple[3]))
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,17 +44,17 @@
|
||||
#include <locale>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
#include <crtdbg.h>
|
||||
#include <shellapi.h>
|
||||
#include <Rpc.h>
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
# include <crtdbg.h>
|
||||
# include <shellapi.h>
|
||||
# include <Rpc.h>
|
||||
#endif
|
||||
|
||||
#if defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
# include <dirent.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
// STL
|
||||
|
||||
@@ -22,113 +22,113 @@
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
#include <tracy/Tracy.hpp>
|
||||
# include <tracy/Tracy.hpp>
|
||||
#else
|
||||
#define TracyNoop
|
||||
# define TracyNoop
|
||||
|
||||
#define ZoneNamed(x, y)
|
||||
#define ZoneNamedN(x, y, z)
|
||||
#define ZoneNamedC(x, y, z)
|
||||
#define ZoneNamedNC(x, y, z, w)
|
||||
# define ZoneNamed(x, y)
|
||||
# define ZoneNamedN(x, y, z)
|
||||
# define ZoneNamedC(x, y, z)
|
||||
# define ZoneNamedNC(x, y, z, w)
|
||||
|
||||
#define ZoneTransient(x, y)
|
||||
#define ZoneTransientN(x, y, z)
|
||||
# define ZoneTransient(x, y)
|
||||
# define ZoneTransientN(x, y, z)
|
||||
|
||||
#define ZoneScoped
|
||||
#define ZoneScopedN(x)
|
||||
#define ZoneScopedC(x)
|
||||
#define ZoneScopedNC(x, y)
|
||||
# define ZoneScoped
|
||||
# define ZoneScopedN(x)
|
||||
# define ZoneScopedC(x)
|
||||
# define ZoneScopedNC(x, y)
|
||||
|
||||
#define ZoneText(x, y)
|
||||
#define ZoneTextV(x, y, z)
|
||||
#define ZoneTextF(x, ...)
|
||||
#define ZoneTextVF(x, y, ...)
|
||||
#define ZoneName(x, y)
|
||||
#define ZoneNameV(x, y, z)
|
||||
#define ZoneNameF(x, ...)
|
||||
#define ZoneNameVF(x, y, ...)
|
||||
#define ZoneColor(x)
|
||||
#define ZoneColorV(x, y)
|
||||
#define ZoneValue(x)
|
||||
#define ZoneValueV(x, y)
|
||||
#define ZoneIsActive false
|
||||
#define ZoneIsActiveV(x) false
|
||||
# define ZoneText(x, y)
|
||||
# define ZoneTextV(x, y, z)
|
||||
# define ZoneTextF(x, ...)
|
||||
# define ZoneTextVF(x, y, ...)
|
||||
# define ZoneName(x, y)
|
||||
# define ZoneNameV(x, y, z)
|
||||
# define ZoneNameF(x, ...)
|
||||
# define ZoneNameVF(x, y, ...)
|
||||
# define ZoneColor(x)
|
||||
# define ZoneColorV(x, y)
|
||||
# define ZoneValue(x)
|
||||
# define ZoneValueV(x, y)
|
||||
# define ZoneIsActive false
|
||||
# define ZoneIsActiveV(x) false
|
||||
|
||||
#define FrameMark
|
||||
#define FrameMarkNamed(x)
|
||||
#define FrameMarkStart(x)
|
||||
#define FrameMarkEnd(x)
|
||||
# define FrameMark
|
||||
# define FrameMarkNamed(x)
|
||||
# define FrameMarkStart(x)
|
||||
# define FrameMarkEnd(x)
|
||||
|
||||
#define FrameImage(x, y, z, w, a)
|
||||
# define FrameImage(x, y, z, w, a)
|
||||
|
||||
#define TracyLockable(type, varname) type varname
|
||||
#define TracyLockableN(type, varname, desc) type varname
|
||||
#define TracySharedLockable(type, varname) type varname
|
||||
#define TracySharedLockableN(type, varname, desc) type varname
|
||||
#define LockableBase(type) type
|
||||
#define SharedLockableBase(type) type
|
||||
#define LockMark(x) (void)x
|
||||
#define LockableName(x, y, z)
|
||||
# define TracyLockable(type, varname) type varname
|
||||
# define TracyLockableN(type, varname, desc) type varname
|
||||
# define TracySharedLockable(type, varname) type varname
|
||||
# define TracySharedLockableN(type, varname, desc) type varname
|
||||
# define LockableBase(type) type
|
||||
# define SharedLockableBase(type) type
|
||||
# define LockMark(x) (void)x
|
||||
# define LockableName(x, y, z)
|
||||
|
||||
#define TracyPlot(x, y)
|
||||
#define TracyPlotConfig(x, y, z, w, a)
|
||||
# define TracyPlot(x, y)
|
||||
# define TracyPlotConfig(x, y, z, w, a)
|
||||
|
||||
#define TracyMessage(x, y)
|
||||
#define TracyMessageL(x)
|
||||
#define TracyMessageC(x, y, z)
|
||||
#define TracyMessageLC(x, y)
|
||||
#define TracyAppInfo(x, y)
|
||||
# define TracyMessage(x, y)
|
||||
# define TracyMessageL(x)
|
||||
# define TracyMessageC(x, y, z)
|
||||
# define TracyMessageLC(x, y)
|
||||
# define TracyAppInfo(x, y)
|
||||
|
||||
#define TracyAlloc(x, y)
|
||||
#define TracyFree(x)
|
||||
#define TracyMemoryDiscard(x)
|
||||
#define TracySecureAlloc(x, y)
|
||||
#define TracySecureFree(x)
|
||||
#define TracySecureMemoryDiscard(x)
|
||||
# define TracyAlloc(x, y)
|
||||
# define TracyFree(x)
|
||||
# define TracyMemoryDiscard(x)
|
||||
# define TracySecureAlloc(x, y)
|
||||
# define TracySecureFree(x)
|
||||
# define TracySecureMemoryDiscard(x)
|
||||
|
||||
#define TracyAllocN(x, y, z)
|
||||
#define TracyFreeN(x, y)
|
||||
#define TracySecureAllocN(x, y, z)
|
||||
#define TracySecureFreeN(x, y)
|
||||
# define TracyAllocN(x, y, z)
|
||||
# define TracyFreeN(x, y)
|
||||
# define TracySecureAllocN(x, y, z)
|
||||
# define TracySecureFreeN(x, y)
|
||||
|
||||
#define ZoneNamedS(x, y, z)
|
||||
#define ZoneNamedNS(x, y, z, w)
|
||||
#define ZoneNamedCS(x, y, z, w)
|
||||
#define ZoneNamedNCS(x, y, z, w, a)
|
||||
# define ZoneNamedS(x, y, z)
|
||||
# define ZoneNamedNS(x, y, z, w)
|
||||
# define ZoneNamedCS(x, y, z, w)
|
||||
# define ZoneNamedNCS(x, y, z, w, a)
|
||||
|
||||
#define ZoneTransientS(x, y, z)
|
||||
#define ZoneTransientNS(x, y, z, w)
|
||||
# define ZoneTransientS(x, y, z)
|
||||
# define ZoneTransientNS(x, y, z, w)
|
||||
|
||||
#define ZoneScopedS(x)
|
||||
#define ZoneScopedNS(x, y)
|
||||
#define ZoneScopedCS(x, y)
|
||||
#define ZoneScopedNCS(x, y, z)
|
||||
# define ZoneScopedS(x)
|
||||
# define ZoneScopedNS(x, y)
|
||||
# define ZoneScopedCS(x, y)
|
||||
# define ZoneScopedNCS(x, y, z)
|
||||
|
||||
#define TracyAllocS(x, y, z)
|
||||
#define TracyFreeS(x, y)
|
||||
#define TracyMemoryDiscardS(x, y)
|
||||
#define TracySecureAllocS(x, y, z)
|
||||
#define TracySecureFreeS(x, y)
|
||||
#define TracySecureMemoryDiscardS(x, y)
|
||||
# define TracyAllocS(x, y, z)
|
||||
# define TracyFreeS(x, y)
|
||||
# define TracyMemoryDiscardS(x, y)
|
||||
# define TracySecureAllocS(x, y, z)
|
||||
# define TracySecureFreeS(x, y)
|
||||
# define TracySecureMemoryDiscardS(x, y)
|
||||
|
||||
#define TracyAllocNS(x, y, z, w)
|
||||
#define TracyFreeNS(x, y, z)
|
||||
#define TracySecureAllocNS(x, y, z, w)
|
||||
#define TracySecureFreeNS(x, y, z)
|
||||
# define TracyAllocNS(x, y, z, w)
|
||||
# define TracyFreeNS(x, y, z)
|
||||
# define TracySecureAllocNS(x, y, z, w)
|
||||
# define TracySecureFreeNS(x, y, z)
|
||||
|
||||
#define TracyMessageS(x, y, z)
|
||||
#define TracyMessageLS(x, y)
|
||||
#define TracyMessageCS(x, y, z, w)
|
||||
#define TracyMessageLCS(x, y, z)
|
||||
# define TracyMessageS(x, y, z)
|
||||
# define TracyMessageLS(x, y)
|
||||
# define TracyMessageCS(x, y, z, w)
|
||||
# define TracyMessageLCS(x, y, z)
|
||||
|
||||
#define TracySourceCallbackRegister(x, y)
|
||||
#define TracyParameterRegister(x, y)
|
||||
#define TracyParameterSetup(x, y, z, w)
|
||||
#define TracyIsConnected false
|
||||
#define TracyIsStarted false
|
||||
#define TracySetProgramName(x)
|
||||
# define TracySourceCallbackRegister(x, y)
|
||||
# define TracyParameterRegister(x, y)
|
||||
# define TracyParameterSetup(x, y, z, w)
|
||||
# define TracyIsConnected false
|
||||
# define TracyIsStarted false
|
||||
# define TracySetProgramName(x)
|
||||
|
||||
#define TracyFiberEnter(x)
|
||||
#define TracyFiberEnterHint(x, y)
|
||||
#define TracyFiberLeave
|
||||
# define TracyFiberEnter(x)
|
||||
# define TracyFiberEnterHint(x, y)
|
||||
# define TracyFiberLeave
|
||||
#endif
|
||||
|
||||
@@ -87,8 +87,7 @@ public:
|
||||
* @param isForce If true, indicates a forced update even if the change threshold (≈1%) hasn’t
|
||||
* been met.
|
||||
*/
|
||||
virtual void show([[maybe_unused]] float position,
|
||||
[[maybe_unused]] ShowFlags flags = ShowFlags::None)
|
||||
virtual void show([[maybe_unused]] float position, [[maybe_unused]] ShowFlags flags = ShowFlags::None)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -58,8 +58,7 @@ bool ProgressIndicatorPy::check(PyObject* py)
|
||||
return Py::PythonExtension<ProgressIndicatorPy>::check(py);
|
||||
}
|
||||
|
||||
PyObject*
|
||||
ProgressIndicatorPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
|
||||
PyObject* ProgressIndicatorPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
|
||||
{
|
||||
return new ProgressIndicatorPy();
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
|
||||
// (re-)defined in pyconfig.h
|
||||
#if defined(_POSIX_C_SOURCE)
|
||||
#undef _POSIX_C_SOURCE
|
||||
# undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
#if defined(_XOPEN_SOURCE)
|
||||
#undef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
@@ -46,13 +46,13 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef FC_OS_MACOSX
|
||||
#undef toupper
|
||||
#undef tolower
|
||||
#undef isupper
|
||||
#undef islower
|
||||
#undef isspace
|
||||
#undef isalpha
|
||||
#undef isalnum
|
||||
# undef toupper
|
||||
# undef tolower
|
||||
# undef isupper
|
||||
# undef islower
|
||||
# undef isspace
|
||||
# undef isalpha
|
||||
# undef isalnum
|
||||
#endif
|
||||
|
||||
namespace Base
|
||||
|
||||
@@ -36,11 +36,13 @@ namespace Base
|
||||
/// terminated by a nullptr (required by CPython) \arg (variadic) Pointers to the storage locations
|
||||
/// for the parameters \returns boolean true on success, or false on failure
|
||||
template<size_t arraySize>
|
||||
bool Wrapped_ParseTupleAndKeywords(PyObject* args,
|
||||
PyObject* kw,
|
||||
const char* format,
|
||||
const std::array<const char*, arraySize> keywords,
|
||||
...)
|
||||
bool Wrapped_ParseTupleAndKeywords(
|
||||
PyObject* args,
|
||||
PyObject* kw,
|
||||
const char* format,
|
||||
const std::array<const char*, arraySize> keywords,
|
||||
...
|
||||
)
|
||||
{
|
||||
static_assert(arraySize > 0, "keywords array must have at least a single nullptr in it");
|
||||
if (keywords.back()) {
|
||||
@@ -60,8 +62,8 @@ bool Wrapped_ParseTupleAndKeywords(PyObject* args,
|
||||
va_list va; // NOLINT
|
||||
va_start(va, keywords);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
|
||||
int retval =
|
||||
PyArg_VaParseTupleAndKeywords(args, kw, format, const_cast<char**>(keywords.data()), va);
|
||||
int retval
|
||||
= PyArg_VaParseTupleAndKeywords(args, kw, format, const_cast<char**>(keywords.data()), va);
|
||||
va_end(va);
|
||||
return retval != 0; // Convert to a true C++ boolean
|
||||
}
|
||||
|
||||
@@ -33,17 +33,18 @@ PythonTypeExt::PythonTypeExt(Py::PythonType& type)
|
||||
: pytype(type)
|
||||
{}
|
||||
|
||||
Py::PythonType& PythonTypeExt::set_tp_descr_get(PyObject* (*tp_descr_get)(PyObject* self,
|
||||
PyObject* obj,
|
||||
PyObject* type))
|
||||
Py::PythonType& PythonTypeExt::set_tp_descr_get(
|
||||
PyObject* (*tp_descr_get)(PyObject* self, PyObject* obj, PyObject* type)
|
||||
)
|
||||
{
|
||||
pytype.type_object()->tp_descr_get = tp_descr_get;
|
||||
|
||||
return pytype;
|
||||
}
|
||||
|
||||
Py::PythonType&
|
||||
PythonTypeExt::set_tp_descr_set(int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value))
|
||||
Py::PythonType& PythonTypeExt::set_tp_descr_set(
|
||||
int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value)
|
||||
)
|
||||
{
|
||||
pytype.type_object()->tp_descr_set = tp_descr_set;
|
||||
|
||||
|
||||
@@ -43,10 +43,12 @@ class BaseExport PythonTypeExt
|
||||
public:
|
||||
explicit PythonTypeExt(Py::PythonType& type);
|
||||
|
||||
Py::PythonType&
|
||||
set_tp_descr_get(PyObject* (*tp_descr_get)(PyObject* self, PyObject* obj, PyObject* type));
|
||||
Py::PythonType&
|
||||
set_tp_descr_set(int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value));
|
||||
Py::PythonType& set_tp_descr_get(
|
||||
PyObject* (*tp_descr_get)(PyObject* self, PyObject* obj, PyObject* type)
|
||||
);
|
||||
Py::PythonType& set_tp_descr_set(
|
||||
int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value)
|
||||
);
|
||||
|
||||
private:
|
||||
Py::PythonType& pytype;
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
|
||||
// suppress annoying warnings from generated source files
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4003)
|
||||
#pragma warning(disable : 4018)
|
||||
#pragma warning(disable : 4065)
|
||||
#pragma warning(disable : 4273)
|
||||
#pragma warning(disable : 4335) // disable MAC file format warning on VC
|
||||
# pragma warning(disable : 4003)
|
||||
# pragma warning(disable : 4018)
|
||||
# pragma warning(disable : 4065)
|
||||
# pragma warning(disable : 4273)
|
||||
# pragma warning(disable : 4335) // disable MAC file format warning on VC
|
||||
#endif
|
||||
|
||||
using Base::Quantity;
|
||||
@@ -130,7 +130,8 @@ bool Quantity::operator<(const Quantity& that) const
|
||||
{
|
||||
if (myUnit != that.myUnit) {
|
||||
throw Base::UnitsMismatchError(
|
||||
"Quantity::operator <(): quantities need to have same unit to compare");
|
||||
"Quantity::operator <(): quantities need to have same unit to compare"
|
||||
);
|
||||
}
|
||||
|
||||
return (myValue < that.myValue);
|
||||
@@ -140,7 +141,8 @@ bool Quantity::operator>(const Quantity& that) const
|
||||
{
|
||||
if (myUnit != that.myUnit) {
|
||||
throw Base::UnitsMismatchError(
|
||||
"Quantity::operator >(): quantities need to have same unit to compare");
|
||||
"Quantity::operator >(): quantities need to have same unit to compare"
|
||||
);
|
||||
}
|
||||
|
||||
return (myValue > that.myValue);
|
||||
@@ -150,7 +152,8 @@ bool Quantity::operator<=(const Quantity& that) const
|
||||
{
|
||||
if (myUnit != that.myUnit) {
|
||||
throw Base::UnitsMismatchError(
|
||||
"Quantity::operator <=(): quantities need to have same unit to compare");
|
||||
"Quantity::operator <=(): quantities need to have same unit to compare"
|
||||
);
|
||||
}
|
||||
|
||||
return (myValue <= that.myValue);
|
||||
@@ -160,7 +163,8 @@ bool Quantity::operator>=(const Quantity& that) const
|
||||
{
|
||||
if (myUnit != that.myUnit) {
|
||||
throw Base::UnitsMismatchError(
|
||||
"Quantity::operator >=(): quantities need to have same unit to compare");
|
||||
"Quantity::operator >=(): quantities need to have same unit to compare"
|
||||
);
|
||||
}
|
||||
|
||||
return (myValue >= that.myValue);
|
||||
@@ -192,8 +196,10 @@ Quantity Quantity::pow(const Quantity& other) const
|
||||
throw Base::UnitsMismatchError("Quantity::pow(): exponent must not have a unit");
|
||||
}
|
||||
|
||||
return Quantity(std::pow(myValue, other.myValue),
|
||||
myUnit.pow(static_cast<signed char>(other.myValue)));
|
||||
return Quantity(
|
||||
std::pow(myValue, other.myValue),
|
||||
myUnit.pow(static_cast<signed char>(other.myValue))
|
||||
);
|
||||
}
|
||||
|
||||
Quantity Quantity::pow(double exp) const
|
||||
@@ -282,8 +288,7 @@ std::string Quantity::getUserString(double& factor, std::string& unitString) con
|
||||
return Base::UnitsApi::schemaTranslate(*this, factor, unitString);
|
||||
}
|
||||
|
||||
std::string
|
||||
Quantity::getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const
|
||||
std::string Quantity::getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const
|
||||
{
|
||||
return schema->translate(*this, factor, unitString);
|
||||
}
|
||||
@@ -512,8 +517,8 @@ double num_change(char* yytext, char dez_delim, char grp_delim)
|
||||
// NOLINTEND
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-noreturn"
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wmissing-noreturn"
|
||||
#endif
|
||||
|
||||
// error func
|
||||
@@ -523,18 +528,18 @@ void Quantity_yyerror(const char* errorinfo)
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wsign-compare"
|
||||
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wsign-compare"
|
||||
# pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
# pragma GCC diagnostic ignored "-Wfree-nonheap-object"
|
||||
#endif
|
||||
|
||||
namespace QuantityParser
|
||||
@@ -553,7 +558,7 @@ int QuantityLexer();
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
// Scanner, defined in Quantity.l
|
||||
// NOLINTNEXTLINE
|
||||
#include "Quantity.lex.c"
|
||||
# include "Quantity.lex.c"
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
class StringBufferCleaner
|
||||
@@ -580,16 +585,15 @@ private:
|
||||
} // namespace QuantityParser
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
Quantity Quantity::parse(const std::string& string)
|
||||
{
|
||||
// parse from buffer
|
||||
QuantityParser::YY_BUFFER_STATE my_string_buffer =
|
||||
QuantityParser::yy_scan_string(string.c_str());
|
||||
QuantityParser::YY_BUFFER_STATE my_string_buffer = QuantityParser::yy_scan_string(string.c_str());
|
||||
QuantityParser::StringBufferCleaner cleaner(my_string_buffer);
|
||||
// set the global return variables
|
||||
QuantResult = Quantity(std::numeric_limits<double>::min());
|
||||
|
||||
@@ -148,11 +148,9 @@ public:
|
||||
myFormat = fmt;
|
||||
}
|
||||
|
||||
std::string
|
||||
toString(const QuantityFormat& format = QuantityFormat(QuantityFormat::Default)) const;
|
||||
std::string toString(const QuantityFormat& format = QuantityFormat(QuantityFormat::Default)) const;
|
||||
|
||||
std::string
|
||||
toNumber(const QuantityFormat& format = QuantityFormat(QuantityFormat::Default)) const;
|
||||
std::string toNumber(const QuantityFormat& format = QuantityFormat(QuantityFormat::Default)) const;
|
||||
|
||||
std::string getUserString() const;
|
||||
/// transfer to user preferred unit/potence
|
||||
|
||||
@@ -229,11 +229,8 @@ PyObject* QuantityPy::getValueAs(PyObject* args) const
|
||||
return Quantity::parse(str);
|
||||
};
|
||||
|
||||
const std::vector<std::function<std::optional<Quantity>()>> funcs = {tryQuantity,
|
||||
tryUnit,
|
||||
tryUnitAndValue,
|
||||
tryUnitPartsAndValue,
|
||||
tryString};
|
||||
const std::vector<std::function<std::optional<Quantity>()>> funcs
|
||||
= {tryQuantity, tryUnit, tryUnitAndValue, tryUnitPartsAndValue, tryString};
|
||||
|
||||
auto tryFuncs = [&]() -> std::optional<Quantity> {
|
||||
for (const auto& func : funcs) {
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
#include "XMLTools.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <zipios++/zipios-config.h>
|
||||
# include <zipios++/zipios-config.h>
|
||||
#endif
|
||||
#include <zipios++/zipinputstream.h>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
using namespace XERCES_CPP_NAMESPACE;
|
||||
#else
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
@@ -168,27 +168,35 @@ T Base::XMLReader::getAttribute(const char* AttrName) const
|
||||
}
|
||||
|
||||
// Explicit template instantiation
|
||||
template BaseExport bool Base::XMLReader::getAttribute<bool>(const char* AttrName,
|
||||
bool defaultValue) const;
|
||||
template BaseExport bool Base::XMLReader::getAttribute<bool>(
|
||||
const char* AttrName,
|
||||
bool defaultValue
|
||||
) const;
|
||||
template BaseExport bool Base::XMLReader::getAttribute<bool>(const char* AttrName) const;
|
||||
template BaseExport const char*
|
||||
Base::XMLReader::getAttribute<const char*>(const char* AttrName, const char* defaultValue) const;
|
||||
template BaseExport const char*
|
||||
Base::XMLReader::getAttribute<const char*>(const char* AttrName) const;
|
||||
template BaseExport double Base::XMLReader::getAttribute<double>(const char* AttrName,
|
||||
double defaultValue) const;
|
||||
template BaseExport const char* Base::XMLReader::getAttribute<const char*>(
|
||||
const char* AttrName,
|
||||
const char* defaultValue
|
||||
) const;
|
||||
template BaseExport const char* Base::XMLReader::getAttribute<const char*>(const char* AttrName) const;
|
||||
template BaseExport double Base::XMLReader::getAttribute<double>(
|
||||
const char* AttrName,
|
||||
double defaultValue
|
||||
) const;
|
||||
template BaseExport double Base::XMLReader::getAttribute<double>(const char* AttrName) const;
|
||||
template BaseExport int Base::XMLReader::getAttribute<int>(const char* AttrName,
|
||||
int defaultValue) const;
|
||||
template BaseExport int Base::XMLReader::getAttribute<int>(const char* AttrName, int defaultValue) const;
|
||||
template BaseExport int Base::XMLReader::getAttribute<int>(const char* AttrName) const;
|
||||
template BaseExport long Base::XMLReader::getAttribute<long>(const char* AttrName,
|
||||
long defaultValue) const;
|
||||
template BaseExport long Base::XMLReader::getAttribute<long>(
|
||||
const char* AttrName,
|
||||
long defaultValue
|
||||
) const;
|
||||
template BaseExport long Base::XMLReader::getAttribute<long>(const char* AttrName) const;
|
||||
template BaseExport unsigned long
|
||||
Base::XMLReader::getAttribute<unsigned long>(const char* AttrName,
|
||||
unsigned long defaultValue) const;
|
||||
template BaseExport unsigned long
|
||||
Base::XMLReader::getAttribute<unsigned long>(const char* AttrName) const;
|
||||
template BaseExport unsigned long Base::XMLReader::getAttribute<unsigned long>(
|
||||
const char* AttrName,
|
||||
unsigned long defaultValue
|
||||
) const;
|
||||
template BaseExport unsigned long Base::XMLReader::getAttribute<unsigned long>(
|
||||
const char* AttrName
|
||||
) const;
|
||||
|
||||
bool Base::XMLReader::hasAttribute(const char* AttrName) const
|
||||
{
|
||||
@@ -341,8 +349,7 @@ std::streamsize Base::XMLReader::read(char_type* s, std::streamsize n)
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
std::streamsize copy_size =
|
||||
static_cast<std::streamsize>(Characters.size()) - CharacterOffset;
|
||||
std::streamsize copy_size = static_cast<std::streamsize>(Characters.size()) - CharacterOffset;
|
||||
if (n < copy_size) {
|
||||
copy_size = n;
|
||||
}
|
||||
@@ -409,7 +416,8 @@ std::istream& Base::XMLReader::beginCharStream(CharStreamFormat format)
|
||||
auto* filteringStream = dynamic_cast<boost::iostreams::filtering_istream*>(CharStream.get());
|
||||
if (format == CharStreamFormat::Base64Encoded) {
|
||||
filteringStream->push(
|
||||
base64_decoder(Base::base64DefaultBufferSize, Base64ErrorHandling::silent));
|
||||
base64_decoder(Base::base64DefaultBufferSize, Base64ErrorHandling::silent)
|
||||
);
|
||||
}
|
||||
filteringStream->push(boost::ref(*this));
|
||||
return *CharStream;
|
||||
@@ -479,8 +487,10 @@ void Base::XMLReader::readFiles(zipios::ZipInputStream& zipstream) const
|
||||
// less data than the file size would allow.
|
||||
// All what we need to do is to notify the user about the
|
||||
// failure.
|
||||
Base::Console().error("Reading failed from embedded file: %s\n",
|
||||
entry->toString().c_str());
|
||||
Base::Console().error(
|
||||
"Reading failed from embedded file: %s\n",
|
||||
entry->toString().c_str()
|
||||
);
|
||||
FailedFiles.push_back(jt->FileName);
|
||||
}
|
||||
// Go to the next registered file name
|
||||
@@ -560,10 +570,12 @@ void Base::XMLReader::endDocument()
|
||||
ReadType = EndDocument;
|
||||
}
|
||||
|
||||
void Base::XMLReader::startElement(const XMLCh* const /*uri*/,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const /*qname*/,
|
||||
const XERCES_CPP_NAMESPACE_QUALIFIER Attributes& attrs)
|
||||
void Base::XMLReader::startElement(
|
||||
const XMLCh* const /*uri*/,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const /*qname*/,
|
||||
const XERCES_CPP_NAMESPACE_QUALIFIER Attributes& attrs
|
||||
)
|
||||
{
|
||||
Level++; // new scope
|
||||
LocalName = StrX(localname).c_str();
|
||||
@@ -577,9 +589,7 @@ void Base::XMLReader::startElement(const XMLCh* const /*uri*/,
|
||||
ReadType = StartElement;
|
||||
}
|
||||
|
||||
void Base::XMLReader::endElement(const XMLCh* const /*uri*/,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const /*qname*/)
|
||||
void Base::XMLReader::endElement(const XMLCh* const /*uri*/, const XMLCh* const localname, const XMLCh* const /*qname*/)
|
||||
{
|
||||
Level--; // end of scope
|
||||
LocalName = StrX(localname).c_str();
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace zipios
|
||||
class ZipInputStream;
|
||||
}
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
namespace XERCES_CPP_NAMESPACE
|
||||
{
|
||||
class Attributes;
|
||||
@@ -133,8 +133,8 @@ class BaseExport XMLReader: public XERCES_CPP_NAMESPACE_QUALIFIER DefaultHandler
|
||||
public:
|
||||
enum ReaderStatus
|
||||
{
|
||||
PartialRestore =
|
||||
0, // This bit indicates that a partial restore took place somewhere in this Document
|
||||
PartialRestore = 0, // This bit indicates that a partial restore took place somewhere in
|
||||
// this Document
|
||||
PartialRestoreInDocumentObject = 1, // This bit is local to the DocumentObject being read
|
||||
// indicating a partial restore therein
|
||||
PartialRestoreInProperty = 2, // Local to the Property
|
||||
@@ -233,9 +233,9 @@ private:
|
||||
// all explicit template instantiations - this is for getting
|
||||
// a compile error, rather than linker error.
|
||||
template<typename T>
|
||||
static constexpr bool instantiated =
|
||||
std::is_same_v<T, bool> || std::is_same_v<T, const char*> || std::is_same_v<T, double>
|
||||
|| std::is_same_v<T, int> || std::is_same_v<T, long> || std::is_same_v<T, unsigned long>;
|
||||
static constexpr bool instantiated = std::is_same_v<T, bool> || std::is_same_v<T, const char*>
|
||||
|| std::is_same_v<T, double> || std::is_same_v<T, int> || std::is_same_v<T, long>
|
||||
|| std::is_same_v<T, unsigned long>;
|
||||
|
||||
public:
|
||||
/// return the named attribute as T (does type checking); if missing return defaultValue.
|
||||
@@ -271,7 +271,8 @@ public:
|
||||
T getAttribute(const char* AttrName, T defaultValue) const
|
||||
{
|
||||
return static_cast<T>(
|
||||
getAttribute<unsigned long>(AttrName, static_cast<unsigned long>(defaultValue)));
|
||||
getAttribute<unsigned long>(AttrName, static_cast<unsigned long>(defaultValue))
|
||||
);
|
||||
}
|
||||
/// Enum classes
|
||||
template<typename T>
|
||||
@@ -327,13 +328,13 @@ protected:
|
||||
//@{
|
||||
void startDocument() override;
|
||||
void endDocument() override;
|
||||
void startElement(const XMLCh* const uri,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const qname,
|
||||
const XERCES_CPP_NAMESPACE_QUALIFIER Attributes& attrs) override;
|
||||
void endElement(const XMLCh* const uri,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const qname) override;
|
||||
void startElement(
|
||||
const XMLCh* const uri,
|
||||
const XMLCh* const localname,
|
||||
const XMLCh* const qname,
|
||||
const XERCES_CPP_NAMESPACE_QUALIFIER Attributes& attrs
|
||||
) override;
|
||||
void endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname) override;
|
||||
void characters(const XMLCh* const chars, const XMLSize_t length) override;
|
||||
void ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length) override;
|
||||
//@}
|
||||
|
||||
@@ -167,8 +167,10 @@ void Rotation::getValue(Matrix4D& matrix) const
|
||||
{
|
||||
// Taken from <http://de.wikipedia.org/wiki/Quaternionen>
|
||||
//
|
||||
const double l = sqrt(this->quat[0] * this->quat[0] + this->quat[1] * this->quat[1]
|
||||
+ this->quat[2] * this->quat[2] + this->quat[3] * this->quat[3]);
|
||||
const double l = sqrt(
|
||||
this->quat[0] * this->quat[0] + this->quat[1] * this->quat[1]
|
||||
+ this->quat[2] * this->quat[2] + this->quat[3] * this->quat[3]
|
||||
);
|
||||
const double x = this->quat[0] / l;
|
||||
const double y = this->quat[1] / l;
|
||||
const double z = this->quat[2] / l;
|
||||
@@ -311,8 +313,10 @@ void Rotation::setValue(const Vector3d& rotateFrom, const Vector3d& rotateTo)
|
||||
|
||||
void Rotation::normalize()
|
||||
{
|
||||
double len = sqrt(this->quat[0] * this->quat[0] + this->quat[1] * this->quat[1]
|
||||
+ this->quat[2] * this->quat[2] + this->quat[3] * this->quat[3]);
|
||||
double len = sqrt(
|
||||
this->quat[0] * this->quat[0] + this->quat[1] * this->quat[1]
|
||||
+ this->quat[2] * this->quat[2] + this->quat[3] * this->quat[3]
|
||||
);
|
||||
if (len > 0.0) {
|
||||
this->quat[0] /= len;
|
||||
this->quat[1] /= len;
|
||||
@@ -388,10 +392,12 @@ Rotation& Rotation::multRight(const Base::Rotation& q)
|
||||
double w1 {};
|
||||
q.getValue(x1, y1, z1, w1);
|
||||
|
||||
this->setValue(w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
|
||||
w0 * y1 - x0 * z1 + y0 * w1 + z0 * x1,
|
||||
w0 * z1 + x0 * y1 - y0 * x1 + z0 * w1,
|
||||
w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1);
|
||||
this->setValue(
|
||||
w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
|
||||
w0 * y1 - x0 * z1 + y0 * w1 + z0 * x1,
|
||||
w0 * z1 + x0 * y1 - y0 * x1 + z0 * w1,
|
||||
w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1
|
||||
);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -416,10 +422,12 @@ Rotation& Rotation::multLeft(const Base::Rotation& q)
|
||||
double w1 {};
|
||||
this->getValue(x1, y1, z1, w1);
|
||||
|
||||
this->setValue(w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
|
||||
w0 * y1 - x0 * z1 + y0 * w1 + z0 * x1,
|
||||
w0 * z1 + x0 * y1 - y0 * x1 + z0 * w1,
|
||||
w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1);
|
||||
this->setValue(
|
||||
w0 * x1 + x0 * w1 + y0 * z1 - z0 * y1,
|
||||
w0 * y1 - x0 * z1 + y0 * w1 + z0 * x1,
|
||||
w0 * z1 + x0 * y1 - y0 * x1 + z0 * w1,
|
||||
w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1
|
||||
);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -451,12 +459,12 @@ void Rotation::multVec(const Vector3d& src, Vector3d& dst) const
|
||||
double z2 = z * z;
|
||||
double w2 = w * w;
|
||||
|
||||
double dx =
|
||||
(x2 + w2 - y2 - z2) * src.x + 2.0 * (x * y - z * w) * src.y + 2.0 * (x * z + y * w) * src.z;
|
||||
double dy =
|
||||
2.0 * (x * y + z * w) * src.x + (w2 - x2 + y2 - z2) * src.y + 2.0 * (y * z - x * w) * src.z;
|
||||
double dz =
|
||||
2.0 * (x * z - y * w) * src.x + 2.0 * (x * w + y * z) * src.y + (w2 - x2 - y2 + z2) * src.z;
|
||||
double dx = (x2 + w2 - y2 - z2) * src.x + 2.0 * (x * y - z * w) * src.y
|
||||
+ 2.0 * (x * z + y * w) * src.z;
|
||||
double dy = 2.0 * (x * y + z * w) * src.x + (w2 - x2 + y2 - z2) * src.y
|
||||
+ 2.0 * (y * z - x * w) * src.z;
|
||||
double dz = 2.0 * (x * z - y * w) * src.x + 2.0 * (x * w + y * z) * src.y
|
||||
+ (w2 - x2 - y2 + z2) * src.z;
|
||||
dst.x = dx;
|
||||
dst.y = dy;
|
||||
dst.z = dz;
|
||||
@@ -530,8 +538,7 @@ Rotation Rotation::identity()
|
||||
return {0.0, 0.0, 0.0, 1.0};
|
||||
}
|
||||
|
||||
Rotation
|
||||
Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const char* priorityOrder)
|
||||
Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const char* priorityOrder)
|
||||
{
|
||||
const double tol = Precision::Confusion();
|
||||
enum dirIndex
|
||||
@@ -549,9 +556,11 @@ Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
order[i] = priorityOrder[i] - 'X';
|
||||
if (order[i] < 0 || order[i] > 2) {
|
||||
THROWM(ValueError,
|
||||
"makeRotationByAxes: characters in priorityOrder must be uppercase X, Y, or Z. "
|
||||
"Some other character encountered.")
|
||||
THROWM(
|
||||
ValueError,
|
||||
"makeRotationByAxes: characters in priorityOrder must be uppercase X, Y, or Z. "
|
||||
"Some other character encountered."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,10 +714,12 @@ void Rotation::setYawPitchRoll(double y, double p, double r)
|
||||
double c3 = cos(r / 2.0);
|
||||
double s3 = sin(r / 2.0);
|
||||
|
||||
this->setValue(c1 * c2 * s3 - s1 * s2 * c3,
|
||||
c1 * s2 * c3 + s1 * c2 * s3,
|
||||
s1 * c2 * c3 - c1 * s2 * s3,
|
||||
c1 * c2 * c3 + s1 * s2 * s3);
|
||||
this->setValue(
|
||||
c1 * c2 * s3 - s1 * s2 * c3,
|
||||
c1 * s2 * c3 + s1 * c2 * s3,
|
||||
s1 * c2 * c3 - c1 * s2 * s3,
|
||||
c1 * c2 * c3 + s1 * s2 * s3
|
||||
);
|
||||
}
|
||||
|
||||
void Rotation::getYawPitchRoll(double& y, double& p, double& r) const
|
||||
@@ -779,15 +790,17 @@ bool Rotation::isSame(const Rotation& q, double tol) const
|
||||
// Is it safe to assume that?
|
||||
// Because a quaternion (x1,x2,x3,x4) is equal to (-x1,-x2,-x3,-x4) we use the
|
||||
// absolute value of the scalar product
|
||||
double dot =
|
||||
q.quat[0] * quat[0] + q.quat[1] * quat[1] + q.quat[2] * quat[2] + q.quat[3] * quat[3];
|
||||
double dot = q.quat[0] * quat[0] + q.quat[1] * quat[1] + q.quat[2] * quat[2]
|
||||
+ q.quat[3] * quat[3];
|
||||
return fabs(dot) >= 1.0 - tol / 2;
|
||||
}
|
||||
|
||||
bool Rotation::isIdentity() const
|
||||
{
|
||||
return ((this->quat[0] == 0.0 && this->quat[1] == 0.0 && this->quat[2] == 0.0)
|
||||
&& (this->quat[3] == 1.0 || this->quat[3] == -1.0));
|
||||
return (
|
||||
(this->quat[0] == 0.0 && this->quat[1] == 0.0 && this->quat[2] == 0.0)
|
||||
&& (this->quat[3] == 1.0 || this->quat[3] == -1.0)
|
||||
);
|
||||
}
|
||||
|
||||
bool Rotation::isIdentity(double tol) const
|
||||
@@ -797,8 +810,9 @@ bool Rotation::isIdentity(double tol) const
|
||||
|
||||
bool Rotation::isNull() const
|
||||
{
|
||||
return (this->quat[0] == 0.0 && this->quat[1] == 0.0 && this->quat[2] == 0.0
|
||||
&& this->quat[3] == 0.0);
|
||||
return (
|
||||
this->quat[0] == 0.0 && this->quat[1] == 0.0 && this->quat[2] == 0.0 && this->quat[3] == 0.0
|
||||
);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -979,10 +993,7 @@ Rotation::EulerSequence Rotation::eulerSequenceFromName(const char* name)
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
void Rotation::setEulerAngles(EulerSequence theOrder,
|
||||
double theAlpha,
|
||||
double theBeta,
|
||||
double theGamma)
|
||||
void Rotation::setEulerAngles(EulerSequence theOrder, double theAlpha, double theBeta, double theGamma)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
@@ -1045,10 +1056,7 @@ void Rotation::setEulerAngles(EulerSequence theOrder,
|
||||
this->evaluateVector();
|
||||
}
|
||||
|
||||
void Rotation::getEulerAngles(EulerSequence theOrder,
|
||||
double& theAlpha,
|
||||
double& theBeta,
|
||||
double& theGamma) const
|
||||
void Rotation::getEulerAngles(EulerSequence theOrder, double& theAlpha, double& theBeta, double& theGamma) const
|
||||
{
|
||||
Mat M;
|
||||
getValue(M);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "Vector3D.h"
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
namespace Base
|
||||
@@ -99,8 +99,7 @@ public:
|
||||
/// Z base vector is assumed to represent the normal vector
|
||||
static Rotation fromNormalVector(const Vector3d& normal);
|
||||
/// Utility function to create Rotation based on euler angles
|
||||
static Rotation
|
||||
fromEulerAngles(EulerSequence theOrder, double alpha, double beta, double gamma);
|
||||
static Rotation fromEulerAngles(EulerSequence theOrder, double alpha, double beta, double gamma);
|
||||
//@}
|
||||
|
||||
/** Methods to get or set rotations. */
|
||||
@@ -184,10 +183,12 @@ public:
|
||||
*
|
||||
* If only one vector provided is nonzero, the other two directions are picked automatically.
|
||||
*/
|
||||
static Rotation makeRotationByAxes(Vector3d xdir,
|
||||
Vector3d ydir,
|
||||
Vector3d zdir,
|
||||
const char* priorityOrder = "ZXY");
|
||||
static Rotation makeRotationByAxes(
|
||||
Vector3d xdir,
|
||||
Vector3d ydir,
|
||||
Vector3d zdir,
|
||||
const char* priorityOrder = "ZXY"
|
||||
);
|
||||
|
||||
private:
|
||||
void normalize();
|
||||
|
||||
@@ -44,9 +44,8 @@ std::string RotationPy::representation() const
|
||||
Py::Float q3(ptr->getValue()[3]);
|
||||
std::stringstream str;
|
||||
str << "Rotation (";
|
||||
str << static_cast<std::string>(q0.repr()) << ", " << static_cast<std::string>(q1.repr())
|
||||
<< ", " << static_cast<std::string>(q2.repr()) << ", "
|
||||
<< static_cast<std::string>(q3.repr());
|
||||
str << static_cast<std::string>(q0.repr()) << ", " << static_cast<std::string>(q1.repr()) << ", "
|
||||
<< static_cast<std::string>(q2.repr()) << ", " << static_cast<std::string>(q3.repr());
|
||||
str << ")";
|
||||
|
||||
return str.str();
|
||||
|
||||
@@ -130,12 +130,12 @@ public:
|
||||
|
||||
std::list<T*> result(source.size());
|
||||
|
||||
std::transform(source.begin(),
|
||||
source.end(),
|
||||
result.begin(),
|
||||
[](const ServiceDescriptor& descriptor) {
|
||||
return descriptor.get<T>();
|
||||
});
|
||||
std::transform(
|
||||
source.begin(),
|
||||
source.end(),
|
||||
result.begin(),
|
||||
[](const ServiceDescriptor& descriptor) { return descriptor.get<T>(); }
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -232,16 +232,16 @@ typedef DWORD64(__stdcall* PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess,
|
||||
|
||||
// Some missing defines (for VC5/6):
|
||||
#ifndef INVALID_FILE_ATTRIBUTES
|
||||
#define INVALID_FILE_ATTRIBUTES ((DWORD) - 1)
|
||||
# define INVALID_FILE_ATTRIBUTES ((DWORD) - 1)
|
||||
#endif
|
||||
|
||||
// secure-CRT_functions are only available starting with VC8
|
||||
#if _MSC_VER < 1400
|
||||
#define strcpy_s(dst, len, src) strcpy(dst, src)
|
||||
#define strncpy_s(dst, len, src, maxLen) strncpy(dst, len, src)
|
||||
#define strcat_s(dst, len, src) strcat(dst, src)
|
||||
#define _snprintf_s _snprintf
|
||||
#define _tcscat_s _tcscat
|
||||
# define strcpy_s(dst, len, src) strcpy(dst, src)
|
||||
# define strncpy_s(dst, len, src, maxLen) strncpy(dst, len, src)
|
||||
# define strcat_s(dst, len, src) strcat(dst, src)
|
||||
# define _snprintf_s _snprintf
|
||||
# define _tcscat_s _tcscat
|
||||
#endif
|
||||
|
||||
static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc)
|
||||
@@ -478,10 +478,12 @@ public:
|
||||
tSFTA pSFTA;
|
||||
|
||||
// SymGetLineFromAddr64()
|
||||
typedef BOOL(__stdcall* tSGLFA)(IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT PDWORD pdwDisplacement,
|
||||
OUT PIMAGEHLP_LINE64 Line);
|
||||
typedef BOOL(__stdcall* tSGLFA)(
|
||||
IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT PDWORD pdwDisplacement,
|
||||
OUT PIMAGEHLP_LINE64 Line
|
||||
);
|
||||
tSGLFA pSGLFA;
|
||||
|
||||
// SymGetModuleBase64()
|
||||
@@ -489,9 +491,11 @@ public:
|
||||
tSGMB pSGMB;
|
||||
|
||||
// SymGetModuleInfo64()
|
||||
typedef BOOL(__stdcall* tSGMI)(IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT IMAGEHLP_MODULE64_V3* ModuleInfo);
|
||||
typedef BOOL(__stdcall* tSGMI)(
|
||||
IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT IMAGEHLP_MODULE64_V3* ModuleInfo
|
||||
);
|
||||
tSGMI pSGMI;
|
||||
|
||||
// SymGetOptions()
|
||||
@@ -499,25 +503,27 @@ public:
|
||||
tSGO pSGO;
|
||||
|
||||
// SymGetSymFromAddr64()
|
||||
typedef BOOL(__stdcall* tSGSFA)(IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT PDWORD64 pdwDisplacement,
|
||||
OUT PIMAGEHLP_SYMBOL64 Symbol);
|
||||
typedef BOOL(__stdcall* tSGSFA)(
|
||||
IN HANDLE hProcess,
|
||||
IN DWORD64 dwAddr,
|
||||
OUT PDWORD64 pdwDisplacement,
|
||||
OUT PIMAGEHLP_SYMBOL64 Symbol
|
||||
);
|
||||
tSGSFA pSGSFA;
|
||||
|
||||
// SymInitialize()
|
||||
typedef BOOL(__stdcall* tSI)(IN HANDLE hProcess,
|
||||
IN LPCSTR UserSearchPath,
|
||||
IN BOOL fInvadeProcess);
|
||||
typedef BOOL(__stdcall* tSI)(IN HANDLE hProcess, IN LPCSTR UserSearchPath, IN BOOL fInvadeProcess);
|
||||
tSI pSI;
|
||||
|
||||
// SymLoadModule64()
|
||||
typedef DWORD64(__stdcall* tSLM)(IN HANDLE hProcess,
|
||||
IN HANDLE hFile,
|
||||
IN LPCSTR ImageName,
|
||||
IN LPCSTR ModuleName,
|
||||
IN DWORD64 BaseOfDll,
|
||||
IN DWORD SizeOfDll);
|
||||
typedef DWORD64(__stdcall* tSLM)(
|
||||
IN HANDLE hProcess,
|
||||
IN HANDLE hFile,
|
||||
IN LPCSTR ImageName,
|
||||
IN LPCSTR ModuleName,
|
||||
IN DWORD64 BaseOfDll,
|
||||
IN DWORD SizeOfDll
|
||||
);
|
||||
tSLM pSLM;
|
||||
|
||||
// SymSetOptions()
|
||||
@@ -525,22 +531,26 @@ public:
|
||||
tSSO pSSO;
|
||||
|
||||
// StackWalk64()
|
||||
typedef BOOL(__stdcall* tSW)(DWORD MachineType,
|
||||
HANDLE hProcess,
|
||||
HANDLE hThread,
|
||||
LPSTACKFRAME64 StackFrame,
|
||||
PVOID ContextRecord,
|
||||
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
|
||||
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
|
||||
PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
|
||||
PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
|
||||
typedef BOOL(__stdcall* tSW)(
|
||||
DWORD MachineType,
|
||||
HANDLE hProcess,
|
||||
HANDLE hThread,
|
||||
LPSTACKFRAME64 StackFrame,
|
||||
PVOID ContextRecord,
|
||||
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
|
||||
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
|
||||
PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
|
||||
PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
|
||||
);
|
||||
tSW pSW;
|
||||
|
||||
// UnDecorateSymbolName()
|
||||
typedef DWORD(__stdcall WINAPI* tUDSN)(PCSTR DecoratedName,
|
||||
PSTR UnDecoratedName,
|
||||
DWORD UndecoratedLength,
|
||||
DWORD Flags);
|
||||
typedef DWORD(__stdcall WINAPI* tUDSN)(
|
||||
PCSTR DecoratedName,
|
||||
PSTR UnDecoratedName,
|
||||
DWORD UndecoratedLength,
|
||||
DWORD Flags
|
||||
);
|
||||
tUDSN pUDSN;
|
||||
|
||||
typedef BOOL(__stdcall WINAPI* tSGSP)(HANDLE hProcess, PSTR SearchPath, DWORD SearchPathLength);
|
||||
@@ -618,11 +628,7 @@ private:
|
||||
keepGoing = !!pM32F(hSnap, &me);
|
||||
int cnt = 0;
|
||||
while (keepGoing) {
|
||||
this->LoadModule(hProcess,
|
||||
me.szExePath,
|
||||
me.szModule,
|
||||
(DWORD64)me.modBaseAddr,
|
||||
me.modBaseSize);
|
||||
this->LoadModule(hProcess, me.szExePath, me.szModule, (DWORD64)me.modBaseAddr, me.modBaseSize);
|
||||
cnt++;
|
||||
keepGoing = !!pM32N(hSnap, &me);
|
||||
}
|
||||
@@ -645,17 +651,13 @@ private:
|
||||
BOOL GetModuleListPSAPI(HANDLE hProcess)
|
||||
{
|
||||
// EnumProcessModules()
|
||||
typedef BOOL(__stdcall
|
||||
* tEPM)(HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeeded);
|
||||
typedef BOOL(__stdcall * tEPM)(HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeeded);
|
||||
// GetModuleFileNameEx()
|
||||
typedef DWORD(__stdcall
|
||||
* tGMFNE)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
typedef DWORD(__stdcall * tGMFNE)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
// GetModuleBaseName()
|
||||
typedef DWORD(__stdcall
|
||||
* tGMBN)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
typedef DWORD(__stdcall * tGMBN)(HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize);
|
||||
// GetModuleInformation()
|
||||
typedef BOOL(__stdcall
|
||||
* tGMI)(HANDLE hProcess, HMODULE hModule, LPMODULEINFO pmi, DWORD nSize);
|
||||
typedef BOOL(__stdcall * tGMI)(HANDLE hProcess, HMODULE hModule, LPMODULEINFO pmi, DWORD nSize);
|
||||
|
||||
HINSTANCE hPsapi;
|
||||
tEPM pEPM;
|
||||
@@ -716,8 +718,7 @@ private:
|
||||
tt2[0] = 0;
|
||||
pGMBN(hProcess, hMods[i], tt2, TTBUFLEN);
|
||||
|
||||
DWORD dwRes =
|
||||
this->LoadModule(hProcess, tt, tt2, (DWORD64)mi.lpBaseOfDll, mi.SizeOfImage);
|
||||
DWORD dwRes = this->LoadModule(hProcess, tt, tt2, (DWORD64)mi.lpBaseOfDll, mi.SizeOfImage);
|
||||
if (dwRes != ERROR_SUCCESS) {
|
||||
this->m_parent->OnDbgHelpErr("LoadModule", dwRes, 0);
|
||||
}
|
||||
@@ -913,12 +914,14 @@ static PCONTEXT get_current_exception_context()
|
||||
return pctx ? *pctx : NULL;
|
||||
}
|
||||
|
||||
bool StackWalker::Init(ExceptType extype,
|
||||
int options,
|
||||
LPCSTR szSymPath,
|
||||
DWORD dwProcessId,
|
||||
HANDLE hProcess,
|
||||
PEXCEPTION_POINTERS exp)
|
||||
bool StackWalker::Init(
|
||||
ExceptType extype,
|
||||
int options,
|
||||
LPCSTR szSymPath,
|
||||
DWORD dwProcessId,
|
||||
HANDLE hProcess,
|
||||
PEXCEPTION_POINTERS exp
|
||||
)
|
||||
{
|
||||
PCONTEXT ctx = NULL;
|
||||
if (extype == AfterCatch) {
|
||||
@@ -1081,9 +1084,11 @@ BOOL StackWalker::LoadModules()
|
||||
strcat_s(szSymPath, nSymPathLen, "*https://msdl.microsoft.com/download/symbols;");
|
||||
}
|
||||
else {
|
||||
strcat_s(szSymPath,
|
||||
nSymPathLen,
|
||||
"SRV*c:\\websymbols*https://msdl.microsoft.com/download/symbols;");
|
||||
strcat_s(
|
||||
szSymPath,
|
||||
nSymPathLen,
|
||||
"SRV*c:\\websymbols*https://msdl.microsoft.com/download/symbols;"
|
||||
);
|
||||
}
|
||||
}
|
||||
} // if SymBuildPath
|
||||
@@ -1114,10 +1119,12 @@ BOOL StackWalker::LoadModules()
|
||||
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL;
|
||||
static LPVOID s_readMemoryFunction_UserData = NULL;
|
||||
|
||||
BOOL StackWalker::ShowCallstack(HANDLE hThread,
|
||||
const CONTEXT* context,
|
||||
PReadProcessMemoryRoutine readMemoryFunction,
|
||||
LPVOID pUserData)
|
||||
BOOL StackWalker::ShowCallstack(
|
||||
HANDLE hThread,
|
||||
const CONTEXT* context,
|
||||
PReadProcessMemoryRoutine readMemoryFunction,
|
||||
LPVOID pUserData
|
||||
)
|
||||
{
|
||||
CONTEXT c;
|
||||
CallstackEntry csEntry;
|
||||
@@ -1218,7 +1225,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread,
|
||||
s.AddrStack.Offset = c.Sp;
|
||||
s.AddrStack.Mode = AddrModeFlat;
|
||||
#else
|
||||
#error "Platform not supported!"
|
||||
# error "Platform not supported!"
|
||||
#endif
|
||||
|
||||
pSym = (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + STACKWALK_MAX_NAMELEN);
|
||||
@@ -1241,15 +1248,17 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread,
|
||||
// assume that either you are done, or that the stack is so hosed that the next
|
||||
// deeper frame could not be found.
|
||||
// CONTEXT need not to be supplied if imageTyp is IMAGE_FILE_MACHINE_I386!
|
||||
if (!this->m_sw->pSW(imageType,
|
||||
this->m_hProcess,
|
||||
hThread,
|
||||
&s,
|
||||
&c,
|
||||
myReadProcMem,
|
||||
this->m_sw->pSFTA,
|
||||
this->m_sw->pSGMB,
|
||||
NULL)) {
|
||||
if (!this->m_sw->pSW(
|
||||
imageType,
|
||||
this->m_hProcess,
|
||||
hThread,
|
||||
&s,
|
||||
&c,
|
||||
myReadProcMem,
|
||||
this->m_sw->pSFTA,
|
||||
this->m_sw->pSGMB,
|
||||
NULL
|
||||
)) {
|
||||
// INFO: "StackWalk64" does not set "GetLastError"...
|
||||
this->OnDbgHelpErr("StackWalk64", 0, s.AddrPC.Offset);
|
||||
break;
|
||||
@@ -1278,21 +1287,12 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread,
|
||||
if (s.AddrPC.Offset != 0) {
|
||||
// we seem to have a valid PC
|
||||
// show procedure info (SymGetSymFromAddr64())
|
||||
if (this->m_sw->pSGSFA(this->m_hProcess,
|
||||
s.AddrPC.Offset,
|
||||
&(csEntry.offsetFromSmybol),
|
||||
pSym)
|
||||
if (this->m_sw->pSGSFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromSmybol), pSym)
|
||||
!= FALSE) {
|
||||
MyStrCpy(csEntry.name, STACKWALK_MAX_NAMELEN, pSym->Name);
|
||||
// UnDecorateSymbolName()
|
||||
this->m_sw->pUDSN(pSym->Name,
|
||||
csEntry.undName,
|
||||
STACKWALK_MAX_NAMELEN,
|
||||
UNDNAME_NAME_ONLY);
|
||||
this->m_sw->pUDSN(pSym->Name,
|
||||
csEntry.undFullName,
|
||||
STACKWALK_MAX_NAMELEN,
|
||||
UNDNAME_COMPLETE);
|
||||
this->m_sw->pUDSN(pSym->Name, csEntry.undName, STACKWALK_MAX_NAMELEN, UNDNAME_NAME_ONLY);
|
||||
this->m_sw->pUDSN(pSym->Name, csEntry.undFullName, STACKWALK_MAX_NAMELEN, UNDNAME_COMPLETE);
|
||||
}
|
||||
else {
|
||||
this->OnDbgHelpErr("SymGetSymFromAddr64", GetLastError(), s.AddrPC.Offset);
|
||||
@@ -1300,10 +1300,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread,
|
||||
|
||||
// show line number info, NT5.0-method (SymGetLineFromAddr64())
|
||||
if (this->m_sw->pSGLFA != NULL) { // yes, we have SymGetLineFromAddr64()
|
||||
if (this->m_sw->pSGLFA(this->m_hProcess,
|
||||
s.AddrPC.Offset,
|
||||
&(csEntry.offsetFromLine),
|
||||
&Line)
|
||||
if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line)
|
||||
!= FALSE) {
|
||||
csEntry.lineNumber = Line.LineNumber;
|
||||
MyStrCpy(csEntry.lineFileName, STACKWALK_MAX_NAMELEN, Line.FileName);
|
||||
@@ -1432,11 +1429,13 @@ BOOL StackWalker::ShowObject(LPVOID pObject)
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
BOOL __stdcall StackWalker::myReadProcMem(HANDLE hProcess,
|
||||
DWORD64 qwBaseAddress,
|
||||
PVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead)
|
||||
BOOL __stdcall StackWalker::myReadProcMem(
|
||||
HANDLE hProcess,
|
||||
DWORD64 qwBaseAddress,
|
||||
PVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead
|
||||
)
|
||||
{
|
||||
if (s_readMemoryFunction == NULL) {
|
||||
SIZE_T st;
|
||||
@@ -1447,23 +1446,27 @@ BOOL __stdcall StackWalker::myReadProcMem(HANDLE hProcess,
|
||||
return bRet;
|
||||
}
|
||||
else {
|
||||
return s_readMemoryFunction(hProcess,
|
||||
qwBaseAddress,
|
||||
lpBuffer,
|
||||
nSize,
|
||||
lpNumberOfBytesRead,
|
||||
s_readMemoryFunction_UserData);
|
||||
return s_readMemoryFunction(
|
||||
hProcess,
|
||||
qwBaseAddress,
|
||||
lpBuffer,
|
||||
nSize,
|
||||
lpNumberOfBytesRead,
|
||||
s_readMemoryFunction_UserData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void StackWalker::OnLoadModule(LPCSTR img,
|
||||
LPCSTR mod,
|
||||
DWORD64 baseAddr,
|
||||
DWORD size,
|
||||
DWORD result,
|
||||
LPCSTR symType,
|
||||
LPCSTR pdbName,
|
||||
ULONGLONG fileVersion)
|
||||
void StackWalker::OnLoadModule(
|
||||
LPCSTR img,
|
||||
LPCSTR mod,
|
||||
DWORD64 baseAddr,
|
||||
DWORD size,
|
||||
DWORD result,
|
||||
LPCSTR symType,
|
||||
LPCSTR pdbName,
|
||||
ULONGLONG fileVersion
|
||||
)
|
||||
{
|
||||
CHAR buffer[STACKWALK_MAX_NAMELEN];
|
||||
size_t maxLen = STACKWALK_MAX_NAMELEN;
|
||||
@@ -1471,37 +1474,41 @@ void StackWalker::OnLoadModule(LPCSTR img,
|
||||
maxLen = _TRUNCATE;
|
||||
#endif
|
||||
if (fileVersion == 0) {
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"%s:%s (%p), size: %ld (result: %ld), SymType: '%s', PDB: '%s'\n",
|
||||
img,
|
||||
mod,
|
||||
(LPVOID)baseAddr,
|
||||
size,
|
||||
result,
|
||||
symType,
|
||||
pdbName);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"%s:%s (%p), size: %ld (result: %ld), SymType: '%s', PDB: '%s'\n",
|
||||
img,
|
||||
mod,
|
||||
(LPVOID)baseAddr,
|
||||
size,
|
||||
result,
|
||||
symType,
|
||||
pdbName
|
||||
);
|
||||
}
|
||||
else {
|
||||
DWORD v4 = (DWORD)(fileVersion & 0xFFFF);
|
||||
DWORD v3 = (DWORD)((fileVersion >> 16) & 0xFFFF);
|
||||
DWORD v2 = (DWORD)((fileVersion >> 32) & 0xFFFF);
|
||||
DWORD v1 = (DWORD)((fileVersion >> 48) & 0xFFFF);
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"%s:%s (%p), size: %ld (result: %ld), SymType: '%s', PDB: '%s', fileVersion: "
|
||||
"%ld.%ld.%ld.%ld\n",
|
||||
img,
|
||||
mod,
|
||||
(LPVOID)baseAddr,
|
||||
size,
|
||||
result,
|
||||
symType,
|
||||
pdbName,
|
||||
v1,
|
||||
v2,
|
||||
v3,
|
||||
v4);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"%s:%s (%p), size: %ld (result: %ld), SymType: '%s', PDB: '%s', fileVersion: "
|
||||
"%ld.%ld.%ld.%ld\n",
|
||||
img,
|
||||
mod,
|
||||
(LPVOID)baseAddr,
|
||||
size,
|
||||
result,
|
||||
symType,
|
||||
pdbName,
|
||||
v1,
|
||||
v2,
|
||||
v3,
|
||||
v4
|
||||
);
|
||||
}
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0; // be sure it is NULL terminated
|
||||
OnOutput(buffer);
|
||||
@@ -1529,21 +1536,25 @@ void StackWalker::OnCallstackEntry(CallstackEntryType eType, CallstackEntry& ent
|
||||
if (entry.moduleName[0] == 0) {
|
||||
MyStrCpy(entry.moduleName, STACKWALK_MAX_NAMELEN, "(module-name not available)");
|
||||
}
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"%p (%s): %s: %s\n",
|
||||
(LPVOID)entry.offset,
|
||||
entry.moduleName,
|
||||
entry.lineFileName,
|
||||
entry.name);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"%p (%s): %s: %s\n",
|
||||
(LPVOID)entry.offset,
|
||||
entry.moduleName,
|
||||
entry.lineFileName,
|
||||
entry.name
|
||||
);
|
||||
}
|
||||
else {
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"%s (%ld): %s\n",
|
||||
entry.lineFileName,
|
||||
entry.lineNumber,
|
||||
entry.name);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"%s (%ld): %s\n",
|
||||
entry.lineFileName,
|
||||
entry.lineNumber,
|
||||
entry.name
|
||||
);
|
||||
}
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
|
||||
OnOutput(buffer);
|
||||
@@ -1557,12 +1568,14 @@ void StackWalker::OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr)
|
||||
#if _MSC_VER >= 1400
|
||||
maxLen = _TRUNCATE;
|
||||
#endif
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"ERROR: %s, GetLastError: %ld (Address: %p)\n",
|
||||
szFuncName,
|
||||
gle,
|
||||
(LPVOID)addr);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"ERROR: %s, GetLastError: %ld (Address: %p)\n",
|
||||
szFuncName,
|
||||
gle,
|
||||
(LPVOID)addr
|
||||
);
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
|
||||
OnOutput(buffer);
|
||||
}
|
||||
@@ -1574,12 +1587,14 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
|
||||
#if _MSC_VER >= 1400
|
||||
maxLen = _TRUNCATE;
|
||||
#endif
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"SymInit: Symbol-SearchPath: '%s', symOptions: %ld, UserName: '%s'\n",
|
||||
szSearchPath,
|
||||
symOptions,
|
||||
szUserName);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"SymInit: Symbol-SearchPath: '%s', symOptions: %ld, UserName: '%s'\n",
|
||||
szSearchPath,
|
||||
symOptions,
|
||||
szUserName
|
||||
);
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
|
||||
OnOutput(buffer);
|
||||
// Also display the OS-version
|
||||
@@ -1588,13 +1603,15 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
|
||||
ZeroMemory(&ver, sizeof(OSVERSIONINFOA));
|
||||
ver.dwOSVersionInfoSize = sizeof(ver);
|
||||
if (GetVersionExA(&ver) != FALSE) {
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"OS-Version: %d.%d.%d (%s)\n",
|
||||
ver.dwMajorVersion,
|
||||
ver.dwMinorVersion,
|
||||
ver.dwBuildNumber,
|
||||
ver.szCSDVersion);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"OS-Version: %d.%d.%d (%s)\n",
|
||||
ver.dwMajorVersion,
|
||||
ver.dwMinorVersion,
|
||||
ver.dwBuildNumber,
|
||||
ver.szCSDVersion
|
||||
);
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
|
||||
OnOutput(buffer);
|
||||
}
|
||||
@@ -1602,26 +1619,28 @@ void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUser
|
||||
OSVERSIONINFOEXA ver;
|
||||
ZeroMemory(&ver, sizeof(OSVERSIONINFOEXA));
|
||||
ver.dwOSVersionInfoSize = sizeof(ver);
|
||||
#if _MSC_VER >= 1900
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
# if _MSC_VER >= 1900
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4996)
|
||||
# endif
|
||||
if (GetVersionExA((OSVERSIONINFOA*)&ver) != FALSE) {
|
||||
_snprintf_s(buffer,
|
||||
maxLen,
|
||||
"OS-Version: %ld.%ld.%ld (%s) 0x%x-0x%x\n",
|
||||
ver.dwMajorVersion,
|
||||
ver.dwMinorVersion,
|
||||
ver.dwBuildNumber,
|
||||
ver.szCSDVersion,
|
||||
ver.wSuiteMask,
|
||||
ver.wProductType);
|
||||
_snprintf_s(
|
||||
buffer,
|
||||
maxLen,
|
||||
"OS-Version: %ld.%ld.%ld (%s) 0x%x-0x%x\n",
|
||||
ver.dwMajorVersion,
|
||||
ver.dwMinorVersion,
|
||||
ver.dwBuildNumber,
|
||||
ver.szCSDVersion,
|
||||
ver.wSuiteMask,
|
||||
ver.wProductType
|
||||
);
|
||||
buffer[STACKWALK_MAX_NAMELEN - 1] = 0;
|
||||
OnOutput(buffer);
|
||||
}
|
||||
#if _MSC_VER >= 1900
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
# if _MSC_VER >= 1900
|
||||
# pragma warning(pop)
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -261,20 +261,20 @@ protected:
|
||||
__asm mov c.Esp, esp \
|
||||
} while (0)
|
||||
// clang-format on
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#else
|
||||
# else
|
||||
|
||||
// The following is defined for x86 (XP and higher), x64 and IA64:
|
||||
#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
RtlCaptureContext(&c); \
|
||||
} while (0);
|
||||
#endif
|
||||
# define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
RtlCaptureContext(&c); \
|
||||
} while (0);
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
# endif // defined(_MSC_VER)
|
||||
|
||||
#endif // __STACKWALKER_H__
|
||||
// NOLINTEND
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QBuffer>
|
||||
#include <QIODevice>
|
||||
#ifdef __GNUC__
|
||||
#include <cstdint>
|
||||
# include <cstdint>
|
||||
#endif
|
||||
|
||||
#include "Stream.h"
|
||||
@@ -283,9 +283,8 @@ std::streamsize ByteArrayOStreambuf::xsputn(const char* s, std::streamsize num)
|
||||
return _buffer->write(s, num);
|
||||
}
|
||||
|
||||
std::streambuf::pos_type ByteArrayOStreambuf::seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type ByteArrayOStreambuf::
|
||||
seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
off_type endpos = 0;
|
||||
off_type curpos = _buffer->pos();
|
||||
@@ -312,8 +311,7 @@ std::streambuf::pos_type ByteArrayOStreambuf::seekoff(std::streambuf::off_type o
|
||||
return {endpos};
|
||||
}
|
||||
|
||||
std::streambuf::pos_type ByteArrayOStreambuf::seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type ByteArrayOStreambuf::seekpos(std::streambuf::pos_type pos, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
@@ -361,9 +359,8 @@ std::streamsize ByteArrayIStreambuf::showmanyc()
|
||||
return _end - _cur;
|
||||
}
|
||||
|
||||
std::streambuf::pos_type ByteArrayIStreambuf::seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type ByteArrayIStreambuf::
|
||||
seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
int p_pos = -1;
|
||||
if (way == std::ios_base::beg) {
|
||||
@@ -389,8 +386,7 @@ std::streambuf::pos_type ByteArrayIStreambuf::seekoff(std::streambuf::off_type o
|
||||
return ((p_pos + off) - _beg);
|
||||
}
|
||||
|
||||
std::streambuf::pos_type ByteArrayIStreambuf::seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type ByteArrayIStreambuf::seekpos(std::streambuf::pos_type pos, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
@@ -419,9 +415,8 @@ std::streamsize IODeviceOStreambuf::xsputn(const char* s, std::streamsize num)
|
||||
return device->write(s, num);
|
||||
}
|
||||
|
||||
std::streambuf::pos_type IODeviceOStreambuf::seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type IODeviceOStreambuf::
|
||||
seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
off_type endpos = 0;
|
||||
off_type curpos = device->pos();
|
||||
@@ -448,8 +443,7 @@ std::streambuf::pos_type IODeviceOStreambuf::seekoff(std::streambuf::off_type of
|
||||
return {endpos};
|
||||
}
|
||||
|
||||
std::streambuf::pos_type IODeviceOStreambuf::seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type IODeviceOStreambuf::seekpos(std::streambuf::pos_type pos, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
@@ -459,9 +453,11 @@ std::streambuf::pos_type IODeviceOStreambuf::seekpos(std::streambuf::pos_type po
|
||||
IODeviceIStreambuf::IODeviceIStreambuf(QIODevice* dev)
|
||||
: device(dev)
|
||||
{
|
||||
setg(buffer + pbSize, // beginning of putback area
|
||||
buffer + pbSize, // read position
|
||||
buffer + pbSize); // end position
|
||||
setg(
|
||||
buffer + pbSize, // beginning of putback area
|
||||
buffer + pbSize, // read position
|
||||
buffer + pbSize
|
||||
); // end position
|
||||
}
|
||||
|
||||
IODeviceIStreambuf::~IODeviceIStreambuf() = default;
|
||||
@@ -501,17 +497,18 @@ std::streambuf::int_type IODeviceIStreambuf::underflow()
|
||||
}
|
||||
|
||||
// reset buffer pointers
|
||||
setg(buffer + (pbSize - numPutback), // beginning of putback area
|
||||
buffer + pbSize, // read position
|
||||
buffer + pbSize + num); // end of buffer
|
||||
setg(
|
||||
buffer + (pbSize - numPutback), // beginning of putback area
|
||||
buffer + pbSize, // read position
|
||||
buffer + pbSize + num
|
||||
); // end of buffer
|
||||
|
||||
// return next character
|
||||
return *gptr();
|
||||
}
|
||||
|
||||
std::streambuf::pos_type IODeviceIStreambuf::seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type IODeviceIStreambuf::
|
||||
seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
off_type endpos = 0;
|
||||
off_type curpos = device->pos();
|
||||
@@ -538,8 +535,7 @@ std::streambuf::pos_type IODeviceIStreambuf::seekoff(std::streambuf::off_type of
|
||||
return {endpos};
|
||||
}
|
||||
|
||||
std::streambuf::pos_type IODeviceIStreambuf::seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type IODeviceIStreambuf::seekpos(std::streambuf::pos_type pos, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
@@ -718,9 +714,8 @@ std::streamsize PyStreambuf::xsputn(const char* s, std::streamsize num)
|
||||
#endif
|
||||
}
|
||||
|
||||
PyStreambuf::pos_type PyStreambuf::seekoff(PyStreambuf::off_type offset,
|
||||
PyStreambuf::seekdir dir,
|
||||
PyStreambuf::openmode /*mode*/)
|
||||
PyStreambuf::pos_type PyStreambuf::
|
||||
seekoff(PyStreambuf::off_type offset, PyStreambuf::seekdir dir, PyStreambuf::openmode /*mode*/)
|
||||
{
|
||||
int whence = 0;
|
||||
switch (dir) {
|
||||
@@ -806,9 +801,8 @@ std::streamsize Streambuf::showmanyc()
|
||||
return _end - _cur;
|
||||
}
|
||||
|
||||
std::streambuf::pos_type Streambuf::seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type Streambuf::
|
||||
seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
std::string::const_iterator p_pos;
|
||||
if (way == std::ios_base::beg) {
|
||||
@@ -834,8 +828,7 @@ std::streambuf::pos_type Streambuf::seekoff(std::streambuf::off_type off,
|
||||
return ((p_pos + off) - _beg);
|
||||
}
|
||||
|
||||
std::streambuf::pos_type Streambuf::seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode /*mode*/)
|
||||
std::streambuf::pos_type Streambuf::seekpos(std::streambuf::pos_type pos, std::ios_base::openmode /*mode*/)
|
||||
{
|
||||
return seekoff(pos, std::ios_base::beg);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define BASE_STREAM_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <cstdint>
|
||||
# include <cstdint>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
@@ -368,11 +368,15 @@ public:
|
||||
protected:
|
||||
int_type overflow(std::streambuf::int_type c) override;
|
||||
std::streamsize xsputn(const char* s, std::streamsize num) override;
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
|
||||
public:
|
||||
ByteArrayOStreambuf(const ByteArrayOStreambuf&) = delete;
|
||||
@@ -400,11 +404,15 @@ protected:
|
||||
int_type underflow() override;
|
||||
int_type pbackfail(int_type ch) override;
|
||||
std::streamsize showmanyc() override;
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
|
||||
public:
|
||||
ByteArrayIStreambuf(const ByteArrayIStreambuf&) = delete;
|
||||
@@ -431,11 +439,15 @@ public:
|
||||
protected:
|
||||
int_type overflow(std::streambuf::int_type c) override;
|
||||
std::streamsize xsputn(const char* s, std::streamsize num) override;
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
|
||||
public:
|
||||
IODeviceOStreambuf(const IODeviceOStreambuf&) = delete;
|
||||
@@ -460,11 +472,15 @@ public:
|
||||
|
||||
protected:
|
||||
int_type underflow() override;
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
|
||||
public:
|
||||
IODeviceIStreambuf(const IODeviceIStreambuf&) = delete;
|
||||
@@ -542,11 +558,15 @@ protected:
|
||||
int_type underflow() override;
|
||||
int_type pbackfail(int_type ch) override;
|
||||
std::streamsize showmanyc() override;
|
||||
pos_type seekoff(std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekpos(std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out) override;
|
||||
pos_type seekoff(
|
||||
std::streambuf::off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
pos_type seekpos(
|
||||
std::streambuf::pos_type pos,
|
||||
std::ios_base::openmode which = std::ios::in | std::ios::out
|
||||
) override;
|
||||
|
||||
public:
|
||||
Streambuf(const Streambuf&) = delete;
|
||||
@@ -581,9 +601,11 @@ public:
|
||||
: std::ofstream(fi.toStdWString().c_str(), mode) {}
|
||||
#else
|
||||
: std::ofstream(fi.filePath().c_str(), mode)
|
||||
{}
|
||||
{
|
||||
}
|
||||
#endif
|
||||
~ofstream() override = default;
|
||||
~ofstream() override
|
||||
= default;
|
||||
void open(const FileInfo& fi, ios_base::openmode mode = std::ios::out | std::ios::trunc)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
@@ -614,9 +636,11 @@ public:
|
||||
: std::ifstream(fi.toStdWString().c_str(), mode) {}
|
||||
#else
|
||||
: std::ifstream(fi.filePath().c_str(), mode)
|
||||
{}
|
||||
{
|
||||
}
|
||||
#endif
|
||||
~ifstream() override = default;
|
||||
~ifstream() override
|
||||
= default;
|
||||
void open(const FileInfo& fi, ios_base::openmode mode = std::ios::in)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -152,8 +152,8 @@ std::string Base::Tools::escapedUnicodeToUtf8(const std::string& s)
|
||||
Base::PyGILStateLocker lock;
|
||||
std::string string;
|
||||
|
||||
PyObject* unicode =
|
||||
PyUnicode_DecodeUnicodeEscape(s.c_str(), static_cast<Py_ssize_t>(s.size()), "strict");
|
||||
PyObject* unicode
|
||||
= PyUnicode_DecodeUnicodeEscape(s.c_str(), static_cast<Py_ssize_t>(s.size()), "strict");
|
||||
if (!unicode) {
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define SRC_BASE_TOOLS_H_
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
@@ -335,8 +335,7 @@ bool Polygon2d::Contains(const Vector2d& rclV) const
|
||||
return sTorsion != 0;
|
||||
}
|
||||
|
||||
void Polygon2d::Intersect(const Polygon2d& rclPolygon,
|
||||
std::list<Polygon2d>& rclResultPolygonList) const
|
||||
void Polygon2d::Intersect(const Polygon2d& rclPolygon, std::list<Polygon2d>& rclResultPolygonList) const
|
||||
{
|
||||
// trim the passed polygon with the current one, the result is a list of polygons (subset of the
|
||||
// passed polygon) your own (trim) polygon is closed
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <vector>
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define BASE_TOOLS3D_H
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -33,49 +33,61 @@ using namespace Base;
|
||||
Translate::Translate()
|
||||
: Py::ExtensionModule<Translate>("__Translate__")
|
||||
{
|
||||
add_varargs_method("translate",
|
||||
&Translate::translate,
|
||||
"translate(context, sourcetext, disambiguation = None, n=-1)\n"
|
||||
"-- Returns the translation text for sourceText, by querying\n"
|
||||
"the installed translation files. The translation files are\n"
|
||||
"searched from the most recently installed file back to the\n"
|
||||
"first installed file.");
|
||||
add_varargs_method("QT_TRANSLATE_NOOP",
|
||||
&Translate::translateNoop,
|
||||
"QT_TRANSLATE_NOOP(context, sourcetext)\n"
|
||||
"Marks the UTF-8 encoded string literal sourcetext for delayed translation "
|
||||
"in the given context.\n"
|
||||
"The context is typically a class name and also needs to be specified as a "
|
||||
"string literal.");
|
||||
add_varargs_method("QT_TRANSLATE_NOOP3",
|
||||
&Translate::translateNoop3,
|
||||
"QT_TRANSLATE_NOOP3(context, sourcetext, disambiguation)\n"
|
||||
"Marks the UTF-8 encoded string literal sourceText for delayed translation "
|
||||
"in the given context\n"
|
||||
"with the given disambiguation. The context is typically a class and also "
|
||||
"needs to be specified\n"
|
||||
"as a string literal. The string literal disambiguation should be a short "
|
||||
"semantic tag to tell\n"
|
||||
"apart otherwise identical strings.");
|
||||
add_varargs_method("QT_TRANSLATE_NOOP_UTF8",
|
||||
&Translate::translateNoop,
|
||||
"QT_TRANSLATE_NOOP_UTF8(context, sourcetext)\n"
|
||||
"Same as QT_TRANSLATE_NOOP");
|
||||
add_varargs_method("QT_TR_NOOP",
|
||||
&Translate::trNoop,
|
||||
"QT_TR_NOOP(sourcetext)\n"
|
||||
"Marks the UTF-8 encoded string literal sourcetext for delayed translation "
|
||||
"in the current context");
|
||||
add_varargs_method("QT_TR_NOOP_UTF8",
|
||||
&Translate::trNoop,
|
||||
"QT_TR_NOOP_UTF8(sourcetext)\n"
|
||||
"Same as QT_TR_NOOP");
|
||||
add_varargs_method("installTranslator",
|
||||
&Translate::installTranslator,
|
||||
"Install a translator for testing purposes");
|
||||
add_varargs_method("removeTranslators",
|
||||
&Translate::removeTranslators,
|
||||
"Remove test translators");
|
||||
add_varargs_method(
|
||||
"translate",
|
||||
&Translate::translate,
|
||||
"translate(context, sourcetext, disambiguation = None, n=-1)\n"
|
||||
"-- Returns the translation text for sourceText, by querying\n"
|
||||
"the installed translation files. The translation files are\n"
|
||||
"searched from the most recently installed file back to the\n"
|
||||
"first installed file."
|
||||
);
|
||||
add_varargs_method(
|
||||
"QT_TRANSLATE_NOOP",
|
||||
&Translate::translateNoop,
|
||||
"QT_TRANSLATE_NOOP(context, sourcetext)\n"
|
||||
"Marks the UTF-8 encoded string literal sourcetext for delayed translation "
|
||||
"in the given context.\n"
|
||||
"The context is typically a class name and also needs to be specified as a "
|
||||
"string literal."
|
||||
);
|
||||
add_varargs_method(
|
||||
"QT_TRANSLATE_NOOP3",
|
||||
&Translate::translateNoop3,
|
||||
"QT_TRANSLATE_NOOP3(context, sourcetext, disambiguation)\n"
|
||||
"Marks the UTF-8 encoded string literal sourceText for delayed translation "
|
||||
"in the given context\n"
|
||||
"with the given disambiguation. The context is typically a class and also "
|
||||
"needs to be specified\n"
|
||||
"as a string literal. The string literal disambiguation should be a short "
|
||||
"semantic tag to tell\n"
|
||||
"apart otherwise identical strings."
|
||||
);
|
||||
add_varargs_method(
|
||||
"QT_TRANSLATE_NOOP_UTF8",
|
||||
&Translate::translateNoop,
|
||||
"QT_TRANSLATE_NOOP_UTF8(context, sourcetext)\n"
|
||||
"Same as QT_TRANSLATE_NOOP"
|
||||
);
|
||||
add_varargs_method(
|
||||
"QT_TR_NOOP",
|
||||
&Translate::trNoop,
|
||||
"QT_TR_NOOP(sourcetext)\n"
|
||||
"Marks the UTF-8 encoded string literal sourcetext for delayed translation "
|
||||
"in the current context"
|
||||
);
|
||||
add_varargs_method(
|
||||
"QT_TR_NOOP_UTF8",
|
||||
&Translate::trNoop,
|
||||
"QT_TR_NOOP_UTF8(sourcetext)\n"
|
||||
"Same as QT_TR_NOOP"
|
||||
);
|
||||
add_varargs_method(
|
||||
"installTranslator",
|
||||
&Translate::installTranslator,
|
||||
"Install a translator for testing purposes"
|
||||
);
|
||||
add_varargs_method("removeTranslators", &Translate::removeTranslators, "Remove test translators");
|
||||
initialize("This module is the Translate module"); // register with Python
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
namespace Py
|
||||
|
||||
@@ -31,22 +31,22 @@
|
||||
|
||||
using namespace Base;
|
||||
|
||||
static_assert(sizeof(Base::Type) == sizeof(Type::TypeId),
|
||||
"Base::Type has been designed to be small to be passed around by value efficiently. "
|
||||
"The size of Base::Type has changed. Be careful when adding more data members.");
|
||||
static_assert(
|
||||
sizeof(Base::Type) == sizeof(Type::TypeId),
|
||||
"Base::Type has been designed to be small to be passed around by value efficiently. "
|
||||
"The size of Base::Type has changed. Be careful when adding more data members."
|
||||
);
|
||||
|
||||
static_assert(
|
||||
sizeof(Base::Type) <= 2 * sizeof(void*),
|
||||
"Base::Type has been designed to be small to be passed around by value efficiently. "
|
||||
"When the size grows larger than ~2 words, consider passing by const reference instead. "
|
||||
"Exact limit depends on the architecture and ABI.");
|
||||
"Exact limit depends on the architecture and ABI."
|
||||
);
|
||||
|
||||
struct Base::TypeData
|
||||
{
|
||||
TypeData(const char* name,
|
||||
const Type type,
|
||||
const Type parent,
|
||||
const Type::instantiationMethod instMethod)
|
||||
TypeData(const char* name, const Type type, const Type parent, const Type::instantiationMethod instMethod)
|
||||
: name(name)
|
||||
, parent(parent)
|
||||
, type(type)
|
||||
@@ -133,8 +133,7 @@ const std::string Type::getModuleName(const char* className)
|
||||
std::string_view classNameView(className);
|
||||
auto pos = classNameView.find("::");
|
||||
|
||||
return pos != std::string_view::npos ? std::string(classNameView.substr(0, pos))
|
||||
: std::string();
|
||||
return pos != std::string_view::npos ? std::string(classNameView.substr(0, pos)) : std::string();
|
||||
}
|
||||
|
||||
|
||||
@@ -191,15 +190,17 @@ const Type Type::fromKey(TypeId key)
|
||||
|
||||
const char* Type::getName() const
|
||||
{
|
||||
assert(typedata.size() >= 1
|
||||
&& "Type::init() must be called before fetching names, even for bad types");
|
||||
assert(
|
||||
typedata.size() >= 1 && "Type::init() must be called before fetching names, even for bad types"
|
||||
);
|
||||
return typedata[index]->name.c_str();
|
||||
}
|
||||
|
||||
const Type Type::getParent() const
|
||||
{
|
||||
assert(typedata.size() >= 1
|
||||
&& "Type::init() must be called before fetching parents, even for bad types");
|
||||
assert(
|
||||
typedata.size() >= 1 && "Type::init() must be called before fetching parents, even for bad types"
|
||||
);
|
||||
return typedata[index]->parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
namespace Base
|
||||
@@ -112,13 +112,19 @@ public:
|
||||
/// Returns all descendants from the given type
|
||||
static int getAllDerivedFrom(const Type type, std::vector<Type>& list);
|
||||
/// Returns the given named type if is derived from parent type, otherwise return bad type
|
||||
[[nodiscard]] static const Type
|
||||
getTypeIfDerivedFrom(const char* name, const Type parent, bool loadModule = false);
|
||||
[[nodiscard]] static const Type getTypeIfDerivedFrom(
|
||||
const char* name,
|
||||
const Type parent,
|
||||
bool loadModule = false
|
||||
);
|
||||
/// Returns the number of types created so far
|
||||
[[nodiscard]] static int getNumTypes();
|
||||
/// Creates a new type with the given name, parent and instantiation method
|
||||
[[nodiscard]] static const Type
|
||||
createType(const Type parent, const char* name, instantiationMethod method = nullptr);
|
||||
[[nodiscard]] static const Type createType(
|
||||
const Type parent,
|
||||
const char* name,
|
||||
instantiationMethod method = nullptr
|
||||
);
|
||||
/// Returns the inner index of the type
|
||||
[[nodiscard]] TypeId getKey() const;
|
||||
/// Checks if the type is invalid
|
||||
|
||||
@@ -29,8 +29,9 @@
|
||||
|
||||
#include "UniqueNameManager.h"
|
||||
|
||||
std::tuple<std::string, std::string, unsigned int, Base::UnlimitedUnsigned>
|
||||
Base::UniqueNameManager::decomposeName(const std::string& name) const
|
||||
std::tuple<std::string, std::string, unsigned int, Base::UnlimitedUnsigned> Base::UniqueNameManager::decomposeName(
|
||||
const std::string& name
|
||||
) const
|
||||
{
|
||||
auto suffixStart = getNameSuffixStartPosition(name);
|
||||
auto digitsStart = std::find_if_not(suffixStart, name.crend(), [](char c) {
|
||||
@@ -41,10 +42,10 @@ Base::UniqueNameManager::decomposeName(const std::string& name) const
|
||||
name.substr(0, name.crend() - digitsStart),
|
||||
name.substr(name.crend() - suffixStart),
|
||||
digitCount,
|
||||
UnlimitedUnsigned::fromString(name.substr(name.crend() - digitsStart, digitCount))};
|
||||
UnlimitedUnsigned::fromString(name.substr(name.crend() - digitsStart, digitCount))
|
||||
};
|
||||
}
|
||||
bool Base::UniqueNameManager::haveSameBaseName(const std::string& first,
|
||||
const std::string& second) const
|
||||
bool Base::UniqueNameManager::haveSameBaseName(const std::string& first, const std::string& second) const
|
||||
{
|
||||
auto firstSuffixStart = getNameSuffixStartPosition(first);
|
||||
auto secondSuffixStart = getNameSuffixStartPosition(second);
|
||||
@@ -68,17 +69,17 @@ void Base::UniqueNameManager::addExactName(const std::string& name)
|
||||
auto baseNameEntry = uniqueSeeds.find(baseName);
|
||||
if (baseNameEntry == uniqueSeeds.end()) {
|
||||
// First use of baseName
|
||||
baseNameEntry =
|
||||
uniqueSeeds
|
||||
.emplace(baseName, std::vector<PiecewiseSparseIntegerSet<UnlimitedUnsigned>>())
|
||||
.first;
|
||||
baseNameEntry
|
||||
= uniqueSeeds
|
||||
.emplace(baseName, std::vector<PiecewiseSparseIntegerSet<UnlimitedUnsigned>>())
|
||||
.first;
|
||||
}
|
||||
if (digitCount >= baseNameEntry->second.size()) {
|
||||
// First use of this digitCount
|
||||
baseNameEntry->second.resize(digitCount + 1);
|
||||
}
|
||||
PiecewiseSparseIntegerSet<UnlimitedUnsigned>& baseNameAndDigitCountEntry =
|
||||
baseNameEntry->second[digitCount];
|
||||
PiecewiseSparseIntegerSet<UnlimitedUnsigned>& baseNameAndDigitCountEntry
|
||||
= baseNameEntry->second[digitCount];
|
||||
|
||||
if (baseNameAndDigitCountEntry.contains(digitsValue)) {
|
||||
// We already have at least one instance of the name.
|
||||
@@ -90,8 +91,10 @@ void Base::UniqueNameManager::addExactName(const std::string& name)
|
||||
}
|
||||
baseNameAndDigitCountEntry.add(digitsValue);
|
||||
}
|
||||
std::string Base::UniqueNameManager::makeUniqueName(const std::string& modelName,
|
||||
std::size_t minDigits) const
|
||||
std::string Base::UniqueNameManager::makeUniqueName(
|
||||
const std::string& modelName,
|
||||
std::size_t minDigits
|
||||
) const
|
||||
{
|
||||
auto [namePrefix, nameSuffix, digitCount, digitsValue] = decomposeName(modelName);
|
||||
std::string baseName = namePrefix + nameSuffix;
|
||||
@@ -147,10 +150,10 @@ void Base::UniqueNameManager::removeExactName(const std::string& name)
|
||||
digitValueSets[digitCount].remove(digitsValue);
|
||||
// an element of digitValueSets may now be newly empty and so may other elements below it
|
||||
// Prune off all such trailing empty entries.
|
||||
auto lastNonemptyEntry =
|
||||
std::find_if(digitValueSets.crbegin(), digitValueSets.crend(), [](auto& it) {
|
||||
return !it.empty();
|
||||
});
|
||||
auto lastNonemptyEntry
|
||||
= std::find_if(digitValueSets.crbegin(), digitValueSets.crend(), [](auto& it) {
|
||||
return !it.empty();
|
||||
});
|
||||
if (lastNonemptyEntry == digitValueSets.crend()) {
|
||||
// All entries are empty, so the entire baseName can be forgotten.
|
||||
uniqueSeeds.erase(baseName);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define SRC_BASE_UNIQUENAMEMANAGER_H_
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -57,8 +57,7 @@ protected:
|
||||
// of the start of the suffix (or name.crbegin() if no suffix).
|
||||
// It must return the same suffix length (name.crbegin() - returnValue) for both
|
||||
// unique names (one containing digits) and the corresponding base name (with no digits).
|
||||
virtual std::string::const_reverse_iterator
|
||||
getNameSuffixStartPosition(const std::string& name) const
|
||||
virtual std::string::const_reverse_iterator getNameSuffixStartPosition(const std::string& name) const
|
||||
{
|
||||
return name.crbegin();
|
||||
}
|
||||
@@ -212,8 +211,9 @@ private:
|
||||
/// @param name The name to break up
|
||||
/// @return a tuple(basePrefix, nameSuffix, uniqueDigitCount, uniqueDigitsValue);
|
||||
/// The two latter values will be (0,0) if name is a base name without uniquifying digits.
|
||||
std::tuple<std::string, std::string, unsigned int, UnlimitedUnsigned>
|
||||
decomposeName(const std::string& name) const;
|
||||
std::tuple<std::string, std::string, unsigned int, UnlimitedUnsigned> decomposeName(
|
||||
const std::string& name
|
||||
) const;
|
||||
|
||||
public:
|
||||
UniqueNameManager() = default;
|
||||
|
||||
@@ -110,20 +110,24 @@ constexpr auto unitSpecs = std::to_array<UnitSpec>({
|
||||
{ "YoungsModulus" , { -1, 1, -2 } },
|
||||
}); // clang-format on
|
||||
|
||||
Unit::Unit(const int length, // NOLINT
|
||||
const int mass,
|
||||
const int time,
|
||||
const int electricCurrent,
|
||||
const int thermodynamicTemperature,
|
||||
const int amountOfSubstance,
|
||||
const int luminousIntensity,
|
||||
const int angle)
|
||||
Unit::Unit(
|
||||
const int length, // NOLINT
|
||||
const int mass,
|
||||
const int time,
|
||||
const int electricCurrent,
|
||||
const int thermodynamicTemperature,
|
||||
const int amountOfSubstance,
|
||||
const int luminousIntensity,
|
||||
const int angle
|
||||
)
|
||||
: _name {""}
|
||||
{
|
||||
auto cast = [](auto val) {
|
||||
return static_cast<int8_t>(std::clamp<decltype(val)>(val,
|
||||
std::numeric_limits<int8_t>::min(),
|
||||
std::numeric_limits<int8_t>::max()));
|
||||
return static_cast<int8_t>(std::clamp<decltype(val)>(
|
||||
val,
|
||||
std::numeric_limits<int8_t>::min(),
|
||||
std::numeric_limits<int8_t>::max()
|
||||
));
|
||||
};
|
||||
|
||||
_exps[0] = cast(length);
|
||||
@@ -257,10 +261,11 @@ std::string Unit::getString() const
|
||||
|
||||
auto denominatorStr = buildStr(negValIndexes);
|
||||
|
||||
return fmt::format("{}/{}",
|
||||
numeratorStr.empty() ? "1" : numeratorStr,
|
||||
negValIndexes.size() > 1 ? fmt::format("({})", denominatorStr)
|
||||
: denominatorStr);
|
||||
return fmt::format(
|
||||
"{}/{}",
|
||||
numeratorStr.empty() ? "1" : numeratorStr,
|
||||
negValIndexes.size() > 1 ? fmt::format("({})", denominatorStr) : denominatorStr
|
||||
);
|
||||
}
|
||||
|
||||
std::string Unit::representation() const
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
namespace Base
|
||||
{
|
||||
|
||||
constexpr auto unitSymbols =
|
||||
std::to_array<std::string_view>({"mm", "kg", "s", "A", "K", "mol", "cd", "deg"});
|
||||
constexpr auto unitSymbols = std::to_array<std::string_view>(
|
||||
{"mm", "kg", "s", "A", "K", "mol", "cd", "deg"}
|
||||
);
|
||||
|
||||
constexpr auto unitNumExponents {unitSymbols.size()};
|
||||
using UnitExponents = std::array<int8_t, unitNumExponents>;
|
||||
@@ -57,14 +58,16 @@ public:
|
||||
}
|
||||
|
||||
/// helper constructor to ease Unit construction from Python
|
||||
explicit Unit(const int length,
|
||||
const int mass = 0,
|
||||
const int time = 0,
|
||||
const int electricCurrent = 0,
|
||||
const int thermodynamicTemperature = 0,
|
||||
const int amountOfSubstance = 0,
|
||||
const int luminousIntensity = 0,
|
||||
const int angle = 0);
|
||||
explicit Unit(
|
||||
const int length,
|
||||
const int mass = 0,
|
||||
const int time = 0,
|
||||
const int electricCurrent = 0,
|
||||
const int thermodynamicTemperature = 0,
|
||||
const int amountOfSubstance = 0,
|
||||
const int luminousIntensity = 0,
|
||||
const int angle = 0
|
||||
);
|
||||
|
||||
bool operator==(const Unit&) const;
|
||||
bool operator!=(const Unit& that) const;
|
||||
|
||||
@@ -238,8 +238,7 @@ PyObject* UnitPy::number_divmod_handler(PyObject* /*self*/, PyObject* /*other*/)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject*
|
||||
UnitPy::number_power_handler(PyObject* /*self*/, PyObject* /*other*/, PyObject* /*modulo*/)
|
||||
PyObject* UnitPy::number_power_handler(PyObject* /*self*/, PyObject* /*other*/, PyObject* /*modulo*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
|
||||
return nullptr;
|
||||
|
||||
@@ -128,8 +128,7 @@ double UnitsApi::toDouble(PyObject* args, const Base::Unit& u)
|
||||
throw Base::UnitsMismatchError("Wrong parameter type!");
|
||||
}
|
||||
|
||||
std::string
|
||||
UnitsApi::schemaTranslate(const Quantity& quant, double& factor, std::string& unitString)
|
||||
std::string UnitsApi::schemaTranslate(const Quantity& quant, double& factor, std::string& unitString)
|
||||
{
|
||||
return schemas->currentSchema()->translate(quant, factor, unitString);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ public:
|
||||
static void setSchema(const std::string& name);
|
||||
static void setSchema(std::size_t num);
|
||||
|
||||
static std::string
|
||||
schemaTranslate(const Quantity& quant, double& factor, std::string& unitString);
|
||||
static std::string schemaTranslate(const Quantity& quant, double& factor, std::string& unitString);
|
||||
|
||||
static std::string schemaTranslate(const Quantity& quant);
|
||||
|
||||
@@ -78,8 +77,7 @@ public:
|
||||
static PyMethodDef Methods[];
|
||||
|
||||
protected:
|
||||
static inline auto schemas =
|
||||
std::make_unique<UnitsSchemas>(UnitsSchemasData::unitSchemasDataPack);
|
||||
static inline auto schemas = std::make_unique<UnitsSchemas>(UnitsSchemasData::unitSchemasDataPack);
|
||||
static inline int decimals {-1};
|
||||
static inline int denominator {-1};
|
||||
|
||||
|
||||
@@ -160,8 +160,10 @@ PyObject* UnitsApi::sSchemaTranslate(PyObject* /*self*/, PyObject* args)
|
||||
}
|
||||
|
||||
if (index < 0 || index >= static_cast<int>(count())) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
std::string {"invalid schema index: " + std::to_string(index)}.c_str());
|
||||
PyErr_SetString(
|
||||
PyExc_ValueError,
|
||||
std::string {"invalid schema index: " + std::to_string(index)}.c_str()
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ std::string UnitsSchema::translate(const Quantity& quant) const
|
||||
return translate(quant, dummy1, dummy2);
|
||||
}
|
||||
|
||||
std::string
|
||||
UnitsSchema::translate(const Quantity& quant, double& factor, std::string& unitString) const
|
||||
std::string UnitsSchema::translate(const Quantity& quant, double& factor, std::string& unitString) const
|
||||
{
|
||||
// Use defaults without schema-level translation.
|
||||
factor = 1.0;
|
||||
@@ -76,18 +75,21 @@ UnitsSchema::translate(const Quantity& quant, double& factor, std::string& unitS
|
||||
auto unitSpecs = spec.translationSpecs.at(unitName);
|
||||
const auto unitSpec = std::find_if(unitSpecs.begin(), unitSpecs.end(), isSuitable);
|
||||
if (unitSpec == unitSpecs.end()) {
|
||||
throw RuntimeError("Suitable threshold not found. Schema: " + spec.name
|
||||
+ " value: " + std::to_string(value));
|
||||
throw RuntimeError(
|
||||
"Suitable threshold not found. Schema: " + spec.name + " value: " + std::to_string(value)
|
||||
);
|
||||
}
|
||||
|
||||
if (unitSpec->factor == 0) {
|
||||
const QuantityFormat& format = quant.getFormat();
|
||||
return UnitsSchemasData::runSpecial(unitSpec->unitString,
|
||||
value,
|
||||
format.getPrecision(),
|
||||
format.getDenominator(),
|
||||
factor,
|
||||
unitString);
|
||||
return UnitsSchemasData::runSpecial(
|
||||
unitSpec->unitString,
|
||||
value,
|
||||
format.getPrecision(),
|
||||
format.getDenominator(),
|
||||
factor,
|
||||
unitString
|
||||
);
|
||||
}
|
||||
|
||||
factor = unitSpec->factor;
|
||||
@@ -96,8 +98,7 @@ UnitsSchema::translate(const Quantity& quant, double& factor, std::string& unitS
|
||||
return toLocale(quant, factor, unitString);
|
||||
}
|
||||
|
||||
std::string
|
||||
UnitsSchema::toLocale(const Quantity& quant, const double factor, const std::string& unitString)
|
||||
std::string UnitsSchema::toLocale(const Quantity& quant, const double factor, const std::string& unitString)
|
||||
{
|
||||
QLocale Lc;
|
||||
const QuantityFormat& format = quant.getFormat();
|
||||
@@ -105,9 +106,8 @@ UnitsSchema::toLocale(const Quantity& quant, const double factor, const std::str
|
||||
Lc.setNumberOptions(static_cast<QLocale::NumberOptions>(format.option));
|
||||
}
|
||||
|
||||
auto valueString =
|
||||
Lc.toString(quant.getValue() / factor, format.toFormat(), format.getPrecision())
|
||||
.toStdString();
|
||||
auto valueString = Lc.toString(quant.getValue() / factor, format.toFormat(), format.getPrecision())
|
||||
.toStdString();
|
||||
|
||||
auto notUnit = [](auto s) {
|
||||
return s.empty() || s == "°" || s == "″" || s == "′" || s == "\"" || s == "'";
|
||||
@@ -157,9 +157,7 @@ std::string UnitsSchema::getUnitText(const Base::Quantity& quant) const
|
||||
|
||||
// TODO: some common code here with translate()
|
||||
if (!spec.translationSpecs.contains(typeString)) {
|
||||
Base::Console().log("Schema %s has no entry for %s\n",
|
||||
getName().c_str(),
|
||||
typeString.c_str());
|
||||
Base::Console().log("Schema %s has no entry for %s\n", getName().c_str(), typeString.c_str());
|
||||
return {};
|
||||
}
|
||||
auto unitSpecs = spec.translationSpecs.at(typeString);
|
||||
@@ -170,8 +168,10 @@ std::string UnitsSchema::getUnitText(const Base::Quantity& quant) const
|
||||
|
||||
const auto unitSpec = std::ranges::find_if(unitSpecs, isSuitable);
|
||||
if (unitSpec == unitSpecs.end()) {
|
||||
throw RuntimeError("Suitable threshold not found (2). Schema: " + spec.name
|
||||
+ " value: " + std::to_string(value));
|
||||
throw RuntimeError(
|
||||
"Suitable threshold not found (2). Schema: " + spec.name
|
||||
+ " value: " + std::to_string(value)
|
||||
);
|
||||
}
|
||||
|
||||
return unitSpec->unitString;
|
||||
|
||||
@@ -56,8 +56,11 @@ public:
|
||||
std::string translate(const Quantity& quant, double& factor, std::string& unitString) const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] static std::string
|
||||
toLocale(const Quantity& quant, double factor, const std::string& unitString);
|
||||
[[nodiscard]] static std::string toLocale(
|
||||
const Quantity& quant,
|
||||
double factor,
|
||||
const std::string& unitString
|
||||
);
|
||||
|
||||
UnitsSchemaSpec spec;
|
||||
};
|
||||
|
||||
@@ -66,9 +66,7 @@ std::vector<std::string> UnitsSchemas::getVec(const std::function<std::string(Un
|
||||
|
||||
std::vector<std::string> UnitsSchemas::names()
|
||||
{
|
||||
return getVec([](const UnitsSchemaSpec& spec) {
|
||||
return spec.name;
|
||||
});
|
||||
return getVec([](const UnitsSchemaSpec& spec) { return spec.name; });
|
||||
}
|
||||
|
||||
std::vector<std::string> UnitsSchemas::descriptions()
|
||||
@@ -131,21 +129,15 @@ UnitsSchemaSpec UnitsSchemas::findSpec(const std::function<bool(UnitsSchemaSpec)
|
||||
|
||||
UnitsSchemaSpec UnitsSchemas::spec()
|
||||
{
|
||||
return findSpec([](const UnitsSchemaSpec& spec) {
|
||||
return spec.isDefault;
|
||||
});
|
||||
return findSpec([](const UnitsSchemaSpec& spec) { return spec.isDefault; });
|
||||
}
|
||||
|
||||
UnitsSchemaSpec UnitsSchemas::spec(const std::string_view& name)
|
||||
{
|
||||
return findSpec([&name](const UnitsSchemaSpec& spec) {
|
||||
return spec.name == name;
|
||||
});
|
||||
return findSpec([&name](const UnitsSchemaSpec& spec) { return spec.name == name; });
|
||||
}
|
||||
|
||||
UnitsSchemaSpec UnitsSchemas::spec(const std::size_t num)
|
||||
{
|
||||
return findSpec([&num](const UnitsSchemaSpec& spec) {
|
||||
return spec.num == num;
|
||||
});
|
||||
return findSpec([&num](const UnitsSchemaSpec& spec) { return spec.num == num; });
|
||||
}
|
||||
|
||||
@@ -677,14 +677,14 @@ inline std::string toFractional(const double value, std::size_t denominator)
|
||||
constexpr auto inchPerFoot {12};
|
||||
constexpr auto mmPerInch {25.4};
|
||||
|
||||
auto numFractUnits =
|
||||
static_cast<std::size_t>(std::round(std::abs(value) / mmPerInch * denominator));
|
||||
auto numFractUnits = static_cast<std::size_t>(
|
||||
std::round(std::abs(value) / mmPerInch * denominator)
|
||||
);
|
||||
if (numFractUnits == 0) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
const auto feet =
|
||||
static_cast<std::size_t>(std::floor(numFractUnits / (inchPerFoot * denominator)));
|
||||
const auto feet = static_cast<std::size_t>(std::floor(numFractUnits / (inchPerFoot * denominator)));
|
||||
numFractUnits -= inchPerFoot * denominator * feet;
|
||||
|
||||
const auto inches = static_cast<std::size_t>(std::floor(numFractUnits / denominator));
|
||||
@@ -773,12 +773,14 @@ inline const std::map<std::string, std::function<std::string(double, std::size_t
|
||||
}
|
||||
}; // clang-format on
|
||||
|
||||
inline std::string runSpecial(const std::string& name,
|
||||
const double value,
|
||||
const std::size_t precision,
|
||||
const std::size_t denominator,
|
||||
double& factor,
|
||||
std::string& unitString)
|
||||
inline std::string runSpecial(
|
||||
const std::string& name,
|
||||
const double value,
|
||||
const std::size_t precision,
|
||||
const std::size_t denominator,
|
||||
double& factor,
|
||||
std::string& unitString
|
||||
)
|
||||
{
|
||||
return specials.contains(name)
|
||||
? specials.at(name)(value, precision, denominator, factor, unitString)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define SRC_BASE_UNLIMITEDUNSIGNED_H_
|
||||
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -52,8 +52,8 @@ private:
|
||||
// calculate the corresponding maxPartPlusOne in a static const initializer, so we just wire
|
||||
// in the values for 4-byte PartType.
|
||||
static const size_t partDigitCount = 9;
|
||||
static const PartType maxPartPlusOne =
|
||||
1000000000; // (PartType)pow(10, partDigitCount); but can't call pow in a const ctor.
|
||||
static const PartType maxPartPlusOne = 1000000000; // (PartType)pow(10, partDigitCount); but
|
||||
// can't call pow in a const ctor.
|
||||
|
||||
public:
|
||||
explicit UnlimitedUnsigned(SmallDeltaType value)
|
||||
@@ -75,7 +75,8 @@ public:
|
||||
else {
|
||||
lastStartPosition -= partDigitCount;
|
||||
result[i] = static_cast<PartType>(
|
||||
std::stoul(text.substr(lastStartPosition, partDigitCount)));
|
||||
std::stoul(text.substr(lastStartPosition, partDigitCount))
|
||||
);
|
||||
}
|
||||
if (result[i] != 0) {
|
||||
minimumSize = i + 1;
|
||||
@@ -211,10 +212,12 @@ public:
|
||||
// invert the result to get <= and we compare the most significant chunks first.
|
||||
return parts.size() < right.parts.size()
|
||||
|| (parts.size() == right.parts.size()
|
||||
&& !std::lexicographical_compare(right.parts.rbegin(),
|
||||
right.parts.rend(),
|
||||
parts.rbegin(),
|
||||
parts.rend()));
|
||||
&& !std::lexicographical_compare(
|
||||
right.parts.rbegin(),
|
||||
right.parts.rend(),
|
||||
parts.rbegin(),
|
||||
parts.rend()
|
||||
));
|
||||
}
|
||||
bool operator>(const UnlimitedUnsigned& right) const
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <string>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
# include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
namespace Base
|
||||
|
||||
@@ -185,8 +185,10 @@ Vector3<float_type> Vector3<float_type>::Cross(const Vector3<float_type>& rcVct)
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
bool Vector3<float_type>::IsOnLineSegment(const Vector3<float_type>& startVct,
|
||||
const Vector3<float_type>& endVct) const
|
||||
bool Vector3<float_type>::IsOnLineSegment(
|
||||
const Vector3<float_type>& startVct,
|
||||
const Vector3<float_type>& endVct
|
||||
) const
|
||||
{
|
||||
Vector3<float_type> vectorAB = endVct - startVct;
|
||||
Vector3<float_type> vectorAC = *this - startVct;
|
||||
@@ -252,8 +254,10 @@ bool Vector3<float_type>::IsNormal(const Vector3<float_type>& rclDir, float_type
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
Vector3<float_type>& Vector3<float_type>::ProjectToPlane(const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclNorm)
|
||||
Vector3<float_type>& Vector3<float_type>::ProjectToPlane(
|
||||
const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclNorm
|
||||
)
|
||||
{
|
||||
Vector3<float_type> clTemp(rclNorm);
|
||||
*this = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
|
||||
@@ -261,17 +265,21 @@ Vector3<float_type>& Vector3<float_type>::ProjectToPlane(const Vector3<float_typ
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
void Vector3<float_type>::ProjectToPlane(const Vector3& rclBase,
|
||||
const Vector3& rclNorm,
|
||||
Vector3& rclProj) const
|
||||
void Vector3<float_type>::ProjectToPlane(
|
||||
const Vector3& rclBase,
|
||||
const Vector3& rclNorm,
|
||||
Vector3& rclProj
|
||||
) const
|
||||
{
|
||||
Vector3<float_type> clTemp(rclNorm);
|
||||
rclProj = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
float_type Vector3<float_type>::DistanceToPlane(const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclNorm) const
|
||||
float_type Vector3<float_type>::DistanceToPlane(
|
||||
const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclNorm
|
||||
) const
|
||||
{
|
||||
return ((*this - rclBase) * rclNorm) / rclNorm.Length();
|
||||
}
|
||||
@@ -283,8 +291,10 @@ float_type Vector3<float_type>::Length() const
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
float_type Vector3<float_type>::DistanceToLine(const Vector3<float_type>& base,
|
||||
const Vector3<float_type>& dir) const
|
||||
float_type Vector3<float_type>::DistanceToLine(
|
||||
const Vector3<float_type>& base,
|
||||
const Vector3<float_type>& dir
|
||||
) const
|
||||
{
|
||||
// clang-format off
|
||||
return static_cast<float_type>(std::fabs((dir % Vector3(*this - base)).Length() / dir.Length()));
|
||||
@@ -292,8 +302,10 @@ float_type Vector3<float_type>::DistanceToLine(const Vector3<float_type>& base,
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
Vector3<float_type> Vector3<float_type>::DistanceToLineSegment(const Vector3& rclP1,
|
||||
const Vector3& rclP2) const
|
||||
Vector3<float_type> Vector3<float_type>::DistanceToLineSegment(
|
||||
const Vector3& rclP1,
|
||||
const Vector3& rclP2
|
||||
) const
|
||||
{
|
||||
float_type len2 = Base::DistanceP2(rclP1, rclP2);
|
||||
if (len2 == 0) {
|
||||
@@ -309,15 +321,19 @@ Vector3<float_type> Vector3<float_type>::DistanceToLineSegment(const Vector3& rc
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
Vector3<float_type>& Vector3<float_type>::ProjectToLine(const Vector3<float_type>& rclPoint,
|
||||
const Vector3<float_type>& rclLine)
|
||||
Vector3<float_type>& Vector3<float_type>::ProjectToLine(
|
||||
const Vector3<float_type>& rclPoint,
|
||||
const Vector3<float_type>& rclLine
|
||||
)
|
||||
{
|
||||
return (*this = ((((rclPoint * rclLine) / rclLine.Sqr()) * rclLine) - rclPoint));
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
Vector3<float_type> Vector3<float_type>::Perpendicular(const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclDir) const
|
||||
Vector3<float_type> Vector3<float_type>::Perpendicular(
|
||||
const Vector3<float_type>& rclBase,
|
||||
const Vector3<float_type>& rclDir
|
||||
) const
|
||||
{
|
||||
float_type t = ((*this - rclBase) * rclDir) / (rclDir * rclDir);
|
||||
return rclBase + t * rclDir;
|
||||
@@ -490,9 +506,11 @@ float_type Vector3<float_type>::GetAngleOriented(const Vector3& rcVect, const Ve
|
||||
}
|
||||
|
||||
template<class float_type>
|
||||
void Vector3<float_type>::TransformToCoordinateSystem(const Vector3& rclBase,
|
||||
const Vector3& rclDirX,
|
||||
const Vector3& rclDirY)
|
||||
void Vector3<float_type>::TransformToCoordinateSystem(
|
||||
const Vector3& rclBase,
|
||||
const Vector3& rclDirX,
|
||||
const Vector3& rclDirY
|
||||
)
|
||||
{
|
||||
Vector3 clVectX;
|
||||
Vector3 clVectY;
|
||||
|
||||
@@ -144,8 +144,10 @@ public:
|
||||
//@}
|
||||
|
||||
/// Check if Vector is on a line segment
|
||||
[[nodiscard]] bool IsOnLineSegment(const Vector3<float_type>& startVct,
|
||||
const Vector3<float_type>& endVct) const;
|
||||
[[nodiscard]] bool IsOnLineSegment(
|
||||
const Vector3<float_type>& startVct,
|
||||
const Vector3<float_type>& endVct
|
||||
) const;
|
||||
|
||||
/** @name Modification */
|
||||
//@{
|
||||
@@ -184,9 +186,11 @@ public:
|
||||
* vector \a vector rclDirX and vector \a vector rclDirY.
|
||||
* \note \a rclDirX must be perpendicular to \a rclDirY, i.e. \a rclDirX * \a rclDirY = 0..
|
||||
*/
|
||||
void TransformToCoordinateSystem(const Vector3& rclBase,
|
||||
const Vector3& rclDirX,
|
||||
const Vector3& rclDirY);
|
||||
void TransformToCoordinateSystem(
|
||||
const Vector3& rclBase,
|
||||
const Vector3& rclDirX,
|
||||
const Vector3& rclDirY
|
||||
);
|
||||
/**
|
||||
* @brief IsEqual
|
||||
* @param rclPnt
|
||||
@@ -248,8 +252,7 @@ Vector3<float_type> const Vector3<float_type>::UnitZ(0.0, 0.0, 1.0);
|
||||
|
||||
/// Returns the distance between two points
|
||||
template<class float_type>
|
||||
[[nodiscard]] inline float_type Distance(const Vector3<float_type>& v1,
|
||||
const Vector3<float_type>& v2)
|
||||
[[nodiscard]] inline float_type Distance(const Vector3<float_type>& v1, const Vector3<float_type>& v2)
|
||||
{
|
||||
float_type x = v1.x - v2.x;
|
||||
float_type y = v1.y - v2.y;
|
||||
@@ -259,8 +262,7 @@ template<class float_type>
|
||||
|
||||
/// Returns the squared distance between two points
|
||||
template<class float_type>
|
||||
[[nodiscard]] inline float_type DistanceP2(const Vector3<float_type>& v1,
|
||||
const Vector3<float_type>& v2)
|
||||
[[nodiscard]] inline float_type DistanceP2(const Vector3<float_type>& v1, const Vector3<float_type>& v2)
|
||||
{
|
||||
float_type x = v1.x - v2.x;
|
||||
float_type y = v1.y - v2.y;
|
||||
@@ -270,8 +272,7 @@ template<class float_type>
|
||||
|
||||
/// Multiplication of scalar with vector.
|
||||
template<class float_type>
|
||||
[[nodiscard]] inline Vector3<float_type> operator*(float_type fFac,
|
||||
const Vector3<float_type>& rcVct)
|
||||
[[nodiscard]] inline Vector3<float_type> operator*(float_type fFac, const Vector3<float_type>& rcVct)
|
||||
{
|
||||
return Vector3<float_type>(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac);
|
||||
}
|
||||
|
||||
@@ -268,9 +268,11 @@ PyObject* VectorPy::mapping_subscript(PyObject* self, PyObject* item)
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Vector indices must be integers or slices, not %.200s",
|
||||
Py_TYPE(item)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"Vector indices must be integers or slices, not %.200s",
|
||||
Py_TYPE(item)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -740,10 +742,12 @@ PyObject* VectorPy::number_divide_handler(PyObject* self, PyObject* other)
|
||||
// slots of the PyNumberMethods structure. So, it must be explicitly
|
||||
// filered out here.
|
||||
if (PyObject_TypeCheck(other, &(VectorPy::Type))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for /: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for /: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -758,44 +762,51 @@ PyObject* VectorPy::number_divide_handler(PyObject* self, PyObject* other)
|
||||
return new VectorPy(vec);
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for /: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for /: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_remainder_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
if (PyObject_TypeCheck(self, &(VectorPy::Type))
|
||||
&& PyObject_TypeCheck(other, &(VectorPy::Type))) {
|
||||
if (PyObject_TypeCheck(self, &(VectorPy::Type)) && PyObject_TypeCheck(other, &(VectorPy::Type))) {
|
||||
Vector3d a = static_cast<VectorPy*>(self)->value();
|
||||
Vector3d b = static_cast<VectorPy*>(other)->value();
|
||||
return new VectorPy(a % b);
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for %%: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for %%: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_divmod_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for divmod(): '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for divmod(): '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_power_handler(PyObject* self, PyObject* other, PyObject* /*arg*/)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for ** or pow(): '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for ** or pow(): '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -848,61 +859,75 @@ PyObject* VectorPy::number_invert_handler(PyObject* self)
|
||||
|
||||
PyObject* VectorPy::number_lshift_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for <<: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for <<: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_rshift_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for >>: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for >>: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_and_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for &: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for &: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_xor_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for ^: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for ^: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_or_handler(PyObject* self, PyObject* other)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported operand type(s) for |: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"unsupported operand type(s) for |: '%s' and '%s'",
|
||||
Py_TYPE(self)->tp_name,
|
||||
Py_TYPE(other)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_int_handler(PyObject* self)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"int() argument must be a string or a number, not '%s'",
|
||||
Py_TYPE(self)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"int() argument must be a string or a number, not '%s'",
|
||||
Py_TYPE(self)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* VectorPy::number_float_handler(PyObject* self)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"float() argument must be a string or a number, not '%s'",
|
||||
Py_TYPE(self)->tp_name);
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"float() argument must be a string or a number, not '%s'",
|
||||
Py_TYPE(self)->tp_name
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,9 @@ void perspectiveTransform(const Base::Matrix4D& mat, Vec& pnt)
|
||||
double m31 = mat[3][1];
|
||||
double m32 = mat[3][2];
|
||||
double m33 = mat[3][3];
|
||||
double ww = (static_cast<double>(pnt.x) * m30 + static_cast<double>(pnt.y) * m31
|
||||
+ static_cast<double>(pnt.z) * m32 + m33);
|
||||
double ww
|
||||
= (static_cast<double>(pnt.x) * m30 + static_cast<double>(pnt.y) * m31
|
||||
+ static_cast<double>(pnt.z) * m32 + m33);
|
||||
|
||||
mat.multVec(pnt, pnt);
|
||||
pnt /= static_cast<typename Vec::num_type>(ww);
|
||||
|
||||
@@ -59,8 +59,9 @@ private:
|
||||
class UniqueFileNameManager: public UniqueNameManager
|
||||
{
|
||||
protected:
|
||||
std::string::const_reverse_iterator
|
||||
getNameSuffixStartPosition(const std::string& name) const override
|
||||
std::string::const_reverse_iterator getNameSuffixStartPosition(
|
||||
const std::string& name
|
||||
) const override
|
||||
{
|
||||
// This is an awkward way to do this, because the FileInfo class only yields pieces of
|
||||
// the path, not delimiter positions. We can't just use fi.extension().size() because
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
using namespace XERCES_CPP_NAMESPACE;
|
||||
#else
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
@@ -42,11 +42,10 @@ void XMLTools::initialize()
|
||||
{
|
||||
if (!transcoder) {
|
||||
XMLTransService::Codes res {};
|
||||
transcoder.reset(XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
|
||||
XMLRecognizer::UTF_8,
|
||||
res,
|
||||
4096,
|
||||
XMLPlatformUtils::fgMemoryManager));
|
||||
transcoder.reset(
|
||||
XMLPlatformUtils::fgTransService
|
||||
->makeNewTranscoderFor(XMLRecognizer::UTF_8, res, 4096, XMLPlatformUtils::fgMemoryManager)
|
||||
);
|
||||
if (res != XMLTransService::Ok) {
|
||||
throw Base::UnicodeError("Can't create transcoder");
|
||||
}
|
||||
@@ -67,12 +66,14 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
|
||||
XMLSize_t inputLength = XMLString::stringLen(toTranscode);
|
||||
|
||||
while (inputLength) {
|
||||
outputLength = transcoder->transcodeTo(toTranscode + offset,
|
||||
inputLength,
|
||||
outBuff,
|
||||
128,
|
||||
eaten,
|
||||
XMLTranscoder::UnRep_RepChar);
|
||||
outputLength = transcoder->transcodeTo(
|
||||
toTranscode + offset,
|
||||
inputLength,
|
||||
outBuff,
|
||||
128,
|
||||
eaten,
|
||||
XMLTranscoder::UnRep_RepChar
|
||||
);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
|
||||
str.append(reinterpret_cast<const char*>(outBuff), outputLength);
|
||||
offset += eaten;
|
||||
@@ -106,12 +107,8 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
|
||||
unsigned char* charSizes = new unsigned char[inputLength];
|
||||
while (inputLength) {
|
||||
outputLength = transcoder->transcodeFrom(xmlBytes + offset,
|
||||
inputLength,
|
||||
outBuff,
|
||||
128,
|
||||
eaten,
|
||||
charSizes);
|
||||
outputLength
|
||||
= transcoder->transcodeFrom(xmlBytes + offset, inputLength, outBuff, 128, eaten, charSizes);
|
||||
str.append(outBuff, outputLength);
|
||||
offset += eaten;
|
||||
inputLength -= eaten;
|
||||
@@ -133,9 +130,11 @@ void XMLTools::terminate()
|
||||
|
||||
void* XStrMemoryManager::allocate(XMLSize_t size)
|
||||
{
|
||||
auto ptr = ::operator new(static_cast<size_t>(size),
|
||||
static_cast<std::align_val_t>(alignof(XMLCh)),
|
||||
std::nothrow);
|
||||
auto ptr = ::operator new(
|
||||
static_cast<size_t>(size),
|
||||
static_cast<std::align_val_t>(alignof(XMLCh)),
|
||||
std::nothrow
|
||||
);
|
||||
if (ptr == nullptr && size != 0) {
|
||||
throw XERCES_CPP_NAMESPACE::OutOfMemoryException();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <FCGlobal.h>
|
||||
|
||||
#ifndef XERCES_CPP_NAMESPACE_BEGIN
|
||||
#define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
# define XERCES_CPP_NAMESPACE_QUALIFIER
|
||||
namespace XERCES_CPP_NAMESPACE
|
||||
{
|
||||
class DOMNode;
|
||||
@@ -171,8 +171,7 @@ class XStr
|
||||
public:
|
||||
/// Constructors and Destructor
|
||||
explicit XStr(const char* const toTranscode);
|
||||
explicit XStr(const char* const toTranscode,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr);
|
||||
explicit XStr(const char* const toTranscode, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr);
|
||||
~XStr();
|
||||
|
||||
|
||||
@@ -191,8 +190,7 @@ inline XStr::XStr(const char* const toTranscode)
|
||||
: XStr(toTranscode, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager)
|
||||
{}
|
||||
|
||||
inline XStr::XStr(const char* const toTranscode,
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr)
|
||||
inline XStr::XStr(const char* const toTranscode, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr)
|
||||
: fUnicodeForm(XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode, memMgr))
|
||||
, memMgr(memMgr)
|
||||
{}
|
||||
@@ -208,11 +206,11 @@ inline XStr::~XStr()
|
||||
// XStrLiteral macro use local memory manager instance to prevent segfault on releasing cached
|
||||
// string because xerces default memory manager is already deleted when destructing local static
|
||||
// variable.
|
||||
#define XStrLiteral(literal) \
|
||||
([]() -> const XStr& { \
|
||||
static XStrMemoryManager memMgr; \
|
||||
static const XStr str {literal, &memMgr}; \
|
||||
return str; \
|
||||
#define XStrLiteral(literal) \
|
||||
([]() -> const XStr& { \
|
||||
static XStrMemoryManager memMgr; \
|
||||
static const XStr str {literal, &memMgr}; \
|
||||
return str; \
|
||||
}())
|
||||
|
||||
|
||||
@@ -254,10 +252,10 @@ inline XUTF8Str::~XUTF8Str() = default;
|
||||
// Uses the compiler to create a cache of transcoded string literals so that each subsequent call
|
||||
// can reuse the data from the lambda's initial creation. Permits the same usage as
|
||||
// XStr("literal").unicodeForm()
|
||||
#define XUTF8StrLiteral(literal) \
|
||||
([]() -> const XUTF8Str& { \
|
||||
static const XUTF8Str str {literal}; \
|
||||
return str; \
|
||||
#define XUTF8StrLiteral(literal) \
|
||||
([]() -> const XUTF8Str& { \
|
||||
static const XUTF8Str str {literal}; \
|
||||
return str; \
|
||||
}())
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
@@ -72,8 +72,8 @@ std::istream* ZipHeader::getInputStream(const std::string& entry_name, MatchPath
|
||||
|
||||
return new zipios::ZipInputStream(
|
||||
_input,
|
||||
static_cast<const zipios::ZipCDirEntry*>(ent.get())->getLocalHeaderOffset()
|
||||
+ _vs.startOffset());
|
||||
static_cast<const zipios::ZipCDirEntry*>(ent.get())->getLocalHeaderOffset() + _vs.startOffset()
|
||||
);
|
||||
}
|
||||
|
||||
bool ZipHeader::init(std::istream& _zipfile)
|
||||
@@ -108,15 +108,19 @@ bool ZipHeader::readCentralDirectory(std::istream& _zipfile)
|
||||
if (!_zipfile) {
|
||||
if (_zipfile.bad()) {
|
||||
throw zipios::IOException(
|
||||
"Error reading zip file while reading zip file central directory");
|
||||
"Error reading zip file while reading zip file central directory"
|
||||
);
|
||||
}
|
||||
if (_zipfile.fail()) {
|
||||
throw zipios::FCollException("Zip file consistency problem. Failure while reading "
|
||||
"zip file central directory");
|
||||
throw zipios::FCollException(
|
||||
"Zip file consistency problem. Failure while reading "
|
||||
"zip file central directory"
|
||||
);
|
||||
}
|
||||
if (_zipfile.eof()) {
|
||||
throw zipios::IOException(
|
||||
"Premature end of file while reading zip file central directory");
|
||||
"Premature end of file while reading zip file central directory"
|
||||
);
|
||||
}
|
||||
}
|
||||
++entry_num;
|
||||
@@ -128,15 +132,19 @@ bool ZipHeader::readCentralDirectory(std::istream& _zipfile)
|
||||
_vs.vseekg(_zipfile, 0, std::ios::end);
|
||||
int remaining = static_cast<int>(_vs.vtellg(_zipfile)) - pos;
|
||||
if (remaining != _eocd.eocdOffSetFromEnd()) {
|
||||
throw zipios::FCollException("Zip file consistency problem. Zip file data fields are "
|
||||
"inconsistent with zip file layout");
|
||||
throw zipios::FCollException(
|
||||
"Zip file consistency problem. Zip file data fields are "
|
||||
"inconsistent with zip file layout"
|
||||
);
|
||||
}
|
||||
|
||||
// Consistency check 2, are local headers consistent with
|
||||
// cd headers
|
||||
if (!confirmLocalHeaders(_zipfile)) {
|
||||
throw zipios::FCollException("Zip file consistency problem. Zip file data fields are "
|
||||
"inconsistent with zip file layout");
|
||||
throw zipios::FCollException(
|
||||
"Zip file consistency problem. Zip file data fields are "
|
||||
"inconsistent with zip file layout"
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -25,26 +25,26 @@
|
||||
|
||||
#include <sstream>
|
||||
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-register"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
#include "PyExport.h"
|
||||
#include "Exception.h"
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-register"
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
# endif
|
||||
# include "PyExport.h"
|
||||
# include "Exception.h"
|
||||
namespace Swig_python
|
||||
{
|
||||
#define SWIG_PYTHON_NO_BUILD_NONE
|
||||
#include <swigpyrun.h>
|
||||
#include "swigpyrun.inl"
|
||||
# define SWIG_PYTHON_NO_BUILD_NONE
|
||||
# include <swigpyrun.h>
|
||||
# include "swigpyrun.inl"
|
||||
} // namespace Swig_python
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
#endif // HAVE_SWIG
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
#include "GuiApplicationNativeEventAware.h"
|
||||
|
||||
std::vector<int> Gui::GuiAbstractNativeEvent::motionDataArray(6,0);
|
||||
std::vector<int> Gui::GuiAbstractNativeEvent::motionDataArray(6, 0);
|
||||
Gui::GUIApplicationNativeEventAware* Gui::GuiAbstractNativeEvent::mainApp;
|
||||
|
||||
Gui::GuiAbstractNativeEvent::GuiAbstractNativeEvent(GUIApplicationNativeEventAware *app)
|
||||
: QObject(app)
|
||||
Gui::GuiAbstractNativeEvent::GuiAbstractNativeEvent(GUIApplicationNativeEventAware* app)
|
||||
: QObject(app)
|
||||
{
|
||||
mainApp = app;
|
||||
mainApp = app;
|
||||
}
|
||||
|
||||
Gui::GuiAbstractNativeEvent::~GuiAbstractNativeEvent()
|
||||
|
||||
@@ -30,24 +30,26 @@ class QMainWindow;
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
class GUIApplicationNativeEventAware;
|
||||
class GUIApplicationNativeEventAware;
|
||||
|
||||
class GuiAbstractNativeEvent : public QObject
|
||||
{
|
||||
class GuiAbstractNativeEvent: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuiAbstractNativeEvent(GUIApplicationNativeEventAware *app);
|
||||
~GuiAbstractNativeEvent() override =0;
|
||||
virtual void initSpaceball(QMainWindow *window)=0;
|
||||
private:
|
||||
GuiAbstractNativeEvent();
|
||||
GuiAbstractNativeEvent(const GuiAbstractNativeEvent&);
|
||||
GuiAbstractNativeEvent& operator=(const GuiAbstractNativeEvent&);
|
||||
protected:
|
||||
static GUIApplicationNativeEventAware *mainApp;
|
||||
static std::vector<int>motionDataArray;
|
||||
};
|
||||
}
|
||||
public:
|
||||
explicit GuiAbstractNativeEvent(GUIApplicationNativeEventAware* app);
|
||||
~GuiAbstractNativeEvent() override = 0;
|
||||
virtual void initSpaceball(QMainWindow* window) = 0;
|
||||
|
||||
private:
|
||||
GuiAbstractNativeEvent();
|
||||
GuiAbstractNativeEvent(const GuiAbstractNativeEvent&);
|
||||
GuiAbstractNativeEvent& operator=(const GuiAbstractNativeEvent&);
|
||||
|
||||
protected:
|
||||
static GUIApplicationNativeEventAware* mainApp;
|
||||
static std::vector<int> motionDataArray;
|
||||
};
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
#endif //GUIABSTRACTNATIVEEVENT_H
|
||||
#endif // GUIABSTRACTNATIVEEVENT_H
|
||||
|
||||
@@ -32,27 +32,32 @@
|
||||
|
||||
#include <spnav.h>
|
||||
|
||||
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
|
||||
: GuiAbstractNativeEvent(app)
|
||||
{
|
||||
}
|
||||
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware* app)
|
||||
: GuiAbstractNativeEvent(app)
|
||||
{}
|
||||
|
||||
Gui::GuiNativeEvent::~GuiNativeEvent()
|
||||
{
|
||||
if (spnav_close())
|
||||
if (spnav_close()) {
|
||||
Base::Console().log("Couldn't disconnect from spacenav daemon\n");
|
||||
else
|
||||
}
|
||||
else {
|
||||
Base::Console().log("Disconnected from spacenav daemon\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
|
||||
void Gui::GuiNativeEvent::initSpaceball(QMainWindow* window)
|
||||
{
|
||||
Q_UNUSED(window)
|
||||
if (spnav_open() == -1) {
|
||||
Base::Console().log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
|
||||
} else {
|
||||
Base::Console().log(
|
||||
"Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n"
|
||||
);
|
||||
}
|
||||
else {
|
||||
Base::Console().log("Connected to spacenav daemon\n");
|
||||
QSocketNotifier* SpacenavNotifier = new QSocketNotifier(spnav_fd(), QSocketNotifier::Read, this);
|
||||
QSocketNotifier* SpacenavNotifier
|
||||
= new QSocketNotifier(spnav_fd(), QSocketNotifier::Read, this);
|
||||
connect(SpacenavNotifier, SIGNAL(activated(int)), this, SLOT(pollSpacenav()));
|
||||
mainApp->setSpaceballPresent(true);
|
||||
}
|
||||
@@ -61,12 +66,9 @@ void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
|
||||
void Gui::GuiNativeEvent::pollSpacenav()
|
||||
{
|
||||
spnav_event ev;
|
||||
while(spnav_poll_event(&ev))
|
||||
{
|
||||
switch (ev.type)
|
||||
{
|
||||
case SPNAV_EVENT_MOTION:
|
||||
{
|
||||
while (spnav_poll_event(&ev)) {
|
||||
switch (ev.type) {
|
||||
case SPNAV_EVENT_MOTION: {
|
||||
motionDataArray[0] = -ev.motion.x;
|
||||
motionDataArray[1] = -ev.motion.z;
|
||||
motionDataArray[2] = -ev.motion.y;
|
||||
@@ -76,8 +78,7 @@ void Gui::GuiNativeEvent::pollSpacenav()
|
||||
mainApp->postMotionEvent(motionDataArray);
|
||||
break;
|
||||
}
|
||||
case SPNAV_EVENT_BUTTON:
|
||||
{
|
||||
case SPNAV_EVENT_BUTTON: {
|
||||
mainApp->postButtonEvent(ev.button.bnum, ev.button.press);
|
||||
break;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user