All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NorthItem.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 NorthItem.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "NorthItem.h"
30 #include "../../item/NorthModel.h"
31 
33  ObjectItem(controller, o)
34 {
35  m_nameClass = std::string(this->metaObject()->className());
36 }
37 
39 {
40 
41 }
42 
43 void te::layout::NorthItem::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0 */ )
44 {
45  Q_UNUSED( option );
46  Q_UNUSED( widget );
47  if ( !painter )
48  {
49  return;
50  }
51 
52  if(m_resizeMode)
53  {
54  ObjectItem::paint(painter, option, widget);
55  return;
56  }
57 
58  drawBackground(painter);
59 
60  drawRectangle(painter);
61 
62  drawBorder(painter);
63 
64  //Draw Selection
65  if (option->state & QStyle::State_Selected)
66  {
67  drawSelection(painter);
68  }
69 }
70 
71 void te::layout::NorthItem::drawRectangle( QPainter * painter )
72 {
73  NorthModel* model = dynamic_cast<NorthModel*>(m_model);
74  if(!model)
75  {
76  return;
77  }
78 
79  painter->save();
80 
81  QPainterPath rect_path;
82  rect_path.addRect(boundingRect());
83 
84  QColor cpen(0,0,0);
85  QPen pn(cpen, 0, Qt::SolidLine);
86  painter->setPen(pn);
87 
88  te::color::RGBAColor clrBack = model->getBackgroundColor();
89 
90  QColor cbrush;
91  cbrush.setRed(clrBack.getRed());
92  cbrush.setGreen(clrBack.getGreen());
93  cbrush.setBlue(clrBack.getBlue());
94  cbrush.setAlpha(clrBack.getAlpha());
95 
96  painter->setBrush(cbrush);
97  painter->drawPath(rect_path);
98 
99  painter->restore();
100 }
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:295
virtual ~NorthItem()
Destructor.
Definition: NorthItem.cpp:38
virtual void drawRectangle(QPainter *painter)
Definition: NorthItem.cpp:71
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Definition: RGBAColor.h:305
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Definition: RGBAColor.h:300
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Abstract class that represents a graphic item. This object is of type QGraphicsObject.
Definition: ObjectItem.h:61
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Definition: RGBAColor.h:310
std::string m_nameClass
Class name.
Definition: ItemObserver.h:201
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Reimplemented from QGraphicsItem.
Definition: NorthItem.cpp:43
NorthItem(ItemController *controller, Observable *o)
Constructor.
Definition: NorthItem.cpp:32
Class that represents a "Model" part of Rectangle MVC component. Its coordinate system is the same of...
Definition: NorthModel.h:52
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Reimplemented from QGraphicsItem.
virtual te::color::RGBAColor getBackgroundColor()
Returns the background color of the MVC component.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
Class that represents a graphic Rectangle. Its coordinate system is the same of scene (millimeters)...