Thanks for help, I´m sending the .h and .cpp code.
VTKViewAxial.h
#ifndef __VtkViewAxial_h
#define __VtkViewAxial_h
#pragma once
#include "implantplandoc.h"
#include "vtkRenderer.h"
#include "vtkWin32OpenGLRenderWindow.h"
#include "vtkWin32RenderWindowInteractor.h"
#include "vtkInteractorStyleImage.h"
#include "interactorvtkview.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkImageData.h"
#include "vtkVolumeTextureMapper3D.h"
#include "vtkFixedPointVolumeRayCastMapper.h"
#include "vtkDICOMImageReader.h"
#include "VtkWrapperText.h"
#include "vtkcommand.h"
#include "vtkDistanceWidget.h"
#include "vtkseedwidget.h"
#include "vtkDistanceRepresentation2D.h"
#include "vtkmath.h"
#include "vtkaxisactor2d.h"
#include "vtkPointHandleRepresentation2D.h"
#include "vtkProperty2D.h"
#include "vtkImageActor.h"
#include "vtkpointpicker.h"
#include "vtkSeedRepresentation.h"
//#define VTKVIEWAXIAL_CLASSNAME _T("VTKViewAxial") // Window class name
#define FmtStr(str_out, strm) { std::ostringstream oss; oss << strm; str_out = oss.str(); }
class CVTKViewAxial : public CView
{
public: // create from serialization only
CVTKViewAxial();
DECLARE_DYNCREATE(CVTKViewAxial)
class vtkDistanceAxiCallback : public vtkCommand
{
public:
static vtkDistanceAxiCallback *New()
{ return new vtkDistanceAxiCallback; }
void vtkDistanceAxiCallback::Execute(vtkObject*, unsigned long eid, void* callData)
{
if ( eid == vtkCommand::InteractionEvent ||
eid == vtkCommand::EndInteractionEvent ||
eid == vtkCommand::MouseMoveEvent ||
eid == vtkCommand::MouseWheelBackwardEvent ||
eid == vtkCommand::MouseWheelForwardEvent)
{
double pos1[3], pos2[3];
// Modify the measure axis
this->Distance->GetPoint1WorldPosition(pos1);
this->Distance->GetPoint2WorldPosition(pos2);
double dist=sqrt(vtkMath::Distance2BetweenPoints(pos1,pos2));
//double dist=(pos1[0]>pos2[0]?pos1[0]-pos2[0]:pos2[0]-pos1[0]);
//char title[256];
CString title;
this->Distance->GetAxis()->SetRange(0.0,dist);
//sprintf(title,"%-#6.3g mm",dist);
title.Format(_T("%-#6.3g mm"),dist);
this->Distance->GetAxis()->SetTitle(title.GetBuffer());
}
else
{
if (callData == 0)
return;
int pid = *(reinterpret_cast<int*>(callData));
//From the point id, get the display coordinates
double pos1[3], pos2[3], *pos;
this->Distance->GetPoint1DisplayPosition(pos1);
this->Distance->GetPoint2DisplayPosition(pos2);
if ( pid == 0 )
{
pos = pos1;
}
else
{
pos = pos2;
}
// Okay, render without the widget, and get the color buffer
int enabled = this->DistanceWidget->GetEnabled();
if ( enabled )
{
this->DistanceWidget->SetEnabled(0); //does a Render() as a side effect
}
// Pretend we are doing something serious....just randomly bump the
// location of the point.
double p[3];
p[0] = pos[0] + static_cast<int>(vtkMath::Random(-5.5,5.5));
p[1] = pos[1] + static_cast<int>(vtkMath::Random(-5.5,5.5));
p[2] = 0.0;
// Set the new position
if ( pid == 0 )
{
this->Distance->SetPoint1DisplayPosition(p);
}
else
{
this->Distance->SetPoint2DisplayPosition(p);
}
// Side effect of a render here
if ( enabled )
{
this->DistanceWidget->SetEnabled(1);
}
}
}
vtkDistanceAxiCallback():Renderer(0),RenderWindow(0),DistanceWidget(0),Distance(0) {}
vtkRenderer *Renderer;
vtkWin32OpenGLRenderWindow *RenderWindow;
vtkDistanceWidget *DistanceWidget;
vtkDistanceRepresentation2D *Distance;
double *m_pSliceThickness;
long *m_pNumberPixelsAlongAxis;
double *m_pPixelSizeMilimeter;
};
class vtkSeedAxiCallback : public vtkCommand
{
public:
static vtkSeedAxiCallback *New()
{ return new vtkSeedAxiCallback; }
virtual void Execute(vtkObject*, unsigned long eid, void *calldata)
{
if (eid == vtkCommand::PlacePointEvent)
{
numberofseeds = this->SeedRepresentation->GetNumberOfSeeds();
this->SeedRepresentation->GetSeedDisplayPosition(numberofseeds-1, point);
}
}
//vtkCommand::CursorChangedEvent
vtkSeedAxiCallback() : SeedRepresentation(0) {}
vtkSeedRepresentation *SeedRepresentation;
int numberofseeds;
double point[3];
};
class CNavigationBar : public CExtToolControlBar
{
public:
CNavigationBar()
{
}
~CNavigationBar()
{
}
public: //Controls
CExtComboBox m_cmbDistances;
CExtComboBox m_cmbPoints;
public: //methods
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if( message == WM_CONTEXTMENU )
return 0L;
if( message == WM_LBUTTONDOWN
|| message == WM_LBUTTONUP
|| message == WM_MBUTTONDOWN
|| message == WM_MBUTTONUP
|| message == WM_RBUTTONDOWN
|| message == WM_RBUTTONUP
)
{
HWND hWndThis = GetSafeHwnd();
ASSERT( hWndThis != NULL );
ASSERT( ::IsWindow( hWndThis ) );
HWND hWndParent = ::GetParent( hWndThis );
ASSERT( hWndParent != NULL );
ASSERT( ::IsWindow( hWndParent ) );
HWND hWndFocus = ::GetFocus();
if( hWndFocus == NULL
|| hWndFocus == hWndThis
|| ::IsChild( hWndThis, hWndFocus )
)
::SetFocus( hWndParent );
else if( ! ::IsChild( hWndParent, hWndFocus ) )
::SetFocus( hWndParent );
}
return CExtToolControlBar::WindowProc(message,wParam,lParam);
}
bool InitNavigationBar()
{
m_bPresubclassDialogMode = true;
LPCTSTR pn = AfxGetApp()->m_pszProfileName;
if( !m_cmbDistances.Create(
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN, CRect( 0, 0, 150, 180 ), this, //&m_wndToolBarMain,
ID_TBAV_CMBDISTANCES)
|| !this->SetButtonCtrl(this->CommandToIndex(m_cmbDistances.GetDlgCtrlID()), &m_cmbDistances))
{
TRACE0("Failed to create help search combobox\n" );
return -1;
}
m_cmbDistances.SetItemHeight( -1, 16 );
m_cmbDistances.SetFont( &g_PaintManager->m_FontNormal );
g_CmdManager->CmdGetPtr(pn, m_cmbDistances.GetDlgCtrlID())->m_sMenuText = _T( "Measures" );
if( !m_cmbPoints.Create(
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN, CRect( 0, 0, 150, 180 ), this, //&m_wndToolBarMain,
ID_TBAV_CMBPOINTS)
|| !this->SetButtonCtrl(this->CommandToIndex(m_cmbPoints.GetDlgCtrlID()), &m_cmbPoints))
{
TRACE0("Failed to create help search combobox\n" );
return -1;
}
m_cmbPoints.SetItemHeight( -1, 16 );
m_cmbPoints.SetFont( &g_PaintManager->m_FontNormal );
g_CmdManager->CmdGetPtr(pn, m_cmbPoints.GetDlgCtrlID())->m_sMenuText = _T( "Points" );
return true;
}
}; // class CNavigationBar
CNavigationBar m_wndToolbar;
public:
virtual ~CVTKViewAxial();
virtual void OnDraw(CDC* pDC); // overridden to draw this view
void Pipeline ( void );
void ResetSize(int cx, int cy);
enum {WIDGET_NULL, WIDGET_RULER, WIDGET_SEED};
protected:
//BOOL RegisterWindowClass();
public:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
private:
//renderrizacao
vtkRenderer *m_ren;
vtkWin32OpenGLRenderWindow *m_renWin;
vtkWin32RenderWindowInteractor *m_iren;
vtkInteractorStyleImage *m_irenStyle;
//CInteractorVTKView *m_irenStyle;
//widget distance
vtkPointHandleRepresentation2D* m_pPtDistHandle2D;
vtkDistanceRepresentation2D* m_pDistRepr2D;
vtkDistanceWidget* m_pDistWidget;
vtkDistanceAxiCallback* m_DistCallback;
//vtkPointPicker* picker;
//vtkPickerAxiCallback* m_PickerCallback;
vtkSeedWidget* m_pSeedWidget;
vtkSeedAxiCallback* m_SeedCallback;
vtkPointHandleRepresentation2D* m_pSeedHandle;
vtkSeedRepresentation* m_pSeedRepr;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
public:
//{{AFX_MSG(CVTKViewAxial)
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
double m_zslicepos;
int m_zsliceidx;
public:
CImplantDoc* GetMainFrmDoc(void);
protected:
virtual void PostNcDestroy();
int m_flg_ResetCamera;
public:
void NewMeasureDistance(void);
protected:
int m_flg_widget;
int m_flg_widget_selected;
public:
void WidgetSelection(void);
void NewSeed(void);
};
#endif
VTKViewAxial.CPP
#include "stdafx.h"
#include "ImplantPlan.h"
#include "VTKViewAxial.h"
#include "mainfrm.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkContourFilter.h"
#include "vtkImageData.h"
#include "vtkImageMapToColors.h"
#include "vtkimagemapper.h"
#include "vtkLight.h"
#include "vtkLookupTable.h"
#include "vtkOutlineFilter.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkPropPicker.h"
#include "vtkProperty.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkStripper.h"
#include "VtkObserverWindowLevel.h"
#include "VtkObserverErrorWarning.h"
#include "VtkObserverFileLoad.h"
#include "dlgnewmeasuredistance.h"
#include "measuredistance.h"
#include "vtkWidgetEvent.h"
#include "vtkAxisActor.h"
#include "vtkAxisActor2D.h"
#include "vtkCubeAxesActor2D.h"
#include "vtkTextProperty.h"
#include <string>
#include <sstream>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CVTKViewAxial
IMPLEMENT_DYNCREATE(CVTKViewAxial, CView)
BEGIN_MESSAGE_MAP(CVTKViewAxial, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND(ID_TBAV_DISTANCE, CVTKViewAxial::NewMeasureDistance)
ON_COMMAND(ID_TBAV_SEED, CVTKViewAxial::NewSeed)
ON_WM_SIZE()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
CVTKViewAxial::CVTKViewAxial()
: m_flg_ResetCamera(true)
, m_flg_widget(0)
, m_flg_widget_selected(0)
,m_zslicepos(0)
,m_zsliceidx(-1)
{
//this->RegisterWindowClass();
this->m_ren = vtkRenderer::New();
this->m_renWin = vtkWin32OpenGLRenderWindow::New();
this->m_iren = vtkWin32RenderWindowInteractor::New();
this->m_irenStyle = vtkInteractorStyleImage::New();
//this->m_irenStyle = CInteractorVTKView::New();
this->m_iren->SetInteractorStyle(m_irenStyle);
}
CVTKViewAxial::~CVTKViewAxial()
{
// Delete the the renderer, window and interactor objects.
//this->m_iren->RemoveObserver(m_PickerCallback);
this->m_flg_widget = this->WIDGET_NULL;
this->WidgetSelection();
this->m_ren->Delete();
this->m_iren->Delete();
this->m_renWin->Delete();
}
void CVTKViewAxial::OnDraw(CDC* pDC)
{
CImplantDoc* pDoc = this->GetMainFrmDoc();
//ASSERT_VALID(pDoc);
if ( !this->m_iren->GetInitialized() )
{
this->m_iren->Initialize();
Pipeline();
CRect rect;
this->GetClientRect(&rect);
RepositionBars( 0, 0xFFFF, 0);
this->m_renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);
}
else
Pipeline();
if ( pDC->IsPrinting() )
{
this->BeginWaitCursor();
// Obtain the size of the printer page in pixels.
int cxPage = pDC->GetDeviceCaps(HORZRES);
int cyPage = pDC->GetDeviceCaps(VERTRES);
// Get the size of the window in pixels.
int *size = this->m_renWin->GetSize();
int cxWindow = size[0];
int cyWindow = size[1];
float fx = float(cxPage) / float(cxWindow);
float fy = float(cyPage) / float(cyWindow);
float scale; // = min(fx,fy);
if (fx < fy)
scale = fx;
else
scale = fy;
int x = int(scale * float(cxWindow));
int y = int(scale * float(cyWindow));
this->m_renWin->SetupMemoryRendering(cxWindow, cyWindow, pDC->GetSafeHdc());
this->m_renWin->Render();
HDC memDC = this->m_renWin->GetMemoryDC();
StretchBlt(pDC->GetSafeHdc(),0,0,x,y,memDC,0,0,cxWindow,cyWindow,SRCCOPY);
this->m_renWin->ResumeScreenRendering();
this->EndWaitCursor();
}
}
void CVTKViewAxial::ResetSize(int cx, int cy)
{
// Reset the render window size, reposition the text actors.
this->m_renWin->SetSize(cx, cy);
}
void CVTKViewAxial::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
CRect rect;
this->GetClientRect(&rect);
RepositionBars( 0, 0xFFFF, 0);
this->m_renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);
}
BOOL CVTKViewAxial::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
BOOL CVTKViewAxial::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
if ((CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))==-1)
return false;
this->m_renWin->AddRenderer(this->m_ren);
//this->m_renWin->SetParentId(this->m_hWnd);
this->m_renWin->SetParentId(this->GetSafeHwnd());
this->m_iren->SetRenderWindow(this->m_renWin);
m_wndToolbar.m_bPresubclassDialogMode = true;
if( !m_wndToolbar.Create(_T(""), this, AFX_IDW_DIALOGBAR, WS_CHILD|WS_VISIBLE
|CBRS_ALIGN_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC))
{
ASSERT( FALSE );
return -1;
}
if( !m_wndToolbar.LoadToolBar(IDR_TOOLBAR_AXIALVIEW) )
{
ASSERT( FALSE );
return -1;
}
if(!m_wndToolbar.InitNavigationBar())
return -1;
RepositionBars(0, 0xFFFF, 0);
return true;
}
LRESULT CVTKViewAxial::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
//case WM_PAINT:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
case WM_CHAR:
case WM_TIMER:
if (this->m_iren->GetInitialized())
{
return vtkHandleMessage2(this->GetSafeHwnd(), message, wParam, lParam, this->m_iren);
}
break;
}
return CView::WindowProc(message, wParam, lParam);
}
void CVTKViewAxial::Pipeline()
{
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if (pFrame->m_pDoc == NULL)
return;
if (!pFrame->m_pDoc->m_flg_img3D_Loaded)
return;
if (pFrame->m_wndView.m_flg_widget_selected != pFrame->m_wndView.WIDGET_3D)
return;
if (this->m_zsliceidx != pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex())
{
this->m_zsliceidx = pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex();
this->m_zslicepos = pFrame->m_wndView.m_planeWidgetZ->GetSlicePosition();
//this->m_DistCallback->m_pNumberPixelsAlongAxis = &pFrame->m_pDoc->m_0028_0100_NumberPixelsAlongAxis;
//this->m_DistCallback->m_pPixelSizeMilimeter = &pFrame->m_pDoc->m_0028_0030_PixelSizeMilimeter;
//this->m_DistCallback->m_pSliceThickness = &pFrame->m_pDoc->m_0018_0050_SliceThickness;
//if (this->m_ren->GetNumberOfPropsRendered() > 0)
//{
// this->m_ren->RemoveAllProps();
// this->m_ren->RemoveAllViewProps();
//}
vtkImageMapToColors* colorMap = vtkImageMapToColors::New();
colorMap->PassAlphaToOutputOff();
colorMap->SetActiveComponent(0);
colorMap->SetOutputFormatToLuminance();
colorMap->SetInput(pFrame->m_wndView.m_planeWidgetZ->GetResliceOutput());
colorMap->SetLookupTable(pFrame->m_wndView.m_planeWidgetX->GetLookupTable());
vtkImageActor* imageActor = vtkImageActor::New();
imageActor->SetInput(colorMap->GetOutput());
imageActor->PickableOff();
imageActor->SetPosition(0, 0, 0);
double iabounds[6];
imageActor->GetBounds(iabounds);
double *center = imageActor->GetCenter();
vtkTextProperty* tprop = vtkTextProperty::New();
tprop->SetColor(0, 0, 1);
vtkCubeAxesActor2D* axes2 = vtkCubeAxesActor2D::New();
axes2->SetViewProp(imageActor);
axes2->SetCamera(this->m_ren->GetActiveCamera());
axes2->SetLabelFormat("%6.4g");
axes2->SetFlyModeToClosestTriad();
axes2->SetFontFactor(1);
axes2->ScalingOn();
axes2->SetAxisTitleTextProperty(tprop);
axes2->SetAxisLabelTextProperty(tprop);
axes2->SetNumberOfLabels(10);
axes2->SetZAxisVisibility(false);
this->m_ren->AddViewProp(axes2);
axes2->GetXAxisActor2D()->GetProperty()->SetColor(0, 0, 1);
axes2->GetYAxisActor2D()->GetProperty()->SetColor(0, 0, 1);
this->m_ren->AddActor(imageActor);
this->m_renWin->Render();
if (this->m_flg_ResetCamera)
{
this->m_ren->ResetCamera();
this->m_flg_ResetCamera = false;
}
colorMap->Delete();
imageActor->Delete();
axes2->Delete();
tprop->Delete();
} //if (this->m_zsliceidx != pFrame->m_wndView.m_planeWidgetZ->GetSliceIndex())
}
// CVTKViewAxialCoronal printing
BOOL CVTKViewAxial::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CVTKViewAxial::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
void CVTKViewAxial::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
// CVTKViewAxial diagnostics
#ifdef _DEBUG
void CVTKViewAxial::AssertValid() const
{
CView::AssertValid();
}
void CVTKViewAxial::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
CImplantDoc* CVTKViewAxial::GetMainFrmDoc(void)
{
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
return pFrame->GetDocument();
}
void CVTKViewAxial::PostNcDestroy()
{
return;
}
void CVTKViewAxial::NewMeasureDistance(void)
{
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if (pFrame->m_pDoc == NULL)
return;
if (!pFrame->m_pDoc->m_flg_img3D_Loaded)
return;
CDlgNewMeasureDistance dlg;
dlg.m_axis = pFrame->A_AXIS;
if (!dlg.DoModal())
return;
this->m_flg_widget = this->WIDGET_RULER;
this->WidgetSelection();
}
void CVTKViewAxial::WidgetSelection(void)
{
/*
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if (pFrame->m_pDoc == NULL)
return;
if (!pFrame->m_pDoc->m_flg_img3D_Loaded)
return;+
*/
if ((this->m_flg_widget_selected == this->WIDGET_RULER) &&
(this->m_flg_widget != this->WIDGET_RULER))
{
m_pDistWidget->RemoveObserver(m_DistCallback);
m_DistCallback->Delete();
m_pDistWidget->Delete();
m_pDistRepr2D->Delete();
m_pPtDistHandle2D->Delete();
}
if ((this->m_flg_widget_selected == this->WIDGET_SEED) &&
(this->m_flg_widget != this->WIDGET_SEED))
{
m_pSeedWidget->RemoveObserver(m_SeedCallback);
m_SeedCallback->Delete();
m_pSeedWidget->Delete();
m_pSeedRepr->Delete();
m_pSeedHandle->Delete();
}
if (m_flg_widget == this->WIDGET_NULL)
return;
if ((this->m_flg_widget_selected != this->WIDGET_RULER) &&
(this->m_flg_widget == this->WIDGET_RULER))
{
//distance
// Create the widget and its representation
m_pPtDistHandle2D = vtkPointHandleRepresentation2D::New();
m_pPtDistHandle2D->GetProperty()->SetColor(1,0,0);
m_pDistRepr2D = vtkDistanceRepresentation2D::New();
m_pDistRepr2D->SetHandleRepresentation(m_pPtDistHandle2D);
m_pDistRepr2D->GetAxis()->SetNumberOfMinorTicks(4);
m_pDistRepr2D->GetAxis()->SetTickLength(9);
m_pDistRepr2D->GetAxis()->SetTitlePosition(0.2);
m_pDistWidget = vtkDistanceWidget::New();
m_pDistWidget->SetInteractor(this->m_iren);
m_pDistWidget->CreateDefaultRepresentation();
m_pDistWidget->SetRepresentation(m_pDistRepr2D);
m_DistCallback = vtkDistanceAxiCallback::New();
m_DistCallback->Renderer = this->m_ren;
m_DistCallback->RenderWindow = this->m_renWin;
m_DistCallback->Distance = m_pDistRepr2D;
m_DistCallback->DistanceWidget = m_pDistWidget;
m_DistCallback->m_pNumberPixelsAlongAxis = NULL;
m_DistCallback->m_pPixelSizeMilimeter = NULL;
m_DistCallback->m_pSliceThickness = NULL;
m_pDistWidget->AddObserver(vtkDistanceAxiCallback::AnyEvent, m_DistCallback);
m_pDistWidget->On();
}
if ((this->m_flg_widget_selected != this->WIDGET_SEED) &&
(this->m_flg_widget == this->WIDGET_SEED))
{
//seed
m_pSeedHandle = vtkPointHandleRepresentation2D::New();
m_pSeedHandle->GetProperty()->SetColor(1,0,0);
m_pSeedRepr = vtkSeedRepresentation::New();
m_pSeedRepr->SetHandleRepresentation(m_pSeedHandle);
m_pSeedWidget = vtkSeedWidget::New();
m_pSeedWidget->SetInteractor(this->m_iren);
m_pSeedWidget->SetRepresentation(m_pSeedRepr);
m_SeedCallback = vtkSeedAxiCallback::New();
m_SeedCallback->SeedRepresentation = m_pSeedRepr;
m_pSeedWidget->AddObserver(vtkCommand::PlacePointEvent,m_SeedCallback);
m_pSeedWidget->AddObserver(vtkCommand::InteractionEvent,m_SeedCallback);
m_pSeedWidget->On();
}
this->m_flg_widget_selected = this->m_flg_widget;
}
void CVTKViewAxial::NewSeed(void)
{
this->m_flg_widget = this->WIDGET_SEED;
this->WidgetSelection();
}