Add frozen TikZRefinery demo baseline and build pipeline
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "model/EditorTypes.h"
|
||||
#include "ShapeTypes.h"
|
||||
|
||||
namespace TikzRefinery {
|
||||
|
||||
inline ShapeApi::ElementDescription describeShape(const ElementRecord &element)
|
||||
{
|
||||
ShapeApi::ElementDescription description;
|
||||
description.documentId = element.documentId;
|
||||
description.uElementId = element.uElementId;
|
||||
description.uRevision = element.uDocumentRevision;
|
||||
description.ptFirstCentimeters = element.ptFirstTikzPosition;
|
||||
description.ptSecondCentimeters = element.ptSecondTikzPosition;
|
||||
description.rLineWidthPoints = element.rLineWidthPoints;
|
||||
return description;
|
||||
}
|
||||
|
||||
inline ShapeApi::HandleId shapeHandle(DragKind dragKind)
|
||||
{
|
||||
switch (dragKind) {
|
||||
case DragKind::RectangleFirstFirst: return ShapeApi::HandleId::FirstFirst;
|
||||
case DragKind::RectangleFirstSecond: return ShapeApi::HandleId::FirstSecond;
|
||||
case DragKind::RectangleSecondFirst: return ShapeApi::HandleId::SecondFirst;
|
||||
default: return ShapeApi::HandleId::SecondSecond;
|
||||
}
|
||||
}
|
||||
|
||||
inline DragKind sceneHandle(ShapeApi::HandleId handleId)
|
||||
{
|
||||
switch (handleId) {
|
||||
case ShapeApi::HandleId::FirstFirst: return DragKind::RectangleFirstFirst;
|
||||
case ShapeApi::HandleId::FirstSecond: return DragKind::RectangleFirstSecond;
|
||||
case ShapeApi::HandleId::SecondFirst: return DragKind::RectangleSecondFirst;
|
||||
default: return DragKind::RectangleSecondSecond;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TikzRefinery
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "plugins/tkrShapePluginStore.h"
|
||||
#include "ShapeBuildContract.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace TikzRefinery {
|
||||
|
||||
tkrShapePluginStore::tkrShapePluginStore(const QString &strModulePath)
|
||||
: m_loader(strModulePath.isEmpty()
|
||||
? QDir(QCoreApplication::applicationDirPath()).filePath(QStringLiteral("shape-plugins/tkr_rectangle"))
|
||||
: strModulePath)
|
||||
{
|
||||
const QJsonObject root = m_loader.metaData();
|
||||
const QJsonObject metadata = root.value(QStringLiteral("MetaData")).toObject();
|
||||
const QJsonArray operations = metadata.value(QStringLiteral("operations")).toArray();
|
||||
if (root.value(QStringLiteral("IID")).toString() != QString::fromLatin1(TKR_SHAPE_PROVIDER_IID)
|
||||
|| metadata.value(QStringLiteral("id")).toString() != QStringLiteral("org.tikzrefinery.rectangle")
|
||||
|| metadata.value(QStringLiteral("name")).toString().isEmpty()
|
||||
|| metadata.value(QStringLiteral("version")).toString().isEmpty()
|
||||
|| metadata.value(QStringLiteral("role")).toString() != QStringLiteral("shape")
|
||||
|| metadata.value(QStringLiteral("apiVersion")).toInt() != ShapeApi::iApiVersion
|
||||
|| metadata.value(QStringLiteral("shapeType")).toString() != ShapeApi::strRectangleType
|
||||
|| metadata.value(QStringLiteral("geometrySchemaVersion")).toInt() != ShapeApi::iRectangleSchemaVersion
|
||||
|| metadata.value(QStringLiteral("parameterSchemaVersion")).toInt() != ShapeApi::iParameterSchemaVersion
|
||||
|| metadata.value(QStringLiteral("buildKey")).toString() != QString::fromLatin1(ShapeBuildContract::pBuildKey)
|
||||
|| !operations.contains(ShapeApi::strMoveOperation) || !operations.contains(ShapeApi::strResizeOperation)) {
|
||||
m_result = {false, QStringLiteral("Rectangle plugin missing or incompatible (API, schema, operations or toolchain). %1")
|
||||
.arg(m_loader.fileName())};
|
||||
return;
|
||||
}
|
||||
m_pProvider = qobject_cast<tkrShapeProvider *>(m_loader.instance());
|
||||
if (!m_pProvider) {
|
||||
m_result = {false, QStringLiteral("Rectangle plugin could not load: %1").arg(m_loader.errorString())};
|
||||
return;
|
||||
}
|
||||
m_strName = metadata.value(QStringLiteral("name")).toString();
|
||||
m_strVersion = metadata.value(QStringLiteral("version")).toString();
|
||||
m_strRuntimeIdentity = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||
m_result = {true, QStringLiteral("Loaded %1 %2").arg(m_strName, m_strVersion)};
|
||||
}
|
||||
|
||||
const tkrShapeProvider *tkrShapePluginStore::provider() const { return m_pProvider; }
|
||||
const OperationResult &tkrShapePluginStore::loadResult() const { return m_result; }
|
||||
const QString &tkrShapePluginStore::runtimeIdentity() const { return m_strRuntimeIdentity; }
|
||||
QString tkrShapePluginStore::modulePath() const { return m_loader.fileName(); }
|
||||
QString tkrShapePluginStore::description() const
|
||||
{
|
||||
return m_result.bSucceeded ? QStringLiteral("%1 %2\n%3\nInstance: %4")
|
||||
.arg(m_strName, m_strVersion, modulePath(), m_strRuntimeIdentity) : m_result.strMessage;
|
||||
}
|
||||
|
||||
} // namespace TikzRefinery
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "model/EditorTypes.h"
|
||||
#include "tkrShapeProvider.h"
|
||||
#include <QPluginLoader>
|
||||
|
||||
namespace TikzRefinery {
|
||||
|
||||
// Owns one immutable module binding for this initial extraction. No hot unloading.
|
||||
class tkrShapePluginStore final
|
||||
{
|
||||
public:
|
||||
explicit tkrShapePluginStore(const QString &strModulePath = {});
|
||||
const tkrShapeProvider *provider() const;
|
||||
const OperationResult &loadResult() const;
|
||||
const QString &runtimeIdentity() const;
|
||||
QString description() const;
|
||||
QString modulePath() const;
|
||||
private:
|
||||
QPluginLoader m_loader;
|
||||
const tkrShapeProvider *m_pProvider = nullptr; // Borrowed from the pinned loader.
|
||||
OperationResult m_result;
|
||||
QString m_strRuntimeIdentity;
|
||||
QString m_strName;
|
||||
QString m_strVersion;
|
||||
};
|
||||
|
||||
} // namespace TikzRefinery
|
||||
Reference in New Issue
Block a user