LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pixmap3htileobject.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef PIXMAP3HTILEOBJECT_H_
23 #define PIXMAP3HTILEOBJECT_H_
24 
25 #include "pixmapobject.h"
26 #include <QRectF>
27 
28 class QPainter;
29 
30 namespace PixmapHTilingStyle
31 {
32  enum Enum
33  {
36  };
37 }
38 
40 {
41  Q_OBJECT
42 
43 public:
44 
46  Pixmap3HTileObject(const quint32 width, const quint32 height,
47  const QString& imageFilename,
48  const QVector<QRect>& sliceCoordinates,
50  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
51 
52  //this is the more friendly variant
53  Pixmap3HTileObject( const quint32 width, const quint32 height,
54  const QString& imageFilename,
55  const quint32 leftIn,const quint32 rightIn,
57  const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
58 
59  virtual ~Pixmap3HTileObject();
60 
61  virtual QSize size() const;
62  virtual int width() const;
63  virtual int height() const;
64  virtual QSizeF sizeF() const;
65 
66  //isSquare() from PixmapObject intentionally omitted because it's used for determining operations on the underlying pixmap,
67  // not the rendered version of the pixmaptileobject
68  //sizeOf() from PixmapObject intentionally omitted, since the underlying mem size of the pixmap is not affected by
69  // how the tiles are defined
70 
71  //WARNING: no guard on validity on undelying pixmap! check in caller if unsure
72  // paint() functions are OUTPUT functions -- they paint this tiled pmo onto the painter
73  // the only INPUT "functions" for pixmap3htile are the constructors
74  virtual void paint(QPainter * painter);
75  virtual void paint(QPainter * painter,const QPointF& targetOriginInPainterCS);
76  virtual void paint(QPainter * painter,const QRectF& targetRectInPainterCS);
77  virtual void paint(QPainter * painter,const QRect& targetRectInPainterCS,
78  const QRect& sourceRect);
79 
80  virtual bool resize(const QSize& size);
81  virtual bool resize(const quint32 w,const quint32 h);
82 
83  virtual bool retile(const quint32 leftIn,const quint32 rightIn,
85  PixmapHTilingStyle::Enum sideTilingStyle = PixmapHTilingStyle::Scale); //TODO: fix this OOP plumbing problem w/ OR'ing styles
86 
87  virtual bool retile(const QVector<QRect>& sliceCoordinates,
90  static bool makeSlices(const quint32 width, const quint32 height,
91  const quint32 leftIn,const quint32 rightIn,
92  QVector<QRect>& r_slices,
93  QRect& r_inCoords);
94 
95  friend class PixPager;
96  friend class PixPagerPage;
97  friend class PixPagerAtlasPage;
98 
99 protected:
100 
102  QSize m_destinationSizeRequested; //how large this needs to paint itself.
103  //geom and boundingrect are computed from this
104  QRect m_inCoords; //using QRect as a convenient way to store topIn,leftIn..etc passed in
105  //this is used by resize() so it can reuse the original "in" coords
106  //
107  QRectF m_geom; //calculated automatically from the slice coordinate setup
108  QRectF m_boundingRect; //derived from m_geom
109 
110  /*
111  [0][1][2]
112  */
113 
114  QVector<QRect> m_sourceRects;
115  QVector<QRectF> m_destRects;
116 
119 
120 };
121 
122 
123 #endif /* PIXMAP3HTILEOBJECT_H_ */