GraphicsItem.hpp
1 #pragma once
2 #include <QList>
3 #include <QPainterPath>
4 
5 #include <score_lib_base_export.h>
6 
7 #include <memory>
8 #include <optional>
9 #include <verdigris>
10 class QGraphicsObject;
11 class QGraphicsItem;
12 class QGraphicsView;
13 
14 namespace score
15 {
16 struct DocumentContext;
17 }
25 SCORE_LIB_BASE_EXPORT void deleteGraphicsObject(QGraphicsObject* item);
26 SCORE_LIB_BASE_EXPORT void deleteGraphicsItem(QGraphicsItem* item);
27 
28 SCORE_LIB_BASE_EXPORT
29 QGraphicsView* getView(const QGraphicsItem& self);
30 SCORE_LIB_BASE_EXPORT
31 QGraphicsView* getView(const QPainter& painter);
32 
33 SCORE_LIB_BASE_EXPORT
34 QImage newImage(double logical_w, double logical_h);
35 
36 SCORE_LIB_BASE_EXPORT
37 std::optional<QPointF> mapPointToItem(QPoint global, QGraphicsItem& item);
38 
39 template <typename T>
41 {
42  T* impl{};
43  graphics_item_ptr() = default;
44  graphics_item_ptr(const graphics_item_ptr&) = default;
45  graphics_item_ptr(graphics_item_ptr&&) noexcept = default;
46  graphics_item_ptr& operator=(const graphics_item_ptr&) = default;
47  graphics_item_ptr& operator=(graphics_item_ptr&&) noexcept = default;
48 
49  graphics_item_ptr(T* p)
50  : impl{p}
51  {
52  }
53 
54  ~graphics_item_ptr() { deleteGraphicsItem(impl); }
55 
56  auto operator=(T* other) { impl = other; }
57 
58  operator bool() const { return impl; }
59 
60  operator T*() const { return impl; }
61 
62  T& operator*() const { return *impl; }
63 
64  T* operator->() const { return impl; }
65 };
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: GraphicsItem.hpp:41