Esempio n. 1
0
void Workspace::deserialize(XmlDeserializer& s) {
    // clear existing network and containers
    clear();

    try {
        s.deserialize("readonly", readOnly_);
    }
    catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
        readOnly_ = false;
    }

    // Deserialize network...
    s.deserialize("ProcessorNetwork", network_);

    // Deserialize animation if present...
    try {
        s.deserialize("Animation", animation_);
    } catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
    }

    if (animation_) {
        animation_->setNetwork(network_);

        // register this as observer on all propertytimelines for undo/redo
        const std::vector<AnimatedProcessor*> animproc = this->animation_->getAnimatedProcessors();
        std::vector<AnimatedProcessor*>::const_iterator it;
        for (it = animproc.begin();it != animproc.end();it++)
        {
            const std::vector<PropertyTimeline*> timelines = (*it)->getPropertyTimelines();
            std::vector<PropertyTimeline*>::const_iterator it2;
            for (it2 = timelines.begin();it2 != timelines.end(); ++it2) {
                (*it2)->registerUndoObserver(this->animation_);
            }
        }

        // register this as observer in the processornetwork to register added and removed processors
        ProcessorNetwork* net = const_cast<ProcessorNetwork*>(network_);
        net->addObserver(this->animation_);
    }

    try {
        s.deserialize("GlobalDescription", description_);
    }
    catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
        description_ = "";
    }
}
Esempio n. 2
0
    virtual void TearDown() {
        if (isAdded_) {
            ProcessorNetwork *pn = InviwoApplication::getPtr()->getProcessorNetwork();
            size_t sizeBefore = pn->getProcessors().size();

            pn->removeAndDeleteProcessor(p);

            size_t sizeAfter = pn->getProcessors().size();
            EXPECT_EQ(sizeBefore, sizeAfter + 1);
        } else if (p) {
            p->deinitialize();
            delete p;
        }
        p = nullptr;
    }
void ProcessorGraphicsItem::renameFinished(bool) {
    textItem_.setTextInteractionFlags(Qt::NoTextInteraction);
    textItem_.setFlag(QGraphicsItem::ItemIsFocusable, false);
    textItem_.setFlag(QGraphicsItem::ItemIsSelectable, false);

    // name unchanged
    if (textItem_.toPlainText().toStdString() == processor_->getName())
        return;

    try {
        ProcessorNetwork* network = networkEditor_->getProcessorNetwork();
        network->setProcessorName(processor_, network->generateUniqueProcessorName(textItem_.toPlainText().toStdString()));
    }
    catch (VoreenException& e) {
        LWARNINGC("voreen.qt.ProcessorGraphicsItem", e.what());
        textItem_.setPlainText(QString::fromStdString(processor_->getName()));
    }

    nameChanged();
}
Esempio n. 4
0
void ProcessorGraphicsItem::renameFinished() {
    nameLabel_.setTextInteractionFlags(Qt::NoTextInteraction);
    nameLabel_.setFlag(QGraphicsItem::ItemIsFocusable, false);
    nameLabel_.setFlag(QGraphicsItem::ItemIsSelectable, false);

    // name unchanged
    if (nameLabel_.toPlainText().toStdString() == processor_->getName())
        return;

    try {
        ProcessorNetwork* network = networkEditor_->getProcessorNetwork();
        std::string name = network->generateUniqueProcessorName(nameLabel_.toPlainText().toStdString());
        network->setProcessorName(processor_, name);
        setGuiName(QString::fromStdString(name));
        nameLabel_.setPlainText(QString::fromStdString(name));
        getPropertyList()->updateParentLabel();
    }
    catch (VoreenException& e) {
        LWARNINGC("voreen.qt.ProcessorGraphicsItem", e.what());
        nameLabel_.setPlainText(QString::fromStdString(processor_->getName()));
    }

    nameChanged();
}