[vtkusers] changing LUT in MIP via vtkPiecewiseFunction and vtkColorTransferFunction
Sergey Alyoshin
4memph at gmail.com
Fri Dec 11 10:29:35 EST 2009
Hellow everyone,
I'm developing PACS-system with MIP-plugin which can view Maximum Intensity
Projection of DICOM images ( mainly CT-slices) and now i'm having troubles
with programming mouse handler in which i should change LUT or use
predefined handler in vtkWin32RenderWindowInteractor - these actions are
made subject to the user's choise. The trouble is that if hte LUT changing
tool is chosen the LUT parameters don't change at all. The part of code
where the handler decides what to do is below ( CVRWindowInteractor is
derived from vtkWin32RenderWindowInteractor ). if i'm not mistaken, i should
invoke some methods to apply the changes in m_pOpacityFun
(vtkPiecewiseFunction ) and m_pColorFun (vtkColorTransferFunction), but i
don't know which. Could you please tell me where i'm wrong.
Thank you for your reply.
void CVRWindowInteractor::OnLButtonDown( HWND wnd, UINT nFlags, int X, intY,
int repeat )
{
if (!this->Enabled)
{
return;
}
if ( MIP_LUTChange == m_Mode )
{
SetFocus( wnd );
SetCapture( wnd );
m_pLUTChangeControl->ChangeWin( 0, 0, false );
int WinCenter = 0;
int WinWidth = 0;
m_pLUTChangeControl->GetCW( &WinCenter, &WinWidth );
m_pOpacityFun->RemoveAllPoints();
double lfCenter = ( WinCenter - m_lfaCastRange[ 0 ] ) * (
VTK_UNSIGNED_SHORT_MAX /
( m_lfaCastRange[ 1 ] - m_lfaCastRange[ 0 ] ) );
double lfWindow = ( WinWidth - m_lfaCastRange[ 0 ] ) * (
VTK_UNSIGNED_SHORT_MAX /
( m_lfaCastRange[ 1 ] - m_lfaCastRange[ 0 ] ) );
m_pOpacityFun->AddPoint( lfCenter - lfWindow / 2, 0.0 );
m_pOpacityFun->AddPoint( lfCenter + lfWindow / 2, 1.0 );
m_pColorFun->BuildFunctionFromTable( lfCenter - lfWindow / 2, lfCenter +
lfWindow / 2,
VTK_UNSIGNED_CHAR_MAX + 1 , (double*)( &m_lfaColorTable ) );
}
else if ( MIP_Rotate == m_Mode )
{
SetFocus( wnd );
SetCapture( wnd );
this->SetEventInformationFlipY( X,
Y,
nFlags & MK_CONTROL,
nFlags & MK_SHIFT,
0, repeat);
this->SetAltKey( GetKeyState( VK_MENU ) & (~1) );
this->InvokeEvent( vtkCommand::LeftButtonPressEvent, NULL );
}
}
void CVRWindowInteractor::OnMouseMove( HWND wnd, UINT nFlags, int X, int Y )
{
if (!this->Enabled)
{
return;
}
if ( ( MIP_LUTChange == m_Mode ) && ( MK_LBUTTON == nFlags ) )
{
if ( !this->MouseInWindow &&
( X >= 0 && X < this->Size[ 0 ] && Y >= 0 && Y < this->Size[ 1 ] ) )
{
m_pLUTChangeControl->ChangeWin( X, Y, true );
int WinCenter = 0;
int WinWidth = 0;
m_pLUTChangeControl->GetCW( &WinCenter, &WinWidth );
m_pOpacityFun->RemoveAllPoints();
double lfCenter = ( WinCenter - m_lfaCastRange[ 0 ] ) * (
VTK_UNSIGNED_SHORT_MAX /
( m_lfaCastRange[ 1 ] - m_lfaCastRange[ 0 ] ) );
double lfWindow = ( WinWidth - m_lfaCastRange[ 0 ] ) * (
VTK_UNSIGNED_SHORT_MAX /
( m_lfaCastRange[ 1 ] - m_lfaCastRange[ 0 ] ) );
m_pOpacityFun->AddPoint( lfCenter - lfWindow / 2, 0.0 );
m_pOpacityFun->AddPoint( lfCenter + lfWindow / 2, 1.0 );
m_pColorFun->BuildFunctionFromTable( lfCenter - lfWindow / 2, lfCenter +
lfWindow / 2,
VTK_UNSIGNED_CHAR_MAX + 1 , (double*)( &m_lfaColorTable ) );
}
}
else if ( MIP_Rotate == m_Mode )
{
this->SetEventInformationFlipY( X,
Y,
nFlags & MK_CONTROL,
nFlags & MK_SHIFT );
this->SetAltKey( GetKeyState( VK_MENU ) & ( ~1 ) );
if ( !this->MouseInWindow &&
( X >= 0 && X < this->Size[ 0 ] && Y >= 0 && Y < this->Size[ 1 ] ) )
{
this->InvokeEvent(vtkCommand::EnterEvent, NULL);
this->MouseInWindow = 1;
// request WM_MOUSELEAVE generation
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = wnd;
TrackMouseEvent(&tme);
}
this->InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091211/1f6ae8c8/attachment.htm>
More information about the vtkusers
mailing list