Пример #1
0
void CameraObject::DrawLine( double x1, double y1, double x2, double y2, double color[4] )
{
    double start[3];
    start[0] = x1;
    start[1] = y1;
    start[2] = zMin;
    double end[3];
    end[0] = x2;
    end[1] = y2;
    end[2] = zMin;

    PerViewElementCont::iterator it = m_perViewElements.begin();
    while( it != m_perViewElements.end() )
    {
        View * v = (*it).first;
        if( v->GetType() == THREED_VIEW_TYPE )
        {
            vtkProp3D * line = SimplePropCreator::CreateLine( start, end, color );
            line->SetUserTransform( m_imageTransform );
            GetCurrentRenderer(v)->AddViewProp( line );
            PerViewElements & elem = (*it).second;
            elem.anotations.push_back( line );
        }
        ++it;
    }
}
Пример #2
0
void PolyDataObject::SetTexture( vtkImageData * texImage )
{
    // standard set code
    if( this->Texture )
        this->Texture->UnRegister( this );
    this->Texture = texImage;
    if( this->Texture )
        this->Texture->Register( this );

    // update texture in actor
    PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
    for( ; it != this->polydataObjectInstances.end(); ++it )
    {
        View * view = (*it).first;
        if( view->GetType() == THREED_VIEW_TYPE )
        {
            vtkSmartPointer<vtkActor> actor = (*it).second;
            vtkTexture * tex = actor->GetTexture();
            if( tex )
            {
                if( this->Texture )
                    tex->SetInputData( this->Texture );
                else
                    tex->SetInputData( this->checkerBoardTexture );
            }
        }
    }

    emit ObjectModified();
}
Пример #3
0
void PolyDataObject::Show()
{
    PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
    for( ; it != this->polydataObjectInstances.end(); ++it )
    {
        View * v = (*it).first;
        vtkSmartPointer<vtkActor> actor = (*it).second;
        if( v->GetType() == THREED_VIEW_TYPE || GetCrossSectionVisible() )
            actor->VisibilityOn();
    }
    emit ObjectModified();
}
Пример #4
0
void CameraObject::ClearDrawing()
{
    PerViewElementCont::iterator it = m_perViewElements.begin();
    while( it != m_perViewElements.end() )
    {
        View * v = (*it).first;
        if( v->GetType() == THREED_VIEW_TYPE )
        {
            ClearDrawingOneView( v, (*it).second );
        }
        ++it;
    }
}
Пример #5
0
void PolyDataObject::SetCrossSectionVisible( bool showCrossSection )
{
    this->CrossSectionVisible = showCrossSection;
    if( IsHidden() )
        return;

    PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
    for( ; it != this->polydataObjectInstances.end(); ++it )
    {
        View * v = (*it).first;
        vtkSmartPointer<vtkActor> actor = (*it).second;
        if( v->GetType() != THREED_VIEW_TYPE )
            actor->SetVisibility( showCrossSection ? 1 : 0 );
    }
    emit ObjectModified();
}
Пример #6
0
void CameraObject::InternalDrawPath( std::vector< Vec3 > & p3d, double color[4] )
{
    PerViewElementCont::iterator it = m_perViewElements.begin();
    while( it != m_perViewElements.end() )
    {
        View * v = (*it).first;
        if( v->GetType() == THREED_VIEW_TYPE )
        {
            vtkProp3D * line = SimplePropCreator::CreatePath( p3d, color );
            line->SetUserTransform( m_imageTransform );
            GetCurrentRenderer(v)->AddViewProp( line );
            PerViewElements & elem = (*it).second;
            elem.anotations.push_back( line );
        }
        ++it;
    }
}
Пример #7
0
void CameraObject::DrawTarget( double x, double y, double radius, double color[4] )
{
    double center[3] = { 0.0, 0.0, 0.0 };
    center[0] = x;
    center[1] = y;
    PerViewElementCont::iterator it = m_perViewElements.begin();
    while( it != m_perViewElements.end() )
    {
        View * v = (*it).first;
        if( v->GetType() == THREED_VIEW_TYPE )
        {
            vtkProp3D * p1 = SimplePropCreator::CreateTarget( center, 10.0, color );
            p1->SetUserTransform( m_imageTransform );
            GetCurrentRenderer(v)->AddViewProp( p1 );
            PerViewElements & elem = (*it).second;
            elem.anotations.push_back( p1 );
        }
        ++it;
    }
}
Пример #8
0
void PolyDataObject::SetShowTexture( bool show )
{
    this->showTexture = show;

    if( show )
    {
        // Create the default texture if needed
        if( !this->Texture && !this->checkerBoardTexture )
        {
            int size = 200;
            int squareSize = 5;
            this->checkerBoardTexture = vtkSmartPointer<vtkImageData>::New();
            this->checkerBoardTexture->SetDimensions( size, size, 1 );
            this->checkerBoardTexture->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
            unsigned char * row = (unsigned char*) this->checkerBoardTexture->GetScalarPointer();
            for( int y = 0; y < size; ++y )
            {
                unsigned char * col = row;
                for( int x = 0; x < size; ++x )
                {
                    bool xOn = ( x / squareSize % 2 ) == 0;
                    bool yOn = ( y / squareSize % 2 ) == 0;
                    if( xOn == yOn )
                        *col = 255;
                    else
                        *col = 160;
                    ++col;
                }
                row += size;
            }
        }

        vtkImageData * texture = this->Texture;
        if( !texture )
            texture = this->checkerBoardTexture;

        // Add a vtkTexture to each actor to map the checker board onto object
        View * view = 0;
        vtkSmartPointer<vtkActor> actor;
        PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
        for( ; it != this->polydataObjectInstances.end(); ++it )
        {
            view = (*it).first;
            if( view->GetType() == THREED_VIEW_TYPE )
            {
                actor = (*it).second;
                vtkTexture * tex = vtkTexture::New();
                tex->SetBlendingMode( vtkTexture::VTK_TEXTURE_BLENDING_MODE_MODULATE );
                tex->InterpolateOff();
                tex->RepeatOn();
                tex->SetInputData( texture );
                actor->SetTexture( tex );
                tex->Delete();
            }
        }
    }
    else
    {
        // remove texture from each of the actors
        View * view = 0;
        vtkSmartPointer<vtkActor> actor;
        PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
        for( ; it != this->polydataObjectInstances.end(); ++it )
        {
            view = (*it).first;
            if( view->GetType() == THREED_VIEW_TYPE )
            {
                actor = (*it).second;
                actor->SetTexture( 0 );
            }
        }
    }
    this->UpdatePipeline();
    emit ObjectModified();
}