All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ItemObserver.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 ItemObserver.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "ItemObserver.h"
30 #include "Context.h"
31 #include "AbstractScene.h"
32 #include "Properties.h"
33 #include "ItemController.h"
34 #include "Observable.h"
35 #include "../../../../../geometry/Coord2D.h"
36 
38  m_controller(controller),
39  m_model(o),
40  m_printable(true),
41  m_ppi(96)
42 {
43  m_model->addObserver(this);
44 }
45 
47 {
48  if(m_controller)
49  delete (ItemController*)m_controller;
50 }
51 
53 {
54  return m_model->getProperties();
55 }
56 
57 void te::layout::ItemObserver::redraw( const double& scaleFactor /*= 1.*/ )
58 {
59  refresh();
60  m_controller->redraw(scaleFactor);
61 }
62 
64 {
65  te::gm::Coord2D coord = getPosition();
66  m_controller->setPosition(coord.x, coord.y);
67  setZValueItem(getZValueItem());
68 }
69 
70 void te::layout::ItemObserver::setPPI( const double& ppi )
71 {
72  m_ppi = ppi;
73 }
74 
76 {
77  if(m_controller)
78  {
79  m_controller->updateProperties(properties);
80  redraw();
81  }
82 }
83 
85 {
86  m_printable = print;
87 }
88 
90 {
91  return m_printable;
92 }
93 
95 {
96  return m_controller;
97 }
98 
100 {
101  return m_model;
102 }
103 
105 {
106  return m_model->getName();
107 }
108 
110 {
111  m_model->setZValue(z);
112 }
double y
y-coordinate.
Definition: Coord2D.h:87
te::layout::Observable * m_model
Definition: ItemObserver.h:82
double x
x-coordinate.
Definition: Coord2D.h:86
virtual void setPrintable(bool print)
virtual void setZValueItem(int z)
virtual std::vector< Property > getProperties()
Definition: Properties.h:116
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
virtual bool isPrintable()
ItemObserver(ItemController *controller=0, Observable *o=0)
virtual bool addObserver(Observer *o)=0
virtual ItemController * getController()
virtual Observable * getModel()
virtual void redraw(const double &scaleFactor=1.)
virtual te::layout::Properties * getProperties() const
virtual void setPPI(const double &ppi)
virtual std::string getName()
virtual void updateProperties(te::layout::Properties *properties)