-
Notifications
You must be signed in to change notification settings - Fork 0
/
operator_const.hpp
66 lines (49 loc) · 1.47 KB
/
operator_const.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: GPL-2.0
#ifndef OPERATOR_CONST_HPP
#define OPERATOR_CONST_HPP
#include "operator.hpp"
#include "color.hpp"
#include <QImage>
enum class ColorType;
class OperatorConstState final : public Operator::StateTemplate<OperatorConstState> {
QJsonObject to_json() const override;
void from_json(const QJsonObject &) override;
public:
ColorType color_type = ColorType::RW;
std::complex<double> v = {1.0, 0.0};
double scale = 1.0;
};
class OperatorConst : public OperatorTemplate<OperatorId::Const, OperatorConstState, 0, 1>
{
static constexpr size_t size = 128;
static constexpr double scale = 1.05;
AlignedBuf<uint32_t> imagebuf;
Handle *handle;
QGraphicsTextItem *text;
ColorType current_color_type;
bool dont_accumulate_undo;
void placed() override;
void state_reset() override;
void clear();
void paint_image();
void place_handle();
void set(std::complex<double>);
bool handle_click(QGraphicsSceneMouseEvent *event) override;
void drag_handle(const QPointF &p, Qt::KeyboardModifiers) override;
void restore_handles() override;
// Switch between color modes
MenuButton *mode_menu;
void switch_mode(ColorType type);
// Overall scale
Scroller *scroller_scale;
void set_scale(double scale);
void set_scroller();
// Paint
void calculate();
public:
inline static constexpr const char *icon = ":/icons/const.svg";
inline static constexpr const char *tooltip = "Add Constant";
OperatorConst(MainWindow &w);
void init() override;
};
#endif