File Node.h¶
Go to the documentation of this file
#pragma once
#include <glm.hpp>
#include <memory>
#include <string>
#include "Core.h"
namespace rayx {
class Group;
class DesignSource;
class DesignElement;
class RAYX_API BeamlineNode {
friend class Group; // Needed so group can access m_parent for BeamlineNodes
public:
virtual ~BeamlineNode() = default;
virtual std::unique_ptr<BeamlineNode> clone() const = 0;
virtual bool isGroup() const { return false; } // Overridden in Group
virtual bool isElement() const { return false; } // Overridden in Element
virtual bool isSource() const { return false; } // Overridden in Source
virtual glm::dvec4 getPosition() const = 0;
virtual glm::dmat4 getOrientation() const = 0;
glm::dvec4 getWorldPosition() const;
glm::dmat4 getWorldOrientation() const;
virtual std::string getName() const = 0;
virtual void setName(std::string name) = 0;
bool hasParent() const { return m_parent != nullptr; }
const BeamlineNode* getParent() const { return m_parent; }
BeamlineNode* getParent() { return m_parent; }
const BeamlineNode* getRoot() const;
BeamlineNode* getRoot();
int getObjectId() const;
// declarative fashion api
// the index operators are declared in BeamlineNode but only work when the BeamlineNode is a group. defined here so they can be called without
// casting an object to Group
virtual const BeamlineNode* operator[](size_t index) const;
virtual BeamlineNode* operator[](size_t index);
virtual const BeamlineNode* operator[](const std::string& name) const;
virtual BeamlineNode* operator[](const std::string& name);
const Group* asGroup() const;
Group* asGroup();
const DesignSource* asSource() const;
DesignSource* asSource();
const DesignElement* asElement() const;
DesignElement* asElement();
private:
BeamlineNode* m_parent = nullptr;
};
} // namespace rayx