31 #include "../../property/Property.h"
32 #include "../../../../geometry/Envelope.h"
33 #include "../../../../geometry/Coord2D.h"
34 #include "../../property/Properties.h"
35 #include "../../property/SharedProperties.h"
36 #include "../singleton/Context.h"
37 #include "../../enum/Enums.h"
46 m_publicProperties(0),
56 m_enableChildren(false)
90 if(m_publicProperties)
92 delete m_publicProperties;
93 m_publicProperties = 0;
105 std::pair<std::set<Observer*>::iterator,
bool> p = m_observers.insert(o);
115 int num = m_observers.erase(o);
125 std::set<Observer*>::iterator it;
126 for(it = m_observers.begin(); it != m_observers.end(); ++it)
128 (*it)->updateObserver(context);
139 m_properties->
clear();
144 pro_name.
setName(m_sharedProps->getName());
147 m_properties->addProperty(pro_name);
150 pro_id.
setName(m_sharedProps->getId());
152 m_properties->addProperty(pro_id);
155 pro_angle.
setName(m_sharedProps->getAngle());
157 m_properties->addProperty(pro_angle);
159 Property pro_backgroundcolor(m_hashCode);
160 pro_backgroundcolor.
setName(m_sharedProps->getBackgroundcolor());
162 pro_backgroundcolor.
setMenu(
true);
163 m_properties->addProperty(pro_backgroundcolor);
165 Property pro_bordercolor(m_hashCode);
166 pro_bordercolor.
setName(m_sharedProps->getBordercolor());
169 m_properties->addProperty(pro_bordercolor);
173 double x1 = m_box.getLowerLeftX();
174 double y1 = m_box.getLowerLeftY();
175 double width = m_box.getWidth();
176 double height = m_box.getHeight();
179 pro_x1.
setName(m_sharedProps->getX1());
182 m_properties->addProperty(pro_x1);
185 pro_y1.
setName(m_sharedProps->getY1());
188 m_properties->addProperty(pro_y1);
191 pro_width.
setName(m_sharedProps->getWidth());
194 m_properties->addProperty(pro_width);
197 pro_height.
setName(m_sharedProps->getHeight());
200 m_properties->addProperty(pro_height);
205 pro_zValue.
setName(m_sharedProps->getZValue());
208 m_properties->addProperty(pro_zValue);
211 pro_border.
setName(m_sharedProps->getBorder());
213 m_properties->addProperty(pro_border);
215 m_properties->setTypeObj(m_type);
231 return m_backgroundColor;
236 m_backgroundColor = color;
241 m_borderColor = color;
246 return m_borderColor;
254 m_properties->setObjectName(m_name);
256 if(m_publicProperties)
257 m_publicProperties->setObjectName(m_name);
267 m_oldPos.x = m_box.m_llx;
268 m_oldPos.y = m_box.m_lly;
272 double x2 = x + m_box.getWidth();
275 double y2 = y + m_box.getHeight();
285 return m_box.contains(env);
314 m_oldAngle = m_angle;
318 Property pro_backgroundcolor = vectorProps->
contains(m_sharedProps->getBackgroundcolor());
319 if(!pro_backgroundcolor.
isNull())
324 Property pro_bordercolor = vectorProps->
contains(m_sharedProps->getBordercolor());
325 if(!pro_bordercolor.
isNull())
335 m_oldPos.x = m_box.m_llx;
342 m_oldPos.y = m_box.m_lly;
413 if((w <= 0) || (h <= 0))
416 if(w == m_box.getWidth() && h == m_box.getHeight())
419 m_box.m_urx = m_box.m_llx + w;
420 m_box.m_ury = m_box.m_lly + h;
425 m_resizable = resize;
438 if((!canvas) || (!utils))
462 m_oldAngle = m_angle;
478 int nameLength = m_name.length();
483 type = m_type->getId();
486 int propertiesLength = 0;
494 propertiesLength = getProperties()->getProperties().size();
498 int hashcode = (nameLength +
id + type + propertiesLength) * 5;
501 std::time_t now = std::time(0);
503 std::tm *ltm = localtime(&now);
509 int year = 1900 + ltm->tm_year;
510 int month = 1 + ltm->tm_mon;
511 int day = ltm->tm_mday;
512 int hour = 1 + ltm->tm_hour;
513 int numberSecond = 1 + ltm->tm_min;
514 int numberMilliseconds = 1 + ltm->tm_sec;
516 hashcode *= year + month + day;
517 hashcode *= hour + numberSecond + numberMilliseconds;
539 return m_enableChildren;
544 m_enableChildren = value;
560 if(!m_enableChildren)
570 std::pair<std::set<ItemObserver*>::iterator,
bool> p = m_children.insert(item);
583 std::set<ItemObserver*>::iterator it = m_children.begin();
585 for( ; it != m_children.end(); it++)
587 if((*it)->getModel()->getHashCode() == hashCode)
589 int num = m_children.erase(*it);
603 if(!m_properties || m_publicProperties)
608 m_publicProperties->
clear();
610 std::vector<Property>::iterator it = m_properties->getProperties().begin();
612 for( ; it != m_properties->getProperties().end() ; ++it )
616 m_publicProperties->addProperty(*it);
620 m_publicProperties->setTypeObj(m_type);
622 return m_publicProperties;
627 std::set<ItemObserver*>::iterator it = m_children.begin();
629 for( ; it != m_children.end(); it++)
631 Properties* props = (*it)->getModel()->getPublicProperties();
633 std::vector<Property>::iterator itProp = props->
getProperties().begin();
645 std::set<ItemObserver*>::iterator it = m_children.begin();
647 for( ; it != m_children.end(); it++)
649 if((*it)->getModel()->getHashCode() == hashCode)
virtual void setPosition(const double &x, const double &y)
Change coordinate llx,lly of the MVC component.
virtual void setAngle(double angle)
Change the value of rotation of the MVC component.
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Class to represent a graphic object (MVC component) and widget object (MVC widget) type enumeration...
virtual ~ItemModelObservable()
Destructor.
virtual bool addProperty(Property property)
Adds the specified property to the set of properties for this object.
Variant getValue()
Returns stored value.
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
virtual int getZValue()
Reimplemented from Observable.
virtual EnumType * getDataTypeBool() const
Returns value that represents type bool belonging to enumeration.
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
virtual void setResizable(bool resize)
Reimplemented from Observable.
virtual void setType(EnumType *type)
Reimplemented from Observable.
virtual EnumType * getDataTypeDouble() const
Returns value that represents type double belonging to enumeration.
bool isNull()
Returns true if no value has been set, false otherwise.
virtual void setPolygonFillColor(const te::color::RGBAColor &color)=0
It sets the color used to fill the draw of polygon geometries.
virtual void drawRectW(te::gm::Envelope box)
Draw a rectangle in world coordinates (mm).
int getParentItemHashCode()
Returns the hashcode of the object that owns this property.
virtual EnumType * getDataTypeInt() const
Returns value that represents type integer belonging to enumeration.
Properties * m_publicProperties
public properties
virtual void setHashCode(int hashCode)
Sets the hashcode of a MVC component.
virtual bool isResizable()
Reimplemented from Observable.
Abstract class to represent an observer. "View" part of MVC component.
double m_urx
Upper right corner x-coordinate.
virtual te::gm::Coord2D getOldPos()
Returns the value of old position.
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
virtual std::vector< Property > getProperties()
Returns set of all properties.
An utility struct for representing 2D coordinates.
EnumType * m_type
type of the MVC component
virtual EnumType * getObjectUnknown() const
Returns value that represents unknown type belonging to enumeration.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
virtual void setBorder(bool value)
Change whether the border should be drawn or not.
virtual te::layout::Properties * getPublicProperties() const
Reimplemented from Observable.
virtual double getAngle()
Returns the value of rotation.
Abstract class to represent an observer. "View" part of MVC component.
virtual int getHashCode()
Reimplemented from Observable.
virtual te::color::RGBAColor getBorderColor()
Returns the border color of the MVC component.
virtual void notifyAll(ContextItem context)
Reimplemented from Observable.
virtual void updateChildrenProperties(Property prop)
double m_llx
Lower left corner x-coordinate.
virtual bool isEnableChildren()
Returns true if MVC component can have children, false otherwise.
static Enums & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
virtual Utils * getUtils()
virtual int getId()
Reimplemented from Observable.
virtual void setZValue(int zValue)
Reimplemented from Observable.
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
te::gm::Envelope m_box
bounding rectangle
virtual EnumType * getType()
Reimplemented from Observable.
virtual int calculateHashCode()
Returns a new hashcode.
virtual void setBackgroundColor(te::color::RGBAColor color)
Change the background color of the MVC component.
std::string m_name
name of the MVC component
virtual int getHashCode()=0
Returns the hashcode of a MVC component. Reimplement this function in a Observable subclass to provid...
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
te::color::RGBAColor m_backgroundColor
background color
virtual te::map::Canvas * getCanvas()
Return canvas.
virtual void setName(std::string name)
Change the name of the MVC component.
double toDouble()
Returns the value of double type. (The setValue method received a double)
virtual te::color::RGBAColor getBackgroundColor()
Returns the background color of the MVC component.
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
virtual bool isBorder()
Returns whether the border should be drawn or not.
Properties * m_properties
properties
double m_lly
Lower left corner y-coordinate.
virtual std::set< ItemObserver * > getChildren() const
Reimplemented from Observable.
virtual bool addChildren(ItemObserver *item)
Reimplemented from Observable.
virtual void drawBackground(ContextItem context)
Draws the background of the MVC component.
A canvas is an abstraction of a drawing area.
Abstract class to represent an observable. "Model" part of MVC component. All classes representing th...
virtual Properties * getProperties() const
Reimplemented from Observable.
virtual void setId(int id)
Reimplemented from Observable.
ItemModelObservable()
Constructor.
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
virtual std::string getName()
Reimplemented from Observable.
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
virtual void setPolygonContourColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw the boundary of polygon geometries.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
virtual bool addObserver(Observer *o)
Reimplemented from Observable.
virtual Observable * getModel()
Returns the "Model" part of the MVC.
virtual bool clear()
Clear set of properties of this object.
std::string toString()
Returns the value of string type. (The setValue method received a string)
void setEditable(bool editable)
Sets true if property is editable, false otherwise.
void setName(std::string name)
Sets the name of this property.
virtual void setMenu(bool menu)
Sets true if property will be used in a menu, false otherwise.
te::color::RGBAColor toColor()
Returns the value of te::color::RGBAColor type. (The setValue method received a te::color::RGBAColor)...
virtual te::gm::Envelope getBox()
Reimplemented from Observable.
virtual void resize(double w, double h)
Resize the bounding rectangle of the MVC component.
te::color::RGBAColor m_borderColor
border color
te::gm::Coord2D m_oldPos
value of old position
virtual void setBorderColor(te::color::RGBAColor color)
Change the background color of the MVC component.
virtual EnumType * getDataTypeString() const
Returns value that represents type string belonging to enumeration.
virtual void draw(ContextItem context)
Drawing method of the MVC component.
Utility class with functions to manipulate the canvas and conversion between projections.
virtual double getOldAngle()
Returns the value of old rotation.
virtual bool contains(const te::gm::Coord2D &coord) const
Checks if the coordinate is contained within the bounding rectangle.
virtual void setBox(te::gm::Envelope box)
Change the bounding rectangle.
virtual bool contains(Property property)
Checks if the property is contained within the set of properties.
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.
int toInt()
Returns the value of int type. (The setValue method received a int)
bool isValid() const
It tells if the rectangle is valid or not.
virtual bool removeChildren(int hashCode)
Reimplemented from Observable.
virtual void addChildrenProperties(Properties *properties)
bool toBool()
Returns the value of boolean type. (The setValue method received a boolean)
virtual void setEnableChildren(bool value)
Sets true if MVC component can have children, false otherwise.
virtual bool removeObserver(Observer *o)
Reimplemented from Observable.
SharedProperties * m_sharedProps
Names of common properties among all MVC components.