All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ImageModel.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 ImageModel.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "ImageModel.h"
30 #include "../core/ContextItem.h"
31 #include "../../geometry/Envelope.h"
32 #include "../../color/RGBAColor.h"
33 #include "../../maptools/Canvas.h"
34 #include "../core/property/Property.h"
35 #include "../core/pattern/mvc/ItemModelObservable.h"
36 #include "../core/property/Properties.h"
37 #include "../core/enum/Enums.h"
38 #include "../core/pattern/singleton/Context.h"
39 
41  m_fileName(""),
42  m_imgType(te::map::JPEG)
43 {
44  m_type = Enums::getInstance().getEnumObjectType()->getImageItem();
45 
46  m_borderColor = te::color::RGBAColor(0, 0, 0, 255);
48 
49  m_box = te::gm::Envelope(0., 0., 90., 90.);
50 
52 
53  m_border = true;
54 }
55 
57 {
58 
59 }
60 
61 void te::layout::ImageModel::setFileName( std::string fileName )
62 {
63  m_fileName = fileName;
64 }
65 
67 {
68  return m_fileName;
69 }
70 
72 {
74 
76 
77  Property pro_fileName(m_hashCode);
78  pro_fileName.setName("fileName");
79  pro_fileName.setValue(m_fileName, dataType->getDataTypeImage());
80  pro_fileName.setMenu(true);
81  m_properties->addProperty(pro_fileName);
82 
83  return m_properties;
84 }
85 
87 {
89 
90  Properties* vectorProps = const_cast<Properties*>(properties);
91 
92  Property pro_fileName = vectorProps->contains("fileName");
93 
94  if(!pro_fileName.isNull())
95  {
96  m_fileName = pro_fileName.getValue().toString();
97  }
98 }
99 
101 {
102  return m_fileExtension;
103 }
104 
106 {
107  return m_imgType;
108 }
109 
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from ItemModelObservable.
Definition: ImageModel.cpp:86
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
Definition: Enums.h:38
Variant getValue()
Returns stored value.
Definition: Property.cpp:72
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
Definition: Enums.cpp:52
virtual te::map::ImageType getFileType()
Returns the type of the image.
Definition: ImageModel.cpp:105
virtual void setFileName(std::string fileName)
Change file name.
Definition: ImageModel.cpp:61
bool isNull()
Returns true if no value has been set, false otherwise.
Definition: Property.cpp:146
bool m_border
true if should be drawn border, false otherwise
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
EnumType * m_type
type of the MVC component
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
virtual std::string getFileExtension()
Returns the file extension.
Definition: ImageModel.cpp:100
static Enums & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
Definition: EnumDataType.h:48
te::gm::Envelope m_box
bounding rectangle
virtual te::layout::Properties * getProperties() const
Reimplemented from ItemModelObservable.
Definition: ImageModel.cpp:71
te::color::RGBAColor m_backgroundColor
background color
Class that represents a "Model" part of Image MVC component. Its coordinate system is the same of sce...
Properties * m_properties
properties
virtual Properties * getProperties() const
Reimplemented from Observable.
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Definition: Property.h:298
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
std::string toString()
Returns the value of string type. (The setValue method received a string)
Definition: Variant.cpp:311
virtual std::string getFileName()
Change file name.
Definition: ImageModel.cpp:66
ImageModel()
Constructor.
Definition: ImageModel.cpp:40
void setName(std::string name)
Sets the name of this property.
Definition: Property.cpp:62
virtual void setMenu(bool menu)
Sets true if property will be used in a menu, false otherwise.
Definition: Property.cpp:228
te::color::RGBAColor m_borderColor
border color
virtual void setHasWindows(bool windows)
Definition: Properties.h:280
virtual EnumType * getDataTypeImage() const
Returns value that represents type image (string) belonging to enumeration.
virtual bool contains(Property property)
Checks if the property is contained within the set of properties.
Definition: Properties.h:251
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
Definition: Property.h:47
virtual ~ImageModel()
Destructor.
Definition: ImageModel.cpp:56