Exemple #1
0
bool LinkSettings::isLinkable(const Property* property) const {
    auto id = dotSeperatedToPascalCase(property->getClassIdentifier());
    auto it  = propertyMap_.find(id);
    if (it != propertyMap_.end()) {
        return it->second->get();
    }
    return false;
}
Exemple #2
0
void LinkSettings::onRegister(PropertyFactoryObject* p) {
    auto property = p->getClassIdentifier();
    bool enabled = (property == CameraProperty::CLASS_IDENTIFIER) != 0 ? true : false;
    // Have to check we we already have a property from deserialization.
    auto id = dotSeperatedToPascalCase(property);
    if (linkProperties_.getPropertyByIdentifier("link" + id) == nullptr) {
        auto linkPropery = util::make_unique<BoolProperty>("link" + id, property, enabled);
        linkProperties_.addProperty(linkPropery.get(), false);
        propertyMap_[id] = std::move(linkPropery);
    }
}
PortInspector::PortInspector(std::string portClassIdentifier,
                             std::string inspectorWorkspaceFileName)
    : inspectorNetworkFileName_(inspectorWorkspaceFileName)
    , portClassIdentifier_(portClassIdentifier) {

    // Deserialize the network
    auto app = InviwoApplication::getPtr();
    Deserializer xmlDeserializer(app, inspectorNetworkFileName_);
    inspectorNetwork_ = util::make_unique<ProcessorNetwork>(app);
    inspectorNetwork_->deserialize(xmlDeserializer);
    processors_ = inspectorNetwork_->getProcessors();

    for (auto processor : processors_) {
        // Set Identifiers
        std::string newIdentifier = dotSeperatedToPascalCase(getPortClassName()) +
            "PortInspector" + processor->getIdentifier();
        processor->setIdentifier(newIdentifier);

        // Find the and save inports.
        for (auto& inport : processor->getInports()) {
            if (!inport->isConnected()) inPorts_.push_back(inport);
        }

        auto meta =
            processor->getMetaData<ProcessorMetaData>(ProcessorMetaData::CLASS_IDENTIFIER);
        meta->setVisible(false);
        meta->setSelected(false);

        // Find and save the canvasProcessor
        if (auto canvasProcessor = dynamic_cast<CanvasProcessor*>(processor)) {
            canvasProcessor_ = canvasProcessor;
        }
    }

    // Store the connections and and disconnect them.
    auto connections = inspectorNetwork_->getConnections();
    for (auto& connection : connections) {
        connections_.emplace_back(connection.getOutport(), connection.getInport());
        inspectorNetwork_->removeConnection(connection.getOutport(), connection.getInport());
    }

    // store the processor links.
    propertyLinks_ = inspectorNetwork_->getLinks();
}
Exemple #4
0
LinkSettings::LinkSettings(const std::string& id, PropertyFactory* factory)
    : Settings(id)
    , FactoryObserver<PropertyFactoryObject>()
    , linkProperties_("autoLinkProperties", "Auto Link Properties") {

    addProperty(linkProperties_);

    auto properties = factory->getKeys();
    std::sort(properties.begin(), properties.end());

    for (auto& property : properties) {
        //enable camera prop linking by default.
        bool enabled = (property == CameraProperty::CLASS_IDENTIFIER) != 0 ? true : false;
        auto id = dotSeperatedToPascalCase(property);
        auto linkPropery = util::make_unique<BoolProperty>("link" + id, property, enabled);
        linkProperties_.addProperty(linkPropery.get(), false);
        propertyMap_[id] = std::move(linkPropery);
    }
    
    factory->addObserver(this);
}
Exemple #5
0
void LinkSettings::onUnRegister(PropertyFactoryObject* p) {
    auto id = dotSeperatedToPascalCase(p->getClassIdentifier());
    linkProperties_.removeProperty("link" + id);
    propertyMap_.erase(id);
}