Process::GraphicsViewLayerModelPanelProxy::GraphicsViewLayerModelPanelProxy( const Process::LayerModel& model, QObject* parent): LayerModelPanelProxy{parent}, m_layer{model}, m_context{iscore::IDocument::documentContext(model), m_dispatcher} { // Setup the view m_widget = new QWidget; m_scene = new QGraphicsScene(this); m_scene->setItemIndexMethod(QGraphicsScene::NoIndex); m_widget->setLayout(new QVBoxLayout); m_view = new ProcessGraphicsView{m_scene}; m_widget->layout()->addWidget(m_view); m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(m_view, &ProcessGraphicsView::sizeChanged, this, &GraphicsViewLayerModelPanelProxy::on_sizeChanged); m_zoomSlider = new DoubleSlider{m_widget}; m_zoomSlider->setValue(0.03); // 30 seconds by default on an average screen connect(m_zoomSlider, &DoubleSlider::valueChanged, this, &GraphicsViewLayerModelPanelProxy::on_zoomChanged); m_widget->layout()->addWidget(m_zoomSlider); m_view->show(); // Setup the model auto& sharedmodel = m_layer.processModel(); auto fact = iscore::AppContext().components.factory<ProcessList>().get(sharedmodel.concreteFactoryKey()); m_obj = new ProcessPanelGraphicsProxy{}; // Add the items to the scene early because // the presenters might call scene() in their ctor. m_scene->addItem(m_obj); m_layerView = fact->makeLayerView(m_layer, m_obj); m_processPresenter = fact->makeLayerPresenter(m_layer, m_layerView, m_context, this); // Have a zoom here too. For now the process should be the size of the window. on_sizeChanged(m_view->size()); on_zoomChanged(0.03); }
void ProcessPanelPresenter::on_focusedViewModelChanged(const LayerModel* theLM) { if(theLM != m_layerModel) { m_layerModel = theLM; delete m_processPresenter; m_processPresenter = nullptr; if(!m_layerModel) return; auto& sharedmodel = m_layerModel->sharedProcessModel(); auto fact = ProcessList::getFactory(sharedmodel.processName()); auto proxy = m_layerModel->make_panelProxy(this); delete m_obj; m_obj = new ProcessPanelGraphicsProxy{*theLM, *this}; // Add the items to the scene early because // the presenters might call scene() in their ctor. auto panelview = static_cast<ProcessPanelView*>(view()); panelview->scene()->addItem(m_obj); m_layer = fact->makeView(proxy->viewModel(), m_obj); m_processPresenter = fact->makePresenter(proxy->viewModel(), m_layer, this); connect(m_layerModel, &QObject::destroyed, this, &ProcessPanelPresenter::cleanup); // Have a zoom here too. For now the process should be the size of the window. on_sizeChanged(panelview->view()->size()); on_zoomChanged(0.03); } }