aboutsummaryrefslogtreecommitdiff
path: root/src/labeller.h
blob: e0dc090f75c972a2263232190f802aae05729460 (plain)
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
#pragma once
#include <memory>
#include <vector>
#include <string>
#include <utility>
#include <filesystem>

namespace backend {
    struct labeller_impl;

    struct rect {
        int x1=0, x2=0, y1=0, y2=0;
    };

    struct label {
        label() {}
        label(const std::string& name, double time) : name(name), time(time) {}
        std::string name;
        double time;
        rect location;
    };

    class labeller {
        public:
            labeller(const std::filesystem::path& savepath);
            std::pair<label, label> getSurrounding(double time) const;
            std::vector<std::string> getLabels() const;
            std::vector<std::string> getRectangleLabels() const;
            void applyLabel(std::string name, double time);
            void deleteLabel(double time); // Deletes closest to time, last added if ties
            void undo();
            void redo();
            void save() const;

        private:
            std::shared_ptr<labeller_impl> data;
    };
}