30 #include "../../core/pattern/singleton/Context.h"
31 #include "../../core/pattern/mvc/Observable.h"
32 #include "../../core/pattern/mvc/ItemObserver.h"
33 #include "../../core/pattern/mvc/OutsideObserver.h"
34 #include "../../core/pattern/mvc/OutsideController.h"
35 #include "../../../geometry/Envelope.h"
36 #include "../core/propertybrowser/PropertyBrowser.h"
37 #include "../item/MapItem.h"
38 #include "../../core/property/SharedProperties.h"
39 #include "../../core/pattern/mvc/ItemModelObservable.h"
40 #include "../../item/MapModel.h"
41 #include "../core/ItemUtils.h"
42 #include "../../core/pattern/derivativevisitor/VisitorUtils.h"
43 #include "../../core/enum/Enums.h"
44 #include "../core/pattern/command/ChangePropertyCommand.h"
45 #include "../core/Scene.h"
46 #include "../core/propertybrowser/PropertiesUtils.h"
50 #include <QGraphicsItem>
51 #include <QVBoxLayout>
52 #include <QHBoxLayout>
53 #include <QToolButton>
55 #include <QUndoCommand>
60 m_updatingValues(false),
67 setWindowTitle(
"Properties");
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93 if(m_layoutPropertyBrowser)
95 delete m_layoutPropertyBrowser;
96 m_layoutPropertyBrowser = 0;
101 delete m_sharedProps;
110 QVBoxLayout* layout =
new QVBoxLayout(
this);
111 layout->setMargin(0);
113 QHBoxLayout* filterLayout =
new QHBoxLayout;
115 m_configurePropertyEditor =
new QToolButton(
this);
116 m_configurePropertyEditor->setText(tr(
"Config"));
117 m_configurePropertyEditor->setBaseSize(QSize(16,16));
118 m_configurePropertyEditor->setVisible(
false);
120 m_propertyFilterEdit =
new QLineEdit(
this);
121 m_propertyFilterEdit->setToolTip(tr(
"String or regular expression to filter property list with"));
123 connect(m_propertyFilterEdit,SIGNAL(textChanged(QString)),
124 m_layoutPropertyBrowser,SLOT(onChangeFilter(QString)));
126 filterLayout->addWidget(m_propertyFilterEdit);
127 filterLayout->addWidget(m_configurePropertyEditor);
129 layout->addLayout(filterLayout);
130 m_nameLabel =
new QLabel(tr(
"Component::"),
this);
131 layout->addWidget(m_nameLabel);
132 layout->addWidget(m_layoutPropertyBrowser->getPropertyEditor());
134 QGroupBox* groupBox =
new QGroupBox(
this);
135 groupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
136 groupBox->setLayout(layout);
138 QVBoxLayout* layoutAll =
new QVBoxLayout(
this);
139 layoutAll->setMargin(0);
141 layoutAll->addWidget(groupBox);
143 setLayout(layoutAll);
148 setVisible(context.
isShow());
149 if(context.
isShow() ==
true)
163 QPointF posF = pos();
164 qreal valuex = posF.x();
165 qreal valuey = posF.y();
168 coordinate.
x = valuex;
169 coordinate.
y = valuey;
176 m_updatingValues =
false;
179 m_layoutPropertyBrowser->clearAll();
180 m_nameLabel->setText(tr(
"Component::"));
182 m_graphicsItems = graphicsItems;
184 m_allItems = allItems;
186 if(m_graphicsItems.empty())
189 Properties* props = m_propUtils->intersection(graphicsItems, window);
195 m_nameLabel->setText(tr(
"Component::") + props->
getObjectName().c_str());
202 m_propUtils->checkDynamicProperty(prop, allItems);
203 m_layoutPropertyBrowser->addProperty(prop);
220 sendPropertyToSelectedItems(property);
224 sendPropertyToSelectedItem(property);
227 changeMapVisitable(property);
237 std::vector<QGraphicsItem*> commandItems;
238 std::vector<Properties*> commandOld;
239 std::vector<Properties*> commandNew;
241 QGraphicsItem *itemSelected = m_propUtils->equalsHashCode(property, m_graphicsItems);
271 commandItems.push_back(itemSelected);
272 commandOld.push_back(oldCommand);
273 commandNew.push_back(newCommand);
278 if(!m_graphicsItems.isEmpty())
291 std::vector<QGraphicsItem*> commandItems;
292 std::vector<Properties*> commandOld;
293 std::vector<Properties*> commandNew;
295 foreach( QGraphicsItem *item, m_graphicsItems)
323 commandItems.push_back(item);
324 commandOld.push_back(oldCommand);
325 commandNew.push_back(newCommand);
332 if(!m_graphicsItems.isEmpty())
342 m_layoutPropertyBrowser->closeAllWindows();
347 if(property.
getName().compare(m_sharedProps->getMapName()) != 0)
350 std::string name =
property.getValue().toString();
351 if(name.compare(
"") == 0)
353 name =
property.getOptionByCurrentChoice().toString();
356 if(name.compare(
"") == 0)
403 itemsSelected(m_graphicsItems, m_allItems);
408 m_updatingValues =
false;
409 m_nameLabel->setText(tr(
"Component::"));
410 m_layoutPropertyBrowser->clearAll();
Abstract class to represent an observable. "Model" part of MVC component.
std::string getName()
Method that returns the name of this property.
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
virtual bool addProperty(Property property)
Adds the specified property to the set of properties for this object.
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
void onChangePropertyValue(Property property)
int getParentItemHashCode()
Returns the hashcode of the object that owns this property.
virtual te::gm::Envelope getBox()=0
Returns the bounding rectangle of the component in scene coordinates(millimeters). Starting point is llx, lly. Reimplement this function in a Observable subclass to provide the model's getBox implementation.
Abstract class to represent an observer. "View" part of MVC widget. All classes representing the grap...
virtual EnumType * getDataTypeNone() const
Returns value that represents type none belonging to enumeration.
virtual MapModel * getMapModel(std::string nameMap)
virtual bool sendPropertyToSelectedItems(Property property)
Abstract class to represent an observable. "Model" part of MVC component. All classes representing th...
double getWidth() const
It returns the envelope width.
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.
virtual bool isMenu()
Returns true if property will be used in a menu, false otherwise.
virtual void setObjectName(std::string name)
Sets object name that owns these properties.
virtual void redraw(bool bRefresh=true)
Redraws the graphic component.
virtual void changeMapVisitable(Property property)
virtual bool isVisible()
Return true if visible, false otherwise.
Manage properties variants values. Maps the QProperty properties (Qt) and Property (Layout) and add t...
virtual void setTypeObj(EnumType *type)
Sets object type that owns these properties.
virtual void updateProperties(te::layout::Properties *properties)=0
Updated model state with properties. Reimplement this function in a Observable subclass to provide th...
static Enums & getInstance()
It returns a reference to the singleton instance.
virtual void updateObserver(ContextItem context)
Reimplemented from Observer.
An Envelope defines a 2D rectangular region.
virtual void closeEvent(QCloseEvent *event)
virtual EnumType * getTypeObj()
Returns object type that owns these properties.
PropertiesUtils * m_propUtils
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
virtual std::string getObjectName()
Returns object name that owns these properties.
ItemUtils * getItemUtils()
Returns pointer for manipulating items in the scene and vectorization of text and legend...
virtual te::layout::Properties * getProperties() const =0
Returns the model state as properties. Reimplement this function in a Observable subclass to provide ...
Utility class for manipulating items in the scene and vectorization of text and legend.
SharedProperties * m_sharedProps
virtual void onClear(std::vector< std::string > names)
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
virtual void itemsSelected(QList< QGraphicsItem * > graphicsItems, QList< QGraphicsItem * > allItems)
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
virtual void refreshOutside()
virtual MapItem * getMapItem(std::string name)
Search for te::layout::MapItem by name.
Utility class with functions to facilitate handling of qt properties and properties layout module...
Observable * m_model
"Model" part of MVC widget.
virtual void createLayout()
virtual void setPosition(const double &x, const double &y)
Change coordinate llx,lly of the MVC widget. Reimplement this function in a ItemController subclass t...
virtual Observable * getModel()
Returns the "Model" part of the MVC.
virtual void addUndoStack(QUndoCommand *command)
Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack.
virtual bool sendPropertyToSelectedItem(Property property)
virtual te::gm::Coord2D getPosition()
Method that returns the position llx, lly Reimplement this function in a ItemObserver subclass to pro...
AbstractScene * getScene()
Returns abstract scene for QGraphicsScene class, part of Graphics View Framework. ...
Abstract class to represent a controller. "Controller" part of MVC widget. All classes representing t...
virtual void setHasWindows(bool windows)
Undo/Redo for changes in component properties.
PropertiesOutside(OutsideController *controller, Observable *o, PropertyBrowser *propertyBrowser=0)
Properties tree for any item, MVC component, using Qt for presentation and editing.
double getHeight() const
It returns the envelope height.
EnumType * getType()
Returns the type of this property.
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.
PropertyBrowser * m_layoutPropertyBrowser
virtual ~PropertiesOutside()
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...