Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ItemController.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 ItemController.cpp
22
23
\brief
24
25
\ingroup layout
26
*/
27
28
// TerraLib
29
#include "
ItemController.h
"
30
#include "
ItemModelObservable.h
"
31
#include "
ItemObserver.h
"
32
#include "
ContextItem.h
"
33
#include "
Context.h
"
34
#include "../../../../../maptools/Canvas.h"
35
36
te::layout::ItemController::ItemController
(
Observable
* o ) :
37
m_model(o)
38
{
39
40
}
41
42
te::layout::ItemController::ItemController
(
Observable
* o,
LayoutAbstractObjectType
type ) :
43
m_model(o)
44
{
45
if
(
m_model
)
46
{
47
m_model
->
setType
(type);
48
}
49
}
50
51
te::layout::ItemController::~ItemController
()
52
{
53
if
(m_model)
54
{
55
ItemModelObservable
* model =
dynamic_cast<
ItemModelObservable
*
>
(m_model);
56
if
(model)
57
delete
model;
58
m_model = 0;
59
}
60
}
61
62
void
te::layout::ItemController::redraw
(
const
double
& zoomFactor )
63
{
64
ParamsCreate
params;
65
ContextItem
context(params, zoomFactor);
66
67
te::map::Canvas
* canvas =
Context::getInstance
()->
getCanvas
();
68
canvas->
clear
();
69
if
(m_model)
70
{
71
ItemModelObservable
* model =
dynamic_cast<
ItemModelObservable
*
>
(m_model);
72
if
(model)
73
model->
draw
(context);
74
}
75
canvas->
clear
();
76
}
77
78
const
te::layout::Observable
*
te::layout::ItemController::getModel
()
79
{
80
return
m_model;
81
}
82
83
const
te::layout::Observer
*
te::layout::ItemController::getView
()
84
{
85
return
m_view;
86
}
87
88
void
te::layout::ItemController::setBox
(
te::gm::Envelope
box )
89
{
90
if
(m_model)
91
{
92
ItemModelObservable
* model =
dynamic_cast<
ItemModelObservable
*
>
(m_model);
93
if
(model)
94
model->
setBox
(box);
95
}
96
}
97
98
void
te::layout::ItemController::updateProperties
(
te::layout::Properties
* properties )
99
{
100
if
(m_model)
101
{
102
ItemModelObservable
* model =
dynamic_cast<
ItemModelObservable
*
>
(m_model);
103
if
(model)
104
model->
updateProperties
(properties);
105
}
106
}
107
108
bool
te::layout::ItemController::contains
(
const
te::gm::Coord2D
&coord )
const
109
{
110
if
(m_model)
111
{
112
ItemModelObservable
* model =
dynamic_cast<
ItemModelObservable
*
>
(m_model);
113
if
(model)
114
return
model->
contains
(coord);
115
}
116
return
false
;
117
}
te::layout::Observable
Definition:
Observable.h:45
te::layout::ContextItem
Definition:
ContextItem.h:41
ItemController.h
te::layout::ParamsCreate
Definition:
ParamsCreate.h:35
te::layout::ItemController::contains
virtual bool contains(const te::gm::Coord2D &coord) const
Definition:
ItemController.cpp:108
ItemObserver.h
te::layout::ItemController::getView
const Observer * getView()
Definition:
ItemController.cpp:83
te::layout::ItemController::updateProperties
virtual void updateProperties(te::layout::Properties *properties)
Definition:
ItemController.cpp:98
te::layout::ItemController::redraw
virtual void redraw(const double &zoomFactor)
Definition:
ItemController.cpp:62
te::layout::ItemModelObservable
Definition:
ItemModelObservable.h:44
te::map::Canvas::clear
virtual void clear()=0
It clears the canvas content and fills with the background color.
te::layout::Properties
Definition:
Properties.h:43
Context.h
te::gm::Coord2D
An utility struct for representing 2D coordinates.
Definition:
Coord2D.h:40
te::layout::ItemController::getModel
const Observable * getModel()
Definition:
ItemController.cpp:78
te::layout::ItemModelObservable::updateProperties
virtual void updateProperties(te::layout::Properties *properties)
Definition:
ItemModelObservable.cpp:227
te::layout::ItemController::m_model
Observable * m_model
Definition:
ItemController.h:62
te::layout::Observer
Definition:
Observer.h:42
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition:
Envelope.h:51
ContextItem.h
te::layout::ItemController::ItemController
ItemController(Observable *o)
Definition:
ItemController.cpp:36
te::layout::LayoutAbstractObjectType
LayoutAbstractObjectType
Enum TdkAbstractComponentType. This is the enumeration of the components types.
Definition:
AbstractType.h:38
te::map::Canvas
A canvas is an abstraction of a drawing area.
Definition:
Canvas.h:91
ItemModelObservable.h
te::layout::ItemModelObservable::draw
virtual void draw(ContextItem context)=0
te::layout::ItemController::~ItemController
virtual ~ItemController()
Definition:
ItemController.cpp:51
te::layout::Observable::setType
virtual void setType(LayoutAbstractObjectType type)=0
te::layout::Context::getInstance
static Context * getInstance()
This function is called to create an instance of the class.
Definition:
Context.cpp:46
te::layout::ItemModelObservable::contains
virtual bool contains(const te::gm::Coord2D &coord) const
Definition:
ItemModelObservable.cpp:217
te::layout::ItemModelObservable::setBox
virtual void setBox(te::gm::Envelope box)
Definition:
ItemModelObservable.cpp:168
te::layout::Context::getCanvas
te::map::Canvas * getCanvas()
Definition:
Context.cpp:116
te::layout::ItemController::setBox
virtual void setBox(te::gm::Envelope box)
Definition:
ItemController.cpp:88
BB_TL5
terralib5
src
terralib
layout
src
core
pattern
mvc
ItemController.cpp
Generated on Mon Sep 29 2014 13:46:34 for TerraLib by
1.8.7