Fix up linux build.

This commit is contained in:
James Grogan 2023-01-16 12:36:02 +00:00
parent c81db288b0
commit b76dc184b3
21 changed files with 86 additions and 66 deletions

View file

@ -11,24 +11,24 @@ class LineNode;
class BlochSphereNode : public AbstractVisualNode
{
public:
BlochSphereNode(const Point& location);
BlochSphereNode(const Point& location);
void setContent(BlochSphere* content);
void setContent(BlochSphere* content);
void update(SceneInfo* sceneInfo) override;
void update(SceneInfo* sceneInfo) override;
void setSize(double size);
void setSize(double size);
private:
double mSize{ 1.0 };
bool mContentDirty{ true };
BlochSphere* mContent{ nullptr };
double mSize{ 1.0 };
bool mContentDirty{ true };
BlochSphere* mContent{ nullptr };
std::unique_ptr<CircleNode> mOuterCircle;
std::unique_ptr<CircleNode> mInnerCircle;
std::unique_ptr<CircleNode> mCentreCircle;
std::unique_ptr<CircleNode> mStateMarkerCircle;
std::unique_ptr<LineNode> mXAxis;
std::unique_ptr<LineNode> mYAxis;
std::unique_ptr<LineNode> mZAxis;
std::unique_ptr<LineNode> mStateVector;
std::unique_ptr<CircleNode> mOuterCircle;
std::unique_ptr<CircleNode> mInnerCircle;
std::unique_ptr<CircleNode> mCentreCircle;
std::unique_ptr<CircleNode> mStateMarkerCircle;
std::unique_ptr<LineNode> mXAxis;
std::unique_ptr<LineNode> mYAxis;
std::unique_ptr<LineNode> mZAxis;
std::unique_ptr<LineNode> mStateVector;
};

View file

@ -3,21 +3,23 @@
#include "TestRenderUtils.h"
#include "BlochSphereNode.h"
#include "CircleNode.h"
#include "LineNode.h"
#include "BlochSphere.h"
TEST_CASE(TestBlochSphereNode, "quantum_computing")
{
TestRenderer renderer(100, 100);
TestRenderer renderer(100, 100);
auto node = std::make_unique<BlochSphereNode>(Point(0.5, 0.5));
auto node = std::make_unique<BlochSphereNode>(Point(0.5, 0.5));
Qubit state({ 1.0, 0.0 }, { 0.0, 0.0 });
Qubit state({ 1.0, 0.0 }, { 0.0, 0.0 });
auto bloch_sphere = std::make_unique<BlochSphere>(state);
auto bloch_sphere = std::make_unique<BlochSphere>(state);
node->setSize(100);
node->setContent(bloch_sphere.get());
node->setSize(100);
node->setContent(bloch_sphere.get());
renderer.getScene()->addNode(node.get());
renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "bloch_sphere.svg");
renderer.getScene()->addNode(node.get());
renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "bloch_sphere.svg");
}

View file

@ -3,6 +3,7 @@
#include "Win32BaseIncludes.h"
#include <vector>
#include <stdexcept>
std::string UnicodeUtils::utf16ToUtf8String(const std::wstring& input)
{

View file

@ -10,7 +10,7 @@
#include <fcntl.h>
#endif
void SharedMemory::allocate(const std::string& namePrefix, std::size_t)
void SharedMemory::allocate(const std::string& namePrefix, std::size_t size)
{
createFile(namePrefix);
@ -30,6 +30,8 @@ void SharedMemory::allocate(const std::string& namePrefix, std::size_t)
close(mFileDescriptor);
mIsValid = false;
}
#else
(void)(size);
#endif
}

View file

