nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

Two or more scenes and views

Open Philius opened this issue 2 years ago • 2 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.

Philius avatar Dec 30 '22 12:12 Philius

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

paceholder avatar Jan 05 '23 12:01 paceholder

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.

Philius avatar Jan 25 '23 06:01 Philius