Marble

MarbleGraphicsItem.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Bastian Holst <[email protected]>
4 //
5 
6 #ifndef MARBLE_MARBLEGRAPHICSITEM_H
7 #define MARBLE_MARBLEGRAPHICSITEM_H
8 
9 #include "marble_export.h"
10 
11 #include <QtGlobal>
12 
13 class QEvent;
14 class QObject;
15 class QPainter;
16 class QRectF;
17 class QSizeF;
18 class QPointF;
19 
20 namespace Marble
21 {
22 
23 class AbstractMarbleGraphicsLayout;
24 class ViewportParams;
25 
26 class MarbleGraphicsItemPrivate;
27 
28 class MARBLE_EXPORT MarbleGraphicsItem
29 {
30  public:
31  enum CacheMode {
32  NoCache,
33  ItemCoordinateCache,
34  DeviceCoordinateCache
35  };
36 
37  virtual ~MarbleGraphicsItem();
38 
39  /**
40  * Paints the item on the screen in view coordinates.
41  * It is not safe to call this function from a thread other than the gui thread.
42  */
43  bool paintEvent( QPainter *painter, const ViewportParams *viewport );
44 
45  /**
46  * Returns true if the Item contains @p point in parent coordinates.
47  */
48  bool contains( const QPointF& point ) const;
49 
50  /**
51  * Returns the layout of the MarbleGraphicsItem.
52  */
53  AbstractMarbleGraphicsLayout *layout() const;
54 
55  /**
56  * Set the layout of the graphics item. The layout will now handle positions of added child
57  * items. The MarbleGraphicsItem takes ownership of the layout.
58  */
59  void setLayout( AbstractMarbleGraphicsLayout *layout );
60 
61  /**
62  * Returns the cache mode of the item
63  */
64  CacheMode cacheMode() const;
65 
66  /**
67  * Set the cache mode of the item
68  */
69  void setCacheMode( CacheMode mode );
70 
71  /**
72  * Returns if the item is visible.
73  */
74  bool visible() const;
75 
76  /**
77  * Makes the item visible or invisible, depending on @p visible.
78  */
79  void setVisible( bool visible );
80 
81  /**
82  * Hides the item. Equivalent to setVisible( false )
83  */
84  void hide();
85 
86  /**
87  * Shows the item. Equivalent to setVisible( true )
88  */
89  void show();
90 
91  /**
92  * Returns the size of the item
93  */
94  QSizeF size() const;
95 
96  /**
97  * Set the size of the item
98  */
99  void setSize( const QSizeF& size );
100 
101  /**
102  * Returns the size of the content of the MarbleGraphicsItem.
103  * This is identical to size() for default MarbleGraphicsItems.
104  */
105  virtual QSizeF contentSize() const;
106 
107  /**
108  * Set the size of the content of the item.
109  */
110  virtual void setContentSize( const QSizeF& size );
111 
112  /**
113  * Returns the rect of the content in item coordinates.
114  */
115  virtual QRectF contentRect() const;
116 
117  virtual void setProjection(const ViewportParams *viewport );
118 
119  protected:
120  explicit MarbleGraphicsItem(MarbleGraphicsItemPrivate *dd);
121 
122  /**
123  * Paints the item in item coordinates. This has to be reimplemented by the subclass
124  * This function will be called by paintEvent().
125  */
126  virtual void paint( QPainter *painter );
127 
128  virtual bool eventFilter( QObject *object, QEvent *e );
129 
130  /**
131  * Marks the item and all parent items as invalid. If caching is enabled, the next paintEvent()
132  * will cause the cache to be recreated, such that the paintEvent()s after will be optimized.
133  */
134  void update();
135 
136  protected:
137  MarbleGraphicsItemPrivate * const d_ptr;
138 
139  private:
140  Q_DISABLE_COPY(MarbleGraphicsItem)
141  Q_DECLARE_PRIVATE(MarbleGraphicsItem)
142 };
143 
144 } // Namespace Marble
145 
146 #endif
Binds a QML item to a specific geodetic location in screen coordinates.
void update(Part *part, const QByteArray &data, qint64 dataSize)
Q_INVOKABLE void setProjection(uint proj)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.