more infrastructure links

This commit is contained in:
Elisa Lupin-Jimenez 2018-01-10 17:08:55 -08:00
parent fdca8ab93e
commit fc0e87d5ea
7 changed files with 51 additions and 22 deletions

View file

@ -590,6 +590,11 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_SKYBOX_MODE, skyboxMode, getSkyboxModeAsString());
}
// Image only
if (_type == EntityTypes::Image) {
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IMAGE_URL, imageURL);
}
// Web only
if (_type == EntityTypes::Web) {
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl);
@ -1734,6 +1739,10 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DPI, uint16_t, setDPI);
}
if (properties.getType() == EntityTypes::Image) {
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IMAGE_URL, QString, setImageURL);
}
if (properties.getType() == EntityTypes::Text) {
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT, QString, setText);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_HEIGHT, float, setLineHeight);

View file

@ -266,6 +266,8 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
bool success = true;
if (_entityTree) {
_entityTree->withWriteLock([&] {
propertiesWithSimID.getType();
qCDebug(entities) << "check 2 type: " << propertiesWithSimID.getType();
EntityItemPointer entity = _entityTree->addEntity(id, propertiesWithSimID);
if (entity) {
if (propertiesWithSimID.queryAACubeRelatedPropertyChanged()) {

View file

@ -514,6 +514,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
// construct the instance of the entity
EntityTypes::EntityType type = props.getType();
qCDebug(entities) << "check 3 type: " << type;
result = EntityTypes::constructEntityItem(type, entityID, props);
if (result) {

View file

@ -28,6 +28,7 @@
#include "LineEntityItem.h"
#include "PolyVoxEntityItem.h"
#include "PolyLineEntityItem.h"
#include "ImageEntityItem.h"
#include "ShapeEntityItem.h"
QMap<EntityTypes::EntityType, QString> EntityTypes::_typeToNameMap;
@ -47,6 +48,7 @@ REGISTER_ENTITY_TYPE(Zone)
REGISTER_ENTITY_TYPE(Line)
REGISTER_ENTITY_TYPE(PolyVox)
REGISTER_ENTITY_TYPE(PolyLine)
REGISTER_ENTITY_TYPE(Image)
REGISTER_ENTITY_TYPE(Shape)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Box, ShapeEntityItem::boxFactory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Sphere, ShapeEntityItem::sphereFactory)
@ -89,7 +91,7 @@ EntityItemPointer EntityTypes::constructEntityItem(EntityType entityType, const
EntityItemPointer newEntityItem = NULL;
EntityTypeFactory factory = NULL;
if (entityType >= 0 && entityType <= LAST) {
qCDebug(entities) << "type: " << entityType;
qCDebug(entities) << "check 4 type: " << entityType;
factory = _factories[entityType];
}
if (factory) {

View file

@ -1,5 +1,5 @@
//
// FlatImageEntity.cpp
// ImageEntityItem.cpp
// libraries/entities/src
//
// Created by Elisa Lupin-Jimenez on 1/3/18.
@ -22,27 +22,27 @@
#include "EntityTreeElement.h"
#include "ResourceCache.h"
#include "ShapeEntityItem.h"
#include "FlatImageEntity.h"
#include "ImageEntityItem.h"
const QString FlatImageEntity::DEFAULT_IMAGE_URL = QString("");
const QString ImageEntityItem::DEFAULT_IMAGE_URL = QString("");
EntityItemPointer FlatImageEntity::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
EntityItemPointer entity(new FlatImageEntity(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
EntityItemPointer ImageEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
EntityItemPointer entity(new ImageEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
entity->setProperties(properties);
return entity;
}
FlatImageEntity::FlatImageEntity(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
ImageEntityItem::ImageEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
_type = EntityTypes::Image;
}
EntityItemProperties FlatImageEntity::getProperties(EntityPropertyFlags desiredProperties) const {
EntityItemProperties ImageEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
properties.setShape("Quad");
return properties;
}
bool FlatImageEntity::setProperties(const EntityItemProperties& properties) {
bool ImageEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
//SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape);
@ -52,7 +52,7 @@ bool FlatImageEntity::setProperties(const EntityItemProperties& properties) {
if (wantDebug) {
uint64_t now = usecTimestampNow();
int elapsed = now - getLastEdited();
qCDebug(entities) << "FlatImageEntity::setProperties() AFTER update... edited AGO=" << elapsed <<
qCDebug(entities) << "ImageEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
"now=" << now << " getLastEdited()=" << getLastEdited();
}
setLastEdited(properties.getLastEdited());
@ -61,13 +61,13 @@ bool FlatImageEntity::setProperties(const EntityItemProperties& properties) {
}
// TODO: eventually only include properties changed since the params.nodeData->getLastTimeBagEmpty() time
EntityPropertyFlags FlatImageEntity::getEntityProperties(EncodeBitstreamParams& params) const {
EntityPropertyFlags ImageEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
return requestedProperties;
}
void FlatImageEntity::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
void ImageEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
@ -80,7 +80,7 @@ void FlatImageEntity::appendSubclassData(OctreePacketData* packetData, EncodeBit
APPEND_ENTITY_PROPERTY(PROP_SHAPE, "Quad");
}
int FlatImageEntity::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
int ImageEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
bool& somethingChanged) {
@ -91,7 +91,7 @@ int FlatImageEntity::readEntitySubclassDataFromBuffer(const unsigned char* data,
return bytesRead;
}
void ShapeEntityItem::setUnscaledDimensions(const glm::vec3& value) {
/*void ShapeEntityItem::setUnscaledDimensions(const glm::vec3& value) {
const float MAX_FLAT_DIMENSION = 0.0001f;
if (value.y > MAX_FLAT_DIMENSION) {
// enforce flatness in Y
@ -101,9 +101,23 @@ void ShapeEntityItem::setUnscaledDimensions(const glm::vec3& value) {
} else {
EntityItem::setUnscaledDimensions(value);
}
}*/
void ImageEntityItem::setImageURL(const QString& value) {
withWriteLock([&] {
if (_imageURL != value) {
auto newURL = QUrl::fromUserInput(value);
if (newURL.isValid()) {
_imageURL = newURL.toDisplayString();
} else {
qCDebug(entities) << "Clearing image entity source URL since" << value << "cannot be parsed to a valid URL.";
}
}
});
}
QString FlatImageEntity::getImageURL() const {
QString ImageEntityItem::getImageURL() const {
return resultWithReadLock<QString>([&] {
return _imageURL;
});

View file

@ -1,5 +1,5 @@
//
// FlatImageEntity.h
// ImageEntityItem.h
// libraries/entities/src
//
// Created by Elisa Lupin-Jimenez on 1/3/18.
@ -9,16 +9,16 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_FlatImageEntity_h
#define hifi_FlatImageEntity_h
#ifndef hifi_ImageEntityItem_h
#define hifi_ImageEntityItem_h
#include "EntityItem.h"
class FlatImageEntity : public EntityItem {
class ImageEntityItem : public EntityItem {
public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
FlatImageEntity(const EntityItemID& entityItemID);
ImageEntityItem(const EntityItemID& entityItemID);
ALLOW_INSTANTIATION // This class can be instantiated
@ -43,6 +43,7 @@ public:
static const QString DEFAULT_IMAGE_URL;
virtual void setImageURL(const QString& value);
QString getImageURL() const;
protected:
@ -50,4 +51,4 @@ protected:
};
#endif // hifi_FlatImageEntity_h
#endif // hifi_ImageEntityItem_h

View file

@ -287,7 +287,7 @@ var toolBar = (function () {
properties.userData = JSON.stringify({ grabbableKey: { grabbable: false } });
}
print("properties.type: " + properties.type);
print("check 1 type: " + properties.type);
entityID = Entities.addEntity(properties);
if (properties.type === "ParticleEffect") {