diff --git a/apps/website-generator/main.cpp b/apps/website-generator/main.cpp index 65a8dde..33fa709 100644 --- a/apps/website-generator/main.cpp +++ b/apps/website-generator/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) args->recordLaunchPath(); WebsiteGenerator generator; - generator.findProject(args->getArg(1)); + generator.findProject(args->getArgs()[1]); generator.readConfig(); diff --git a/plugins/quantum_computing/src/visuals/BlochSphereNode.cpp b/plugins/quantum_computing/src/visuals/BlochSphereNode.cpp index 741c2ff..14b4b62 100644 --- a/plugins/quantum_computing/src/visuals/BlochSphereNode.cpp +++ b/plugins/quantum_computing/src/visuals/BlochSphereNode.cpp @@ -41,7 +41,8 @@ void BlochSphereNode::update(SceneInfo* sceneInfo) mOuterCircle = std::make_unique(loc, mSize/2.0); const auto end_point_x = Point(loc.getX() + 1.2 * mSize / 2.0, loc.getY()); - mXAxis = std::make_unique(loc, { end_point_x }); + const std::vector points{end_point_x }; + mXAxis = std::make_unique(loc, points); mCentreCircle = std::make_unique(loc, mSize / 50.0); mCentreCircle->setFillColor(Color(0, 0, 0)); @@ -49,5 +50,6 @@ void BlochSphereNode::update(SceneInfo* sceneInfo) addChild(mInnerCircle.get()); addChild(mOuterCircle.get()); + addChild(mXAxis.get()); addChild(mCentreCircle.get()); } \ No newline at end of file diff --git a/src/compiler/template_engine/TemplateFile.cpp b/src/compiler/template_engine/TemplateFile.cpp index f28e566..b8474e8 100644 --- a/src/compiler/template_engine/TemplateFile.cpp +++ b/src/compiler/template_engine/TemplateFile.cpp @@ -73,7 +73,7 @@ void TemplateFile::onTextSpanFinished() mWorkingLineContent.clear(); } -unsigned TemplateFile::checkForStatement(const std::string& lineSection) +std::size_t TemplateFile::checkForStatement(const std::string& lineSection) { if (lineSection.empty()) { @@ -81,7 +81,7 @@ unsigned TemplateFile::checkForStatement(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; if (Lexer::matchPattern("{%@%}", lineSection, '@', hits)) { if (hits.size() == 1) @@ -97,7 +97,7 @@ unsigned TemplateFile::checkForStatement(const std::string& lineSection) return hit_size; } -unsigned TemplateFile::checkForExpression(const std::string& lineSection) +std::size_t TemplateFile::checkForExpression(const std::string& lineSection) { if (lineSection.empty()) { @@ -105,7 +105,7 @@ unsigned TemplateFile::checkForExpression(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; if (Lexer::matchPattern("{{@}}", lineSection, '@', hits)) { if (hits.size() == 1) @@ -123,7 +123,7 @@ unsigned TemplateFile::checkForExpression(const std::string& lineSection) void TemplateFile::processLine(const std::string& line) { - unsigned line_position = 0; + std::size_t line_position = 0; mWorkingLineContent.clear(); while(line_position < line.size()) { diff --git a/src/compiler/template_engine/TemplateFile.h b/src/compiler/template_engine/TemplateFile.h index 46209ea..717d73b 100644 --- a/src/compiler/template_engine/TemplateFile.h +++ b/src/compiler/template_engine/TemplateFile.h @@ -27,9 +27,9 @@ public: void loadContent(); private: - unsigned checkForStatement(const std::string& lineSection); + std::size_t checkForStatement(const std::string& lineSection); - unsigned checkForExpression(const std::string& lineSection); + std::size_t checkForExpression(const std::string& lineSection); void onTextSpanFinished(); diff --git a/src/compression/huffman/HuffmanCodeLengthTable.cpp b/src/compression/huffman/HuffmanCodeLengthTable.cpp index d3470b1..fc1ad5e 100644 --- a/src/compression/huffman/HuffmanCodeLengthTable.cpp +++ b/src/compression/huffman/HuffmanCodeLengthTable.cpp @@ -218,7 +218,7 @@ unsigned HuffmanCodeLengthTable::mapToDeflateIndex(unsigned index) const } } -unsigned HuffmanCodeLengthTable::getNumCodeLengths() const +std::size_t HuffmanCodeLengthTable::getNumCodeLengths() const { return mTree.getNumCodeLengths(); } diff --git a/src/compression/huffman/HuffmanCodeLengthTable.h b/src/compression/huffman/HuffmanCodeLengthTable.h index f8fff09..ea8b5ae 100644 --- a/src/compression/huffman/HuffmanCodeLengthTable.h +++ b/src/compression/huffman/HuffmanCodeLengthTable.h @@ -30,7 +30,7 @@ public: const std::vector getCompressedLengthCounts() const; - unsigned getNumCodeLengths() const; + std::size_t getNumCodeLengths() const; unsigned getCodeLength(std::size_t treeIndex) const; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9acd7c2..1435e0a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,6 +1,6 @@ set(MODULE_NAME core) -list(APPEND core_HEADERS +list(APPEND HEADERS AbstractApp.h AbstractNamedItem.h AbstractWebApp.h @@ -8,20 +8,22 @@ list(APPEND core_HEADERS Event.h Color.h CommandLineArgs.h + encoding/ByteUtils.h + encoding/StringUtils.h + encoding/UnicodeUtils.h loggers/FileLogger.h file_utilities/Directory.h file_utilities/File.h file_utilities/FileFormats.h file_utilities/PathUtils.h - StringUtils.h http/HttpResponse.h http/HttpHeader.h http/HttpRequest.h serializers/TomlReader.h + Win32BaseIncludes.h ) -list(APPEND core_LIB_INCLUDES - ByteUtils.cpp +list(APPEND LIB_INCLUDES Event.cpp Dictionary.cpp Color.cpp @@ -35,7 +37,9 @@ list(APPEND core_LIB_INCLUDES file_utilities/PathUtils.cpp memory/SharedMemory.cpp RandomUtils.cpp - StringUtils.cpp + encoding/StringUtils.cpp + encoding/ByteUtils.cpp + encoding/UnicodeUtils.cpp streams/BinaryStream.cpp streams/BitStream.cpp streams/InputBitStream.cpp @@ -46,10 +50,11 @@ list(APPEND core_LIB_INCLUDES http/HttpRequest.cpp serializers/TomlReader.cpp) -add_library(${MODULE_NAME} SHARED ${core_LIB_INCLUDES} ${core_HEADERS}) +add_library(${MODULE_NAME} SHARED ${LIB_INCLUDES} ${HEADERS}) target_include_directories(${MODULE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/encoding ${CMAKE_CURRENT_SOURCE_DIR}/file_utilities ${CMAKE_CURRENT_SOURCE_DIR}/loggers ${CMAKE_CURRENT_SOURCE_DIR}/memory diff --git a/src/core/CommandLineArgs.cpp b/src/core/CommandLineArgs.cpp index de4392f..dcc35a5 100644 --- a/src/core/CommandLineArgs.cpp +++ b/src/core/CommandLineArgs.cpp @@ -1,9 +1,8 @@ #include "CommandLineArgs.h" -#include "StringUtils.h" -#ifdef _WIN32 -#include "Windows.h" -#endif +#include "UnicodeUtils.h" + +#include "Win32BaseIncludes.h" CommandLineArgs::CommandLineArgs() : mArugments(), @@ -25,7 +24,7 @@ void CommandLineArgs::initialize(CommandLineArgs* args) std::vector windowsArgs(nArgs); for (int idx = 0; idx < nArgs; idx++) { - windowsArgs[idx] = StringUtils::convert(szArglist[idx]); + windowsArgs[idx] = UnicodeUtils::utf16ToUtf8String(szArglist[idx]); } ::LocalFree(szArglist); @@ -71,7 +70,7 @@ std::vector CommandLineArgs::getUserArgs() const return user_args; } -const std::vector CommandLineArgs::getArgs() const +const std::vector CommandLineArgs::getArgs() const { return mArugments; } diff --git a/src/core/CommandLineArgs.h b/src/core/CommandLineArgs.h index 618789f..9a39346 100644 --- a/src/core/CommandLineArgs.h +++ b/src/core/CommandLineArgs.h @@ -1,4 +1,5 @@ #pragma once + #include #include #include @@ -15,15 +16,15 @@ public: const std::vector getArgs() const; + std::vector getUserArgs() const; + + static void initialize(CommandLineArgs* args); + void process(int argc, char *argv[]); void process(const std::vector& args); void recordLaunchPath(); - - std::vector getUserArgs() const; - - static void initialize(CommandLineArgs* args); private: std::vector mArugments; std::filesystem::path mLaunchPath; diff --git a/src/core/Win32BaseIncludes.h b/src/core/Win32BaseIncludes.h new file mode 100644 index 0000000..0c00f36 --- /dev/null +++ b/src/core/Win32BaseIncludes.h @@ -0,0 +1,13 @@ +#pragma once + +#ifndef UNICODE +#define UNICODE +#endif + +//#ifndef WIN32_LEAN_AND_MEAN +//#define WIN32_LEAN_AND_MEAN +//#endif + +#ifdef _WIN32 +#include "Windows.h" +#endif diff --git a/src/core/ByteUtils.cpp b/src/core/encoding/ByteUtils.cpp similarity index 100% rename from src/core/ByteUtils.cpp rename to src/core/encoding/ByteUtils.cpp diff --git a/src/core/ByteUtils.h b/src/core/encoding/ByteUtils.h similarity index 95% rename from src/core/ByteUtils.h rename to src/core/encoding/ByteUtils.h index 15ee90a..cb15b22 100644 --- a/src/core/ByteUtils.h +++ b/src/core/encoding/ByteUtils.h @@ -67,6 +67,6 @@ public: static bool CompareWords(char* buffer, const char* tag); static const int BYTE_FIRST_BIT = 0x40; // 1000 0000 - static const Word WORD_FIRST_BIT = 0x8000; // 1000 0000 - 0000 0000 + static const Word WORD_FIRST_BIT = static_cast(0x8000); // 1000 0000 - 0000 0000 static const Word WORD_LAST_BYTE = 0x00FF; // 0000 0000 - 1111 1111 }; diff --git a/src/core/StringUtils.cpp b/src/core/encoding/StringUtils.cpp similarity index 78% rename from src/core/StringUtils.cpp rename to src/core/encoding/StringUtils.cpp index a646f38..e1e56e3 100644 --- a/src/core/StringUtils.cpp +++ b/src/core/encoding/StringUtils.cpp @@ -5,10 +5,6 @@ #include #include -#ifdef _WIN32 -#include "Windows.h" -#endif - bool StringUtils::isAlphaNumeric(char c) { return std::isalnum(c); @@ -57,7 +53,7 @@ bool StringUtils::isWhitespaceOnly(const std::string& input) } } -unsigned StringUtils::countFirstConsecutiveHits(const std::string& input, char c) +std::size_t StringUtils::countFirstConsecutiveHits(const std::string& input, char c) { auto found_id = input.find(c); if(found_id == std::string::npos) @@ -66,8 +62,8 @@ unsigned StringUtils::countFirstConsecutiveHits(const std::string& input, char c } else { - unsigned count = 1; - for(unsigned idx=found_id+1; idx buffer(charsNeeded); - const auto charsConverted = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), (int)input.size(), &buffer[0], buffer.size()); - return std::wstring(&buffer[0], charsConverted); -#else - throw std::logic_error("Not implemented"); -#endif -} - std::string StringUtils::toPaddedString(unsigned numBytes, unsigned entry) { std::stringstream sstr; diff --git a/src/core/StringUtils.h b/src/core/encoding/StringUtils.h similarity index 87% rename from src/core/StringUtils.h rename to src/core/encoding/StringUtils.h index ba7ce52..e91010b 100644 --- a/src/core/StringUtils.h +++ b/src/core/encoding/StringUtils.h @@ -16,11 +16,7 @@ public: static constexpr char SINGLE_QUOTE = '\''; static constexpr char COLON = ':'; - static unsigned countFirstConsecutiveHits(const std::string& input, char c); - - static std::string convert(const std::wstring& input); - - static std::wstring convert(const std::string& input); + static std::size_t countFirstConsecutiveHits(const std::string& input, char c); static bool isAlphaNumeric(char c); diff --git a/src/core/encoding/UnicodeUtils.cpp b/src/core/encoding/UnicodeUtils.cpp new file mode 100644 index 0000000..5853d4d --- /dev/null +++ b/src/core/encoding/UnicodeUtils.cpp @@ -0,0 +1,40 @@ +#include "UnicodeUtils.h" + +#include "Win32BaseIncludes.h" + +#include + +std::string UnicodeUtils::utf16ToUtf8String(const std::wstring& input) +{ + if (input.empty()) + { + return std::string(); + } + +#ifdef _WIN32 + const auto size = ::WideCharToMultiByte(CP_UTF8, 0, &input[0], static_cast(input.size()), nullptr, 0, nullptr, nullptr); + + std::string result(size, 0); + ::WideCharToMultiByte(CP_UTF8, 0, &input[0], static_cast(input.size()), &result[0], size, nullptr, nullptr); + return result; +#else + throw std::logic_error("Not implemented"); +#endif +} + +std::wstring UnicodeUtils::utf8ToUtf16WString(const std::string& input) +{ + if (input.empty()) + { + return std::wstring(); + } + +#ifdef _WIN32 + const auto charsNeeded = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), static_cast(input.size()), nullptr, 0); + std::vector buffer(charsNeeded); + const auto charsConverted = ::MultiByteToWideChar(CP_UTF8, 0, input.data(), static_cast(input.size()), &buffer[0], static_cast(buffer.size())); + return std::wstring(&buffer[0], charsConverted); +#else + throw std::logic_error("Not implemented"); +#endif +} \ No newline at end of file diff --git a/src/core/encoding/UnicodeUtils.h b/src/core/encoding/UnicodeUtils.h new file mode 100644 index 0000000..48539be --- /dev/null +++ b/src/core/encoding/UnicodeUtils.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +class UnicodeUtils +{ +public: + static std::string utf16ToUtf8String(const std::wstring& input); + + static std::wstring utf8ToUtf16WString(const std::string& input); +}; \ No newline at end of file diff --git a/src/core/streams/InputBitStream.cpp b/src/core/streams/InputBitStream.cpp index c32ab53..75bd78f 100644 --- a/src/core/streams/InputBitStream.cpp +++ b/src/core/streams/InputBitStream.cpp @@ -21,7 +21,7 @@ std::optional InputBitStream::readNextByte() { if (mStream->good()) { - return mStream->get(); + return static_cast(mStream->get()); } else { diff --git a/src/fonts/BasicFontEngine.h b/src/fonts/BasicFontEngine.h index 3db266d..4afc8c4 100644 --- a/src/fonts/BasicFontEngine.h +++ b/src/fonts/BasicFontEngine.h @@ -9,7 +9,7 @@ class BasicFontEngine : public IFontEngine { virtual void initialize(){}; - virtual void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16){}; + virtual void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16){}; virtual std::unique_ptr loadGlyph(unsigned charCode){return nullptr;}; }; diff --git a/src/fonts/CMakeLists.txt b/src/fonts/CMakeLists.txt index a42bacd..2751084 100644 --- a/src/fonts/CMakeLists.txt +++ b/src/fonts/CMakeLists.txt @@ -14,6 +14,8 @@ list(APPEND fonts_LIB_INCLUDES FontGlyph.h IFont.h IFontEngine.h + BasicFontEngine.h + BasicFontEngine.cpp ) if(UNIX) diff --git a/src/fonts/FontsManager.cpp b/src/fonts/FontsManager.cpp index 7e87c7b..dfb7fbb 100644 --- a/src/fonts/FontsManager.cpp +++ b/src/fonts/FontsManager.cpp @@ -34,7 +34,7 @@ IFontEngine* FontsManager::getFontEngine() const return mFontEngine.get(); } -FontGlyph* FontsManager::getGlyph(const std::string& fontFace, int size, uint32_t c) +FontGlyph* FontsManager::getGlyph(const std::string& fontFace, float size, uint32_t c) { auto path = std::filesystem::path("truetype/liberation/LiberationSans-Regular.ttf"); diff --git a/src/fonts/FontsManager.h b/src/fonts/FontsManager.h index 2bbdc13..59aeda3 100644 --- a/src/fonts/FontsManager.h +++ b/src/fonts/FontsManager.h @@ -17,7 +17,7 @@ public: bool usesGlyphs() const; - FontGlyph* getGlyph(const std::string& fontFace, int size, uint32_t c); + FontGlyph* getGlyph(const std::string& fontFace, float size, uint32_t c); private: bool mUsesGlyphs{ false }; diff --git a/src/fonts/IFontEngine.h b/src/fonts/IFontEngine.h index ccfe7ea..644a92f 100644 --- a/src/fonts/IFontEngine.h +++ b/src/fonts/IFontEngine.h @@ -13,7 +13,7 @@ public: virtual void initialize(){}; - virtual void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) = 0; + virtual void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16) = 0; virtual std::unique_ptr loadGlyph(uint32_t charCode) = 0; }; diff --git a/src/fonts/directx/DirectWriteFontEngine.cpp b/src/fonts/directx/DirectWriteFontEngine.cpp index fe55846..10e05bb 100644 --- a/src/fonts/directx/DirectWriteFontEngine.cpp +++ b/src/fonts/directx/DirectWriteFontEngine.cpp @@ -1,7 +1,7 @@ #include "DirectWriteFontEngine.h" #include "FontGlyph.h" -#include "StringUtils.h" +#include "UnicodeUtils.h" #include "DirectWriteHelpers.h" @@ -24,10 +24,10 @@ void DirectWriteFontEngine::initializeOffScreenRenderer() pInterface->QueryInterface(IID_IOffScreenTextRenderer, &mOffScreenRenderer); } -void DirectWriteFontEngine::loadFontFaceFromName(const std::string& fontName, int penSize) +void DirectWriteFontEngine::loadFontFaceFromName(const std::string& fontName, float penSize) { - mDWriteFactory->CreateTextFormat(StringUtils::convert(fontName).c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, - penSize, L"en-us", &mTextFormat); + mDWriteFactory->CreateTextFormat(UnicodeUtils::utf8ToUtf16WString(fontName).c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, penSize, L"en-us", &mTextFormat); } std::unique_ptr DirectWriteFontEngine::loadGlyph(uint32_t charCode) @@ -45,7 +45,7 @@ std::unique_ptr DirectWriteFontEngine::getGlyphRunOutlines(con text.push_back(code); } - auto hr = mDWriteFactory->CreateTextLayout(text.c_str(), text.size(), mTextFormat.Get(), 50.0, 50.0, &mTextLayout); + auto hr = mDWriteFactory->CreateTextLayout(text.c_str(), static_cast(text.size()), mTextFormat.Get(), 50.0, 50.0, &mTextLayout); mTextLayout->Draw(nullptr, mOffScreenRenderer.Get(), 0.0, 0.0); diff --git a/src/fonts/directx/DirectWriteFontEngine.h b/src/fonts/directx/DirectWriteFontEngine.h index cd9e32e..6f01315 100644 --- a/src/fonts/directx/DirectWriteFontEngine.h +++ b/src/fonts/directx/DirectWriteFontEngine.h @@ -19,9 +19,9 @@ class DirectWriteFontEngine : public IFontEngine public: void initialize() override; - void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) override {}; + void loadFontFace(const std::filesystem::path& fontFile, float penSize = 16) override {}; - void loadFontFaceFromName(const std::string& fontName, int penSize = 16); + void loadFontFaceFromName(const std::string& fontName, float penSize = 16); std::unique_ptr loadGlyph(uint32_t charCode) override; diff --git a/src/geometry/CMakeLists.txt b/src/geometry/CMakeLists.txt index d450add..4f156b1 100644 --- a/src/geometry/CMakeLists.txt +++ b/src/geometry/CMakeLists.txt @@ -1,46 +1,53 @@ set(MODULE_NAME geometry) -list(APPEND geometry_LIB_INCLUDES +list(APPEND HEADERS AbstractGeometricItem.h Bounds.h - DiscretePoint.h - DiscretePoint.cpp Grid.h - Grid.cpp - Point.h - Point.cpp - Transform.cpp math/Linalg.h - math/Linalg.cpp math/Matrix.h - math/Matrix.cpp math/Vector.h - math/Vector.cpp path/Curve.h - path/Curve.cpp path/Line.h - path/Line.cpp path/LineSegment.h - path/LineSegment.cpp path/Path.h - path/Path.cpp path/PathElement.h + points/Point.h + points/PointCollection.h + points/DiscretePoint.h primitives/Circle.h - primitives/Circle.cpp primitives/Quad.h - primitives/Quad.cpp primitives/Rectangle.h - primitives/Rectangle.cpp primitives/Triangle.h +) + +list(APPEND LIB_INCLUDES + Grid.cpp + Transform.cpp + math/Linalg.cpp + math/Matrix.cpp + math/Vector.cpp + path/Curve.cpp + path/Line.cpp + path/LineSegment.cpp + path/Path.cpp + path/PathElement.cpp + points/Point.cpp + points/PointCollection.cpp + points/DiscretePoint.cpp + primitives/Circle.cpp + primitives/Quad.cpp + primitives/Rectangle.cpp primitives/Triangle.cpp ) -add_library(${MODULE_NAME} SHARED ${geometry_LIB_INCLUDES}) +add_library(${MODULE_NAME} SHARED ${LIB_INCLUDES} ${HEADERS}) target_include_directories(${MODULE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/math ${CMAKE_CURRENT_SOURCE_DIR}/path + ${CMAKE_CURRENT_SOURCE_DIR}/points ${CMAKE_CURRENT_SOURCE_DIR}/primitives ) diff --git a/src/geometry/path/Line.h b/src/geometry/path/Line.h index 23cce25..b4f18f5 100644 --- a/src/geometry/path/Line.h +++ b/src/geometry/path/Line.h @@ -17,6 +17,8 @@ public: Bounds getBounds() const override; + void sample(Grid* grid) const override {}; + private: Point mStartPoint; std::vector mPoints; diff --git a/src/geometry/path/Path.cpp b/src/geometry/path/Path.cpp index f299982..90e341b 100644 --- a/src/geometry/path/Path.cpp +++ b/src/geometry/path/Path.cpp @@ -1,6 +1,11 @@ #include "Path.h" -const std::vector Path::getElements() const +Path::~Path() +{ + +} + +const std::vector& Path::getElements() const { return mElements; } \ No newline at end of file diff --git a/src/geometry/path/Path.h b/src/geometry/path/Path.h index 5f28825..7c1bcbb 100644 --- a/src/geometry/path/Path.h +++ b/src/geometry/path/Path.h @@ -10,7 +10,8 @@ using PathElementPtr = std::unique_ptr; class Path : public AbstractGeometricItem { public: - const std::vector getElements() const; + ~Path(); + const std::vector& getElements() const; private: std::vector mElements; diff --git a/src/geometry/path/PathElement.cpp b/src/geometry/path/PathElement.cpp index e69de29..568527c 100644 --- a/src/geometry/path/PathElement.cpp +++ b/src/geometry/path/PathElement.cpp @@ -0,0 +1,6 @@ +#include "PathElement.h" + +PathElement::~PathElement() +{ + +} \ No newline at end of file diff --git a/src/geometry/path/PathElement.h b/src/geometry/path/PathElement.h index 42aad66..93a9286 100644 --- a/src/geometry/path/PathElement.h +++ b/src/geometry/path/PathElement.h @@ -5,5 +5,5 @@ class PathElement : public AbstractGeometricItem { public: - ~PathElement() = default; + ~PathElement(); }; \ No newline at end of file diff --git a/src/geometry/DiscretePoint.cpp b/src/geometry/points/DiscretePoint.cpp similarity index 100% rename from src/geometry/DiscretePoint.cpp rename to src/geometry/points/DiscretePoint.cpp diff --git a/src/geometry/DiscretePoint.h b/src/geometry/points/DiscretePoint.h similarity index 100% rename from src/geometry/DiscretePoint.h rename to src/geometry/points/DiscretePoint.h diff --git a/src/geometry/Point.cpp b/src/geometry/points/Point.cpp similarity index 82% rename from src/geometry/Point.cpp rename to src/geometry/points/Point.cpp index f9f1088..bb20266 100644 --- a/src/geometry/Point.cpp +++ b/src/geometry/points/Point.cpp @@ -1,5 +1,7 @@ #include "Point.h" +#include "Transform.h" + #include Point::Point(double x, double y, double z) @@ -77,16 +79,13 @@ double Point::getDeltaZ(const Point& point) const return point.getZ() - mZ; } -void Point::scale(double x, double y, double z) +void Point::apply(const Transform& transform) { - mX = x * mX; - mY = y * mY; - mZ = z * mZ; -} + mX -= transform.getLocation().getX(); + mY -= transform.getLocation().getY(); + mZ -= transform.getLocation().getZ(); -void Point::translate(double x, double y, double z) -{ - mX += x; - mY += y; - mZ += z; + mX *= transform.getScaleX(); + mY *= transform.getScaleY(); + mZ *= transform.getScaleZ(); } diff --git a/src/geometry/Point.h b/src/geometry/points/Point.h similarity index 86% rename from src/geometry/Point.h rename to src/geometry/points/Point.h index b9f204a..5f8b53d 100644 --- a/src/geometry/Point.h +++ b/src/geometry/points/Point.h @@ -4,6 +4,9 @@ #include "Vector.h" #include +#include + +class Transform; class Point { @@ -18,6 +21,8 @@ public: static std::shared_ptr Create(double x, double y, double z = 0); + void apply(const Transform& transform); + double getX() const; double getY() const; @@ -34,10 +39,6 @@ public: Vector getDelta(const Point& point) const; - void scale(double x, double y, double z = 1.0); - - void translate(double x, double y, double z = 0.0); - bool operator==(const Point& rhs) const { return (mX == rhs.mX) @@ -56,4 +57,4 @@ private: double mZ{0}; }; -using PointPtr = std::shared_ptr; +using PointPtr = std::unique_ptr; diff --git a/src/geometry/points/PointCollection.cpp b/src/geometry/points/PointCollection.cpp new file mode 100644 index 0000000..0be3812 --- /dev/null +++ b/src/geometry/points/PointCollection.cpp @@ -0,0 +1,15 @@ +#include "PointCollection.h" + +PointCollection::PointCollection(const std::vector points) + : mPoints(points) +{ + +} + +void PointCollection::apply(const Transform& transform) +{ + for (auto& point : mPoints) + { + point.apply(transform); + } +} \ No newline at end of file diff --git a/src/geometry/points/PointCollection.h b/src/geometry/points/PointCollection.h new file mode 100644 index 0000000..8fea69a --- /dev/null +++ b/src/geometry/points/PointCollection.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Point.h" +#include "Transform.h" + +class PointCollection +{ +public: + PointCollection(const std::vector points = {}); + + void apply(const Transform& transform); + +private: + std::vector mPoints; +}; diff --git a/src/graphics/RasterPainter.cpp b/src/graphics/RasterPainter.cpp index 174ca48..601dcad 100644 --- a/src/graphics/RasterPainter.cpp +++ b/src/graphics/RasterPainter.cpp @@ -6,7 +6,7 @@ RasterPainter::RasterPainter(DrawingContext* context) : AbstractPainter(context), - mGrid(std::make_unique >(ntk::Rectangle(Point(0, 0), Point(100, 100)))) + mGrid(std::make_unique(Bounds{0.0, 0.0, 100.0, 100.0})) { } @@ -15,7 +15,7 @@ void RasterPainter::paint() { const auto width = mDrawingContext->getSurface()->getWidth(); const auto height = mDrawingContext->getSurface()->getHeight(); - mGrid->resetBounds(ntk::Rectangle(Point(0, 0), Point(width, height))); + mGrid->resetBounds(Bounds{ 0.0, 0.0, static_cast(width), static_cast(height) }); /* for (unsigned idx=0; idx< context->getNumItems(); idx++) diff --git a/src/graphics/RasterPainter.h b/src/graphics/RasterPainter.h index 7ebfefb..586e447 100644 --- a/src/graphics/RasterPainter.h +++ b/src/graphics/RasterPainter.h @@ -1,11 +1,10 @@ #pragma once #include "AbstractPainter.h" + #include class DrawingContext; - -template class Grid; class RasterPainter : public AbstractPainter @@ -16,5 +15,5 @@ public: void paint() override; private: - std::unique_ptr > mGrid; + std::unique_ptr mGrid; }; diff --git a/src/graphics/directx/DirectXTextPainter.cpp b/src/graphics/directx/DirectXTextPainter.cpp index 9355219..29e11b8 100644 --- a/src/graphics/directx/DirectXTextPainter.cpp +++ b/src/graphics/directx/DirectXTextPainter.cpp @@ -10,10 +10,10 @@ #include "SceneText.h" #include "DirectX2dInterface.h" -#include "StringUtils.h" +#include "UnicodeUtils.h" #include "File.h" -#include +#include "Win32BaseIncludes.h" #include #include @@ -33,7 +33,7 @@ void DirectXTextPainter::setD2dInterface(DirectX2dInterface* d2dIterface) void DirectXTextPainter::updateTextFormat(const FontItem& font) { mD2dInterface->getDirectWriteFactory()->CreateTextFormat( - StringUtils::convert(font.getFaceName()).c_str(), + UnicodeUtils::utf8ToUtf16WString(font.getFaceName()).c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, @@ -53,7 +53,7 @@ void DirectXTextPainter::paint(SceneText* text, DrawingContext* context) updateTextFormat(text->getTextData().mFont); - auto content = StringUtils::convert(text->getTextData().mContent); + auto content = UnicodeUtils::utf8ToUtf16WString(text->getTextData().mContent); mD2dInterface->getRenderTarget()->DrawText(content.c_str(), static_cast(content.size()), mTextFormat.Get(), &textRect, mTextBrush.Get()); } diff --git a/src/image/png/PngWriter.cpp b/src/image/png/PngWriter.cpp index b2b4cc5..2a24c41 100644 --- a/src/image/png/PngWriter.cpp +++ b/src/image/png/PngWriter.cpp @@ -126,7 +126,7 @@ void PngWriter::writeDataChunks(const BufferBitStream& buffer) auto max_bytes{32000}; auto num_dat_chunks = num_bytes/max_bytes + 1; - unsigned offset = 0; + std::size_t offset = 0; for(std::size_t idx=0;idx getNodeIds() const = 0; + virtual std::vector getNodeIds() const = 0; void addVectorAttribute(const std::string& tag, const std::vector& values); std::vector getVectorAttribute(const std::string& tag) const; - void setIndex(std::size_t idx); - - virtual unsigned getNumNodes() const = 0; + virtual std::size_t getNumNodes() const = 0; virtual void associateWidthEdges() = 0; - virtual void replaceEdge(Edge* original, Edge* replacement) = 0; - - virtual std::vector getEdgeIds() const = 0; + virtual std::vector getEdgeIds() const = 0; virtual std::vector getNodeLocations(Orientation orientation = Orientation::CCW) const = 0; + virtual void replaceEdge(Edge* original, Edge* replacement) = 0; + + void setIndex(std::size_t idx); + protected: - unsigned mId{0}; + std::size_t mId{0}; std::unordered_map > mVectorAttributes; }; diff --git a/src/mesh/Edge.cpp b/src/mesh/Edge.cpp index 5fc6137..8803de6 100644 --- a/src/mesh/Edge.cpp +++ b/src/mesh/Edge.cpp @@ -2,14 +2,14 @@ #include "Node.h" -Edge::Edge(Node* node0, Node* node1, unsigned id) +Edge::Edge(Node* node0, Node* node1, std::size_t id) : mNode0(node0), mNode1(node1), mId(id) { } -std::unique_ptr Edge::Create(Node* node0, Node* node1, unsigned id) +std::unique_ptr Edge::Create(Node* node0, Node* node1, std::size_t id) { return std::make_unique(node0, node1, id); } @@ -19,12 +19,12 @@ Edge::~Edge() } -unsigned Edge::getNode0Id() const +std::size_t Edge::getNode0Id() const { return mNode0->getIndex(); } -unsigned Edge::getNode1Id() const +std::size_t Edge::getNode1Id() const { return mNode1->getIndex(); } @@ -75,7 +75,7 @@ Node* Edge::getOtherNode(Node* node) const } } -unsigned Edge::getId() const +std::size_t Edge::getId() const { return mId; } @@ -95,17 +95,17 @@ void Edge::clearConnectivity() mAssociatedFaceIds.clear(); } -unsigned Edge::getNumConnectedFaces() const +std::size_t Edge::getNumConnectedFaces() const { return mAssociatedFaceIds.size(); } -void Edge::associateFace(unsigned faceId) +void Edge::associateFace(std::size_t faceId) { mAssociatedFaceIds.push_back(faceId); } -unsigned Edge::getConnectedFaceId(std::size_t idx) const +std::size_t Edge::getConnectedFaceId(std::size_t idx) const { return mAssociatedFaceIds[idx]; } @@ -116,7 +116,7 @@ void Edge::associateWithNodes() mNode1->associateEdge(mId); } -void Edge::setIndex(unsigned idx) +void Edge::setIndex(std::size_t idx) { mId = idx; } diff --git a/src/mesh/Edge.h b/src/mesh/Edge.h index 83d7d9d..5f5a33f 100644 --- a/src/mesh/Edge.h +++ b/src/mesh/Edge.h @@ -14,33 +14,33 @@ public: DIRTY }; - Edge(Node* node0, Node* node1, unsigned id = 0); + Edge(Node* node0, Node* node1, std::size_t id = 0); ~Edge(); - static std::unique_ptr Create(Node* node0, Node* node1, unsigned id = 0); + static std::unique_ptr Create(Node* node0, Node* node1, std::size_t id = 0); - void associateFace(unsigned faceId); + void associateFace(std::size_t faceId); void associateWithNodes(); void clearConnectivity(); - unsigned getConnectedFaceId(std::size_t idx) const; + std::size_t getConnectedFaceId(std::size_t idx) const; State getState() const; - unsigned getId() const; + std::size_t getId() const; - unsigned getNode0Id() const; + std::size_t getNode0Id() const; - unsigned getNode1Id() const; + std::size_t getNode1Id() const; Node* getNode0() const; Node* getNode1() const; - unsigned getNumConnectedFaces() const; + std::size_t getNumConnectedFaces() const; Node* getOtherNode(Node* node) const; @@ -52,14 +52,14 @@ public: void setState(State state); - void setIndex(unsigned idx); + void setIndex(std::size_t idx); private: - unsigned mId{0}; + std::size_t mId{0}; Node* mNode0{nullptr}; Node* mNode1{nullptr}; - std::vector mAssociatedFaceIds; + std::vector mAssociatedFaceIds; State mState{State::HEALTHY}; }; diff --git a/src/mesh/FaceMesh.cpp b/src/mesh/FaceMesh.cpp index 177ba7f..3ac6078 100644 --- a/src/mesh/FaceMesh.cpp +++ b/src/mesh/FaceMesh.cpp @@ -4,8 +4,6 @@ #include "Edge.h" #include "AbstractFace.h" -#include - FaceMesh::~FaceMesh() { @@ -26,7 +24,7 @@ const VecFaces& FaceMesh::getFaces() const return mFaces; } -std::vector FaceMesh::getFaceNodeIds() const +std::vector FaceMesh::getFaceNodeIds() const { if (mFaces.empty()) { @@ -34,7 +32,7 @@ std::vector FaceMesh::getFaceNodeIds() const } auto nodes_per_face = mFaces[0]->getNumNodes(); - std::vector ids(nodes_per_face*mFaces.size()); + std::vector ids(nodes_per_face*mFaces.size()); for(std::size_t idx=0; idxsetIndex(count); @@ -115,7 +113,7 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Node* target_node) const if (node->getNumConnectedEdges() == 3 && node->isCoincident(target_node)) { target_node->setState(Node::State::DIRTY); - for (unsigned idx=0; idx<3; idx++) + for (std::size_t idx=0; idx<3; idx++) { auto edge = mesh->mEdges[idx].get(); edge->replaceNodes(target_node, node.get()); @@ -132,7 +130,7 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Edge* target_edge) const if (edge->getNumConnectedFaces() == 2 && target_edge->hasSameNodes(edge.get())) { target_edge->setState(Edge::State::DIRTY); - for (unsigned idx=0; idx<2; idx++) + for (std::size_t idx=0; idx<2; idx++) { auto face = mesh->mFaces[idx].get(); face->replaceEdge(target_edge, edge.get()); @@ -142,9 +140,9 @@ void FaceMesh::replaceIfOverlapping(FaceMesh* mesh, Edge* target_edge) const } } -std::vector FaceMesh::getEdgeNodeIds() const +std::vector FaceMesh::getEdgeNodeIds() const { - std::vector ids(2*mEdges.size()); + std::vector ids(2*mEdges.size()); for(std::size_t idx=0; idxgetNode0Id(); diff --git a/src/mesh/FaceMesh.h b/src/mesh/FaceMesh.h index 2949243..2e412bc 100644 --- a/src/mesh/FaceMesh.h +++ b/src/mesh/FaceMesh.h @@ -25,9 +25,9 @@ public: void populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces); - std::vector getFaceNodeIds() const; + std::vector getFaceNodeIds() const; - std::vector getEdgeNodeIds() const; + std::vector getEdgeNodeIds() const; void addConstantFaceVectorAttribute(const std::string& tag, const std::vector& values); diff --git a/src/mesh/LineMesh.cpp b/src/mesh/LineMesh.cpp index 4a864de..8de66ca 100644 --- a/src/mesh/LineMesh.cpp +++ b/src/mesh/LineMesh.cpp @@ -23,9 +23,9 @@ LineMesh::MeshType LineMesh::getType() const return LineMesh::MeshType::LINE; } -std::vector LineMesh::getEdgeNodeIds() const +std::vector LineMesh::getEdgeNodeIds() const { - std::vector ids(2*mEdges.size()); + std::vector ids(2*mEdges.size()); for(std::size_t idx=0; idxgetNode0Id(); diff --git a/src/mesh/LineMesh.h b/src/mesh/LineMesh.h index 3cf98ad..3449c57 100644 --- a/src/mesh/LineMesh.h +++ b/src/mesh/LineMesh.h @@ -18,7 +18,7 @@ public: void populate(VecNodes& nodes, VecEdges& edges); - std::vector getEdgeNodeIds() const; + std::vector getEdgeNodeIds() const; MeshType getType() const override; diff --git a/src/mesh/Node.cpp b/src/mesh/Node.cpp index fde89d5..d90a7d8 100644 --- a/src/mesh/Node.cpp +++ b/src/mesh/Node.cpp @@ -1,6 +1,6 @@ #include "Node.h" -std::unique_ptr Node::Create(const Point& p, unsigned index) +std::unique_ptr Node::Create(const Point& p, std::size_t index) { return std::make_unique(p, index); } @@ -10,19 +10,19 @@ Node::~Node() } -Node::Node(const Point& p, unsigned index) +Node::Node(const Point& p, std::size_t index) : mPoint(p), mIndex(index) { } -unsigned Node::getIndex() const +std::size_t Node::getIndex() const { return mIndex; } -void Node::updateIndex(unsigned index) +void Node::updateIndex(std::size_t index) { mIndex = index; } @@ -78,32 +78,32 @@ void Node::clearConnectivity() mAssociatedFaceIds.clear(); } -unsigned Node::getNumConnectedEdges() const +std::size_t Node::getNumConnectedEdges() const { return mAssociatedEdgeIds.size(); } -unsigned Node::getNumConnectedFaces() const +std::size_t Node::getNumConnectedFaces() const { return mAssociatedFaceIds.size(); } -void Node::associateEdge(unsigned edgeId) +void Node::associateEdge(std::size_t edgeId) { mAssociatedEdgeIds.push_back(edgeId); } -void Node::associateFace(unsigned faceId) +void Node::associateFace(std::size_t faceId) { mAssociatedFaceIds.push_back(faceId); } -unsigned Node::getConnectedEdgeId(std::size_t idx) const +std::size_t Node::getConnectedEdgeId(std::size_t idx) const { return mAssociatedEdgeIds[idx]; } -unsigned Node::getConnectedFaceId(std::size_t idx) const +std::size_t Node::getConnectedFaceId(std::size_t idx) const { return mAssociatedFaceIds[idx]; } diff --git a/src/mesh/Node.h b/src/mesh/Node.h index d91e7e1..30abc84 100644 --- a/src/mesh/Node.h +++ b/src/mesh/Node.h @@ -16,29 +16,29 @@ public: DIRTY }; - Node(const Point& p, unsigned index = 0); + Node(const Point& p, std::size_t index = 0); - static std::unique_ptr Create(const Point& p, unsigned index = 0); + static std::unique_ptr Create(const Point& p, std::size_t index = 0); ~Node(); - void associateEdge(unsigned edgeId); + void associateEdge(std::size_t edgeId); - void associateFace(unsigned faceId); + void associateFace(std::size_t faceId); void addVectorAttribute(const std::string& tag, const std::vector& values); void clearConnectivity(); - unsigned getIndex() const; + std::size_t getIndex() const; - unsigned getNumConnectedEdges() const; + std::size_t getNumConnectedEdges() const; - unsigned getNumConnectedFaces() const; + std::size_t getNumConnectedFaces() const; - unsigned getConnectedEdgeId(std::size_t idx) const; + std::size_t getConnectedEdgeId(std::size_t idx) const; - unsigned getConnectedFaceId(std::size_t idx) const; + std::size_t getConnectedFaceId(std::size_t idx) const; State getState() const; @@ -52,7 +52,7 @@ public: void setIndex(std::size_t idx); - void updateIndex(unsigned index); + void updateIndex(std::size_t index); void scale(double x, double y); @@ -60,11 +60,11 @@ public: private: std::unordered_map > mVectorAttributes; - unsigned mIndex{0}; + std::size_t mIndex{0}; Point mPoint; - std::vector mAssociatedEdgeIds; - std::vector mAssociatedFaceIds; + std::vector mAssociatedEdgeIds; + std::vector mAssociatedFaceIds; State mState{State::HEALTHY}; }; diff --git a/src/mesh/TriFace.cpp b/src/mesh/TriFace.cpp index 709983e..68aef8f 100644 --- a/src/mesh/TriFace.cpp +++ b/src/mesh/TriFace.cpp @@ -3,7 +3,7 @@ #include "Edge.h" #include "Node.h" -TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id) +TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id) : AbstractFace(id), mEdge0(edge0), mEdge1(edge1), @@ -12,7 +12,7 @@ TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id) } -std::unique_ptr TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id) +std::unique_ptr TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id) { return std::make_unique(edge0, edge1, edge2, id); } @@ -22,12 +22,12 @@ TriFace::~TriFace() } -std::vector TriFace::getNodeIds() const +std::vector TriFace::getNodeIds() const { return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()}; } -unsigned TriFace::getNumNodes() const +std::size_t TriFace::getNumNodes() const { return 3; } @@ -48,22 +48,22 @@ void TriFace::replaceEdge(Edge* original, Edge* replacement) } } -unsigned TriFace::getEdge0Id () const +std::size_t TriFace::getEdge0Id () const { return mEdge0->getId(); } -unsigned TriFace::getEdge1Id () const +std::size_t TriFace::getEdge1Id () const { return mEdge1->getId(); } -unsigned TriFace::getEdge2Id () const +std::size_t TriFace::getEdge2Id () const { return mEdge2->getId(); } -std::vector TriFace::getEdgeIds() const +std::vector TriFace::getEdgeIds() const { return {mEdge0->getId(), mEdge1->getId(), mEdge2->getId()}; } diff --git a/src/mesh/TriFace.h b/src/mesh/TriFace.h index bf8971d..83bcb49 100644 --- a/src/mesh/TriFace.h +++ b/src/mesh/TriFace.h @@ -8,24 +8,24 @@ class Edge; class TriFace : public AbstractFace { public: - TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0); + TriFace(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id=0); ~TriFace(); - static std::unique_ptr Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0); + static std::unique_ptr Create(Edge* edge0, Edge* edge1, Edge* edge2, std::size_t id=0); void associateWidthEdges() override; - std::vector getNodeIds() const override; + std::vector getNodeIds() const override; - unsigned getNumNodes() const override; + std::size_t getNumNodes() const override; void replaceEdge(Edge* original, Edge* replacement); - unsigned getEdge0Id () const; - unsigned getEdge1Id () const; - unsigned getEdge2Id () const; - std::vector getEdgeIds() const override; + std::size_t getEdge0Id () const; + std::size_t getEdge1Id () const; + std::size_t getEdge2Id () const; + std::vector getEdgeIds() const override; std::vector getNodeLocations(Orientation orientation = Orientation::CCW) const override; diff --git a/src/network/server/win32/Win32WebRequest.cpp b/src/network/server/win32/Win32WebRequest.cpp index 3042ef8..f3a6c3b 100644 --- a/src/network/server/win32/Win32WebRequest.cpp +++ b/src/network/server/win32/Win32WebRequest.cpp @@ -5,6 +5,7 @@ #include "FileLogger.h" #include "Win32TempFile.h" +#include "UnicodeUtils.h" Win32WebRequest::Win32WebRequest() : mBuffer(DEFAULT_BUFFER_SIZE) @@ -47,8 +48,7 @@ void Win32WebRequest::resizeBuffer(unsigned size) std::string Win32WebRequest::getUrlFromRequest() const { - const std::wstring wide_url = mHandle->CookedUrl.pFullUrl; - return StringUtils::convert(wide_url); + return UnicodeUtils::utf16ToUtf8String(mHandle->CookedUrl.pFullUrl); } HttpRequest Win32WebRequest::getRequest() const diff --git a/src/network/server/win32/Win32WebServer.cpp b/src/network/server/win32/Win32WebServer.cpp index d6478d2..f69cc56 100644 --- a/src/network/server/win32/Win32WebServer.cpp +++ b/src/network/server/win32/Win32WebServer.cpp @@ -9,7 +9,7 @@ #include "HttpRequest.h" #include "HttpResponse.h" #include "FileLogger.h" -#include "StringUtils.h" +#include "UnicodeUtils.h" Win32WebServer::Win32WebServer(AbstractWebApp* webApp) : mListenUrl("http://localhost:49153/"), @@ -26,7 +26,7 @@ Win32WebServer::~Win32WebServer() void Win32WebServer::clear() { // Remove url - ::HttpRemoveUrl(mWorkingQueue, StringUtils::convert(mListenUrl).c_str()); + ::HttpRemoveUrl(mWorkingQueue, UnicodeUtils::utf8ToUtf16WString(mListenUrl).c_str()); // Close the Request Queue handle. if (mWorkingQueue) @@ -56,7 +56,7 @@ void Win32WebServer::initialize() return; } - retCode = ::HttpAddUrl(mWorkingQueue, StringUtils::convert(mListenUrl).c_str(), nullptr); + retCode = ::HttpAddUrl(mWorkingQueue, UnicodeUtils::utf8ToUtf16WString(mListenUrl).c_str(), nullptr); if (FAILED(retCode)) { MLOG_ERROR("Failed to register queue to url: " << mListenUrl); diff --git a/src/network/server/win32/Win32WebServer.h b/src/network/server/win32/Win32WebServer.h index df34cf5..455e985 100644 --- a/src/network/server/win32/Win32WebServer.h +++ b/src/network/server/win32/Win32WebServer.h @@ -1,13 +1,10 @@ #pragma once -#ifndef UNICODE -#define UNICODE -#endif - #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#include + +#include "Win32BaseIncludes.h" #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 diff --git a/src/publishing/latex/LatexSymbols.cpp b/src/publishing/latex/LatexSymbols.cpp index ae86fe3..c12712f 100644 --- a/src/publishing/latex/LatexSymbols.cpp +++ b/src/publishing/latex/LatexSymbols.cpp @@ -1,6 +1,6 @@ #include "LatexSymbols.h" -#include "StringUtils.h" +#include "UnicodeUtils.h" std::unordered_map LatexSymbolLookup::mSymbols = { {"Psi", L"\u03A8"}, @@ -14,7 +14,7 @@ std::optional LatexSymbolLookup::getSymbolUtf8(const std::string& t { if (auto entry = getSymbolUtf16(tag); entry) { - return StringUtils::convert(*entry); + return UnicodeUtils::utf16ToUtf8String(*entry); } else { diff --git a/src/ui_elements/widgets/Button.cpp b/src/ui_elements/widgets/Button.cpp index e556fc9..d09c5e7 100644 --- a/src/ui_elements/widgets/Button.cpp +++ b/src/ui_elements/widgets/Button.cpp @@ -73,7 +73,7 @@ void Button::doPaint(const PaintEvent* event) void Button::updateLabel(const PaintEvent* event) { unsigned fontOffset = unsigned(mLabel.size()) * 4; - auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4); + auto middle = DiscretePoint(mLocation.getX() + mSize.mWidth/2 - fontOffset, mLocation.getY() + mSize.mHeight/2 + 4); if (!mTextNode) { diff --git a/src/ui_elements/widgets/HorizontalSpacer.cpp b/src/ui_elements/widgets/HorizontalSpacer.cpp index 6f02bcc..51b5a6a 100644 --- a/src/ui_elements/widgets/HorizontalSpacer.cpp +++ b/src/ui_elements/widgets/HorizontalSpacer.cpp @@ -48,7 +48,7 @@ void HorizontalSpacer::updateChildLocations() delta = size.mMaxHeight; } child->setBounds(mSize.mWidth, unsigned(delta)); - child->setLocation(DiscretePoint(mLocation.GetX(), mLocation.GetY() + unsigned(offset))); + child->setLocation(DiscretePoint(mLocation.getX(), mLocation.getY() + unsigned(offset))); offset += delta; } } diff --git a/src/ui_elements/widgets/Label.cpp b/src/ui_elements/widgets/Label.cpp index 2f64d73..6b41141 100644 --- a/src/ui_elements/widgets/Label.cpp +++ b/src/ui_elements/widgets/Label.cpp @@ -39,7 +39,7 @@ void Label::doPaint(const PaintEvent* event) void Label::updateLabel(const PaintEvent* event) { unsigned fontOffset = unsigned(mLabel.size()) * 4; - auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4); + auto middle = DiscretePoint(mLocation.getX() + mSize.mWidth/2 - fontOffset, mLocation.getY() + mSize.mHeight/2 + 4); if (!mTextNode) { diff --git a/src/ui_elements/widgets/TextBox.cpp b/src/ui_elements/widgets/TextBox.cpp index 6342d4d..f05f206 100644 --- a/src/ui_elements/widgets/TextBox.cpp +++ b/src/ui_elements/widgets/TextBox.cpp @@ -83,7 +83,7 @@ void TextBox::doPaint(const PaintEvent* event) void TextBox::updateLabel(const PaintEvent* event) { - auto loc = DiscretePoint(mLocation.GetX() + mPadding.mLeft, mLocation.GetY() + mPadding.mTop + unsigned(0)); + auto loc = DiscretePoint(mLocation.getX() + mPadding.mLeft, mLocation.getY() + mPadding.mTop + unsigned(0)); if (!mTextNode) { diff --git a/src/ui_elements/widgets/VerticalSpacer.cpp b/src/ui_elements/widgets/VerticalSpacer.cpp index 3397987..5137f9b 100644 --- a/src/ui_elements/widgets/VerticalSpacer.cpp +++ b/src/ui_elements/widgets/VerticalSpacer.cpp @@ -37,7 +37,7 @@ void VerticalSpacer::updateChildLocations() double scale = mScales[idx]; double delta = mSize.mWidth * (scale/scaleSum); child->setBounds(unsigned(delta), mSize.mHeight); - child->setLocation(DiscretePoint(mLocation.GetX() + unsigned(offset), mLocation.GetY())); + child->setLocation(DiscretePoint(mLocation.getX() + unsigned(offset), mLocation.getY())); offset += delta; } } diff --git a/src/ui_elements/widgets/Widget.cpp b/src/ui_elements/widgets/Widget.cpp index 298b7da..8df9f0a 100644 --- a/src/ui_elements/widgets/Widget.cpp +++ b/src/ui_elements/widgets/Widget.cpp @@ -237,19 +237,19 @@ void Widget::updateChildLocations() bool Widget::contains(const DiscretePoint& loc) const { - if(loc.GetX() < mLocation.GetX()) + if(loc.getX() < mLocation.getX()) { return false; } - if(loc.GetX() > mLocation.GetX() + mSize.mWidth) + if(loc.getX() > mLocation.getX() + mSize.mWidth) { return false; } - if(loc.GetY() > mLocation.GetY() + mSize.mHeight) + if(loc.getY() > mLocation.getY() + mSize.mHeight) { return false; } - if(loc.GetY() < mLocation.GetY()) + if(loc.getY() < mLocation.getY()) { return false; } @@ -313,8 +313,8 @@ void Widget::onMyMouseEvent(const MouseEvent* event) void Widget::updateBackground(const PaintEvent* event) { - unsigned locX = mLocation.GetX() + mMargin.mLeft; - unsigned locY = mLocation.GetY() + mMargin.mTop; + unsigned locX = mLocation.getX() + mMargin.mLeft; + unsigned locY = mLocation.getX() + mMargin.mTop; unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight; unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom; diff --git a/src/visual_elements/basic_shapes/LineNode.cpp b/src/visual_elements/basic_shapes/LineNode.cpp index e69de29..87a2c81 100644 --- a/src/visual_elements/basic_shapes/LineNode.cpp +++ b/src/visual_elements/basic_shapes/LineNode.cpp @@ -0,0 +1,28 @@ +#include "LineNode.h" + +LineNode::LineNode(const Point& location, const std::vector& points) + : GeometryNode(location), + mPoints(points) +{ + +} + +LineNode::Type LineNode::getType() +{ + return Type::Line; +} + +void LineNode::createOrUpdateGeometry(SceneInfo* sceneInfo) +{ + if (sceneInfo->mSupportsGeometryPrimitives) + { + auto line = std::make_unique(Point{ 0, 0 }, mPoints); + mBackgroundItem = std::make_unique(std::move(line)); + } + mBackgroundItem->setName(mName + "_Model"); +} + +void LineNode::updateTransform() +{ + mBackgroundItem->updateTransform({ mLocation }); +} \ No newline at end of file diff --git a/src/visual_elements/basic_shapes/LineNode.h b/src/visual_elements/basic_shapes/LineNode.h index c863212..3123ee9 100644 --- a/src/visual_elements/basic_shapes/LineNode.h +++ b/src/visual_elements/basic_shapes/LineNode.h @@ -10,33 +10,14 @@ class LineNode : public GeometryNode { public: - LineNode(const Point& location, const std::vector& points) - : GeometryNode(location), - mPoints(points) - { + LineNode(const Point& location, const std::vector& points); - } - - Type getType() - { - return Type::Line; - } - - void createOrUpdateGeometry(SceneInfo* sceneInfo) - { - if (sceneInfo->mSupportsGeometryPrimitives) - { - auto line = std::make_unique(Point{ 0, 0 }, 1, 1); - mBackgroundItem = std::make_unique(std::move(line)); - } - mBackgroundItem->setName(mName + "_Model"); - } - - void updateTransform() - { - mBackgroundItem->updateTransform({ mLocation }); - } + Type getType(); private: + void createOrUpdateGeometry(SceneInfo* sceneInfo) override; + + void updateTransform() override; + std::vector mPoints; }; \ No newline at end of file diff --git a/src/web/markdown/MarkdownParser.cpp b/src/web/markdown/MarkdownParser.cpp index 685de96..bd08505 100644 --- a/src/web/markdown/MarkdownParser.cpp +++ b/src/web/markdown/MarkdownParser.cpp @@ -32,7 +32,7 @@ bool MarkdownParser::isInMultilineBlock() const return working_type == MarkdownElement::Type::MULTILINE_QUOTE || working_type == MarkdownElement::Type::CUSTOM_MULTILINE ; } -unsigned MarkdownParser::checkForLink(const std::string& lineSection) +std::size_t MarkdownParser::checkForLink(const std::string& lineSection) { if (lineSection.empty()) { @@ -40,7 +40,7 @@ unsigned MarkdownParser::checkForLink(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; if (Lexer::matchPattern("[@](@)", lineSection, '@', hits)) { if (hits.size() == 2) @@ -59,7 +59,7 @@ unsigned MarkdownParser::checkForLink(const std::string& lineSection) return hit_size; } -unsigned MarkdownParser::checkForImage(const std::string& lineSection) +std::size_t MarkdownParser::checkForImage(const std::string& lineSection) { if (lineSection.empty()) { @@ -67,7 +67,7 @@ unsigned MarkdownParser::checkForImage(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; if (Lexer::matchPattern("![@](@)", lineSection, '@', hits)) { if (hits.size() == 2) @@ -85,7 +85,7 @@ unsigned MarkdownParser::checkForImage(const std::string& lineSection) return hit_size; } -unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection) +std::size_t MarkdownParser::checkForInlineQuote(const std::string& lineSection) { if (lineSection.empty()) { @@ -93,7 +93,7 @@ unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; if (Lexer::matchPattern("`@`", lineSection, '@', hits)) { if (hits.size() == 1) @@ -111,7 +111,8 @@ unsigned MarkdownParser::checkForInlineQuote(const std::string& lineSection) } return hit_size; } -unsigned MarkdownParser::checkForCustomInline(const std::string& lineSection) + +std::size_t MarkdownParser::checkForCustomInline(const std::string& lineSection) { if (lineSection.empty()) { @@ -119,9 +120,9 @@ unsigned MarkdownParser::checkForCustomInline(const std::string& lineSection) } std::vector hits; - unsigned hit_size{0}; + std::size_t hit_size{0}; - for(unsigned idx=0; idxgetNumInlineContexts(); idx++) + for(std::size_t idx=0; idxgetNumInlineContexts(); idx++) { const auto delimiter = mWorkingDocument->getInlineContext(idx)->getDelimiter(); if (Lexer::matchPattern(delimiter + "@" + delimiter, lineSection, '@', hits)) @@ -193,7 +194,7 @@ void MarkdownParser::processLine(const std::string& line) } } - unsigned line_position = 0; + std::size_t line_position = 0; mWorkingLine.clear(); while(line_position < line.size()) { @@ -308,11 +309,11 @@ void MarkdownParser::onFoundHeading(const std::string& line) { onSectionFinished(); - unsigned level = StringUtils::countFirstConsecutiveHits(line, HEADING_DELIMITER); + auto level = StringUtils::countFirstConsecutiveHits(line, HEADING_DELIMITER); auto heading = std::make_unique(level); std::string prefix; - for(unsigned idx=0; idx child); - unsigned checkForImage(const std::string& lineSection); - unsigned checkForLink(const std::string& lineSection); - unsigned checkForInlineQuote(const std::string& lineSection); - unsigned checkForCustomInline(const std::string& lineSection); + std::size_t checkForImage(const std::string& lineSection); + std::size_t checkForLink(const std::string& lineSection); + std::size_t checkForInlineQuote(const std::string& lineSection); + std::size_t checkForCustomInline(const std::string& lineSection); bool isInMultilineBlock() const; diff --git a/src/windows/ui_interfaces/win32/Win32Window.cpp b/src/windows/ui_interfaces/win32/Win32Window.cpp index 28e90f0..25dc87a 100644 --- a/src/windows/ui_interfaces/win32/Win32Window.cpp +++ b/src/windows/ui_interfaces/win32/Win32Window.cpp @@ -5,7 +5,7 @@ #include "Win32DxWindowInterface.h" #include "FileLogger.h" -#include "StringUtils.h" +#include "UnicodeUtils.h" #include "Widget.h" #include "DrawingContext.h" #include "DirectXPainter.h" @@ -105,7 +105,7 @@ LRESULT CALLBACK Win32Window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa key_event->setAction(KeyboardEvent::Action::Pressed); auto keyChar = (wchar_t)wParam; - key_event->setKeyString(StringUtils::convert(std::wstring(1, keyChar))); + key_event->setKeyString(UnicodeUtils::utf16ToUtf8String(std::wstring(1, keyChar))); mDesktopManager->onUiEvent(std::move(key_event)); return 0; }