示例#1
0
void RendererImplementationPlot::onAddContent(AbstractVisualizedData * content, unsigned int /*subViewIndex*/)
{
    assert(dynamic_cast<Context2DData *>(content));
    auto contextData = static_cast<Context2DData *>(content);

    auto items = vtkSmartPointer<vtkPlotCollection>::New();

    vtkCollectionSimpleIterator it;
    contextData->plots()->InitTraversal(it);
    while (auto item = contextData->plots()->GetNextPlot(it))
    {
        items->AddItem(item);
        m_chart->AddPlot(item);
    }

    assert(!m_plots.contains(contextData));
    m_plots.insert(contextData, items);


    addConnectionForContent(content,
        connect(contextData, &Context2DData::plotCollectionChanged,
        [this, contextData] () { fetchContextItems(contextData); }));

    addConnectionForContent(content,
        connect(contextData, &Context2DData::visibilityChanged,
        [this, contextData] (bool) { dataVisibilityChanged(contextData); }));

    dataVisibilityChanged(contextData);
}
示例#2
0
void RendererImplementationBase3D::onAddContent(AbstractVisualizedData * content, unsigned int subViewIndex)
{
    assert(dynamic_cast<RenderedData *>(content));
    auto renderedData = static_cast<RenderedData *>(content);

    renderedData->colorMapping().colorBarRepresentation().setContext(
        m_renderWindow->GetInteractor(),
        renderer(subViewIndex));

    auto props = vtkSmartPointer<vtkPropCollection>::New();

    auto && renderer = this->renderer(subViewIndex);
    auto && dataProps = m_viewportSetups[subViewIndex].dataProps;

    vtkCollectionSimpleIterator it;
    renderedData->viewProps()->InitTraversal(it);
    while (auto prop = renderedData->viewProps()->GetNextProp(it))
    {
        props->AddItem(prop);
        renderer->AddViewProp(prop);
    }

    assert(!dataProps.contains(renderedData));
    dataProps.insert(renderedData, props);

    addConnectionForContent(content,
        connect(renderedData, &RenderedData::viewPropCollectionChanged,
        [this, renderedData, subViewIndex] () { fetchViewProps(renderedData, subViewIndex); }));

    addConnectionForContent(content,
        connect(renderedData, &RenderedData::visibilityChanged,
        [this, renderedData, subViewIndex] (bool) { dataVisibilityChanged(renderedData, subViewIndex); }));

    dataVisibilityChanged(renderedData, subViewIndex);
}
示例#3
0
void RendererImplementationBase3D::onRemoveContent(AbstractVisualizedData * content, unsigned int subViewIndex)
{
    assert(dynamic_cast<RenderedData *>(content));
    auto renderedData = static_cast<RenderedData *>(content);

    // update camera and axes. signal/slots are already disconnected for this object, so explicitly trigger the updates
    if (content->isVisible())
    {
        content->setVisible(false);
        dataVisibilityChanged(renderedData, subViewIndex);
    }
    else
    {
        assert(selection().visualization != content);
    }

    auto & renderer = *this->renderer(subViewIndex);
    auto & dataProps = m_viewportSetups[subViewIndex].dataProps;

    vtkSmartPointer<vtkPropCollection> props = dataProps.take(renderedData);
    assert(props);

    vtkCollectionSimpleIterator it;
    props->InitTraversal(it);
    while (auto prop = props->GetNextProp(it))
    {
        renderer.RemoveViewProp(prop);
    }
}