NAP
parametermat.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "mathutils.h"
9 
10 // External Includes
11 #include <parameter.h>
12 #include <nap/signalslot.h>
13 
14 namespace nap
15 {
20  template<typename T>
21  class ParameterMat : public Parameter
22  {
23  RTTI_ENABLE(Parameter)
24  public:
25 
31  virtual void setValue(const Parameter& value) override;
32 
38  void setValue(T value);
39 
40  public:
41  T mValue;
43  };
44 
45 
47  // Matrix Parameter Type Definitions
49 
52 
53 
55  // Template Definitions
57 
58  template<typename T>
60  {
61  const ParameterMat<T>* derived_type = rtti_cast<const ParameterMat<T>>(&value);
62  assert(derived_type != nullptr);
63  setValue(derived_type->mValue);
64  }
65 
66  template<typename T>
68  {
69  // Set the components for each element individually
70  T oldValue = mValue;
71  mValue = value;
72 
73  if (oldValue != mValue)
74  valueChanged(mValue);
75  }
76 }
77 
81 #define DEFINE_MATRIX_PARAMETER(Type) \
82  RTTI_BEGIN_CLASS(Type) \
83  RTTI_PROPERTY("Value", &Type::mValue, nap::rtti::EPropertyMetaData::Default) \
84  RTTI_FUNCTION("setValue", static_cast<void (Type::*)(decltype(Type::mValue))>(&Type::setValue)) \
85  RTTI_END_CLASS
nap::Parameter
Definition: parameter.h:20
nap::Signal< T >
nap::ParameterMat::setValue
virtual void setValue(const Parameter &value) override
Definition: parametermat.h:59
nap::ParameterMat::valueChanged
Signal< T > valueChanged
Signal that's raised when the value changes.
Definition: parametermat.h:42
nap::ParameterMat
Definition: parametermat.h:21
nap
Definition: templateapp.h:17
nap::ParameterMat::mValue
T mValue
Property: 'Value' the value of this parameter.
Definition: parametermat.h:41