Initial quantum circuit.

This commit is contained in:
jmsgrogan 2023-01-26 11:27:35 +00:00
parent 77ce58c612
commit 20c13c1cdf
38 changed files with 1153 additions and 14 deletions

View file

@ -0,0 +1,53 @@
#include "QuantumTerminalNode.h"
#include "QuantumTerminal.h"
#include "EquationNode.h"
#include "LatexMathExpression.h"
QuantumTerminalNode::QuantumTerminalNode(const Transform& transform)
: AbstractVisualNode(transform)
{
}
void QuantumTerminalNode::setContent(QuantumTerminal* terminal)
{
mContent = terminal;
mContentDirty = true;
}
void QuantumTerminalNode::update(SceneInfo* sceneInfo)
{
if (mContentDirty)
{
createOrUpdateGeometry(sceneInfo);
mContentDirty = false;
}
}
void QuantumTerminalNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
{
if (!mLabel)
{
const auto value = mContent->getValue();
std::string label;
if (value.isIn0State())
{
label = "\\ket{0}";
}
else if(value.isIn1State())
{
label = "\\ket{1}";
}
else
{
label = "\\Psi";
}
mLabelExpression = std::make_unique<LatexMathExpression>(label);
mLabel = std::make_unique<EquationNode>();
mLabel->setContent(mLabelExpression.get());
addChild(mLabel.get());
}
}