Ejemplo n.º 1
0
QVariant ProcessorGraphicsItem::itemChange(GraphicsItemChange change, const QVariant& value) {
#include <warn/push>
#include <warn/ignore/switch-enum>
    switch (change) {
        case QGraphicsItem::ItemPositionHasChanged:
            if (processorMeta_) processorMeta_->setPosition(ivec2(x(), y()));
            break;
        case QGraphicsItem::ItemSelectedHasChanged:
            if (isSelected()) {
                setZValue(SELECTED_PROCESSORGRAPHICSITEM_DEPTH);
                if (!highlight_) {
                    if (auto editor = getNetworkEditor()) {
                        editor->addPropertyWidgets(getProcessor());
                    }
                }
            } else {
                setZValue(PROCESSORGRAPHICSITEM_DEPTH);
                if (auto editor = getNetworkEditor()) {
                    editor->removePropertyWidgets(getProcessor());
                }
            }
            if (!highlight_ && processorMeta_) processorMeta_->setSelected(isSelected());
            break;
        case QGraphicsItem::ItemVisibleHasChanged:
            if (processorMeta_) processorMeta_->setVisibile(isVisible());
            break;
        default:
            break;
    }
#include <warn/pop>
    return QGraphicsItem::itemChange(change, value);
}
Ejemplo n.º 2
0
void ProcessorGraphicsItem::togglePropertyList() {
    if (!networkEditor_ || !networkEditor_->updatesEnabled())
        return;

    prepareGeometryChange();
    if (propertyList_.getIsVisibleInEditor()){
        propertyList_.setVisible(false);
        propertyList_.setIsVisibleInEditor(false);
    } else {
        //layoutChildItems();
        propertyList_.setIsVisibleInEditor(true);
        if(currentLayer() == NetworkEditorLayerGeneralLinking){
            propertyList_.setPropertyVisibleMode(PropertyListGraphicsItem::SHOW_LINKED_PROPERTIES);
            if(getNetworkEditor()->cameraLinksHidden() && getNetworkEditor()->portSizeLinksHidden())
                propertyList_.setPropertyVisibleModifier(PropertyListGraphicsItem::HIDE_CAMERA_AND_SIZE_PROPERTIES);
            else if(getNetworkEditor()->cameraLinksHidden())
                propertyList_.setPropertyVisibleModifier(PropertyListGraphicsItem::HIDE_CAMERA_PROPERTIES);
            else if(getNetworkEditor()->portSizeLinksHidden())
                propertyList_.setPropertyVisibleModifier(PropertyListGraphicsItem::HIDE_SIZE_PROPERTIES);
            else 
                propertyList_.setPropertyVisibleModifier(PropertyListGraphicsItem::HIDE_NO_PROPERTIES);
        }
        else if (currentLayer() == NetworkEditorLayerCameraLinking) {
            propertyList_.setPropertyVisibleMode(PropertyListGraphicsItem::SHOW_CAMERA_PROPERTIES);
            propertyList_.setPropertyVisibleModifier(PropertyListGraphicsItem::HIDE_NO_PROPERTIES);
        }
        propertyList_.setHeaderMode(PropertyListGraphicsItem::NO_HEADER);
        propertyList_.setLinkArrowMode(PropertyListGraphicsItem::SHOW_ALL_ARROWS);
        propertyList_.setVisible(true);
        if(propertyList_.getAllVisiblePropertyGraphicsItems().empty()) {
            propertyList_.setVisible(false);
            propertyList_.setIsVisibleInEditor(false);
        }
    }
    layoutChildItems();

    networkEditor_->resetCachedContent();
}
void ProcessorOutportGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent* e) {
    if(e->buttons() == Qt::LeftButton) {
        getNetworkEditor()->initiateConnection(this);
    }
    e->accept();
}
void ProcessorInportGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent* e) {
    if(e->buttons() == Qt::LeftButton && port_->isConnected()) {
        getNetworkEditor()->releaseConnection(this);
    }
    e->accept();
}