RayZaler 0.1
The free opto-mechanical simulation framework
CompositeElement.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _COMPOSITE_ELEMENT
20#define _COMPOSITE_ELEMENT
21
22#include "GenericCompositeModel.h"
23#include "OpticalElement.h"
24#include "ReferenceFrame.h"
25
26namespace RZ {
27 class OMModel;
28
29 // This is all Bjarne Stroustrup's fault, he made me do this.
31 OMModel *m_model = nullptr;
32
33 public:
34 IHateCPlusPlus(OMModel *model);
35 inline OMModel *
36 model() const
37 {
38 return m_model;
39 }
40 };
41
43 OMModel *m_model = nullptr; // Owned
44 OpticalPath m_defaultPath;
45
46 protected:
47 // Interface methods
48 virtual void registerDof(
49 std::string const &name,
50 GenericModelParam *) override;
51
52 virtual void registerParam(
53 std::string const &name,
54 GenericModelParam *) override;
55
56 virtual void registerOpticalPath(
57 std::string const &name,
58 std::list<std::string> &params) override;
59
60 virtual GenericEvaluator *allocateEvaluator(
61 std::string const &expr,
62 const GenericEvaluatorSymbolDict *dict,
63 std::list<GenericCustomFunction *> const &functions,
64 ExprRandomState *state) override;
65
66 virtual void exposePort(
67 std::string const &name,
68 ReferenceFrame *frame) override;
69
70 virtual bool propertyChanged(
71 std::string const &name,
72 PropertyValue const &val) override;
73
74 public:
76 ElementFactory *factory,
77 std::string const &name,
78 ReferenceFrame *pFrame,
79 Recipe *recipe,
80 GenericCompositeModel *parentCompositeModel,
81 Element *parent = nullptr);
82 virtual OpticalPath opticalPath(std::string const &name = "") const override;
84
85 virtual void renderOpenGL() override;
86 virtual OMModel *nestedModel() const override;
87 virtual GenericCompositeModel *nestedCompositeModel() const;
88
89 virtual void notifyDetector(
90 std::string const &preferredName,
91 Detector *det) override;
92
93 virtual void setRecordHits(bool) override;
94 virtual void clearHits() override;
95 };
96
97 class CompositeElementFactory : public OpticalElementFactory {
98 Recipe *m_recipe = nullptr;
99 GenericCompositeModel *m_owner = nullptr;
100 std::string m_name;
101
102 public:
104 std::string const &,
105 Recipe *,
106 GenericCompositeModel *owner);
107
108 virtual Element *make(
109 std::string const &name,
110 ReferenceFrame *pFrame,
111 Element *parent = nullptr) override;
112 };
113}
114
115#endif // _COMPOSITE_ELEMENT
Definition: CompositeElement.h:97
Definition: CompositeElement.h:42
Definition: Detector.h:116
Definition: Element.h:393
Definition: Element.h:173
Definition: Random.h:28
Definition: GenericCompositeModel.h:120
Definition: GenericCompositeModel.h:64
Definition: CompositeElement.h:30
Definition: OMModel.h:204
Definition: OpticalElement.h:87
Definition: Element.h:58
Definition: Recipe.h:142
Definition: ReferenceFrame.h:59
Definition: GenericCompositeModel.h:106
Definition: OpticalElement.h:54