All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LegendChildItem.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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 LegendChildItem.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "LegendChildItem.h"
30 #include "../../core/pattern/mvc/ItemController.h"
31 #include "../core/Scene.h"
32 #include "../../core/pattern/mvc/Observable.h"
33 #include "../../../color/RGBAColor.h"
34 #include "../../../qt/widgets/Utils.h"
35 #include "../../../geometry/Envelope.h"
36 #include "../../../common/STLUtils.h"
37 
38 // Qt
39 #include <QPixmap>
40 
42  LegendItem(controller, o)
43 {
44  this->setFlags(QGraphicsItem::ItemIsMovable
45  | QGraphicsItem::ItemIsSelectable
46  | QGraphicsItem::ItemSendsGeometryChanges
47  | QGraphicsItem::ItemIsFocusable);
48 
49  m_nameClass = std::string(this->metaObject()->className());
50 }
51 
53 {
54 
55 }
56 
57 void te::layout::LegendChildItem::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0 */ )
58 {
59  Q_UNUSED( option );
60  Q_UNUSED( widget );
61  if ( !painter )
62  {
63  return;
64  }
65 
66  drawBackground( painter );
67 
68  QRectF boundRect;
69  boundRect = boundingRect();
70 
71  painter->save();
72  painter->translate( -boundRect.bottomLeft().x(), -boundRect.topRight().y() );
73  QRectF rtSource( 0, 0, m_pixmap.width(), m_pixmap.height() );
74  painter->drawPixmap(boundRect, m_pixmap, rtSource);
75  painter->restore();
76 
77  drawBorder(painter);
78 
79  //Draw Selection
80  if (option->state & QStyle::State_Selected)
81  {
82  drawSelection(painter);
83  }
84 }
85 
86 
87 
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Class that represents a graphic legend of a map. Its coordinate system is the same of scene (millimet...
Definition: LegendItem.h:54
std::string m_nameClass
Class name.
Definition: ItemObserver.h:201
LegendChildItem(ItemController *controller, Observable *o)
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Mandatory implementation from QGraphicsItem.