Exemple #1
0
GraphDraw::GraphDraw(QWidget *parent):
    QWidget(parent),
    _graphEditor(dynamic_cast<GraphEditor *>(parent)),
    _zoomScale(1.0),
    _mouseLeftDown(false),
    _showGraphConnectionPoints(false),
    _showGraphBoundingBoxes(false)
{
    assert(this->getGraphEditor() != nullptr);
    this->setAcceptDrops(true);

    this->setZoomScale(1.0);

    this->setFocusPolicy(Qt::ClickFocus);

    this->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
        this, SLOT(handleCustomContextMenuRequested(const QPoint &)));
    connect(this, SIGNAL(stateChanged(const GraphState &)),
        parent, SLOT(handleStateChange(const GraphState &)));
    connect(this, SIGNAL(modifyProperties(GraphObject *)),
        getObjectMap()["propertiesPanel"], SLOT(handleGraphModifyProperties(GraphObject *)));

    //debug view - connect and initialize
    connect(getActionMap()["showGraphConnectionPoints"], SIGNAL(triggered(void)),
        this, SLOT(handleGraphDebugViewChange(void)));
    connect(getActionMap()["showGraphBoundingBoxes"], SIGNAL(triggered(void)),
        this, SLOT(handleGraphDebugViewChange(void)));
    this->handleGraphDebugViewChange();
}
Exemple #2
0
void GraphDraw::handleGraphDebugViewChange(void)
{
    _showGraphConnectionPoints = getActionMap()["showGraphConnectionPoints"]->isChecked();
    _showGraphBoundingBoxes = getActionMap()["showGraphBoundingBoxes"]->isChecked();
    if (not this->isVisible()) return;
    this->render();
}
Exemple #3
0
void GraphDraw::wheelEvent(QWheelEvent *event)
{
    const bool ctrlDown = QApplication::keyboardModifiers() & Qt::ControlModifier;
    if (not ctrlDown) return QGraphicsView::wheelEvent(event);

    //ctrl was down, wheel event means zoom in or out:
    if (event->delta() > 0) getActionMap()["zoomIn"]->activate(QAction::Trigger);
    if (event->delta() < 0) getActionMap()["zoomOut"]->activate(QAction::Trigger);
}
Exemple #4
0
GraphEditorTabs::GraphEditorTabs(QWidget *parent):
    QTabWidget(parent)
{
    this->setTabsClosable(true);
    this->setMovable(true);
    this->setUsesScrollButtons(true);
    this->setTabPosition(QTabWidget::North);
    this->setStyleSheet(
        QString("QTabBar::close-button {image: url(%1);}").arg(makeIconPath("standardbutton-closetab-16.png"))+
        QString("QTabBar::close-button:hover {image: url(%1);}").arg(makeIconPath("standardbutton-closetab-hover-16.png"))+
        QString("QTabBar::close-button:pressed {image: url(%1);}").arg(makeIconPath("standardbutton-closetab-down-16.png")));

    connect(getObjectMap()["mainWindow"], SIGNAL(initDone(void)), this, SLOT(handleInit(void)));
    connect(getObjectMap()["mainWindow"], SIGNAL(exitBegin(QCloseEvent *)), this, SLOT(handleExit(QCloseEvent *)));
    connect(getActionMap()["new"], SIGNAL(triggered(void)), this, SLOT(handleNew(void)));
    connect(getActionMap()["open"], SIGNAL(triggered(void)), this, SLOT(handleOpen(void)));
    connect(getActionMap()["save"], SIGNAL(triggered(void)), this, SLOT(handleSave(void)));
    connect(getActionMap()["saveAs"], SIGNAL(triggered(void)), this, SLOT(handleSaveAs(void)));
    connect(getActionMap()["saveAll"], SIGNAL(triggered(void)), this, SLOT(handleSaveAll(void)));
    connect(getActionMap()["reload"], SIGNAL(triggered(void)), this, SLOT(handleReload(void)));
    connect(getActionMap()["close"], SIGNAL(triggered(void)), this, SLOT(handleClose(void)));
    connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(handleClose(int)));
}
Exemple #5
0
void GraphEditor::updateEnabledActions(void)
{
    if (not this->isVisible()) return;

    getActionMap()["undo"]->setEnabled(_stateManager->isPreviousAvailable());
    getActionMap()["redo"]->setEnabled(_stateManager->isSubsequentAvailable());
    getActionMap()["save"]->setEnabled(not _stateManager->isCurrentSaved());
    getActionMap()["reload"]->setEnabled(not this->getCurrentFilePath().isEmpty());
    getActionMap()["activateTopology"]->setChecked(_isTopologyActive);

    //can we paste something from the clipboard?
    auto mimeData = QApplication::clipboard()->mimeData();
    const bool canPaste = mimeData->hasFormat("text/json/pothos_object_array") and
                      not mimeData->data("text/json/pothos_object_array").isEmpty();
    getActionMap()["paste"]->setEnabled(canPaste);

    //update window title
    QString subtext = this->getCurrentFilePath();
    if (subtext.isEmpty()) subtext = tr("untitled");
    emit this->newTitleSubtext(tr("Editing ") + subtext);
}
Exemple #6
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);
    }
}
Exemple #7
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 #8
0
void GraphEditor::handleEvalEngineDeactivate(void)
{
    getActionMap()["activateTopology"]->setChecked(false);
    _isTopologyActive = false;
}
Exemple #9
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 &)));
}