File indexing completed on 2025-01-05 03:59:17
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de> 0004 // 0005 0006 #ifndef MARBLE_MARBLEGRAPHICSITEM_H 0007 #define MARBLE_MARBLEGRAPHICSITEM_H 0008 0009 #include "digikam_export.h" 0010 0011 #include <QtGlobal> 0012 0013 class QEvent; 0014 class QObject; 0015 class QPainter; 0016 class QRectF; 0017 class QSizeF; 0018 class QPointF; 0019 0020 namespace Marble 0021 { 0022 0023 class AbstractMarbleGraphicsLayout; 0024 class ViewportParams; 0025 0026 class MarbleGraphicsItemPrivate; 0027 0028 class DIGIKAM_EXPORT MarbleGraphicsItem 0029 { 0030 public: 0031 enum CacheMode { 0032 NoCache, 0033 ItemCoordinateCache, 0034 DeviceCoordinateCache 0035 }; 0036 0037 virtual ~MarbleGraphicsItem(); 0038 0039 /** 0040 * Paints the item on the screen in view coordinates. 0041 * It is not safe to call this function from a thread other than the gui thread. 0042 */ 0043 bool paintEvent( QPainter *painter, const ViewportParams *viewport ); 0044 0045 /** 0046 * Returns true if the Item contains @p point in parent coordinates. 0047 */ 0048 bool contains( const QPointF& point ) const; 0049 0050 /** 0051 * Returns the layout of the MarbleGraphicsItem. 0052 */ 0053 AbstractMarbleGraphicsLayout *layout() const; 0054 0055 /** 0056 * Set the layout of the graphics item. The layout will now handle positions of added child 0057 * items. The MarbleGraphicsItem takes ownership of the layout. 0058 */ 0059 void setLayout( AbstractMarbleGraphicsLayout *layout ); 0060 0061 /** 0062 * Returns the cache mode of the item 0063 */ 0064 CacheMode cacheMode() const; 0065 0066 /** 0067 * Set the cache mode of the item 0068 */ 0069 void setCacheMode( CacheMode mode ); 0070 0071 /** 0072 * Returns if the item is visible. 0073 */ 0074 bool visible() const; 0075 0076 /** 0077 * Makes the item visible or invisible, depending on @p visible. 0078 */ 0079 void setVisible( bool visible ); 0080 0081 /** 0082 * Hides the item. Equivalent to setVisible( false ) 0083 */ 0084 void hide(); 0085 0086 /** 0087 * Shows the item. Equivalent to setVisible( true ) 0088 */ 0089 void show(); 0090 0091 /** 0092 * Returns the size of the item 0093 */ 0094 QSizeF size() const; 0095 0096 /** 0097 * Set the size of the item 0098 */ 0099 void setSize( const QSizeF& size ); 0100 0101 /** 0102 * Returns the size of the content of the MarbleGraphicsItem. 0103 * This is identical to size() for default MarbleGraphicsItems. 0104 */ 0105 virtual QSizeF contentSize() const; 0106 0107 /** 0108 * Set the size of the content of the item. 0109 */ 0110 virtual void setContentSize( const QSizeF& size ); 0111 0112 /** 0113 * Returns the rect of the content in item coordinates. 0114 */ 0115 virtual QRectF contentRect() const; 0116 0117 virtual void setProjection(const ViewportParams *viewport ); 0118 0119 protected: 0120 explicit MarbleGraphicsItem(MarbleGraphicsItemPrivate *dd); 0121 0122 /** 0123 * Paints the item in item coordinates. This has to be reimplemented by the subclass 0124 * This function will be called by paintEvent(). 0125 */ 0126 virtual void paint( QPainter *painter ); 0127 0128 virtual bool eventFilter( QObject *object, QEvent *e ); 0129 0130 /** 0131 * Marks the item and all parent items as invalid. If caching is enabled, the next paintEvent() 0132 * will cause the cache to be recreated, such that the paintEvent()s after will be optimized. 0133 */ 0134 void update(); 0135 0136 protected: 0137 MarbleGraphicsItemPrivate * const d_ptr; 0138 0139 private: 0140 Q_DISABLE_COPY(MarbleGraphicsItem) 0141 Q_DECLARE_PRIVATE(MarbleGraphicsItem) 0142 }; 0143 0144 } // Namespace Marble 0145 0146 #endif