paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Two or more scenes and views

Philius opened this issue · comments

I tried to get the calculator example to work with two views.
It's a first step in implementing groups.
See the patch. It's got some qDebug() s added but just ignore them.
0001-Calculator-with-two-scenes-plus-some-qDebug-addition.patch.txt
To switch views, double click on the view.
Blender uses Tab to enter/exit a group.
Anyway, when I add a node it appears in both scenes/views, one without the text widget.

Thanks for the patch! I'll have a look asap

I figured it out.
You're storing the embedded QWidgets in the data model, e.g. NumberSourceDataModel.
This fixes it: create two data model registries - they don't need to be the same for embedded scenes anyway.

    std::shared_ptr<NodeDelegateModelRegistry> registry1 = registerDataModels();
    std::shared_ptr<NodeDelegateModelRegistry> registry2 = registerDataModels();

    QWidget mainWidget;

    auto menuBar = new QMenuBar();
    QMenu *menu = menuBar->addMenu("File");
    auto saveAction = menu->addAction("Save Scene");
    auto loadAction = menu->addAction("Load Scene");

    QVBoxLayout *l = new QVBoxLayout(&mainWidget);

    DataFlowGraphModel dataFlowGraphModel1(registry1);
    DataFlowGraphModel dataFlowGraphModel2(registry2);

    l->addWidget(menuBar);
    auto scene1 = new DataFlowGraphicsScene(dataFlowGraphModel1, &mainWidget);
    auto view1 = new CalcGraphicsView(scene1);
    l->addWidget(view1);

    auto scene2 = new DataFlowGraphicsScene(dataFlowGraphModel2, &mainWidget);
    auto view2 = new CalcGraphicsView(scene2);
    l->addWidget(view2);
    view2->hide();

Now, double-clicking anywhere on one scene takes you to the other scene.
That's not ideal, as in Blender you need to have the group node selected in order to tab into it, but at least it's a start.