@ -1,6 +1,7 @@
#include "FreeTypeFontEngine.h"
#include "Image.h"
#include "Grid.h"
#include "FileLogger.h"
#include "FontGlyph.h"
@ -20,7 +21,7 @@ void FreeTypeFontEngine::initialize()
}
}
void FreeTypeFontEngine::loadFontFace(const std::filesystem::path& fontFile, int penSize)
void FreeTypeFontEngine::loadFontFace(const std::filesystem::path& fontFile, float penSize)
{
if (!mLibrary)
{
@ -78,7 +79,7 @@ std::unique_ptr<FontGlyph> FreeTypeFontEngine::loadGlyph(uint32_t charCode)
auto rows = mWorkingFontFace->glyph->bitmap.rows;
auto columns = mWorkingFontFace->glyph->bitmap.width;
auto image = std::make_unique<Image<unsigned char>> (columns, rows);
auto image = std::make_unique<Image>(columns, rows);
unsigned counter = 0;
std::vector<unsigned char> data(rows*columns, 0);
@ -90,7 +91,7 @@ std::unique_ptr<FontGlyph> FreeTypeFontEngine::loadGlyph(uint32_t charCode)
counter++;
}
}
image->setData(data);
image->getGridT<unsigned char>()->setData(data);
auto glyph = std::make_unique<FontGlyph>(mWorkingFontFace->glyph->bitmap.width,
mWorkingFontFace->glyph->bitmap.rows,
mWorkingFontFace->glyph->bitmap_left,

View file

@ -4,7 +4,6 @@
#include "Image.h"
template<typename T>
class Image;
#include <ft2build.h>
@ -17,7 +16,7 @@ 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;
std::unique_ptr<FontGlyph> loadGlyph(uint32_t charCode) override;

View file

@ -9,16 +9,22 @@ template <typename T>
class TypedGrid : public AbstractGrid
{
public:
TypedGrid(const Bounds& bounds, std::size_t numPointsX, std::size_t numPointsY, std::size_t numPointsZ = 1)
: AbstractGrid(bounds, numPointsX, numPointsY, numPointsZ),
mData(std::make_unique<List<T> >())
{
}
TypedGrid(const Bounds& bounds, std::size_t numPointsX, std::size_t numPointsY, std::size_t numPointsZ = 1)
: AbstractGrid(bounds, numPointsX, numPointsY, numPointsZ),
mData(std::make_unique<List<T> >())
{
}
virtual T getItem(std::size_t idx, std::size_t jdx, std::size_t kdx) const = 0;
virtual ~TypedGrid() = default;
virtual void setItem(std::size_t idx, std::size_t jdx, std::size_t kdx, const T& value) = 0;
virtual T getItem(std::size_t idx, std::size_t jdx, std::size_t kdx) const = 0;
virtual void setItem(std::size_t idx, std::size_t jdx, std::size_t kdx, const T& value) = 0;
List<T>* getInternalData() const
{
return mData.get();
}
protected:
std::unique_ptr<List<T> > mData;
std::unique_ptr<List<T> > mData;
};

View file

@ -1,6 +1,7 @@
#include "OpenGlFontTexture.h"
#include "FontGlyph.h"
#include "Grid.h"
#include "Image.h"
#define GL_GLEXT_PROTOTYPES
@ -14,7 +15,7 @@ OpenGlFontTexture::OpenGlFontTexture(FontGlyph* glyph)
glGenTextures(1, &mHandle);
glBindTexture(GL_TEXTURE_2D, mHandle);
auto buffer = glyph->getImage()->getDataPtr();
auto buffer = glyph->getImage()->getGridT<unsigned char>()->getInternalData()->getDataPtr();
glTexImage2D(
GL_TEXTURE_2D,

View file

@ -45,7 +45,7 @@ void OpenGlMeshPainter::initializeBuffers()
glGenVertexArrays(1, &mVertexArray);
}
void OpenGlMeshPainter::paint(const std::vector<float>& verts, const std::vector<unsigned>& elements, const std::vector<float>& color, bool lines)
void OpenGlMeshPainter::paint(const std::vector<float>& verts, const std::vector<std::size_t>& elements, const std::vector<float>& color, bool lines)
{
glBindVertexArray(mVertexArray);
@ -113,7 +113,7 @@ void OpenGlMeshPainter::paint(SceneModel* model, DrawingContext* context)
}
std::vector<unsigned> indices;
std::vector<std::size_t> indices;
const bool line_mesh = model->getMesh()->getType() == AbstractMesh::MeshType::LINE;
if (line_mesh)
{
@ -124,7 +124,7 @@ void OpenGlMeshPainter::paint(SceneModel* model, DrawingContext* context)
indices = dynamic_cast<TriMesh*>(model->getMesh())->getFaceNodeIds();
}
auto model_color = model->getColor().getAsVectorDouble();
auto model_color = model->getFillColor().getAsVectorDouble();
std::vector<float> color = {float(model_color[0]), float(model_color[1]), float(model_color[2]), float(model_color[3])};
paint(vertices, indices, color, line_mesh);

View file

@ -18,7 +18,7 @@ private:
void initializeShader();
void initializeBuffers();
void paint(const std::vector<float>& verts, const std::vector<unsigned>& elements, const std::vector<float>& color, bool lines = false);
void paint(const std::vector<float>& verts, const std::vector<std::size_t>& elements, const std::vector<float>& color, bool lines = false);
unsigned mVertexBuffer{0};
unsigned mElementBuffer{0};

View file

@ -32,7 +32,7 @@
#include <iostream>
OpenGlPainter::OpenGlPainter(DrawingContext* context)
: AbstractPainter(context)
: AbstractPainter(context),
mMeshPainter(std::make_unique<OpenGlMeshPainter>()),
mTextPainter(std::make_unique<OpenGlTextPainter>())
{
@ -41,7 +41,7 @@ OpenGlPainter::OpenGlPainter(DrawingContext* context)
void OpenGlPainter::paint()
{
auto surface = context->getSurface();
auto surface = mDrawingContext->getSurface();
const auto width = double(surface->getWidth());
const auto height = double(surface->getHeight());

View file

@ -84,7 +84,9 @@ PlatformImage* Image::getPlatformImage()
{
if (!mPlatformImage)
{
#ifdef _WIN32
mPlatformImage = std::make_unique<Win32WicImage>(this);
#endif
}
return mPlatformImage.get();
}

View file

@ -20,7 +20,7 @@ class BasicPngWriter : public IImageWriter
public:
BasicPngWriter();
~BasicPngWriter();
virtual ~BasicPngWriter();
static std::unique_ptr<BasicPngWriter> Create();

View file

@ -12,7 +12,7 @@ PngWriter::PngWriter()
#ifdef _WIN32
mWriterImpl = std::make_unique<Win32WicImageWriter>(mFormat);
#else
mWriterImpl = std::make_unique<BasicPngWriter>(mFormat);
mWriterImpl = std::make_unique<BasicPngWriter>();
#endif
}

View file

@ -61,7 +61,8 @@ void AbstractMesh::transform(const Transform& transform)
void AbstractMesh::translate(double offsetX, double offsetY, double offsetZ)
{
Transform transform({ -offsetX, -offsetY, -offsetZ });
const Point loc {-offsetX, -offsetY, -offsetZ};
Transform transform(loc);
for (auto& node : mNodes)
{
node->apply(transform);

View file

@ -40,7 +40,7 @@ void NetworkManager::runHttpServer(AbstractWebApp* webApp)
#else
if (!mSocketInterface)
{
Initialize();
initialize();
}
auto socket = Socket::Create();

View file

@ -3,6 +3,7 @@
#include <xcb/xcb_image.h>
#include "Window.h"
#include "Grid.h"
#include "XcbWindow.h"
#include "Image.h"
@ -28,7 +29,7 @@ public:
const auto h = window->getHeight();
//auto data = const_cast<unsigned char*>(backing_image->getDataPtr());
auto data = backing_image->getData();
auto data = backing_image->getGridT<unsigned char>()->getInternalData()->getData();
unsigned char* converted = &data[0];
mXImage = xcb_image_create_native(connection, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP, screen->root_depth, converted, w*h*4, converted);

View file

@ -46,8 +46,8 @@ namespace {
} _xkb_event;
}
XcbInterface::XcbInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware)
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware),
XcbInterface::XcbInterface(DesktopManager* desktopManager, bool useHardware)
: AbstractUIInterface(desktopManager, useHardware),
mEventInterface(XcbEventInterface::Create()),
mExtensionInterface(std::make_unique<XcbExtensionInterface>())
{
@ -177,7 +177,7 @@ uint32_t XcbInterface::getEventMask()
void XcbInterface::addWindow(mt::Window* window)
{
auto screen = mDesktopManager->getDefaultScreen();
XcbWindow::add(window, mConnection, screen, getEventMask(), mFontsManager.get(), mGlInterface.get());
XcbWindow::add(window, mConnection, screen, getEventMask(), mDesktopManager->getFontsManager(), mGlInterface.get());
}
void XcbInterface::onPaint()

View file

@ -27,7 +27,7 @@ namespace mt
class XcbInterface : public AbstractUIInterface
{
public:
XcbInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = true);
XcbInterface(DesktopManager* desktopManager, bool useHardware = true);
~XcbInterface();

View file

@ -69,7 +69,7 @@ void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen
auto xcb_window = std::make_unique<XcbWindow>(window, hwnd, connection, xcbGlInterface);
const auto drawing_mode = xcbGlInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
window->setPlatformWindow(std::move(xcb_window), fontsManager, drawing_mode);
window->setPlatformWindow(std::move(xcb_window));
}
int XcbWindow::getHandle() const

View file

@ -20,8 +20,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
auto args = CommandLineArgs::Create();
CommandLineArgs::initialize(args.get());
auto args = CommandLineArgs::Create();
CommandLineArgs::initialize(args.get());
const auto user_args = args->getUserArgs();
@ -38,8 +38,12 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
#else
int main(int argc, char *argv[])
{
auto args = CommandLineArgs::Create();
auto args = CommandLineArgs::Create();
args->process(argc, argv);
auto user_args = args->getArgs();
auto gui_app = std::make_unique<TestUiApplication>(std::move(args));
#endif
TestCaseRunner::getInstance().setTestApplication(gui_app.get());