Exemple #1
0
Processor* CompositeProperty::getProcessor() {
    PropertyOwner* owner = getOwner();
    if (owner) {
        return owner->getProcessor();
    } else {
        return nullptr;
    }
}
Exemple #2
0
std::string Property::fullyQualifiedIdentifier() const {
    std::string identifier = _identifier;
    PropertyOwner* currentOwner = owner();
    while (currentOwner) {
        std::string ownerId = currentOwner->name();
        if (!ownerId.empty()) {
            identifier = ownerId + "." + identifier;
        }
        currentOwner = currentOwner->owner();
    }
    return identifier;
}
void TemplatePropertyTimeline<Camera>::deserialize(XmlDeserializer& s) {
    s.deserialize("activeOnRendering", activeOnRendering_);
    PropertyOwner* propertyOwner = 0;
    s.deserialize("propertyOwner", propertyOwner);
    std::string propertyId;
    s.deserialize("propertyId", propertyId);
    if (propertyOwner)
        property_ = dynamic_cast<CameraProperty*>(propertyOwner->getProperty(propertyId));
    else
        LERRORC("TemplatePropertyTimeline<Camera>", "deserialize(): no property owner");
    s.deserialize("duration", duration_);
    s.deserialize("timeline", timeline_);
}
// TODO force user to pass camprop pointer instead of blindly searching for it
CameraProperty* LightSourceProperty::getCamera() {
    if(camProp_)
        return camProp_;
    else {
        PropertyOwner* propOwner = getOwner();
        if(!propOwner)
            return 0;

        std::vector<Property*> props = propOwner->getProperties();
        std::vector<Property*>::iterator it = props.begin();
        while (it != props.end()) {
            if(CameraProperty* camProp = dynamic_cast<CameraProperty*>(*it)) {
                setCamera(camProp);
                break;
            }
            ++it;
        }
        return camProp_;
    }
}
Exemple #5
0
void Property::propertyModified() {
    NetworkLock lock(this);
    onChangeCallback_.invokeAll();
    setPropertyModified(true);

    PropertyOwner* owner = getOwner();
    if (owner) {
        // Evaluate property links       
        if (Processor* processor = owner->getProcessor()) {
             processor->notifyObserversAboutPropertyChange(this);
        }

        // Invalidate Owner
        if (getInvalidationLevel() > InvalidationLevel::Valid) {
            owner->invalidate(getInvalidationLevel(), this);        
        }
    }

    updateWidgets();
}
Property* PropertyOwner::property(const std::string& id) const {
    assert(std::is_sorted(_properties.begin(), _properties.end(), propertyLess));

    // As the _properties list is sorted, just finding the lower bound is sufficient
    std::vector<Property*>::const_iterator it
          = std::lower_bound(_properties.begin(), _properties.end(), id,
                             [](Property* prop, const std::string& str) {
              return prop->identifier() < str;
          });

    if (it == _properties.end() || (*it)->identifier() != id) {
        // if we do not own the searched property, it must consist of a concatenated
        // name and we can delegate it to a subowner
        const size_t ownerSeparator = id.find(URISeparator);
        if (ownerSeparator == std::string::npos) {
            // if we do not own the property and there is no separator, it does not exist
            return nullptr;
        }
        else {
            const std::string ownerName = id.substr(0, ownerSeparator);
            const std::string propertyName = id.substr(ownerSeparator + 1);
            
            PropertyOwner* owner = propertySubOwner(ownerName);
            if (owner == nullptr) {
                return nullptr;
            }
            else {
                // Recurse into the subOwner
                return owner->property(propertyName);
            }
        }
    }
    else {
        return *it;
    }
}
/**
 * Constrain the local properties of the PropertyOwner.
 * @param propertyOwner to constrain
 * @param updateBufferIndex buffer index to use
 * @return The number of constraints that are still being applied
 */
unsigned int ConstrainPropertyOwner( PropertyOwner& propertyOwner, BufferIndex updateBufferIndex )
{
  unsigned int activeCount = 0;

  ConstraintOwnerContainer& constraints = propertyOwner.GetConstraints();

  const ConstraintIter endIter = constraints.End();
  for( ConstraintIter iter = constraints.Begin(); iter != endIter; ++iter )
  {
    ConstraintBase& constraint = **iter;
    constraint.Apply( updateBufferIndex );

    if( constraint.mWeight[updateBufferIndex] < 1.0f )
    {
      // this constraint is still being applied
      ++activeCount;
    }
  }

  return activeCount;
}