Exemple #1
0
void
ConeAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ConeAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("angle")) != 0)
        SetAngle(node->AsDouble());
    if((node = searchNode->GetNode("origin")) != 0)
        SetOrigin(node->AsDoubleArray());
    if((node = searchNode->GetNode("normal")) != 0)
        SetNormal(node->AsDoubleArray());
    if((node = searchNode->GetNode("representation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetRepresentation(Representation(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Representation value;
            if(Representation_FromString(node->AsString(), value))
                SetRepresentation(value);
        }
    }
    if((node = searchNode->GetNode("upAxis")) != 0)
        SetUpAxis(node->AsDoubleArray());
    if((node = searchNode->GetNode("cutByLength")) != 0)
        SetCutByLength(node->AsBool());
    if((node = searchNode->GetNode("length")) != 0)
        SetLength(node->AsDouble());
}
Exemple #2
0
mitk::Material::Material(  )
{
  InitializeStandardValues();
  SetColor( GetColor() );
  SetColorCoefficient( GetColorCoefficient() );
  SetSpecularColor( GetSpecularColor() );
  SetSpecularCoefficient( GetSpecularCoefficient() );
  SetSpecularPower( GetSpecularPower() );
  SetOpacity( GetOpacity() );
  SetInterpolation( GetInterpolation() );
  SetRepresentation( GetRepresentation() );
  SetLineWidth( GetLineWidth() );
}
Exemple #3
0
mitk::Material::Material( mitk::Material::Color color, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity )
{
  InitializeStandardValues();
  SetColor( color );
  SetColorCoefficient( colorCoefficient );
  SetSpecularColor( GetSpecularColor() );
  SetSpecularCoefficient( specularCoefficient );
  SetSpecularPower( specularPower );
  SetOpacity( opacity );
  SetInterpolation( GetInterpolation() );
  SetRepresentation( GetRepresentation() );
  SetLineWidth( GetLineWidth() );
}
Exemple #4
0
mitk::Material::Material( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity )
{
  InitializeStandardValues();
  SetColor( red, green, blue );
  SetColorCoefficient( GetColorCoefficient() );
  SetSpecularColor( GetSpecularColor() );
  SetSpecularCoefficient( GetSpecularCoefficient() );
  SetSpecularPower( GetSpecularPower() );
  SetOpacity( opacity );
  SetInterpolation( GetInterpolation() );
  SetRepresentation( GetRepresentation() );
  SetLineWidth( GetLineWidth() );
  m_Name = "";
}
Exemple #5
0
mitk::Material::Material( Color color, double opacity )
{
  InitializeStandardValues();
  SetColor( color );
  SetColorCoefficient( GetColorCoefficient() );
  SetSpecularColor( GetSpecularColor() );
  SetSpecularCoefficient( GetSpecularCoefficient() );
  SetSpecularPower( GetSpecularPower() );
  SetOpacity( opacity );
  SetInterpolation( GetInterpolation() );
  SetRepresentation( GetRepresentation() );
  SetLineWidth( GetLineWidth() );
  m_Name = "";
}
Exemple #6
0
mitk::Material::Material( double red, double green, double blue,
    double colorCoefficient, double specularCoefficient,
    double specularPower, double opacity )
{
  InitializeStandardValues();
  SetColor( red, green, blue );
  SetColorCoefficient( colorCoefficient );
  SetSpecularColor( GetSpecularColor() );
  SetSpecularCoefficient( specularCoefficient );
  SetSpecularPower( specularPower );
  SetOpacity( opacity );
  SetInterpolation( GetInterpolation() );
  SetRepresentation( GetRepresentation() );
  SetLineWidth( GetLineWidth() );
  m_Name = "";
}
Exemple #7
0
void RendererImplementationBase3D::initialize()
{
    if (m_isInitialized)
    {
        return;
    }

    // -- lights --

    m_lightKit = vtkSmartPointer<vtkLightKit>::New();
    m_lightKit->SetKeyLightIntensity(1.0);


    // -- render (window) --

    m_renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

    m_viewportSetups.resize(renderView().numberOfSubViews());

    for (unsigned int subViewIndex = 0; subViewIndex < renderView().numberOfSubViews(); ++subViewIndex)
    {
        auto & viewport = m_viewportSetups[subViewIndex];

        auto renderer = vtkSmartPointer<vtkRenderer>::New();
        renderer->SetBackground(1, 1, 1);

        renderer->RemoveAllLights();
        m_lightKit->AddLightsToRenderer(renderer);

        viewport.renderer = renderer;
        m_renderWindow->AddRenderer(renderer);


        auto titleWidget = vtkSmartPointer<vtkTextWidget>::New();
        viewport.titleWidget = titleWidget;
        titleWidget->SetDefaultRenderer(viewport.renderer);
        titleWidget->SetCurrentRenderer(viewport.renderer);

        auto titleRepr = vtkSmartPointer<vtkTextRepresentation>::New();
        auto titleActor = titleRepr->GetTextActor();
        titleActor->GetTextProperty()->SetColor(0, 0, 0);
        titleActor->GetTextProperty()->SetVerticalJustificationToTop();
        FontHelper::configureTextProperty(*titleActor->GetTextProperty());

        titleRepr->GetPositionCoordinate()->SetValue(0.2, .85);
        titleRepr->GetPosition2Coordinate()->SetValue(0.6, .10);
        titleRepr->GetBorderProperty()->SetColor(0.2, 0.2, 0.2);

        titleWidget->SetRepresentation(titleRepr);
        titleWidget->SetTextActor(titleActor);
        titleWidget->SelectableOff();

        viewport.axesActor = createAxes();
        renderer->AddViewProp(viewport.axesActor);
    }

    // -- interaction --

    m_interactorStyle = vtkSmartPointer<CameraInteractorStyleSwitch>::New();
    m_interactorStyle->SetCurrentRenderer(m_viewportSetups.front().renderer);

    m_interactorStyle->addStyle("InteractorStyleTerrain", vtkSmartPointer<InteractorStyleTerrain>::New());
    m_interactorStyle->addStyle("InteractorStyleImage", vtkSmartPointer<InteractorStyleImage>::New());

    // correctly show axes and labels based on the interaction style and resulting camera setup
    m_interactorStyle->AddObserver(InteractorStyleSwitch::StyleChangedEvent,
        this, &RendererImplementationBase3D::updateAxes);


    m_pickerHighlighter = vtkSmartPointer<PickerHighlighterInteractorObserver>::New();

    connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::pickedInfoChanged,
        &m_renderView, &AbstractRenderView::showInfoText);
    connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::dataPicked,
        [this] (const VisualizationSelection & selection)
    {
        if (selection.isEmpty())
        {
            m_renderView.clearSelection();
        }
        else
        {
            m_renderView.setVisualizationSelection(selection);
        }
    });
    connect(m_pickerHighlighter, &PickerHighlighterInteractorObserver::geometryChanged,
        this, &RendererImplementation::render);

    m_cursorCallback = std::make_unique<RenderWindowCursorCallback>();
    m_cursorCallback->setRenderWindow(m_renderWindow);

    m_isInitialized = true;
}