All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PaperItem.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2014 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file ItemGroup.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "PaperItem.h"
30 #include "ItemController.h"
31 #include "Context.h"
32 #include "Scene.h"
33 #include "Observable.h"
34 #include "../../../color/RGBAColor.h"
35 #include "../../../../qt/widgets/Utils.h"
36 #include "../../../../geometry/Envelope.h"
37 #include "../../../../common/STLUtils.h"
38 
39 // Qt
40 #include <QPixmap>
41 
43  ObjectItem(controller, o)
44 {
45 
46 }
47 
49 {
50 
51 }
52 
54 {
55  if(!m_model)
56  return;
57 
58  te::color::RGBAColor** rgba = context.getPixmap();
59 
60  if(!rgba)
61  return;
62 
63  Utils* utils = Context::getInstance()->getUtils();
64 
65  if(!utils)
66  return;
67 
68  te::gm::Envelope box = utils->viewportBox(m_model->getBox());
69 
70  if(!box.isValid())
71  return;
72 
73  QPixmap pixmap;
74  QImage* img = 0;
75 
76  if(rgba)
77  {
78  img = te::qt::widgets::GetImage(rgba, box.getWidth(), box.getHeight());
79  pixmap = QPixmap::fromImage(*img);
80  }
81 
82  te::common::Free(rgba, box.getHeight());
83  if(img)
84  delete img;
85 
86  setPixmap(pixmap);
87  update();
88 }
89 
virtual void updateObserver(ContextItem context)
Definition: PaperItem.cpp:53
PaperItem(ItemController *controller, Observable *o)
Definition: PaperItem.cpp:42
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
te::color::RGBAColor ** getPixmap()
Definition: ContextItem.cpp:82
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
Utils * getUtils()
Definition: Context.cpp:126
virtual te::gm::Envelope viewportBox(te::gm::Envelope box)
Definition: Utils.cpp:164
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
Definition: Utils.cpp:63
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
static Context * getInstance()
This function is called to create an instance of the class.
Definition: Context.cpp:46
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438