Loading...
Searching...
No Matches
score-plugin-gfx/Gfx/Images/Process.hpp
1#pragma once
2#include <Process/Dataflow/Port.hpp>
3#include <Process/Drop/ProcessDropHandler.hpp>
4#include <Process/GenericProcessFactory.hpp>
5#include <Process/Process.hpp>
6
7#include <Gfx/CommandFactory.hpp>
8#include <Gfx/Graph/ImageNode.hpp>
9#include <Gfx/Images/Metadata.hpp>
10#include <Library/LibraryInterface.hpp>
11
12#include <score/command/PropertyCommand.hpp>
13
14#include <ossia/detail/hash_map.hpp>
15
16namespace Gfx
17{
18std::vector<score::gfx::Image> getImages(const ossia::value& val);
19ossia::value fromImageSet(const tcb::span<score::gfx::Image>& images);
20void releaseImages(std::vector<score::gfx::Image>& imgs);
21
23{
24public:
25 std::optional<score::gfx::Image> acquire(const std::string& path);
26 void release(score::gfx::Image&& img);
27
28 static ImageCache& instance() noexcept;
29
30private:
31 ossia::hash_map<std::string, std::pair<int, score::gfx::Image>> m_images;
32};
33}
34W_REGISTER_ARGTYPE(score::gfx::Image)
35
36namespace Gfx::Images
37{
38class Model final : public Process::ProcessModel
39{
40 SCORE_SERIALIZE_FRIENDS
41 PROCESS_METADATA_IMPL(Gfx::Images::Model)
42 W_OBJECT(Model)
43
44public:
45 constexpr bool hasExternalUI() { return false; }
46 Model(const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
47
48 template <typename Impl>
49 Model(Impl& vis, QObject* parent)
50 : Process::ProcessModel{vis, parent}
51 {
52 vis.writeTo(*this);
53 }
54
55 ~Model() override;
56
57 //std::vector<score::gfx::Image> images() const noexcept;
58 //void setImages(const std::vector<score::gfx::Image>& f);
59 // void imagesChanged() W_SIGNAL(imagesChanged);
60 // PROPERTY(
61 // std::vector<score::gfx::Image>,
62 // images READ images WRITE setImages NOTIFY imagesChanged)
63 //
64private:
65 void on_imagesChanged(const ossia::value& v);
66 QString prettyName() const noexcept override;
67 std::vector<score::gfx::Image> m_currentImages;
68};
69
70using ProcessFactory = Process::ProcessFactory_T<Gfx::Images::Model>;
71
72class LibraryHandler final : public Library::LibraryInterface
73{
74 SCORE_CONCRETE("0916759f-a5f6-4870-a96b-4e1e5efe5885")
75
76 QSet<QString> acceptedFiles() const noexcept override;
77};
78
79class DropHandler final : public Process::ProcessDropHandler
80{
81 SCORE_CONCRETE("f37aa176-d8be-45bc-b833-d014efba6157")
82public:
83 QSet<QString> mimeTypes() const noexcept override;
84 QSet<QString> fileExtensions() const noexcept override;
85 void dropCustom(
86 std::vector<ProcessDrop>& drops, const QMimeData& data,
87 const score::DocumentContext& ctx) const noexcept override;
88};
89
90}
The Process class.
Definition score-lib-process/Process/Process.hpp:61
The id_base_t class.
Definition Identifier.hpp:57
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:28
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Definition score-plugin-gfx/Gfx/Images/Process.hpp:23
Definition TimeValue.hpp:21
Image data and metadata.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:146