Exemple #1
0
void GraphDraw::handleCustomContextMenuRequested(const QPoint &pos)
{
    auto menu = new QMenu(this);
    menu->addAction(getActionMap()["cut"]);
    menu->addAction(getActionMap()["copy"]);
    menu->addAction(getActionMap()["paste"]);
    menu->addAction(getActionMap()["delete"]);
    menu->addSeparator();
    menu->addAction(getActionMap()["selectAll"]);
    menu->addSeparator();
    menu->addAction(getActionMap()["find"]);
    menu->addSeparator();
    menu->addAction(getActionMap()["createGraphPage"]);
    menu->addAction(getActionMap()["renameGraphPage"]);
    menu->addAction(getActionMap()["deleteGraphPage"]);
    menu->addMenu(getMenuMap()["moveGraphObjects"]);
    menu->addMenu(getMenuMap()["setAffinityZone"]);
    menu->addSeparator();
    menu->addAction(getActionMap()["createInputBreaker"]);
    menu->addAction(getActionMap()["createOutputBreaker"]);
    menu->addSeparator();
    menu->addAction(getActionMap()["rotateLeft"]);
    menu->addAction(getActionMap()["rotateRight"]);

    _lastContextMenuPos = pos;
    menu->exec(this->mapToGlobal(pos));
    delete menu;
}
Exemple #2
0
void GraphEditor::updateGraphEditorMenus(void)
{
    if (not this->isVisible()) return;

    //always store the last visible page with the state
    //we use this to restore the last viewed page when undo/reset
    _stateToLastTabIndex[_stateManager->getCurrentIndex()] = this->currentIndex();

    auto menu = getMenuMap()["moveGraphObjects"];
    menu->clear();
    for (int i = 0; i < this->count(); i++)
    {
        if (i == this->currentIndex()) continue;
        auto action = menu->addAction(QString("%1 (%2)").arg(this->tabText(i)).arg(i));
        connect(action, SIGNAL(triggered(void)), _moveGraphObjectsMapper, SLOT(map(void)));
        _moveGraphObjectsMapper->setMapping(action, i);
    }

    menu = getMenuMap()["insertGraphWidgets"];
    menu->clear();
    for (auto obj : this->getGraphObjects(GRAPH_BLOCK))
    {
        auto block = dynamic_cast<GraphBlock *>(obj);
        assert(block != nullptr);
        if (not block->isGraphWidget()) continue;

        //does block have an active graph display?
        for (auto subObj : this->getGraphObjects(GRAPH_WIDGET))
        {
            auto display = dynamic_cast<GraphWidget *>(subObj);
            assert(display != nullptr);
            if (display->getGraphBlock() == block) goto next_block;
        }

        //block is a display widget with no active displays:
        {
            auto action = menu->addAction(QString("%1 (%2)").arg(block->getTitle()).arg(block->getId()));
            connect(action, SIGNAL(triggered(void)), _insertGraphWidgetsMapper, SLOT(map(void)));
            _insertGraphWidgetsMapper->setMapping(action, block);
        }

        next_block: continue;
    }
}
Exemple #3
0
GraphEditor::GraphEditor(QWidget *parent):
    QTabWidget(parent),
    _parentTabWidget(dynamic_cast<QTabWidget *>(parent)),
    _moveGraphObjectsMapper(new QSignalMapper(this)),
    _insertGraphWidgetsMapper(new QSignalMapper(this)),
    _stateManager(new GraphStateManager(this)),
    _evalEngine(new EvalEngine(this)),
    _isTopologyActive(false)
{
    this->setMovable(true);
    this->setUsesScrollButtons(true);
    this->setTabPosition(QTabWidget::West);
    this->makeDefaultPage();

    this->tabBar()->setStyleSheet("font-size:8pt;");

    //connect handlers that work at the page-level of control
    connect(QApplication::clipboard(), SIGNAL(dataChanged(void)), this, SLOT(handleClipboardDataChange(void)));
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(handleCurrentChanged(int)));
    connect(_stateManager, SIGNAL(newStateSelected(int)), this, SLOT(handleResetState(int)));
    connect(getActionMap()["createGraphPage"], SIGNAL(triggered(void)), this, SLOT(handleCreateGraphPage(void)));
    connect(getActionMap()["renameGraphPage"], SIGNAL(triggered(void)), this, SLOT(handleRenameGraphPage(void)));
    connect(getActionMap()["deleteGraphPage"], SIGNAL(triggered(void)), this, SLOT(handleDeleteGraphPage(void)));
    connect(getActionMap()["inputBreaker"], SIGNAL(triggered(void)), this, SLOT(handleCreateInputBreaker(void)));
    connect(getActionMap()["outputBreaker"], SIGNAL(triggered(void)), this, SLOT(handleCreateOutputBreaker(void)));
    connect(getActionMap()["cut"], SIGNAL(triggered(void)), this, SLOT(handleCut(void)));
    connect(getActionMap()["copy"], SIGNAL(triggered(void)), this, SLOT(handleCopy(void)));
    connect(getActionMap()["paste"], SIGNAL(triggered(void)), this, SLOT(handlePaste(void)));
    connect(getObjectMap()["blockTreeDock"], SIGNAL(addBlockEvent(const Poco::JSON::Object::Ptr &)), this, SLOT(handleAddBlock(const Poco::JSON::Object::Ptr &)));
    connect(getActionMap()["selectAll"], SIGNAL(triggered(void)), this, SLOT(handleSelectAll(void)));
    connect(getActionMap()["delete"], SIGNAL(triggered(void)), this, SLOT(handleDelete(void)));
    connect(getActionMap()["rotateLeft"], SIGNAL(triggered(void)), this, SLOT(handleRotateLeft(void)));
    connect(getActionMap()["rotateRight"], SIGNAL(triggered(void)), this, SLOT(handleRotateRight(void)));
    connect(getActionMap()["objectProperties"], SIGNAL(triggered(void)), this, SLOT(handleObjectProperties(void)));
    connect(getActionMap()["graphProperties"], SIGNAL(triggered(void)), this, SLOT(handleGraphProperties(void)));
    connect(getActionMap()["zoomIn"], SIGNAL(triggered(void)), this, SLOT(handleZoomIn(void)));
    connect(getActionMap()["zoomOut"], SIGNAL(triggered(void)), this, SLOT(handleZoomOut(void)));
    connect(getActionMap()["zoomOriginal"], SIGNAL(triggered(void)), this, SLOT(handleZoomOriginal(void)));
    connect(getActionMap()["undo"], SIGNAL(triggered(void)), this, SLOT(handleUndo(void)));
    connect(getActionMap()["redo"], SIGNAL(triggered(void)), this, SLOT(handleRedo(void)));
    connect(getActionMap()["enable"], SIGNAL(triggered(void)), this, SLOT(handleEnable(void)));
    connect(getActionMap()["disable"], SIGNAL(triggered(void)), this, SLOT(handleDisable(void)));
    connect(getActionMap()["reeval"], SIGNAL(triggered(void)), this, SLOT(handleReeval(void)));
    connect(getMenuMap()["setAffinityZone"], SIGNAL(zoneClicked(const QString &)), this, SLOT(handleAffinityZoneClicked(const QString &)));
    connect(getObjectMap()["affinityZonesDock"], SIGNAL(zoneChanged(const QString &)), this, SLOT(handleAffinityZoneChanged(const QString &)));
    connect(getActionMap()["showRenderedGraph"], SIGNAL(triggered(void)), this, SLOT(handleShowRenderedGraphDialog(void)));
    connect(getActionMap()["showTopologyStats"], SIGNAL(triggered(void)), this, SLOT(handleShowTopologyStatsDialog(void)));
    connect(getActionMap()["activateTopology"], SIGNAL(toggled(bool)), this, SLOT(handleToggleActivateTopology(bool)));
    connect(getActionMap()["showPortNames"], SIGNAL(changed(void)), this, SLOT(handleShowPortNames(void)));
    connect(getActionMap()["increment"], SIGNAL(triggered(void)), this, SLOT(handleBlockIncrement(void)));
    connect(getActionMap()["decrement"], SIGNAL(triggered(void)), this, SLOT(handleBlockDecrement(void)));
    connect(_moveGraphObjectsMapper, SIGNAL(mapped(int)), this, SLOT(handleMoveGraphObjects(int)));
    connect(_insertGraphWidgetsMapper, SIGNAL(mapped(QObject *)), this, SLOT(handleInsertGraphWidget(QObject *)));
    connect(_evalEngine, SIGNAL(deactivateDesign(void)), this, SLOT(handleEvalEngineDeactivate(void)));
    connect(this, SIGNAL(newTitleSubtext(const QString &)), getObjectMap()["mainWindow"], SLOT(handleNewTitleSubtext(const QString &)));
}
Exemple #4
0
void GraphDraw::updateEnabledActions(void)
{
    auto selectedObjsNoC = this->getObjectsSelected(false/*NC*/);
    const bool selectedNoC = not selectedObjsNoC.empty();

    auto selectedObjs = this->getObjectsSelected();
    const bool selected = not selectedObjs.empty();

    getActionMap()["cut"]->setEnabled(selectedNoC);
    getActionMap()["copy"]->setEnabled(selectedNoC);
    getActionMap()["delete"]->setEnabled(selected);
    getActionMap()["rotateLeft"]->setEnabled(selectedNoC);
    getActionMap()["rotateRight"]->setEnabled(selectedNoC);
    getActionMap()["properties"]->setEnabled(selected);

    //and enable/disable the actions in the move graph objects submenu
    for (auto child : getMenuMap()["moveGraphObjects"]->children())
    {
        auto action = dynamic_cast<QAction *>(child);
        if (action != nullptr) action->setEnabled(selectedNoC);
    }
}