-
Notifications
You must be signed in to change notification settings - Fork 0
/
operator_pow.hpp
44 lines (37 loc) · 1.15 KB
/
operator_pow.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: GPL-2.0
#ifndef OPERATOR_POW_HPP
#define OPERATOR_POW_HPP
#include "operator.hpp"
class OperatorPowState final : public Operator::StateTemplate<OperatorPowState> {
QJsonObject to_json() const override;
void from_json(const QJsonObject &) override;
public:
// Supported exponents:
// -3 -> 1/3 (cube root)
// -2 -> 1/2 (square root)
// 2 -> 2 (square)
// 3 -> 3 (cube)
// -1 -> -1 (inverse)
int exponent = -2;
};
class OperatorPow : public OperatorTemplate<OperatorId::Pow, OperatorPowState, 1, 1>
{
void state_reset() override;
bool input_connection_changed() override;
void execute() override;
MenuButton *menu;
void set_exponent(int exponent);
static QPixmap get_pixmap(int exponent, int size);
static const char *get_tooltip(int exponent);
static InitState make_init_state(int exponent);
public:
inline static constexpr const char *icon = ":/icons/pow.svg";
inline static constexpr const char *tooltip = "Add power function";
static std::vector<InitState> get_init_states();
using OperatorTemplate::OperatorTemplate;
void init() override;
private:
friend class Operator;
template<size_t N> void calculate();
};
#endif