mbsimcontrol 4.0.0 MBSim Control Module

signal_observer.h
1 /* Copyright (C) 2004-2020 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@gmail.com
18 */
19
20 #ifndef _SIGNAL_OBSERVER_H__
21 #define _SIGNAL_OBSERVER_H__
22
23 #include "mbsim/observers/observer.h"
24
25 #include <mbsim/utils/boost_parameters.h>
26 #include <mbsim/utils/openmbv_utils.h>
27
28 namespace OpenMBV {
29 class IvScreenAnnotation;
30 }
31
32 namespace MBSimControl {
33
34 class Signal;
35
36 class SignalObserver : public MBSim::Observer {
37 private:
38 Signal *signal{nullptr};
39 Signal *position{nullptr};
40 std::shared_ptr<MBSim::OpenMBVArrow> ombvArrow;
41 std::shared_ptr<OpenMBV::Arrow> openMBVArrow;
42 std::shared_ptr<OpenMBV::IvScreenAnnotation> openMBVIvScreenAnnotation;
43 std::string saved_signal;
44 std::string saved_position;
45
46 public:
47 SignalObserver(const std::string &name="") : MBSim::Observer(name) { }
48
49 void setSignal(Signal *signal_) { signal = signal_; }
50 void setPosition(Signal *position_) { position = position_; }
51
52 void init(InitStage stage, const MBSim::InitConfigSet &config) override;
53 void initializeUsingXML(xercesc::DOMElement *element) override;
54 void plot() override;
55
56 // draw a Arrow for the signal
57 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(MBSim::OpenMBVArrow::ReferencePoint),MBSim::OpenMBVArrow::fromPoint)(colorRepresentation,(MBSim::OpenMBVArrow::ColorRepresentation),MBSim::OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
58 ombvArrow = std::shared_ptr<MBSim::OpenMBVArrow>(new MBSim::OpenMBVArrow(scaleLength,scaleSize,MBSim::OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
59 }
60
61 void setOpenMBVIvScreenAnnotation(const std::shared_ptr<OpenMBV::IvScreenAnnotation> &ivsa);
62 std::shared_ptr<OpenMBV::IvScreenAnnotation> getOpenMBVIvScreenAnnotation() const;
63 };
64
65 }
66
67 #endif
MBSim::OpenMBVArrow
MBSimControl::Signal
Signal.
Definition: signal_.h:38
MBSim::Element::InitStage
InitStage
MBSim::Element::name
std::string name
MBSim::Observer
MBSimControl::SignalObserver
Definition: signal_observer.h:36